import { CachedAccessToken, ConnectionMetadata, ITokenCacheStorage } from "../types"; export interface OAuthTokenResponse { access_token: string; refresh_token?: string; expires_in?: number; token_type?: string; scope?: string; [key: string]: unknown; } export interface OAuthInstallContext { user_id: string; account_id?: string; workspace_id?: string; provider?: string; scopes?: string[]; metadata?: Record; } export interface OAuthInstallUrlResult { url: string; state: string; provider?: string; scopes: string[]; } export interface OAuthCallbackPayload { code: string; state: string; provider?: string; metadata?: Record; } export interface OAuthLifecycleState { user_id: string; account_id?: string; workspace_id?: string; provider?: string; metadata?: Record; } export interface OAuthLifecycleOptions { clientId?: string; clientSecret?: string; redirectUri?: string; authorizeBaseUrl?: string; tokenUrl?: string; cacheStorage?: ITokenCacheStorage; cacheTtlFallbackSeconds?: number; tokenBodyFormat?: "form" | "json"; stateSecret?: string; } export interface OAuthRuntimeShape { [key: string]: unknown; hostname: string; headers: Record; metadata?: Record; } export type OAuthAuthorizationParams = Record; type OAuthConnectionLike = { provider: string; }; export interface OAuthLifecycleAdapter { resolveScopes(context: TInstallContext): string[] | Promise; buildState(context: TInstallContext): OAuthLifecycleState; buildRuntime(connection: TConnection, accessToken: string): TRuntime; handleCallbackResult(args: { payload: OAuthCallbackPayload; state: OAuthLifecycleState; tokens: OAuthTokenResponse; }): Promise; getAuthorizationParams?(context: TInstallContext): OAuthAuthorizationParams | Promise; getRefreshToken(connection: TConnection): string | undefined; getLatestRefreshToken?(connection: TConnection): Promise; updateConnection(connection: TConnection, tokens: OAuthTokenResponse): Promise; getCacheKey?(connection: TConnection): string; getRefreshLockKey?(connection: TConnection): string; readCachedAccessToken?(connection: TConnection, cacheStorage: ITokenCacheStorage): Promise; writeCachedAccessToken?(connection: TConnection, cacheStorage: ITokenCacheStorage, cacheEntry: CachedAccessToken, ttlSeconds: number): Promise; deleteCachedAccessToken?(connection: TConnection, cacheStorage: ITokenCacheStorage): Promise; } export declare class OAuthStrategy { private storage; private options; constructor(storage: any, options?: OAuthLifecycleOptions); buildInstallUrl(context: TInstallContext, adapter: OAuthLifecycleAdapter): Promise; handleInstallCallback(payload: OAuthCallbackPayload, adapter: OAuthLifecycleAdapter): Promise; getValidAccessToken(conn: TConnection, adapter: OAuthLifecycleAdapter): Promise; invalidateTokens(conn: TConnection, adapter?: OAuthLifecycleAdapter): Promise; refreshIfNeeded(conn: ConnectionMetadata): Promise; resolve(conn: ConnectionMetadata): Promise; private exchangeAuthorizationCode; private refreshWithAdapter; private waitForConcurrentRefresh; private refreshAccessToken; private writeAccessTokenToCache; private getTtlSeconds; private getDefaultCacheKey; private getDefaultRefreshLockKey; private readCachedAccessToken; private deleteCachedAccessToken; private getDefaultConnectionId; private encodeState; private decodeState; private buildTokenRequest; private verifyAndExtractStatePayload; private signState; private requireOption; private delay; } export {};