import { ClientConfigError, CodeResponse, CredentialResponse, GoogleAccounts, PromptMomentNotification } from "./types.mjs"; //#region src/google-one-tap/index.d.ts declare global { interface Window { /** Set by the external GSI script once it loads — absent until then. */ google?: { accounts: GoogleAccounts; }; } } type Props = { /** * Opaque nonce string forwarded as-is to Google. Google echoes it back in * the ID Token's `nonce` claim per the OIDC spec; the caller is responsible * for any hashing/encoding required by its verifier. */ nonce?: string; client_id: string; auto_select?: boolean; cancel_on_tap_outside?: boolean; use_fedcm_for_prompt?: boolean; }; type PromptMoment = { skipped: boolean; dismissed: boolean; dismissedReason: ReturnType; }; /** * Why prompt() could not run One Tap, so the caller can decide to fall back * to requestCode(). * - `fedcm_unsupported`: browser has no FedCM (Safari/Firefox/pre-117 Chrome). * - `script_load_failed`: the GSI script failed to load (network/CSP). * - `prompt_error`: GIS threw synchronously while initializing/prompting. */ type UnsupportedReason = 'fedcm_unsupported' | 'script_load_failed' | 'prompt_error'; type PromptResult = { authorized: true; credential: CredentialResponse; } | { authorized: false; moment: PromptMoment; } | { authorized: false; unsupported: true; reason: UnsupportedReason; }; /** debug: chrome://settings/content/federatedIdentityApi */ declare function prompt({ nonce, client_id, auto_select, use_fedcm_for_prompt, cancel_on_tap_outside }: Props): Promise; type CodeProps = { client_id: string; /** * Space-delimited OAuth scopes. Defaults to OpenID Connect scopes so the * backend can exchange the code for an ID token, mirroring One Tap's intent. */ scope?: string; /** 'popup' resolves the returned promise; 'redirect' navigates away and never resolves. */ ux_mode?: 'popup' | 'redirect'; /** Required when ux_mode is 'redirect'; for 'popup' Google uses postMessage. */ redirect_uri?: string; state?: string; login_hint?: string; hd?: string; }; type CodeResult = { ok: true; response: CodeResponse; } | { ok: false; error: ClientConfigError | CodeResponse; }; /** * OAuth 2.0 authorization-code fallback for environments where One Tap / FedCM * is unavailable (i.e. prompt() resolved with `unsupported: true`). It reuses * the same GSI script, so there is no extra dependency. * * Unlike One Tap it returns an authorization `code` for the backend to * exchange, not an ID token, and it must be triggered by a user gesture or the * popup may be blocked. */ declare function requestCode({ client_id, scope, ux_mode, redirect_uri, state, login_hint, hd }: CodeProps): Promise; //#endregion export { CodeProps, CodeResult, PromptMoment, PromptResult, Props, UnsupportedReason, prompt, requestCode }; //# sourceMappingURL=index.d.mts.map