UNPKG

recoder-shared

Version:

Shared types, utilities, and configurations for Recoder

145 lines 3.53 kB
/** * Mobile OAuth Implementation * Handles OAuth flows for mobile platforms (React Native) */ import { AuthClient } from './auth-client'; export interface MobileOAuthConfig { customScheme?: string; useInAppBrowser?: boolean; browserOptions?: { dismissButtonStyle?: 'done' | 'close' | 'cancel'; preferredBarTintColor?: string; preferredControlTintColor?: string; readerMode?: boolean; animated?: boolean; modalPresentationStyle?: string; modalTransitionStyle?: string; }; } export interface MobileOAuthResult { success: boolean; user?: any; tokens?: any; error?: string; } export declare class MobileOAuthHandler { private oauthHandler; private authClient; private config; private deepLinkHandler?; constructor(authClient: AuthClient, config?: MobileOAuthConfig); private setupEventHandlers; /** * Start OAuth flow for mobile */ login(provider: string): Promise<MobileOAuthResult>; /** * Login with Google */ loginWithGoogle(): Promise<MobileOAuthResult>; /** * Login with GitHub */ loginWithGitHub(): Promise<MobileOAuthResult>; /** * Login with Microsoft */ loginWithMicrosoft(): Promise<MobileOAuthResult>; /** * Handle deep link callback */ handleDeepLink(url: string): Promise<MobileOAuthResult>; /** * Open OAuth URL using platform-specific method */ private openAuthUrl; /** * Set up deep link handler */ private setDeepLinkHandler; /** * Remove deep link handler */ private removeDeepLinkHandler; /** * Handle linking URL event */ private handleLinkingUrl; /** * Parse callback URL parameters */ private parseCallbackUrl; /** * Extract provider from callback URL */ private extractProviderFromUrl; /** * Get React Native Linking module */ private getLinking; /** * Get Expo WebBrowser module */ private getWebBrowser; /** * Get Expo Linking module */ private getExpoLinking; /** * React Native Hook for OAuth */ static createUseAuth(): () => { isAuthenticated: boolean; user: null; loading: boolean; login: (provider: string) => Promise<void>; logout: () => Promise<void>; }; /** * Setup deep linking for the app */ static setupDeepLinking(customScheme?: string): { linking: { prefixes: string[]; config: { screens: { OAuthCallback: string; }; }; }; expoConfig: { scheme: string; ios: { bundleIdentifier: string; }; android: { package: string; intentFilters: { action: string; data: { scheme: string; }; category: string[]; }[]; }; }; }; /** * Get available OAuth providers */ getAvailableProviders(): string[]; /** * Check if user is authenticated */ isAuthenticated(): boolean; /** * Get current user */ getCurrentUser(): any; /** * Logout */ logout(): Promise<void>; } export default MobileOAuthHandler; //# sourceMappingURL=oauth-mobile.d.ts.map