import { Plugin, Ref } from "vue"; export type MaybeRef = T | Ref; export interface DecodedGoogleUser { email: string; email_verified: boolean; hd: string; family_name: string; given_name: string; name: string; id: string; picture: string; iat: number; exp: number; } /** * UxMode for client */ export type UxMode = "popup" | "redirect"; /** * Context */ export type Context = "use" | "signin" | "signup"; /** * Select By * * @see https://developers.google.com/identity/gsi/web/reference/js-reference#select_by */ export type SelectBy = "auto" | "user" | "user_1tap" | "user_2tap" | "btn" | "btn_confirm" | "brn_add_session" | "btn_confirm_add_session" | "auto" | "user" | "user_1tap" | "user_2tap" | "btn" | "btn_confirm" | "brn_add_session" | "btn_confirm_add_session"; /** * Credential response returned from google. * * * @export * @see https://developers.google.com/identity/gsi/web/reference/js-reference#CredentialResponse * @interface CredentialResponse */ export interface CredentialResponse { /** * This field is the ID token as a base64-encoded JSON Web Token (JWT) string * * @type {string} * @memberof CredentialResponse */ credential?: string; /** * About how google selected the credentials * * @type {SelectBy} * @memberof CredentialResponse */ select_by?: SelectBy; /** * This field is only defined when user clicks a Sign in with Google button to sign in, and the button's state attribute is specified. * * @type {string} * @memberof CredentialResponse */ state?: string; } /** * The credential response passed to success callbacks, which only run when * Google returned an ID token * * @export */ export type CredentialSuccessResponse = CredentialResponse & { credential: string; }; /** * Native credential response * * @export * @interface NativeCallbackResponse */ export interface NativeCallbackResponse { id: string; password: string; } /** * Configuration for Google Client. * * @export * @see https://developers.google.com/identity/gsi/web/reference/js-reference#IdConfiguration * @interface IdConfiguration */ export interface IdConfiguration { /** * Application client ID * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#client_id * @memberof IdConfiguration */ client_id: string; /** * This field determines if an ID token is automatically returned without any user interaction * when there's only one Google session that has approved your app before * * @type {boolean} * @default false * @see https://developers.google.com/identity/gsi/web/reference/js-reference#auto_select * @memberof IdConfiguration */ auto_select?: boolean; /** * This field is the JavaScript function that handles the ID token returned from the One Tap prompt or the pop-up window. * * @see https://developers.google.com/identity/gsi/web/reference/js-reference#callback * @memberof IdConfiguration */ callback?: (credentialResponse: CredentialResponse) => void; /** * This attribute is the URI of your login endpoint. * May be omitted if the current page is your login page, in which case the credential is posted to this page by default. * * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#login_uri * @memberof IdConfiguration */ login_uri?: string; /** * This field is the name of the JavaScript function that handles the password credential returned from the browser's native credential manager. * * @see https://developers.google.com/identity/gsi/web/reference/js-reference#native_callback * @memberof IdConfiguration */ native_callback?: (response: NativeCallbackResponse) => void; /** * This field sets whether or not to cancel the One Tap request if a user clicks outside the prompt. * * @type {boolean} * @default true * @see https://developers.google.com/identity/gsi/web/reference/js-reference#cancel_on_tap_outside * @memberof IdConfiguration */ cancel_on_tap_outside?: boolean; /** * This attribute sets the DOM ID of the container element. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#prompt_parent_id * @memberof IdConfiguration */ prompt_parent_id?: string; /** * This field is a random string used by the ID token to prevent replay attacks. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#nonce * @memberof IdConfiguration */ nonce?: string; /** * This field changes the text of the title and messages in the One Tap prompt. * * @type {Context} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#context * @memberof IdConfiguration */ context?: Context; /** * If you need to display One Tap in the parent domain and its subdomains, pass the parent domain to this field so that a single shared-state cookie is used. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#state_cookie_domain * @memberof IdConfiguration */ state_cookie_domain?: string; /** * Use this field to set the UX flow used by the Sign In With Google button. * * @type {UxMode} * @default popup * @see https://developers.google.com/identity/gsi/web/reference/js-reference#ux_mode * @memberof IdConfiguration */ ux_mode?: UxMode; /** * The origins that are allowed to embed the intermediate iframe. One Tap will run in the intermediate iframe mode if this field presents. * * @type {(string | string[])} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#allowed_parent_origin * @memberof IdConfiguration */ allowed_parent_origin?: string | string[]; /** * Overrides the default intermediate iframe behavior when users manually close One Tap by tapping on the 'X' button in the One Tap UI. * The default behavior is to remove the intermediate iframe from the DOM immediately. * * * @see https://developers.google.com/identity/gsi/web/reference/js-reference#intermediate_iframe_close_callback * @memberof IdConfiguration */ intermediate_iframe_close_callback?: () => void; /** * This field determines if the upgraded One Tap UX should be enabled on browsers that support Intelligent Tracking Prevention (ITP). * * @type {boolean} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#itp_support * @memberof IdConfiguration */ itp_support?: boolean; /** * Skips account selection when you already know which user should sign in. * An email address or the `sub` field of an ID token. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#login_hint * @memberof IdConfiguration */ login_hint?: string; /** * Limits account selection to a Google Workspace domain, or `*` for any Workspace account. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#hd * @memberof IdConfiguration */ hd?: string; /** * Use the FedCM button flow on browsers that support it. * * @type {boolean} * @default false * @see https://developers.google.com/identity/gsi/web/reference/js-reference#use_fedcm_for_button * @memberof IdConfiguration */ use_fedcm_for_button?: boolean; /** * With the FedCM button flow, sign returning users in without showing the account chooser. * * @type {boolean} * @default false * @see https://developers.google.com/identity/gsi/web/reference/js-reference#button_auto_select * @memberof IdConfiguration */ button_auto_select?: boolean; /** * Color scheme of the One Tap prompt. Defaults to the user's system setting. * * @type {("default" | "light" | "dark")} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#color_scheme * @memberof IdConfiguration */ color_scheme?: "default" | "light" | "dark"; /** * Extra claims to include in the ID token, such as `"auth_time, amr"`. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#essential_claims * @memberof IdConfiguration */ essential_claims?: string; /** * @deprecated Ignored by Google: One Tap always uses FedCM now. * @see https://developers.google.com/identity/gsi/web/reference/js-reference#use_fedcm_for_prompt */ use_fedcm_for_prompt?: boolean; } /** * Prompt moment notification. * * @export * @see https://developers.google.com/identity/gsi/web/reference/js-reference#PromptMomentNotification * @interface PromptMomentNotification */ export interface PromptMomentNotification { /** * Is this notification for a skipped moment? * * @memberof PromptMomentNotification */ isSkippedMoment: () => boolean; /** * The detailed reason for the skipped moment. FedCM doesn't report `user_cancel`. * * @memberof PromptMomentNotification */ getSkippedReason: () => "auto_cancel" | "user_cancel" | "tap_outside" | "issuing_failed"; /** * Is this notification for a dismissed moment? * * @memberof PromptMomentNotification */ isDismissedMoment: () => boolean; /** *The detailed reason for the dismissal. * * @memberof PromptMomentNotification */ getDismissedReason: () => "credential_returned" | "cancel_called" | "flow_restarted"; /** * Return a string for the moment type. * * @memberof PromptMomentNotification */ getMomentType: () => "display" | "skipped" | "dismissed"; } /** * Google Sign In Button configuration. * * @export * @see https://developers.google.com/identity/gsi/web/reference/js-reference#GsiButtonConfiguration * @interface GsiButtonConfiguration */ export interface GsiButtonConfiguration { /** * The button type: icon, or standard button. * * @type {("standard" | "icon")} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#type * @memberof GsiButtonConfiguration */ type?: "standard" | "icon"; /** * The button theme * * @type {("outline" | "filled_blue" | "filled_black")} * @default outline * @see https://developers.google.com/identity/gsi/web/reference/js-reference#theme * @memberof GsiButtonConfiguration */ theme?: "outline" | "filled_blue" | "filled_black"; /** * The button size * * @type {("large" | "medium" | "small")} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#size * @default small * @memberof GsiButtonConfiguration */ size?: "large" | "medium" | "small"; /** * The button text. * * @type {("signin_with" | "signup_with" | "continue_with" | "signin")} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#text * @default signup_with * @memberof GsiButtonConfiguration */ text?: "signin_with" | "signup_with" | "continue_with" | "signin"; /** * The button shape * * @type {("rectangular" | "pill" | "circle" | "square")} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#shape * @default rectangular * @memberof GsiButtonConfiguration */ shape?: "rectangular" | "pill" | "circle" | "square"; /** * The alignment of the Google logo * * @type {("left" | "center")} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#logo_alignment * @default left * @memberof GsiButtonConfiguration */ logo_alignment?: "left" | "center"; /** * The minimum button width, in pixels. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#width * @default 400 * @memberof GsiButtonConfiguration */ width?: string; /** * The pre-set locale of the button text. If it's not set, the browser's default locale or the Google session user’s preference is used. * Therefore, different users might see different versions of localized buttons, and possibly with different sizes. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#locale * @memberof GsiButtonConfiguration */ locale?: string; /** * Called when the button is clicked. * * @see https://developers.google.com/identity/gsi/web/reference/js-reference#click_listener * @memberof GsiButtonConfiguration */ click_listener?: () => void; /** * Returned as `state` in the credential response, to tell several buttons apart. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#state * @memberof GsiButtonConfiguration */ state?: string; } export type MomentListener = (promptMomentNotification: PromptMomentNotification) => void; export interface RevocationResponse { /** * Successfully revocated * * @type {*} * @memberof RevocationResponse */ successful: any; /** * Error on revocation * * @type {*} * @memberof RevocationResponse */ error: any; } export type RevocationCallback = (response: RevocationResponse) => void; interface GoogleSignInButtonProps { /** * Client ID for this button. Overrides the one given to the plugin. * * @type {string} * @see https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid * @memberof GoogleSignInButtonProps */ clientId?: string; /** * Use One Tap Login * * @type {boolean} * @memberof GoogleSignInButtonProps */ oneTap?: boolean; /** * This field determines if an ID token is automatically returned without any user interaction * when there's only one Google session that has approved your app before * * @type {boolean} * @default false * @see https://developers.google.com/identity/gsi/web/reference/js-reference#auto_select * @memberof GoogleSignInButtonProps */ autoSelect?: boolean; /** * This attribute is the URI of your login endpoint. * May be omitted if the current page is your login page, in which case the credential is posted to this page by default. * * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#login_uri * @memberof GoogleSignInButtonProps */ loginUri?: string; /** * This field sets whether or not to cancel the One Tap request if a user clicks outside the prompt. * * @type {boolean} * @default true * @see https://developers.google.com/identity/gsi/web/reference/js-reference#cancel_on_tap_outside * @memberof GoogleSignInButtonProps */ cancelOnTapOutside?: boolean; /** * This attribute sets the DOM ID of the container element. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#prompt_parent_id * @memberof GoogleSignInButtonProps */ promptParentId?: string; /** * This field is a random string used by the ID token to prevent replay attacks. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#nonce * @memberof GoogleSignInButtonProps */ nonce?: string; /** * This field changes the text of the title and messages in the One Tap prompt. * * @type {Context} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#context * @memberof GoogleSignInButtonProps */ context?: Context; /** * If you need to display One Tap in the parent domain and its subdomains, pass the parent domain to this field so that a single shared-state cookie is used. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#state_cookie_domain * @memberof GoogleSignInButtonProps */ stateCookieDomain?: string; /** * Use this field to set the UX flow used by the Sign In With Google button. * * @type {UxMode} * @default popup * @see https://developers.google.com/identity/gsi/web/reference/js-reference#ux_mode * @memberof GoogleSignInButtonProps */ uxMode?: UxMode; /** * The origins that are allowed to embed the intermediate iframe. One Tap will run in the intermediate iframe mode if this field presents. * * @type {(string | string[])} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#allowed_parent_origin * @memberof GoogleSignInButtonProps */ allowedParentOrigin?: string | string[]; /** * This field determines if the upgraded One Tap UX should be enabled on browsers that support Intelligent Tracking Prevention (ITP). * * @type {boolean} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#itp_support * @memberof GoogleSignInButtonProps */ itpSupport?: boolean; /** * Skips account selection when you already know which user should sign in: an email address or the `sub` field of an ID token. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#login_hint * @memberof GoogleSignInButtonProps */ loginHint?: string; /** * Limits account selection to a Google Workspace domain, or `*` for any Workspace account. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#hd * @memberof GoogleSignInButtonProps */ hd?: string; /** * Color scheme of the One Tap prompt. Defaults to the user's system setting. * * @type {"default" | "light" | "dark"} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#color_scheme * @memberof GoogleSignInButtonProps */ colorScheme?: "default" | "light" | "dark"; /** * Extra claims to include in the ID token, such as `"auth_time, amr"`. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#essential_claims * @memberof GoogleSignInButtonProps */ essentialClaims?: string; /** * Use the FedCM button flow on browsers that support it. * * @type {boolean} * @default false * @see https://developers.google.com/identity/gsi/web/reference/js-reference#use_fedcm_for_button * @memberof GoogleSignInButtonProps */ useFedcmForButton?: boolean; /** * With the FedCM button flow, sign returning users in without showing the account chooser. * * @type {boolean} * @default false * @see https://developers.google.com/identity/gsi/web/reference/js-reference#button_auto_select * @memberof GoogleSignInButtonProps */ buttonAutoSelect?: boolean; /** * Returned as `state` in the credential response, to tell several buttons apart. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#state * @memberof GoogleSignInButtonProps */ state?: string; /** * The button type: icon, or standard button. * * @type {("standard" | "icon")} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#type * @memberof GoogleSignInButtonProps */ type?: "standard" | "icon"; /** * The button theme * * @type {("outline" | "filled_blue" | "filled_black")} * @default outline * @see https://developers.google.com/identity/gsi/web/reference/js-reference#theme * @memberof GoogleSignInButtonProps */ theme?: "outline" | "filled_blue" | "filled_black"; /** * The button size * * @type {("large" | "medium" | "small")} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#size * @default small * @memberof GoogleSignInButtonProps */ size?: "large" | "medium" | "small"; /** * The button text. * * @type {("signin_with" | "signup_with" | "continue_with" | "signin")} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#text * @default signup_with * @memberof GoogleSignInButtonProps */ text?: "signin_with" | "signup_with" | "continue_with" | "signin"; /** * The button shape * * @type {("rectangular" | "pill" | "circle" | "square")} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#shape * @default rectangular * @memberof GoogleSignInButtonProps */ shape?: "rectangular" | "pill" | "circle" | "square"; /** * The alignment of the Google logo * * @type {("left" | "center")} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#logo_alignment * @default left * @memberof GoogleSignInButtonProps */ logoAlignment?: "left" | "center"; /** * The minimum button width, in pixels. * * @type {number} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#width * @default 400 * @memberof GoogleSignInButtonProps */ width?: number; /** * The pre-set locale of the button text. If it's not set, the browser's default locale or the Google session user’s preference is used. * Therefore, different users might see different versions of localized buttons, and possibly with different sizes. * * @type {string} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#locale * @memberof GoogleSignInButtonProps */ locale?: string; } declare const __VLS_export: import("vue").DefineComponent any; error: (response: CredentialResponse) => any; intermediateIframeCloseCallback: () => any; nativeCallback: (response: NativeCallbackResponse) => any; promptMomentNotification: (notification: PromptMomentNotification) => any; }, string, import("vue").PublicProps, Readonly & Readonly<{ onSuccess?: ((response: CredentialSuccessResponse) => any) | undefined; onError?: ((response: CredentialResponse) => any) | undefined; onIntermediateIframeCloseCallback?: (() => any) | undefined; onNativeCallback?: ((response: NativeCallbackResponse) => any) | undefined; onPromptMomentNotification?: ((notification: PromptMomentNotification) => any) | undefined; }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>; declare const _default: typeof __VLS_export; type UseGsiScriptReturn = { /** * Script loaded successfully * * @type {Readonly>} */ scriptLoaded: Readonly>; /** * Failed to load the GSI script * * @type {Readonly>} */ scriptLoadError: Readonly>; }; /** * Use google GSI script in the application. * * This is automatically called when you use any of * the provided composables such as `useOneTap` or using the `GoogleSignInButton` component. * * No matter how many time this function called, it only loads the script once if it not present. * * @export * @return {*} {UseGsiScriptReturn} */ declare function useGsiScript(): UseGsiScriptReturn; export type ErrorCode = "invalid_request" | "access_denied" | "unauthorized_client" | "unsupported_response_type" | "invalid_scope" | "server_error" | "temporarily_unavailable"; /** * An error that isn't an OAuth response, passed to `error_callback` * * @export * @see https://developers.google.com/identity/oauth2/web/reference/js-reference#TokenClientConfig * @interface NonOAuthError */ export interface NonOAuthError { /** * - `popup_failed_to_open`: the popup window couldn't be opened * - `popup_closed`: the popup was closed before an OAuth response was returned * - `unknown`: any other error */ type: "popup_failed_to_open" | "popup_closed" | "unknown"; } /** * CodeResponse from Google * * @export * @see https://developers.google.com/identity/oauth2/web/reference/js-reference#CodeResponse * @interface CodeResponse */ export interface CodeResponse { /** The authorization code of a successful token response */ code: string; /** A space-delimited list of scopes that are approved by the user */ scope: string; /** The string value that your application uses to maintain state between your authorization request and the response */ state?: string; /** A single ASCII error code */ error?: ErrorCode; /** Human-readable ASCII text providing additional information, used to assist the client developer in understanding the error that occurred */ error_description?: string; /** A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error */ error_uri?: string; } /** * Configure code client * * @export * @see https://developers.google.com/identity/oauth2/web/reference/js-reference#CodeClientConfig * @interface CodeClientConfig */ export interface CodeClientConfig { /** * The client ID for your application. You can find this value in the [API Console](https://console.developers.google.com/). * * @type {string} * @memberof CodeClientConfig */ client_id: string; /** * A space-delimited list of scopes that identify the resources that your application could access on the user's behalf. * These values inform the consent screen that Google displays to the user. * * @type {string} * @memberof CodeClientConfig */ scope: string; /** * Required for redirect UX. Determines where the API server redirects the user after the user completes the authorization flow. * The value must exactly match one of the authorized redirect URIs for the OAuth 2.0 client, * which you configured in the API Console and must conform to our [Redirect URI validation rules](https://developers.google.com/identity/protocols/oauth2/web-server#uri-validation). * The property will be ignored by the popup UX. * * @type {string} * @memberof CodeClientConfig */ redirect_uri?: string; /** * Required for popup UX. The JavaScript function name that handles returned code response. The property will be ignored by the redirect UX. * * @memberof CodeClientConfig */ callback?: (codeResponse: CodeResponse) => void; /** * Optional. Recommended for redirect UX. * Specifies any string value that your application uses to maintain state between your authorization request and the authorization server's response. * * @type {string} * @memberof CodeClientConfig */ state?: string; /** * Optional, defaults to `true`. Keeps scopes the user already granted when you * request more later (incremental authorization). */ include_granted_scopes?: boolean; /** * Optional. Skips account selection when you know which user should authorize * the request: their email address or the `sub` field of their ID token. */ login_hint?: string; /** * Optional. Limits account selection to this Google Workspace domain. */ hd?: string; /** @deprecated No effect: granular permissions are always on. */ enable_granular_consent?: boolean; /** @deprecated No effect: granular permissions are always on. */ enable_serial_consent?: boolean; /** @deprecated Use `login_hint`. */ hint?: string; /** @deprecated Use `hd`. */ hosted_domain?: string; /** * Optional. The UX mode to use for the authorization flow. * By default, it will open the consent flow in a popup. Valid values are popup and redirect. * * @type {("popup" | "redirect")} * @memberof CodeClientConfig */ ux_mode?: "popup" | "redirect"; /** * Optional, defaults to `false`. Boolean value to prompt the user to select an account. * * @type {boolean} * @default false * @memberof CodeClientConfig */ select_account?: boolean; /** * Optional. Handles errors that aren't OAuth responses, such as the popup being closed. * * @see https://developers.google.com/identity/oauth2/web/reference/js-reference#CodeClientConfig */ error_callback?: (error: NonOAuthError) => void; } export interface CodeClient { requestCode(): void; } export interface TokenResponse { /** The access token of a successful token response. */ access_token: string; /** The lifetime in seconds of the access token. */ expires_in: string; /** The hosted domain the signed-in user belongs to. */ hd?: string; /** The prompt value that was used from the possible list of values specified by TokenClientConfig or OverridableTokenClientConfig */ prompt: string; /** The type of the token issued. */ token_type: string; /** A space-delimited list of scopes that are approved by the user. */ scope: string; /** The string value that your application uses to maintain state between your authorization request and the response. */ state?: string; /** A single ASCII error code. */ error?: ErrorCode; /** Human-readable ASCII text providing additional information, used to assist the client developer in understanding the error that occurred. */ error_description?: string; /** A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error. */ error_uri?: string; } export interface TokenClientConfig { /** * The client ID for your application. You can find this value in the * [API Console](https://console.cloud.google.com/apis/dashboard) */ client_id: string; /** * A space-delimited list of scopes that identify the resources * that your application could access on the user's behalf. * These values inform the consent screen that Google displays to the user */ scope: string; /** * Required for popup UX. The JavaScript function name that handles returned code response * The property will be ignored by the redirect UX */ callback?: (response: TokenResponse) => void; /** * Optional, defaults to 'select_account'. A space-delimited, case-sensitive list of prompts to present the user */ prompt?: "" | "none" | "consent" | "select_account"; /** * Optional, defaults to `true`. Keeps scopes the user already granted when you * request more later (incremental authorization). */ include_granted_scopes?: boolean; /** * Optional. Skips account selection when you know which user should authorize * the request: their email address or the `sub` field of their ID token. */ login_hint?: string; /** * Optional. Limits account selection to this Google Workspace domain. */ hd?: string; /** @deprecated No effect: granular permissions are always on. */ enable_granular_consent?: boolean; /** @deprecated No effect: granular permissions are always on. */ enable_serial_consent?: boolean; /** @deprecated Use `login_hint`. */ hint?: string; /** @deprecated Use `hd`. */ hosted_domain?: string; /** * Optional. Not recommended. Specifies any string value that * your application uses to maintain state between your authorization * request and the authorization server's response. */ state?: string; /** * Optional. Handles errors that aren't OAuth responses, such as the popup being closed. * * @see https://developers.google.com/identity/oauth2/web/reference/js-reference#TokenClientConfig */ error_callback?: (error: NonOAuthError) => void; } export interface OverridableTokenClientConfig { /** * Optional. A space-delimited, case-sensitive list of prompts to present the user. */ prompt?: string; /** * Optional. A space-delimited list of scopes to request instead of the client's. */ scope?: string; /** * Optional, defaults to `true`. Keeps scopes the user already granted when you * request more later (incremental authorization). */ include_granted_scopes?: boolean; /** * Optional. Skips account selection when you know which user should authorize * the request: their email address or the `sub` field of their ID token. */ login_hint?: string; /** @deprecated No effect: granular permissions are always on. */ enable_granular_consent?: boolean; /** @deprecated No effect: granular permissions are always on. */ enable_serial_consent?: boolean; /** @deprecated Use `login_hint`. */ hint?: string; /** * Optional. Not recommended. Specifies any string value that your * application uses to maintain state between your authorization request * and the authorization server's response. */ state?: string; } /** * Token client * * @export * @interface TokenClient */ export interface TokenClient { requestAccessToken(overrideConfig?: OverridableTokenClientConfig): void; } /** * Successful code response */ type CodeClientSuccessResponse = Omit; /** * Code response with an OAuth error */ type CodeClientErrorResponse = Pick; /** * Options for `useCodeClient` * * @export * @interface UseCodeClientOptions * @extends {(Omit)} */ interface UseCodeClientOptions extends Omit { /** * On success callback * * @memberof UseCodeClientOptions */ onSuccess?: (response: CodeClientSuccessResponse) => void; /** * On error callback * * @memberof UseCodeClientOptions */ onError?: (errorResponse: CodeClientErrorResponse) => void; /** * Called when the flow ends without an OAuth response, * for example when the user closes the popup or it can't be opened * * @see https://developers.google.com/identity/oauth2/web/reference/js-reference#CodeClientConfig * @memberof UseCodeClientOptions */ onNonOAuthError?: (error: NonOAuthError) => void; /** * Authorization scopes * * @type {(MaybeRef | MaybeRef)} * @see https://developers.google.com/identity/protocols/oauth2/scopes * @memberof UseCodeClientOptions */ scope?: MaybeRef | MaybeRef; /** * Client ID for this code client. Overrides the one given to the plugin. * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid * @memberof UseCodeClientOptions */ clientId?: MaybeRef; } /** @deprecated Renamed to {@link UseCodeClientOptions}. */ type ImplicitFlowOptions = UseCodeClientOptions; /** @deprecated Renamed to {@link CodeClientSuccessResponse}. */ type ImplicitFlowSuccessResponse = CodeClientSuccessResponse; /** @deprecated Renamed to {@link CodeClientErrorResponse}. */ type ImplicitFlowErrorResponse = CodeClientErrorResponse; /** * Result of composable * * @export * @interface UseCodeClientReturn */ interface UseCodeClientReturn { /** * Is script is ready to be used? * * @type {Readonly>} * @memberof UseCodeClientReturn */ isReady: Readonly>; /** * Execute login with code client * * @memberof UseCodeClientReturn */ login: () => void | undefined; /** * Get a URL to perform code request without actually redirecting user. * This is useful for platforms like _Electron/Tauri_ for redirecting user with system browser * * @type {Readonly>} * @memberof UseCodeClientReturn */ codeRequestRedirectUrl: Readonly>; } /** * Initiate login with the authorization code flow using a code client. Return values of the composable can be used * to trigger the login flow and determine the readiness of the client. * It also provides callbacks such as `onSuccess` and `onError` that can be used to obtain the results from the login client. * * @export * @param {UseCodeClientOptions} [options={}] * @see https://developers.google.com/identity/oauth2/web/guides/use-code-model * @return {*} {UseCodeClientReturn} */ declare function useCodeClient(options?: UseCodeClientOptions): UseCodeClientReturn; interface UseGoogleOneTapLoginOptions { /** * Client ID for this One Tap prompt. Overrides the one given to the plugin. * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid * @memberof UseGoogleOneTapLoginOptions */ clientId?: MaybeRef; /** * Callback to run on success * * @memberof UseGoogleOneTapLoginOptions */ onSuccess?: (credentialResponse: CredentialSuccessResponse) => void; /** * Called when Google responds without a credential * * @memberof UseGoogleOneTapLoginOptions */ onError?: (credentialResponse: CredentialResponse) => void; /** * Callback to run on prompt moment * * @memberof UseGoogleOneTapLoginOptions */ onPromptMomentNotification?: (promptMomentNotification: PromptMomentNotification) => void; /** * Native callback * * @memberof UseGoogleOneTapLoginOptions */ onNativeCallback?: (nativeCallbackResponse: NativeCallbackResponse) => void; /** * On intermediate iframe closed * * @memberof UseGoogleOneTapLoginOptions */ onIntermediateIframeCloseCallback?: () => void; /** * Explicitly disable the automatic prompt. * This is `false` by default. You can trigger the prompet using `login` returned by the composable * * @type {MaybeRef} * @memberof UseGoogleOneTapLoginOptions */ disableAutomaticPrompt?: MaybeRef; /** * This field determines if an ID token is automatically returned without any user interaction * when there's only one Google session that has approved your app before * * @type {MaybeRef} * @default false * @see https://developers.google.com/identity/gsi/web/reference/js-reference#auto_select * @memberof UseGoogleOneTapLoginOptions */ autoSelect?: MaybeRef; /** * This attribute is the URI of your login endpoint. * May be omitted if the current page is your login page, in which case the credential is posted to this page by default. * * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#login_uri * @memberof UseGoogleOneTapLoginOptions */ loginUri?: MaybeRef; /** * This field sets whether or not to cancel the One Tap request if a user clicks outside the prompt. * * @type {MaybeRef} * @default true * @see https://developers.google.com/identity/gsi/web/reference/js-reference#cancel_on_tap_outside * @memberof UseGoogleOneTapLoginOptions */ cancelOnTapOutside?: MaybeRef; /** * This attribute sets the DOM ID of the container element. * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#prompt_parent_id * @memberof UseGoogleOneTapLoginOptions */ promptParentId?: MaybeRef; /** * This field is a random string used by the ID token to prevent replay attacks. * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#nonce * @memberof UseGoogleOneTapLoginOptions */ nonce?: MaybeRef; /** * This field changes the text of the title and messages in the One Tap prompt. * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#context * @memberof UseGoogleOneTapLoginOptions */ context?: MaybeRef; /** * If you need to display One Tap in the parent domain and its subdomains, pass the parent domain to this field so that a single shared-state cookie is used. * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#state_cookie_domain * @memberof UseGoogleOneTapLoginOptions */ stateCookieDomain?: MaybeRef; /** * The origins that are allowed to embed the intermediate iframe. One Tap will run in the intermediate iframe mode if this field presents. * * @type {(MaybeRef | MaybeRef)} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#allowed_parent_origin * @memberof UseGoogleOneTapLoginOptions */ allowedParentOrigin?: MaybeRef | MaybeRef; /** * This field determines if the upgraded One Tap UX should be enabled on browsers that support Intelligent Tracking Prevention (ITP). * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#itp_support * @memberof UseGoogleOneTapLoginOptions */ itpSupport?: MaybeRef; /** * Skips account selection when you already know which user should sign in: an email address or the `sub` field of an ID token. * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#login_hint * @memberof UseGoogleOneTapLoginOptions */ loginHint?: MaybeRef; /** * Limits account selection to a Google Workspace domain, or `*` for any Workspace account. * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#hd * @memberof UseGoogleOneTapLoginOptions */ hd?: MaybeRef; /** * Color scheme of the One Tap prompt. Defaults to the user's system setting. * * @type {MaybeRef<"default" | "light" | "dark">} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#color_scheme * @memberof UseGoogleOneTapLoginOptions */ colorScheme?: MaybeRef<"default" | "light" | "dark">; /** * Extra claims to include in the ID token, such as `"auth_time, amr"`. * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/reference/js-reference#essential_claims * @memberof UseGoogleOneTapLoginOptions */ essentialClaims?: MaybeRef; } interface UseOneTapResult { /** * Is one tap ready to be used? * * @type {Readonly>} * @memberof UseOneTapResult */ isReady: Readonly>; /** * Trigger one tap login manually * * @memberof UseOneTapResult */ login: () => void; } /** * Use google one tap login * * @export * @param {UseGoogleOneTapLoginOptions} [options] * @see https://developers.google.com/identity/gsi/web/guides/display-google-one-tap * @return {*} {UseOneTapResult} */ declare function useOneTap(options?: UseGoogleOneTapLoginOptions): UseOneTapResult; /** * Successful token response */ type TokenClientSuccessResponse = Omit; /** * Token response with an OAuth error */ type TokenClientErrorResponse = Pick; /** * Options for `useTokenClient` * * @export * @interface UseTokenClientOptions * @extends {(Omit)} */ interface UseTokenClientOptions extends Omit { /** * On success callback * * @memberof UseTokenClientOptions */ onSuccess?: (response: TokenClientSuccessResponse) => void; /** * On error callback * * @memberof UseTokenClientOptions */ onError?: (errorResponse: TokenClientErrorResponse) => void; /** * Called when the flow ends without an OAuth response, * for example when the user closes the popup or it can't be opened * * @see https://developers.google.com/identity/oauth2/web/reference/js-reference#TokenClientConfig * @memberof UseTokenClientOptions */ onNonOAuthError?: (error: NonOAuthError) => void; /** * Authorization scopes * * @type {(MaybeRef | MaybeRef)} * @see https://developers.google.com/identity/protocols/oauth2/scopes * @memberof UseTokenClientOptions */ scope?: MaybeRef | MaybeRef; /** * Client ID for this token client. Overrides the one given to the plugin. * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid * @memberof UseTokenClientOptions */ clientId?: MaybeRef; } /** @deprecated Renamed to {@link UseTokenClientOptions}. */ type AuthCodeFlowOptions = UseTokenClientOptions; /** @deprecated Renamed to {@link TokenClientSuccessResponse}. */ type AuthCodeFlowSuccessResponse = TokenClientSuccessResponse; /** @deprecated Renamed to {@link TokenClientErrorResponse}. */ type AuthCodeFlowErrorResponse = TokenClientErrorResponse; /** * Token Client Result * * @export * @interface UseTokenClientReturn */ interface UseTokenClientReturn { /** * Is script ready to be used? * * @type {Readonly>} * @memberof UseTokenClientReturn */ isReady: Readonly>; /** * Invoke login flow. You can provide a `OverridableTokenClientConfig` to override the login flow options. * * @memberof UseTokenClientReturn */ login: (overrideConfig?: OverridableTokenClientConfig) => void | undefined; } /** * Initiate login with the implicit flow using a token client. Return values of the composable can be used * to trigger the login flow and determine the readiness of the client. * It also provides callbacks such as `onSuccess` and `onError` that can be used to obtain the results from the login client. * * @export * @param {UseTokenClientOptions} [options={}] * @see https://developers.google.com/identity/oauth2/web/guides/use-token-model * @return {*} {UseTokenClientReturn} */ declare function useTokenClient(options?: UseTokenClientOptions): UseTokenClientReturn; /** * Helper method for [google.accounts.id.revoke](https://developers.google.com/identity/gsi/web/reference/js-reference#google.accounts.id.revoke) * * @param {string} hint - The email address or unique ID of the user's Google Account. The ID is the sub property of the credential payload. * @param {RevocationCallback} [callback] - Optional callback * @export * @param {type} params */ export declare function idRevoke(hint: string, callback?: RevocationCallback): void; /** * Decode the credential token retrieved from the GoogleSignIn onSuccess response into a usable Object * * @param {string} credential * @returns {DecodedGoogleUser} */ export declare function decodeCredential(credential: string): DecodedGoogleUser; /** * Helper method for [google.accounts.oauth2.hasGrantedAllScopes](https://developers.google.com/identity/oauth2/web/reference/js-reference#google.accounts.oauth2.hasGrantedAllScopes) * * @export * @param {TokenResponse} tokenResponse - A valid access token * @param {string} firstScope - first scope * @param {...string[]} restScopes - other scopes * @return {*} {boolean} */ export declare function hasGrantedAllScopes(tokenResponse: TokenResponse, firstScope: string, ...restScopes: string[]): boolean; /** * Helper method for [google.accounts.oauth2.hasGrantedAnyScopes](https://developers.google.com/identity/oauth2/web/reference/js-reference#google.accounts.oauth2.hasGrantedAnyScopes) * * @export * @param {TokenResponse} tokenResponse - A valid access token * @param {string} firstScope - first scope * @param {...string[]} restScopes - other scopes * @return {*} {boolean} */ export declare function hasGrantedAnyScopes(tokenResponse: TokenResponse, firstScope: string, ...restScopes: string[]): boolean; /** * Helper method for [google.accounts.oauth2.revoke](https://developers.google.com/identity/oauth2/web/reference/js-reference#google.accounts.oauth2.revoke) * * @export * @param {string} accessToken * @param {() => void} [done] */ export declare function revokeAccessToken(accessToken: string, done?: () => void): void; export type CodeRequestRedirectUrlOptions = Omit; /** * Get the OAuth2 redirect URL for the authorization code flow * * @export * @param {CodeRequestRedirectUrlOptions} options * @return {string} */ export declare function buildCodeRequestRedirectUrl(options: CodeRequestRedirectUrlOptions): string; declare global { interface Window { google?: { accounts: { id: { initialize: (idConfiguration: IdConfiguration) => void; prompt: (momentListener?: MomentListener) => void; renderButton: (parent: HTMLElement, options: GsiButtonConfiguration, clickHandler?: () => void) => void; disableAutoSelect: () => void; storeCredential: (credential: { id: string; password: string; }, callback?: () => void) => void; cancel: () => void; onGoogleLibraryLoad: () => void; revoke: (hint: string, callback?: RevocationCallback) => void; }; oauth2: { initTokenClient: (config: TokenClientConfig) => { requestAccessToken: (overridableClientConfig?: OverridableTokenClientConfig) => void; }; initCodeClient: (config: CodeClientConfig) => CodeClient; hasGrantedAnyScope: (tokenResponse: TokenResponse, firstScope: string, ...restScopes: string[]) => boolean; hasGrantedAllScopes: (tokenResponse: TokenResponse, firstScope: string, ...restScopes: string[]) => boolean; revoke: (accessToken: string, done?: () => void) => void; }; }; }; } } export declare const PLUGIN_NAME = "GoogleSignInPlugin"; export interface GoogleSignInPluginOptions { /** * This field is your application's client ID, which is found and created in the Google Developers Console. * Pass a ref to set or change it later, for example after fetching it from your server. * Leave it out to give each composable or button its own `clientId`. * * @type {MaybeRef} * @see https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid * @memberof GoogleSignInPluginOptions */ clientId?: MaybeRef; /** * Language to load Google's script in, such as `en` or `fr`. It sets the * placeholder Google shows while a button loads and the One Tap prompt's text. * Defaults to the browser's language. Use the button's `locale` prop as well * to set the button itself. * * @type {string} * @memberof GoogleSignInPluginOptions */ locale?: string; } declare const plugin: Plugin; export { type AuthCodeFlowErrorResponse, type AuthCodeFlowOptions, type AuthCodeFlowSuccessResponse, type CodeClientErrorResponse, type CodeClientSuccessResponse, _default as GoogleSignInButton, type ImplicitFlowErrorResponse, type ImplicitFlowOptions, type ImplicitFlowSuccessResponse, type TokenClientErrorResponse, type TokenClientSuccessResponse, type UseCodeClientOptions, type UseCodeClientReturn as UseCodeClientResult, type UseGoogleOneTapLoginOptions, type UseOneTapResult as UseOneTapResponse, type UseTokenClientOptions, type UseTokenClientReturn as UseTokenClientResult, plugin as default, useCodeClient, useGsiScript, useOneTap, useTokenClient };