UNPKG

@curvenote/remix-auth-google

Version:

**Forked** and updated from [https://github.com/pbteja1998/remix-auth-google](https://github.com/pbteja1998/remix-auth-google) to use the latest `remix-auth-oauth2` strategy.

80 lines (79 loc) 2.45 kB
import { OAuth2Strategy } from 'remix-auth-oauth2'; import type { Strategy } from 'remix-auth/strategy'; /** * @see https://developers.google.com/identity/protocols/oauth2/scopes */ export type GoogleScope = string; export type GoogleStrategyOptions = { clientId: string; clientSecret: string; redirectURI: string; /** * @default "openid profile email" */ scopes?: GoogleScope[]; accessType?: 'online' | 'offline'; includeGrantedScopes?: boolean; prompt?: 'none' | 'consent' | 'select_account'; hd?: string; loginHint?: string; }; interface OAuth2Profile { provider: string; name?: { familyName?: string; givenName?: string; middleName?: string; }; } export type GoogleProfile = { id: string; displayName: string; name: { familyName: string; givenName: string; }; emails: [{ value: string; type?: string; }]; photos: [{ value: string; }]; _json: { sub: string; name: string; given_name: string; family_name: string; picture: string; locale: string; email: string; email_verified: boolean; hd: string; }; } & OAuth2Profile; export type GoogleExtraParams = { expires_in: 3920; token_type: 'Bearer'; scope: string; id_token: string; } & Record<string, string | number>; export declare const GoogleStrategyScopeSeperator = " "; export declare const GoogleStrategyDefaultScopes: string; export declare const GoogleStrategyDefaultName = "google"; export declare class GoogleStrategy<User> extends OAuth2Strategy<User> { static userInfoURL: string; name: string; private readonly accessType; private readonly prompt?; private readonly includeGrantedScopes; private readonly hd?; private readonly loginHint?; private readonly responseType; constructor({ clientId, clientSecret, redirectURI, scopes, accessType, includeGrantedScopes, prompt, hd, loginHint, }: GoogleStrategyOptions, verify: Strategy.VerifyFunction<User, OAuth2Strategy.VerifyOptions>); protected authorizationParams(params: URLSearchParams, request: Request): URLSearchParams; protected stringifyScopes(scopes: GoogleScope[]): string; static userProfile(accessToken: string): Promise<GoogleProfile>; static parseScopes(scopes: GoogleStrategyOptions['scopes']): string[]; } export {};