@swr-login/plugin-oauth-google 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 swr-login contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # @swr-login/plugin-oauth-google
2
+
3
+ > Google OAuth 2.0 login plugin for swr-login (supports Popup & Redirect with PKCE).
4
+
5
+ [![npm](https://img.shields.io/npm/v/@swr-login/plugin-oauth-google?color=blue)](https://www.npmjs.com/package/@swr-login/plugin-oauth-google)
6
+ [![license](https://img.shields.io/github/license/swr-login/swr-login)](https://github.com/swr-login/swr-login/blob/main/LICENSE)
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @swr-login/plugin-oauth-google
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```ts
17
+ import { GoogleOAuthPlugin } from '@swr-login/plugin-oauth-google';
18
+
19
+ const plugin = GoogleOAuthPlugin({
20
+ clientId: 'your-google-client-id',
21
+ redirectUri: 'https://yourapp.com/callback/google',
22
+ // 'popup' (default) | 'redirect'
23
+ mode: 'popup',
24
+ });
25
+ ```
26
+
27
+ Then use the `useLogin` hook:
28
+
29
+ ```tsx
30
+ const { login, isLoading } = useLogin('google');
31
+
32
+ <button onClick={() => login()}>Sign in with Google</button>
33
+ ```
34
+
35
+ ## Features
36
+
37
+ - 🔒 PKCE (Proof Key for Code Exchange) enforced
38
+ - 🔒 CSRF state parameter validation
39
+ - 🪟 Popup and redirect modes
40
+ - âš¡ Zero page refresh on login
41
+
42
+ ## Part of swr-login
43
+
44
+ See the full project at [github.com/swr-login/swr-login](https://github.com/swr-login/swr-login).
45
+
46
+ ## License
47
+
48
+ [MIT](https://github.com/swr-login/swr-login/blob/main/LICENSE)
package/dist/index.cjs ADDED
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ GoogleOAuthPlugin: () => GoogleOAuthPlugin,
24
+ handleGoogleCallback: () => handleGoogleCallback
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var import_core = require("@swr-login/core");
28
+ var DEFAULT_AUTHORIZE_URL = "https://accounts.google.com/o/oauth2/v2/auth";
29
+ var DEFAULT_SCOPES = ["openid", "profile", "email"];
30
+ function GoogleOAuthPlugin(options) {
31
+ const {
32
+ clientId,
33
+ redirectUri,
34
+ tokenEndpoint = "/api/auth/google/callback",
35
+ authorizeUrl = DEFAULT_AUTHORIZE_URL,
36
+ popupWidth = 500,
37
+ popupHeight = 600
38
+ } = options;
39
+ const getRedirectUri = () => redirectUri ?? (typeof window !== "undefined" ? `${window.location.origin}/auth/callback` : "");
40
+ return {
41
+ name: "oauth-google",
42
+ type: "oauth",
43
+ async login(credentials, ctx) {
44
+ const mode = credentials.mode ?? "popup";
45
+ const scopes = credentials.scopes ?? DEFAULT_SCOPES;
46
+ const pkce = await (0, import_core.generatePKCE)();
47
+ (0, import_core.storePKCEVerifier)(pkce.codeVerifier);
48
+ const state = (0, import_core.generateCSRFState)("google");
49
+ const params = new URLSearchParams({
50
+ client_id: clientId,
51
+ redirect_uri: getRedirectUri(),
52
+ response_type: "code",
53
+ scope: scopes.join(" "),
54
+ state,
55
+ code_challenge: pkce.codeChallenge,
56
+ code_challenge_method: pkce.codeChallengeMethod,
57
+ access_type: "offline",
58
+ prompt: "consent"
59
+ });
60
+ if (credentials.loginHint) {
61
+ params.set("login_hint", credentials.loginHint);
62
+ }
63
+ const authUrl = `${authorizeUrl}?${params.toString()}`;
64
+ if (mode === "redirect") {
65
+ window.location.href = authUrl;
66
+ return new Promise(() => {
67
+ });
68
+ }
69
+ return new Promise((resolve, reject) => {
70
+ const left = Math.round(window.screenX + (window.outerWidth - popupWidth) / 2);
71
+ const top = Math.round(window.screenY + (window.outerHeight - popupHeight) / 2);
72
+ const popup = window.open(
73
+ authUrl,
74
+ "swr-login-google",
75
+ `width=${popupWidth},height=${popupHeight},left=${left},top=${top},toolbar=no,menubar=no`
76
+ );
77
+ if (!popup) {
78
+ reject(new import_core.OAuthPopupError("Popup was blocked by the browser"));
79
+ return;
80
+ }
81
+ const pollTimer = setInterval(() => {
82
+ if (popup.closed) {
83
+ clearInterval(pollTimer);
84
+ reject(new import_core.OAuthPopupError("Popup was closed by user"));
85
+ }
86
+ }, 500);
87
+ const handleMessage = async (event) => {
88
+ if (event.origin !== ctx.origin) return;
89
+ const { type, code, state: returnedState, error } = event.data ?? {};
90
+ if (type !== "SWR_LOGIN_OAUTH_CALLBACK") return;
91
+ clearInterval(pollTimer);
92
+ window.removeEventListener("message", handleMessage);
93
+ popup.close();
94
+ if (error) {
95
+ reject(new import_core.OAuthPopupError(error));
96
+ return;
97
+ }
98
+ if (!(0, import_core.validateCSRFState)(returnedState, "google")) {
99
+ reject(new import_core.OAuthPopupError("CSRF state validation failed"));
100
+ return;
101
+ }
102
+ try {
103
+ const response = await fetch(tokenEndpoint, {
104
+ method: "POST",
105
+ headers: { "Content-Type": "application/json" },
106
+ credentials: "include",
107
+ body: JSON.stringify({
108
+ code,
109
+ code_verifier: pkce.codeVerifier,
110
+ redirect_uri: getRedirectUri()
111
+ })
112
+ });
113
+ if (!response.ok) {
114
+ throw new Error(`Token exchange failed: ${response.statusText}`);
115
+ }
116
+ const data = await response.json();
117
+ const authResponse = {
118
+ user: data.user,
119
+ accessToken: data.accessToken ?? data.access_token,
120
+ refreshToken: data.refreshToken ?? data.refresh_token,
121
+ expiresAt: data.expiresAt ?? data.expires_at ?? Date.now() + 3600 * 1e3
122
+ };
123
+ ctx.setTokens({
124
+ accessToken: authResponse.accessToken,
125
+ refreshToken: authResponse.refreshToken,
126
+ expiresAt: authResponse.expiresAt
127
+ });
128
+ resolve(authResponse);
129
+ } catch (err) {
130
+ reject(err);
131
+ }
132
+ };
133
+ window.addEventListener("message", handleMessage);
134
+ });
135
+ },
136
+ async logout(ctx) {
137
+ ctx.clearTokens();
138
+ }
139
+ };
140
+ }
141
+ function handleGoogleCallback() {
142
+ if (typeof window === "undefined") return;
143
+ const params = new URLSearchParams(window.location.search);
144
+ const code = params.get("code");
145
+ const state = params.get("state");
146
+ const error = params.get("error");
147
+ if (window.opener) {
148
+ window.opener.postMessage(
149
+ {
150
+ type: "SWR_LOGIN_OAUTH_CALLBACK",
151
+ code,
152
+ state,
153
+ error
154
+ },
155
+ window.location.origin
156
+ );
157
+ }
158
+ }
159
+ // Annotate the CommonJS export names for ESM import in node:
160
+ 0 && (module.exports = {
161
+ GoogleOAuthPlugin,
162
+ handleGoogleCallback
163
+ });
164
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n type AuthResponse,\n OAuthPopupError,\n type SWRLoginPlugin,\n generateCSRFState,\n generatePKCE,\n storePKCEVerifier,\n validateCSRFState,\n} from '@swr-login/core';\n\nexport interface GoogleOAuthCredentials {\n /** Login mode: popup (no refresh) or redirect */\n mode?: 'popup' | 'redirect';\n /** Custom scopes (default: ['openid', 'profile', 'email']) */\n scopes?: string[];\n /** Login hint (email address) */\n loginHint?: string;\n}\n\nexport interface GoogleOAuthPluginOptions {\n /** Google OAuth Client ID */\n clientId: string;\n /** Redirect URI for OAuth callback */\n redirectUri?: string;\n /** Backend token exchange endpoint */\n tokenEndpoint?: string;\n /** Authorization endpoint (default: Google's) */\n authorizeUrl?: string;\n /** Popup window dimensions */\n popupWidth?: number;\n popupHeight?: number;\n}\n\nconst DEFAULT_AUTHORIZE_URL = 'https://accounts.google.com/o/oauth2/v2/auth';\nconst DEFAULT_SCOPES = ['openid', 'profile', 'email'];\n\n/**\n * Google OAuth 2.0 login plugin with PKCE support.\n *\n * Supports two modes:\n * - **Popup** (default): Opens OAuth flow in a popup window. Main page stays intact.\n * - **Redirect**: Full-page redirect to Google, then back to your app.\n *\n * @example\n * ```ts\n * import { GoogleOAuthPlugin } from '@swr-login/plugin-oauth-google';\n *\n * const plugin = GoogleOAuthPlugin({\n * clientId: 'your-google-client-id.apps.googleusercontent.com',\n * tokenEndpoint: '/api/auth/google/callback',\n * });\n * ```\n */\nexport function GoogleOAuthPlugin(\n options: GoogleOAuthPluginOptions,\n): SWRLoginPlugin<GoogleOAuthCredentials> {\n const {\n clientId,\n redirectUri,\n tokenEndpoint = '/api/auth/google/callback',\n authorizeUrl = DEFAULT_AUTHORIZE_URL,\n popupWidth = 500,\n popupHeight = 600,\n } = options;\n\n const getRedirectUri = () =>\n redirectUri ?? (typeof window !== 'undefined' ? `${window.location.origin}/auth/callback` : '');\n\n return {\n name: 'oauth-google',\n type: 'oauth',\n\n async login(credentials, ctx) {\n const mode = credentials.mode ?? 'popup';\n const scopes = credentials.scopes ?? DEFAULT_SCOPES;\n\n const pkce = await generatePKCE();\n storePKCEVerifier(pkce.codeVerifier);\n\n const state = generateCSRFState('google');\n\n const params = new URLSearchParams({\n client_id: clientId,\n redirect_uri: getRedirectUri(),\n response_type: 'code',\n scope: scopes.join(' '),\n state,\n code_challenge: pkce.codeChallenge,\n code_challenge_method: pkce.codeChallengeMethod,\n access_type: 'offline',\n prompt: 'consent',\n });\n\n if (credentials.loginHint) {\n params.set('login_hint', credentials.loginHint);\n }\n\n const authUrl = `${authorizeUrl}?${params.toString()}`;\n\n if (mode === 'redirect') {\n window.location.href = authUrl;\n // Will never resolve - page navigates away\n return new Promise<AuthResponse>(() => {});\n }\n\n // Popup mode\n return new Promise<AuthResponse>((resolve, reject) => {\n const left = Math.round(window.screenX + (window.outerWidth - popupWidth) / 2);\n const top = Math.round(window.screenY + (window.outerHeight - popupHeight) / 2);\n\n const popup = window.open(\n authUrl,\n 'swr-login-google',\n `width=${popupWidth},height=${popupHeight},left=${left},top=${top},toolbar=no,menubar=no`,\n );\n\n if (!popup) {\n reject(new OAuthPopupError('Popup was blocked by the browser'));\n return;\n }\n\n // Poll for popup close and listen for postMessage\n const pollTimer = setInterval(() => {\n if (popup.closed) {\n clearInterval(pollTimer);\n reject(new OAuthPopupError('Popup was closed by user'));\n }\n }, 500);\n\n const handleMessage = async (event: MessageEvent) => {\n if (event.origin !== ctx.origin) return;\n\n const { type, code, state: returnedState, error } = event.data ?? {};\n\n if (type !== 'SWR_LOGIN_OAUTH_CALLBACK') return;\n\n clearInterval(pollTimer);\n window.removeEventListener('message', handleMessage);\n popup.close();\n\n if (error) {\n reject(new OAuthPopupError(error));\n return;\n }\n\n if (!validateCSRFState(returnedState, 'google')) {\n reject(new OAuthPopupError('CSRF state validation failed'));\n return;\n }\n\n try {\n // Exchange code for tokens via backend\n const response = await fetch(tokenEndpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n credentials: 'include',\n body: JSON.stringify({\n code,\n code_verifier: pkce.codeVerifier,\n redirect_uri: getRedirectUri(),\n }),\n });\n\n if (!response.ok) {\n throw new Error(`Token exchange failed: ${response.statusText}`);\n }\n\n const data = await response.json();\n const authResponse: AuthResponse = {\n user: data.user,\n accessToken: data.accessToken ?? data.access_token,\n refreshToken: data.refreshToken ?? data.refresh_token,\n expiresAt: data.expiresAt ?? data.expires_at ?? Date.now() + 3600 * 1000,\n };\n\n ctx.setTokens({\n accessToken: authResponse.accessToken,\n refreshToken: authResponse.refreshToken,\n expiresAt: authResponse.expiresAt,\n });\n\n resolve(authResponse);\n } catch (err) {\n reject(err);\n }\n };\n\n window.addEventListener('message', handleMessage);\n });\n },\n\n async logout(ctx) {\n ctx.clearTokens();\n },\n };\n}\n\n/**\n * Helper: Call this from your OAuth callback page to send the code back to the opener.\n *\n * @example\n * ```ts\n * // pages/auth/callback.tsx\n * import { handleGoogleCallback } from '@swr-login/plugin-oauth-google';\n *\n * useEffect(() => {\n * handleGoogleCallback();\n * }, []);\n * ```\n */\nexport function handleGoogleCallback(): void {\n if (typeof window === 'undefined') return;\n\n const params = new URLSearchParams(window.location.search);\n const code = params.get('code');\n const state = params.get('state');\n const error = params.get('error');\n\n if (window.opener) {\n window.opener.postMessage(\n {\n type: 'SWR_LOGIN_OAUTH_CALLBACK',\n code,\n state,\n error,\n },\n window.location.origin,\n );\n }\n}\n"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kBAAM,eAA6B;AAAA,cACjC,MAAM,KAAK;AAAA,cACX,aAAa,KAAK,eAAe,KAAK;AAAA,cACtC,cAAc,KAAK,gBAAgB,KAAK;AAAA,cACxC,WAAW,KAAK,aAAa,KAAK,cAAc,KAAK,IAAI,IAAI,OAAO;AAAA,YACtE;AAEA,gBAAI,UAAU;AAAA,cACZ,aAAa,aAAa;AAAA,cAC1B,cAAc,aAAa;AAAA,cAC3B,WAAW,aAAa;AAAA,YAC1B,CAAC;AAED,oBAAQ,YAAY;AAAA,UACtB,SAAS,KAAK;AACZ,mBAAO,GAAG;AAAA,UACZ;AAAA,QACF;AAEA,eAAO,iBAAiB,WAAW,aAAa;AAAA,MAClD,CAAC;AAAA,IACH;AAAA,IAEA,MAAM,OAAO,KAAK;AAChB,UAAI,YAAY;AAAA,IAClB;AAAA,EACF;AACF;AAeO,SAAS,uBAA6B;AAC3C,MAAI,OAAO,WAAW,YAAa;AAEnC,QAAM,SAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM;AACzD,QAAM,OAAO,OAAO,IAAI,MAAM;AAC9B,QAAM,QAAQ,OAAO,IAAI,OAAO;AAChC,QAAM,QAAQ,OAAO,IAAI,OAAO;AAEhC,MAAI,OAAO,QAAQ;AACjB,WAAO,OAAO;AAAA,MACZ;AAAA,QACE,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAO,SAAS;AAAA,IAClB;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,57 @@
1
+ import { SWRLoginPlugin } from '@swr-login/core';
2
+
3
+ interface GoogleOAuthCredentials {
4
+ /** Login mode: popup (no refresh) or redirect */
5
+ mode?: 'popup' | 'redirect';
6
+ /** Custom scopes (default: ['openid', 'profile', 'email']) */
7
+ scopes?: string[];
8
+ /** Login hint (email address) */
9
+ loginHint?: string;
10
+ }
11
+ interface GoogleOAuthPluginOptions {
12
+ /** Google OAuth Client ID */
13
+ clientId: string;
14
+ /** Redirect URI for OAuth callback */
15
+ redirectUri?: string;
16
+ /** Backend token exchange endpoint */
17
+ tokenEndpoint?: string;
18
+ /** Authorization endpoint (default: Google's) */
19
+ authorizeUrl?: string;
20
+ /** Popup window dimensions */
21
+ popupWidth?: number;
22
+ popupHeight?: number;
23
+ }
24
+ /**
25
+ * Google OAuth 2.0 login plugin with PKCE support.
26
+ *
27
+ * Supports two modes:
28
+ * - **Popup** (default): Opens OAuth flow in a popup window. Main page stays intact.
29
+ * - **Redirect**: Full-page redirect to Google, then back to your app.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { GoogleOAuthPlugin } from '@swr-login/plugin-oauth-google';
34
+ *
35
+ * const plugin = GoogleOAuthPlugin({
36
+ * clientId: 'your-google-client-id.apps.googleusercontent.com',
37
+ * tokenEndpoint: '/api/auth/google/callback',
38
+ * });
39
+ * ```
40
+ */
41
+ declare function GoogleOAuthPlugin(options: GoogleOAuthPluginOptions): SWRLoginPlugin<GoogleOAuthCredentials>;
42
+ /**
43
+ * Helper: Call this from your OAuth callback page to send the code back to the opener.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * // pages/auth/callback.tsx
48
+ * import { handleGoogleCallback } from '@swr-login/plugin-oauth-google';
49
+ *
50
+ * useEffect(() => {
51
+ * handleGoogleCallback();
52
+ * }, []);
53
+ * ```
54
+ */
55
+ declare function handleGoogleCallback(): void;
56
+
57
+ export { type GoogleOAuthCredentials, GoogleOAuthPlugin, type GoogleOAuthPluginOptions, handleGoogleCallback };
@@ -0,0 +1,57 @@
1
+ import { SWRLoginPlugin } from '@swr-login/core';
2
+
3
+ interface GoogleOAuthCredentials {
4
+ /** Login mode: popup (no refresh) or redirect */
5
+ mode?: 'popup' | 'redirect';
6
+ /** Custom scopes (default: ['openid', 'profile', 'email']) */
7
+ scopes?: string[];
8
+ /** Login hint (email address) */
9
+ loginHint?: string;
10
+ }
11
+ interface GoogleOAuthPluginOptions {
12
+ /** Google OAuth Client ID */
13
+ clientId: string;
14
+ /** Redirect URI for OAuth callback */
15
+ redirectUri?: string;
16
+ /** Backend token exchange endpoint */
17
+ tokenEndpoint?: string;
18
+ /** Authorization endpoint (default: Google's) */
19
+ authorizeUrl?: string;
20
+ /** Popup window dimensions */
21
+ popupWidth?: number;
22
+ popupHeight?: number;
23
+ }
24
+ /**
25
+ * Google OAuth 2.0 login plugin with PKCE support.
26
+ *
27
+ * Supports two modes:
28
+ * - **Popup** (default): Opens OAuth flow in a popup window. Main page stays intact.
29
+ * - **Redirect**: Full-page redirect to Google, then back to your app.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { GoogleOAuthPlugin } from '@swr-login/plugin-oauth-google';
34
+ *
35
+ * const plugin = GoogleOAuthPlugin({
36
+ * clientId: 'your-google-client-id.apps.googleusercontent.com',
37
+ * tokenEndpoint: '/api/auth/google/callback',
38
+ * });
39
+ * ```
40
+ */
41
+ declare function GoogleOAuthPlugin(options: GoogleOAuthPluginOptions): SWRLoginPlugin<GoogleOAuthCredentials>;
42
+ /**
43
+ * Helper: Call this from your OAuth callback page to send the code back to the opener.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * // pages/auth/callback.tsx
48
+ * import { handleGoogleCallback } from '@swr-login/plugin-oauth-google';
49
+ *
50
+ * useEffect(() => {
51
+ * handleGoogleCallback();
52
+ * }, []);
53
+ * ```
54
+ */
55
+ declare function handleGoogleCallback(): void;
56
+
57
+ export { type GoogleOAuthCredentials, GoogleOAuthPlugin, type GoogleOAuthPluginOptions, handleGoogleCallback };
package/dist/index.js ADDED
@@ -0,0 +1,144 @@
1
+ // src/index.ts
2
+ import {
3
+ OAuthPopupError,
4
+ generateCSRFState,
5
+ generatePKCE,
6
+ storePKCEVerifier,
7
+ validateCSRFState
8
+ } from "@swr-login/core";
9
+ var DEFAULT_AUTHORIZE_URL = "https://accounts.google.com/o/oauth2/v2/auth";
10
+ var DEFAULT_SCOPES = ["openid", "profile", "email"];
11
+ function GoogleOAuthPlugin(options) {
12
+ const {
13
+ clientId,
14
+ redirectUri,
15
+ tokenEndpoint = "/api/auth/google/callback",
16
+ authorizeUrl = DEFAULT_AUTHORIZE_URL,
17
+ popupWidth = 500,
18
+ popupHeight = 600
19
+ } = options;
20
+ const getRedirectUri = () => redirectUri ?? (typeof window !== "undefined" ? `${window.location.origin}/auth/callback` : "");
21
+ return {
22
+ name: "oauth-google",
23
+ type: "oauth",
24
+ async login(credentials, ctx) {
25
+ const mode = credentials.mode ?? "popup";
26
+ const scopes = credentials.scopes ?? DEFAULT_SCOPES;
27
+ const pkce = await generatePKCE();
28
+ storePKCEVerifier(pkce.codeVerifier);
29
+ const state = generateCSRFState("google");
30
+ const params = new URLSearchParams({
31
+ client_id: clientId,
32
+ redirect_uri: getRedirectUri(),
33
+ response_type: "code",
34
+ scope: scopes.join(" "),
35
+ state,
36
+ code_challenge: pkce.codeChallenge,
37
+ code_challenge_method: pkce.codeChallengeMethod,
38
+ access_type: "offline",
39
+ prompt: "consent"
40
+ });
41
+ if (credentials.loginHint) {
42
+ params.set("login_hint", credentials.loginHint);
43
+ }
44
+ const authUrl = `${authorizeUrl}?${params.toString()}`;
45
+ if (mode === "redirect") {
46
+ window.location.href = authUrl;
47
+ return new Promise(() => {
48
+ });
49
+ }
50
+ return new Promise((resolve, reject) => {
51
+ const left = Math.round(window.screenX + (window.outerWidth - popupWidth) / 2);
52
+ const top = Math.round(window.screenY + (window.outerHeight - popupHeight) / 2);
53
+ const popup = window.open(
54
+ authUrl,
55
+ "swr-login-google",
56
+ `width=${popupWidth},height=${popupHeight},left=${left},top=${top},toolbar=no,menubar=no`
57
+ );
58
+ if (!popup) {
59
+ reject(new OAuthPopupError("Popup was blocked by the browser"));
60
+ return;
61
+ }
62
+ const pollTimer = setInterval(() => {
63
+ if (popup.closed) {
64
+ clearInterval(pollTimer);
65
+ reject(new OAuthPopupError("Popup was closed by user"));
66
+ }
67
+ }, 500);
68
+ const handleMessage = async (event) => {
69
+ if (event.origin !== ctx.origin) return;
70
+ const { type, code, state: returnedState, error } = event.data ?? {};
71
+ if (type !== "SWR_LOGIN_OAUTH_CALLBACK") return;
72
+ clearInterval(pollTimer);
73
+ window.removeEventListener("message", handleMessage);
74
+ popup.close();
75
+ if (error) {
76
+ reject(new OAuthPopupError(error));
77
+ return;
78
+ }
79
+ if (!validateCSRFState(returnedState, "google")) {
80
+ reject(new OAuthPopupError("CSRF state validation failed"));
81
+ return;
82
+ }
83
+ try {
84
+ const response = await fetch(tokenEndpoint, {
85
+ method: "POST",
86
+ headers: { "Content-Type": "application/json" },
87
+ credentials: "include",
88
+ body: JSON.stringify({
89
+ code,
90
+ code_verifier: pkce.codeVerifier,
91
+ redirect_uri: getRedirectUri()
92
+ })
93
+ });
94
+ if (!response.ok) {
95
+ throw new Error(`Token exchange failed: ${response.statusText}`);
96
+ }
97
+ const data = await response.json();
98
+ const authResponse = {
99
+ user: data.user,
100
+ accessToken: data.accessToken ?? data.access_token,
101
+ refreshToken: data.refreshToken ?? data.refresh_token,
102
+ expiresAt: data.expiresAt ?? data.expires_at ?? Date.now() + 3600 * 1e3
103
+ };
104
+ ctx.setTokens({
105
+ accessToken: authResponse.accessToken,
106
+ refreshToken: authResponse.refreshToken,
107
+ expiresAt: authResponse.expiresAt
108
+ });
109
+ resolve(authResponse);
110
+ } catch (err) {
111
+ reject(err);
112
+ }
113
+ };
114
+ window.addEventListener("message", handleMessage);
115
+ });
116
+ },
117
+ async logout(ctx) {
118
+ ctx.clearTokens();
119
+ }
120
+ };
121
+ }
122
+ function handleGoogleCallback() {
123
+ if (typeof window === "undefined") return;
124
+ const params = new URLSearchParams(window.location.search);
125
+ const code = params.get("code");
126
+ const state = params.get("state");
127
+ const error = params.get("error");
128
+ if (window.opener) {
129
+ window.opener.postMessage(
130
+ {
131
+ type: "SWR_LOGIN_OAUTH_CALLBACK",
132
+ code,
133
+ state,
134
+ error
135
+ },
136
+ window.location.origin
137
+ );
138
+ }
139
+ }
140
+ export {
141
+ GoogleOAuthPlugin,
142
+ handleGoogleCallback
143
+ };
144
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n type AuthResponse,\n OAuthPopupError,\n type SWRLoginPlugin,\n generateCSRFState,\n generatePKCE,\n storePKCEVerifier,\n validateCSRFState,\n} from '@swr-login/core';\n\nexport interface GoogleOAuthCredentials {\n /** Login mode: popup (no refresh) or redirect */\n mode?: 'popup' | 'redirect';\n /** Custom scopes (default: ['openid', 'profile', 'email']) */\n scopes?: string[];\n /** Login hint (email address) */\n loginHint?: string;\n}\n\nexport interface GoogleOAuthPluginOptions {\n /** Google OAuth Client ID */\n clientId: string;\n /** Redirect URI for OAuth callback */\n redirectUri?: string;\n /** Backend token exchange endpoint */\n tokenEndpoint?: string;\n /** Authorization endpoint (default: Google's) */\n authorizeUrl?: string;\n /** Popup window dimensions */\n popupWidth?: number;\n popupHeight?: number;\n}\n\nconst DEFAULT_AUTHORIZE_URL = 'https://accounts.google.com/o/oauth2/v2/auth';\nconst DEFAULT_SCOPES = ['openid', 'profile', 'email'];\n\n/**\n * Google OAuth 2.0 login plugin with PKCE support.\n *\n * Supports two modes:\n * - **Popup** (default): Opens OAuth flow in a popup window. Main page stays intact.\n * - **Redirect**: Full-page redirect to Google, then back to your app.\n *\n * @example\n * ```ts\n * import { GoogleOAuthPlugin } from '@swr-login/plugin-oauth-google';\n *\n * const plugin = GoogleOAuthPlugin({\n * clientId: 'your-google-client-id.apps.googleusercontent.com',\n * tokenEndpoint: '/api/auth/google/callback',\n * });\n * ```\n */\nexport function GoogleOAuthPlugin(\n options: GoogleOAuthPluginOptions,\n): SWRLoginPlugin<GoogleOAuthCredentials> {\n const {\n clientId,\n redirectUri,\n tokenEndpoint = '/api/auth/google/callback',\n authorizeUrl = DEFAULT_AUTHORIZE_URL,\n popupWidth = 500,\n popupHeight = 600,\n } = options;\n\n const getRedirectUri = () =>\n redirectUri ?? (typeof window !== 'undefined' ? `${window.location.origin}/auth/callback` : '');\n\n return {\n name: 'oauth-google',\n type: 'oauth',\n\n async login(credentials, ctx) {\n const mode = credentials.mode ?? 'popup';\n const scopes = credentials.scopes ?? DEFAULT_SCOPES;\n\n const pkce = await generatePKCE();\n storePKCEVerifier(pkce.codeVerifier);\n\n const state = generateCSRFState('google');\n\n const params = new URLSearchParams({\n client_id: clientId,\n redirect_uri: getRedirectUri(),\n response_type: 'code',\n scope: scopes.join(' '),\n state,\n code_challenge: pkce.codeChallenge,\n code_challenge_method: pkce.codeChallengeMethod,\n access_type: 'offline',\n prompt: 'consent',\n });\n\n if (credentials.loginHint) {\n params.set('login_hint', credentials.loginHint);\n }\n\n const authUrl = `${authorizeUrl}?${params.toString()}`;\n\n if (mode === 'redirect') {\n window.location.href = authUrl;\n // Will never resolve - page navigates away\n return new Promise<AuthResponse>(() => {});\n }\n\n // Popup mode\n return new Promise<AuthResponse>((resolve, reject) => {\n const left = Math.round(window.screenX + (window.outerWidth - popupWidth) / 2);\n const top = Math.round(window.screenY + (window.outerHeight - popupHeight) / 2);\n\n const popup = window.open(\n authUrl,\n 'swr-login-google',\n `width=${popupWidth},height=${popupHeight},left=${left},top=${top},toolbar=no,menubar=no`,\n );\n\n if (!popup) {\n reject(new OAuthPopupError('Popup was blocked by the browser'));\n return;\n }\n\n // Poll for popup close and listen for postMessage\n const pollTimer = setInterval(() => {\n if (popup.closed) {\n clearInterval(pollTimer);\n reject(new OAuthPopupError('Popup was closed by user'));\n }\n }, 500);\n\n const handleMessage = async (event: MessageEvent) => {\n if (event.origin !== ctx.origin) return;\n\n const { type, code, state: returnedState, error } = event.data ?? {};\n\n if (type !== 'SWR_LOGIN_OAUTH_CALLBACK') return;\n\n clearInterval(pollTimer);\n window.removeEventListener('message', handleMessage);\n popup.close();\n\n if (error) {\n reject(new OAuthPopupError(error));\n return;\n }\n\n if (!validateCSRFState(returnedState, 'google')) {\n reject(new OAuthPopupError('CSRF state validation failed'));\n return;\n }\n\n try {\n // Exchange code for tokens via backend\n const response = await fetch(tokenEndpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n credentials: 'include',\n body: JSON.stringify({\n code,\n code_verifier: pkce.codeVerifier,\n redirect_uri: getRedirectUri(),\n }),\n });\n\n if (!response.ok) {\n throw new Error(`Token exchange failed: ${response.statusText}`);\n }\n\n const data = await response.json();\n const authResponse: AuthResponse = {\n user: data.user,\n accessToken: data.accessToken ?? data.access_token,\n refreshToken: data.refreshToken ?? data.refresh_token,\n expiresAt: data.expiresAt ?? data.expires_at ?? Date.now() + 3600 * 1000,\n };\n\n ctx.setTokens({\n accessToken: authResponse.accessToken,\n refreshToken: authResponse.refreshToken,\n expiresAt: authResponse.expiresAt,\n });\n\n resolve(authResponse);\n } catch (err) {\n reject(err);\n }\n };\n\n window.addEventListener('message', handleMessage);\n });\n },\n\n async logout(ctx) {\n ctx.clearTokens();\n },\n };\n}\n\n/**\n * Helper: Call this from your OAuth callback page to send the code back to the opener.\n *\n * @example\n * ```ts\n * // pages/auth/callback.tsx\n * import { handleGoogleCallback } from '@swr-login/plugin-oauth-google';\n *\n * useEffect(() => {\n * handleGoogleCallback();\n * }, []);\n * ```\n */\nexport function handleGoogleCallback(): void {\n if (typeof window === 'undefined') return;\n\n const params = new URLSearchParams(window.location.search);\n const code = params.get('code');\n const state = params.get('state');\n const error = params.get('error');\n\n if (window.opener) {\n window.opener.postMessage(\n {\n type: 'SWR_LOGIN_OAUTH_CALLBACK',\n code,\n state,\n error,\n },\n window.location.origin,\n );\n }\n}\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAyBP,IAAM,wBAAwB;AAC9B,IAAM,iBAAiB,CAAC,UAAU,WAAW,OAAO;AAmB7C,SAAS,kBACd,SACwC;AACxC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,aAAa;AAAA,IACb,cAAc;AAAA,EAChB,IAAI;AAEJ,QAAM,iBAAiB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Y;AAAA,UACtB,SAAS,KAAK;AACZ,mBAAO,GAAG;AAAA,UACZ;AAAA,QACF;AAEA,eAAO,iBAAiB,WAAW,aAAa;AAAA,MAClD,CAAC;AAAA,IACH;AAAA,IAEA,MAAM,OAAO,KAAK;AAChB,UAAI,YAAY;AAAA,IAClB;AAAA,EACF;AACF;AAeO,SAAS,uBAA6B;AAC3C,MAAI,OAAO,WAAW,YAAa;AAEnC,QAAM,SAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM;AACzD,QAAM,OAAO,OAAO,IAAI,MAAM;AAC9B,QAAM,QAAQ,OAAO,IAAI,OAAO;AAChC,QAAM,QAAQ,OAAO,IAAI,OAAO;AAEhC,MAAI,OAAO,QAAQ;AACjB,WAAO,OAAO;AAAA,MACZ;AAAA,QACE,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAO,SAAS;AAAA,IAClB;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@swr-login/plugin-oauth-google",
3
+ "version": "0.1.0",
4
+ "description": "Google OAuth 2.0 login plugin for swr-login (supports Popup & Redirect with PKCE)",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "sideEffects": false,
25
+ "dependencies": {
26
+ "@swr-login/core": "0.1.0"
27
+ },
28
+ "keywords": [
29
+ "swr-login",
30
+ "plugin",
31
+ "google",
32
+ "oauth",
33
+ "login"
34
+ ],
35
+ "license": "MIT",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/swr-login/swr-login",
39
+ "directory": "packages/plugin-oauth-google"
40
+ },
41
+ "homepage": "https://github.com/swr-login/swr-login#readme",
42
+ "bugs": "https://github.com/swr-login/swr-login/issues",
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "scripts": {
47
+ "build": "tsup",
48
+ "dev": "tsup --watch",
49
+ "clean": "rm -rf dist"
50
+ }
51
+ }