/** * Social Authentication Hooks * * Native social login hooks for Apple and Google using Expo libraries. * These hooks handle the OAuth flow and return credentials that can be * passed to your AuthAdapter. * * Usage: * ```tsx * const { signIn, loading, error } = useAppleAuth(); * const result = await signIn(); // Returns AppleAuthResult * // Pass result to your adapter: authClient.signIn({ provider: 'apple', ...result }) * ``` */ import type { AuthErrorCode, SocialProvider } from './types'; export interface SocialAuthError { code: AuthErrorCode; message: string; original?: Error; } export interface AppleAuthResult { provider: 'apple'; /** Apple identity token (JWT) */ identityToken: string; /** Authorization code for server validation */ authorizationCode: string; /** User info (only available on first sign-in) */ user?: { email?: string | null; fullName?: { givenName?: string | null; familyName?: string | null; }; }; } export interface GoogleAuthResult { provider: 'google'; /** Google ID token (JWT) */ idToken: string; /** Access token for Google APIs (may be null) */ accessToken: string | null; } export type SocialAuthResult = AppleAuthResult | GoogleAuthResult; export interface SocialAuthHookResult { /** Trigger the sign-in flow */ signIn: () => Promise; /** Whether sign-in is in progress */ loading: boolean; /** Last error that occurred */ error: SocialAuthError | null; /** Clear the error state */ clearError: () => void; /** Whether this provider is available on current platform */ isAvailable: boolean; } /** * Hook for Apple Sign In using expo-apple-authentication. * * Requirements: * - iOS 13+ (returns isAvailable: false on older versions and other platforms) * - expo-apple-authentication must be installed * - Proper entitlements configured in app.json * * @example * ```tsx * const { signIn, loading, error, isAvailable } = useAppleAuth(); * * if (!isAvailable) return null; * * const handleAppleSignIn = async () => { * const result = await signIn(); * if (result) { * await authClient.signIn({ provider: 'apple', token: result.identityToken }); * } * }; * ``` */ export declare function useAppleAuth(): SocialAuthHookResult; export interface GoogleAuthConfig { /** Google OAuth client ID for iOS */ iosClientId?: string; /** * Google OAuth client ID for Android. * @deprecated Auto-detected from `google-services.json` on Android. This field has no effect and will be removed in a future major release. */ androidClientId?: string; /** Google OAuth client ID for web (used as the server client ID) */ webClientId?: string; /** Additional OAuth scopes beyond openid/email/profile */ scopes?: string[]; } /** * Hook for Google Sign In using @react-native-google-signin/google-signin v16. * * Requirements: * - @react-native-google-signin/google-signin v16+ installed * - On Android: clientId auto-detected from google-services.json * - On iOS: iosClientId and webClientId required * * @example * ```tsx * const { signIn, loading, error } = useGoogleAuth({ * iosClientId: 'xxx.apps.googleusercontent.com', * webClientId: 'zzz.apps.googleusercontent.com', * }); * * const handleGoogleSignIn = async () => { * const result = await signIn(); * if (result) { * await authClient.signIn({ provider: 'google', token: result.idToken }); * } * }; * ``` */ export declare function useGoogleAuth(config: GoogleAuthConfig): SocialAuthHookResult; export interface SocialAuthConfig { /** Google OAuth configuration */ google?: GoogleAuthConfig; } /** * Generic social auth hook that provides access to all social providers. * * @example * ```tsx * const { apple, google, signInWith, loading } = useSocialAuth({ * google: { webClientId: 'xxx.apps.googleusercontent.com' }, * }); * * // Use provider-specific hooks * await apple.signIn(); * * // Or use the generic signInWith * await signInWith('google'); * ``` */ export declare function useSocialAuth(config?: SocialAuthConfig): { apple: SocialAuthHookResult; google: SocialAuthHookResult; signInWith: (provider: SocialProvider) => Promise; loading: boolean; }; //# sourceMappingURL=social-auth.d.ts.map