UNPKG

@zestic/oauth-core

Version:

Framework-agnostic OAuth authentication library with support for multiple OAuth flows

75 lines 2.28 kB
/** * Main OAuth orchestrator */ import { OAuthConfig, OAuthAdapters, OAuthResult, FlowConfiguration } from '../types/OAuthTypes'; import { CallbackFlowHandler } from '../types/CallbackFlowTypes'; export declare class OAuthCore { private config; private adapters; private flowRegistry; private pkceManager; private tokenManager; private stateValidator; constructor(config: OAuthConfig, adapters: OAuthAdapters, flowConfig?: FlowConfiguration); /** * Handle OAuth callback with automatic flow detection */ handleCallback(params: URLSearchParams | string, explicitFlow?: string): Promise<OAuthResult>; /** * Generate PKCE challenge for authorization request */ generatePKCEChallenge(): Promise<import("../types/OAuthTypes").PKCEChallenge>; /** * Generate OAuth state parameter */ generateState(): Promise<string>; /** * Generate complete authorization URL with PKCE parameters * This method handles all OAuth logic including PKCE generation and state management */ generateAuthorizationUrl(additionalParams?: Record<string, string>): Promise<{ url: string; state: string; }>; /** * Get current access token */ getAccessToken(): Promise<string | null>; /** * Get current refresh token */ getRefreshToken(): Promise<string | null>; /** * Check if current token is expired */ isTokenExpired(): Promise<boolean>; /** * Refresh access token using refresh token */ refreshAccessToken(): Promise<OAuthResult>; /** * Revoke tokens and clear storage */ logout(): Promise<void>; /** * Register a custom flow handler */ registerFlow(handler: CallbackFlowHandler): void; /** * Unregister a flow handler */ unregisterFlow(name: string): void; /** * Get all registered flow handlers */ getRegisteredFlows(): CallbackFlowHandler[]; /** * Get compatible handlers for given parameters */ getCompatibleHandlers(params: URLSearchParams | string): CallbackFlowHandler[]; /** * Initialize flow handlers based on configuration */ private initializeFlows; } //# sourceMappingURL=OAuthCore.d.ts.map