recoder-shared
Version:
Shared types, utilities, and configurations for Recoder
82 lines • 2.25 kB
TypeScript
/**
* OAuth Callback Handler for Cross-Platform Authentication
* Handles OAuth callbacks for all Recoder platforms
*/
import { EventEmitter } from 'events';
import { AuthClient } from './auth-client';
export interface OAuthConfig {
clientId: string;
clientSecret?: string;
redirectUri: string;
scope: string[];
state?: string;
}
export interface OAuthProvider {
name: string;
displayName: string;
authUrl: string;
tokenUrl: string;
userInfoUrl: string;
defaultScopes: string[];
}
export interface OAuthCallbackData {
code: string;
state?: string;
error?: string;
errorDescription?: string;
}
export interface OAuthResult {
success: boolean;
user?: any;
tokens?: any;
error?: string;
}
export declare class OAuthHandler extends EventEmitter {
private authClient;
private providers;
private pendingAuths;
constructor(authClient: AuthClient);
private initializeProviders;
/**
* Generate OAuth authorization URL for a platform
*/
generateAuthUrl(provider: string, platform: string, config?: Partial<OAuthConfig>): string;
/**
* Handle OAuth callback for any platform
*/
handleCallback(provider: string, platform: string, callbackData: OAuthCallbackData): Promise<OAuthResult>;
/**
* Start OAuth flow for a platform
*/
startOAuthFlow(provider: string, platform: string, config?: Partial<OAuthConfig>): Promise<OAuthResult>;
/**
* Complete OAuth flow when callback is received
*/
completeOAuthFlow(provider: string, platform: string, callbackData: OAuthCallbackData): Promise<void>;
/**
* Platform-specific URL opening
*/
private openAuthUrl;
/**
* Generate secure state parameter
*/
private generateState;
/**
* Verify state parameter
*/
private verifyState;
/**
* Get redirect URI for platform/provider combination
*/
private getRedirectUri;
/**
* Get supported providers
*/
getSupportedProviders(): OAuthProvider[];
/**
* Check if provider is supported
*/
isProviderSupported(provider: string): boolean;
}
export default OAuthHandler;
//# sourceMappingURL=oauth-handler.d.ts.map