infinity-forge
Version:
26 lines (25 loc) • 1.58 kB
TypeScript
import { TokenClientConfig, TokenResponse, CodeClientConfig, CodeResponse, OverridableTokenClientConfig, NonOAuthError } from '../types/index.js';
interface ImplicitFlowOptions extends Omit<TokenClientConfig, 'client_id' | 'scope' | 'callback'> {
onSuccess?: (tokenResponse: Omit<TokenResponse, 'error' | 'error_description' | 'error_uri'>) => void;
onError?: (errorResponse: Pick<TokenResponse, 'error' | 'error_description' | 'error_uri'>) => void;
onNonOAuthError?: (nonOAuthError: NonOAuthError) => void;
scope?: TokenClientConfig['scope'];
overrideScope?: boolean;
}
interface AuthCodeFlowOptions extends Omit<CodeClientConfig, 'client_id' | 'scope' | 'callback'> {
onSuccess?: (codeResponse: Omit<CodeResponse, 'error' | 'error_description' | 'error_uri'>) => void;
onError?: (errorResponse: Pick<CodeResponse, 'error' | 'error_description' | 'error_uri'>) => void;
onNonOAuthError?: (nonOAuthError: NonOAuthError) => void;
scope?: CodeResponse['scope'];
overrideScope?: boolean;
}
export type UseGoogleLoginOptionsImplicitFlow = {
flow?: 'implicit';
} & ImplicitFlowOptions;
export type UseGoogleLoginOptionsAuthCodeFlow = {
flow?: 'auth-code';
} & AuthCodeFlowOptions;
export type UseGoogleLoginOptions = UseGoogleLoginOptionsImplicitFlow | UseGoogleLoginOptionsAuthCodeFlow;
export declare function useGoogleLogin(options: UseGoogleLoginOptionsImplicitFlow): (overrideConfig?: OverridableTokenClientConfig) => void;
export declare function useGoogleLogin(options: UseGoogleLoginOptionsAuthCodeFlow): () => void;
export {};