import type { RegistryScriptInput, UseScriptContext } from '#nuxt-scripts/types'; import { GoogleSignInOptions } from './schemas.js'; export interface CredentialResponse { credential: string; select_by: 'auto' | 'user' | 'user_1tap' | 'user_2tap' | 'btn' | 'btn_confirm' | 'btn_add_session' | 'btn_confirm_add_session'; clientId?: string; } export interface IdConfiguration { client_id: string; auto_select?: boolean; callback?: (response: CredentialResponse) => void; login_uri?: string; native_callback?: (response: CredentialResponse) => void; cancel_on_tap_outside?: boolean; prompt_parent_id?: string; nonce?: string; context?: 'signin' | 'signup' | 'use'; state_cookie_domain?: string; ux_mode?: 'popup' | 'redirect'; allowed_parent_origin?: string | string[]; intermediate_iframe_close_callback?: () => void; itp_support?: boolean; login_hint?: string; hd?: string; use_fedcm_for_prompt?: boolean; } export interface GsiButtonConfiguration { type?: 'standard' | 'icon'; theme?: 'outline' | 'filled_blue' | 'filled_black'; size?: 'large' | 'medium' | 'small'; text?: 'signin_with' | 'signup_with' | 'continue_with' | 'signin'; shape?: 'rectangular' | 'pill' | 'circle' | 'square'; logo_alignment?: 'left' | 'center'; width?: string | number; locale?: string; click_listener?: () => void; use_fedcm?: boolean; } export type MomentType = 'display' | 'skipped' | 'dismissed'; export interface MomentNotification { isDisplayMoment: () => boolean; isDisplayed: () => boolean; isNotDisplayed: () => boolean; getNotDisplayedReason: () => 'browser_not_supported' | 'invalid_client' | 'missing_client_id' | 'opt_out_or_no_session' | 'secure_http_required' | 'suppressed_by_user' | 'unregistered_origin' | 'unknown_reason'; isSkippedMoment: () => boolean; getSkippedReason: () => 'auto_cancel' | 'user_cancel' | 'tap_outside' | 'issuing_failed'; isDismissedMoment: () => boolean; getDismissedReason: () => 'credential_returned' | 'cancel_called' | 'flow_restarted'; getMomentType: () => MomentType; } export interface RevocationResponse { successful: boolean; error?: string; } declare namespace google { namespace accounts { namespace id { function initialize(config: IdConfiguration): void; function prompt(momentListener?: (notification: MomentNotification) => void): void; function renderButton(parent: HTMLElement, options: GsiButtonConfiguration): void; function disableAutoSelect(): void; function cancel(): void; function revoke(hint: string, callback: (response: RevocationResponse) => void): void; } } } type AccountsNamespace = typeof google.accounts; export interface GoogleSignInApi { accounts: AccountsNamespace; } export { GoogleSignInOptions }; export type GoogleSignInInput = RegistryScriptInput; /** * Helpers attached to the `useScriptGoogleSignIn()` instance. * * They merge schema options (passed to `useScriptGoogleSignIn(...)`) with the * arguments below, ensure `accounts.id.initialize()` is called at most once * across the page lifecycle (avoids the error Google emits on re-init after a * button is rendered), and wait for the script to load. */ export interface GoogleSignInHelpers { /** * Initialize Google Identity Services. Schema options are used as defaults; * pass a callback (and any other non-serializable config) here. Subsequent * calls are a no-op so this is safe to invoke from a remounting component. */ initialize: (config?: Partial) => void; /** * Render a personalized Google Sign-In button. Auto-initializes if needed. * Safe to re-render on navigation or locale change. */ renderButton: (parent: HTMLElement, config?: GsiButtonConfiguration) => void; /** * Show the One Tap prompt. Auto-initializes if needed. */ prompt: (listener?: (notification: MomentNotification) => void) => void; } export declare function useScriptGoogleSignIn(_options?: GoogleSignInInput): UseScriptContext & GoogleSignInHelpers;