@logto/connector-google 1.6.1 → 1.8.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/README.md CHANGED
@@ -1,85 +1,213 @@
1
1
  # Google connector
2
2
 
3
- The Google connector provides a succinct way for your application to use Google’s OAuth 2.0 authentication system.
3
+ Integrate Google OAuth 2.0 authentication system to enable Sign-in with Google, account linking, and secure access to Google APIs.
4
4
 
5
5
  **Table of contents**
6
- - [Set up a project in the Google API Console](#set-up-a-project-in-the-google-api-console)
7
- - [Configure your consent screen](#configure-your-consent-screen)
8
- - [Configure and register your application](#configure-and-register-your-application)
9
- - [Edit app registration](#edit-app-registration)
10
- - [Config OAuth consent screen](#config-oauth-consent-screen)
11
- - [Config scopes](#config-scopes)
12
- - [Add test users (External user type only)](#add-test-users-external-user-type-only)
13
- - [Obtain OAuth 2.0 credentials](#obtain-oauth-20-credentials)
14
- - [Configure your connector](#configure-your-connector)
15
- - [Config types](#config-types)
16
- - [References](#references)
6
+ - [Get started](#get-started)
7
+ - [Step 1: Create a project on Google Auth Platform](#step-1-create-a-project-on-google-auth-platform)
8
+ - [Step 2: Create OAuth 2.0 credentials](#step-2-create-oauth-20-credentials)
9
+ - [Step 3: Configure Logto connector with credentials](#step-3-configure-logto-connector-with-credentials)
10
+ - [Step 4: Configure scopes](#step-4-configure-scopes)
11
+ - [Step 5: Customize authentication prompts](#step-5-customize-authentication-prompts)
12
+ - [Step 6: General settings](#step-6-general-settings)
13
+ - [Step 7: Enable Google One Tap (Optional)](#step-7-enable-google-one-tap-optional)
14
+ - [Step 8: Test and publish your app](#step-8-test-and-publish-your-app)
15
+ - [Utilize the Google connector](#utilize-the-google-connector)
16
+ - [Manage user's Google identity](#manage-users-google-identity)
17
+ - [Reference](#reference)
17
18
 
18
- ## Set up a project in the Google API Console
19
+ ## Get started
19
20
 
20
- - Visit the [Google API Console](https://console.developers.google.com) and sign in with your Google account.
21
- - Click the **Select a project** button on the top menu bar, and click the **New Project** button to create a project.
22
- - In your newly created project, click the **APIs & Services** to enter the **APIs & Services** menu.
21
+ The Google connector enables OAuth 2.0 integration to let your application:
23
22
 
24
- ## Configure your consent screen
23
+ - Add "Sign-in with Google" authentication
24
+ - Link user accounts to Google identities
25
+ - Sync user profile info from Google
26
+ - Access Google APIs through secure token storage in Logto [Secret Vault](https://docs.logto.io/secret-vault/federated-token-set) for automation tasks (e.g., editing Google Docs, managing Calendar events in your app)
25
27
 
26
- ### Configure and register your application
28
+ ## Step 1: Create a project on Google Auth Platform
27
29
 
28
- - On the left **APIs & Services** menu, click the **OAuth consent screen** button.
29
- - Choose the **User Type** you want, and click the **Create** button. (Note: If you select **External** as your **User Type**, you will need to add test users later.)
30
+ Before you can use Google as an authentication provider, you must set up a project in the Google Cloud Console to obtain OAuth 2.0 credentials. If you already have a project, you can skip this step.
30
31
 
31
- Now you will be on the **Edit app registration** page.
32
+ 1. Visit the [Google Cloud Console](https://console.cloud.google.com/) and sign in with your Google account.
33
+ 2. Click the **Select a project** button on the top menu bar, then click the **New Project** button to create a project.
34
+ 3. In your newly created project, navigate to **APIs & Services > OAuth consent screen** to configure your app:
35
+ - **App information**: Enter the **Application name** and **Support email** to be displayed on the consent page
36
+ - **Audience**: Select your preferred audience type:
37
+ - **Internal** - Only for Google Workspace users within your organization
38
+ - **External** - For any Google user (requires verification for production use)
39
+ - **Contact information**: Provide email addresses so Google can notify you about any changes to your project
40
+ - Check **I agree to Google's policies** to finish the basic setup
41
+ 4. Optionally, go to the **Branding** section to edit product info and upload your **App logo**, which will appear on the OAuth consent screen to help users recognize your app.
32
42
 
33
- ### Edit app registration
43
+ **Tip**: If you choose **External** audience type, you'll need to add test users during development and publish your app for production use.
34
44
 
35
- #### Config OAuth consent screen
45
+ ## Step 2: Create OAuth 2.0 credentials
36
46
 
37
- - Follow the instructions to fill out the **OAuth consent screen** form.
38
- - Click **SAVE AND CONTINUE** to continue.
47
+ Navigate to the [Credentials](https://console.cloud.google.com/apis/credentials) page in Google Cloud Console and create OAuth credentials for your application.
39
48
 
40
- #### Config scopes
49
+ 1. Click **Create Credentials > OAuth client ID**.
50
+ 2. Select **Web application** as the application type.
51
+ 3. Fill in the **Name** of your OAuth client. This helps you identify the credentials and is not shown to end users.
52
+ 4. Configure the authorized URIs:
53
+ - **Authorized JavaScript origins**: Add your Logto instance's origin (e.g., `https://your-logto-domain.com`)
54
+ - **Authorized redirect URIs**: Add the Logto **Callback URI** (copy this from your Logto Google connector)
55
+ 5. Click **Create** to generate the OAuth client.
41
56
 
42
- - Click **ADD OR REMOVE SCOPES** and select `../auth/userinfo.email`, `../auth/userinfo.profile` and `openid` in the popup drawer, and click **UPDATE** to finish. It is recommended that you consider adding all the scopes you may use, otherwise some scopes you added in the configuration may not work.
43
- - Fill out the form as you need.
44
- - Click **SAVE AND CONTINUE** to continue.
57
+ ## Step 3: Configure Logto connector with credentials
45
58
 
46
- #### Add test users (External user type only)
59
+ After creating the OAuth client, Google will display a modal with your credentials:
47
60
 
48
- - Click **ADD USERS** and add test users to allow these users to access your application while testing.
49
- - Click **SAVE AND CONTINUE** to continue.
61
+ 1. Copy the **Client ID** and paste it into the `clientId` field in Logto
62
+ 2. Copy the **Client secret** and paste it into the `clientSecret` field in Logto
63
+ 3. Click **Save and Done** in Logto to connect your identity system with Google
50
64
 
51
- Now you should have the Google OAuth 2.0 consent screen configured.
65
+ **Warning**: Keep your client secret secure and never expose it in client-side code. If compromised, generate a new one immediately.
52
66
 
53
- ## Obtain OAuth 2.0 credentials
67
+ ## Step 4: Configure scopes
54
68
 
55
- - On the left **APIs & Services** menu, click the **Credentials** button.
56
- - On the **Credentials** page, click the **+ CREATE CREDENTIALS** button on the top menu bar, and select **OAuth client ID**.
57
- - On the **Create OAuth client ID** page, select **Web application** as the application type.
58
- - Fill out the basic information for your application.
59
- - Click **+ Add URI** to add an authorized domain to the **Authorized JavaScript origins** section. This is the domain that your logto authorization page will be served from. In our case, this will be `${your_logto_endpoint_origin}`. e.g.`https://foo.logto.app`.
60
- - Click **+ Add URI** in the ****Authorized redirect URIs**** section to set up the ****Authorized redirect URIs****, which redirect the user to the application after logging in. In our case, this will be `${your_logto_endpoint}/callback/${connector_id}`. e.g. `https://foo.logto.app/callback/${connector_id}`. The `connector_id` can be found on the top bar of the Logto Admin Console connector details page.
61
- - Click **Create** to finish and then you will get the **Client ID** and **Client Secret**.
69
+ Scopes define the permissions your app requests from users and control which data your app can access from their Google accounts.
62
70
 
63
- ## Configure your connector
71
+ ### Configure scopes in Google Cloud Console
64
72
 
65
- Fill out the `clientId` and `clientSecret` field with _Client ID_ and _Client Secret_ you've got from OAuth app detail pages mentioned in the previous section.
73
+ 1. Navigate to **APIs & Services > OAuth consent screen > Scopes**.
74
+ 2. Click **Add or Remove Scopes** and select only the scopes your app requires:
75
+ - **Authentication (Required)**:
76
+ - `https://www.googleapis.com/auth/userinfo.email`
77
+ - `https://www.googleapis.com/auth/userinfo.profile`
78
+ - `openid`
79
+ - **API access (Optional)**: Add any additional scopes needed for your app (e.g., Drive, Calendar, YouTube). Browse the [Google API Library](https://console.cloud.google.com/apis/library) to find available services. If your app needs access to Google APIs beyond basic permissions, first enable the specific APIs your app will use (e.g., Google Drive API, Gmail API, Calendar API) in the Google API Library.
80
+ 3. Click **Update** to confirm the selection.
81
+ 4. Click **Save and Continue** to apply the changes.
66
82
 
67
- `scope` is a space-delimited list of [scopes](https://developers.google.com/identity/protocols/oauth2/scopes). If not provided, scope defaults to be `openid profile email`.
83
+ ### Configure scopes in Logto
68
84
 
69
- `prompts` is an array of strings that specifies the type of user interaction that is required. The string can be one of the following values:
85
+ Choose one or more of the following approaches based on your needs:
70
86
 
71
- - `none`: The authorization server does not display any authentication or user consent screens; it will return an error if the user is not already authenticated and has not pre-configured consent for the requested scopes. You can use none to check for existing authentication and/or consent.
72
- - `consent`: The authorization server prompts the user for consent before returning information to the client.
73
- - `select_account`: The authorization server prompts the user to select a user account. This allows a user who has multiple accounts at the authorization server to select amongst the multiple accounts that they may have current sessions for.
87
+ **Option 1: No extra API scopes needed**
74
88
 
75
- ### Config types
89
+ - Leave the `Scopes` field in your Logto Google connector blank.
90
+ - The default scopes `openid profile email` will be requested to ensure Logto can get basic user info properly.
76
91
 
77
- | Name | Type |
78
- |--------------|----------|
79
- | clientId | string |
80
- | clientSecret | string |
81
- | scope | string |
82
- | prompts | string[] |
92
+ **Option 2: Request additional scopes at sign-in**
83
93
 
84
- ## References
85
- * [Google Identity: Setting up OAuth 2.0](https://developers.google.com/identity/protocols/oauth2/openid-connect#appsetup)
94
+ - Enter all desired scopes in the **Scopes** field, separated by spaces.
95
+ - Any scopes you list here override the defaults, so always include the authentication scopes: `https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile openid`.
96
+ - Use full scope URLs. Example: `https://www.googleapis.com/auth/calendar.readonly`.
97
+
98
+ **Option 3: Request incremental scopes later**
99
+
100
+ - After the user signs in, you can [request additional scopes](https://docs.logto.io/secret-vault/federated-token-set#reauthentication-and-token-renewal) on demand by reinitiating a federated social authorization flow and updating users' stored token set.
101
+ - These additional scopes do not need to be filled in the `Scopes` field in your Logto Google connector, and can be achieved through Logto's Social Verification API.
102
+
103
+ By following these steps, your Logto Google connector requests exactly the permissions your app needs - no more, no less.
104
+
105
+ **Tip**: If your app requests these scopes to access the Google API and perform actions, make sure to enable **Store tokens for persistent API access** in Logto Google connector. See the next section for details.
106
+
107
+ ## Step 5: Customize authentication prompts
108
+
109
+ Configure **Prompts** in Logto to control the user authentication experience. Prompts is an array of strings that specifies the type of user interaction required:
110
+
111
+ - `none` - The authorization server does not display any authentication or consent screens. Returns an error if the user is not already authenticated and has not pre-configured consent for the requested scopes. Use this to check for existing authentication and/or consent.
112
+ - `consent` - The authorization server prompts the user for consent before returning information to the client. Required to enable **offline access** for Google API access.
113
+ - `select_account` - The authorization server prompts the user to select a user account. This allows users with multiple Google accounts to choose which account to use for authentication.
114
+
115
+ ## Step 6: General settings
116
+
117
+ Here are some general settings that won't block the connection to Google but may affect the end-user authentication experience.
118
+
119
+ ### Sync profile information
120
+
121
+ In the Google connector, you can set the policy for syncing profile information, such as user names and avatars. Choose from:
122
+
123
+ - **Only sync at sign-up**: Profile info is fetched once when the user first signs in.
124
+ - **Always sync at sign-in**: Profile info is updated every time the user signs in.
125
+
126
+ ### Store tokens to access Google APIs (Optional)
127
+
128
+ If you want to access [Google APIs](https://console.cloud.google.com/apis/library) and perform actions with user authorization (whether via social sign-in or account linking), Logto needs to get specific API scopes and store tokens.
129
+
130
+ 1. Add the required scopes in your Google Cloud Console OAuth consent screen configuration and Logto Google connector.
131
+ 2. Enable **Store tokens for persistent API access** in Logto Google connector. Logto will securely store Google access and refresh tokens in the Secret Vault.
132
+ 3. To ensure refresh tokens are returned, configure your Logto Google connector as follows:
133
+ - Set **Prompts** to include `consent`
134
+ - Enable **Offline Access**
135
+
136
+ **Warning**: You do not need to add `offline_access` in the Logto `Scope` field — doing so may cause an error. Google uses `access_type=offline` automatically when offline access is enabled.
137
+
138
+ ## Step 7: Enable Google One Tap (Optional)
139
+
140
+ [Google One Tap](https://developers.google.com/identity/gsi/web/guides/features) is a secure and streamlined way to let users sign in to your website with their Google account using a popup interface.
141
+
142
+ Once you have the Google connector set up, you'll see a card for Google One Tap in the connector details page. Enable Google One Tap by toggling the switch.
143
+
144
+ ### Google One Tap configuration options
145
+
146
+ - **Auto-select credential if possible** - Automatically sign in the user with the Google account if [certain conditions are met](https://developers.google.com/identity/gsi/web/guides/automatic-sign-in-sign-out)
147
+ - **Cancel the prompt if user clicks/taps outside** - Close the Google One Tap prompt if the user clicks or taps outside the prompt. If disabled, the user must click the close button to dismiss the prompt.
148
+ - **Enable Upgraded One Tap UX on ITP browsers** - Enable the upgraded Google One Tap user experience on Intelligent Tracking Prevention (ITP) browsers. Refer to [this documentation](https://developers.google.com/identity/gsi/web/guides/features#upgraded_ux_on_itp_browsers) for more information.
149
+
150
+ **Warning**: Make sure to add your domain to the **Authorized JavaScript origins** section in your OAuth client configuration. Otherwise, Google One Tap cannot be displayed.
151
+
152
+ ### Important limitations with Google One Tap
153
+
154
+ If you enable **Store tokens for persistent API access** along with **Google One Tap**, you won't automatically receive an access token or the requested scopes.
155
+
156
+ Google One Tap sign-in (unlike the standard "Sign in with Google" button) does **not** issue an OAuth access token. It only returns an ID token (a signed JWT) that verifies the user's identity, but does not grant API access.
157
+
158
+ To access Google APIs with Google One Tap users, you can use [Logto's Social Verification API](https://openapi.logto.io/operation/operation-createverificationbysocial) to [reinitiate a federated social authorization flow](https://docs.logto.io/secret-vault/federated-token-set#reauthentication-and-token-renewal) after the user signs in with Google One Tap. This allows you to request additional scopes as needed and update the user's stored token set, without requiring the scopes to be pre-filled in the Logto Google connector. This approach enables incremental authorization, so users are only prompted for extra permissions when your app actually needs them.
159
+
160
+ Learn more about [Google One Tap limitations](https://developers.google.com/identity/gsi/web/guides/overview) in the official documentation.
161
+
162
+ ## Step 8: Test and publish your app
163
+
164
+ ### For Internal apps
165
+
166
+ If your **Audience** type in Google is set to **Internal**, your app will be available only to Google Workspace users within your organization. You can test using any account from your organization.
167
+
168
+ ### For External apps
169
+
170
+ If your **Audience** type is **External**:
171
+
172
+ 1. **During development**: Navigate to **OAuth consent screen > Test users** and add test user email addresses. Only these users can sign in with your app.
173
+ 2. **For production**: Click **Publish App** in the OAuth consent screen section to make it available to anyone with a Google Account.
174
+
175
+ **Note**: Apps with sensitive or restricted scopes may require Google's verification before they can be published. This process can take several weeks.
176
+
177
+ ## Utilize the Google connector
178
+
179
+ Once you've created a Google connector and connected it to Google, you can incorporate it into your end-user flows. Choose the options that match your needs:
180
+
181
+ ### Enable "Sign-in with Google"
182
+
183
+ 1. In Logto Console, go to [Sign-in experience > Sign-up and sign-in](https://cloud.logto.io/to/sign-in-experience/sign-up-and-sign-in).
184
+ 2. Add the Google connector under **Social sign-in** section to let users authenticate with Google.
185
+ 3. Optionally enable **Google One Tap** on the sign-in and sign-up pages for a streamlined authentication experience.
186
+
187
+ Learn more about [social sign-in experience](https://docs.logto.io//end-user-flows/sign-up-and-sign-in/social-sign-in).
188
+
189
+ ### Link or unlink a Google account
190
+
191
+ Use the Account API to build a custom Account Center in your app that lets signed-in users link or unlink their Google account. [Follow the Account API tutorial](https://docs.logto.io//end-user-flows/account-settings/by-account-api#link-a-new-social-connection)
192
+
193
+ **Tip**: It's allowed to enable the Google connector only for account linking and API access, without enabling it for social sign-in.
194
+
195
+ ### Access Google APIs and perform actions
196
+
197
+ Your application can retrieve stored Google access tokens from the [Secret Vault](https://docs.logto.io/secret-vault) to call Google APIs and automate backend tasks (for example, managing Google Drive files, creating Calendar events, or sending emails through Gmail). [Refer to the guide](https://docs.logto.io/secret-vault/federated-token-set) on retrieving stored tokens for API access.
198
+
199
+ ## Manage user's Google identity
200
+
201
+ After a user links their Google account, admins can manage that connection in the Logto Console:
202
+
203
+ 1. Navigate to [Logto console > User management](https://cloud.logto.io/to/users) and open the user's profile.
204
+ 2. Under **Social connections**, locate the Google item and click **Manage**.
205
+ 3. On this page, admins can manage the user's Google connection, see all profile information granted and synced from their Google account, and check the [access token status](https://docs.logto.io/secret-vault/federated-token-set#token-storage-status).
206
+
207
+ ## Reference
208
+
209
+ [Google Identity: Setting up OAuth 2.0](https://developers.google.com/identity/protocols/oauth2/openid-connect#appsetup)
210
+
211
+ [Google Identity Services (One Tap)](https://developers.google.com/identity/gsi/web/guides/overview)
212
+
213
+ [Google Cloud Console](https://console.cloud.google.com/)
package/lib/index.js CHANGED
@@ -7,7 +7,8 @@ import {
7
7
  validateConfig,
8
8
  ConnectorType,
9
9
  parseJson,
10
- GoogleConnector as GoogleConnector3
10
+ GoogleConnector as GoogleConnector3,
11
+ getAccessTokenByRefreshToken as _getAccessTokenByRefreshToken
11
12
  } from "@logto/connector-kit";
12
13
  import { createRemoteJWKSet, jwtVerify } from "jose";
13
14
 
@@ -58,11 +59,11 @@ var defaultMetadata = {
58
59
  },
59
60
  {
60
61
  key: "scope",
61
- type: ConnectorConfigFormItemType.Text,
62
+ type: ConnectorConfigFormItemType.MultilineText,
62
63
  label: "Scope",
63
64
  required: false,
64
- placeholder: "<scope>",
65
- description: "The `scope` determines permissions granted by the user's authorization. If you are not sure what to enter, do not worry, just leave it blank."
65
+ placeholder: "Enter the scopes (separated by a space)",
66
+ description: "The `scope` determines permissions granted by the user's authorization. "
66
67
  },
67
68
  {
68
69
  key: "prompts",
@@ -75,8 +76,17 @@ var defaultMetadata = {
75
76
  value: prompt
76
77
  })),
77
78
  defaultValue: [OidcPrompt.SelectAccount]
79
+ },
80
+ {
81
+ key: "offlineAccess",
82
+ type: ConnectorConfigFormItemType.Switch,
83
+ required: false,
84
+ label: "Refresh access token",
85
+ defaultValue: false,
86
+ description: 'Enable Google `offline` access to request a refresh token, allowing your app to refresh the access token without user re-authorization. (Note: "consent" prompt is required)'
78
87
  }
79
- ]
88
+ ],
89
+ isTokenStorageSupported: true
80
90
  };
81
91
  var defaultTimeout = 5e3;
82
92
  var jwksUri = "https://www.googleapis.com/oauth2/v3/certs";
@@ -87,7 +97,9 @@ import { GoogleConnector as GoogleConnector2 } from "@logto/connector-kit";
87
97
  var accessTokenResponseGuard = z.object({
88
98
  access_token: z.string(),
89
99
  scope: z.string(),
90
- token_type: z.string()
100
+ token_type: z.string(),
101
+ expires_in: z.number().or(z.string()).optional(),
102
+ refresh_token: z.string().optional()
91
103
  });
92
104
  var userInfoResponseGuard = z.object({
93
105
  sub: z.string(),
@@ -108,17 +120,19 @@ var googleOneTapDataGuard = z.object({
108
120
  });
109
121
 
110
122
  // src/index.ts
111
- var getAuthorizationUri = (getConfig) => async ({ state, redirectUri }) => {
123
+ var getAuthorizationUri = (getConfig) => async ({ state, redirectUri, scope: customScope }) => {
112
124
  const config = await getConfig(defaultMetadata.id);
113
125
  validateConfig(config, GoogleConnector3.configGuard);
114
- const { clientId, scope: scope2, prompts } = config;
126
+ const { clientId, scope: scope2, prompts, offlineAccess } = config;
115
127
  const queryParameters = new URLSearchParams({
116
128
  client_id: clientId,
117
129
  redirect_uri: redirectUri,
118
130
  response_type: "code",
119
131
  state,
120
- scope: scope2 ?? scope,
121
- ...conditional(prompts && prompts.length > 0 && { prompt: prompts.join(" ") })
132
+ scope: customScope ?? scope2 ?? scope,
133
+ ...conditional(prompts && prompts.length > 0 && { prompt: prompts.join(" ") }),
134
+ // Add `access_type=offline` if offlineAccess is enabled.
135
+ ...conditional(offlineAccess && { access_type: "offline" })
122
136
  });
123
137
  return `${authorizationEndpoint}?${queryParameters.toString()}`;
124
138
  };
@@ -141,9 +155,9 @@ var getAccessToken = async (config, codeObject) => {
141
155
  }
142
156
  const { access_token: accessToken } = result.data;
143
157
  assert(accessToken, new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid));
144
- return { accessToken };
158
+ return result.data;
145
159
  };
146
- var getUserInfoJson = async (data, config) => {
160
+ var getUserInfoJsonAndTokenResponse = async (data, config) => {
147
161
  const oneTapResult = googleOneTapDataGuard.safeParse(data);
148
162
  if (oneTapResult.success) {
149
163
  const { payload } = await jwtVerify(
@@ -156,34 +170,56 @@ var getUserInfoJson = async (data, config) => {
156
170
  clockTolerance: 10
157
171
  }
158
172
  );
159
- return payload;
173
+ return {
174
+ rawUserInfo: payload
175
+ };
160
176
  }
161
177
  const { code, redirectUri } = await authorizationCallbackHandler(data);
162
- const { accessToken } = await getAccessToken(config, { code, redirectUri });
178
+ const tokenResponse = await getAccessToken(config, { code, redirectUri });
179
+ const { access_token: accessToken } = tokenResponse;
163
180
  const httpResponse = await got.post(userInfoEndpoint, {
164
181
  headers: {
165
182
  authorization: `Bearer ${accessToken}`
166
183
  },
167
184
  timeout: { request: defaultTimeout }
168
185
  });
169
- return parseJson(httpResponse.body);
186
+ return {
187
+ rawUserInfo: parseJson(httpResponse.body),
188
+ tokenResponse
189
+ };
190
+ };
191
+ var parseUserInfoResponse = (rawUserInfo) => {
192
+ const result = userInfoResponseGuard.safeParse(rawUserInfo);
193
+ if (!result.success) {
194
+ throw new ConnectorError(ConnectorErrorCodes.InvalidResponse, result.error);
195
+ }
196
+ const { sub: id, picture: avatar, email, email_verified, name } = result.data;
197
+ return {
198
+ id,
199
+ avatar,
200
+ email: conditional(email_verified && email),
201
+ name,
202
+ rawData: rawUserInfo
203
+ };
170
204
  };
171
205
  var getUserInfo = (getConfig) => async (data) => {
172
206
  const config = await getConfig(defaultMetadata.id);
173
207
  validateConfig(config, GoogleConnector3.configGuard);
174
208
  try {
175
- const rawData = await getUserInfoJson(data, config);
176
- const result = userInfoResponseGuard.safeParse(rawData);
177
- if (!result.success) {
178
- throw new ConnectorError(ConnectorErrorCodes.InvalidResponse, result.error);
179
- }
180
- const { sub: id, picture: avatar, email, email_verified, name } = result.data;
209
+ const { rawUserInfo } = await getUserInfoJsonAndTokenResponse(data, config);
210
+ return parseUserInfoResponse(rawUserInfo);
211
+ } catch (error) {
212
+ return getUserInfoErrorHandler(error);
213
+ }
214
+ };
215
+ var getTokenResponseAndUserInfo = (getConfig) => async (data) => {
216
+ const config = await getConfig(defaultMetadata.id);
217
+ validateConfig(config, GoogleConnector3.configGuard);
218
+ try {
219
+ const { rawUserInfo, tokenResponse } = await getUserInfoJsonAndTokenResponse(data, config);
181
220
  return {
182
- id,
183
- avatar,
184
- email: conditional(email_verified && email),
185
- name,
186
- rawData
221
+ userInfo: parseUserInfoResponse(rawUserInfo),
222
+ tokenResponse
187
223
  };
188
224
  } catch (error) {
189
225
  return getUserInfoErrorHandler(error);
@@ -206,13 +242,27 @@ var getUserInfoErrorHandler = (error) => {
206
242
  }
207
243
  throw error;
208
244
  };
245
+ var getAccessTokenByRefreshToken = (getConfig) => async (refreshToken) => {
246
+ const config = await getConfig(defaultMetadata.id);
247
+ validateConfig(config, GoogleConnector3.configGuard);
248
+ return _getAccessTokenByRefreshToken(
249
+ {
250
+ clientId: config.clientId,
251
+ clientSecret: config.clientSecret,
252
+ tokenEndpoint: accessTokenEndpoint
253
+ },
254
+ refreshToken
255
+ );
256
+ };
209
257
  var createGoogleConnector = async ({ getConfig }) => {
210
258
  return {
211
259
  metadata: defaultMetadata,
212
260
  type: ConnectorType.Social,
213
261
  configGuard: GoogleConnector3.configGuard,
214
262
  getAuthorizationUri: getAuthorizationUri(getConfig),
215
- getUserInfo: getUserInfo(getConfig)
263
+ getUserInfo: getUserInfo(getConfig),
264
+ getTokenResponseAndUserInfo: getTokenResponseAndUserInfo(getConfig),
265
+ getAccessTokenByRefreshToken: getAccessTokenByRefreshToken(getConfig)
216
266
  };
217
267
  };
218
268
  var index_default = createGoogleConnector;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/constant.ts","../src/types.ts"],"sourcesContent":["/**\n * The Implementation of OpenID Connect of Google Identity Platform.\n * https://developers.google.com/identity/protocols/oauth2/openid-connect\n */\nimport { conditional, assert } from '@silverhand/essentials';\nimport { got, HTTPError } from 'got';\n\nimport type {\n GetAuthorizationUri,\n GetUserInfo,\n GetConnectorConfig,\n CreateConnector,\n SocialConnector,\n GoogleConnectorConfig,\n} from '@logto/connector-kit';\nimport {\n ConnectorError,\n ConnectorErrorCodes,\n validateConfig,\n ConnectorType,\n parseJson,\n GoogleConnector,\n} from '@logto/connector-kit';\nimport { createRemoteJWKSet, jwtVerify } from 'jose';\n\nimport {\n accessTokenEndpoint,\n authorizationEndpoint,\n scope as defaultScope,\n userInfoEndpoint,\n defaultMetadata,\n defaultTimeout,\n jwksUri,\n} from './constant.js';\nimport {\n accessTokenResponseGuard,\n userInfoResponseGuard,\n authResponseGuard,\n googleOneTapDataGuard,\n} from './types.js';\n\nconst getAuthorizationUri =\n (getConfig: GetConnectorConfig): GetAuthorizationUri =>\n async ({ state, redirectUri }) => {\n const config = await getConfig(defaultMetadata.id);\n validateConfig(config, GoogleConnector.configGuard);\n\n const { clientId, scope, prompts } = config;\n\n const queryParameters = new URLSearchParams({\n client_id: clientId,\n redirect_uri: redirectUri,\n response_type: 'code',\n state,\n scope: scope ?? defaultScope,\n ...conditional(prompts && prompts.length > 0 && { prompt: prompts.join(' ') }),\n });\n\n return `${authorizationEndpoint}?${queryParameters.toString()}`;\n };\n\nexport const getAccessToken = async (\n config: GoogleConnectorConfig,\n codeObject: { code: string; redirectUri: string }\n) => {\n const { code, redirectUri } = codeObject;\n const { clientId, clientSecret } = config;\n\n // Note:Need to decodeURIComponent on code\n // https://stackoverflow.com/questions/51058256/google-api-node-js-invalid-grant-malformed-auth-code\n const httpResponse = await got.post(accessTokenEndpoint, {\n form: {\n code: decodeURIComponent(code),\n client_id: clientId,\n client_secret: clientSecret,\n redirect_uri: redirectUri,\n grant_type: 'authorization_code',\n },\n timeout: { request: defaultTimeout },\n });\n\n const result = accessTokenResponseGuard.safeParse(parseJson(httpResponse.body));\n\n if (!result.success) {\n throw new ConnectorError(ConnectorErrorCodes.InvalidResponse, result.error);\n }\n\n const { access_token: accessToken } = result.data;\n\n assert(accessToken, new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid));\n\n return { accessToken };\n};\n\ntype Json = ReturnType<typeof parseJson>;\n\n/**\n * Get user information JSON from Google Identity Platform. It will use the following order to\n * retrieve user information:\n *\n * 1. Google One Tap: https://developers.google.com/identity/gsi/web/guides/verify-google-id-token\n * 2. Normal Google OAuth: https://developers.google.com/identity/protocols/oauth2/openid-connect\n *\n * @param data The data from the client.\n * @param config The configuration of the connector.\n * @returns A Promise that resolves to the user information JSON.\n */\nconst getUserInfoJson = async (data: unknown, config: GoogleConnectorConfig): Promise<Json> => {\n // Google One Tap\n const oneTapResult = googleOneTapDataGuard.safeParse(data);\n\n if (oneTapResult.success) {\n const { payload } = await jwtVerify<Json>(\n oneTapResult.data.credential,\n createRemoteJWKSet(new URL(jwksUri)),\n {\n // https://developers.google.com/identity/gsi/web/guides/verify-google-id-token\n issuer: ['https://accounts.google.com', 'accounts.google.com'],\n audience: config.clientId,\n clockTolerance: 10,\n }\n );\n return payload;\n }\n\n // Normal Google OAuth\n const { code, redirectUri } = await authorizationCallbackHandler(data);\n const { accessToken } = await getAccessToken(config, { code, redirectUri });\n\n const httpResponse = await got.post(userInfoEndpoint, {\n headers: {\n authorization: `Bearer ${accessToken}`,\n },\n timeout: { request: defaultTimeout },\n });\n return parseJson(httpResponse.body);\n};\n\nconst getUserInfo =\n (getConfig: GetConnectorConfig): GetUserInfo =>\n async (data) => {\n const config = await getConfig(defaultMetadata.id);\n validateConfig(config, GoogleConnector.configGuard);\n\n try {\n const rawData = await getUserInfoJson(data, config);\n const result = userInfoResponseGuard.safeParse(rawData);\n\n if (!result.success) {\n throw new ConnectorError(ConnectorErrorCodes.InvalidResponse, result.error);\n }\n\n const { sub: id, picture: avatar, email, email_verified, name } = result.data;\n\n return {\n id,\n avatar,\n email: conditional(email_verified && email),\n name,\n rawData,\n };\n } catch (error: unknown) {\n return getUserInfoErrorHandler(error);\n }\n };\n\nconst authorizationCallbackHandler = async (parameterObject: unknown) => {\n const result = authResponseGuard.safeParse(parameterObject);\n\n if (!result.success) {\n throw new ConnectorError(ConnectorErrorCodes.General, JSON.stringify(parameterObject));\n }\n\n return result.data;\n};\n\nconst getUserInfoErrorHandler = (error: unknown) => {\n if (error instanceof HTTPError) {\n const { statusCode, body: rawBody } = error.response;\n\n if (statusCode === 401) {\n throw new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid);\n }\n\n throw new ConnectorError(ConnectorErrorCodes.General, JSON.stringify(rawBody));\n }\n\n throw error;\n};\n\nconst createGoogleConnector: CreateConnector<SocialConnector> = async ({ getConfig }) => {\n return {\n metadata: defaultMetadata,\n type: ConnectorType.Social,\n configGuard: GoogleConnector.configGuard,\n getAuthorizationUri: getAuthorizationUri(getConfig),\n getUserInfo: getUserInfo(getConfig),\n };\n};\n\nexport default createGoogleConnector;\n","import type { ConnectorMetadata } from '@logto/connector-kit';\nimport {\n ConnectorConfigFormItemType,\n ConnectorPlatform,\n GoogleConnector,\n OidcPrompt,\n} from '@logto/connector-kit';\n\nexport const authorizationEndpoint = 'https://accounts.google.com/o/oauth2/v2/auth';\nexport const accessTokenEndpoint = 'https://oauth2.googleapis.com/token';\nexport const userInfoEndpoint = 'https://openidconnect.googleapis.com/v1/userinfo';\nexport const scope = 'openid profile email';\n\n// Instead of defining the metadata in the connector, we reuse the metadata from the connector-kit.\n// This is not the normal practice, but Google One Tap is a special case.\n// @see {@link GoogleConnector} for more information.\nexport const defaultMetadata: ConnectorMetadata = {\n id: GoogleConnector.factoryId,\n target: GoogleConnector.target,\n platform: ConnectorPlatform.Universal,\n name: {\n en: 'Google',\n 'zh-CN': 'Google',\n 'tr-TR': 'Google',\n ko: 'Google',\n },\n logo: './logo.svg',\n logoDark: null,\n description: {\n en: 'Google is a principal search engine technology and email service provider.',\n 'zh-CN': 'Google 是全球性的搜索引擎和邮件服务提供商。',\n 'tr-TR': 'Google, en büyük arama motoru teknolojisi ve e-posta servis sağlayıcısıdır.',\n ko: 'Google은 가장 큰 검색 엔진 기술과 이메일 서비스 제공자입니다.',\n },\n readme: './README.md',\n formItems: [\n {\n key: 'clientId',\n type: ConnectorConfigFormItemType.Text,\n label: 'Client ID',\n required: true,\n placeholder: '<client-id>',\n },\n {\n key: 'clientSecret',\n type: ConnectorConfigFormItemType.Text,\n label: 'Client Secret',\n required: true,\n placeholder: '<client-secret>',\n },\n {\n key: 'scope',\n type: ConnectorConfigFormItemType.Text,\n label: 'Scope',\n required: false,\n placeholder: '<scope>',\n description:\n \"The `scope` determines permissions granted by the user's authorization. If you are not sure what to enter, do not worry, just leave it blank.\",\n },\n {\n key: 'prompts',\n type: ConnectorConfigFormItemType.MultiSelect,\n required: false,\n label: 'Prompts',\n // Google does not support `login` prompt.\n // Ref: https://developers.google.com/identity/openid-connect/openid-connect#authenticationuriparameters\n selectItems: Object.values(OidcPrompt)\n .filter((prompt) => prompt !== OidcPrompt.Login)\n .map((prompt) => ({\n value: prompt,\n })),\n defaultValue: [OidcPrompt.SelectAccount],\n },\n ],\n};\n\nexport const defaultTimeout = 5000;\n\n// https://developers.google.com/identity/gsi/web/guides/verify-google-id-token\nexport const jwksUri = 'https://www.googleapis.com/oauth2/v3/certs';\n","import { z } from 'zod';\n\nimport { GoogleConnector } from '@logto/connector-kit';\n\nexport const accessTokenResponseGuard = z.object({\n access_token: z.string(),\n scope: z.string(),\n token_type: z.string(),\n});\n\nexport type AccessTokenResponse = z.infer<typeof accessTokenResponseGuard>;\n\nexport const userInfoResponseGuard = z.object({\n sub: z.string(),\n name: z.string().optional(),\n given_name: z.string().optional(),\n family_name: z.string().optional(),\n picture: z.string().optional(),\n email: z.string().optional(),\n email_verified: z.boolean().optional(),\n locale: z.string().optional(),\n});\n\nexport type UserInfoResponse = z.infer<typeof userInfoResponseGuard>;\n\nexport const authResponseGuard = z.object({\n code: z.string(),\n redirectUri: z.string(),\n});\n\n/**\n * Response payload from Google One Tap. Note the CSRF token is not included since it should be\n * verified by the web server.\n */\nexport const googleOneTapDataGuard = z.object({\n [GoogleConnector.oneTapParams.credential]: z.string(),\n});\n"],"mappings":";AAIA,SAAS,aAAa,cAAc;AACpC,SAAS,KAAK,iBAAiB;AAU/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAAA;AAAA,OACK;AACP,SAAS,oBAAoB,iBAAiB;;;ACtB9C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,wBAAwB;AAC9B,IAAM,sBAAsB;AAC5B,IAAM,mBAAmB;AACzB,IAAM,QAAQ;AAKd,IAAM,kBAAqC;AAAA,EAChD,IAAI,gBAAgB;AAAA,EACpB,QAAQ,gBAAgB;AAAA,EACxB,UAAU,kBAAkB;AAAA,EAC5B,MAAM;AAAA,IACJ,IAAI;AAAA,IACJ,SAAS;AAAA,IACT,SAAS;AAAA,IACT,IAAI;AAAA,EACN;AAAA,EACA,MAAM;AAAA,EACN,UAAU;AAAA,EACV,aAAa;AAAA,IACX,IAAI;AAAA,IACJ,SAAS;AAAA,IACT,SAAS;AAAA,IACT,IAAI;AAAA,EACN;AAAA,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AAAA,MACL;AAAA,MACA;AAAA,MACA,OAAO,YAAY,kBAAkB,KAAK;AAAA,MAC1C;AAAA,MACA;AAAA,IACF;AAAA,EACF,SAAS,OAAgB;AACvB,WAAO,wBAAwB,KAAK;AAAA,EACtC;AACF;AAEF,IAAM,+BAA+B,OAAO,oBAA6B;AACvE,QAAM,SAAS,kBAAkB,UAAU,eAAe;AAE1D,MAAI,CAAC,OAAO,SAAS;AACnB,UAAM,IAAI,eAAe,oBAAoB,SAAS,KAAK,UAAU,eAAe,CAAC;AAAA,EACvF;AAEA,SAAO,OAAO;AAChB;AAEA,IAAM,0BAA0B,CAAC,UAAmB;AAClD,MAAI,iBAAiB,WAAW;AAC9B,UAAM,EAAE,YAAY,MAAM,QAAQ,IAAI,MAAM;AAE5C,QAAI,eAAe,KAAK;AACtB,YAAM,IAAI,eAAe,oBAAoB,wBAAwB;AAAA,IACvE;AAEA,UAAM,IAAI,eAAe,oBAAoB,SAAS,KAAK,UAAU,OAAO,CAAC;AAAA,EAC/E;AAEA,QAAM;AACR;AAEA,IAAM,wBAA0D,OAAO,EAAE,UAAU,MAAM;AACvF,SAAO;AAAA,IACL,UAAU;AAAA,IACV,MAAM,cAAc;AAAA,IACpB,aAAaA,iBAAgB;AAAA,IAC7B,qBAAqB,oBAAoB,SAAS;AAAA,IAClD,aAAa,YAAY,SAAS;AAAA,EACpC;AACF;AAEA,IAAO,gBAAQ;","names":["GoogleConnector","GoogleConnector","GoogleConnector","scope"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/constant.ts","../src/types.ts"],"sourcesContent":["/**\n * The Implementation of OpenID Connect of Google Identity Platform.\n * https://developers.google.com/identity/protocols/oauth2/openid-connect\n */\nimport { conditional, assert } from '@silverhand/essentials';\nimport { got, HTTPError } from 'got';\n\nimport type {\n GetAuthorizationUri,\n GetUserInfo,\n GetConnectorConfig,\n CreateConnector,\n SocialConnector,\n GoogleConnectorConfig,\n SocialUserInfo,\n GetTokenResponseAndUserInfo,\n GetAccessTokenByRefreshToken,\n} from '@logto/connector-kit';\nimport {\n ConnectorError,\n ConnectorErrorCodes,\n validateConfig,\n ConnectorType,\n parseJson,\n GoogleConnector,\n getAccessTokenByRefreshToken as _getAccessTokenByRefreshToken,\n} from '@logto/connector-kit';\nimport { createRemoteJWKSet, jwtVerify } from 'jose';\n\nimport {\n accessTokenEndpoint,\n authorizationEndpoint,\n scope as defaultScope,\n userInfoEndpoint,\n defaultMetadata,\n defaultTimeout,\n jwksUri,\n} from './constant.js';\nimport {\n accessTokenResponseGuard,\n userInfoResponseGuard,\n authResponseGuard,\n googleOneTapDataGuard,\n type AccessTokenResponse,\n} from './types.js';\n\nconst getAuthorizationUri =\n (getConfig: GetConnectorConfig): GetAuthorizationUri =>\n async ({ state, redirectUri, scope: customScope }) => {\n const config = await getConfig(defaultMetadata.id);\n validateConfig(config, GoogleConnector.configGuard);\n\n const { clientId, scope, prompts, offlineAccess } = config;\n\n const queryParameters = new URLSearchParams({\n client_id: clientId,\n redirect_uri: redirectUri,\n response_type: 'code',\n state,\n scope: customScope ?? scope ?? defaultScope,\n ...conditional(prompts && prompts.length > 0 && { prompt: prompts.join(' ') }),\n // Add `access_type=offline` if offlineAccess is enabled.\n ...conditional(offlineAccess && { access_type: 'offline' }),\n });\n\n return `${authorizationEndpoint}?${queryParameters.toString()}`;\n };\n\nexport const getAccessToken = async (\n config: GoogleConnectorConfig,\n codeObject: { code: string; redirectUri: string }\n) => {\n const { code, redirectUri } = codeObject;\n const { clientId, clientSecret } = config;\n\n // Note:Need to decodeURIComponent on code\n // https://stackoverflow.com/questions/51058256/google-api-node-js-invalid-grant-malformed-auth-code\n const httpResponse = await got.post(accessTokenEndpoint, {\n form: {\n code: decodeURIComponent(code),\n client_id: clientId,\n client_secret: clientSecret,\n redirect_uri: redirectUri,\n grant_type: 'authorization_code',\n },\n timeout: { request: defaultTimeout },\n });\n\n const result = accessTokenResponseGuard.safeParse(parseJson(httpResponse.body));\n\n if (!result.success) {\n throw new ConnectorError(ConnectorErrorCodes.InvalidResponse, result.error);\n }\n\n const { access_token: accessToken } = result.data;\n\n assert(accessToken, new ConnectorError(ConnectorErrorCodes.SocialAuthCodeInvalid));\n\n return result.data;\n};\n\ntype Json = ReturnType<typeof parseJson>;\n\n/**\n * Get user information JSON from Google Identity Platform. It will use the following order to\n * retrieve user information:\n *\n * 1. Google One Tap: https://developers.google.com/identity/gsi/web/guides/verify-google-id-token\n * 2. Normal Google OAuth: https://developers.google.com/identity/protocols/oauth2/openid-connect\n *\n * @param data The data from the client.\n * @param config The configuration of the connector.\n * @returns An object containing user information JSON and optionally the access token response.\n */\nconst getUserInfoJsonAndTokenResponse = async (\n data: unknown,\n config: GoogleConnectorConfig\n): Promise<{\n rawUserInfo: Json;\n tokenResponse?: AccessTokenResponse;\n}> => {\n // Google One Tap\n const oneTapResult = googleOneTapDataGuard.safeParse(data);\n if (oneTapResult.success) {\n const { payload } = await jwtVerify<Json>(\n oneTapResult.data.credential,\n createRemoteJWKSet(new URL(jwksUri)),\n {\n // https://developers.google.com/identity/gsi/web/guides/verify-google-id-token\n issuer: ['https://accounts.google.com', 'accounts.google.com'],\n audience: config.clientId,\n clockTolerance: 10,\n }\n );\n\n // Google One Tap will return only user information JSON.\n return {\n rawUserInfo: payload,\n };\n }\n\n // Normal Google OAuth\n const { code, redirectUri } = await authorizationCallbackHandler(data);\n const tokenResponse = await getAccessToken(config, { code, redirectUri });\n\n const { access_token: accessToken } = tokenResponse;\n\n const httpResponse = await got.post(userInfoEndpoint, {\n headers: {\n authorization: `Bearer ${accessToken}`,\n },\n timeout: { request: defaultTimeout },\n });\n\n return {\n rawUserInfo: parseJson(httpResponse.body),\n tokenResponse,\n };\n};\n\nconst parseUserInfoResponse = (rawUserInfo: Json): SocialUserInfo => {\n const result = userInfoResponseGuard.safeParse(rawUserInfo);\n if (!result.success) {\n throw new ConnectorError(ConnectorErrorCodes.InvalidResponse, result.error);\n }\n\n const { sub: id, picture: avatar, email, email_verified, name } = result.data;\n\n return {\n id,\n avatar,\n email: conditional(email_verified && email),\n name,\n rawData: rawUserInfo,\n };\n};\n\nconst getUserInfo =\n (getConfig: GetConnectorConfig): GetUserInfo =>\n async (data) => {\n const config = await getConfig(defaultMetadata.id);\n validateConfig(config, GoogleConnector.configGuard);\n\n try {\n const { rawUserInfo } = await getUserInfoJsonAndTokenResponse(data, config);\n return parseUserInfoResponse(rawUserInfo);\n } catch (error: unknown) {\n return getUserInfoErrorHandler(error);\n }\n };\n\nconst getTokenResponseAndUserInfo =\n (getConfig: GetConnectorConfig): GetTokenResponseAndUserInfo =>\n async (data) => {\n const config = await getConfig(defaultMetadata.id);\n validateConfig(config, GoogleConnector.configGuard);\n\n try {\n const { rawUserInfo, tokenResponse } = await getUserInfoJsonAndTokenResponse(data, config);\n\n return {\n userInfo: parseUserInfoResponse(rawUserInfo),\n tokenResponse,\n };\n } catch (error: unknown) {\n return getUserInfoErrorHandler(error);\n }\n };\n\nconst authorizationCallbackHandler = async (parameterObject: unknown) => {\n const result = authResponseGuard.safeParse(parameterObject);\n\n if (!result.success) {\n throw new ConnectorError(ConnectorErrorCodes.General, JSON.stringify(parameterObject));\n }\n\n return result.data;\n};\n\nconst getUserInfoErrorHandler = (error: unknown) => {\n if (error instanceof HTTPError) {\n const { statusCode, body: rawBody } = error.response;\n\n if (statusCode === 401) {\n throw new ConnectorError(ConnectorErrorCodes.SocialAccessTokenInvalid);\n }\n\n throw new ConnectorError(ConnectorErrorCodes.General, JSON.stringify(rawBody));\n }\n\n throw error;\n};\n\nconst getAccessTokenByRefreshToken =\n (getConfig: GetConnectorConfig): GetAccessTokenByRefreshToken =>\n async (refreshToken: string) => {\n const config = await getConfig(defaultMetadata.id);\n validateConfig(config, GoogleConnector.configGuard);\n\n return _getAccessTokenByRefreshToken(\n {\n clientId: config.clientId,\n clientSecret: config.clientSecret,\n tokenEndpoint: accessTokenEndpoint,\n },\n refreshToken\n );\n };\n\nconst createGoogleConnector: CreateConnector<SocialConnector> = async ({ getConfig }) => {\n return {\n metadata: defaultMetadata,\n type: ConnectorType.Social,\n configGuard: GoogleConnector.configGuard,\n getAuthorizationUri: getAuthorizationUri(getConfig),\n getUserInfo: getUserInfo(getConfig),\n getTokenResponseAndUserInfo: getTokenResponseAndUserInfo(getConfig),\n getAccessTokenByRefreshToken: getAccessTokenByRefreshToken(getConfig),\n };\n};\n\nexport default createGoogleConnector;\n","import type { ConnectorMetadata } from '@logto/connector-kit';\nimport {\n ConnectorConfigFormItemType,\n ConnectorPlatform,\n GoogleConnector,\n OidcPrompt,\n} from '@logto/connector-kit';\n\nexport const authorizationEndpoint = 'https://accounts.google.com/o/oauth2/v2/auth';\nexport const accessTokenEndpoint = 'https://oauth2.googleapis.com/token';\nexport const userInfoEndpoint = 'https://openidconnect.googleapis.com/v1/userinfo';\nexport const scope = 'openid profile email';\n\n// Instead of defining the metadata in the connector, we reuse the metadata from the connector-kit.\n// This is not the normal practice, but Google One Tap is a special case.\n// @see {@link GoogleConnector} for more information.\nexport const defaultMetadata: ConnectorMetadata = {\n id: GoogleConnector.factoryId,\n target: GoogleConnector.target,\n platform: ConnectorPlatform.Universal,\n name: {\n en: 'Google',\n 'zh-CN': 'Google',\n 'tr-TR': 'Google',\n ko: 'Google',\n },\n logo: './logo.svg',\n logoDark: null,\n description: {\n en: 'Google is a principal search engine technology and email service provider.',\n 'zh-CN': 'Google 是全球性的搜索引擎和邮件服务提供商。',\n 'tr-TR': 'Google, en büyük arama motoru teknolojisi ve e-posta servis sağlayıcısıdır.',\n ko: 'Google은 가장 큰 검색 엔진 기술과 이메일 서비스 제공자입니다.',\n },\n readme: './README.md',\n formItems: [\n {\n key: 'clientId',\n type: ConnectorConfigFormItemType.Text,\n label: 'Client ID',\n required: true,\n placeholder: '<client-id>',\n },\n {\n key: 'clientSecret',\n type: ConnectorConfigFormItemType.Text,\n label: 'Client Secret',\n required: true,\n placeholder: '<client-secret>',\n },\n {\n key: 'scope',\n type: ConnectorConfigFormItemType.MultilineText,\n label: 'Scope',\n required: false,\n placeholder: 'Enter the scopes (separated by a space)',\n description: \"The `scope` determines permissions granted by the user's authorization. \",\n },\n {\n key: 'prompts',\n type: ConnectorConfigFormItemType.MultiSelect,\n required: false,\n label: 'Prompts',\n // Google does not support `login` prompt.\n // Ref: https://developers.google.com/identity/openid-connect/openid-connect#authenticationuriparameters\n selectItems: Object.values(OidcPrompt)\n .filter((prompt) => prompt !== OidcPrompt.Login)\n .map((prompt) => ({\n value: prompt,\n })),\n defaultValue: [OidcPrompt.SelectAccount],\n },\n {\n key: 'offlineAccess',\n type: ConnectorConfigFormItemType.Switch,\n required: false,\n label: 'Refresh access token',\n defaultValue: false,\n description:\n 'Enable Google `offline` access to request a refresh token, allowing your app to refresh the access token without user re-authorization. (Note: \"consent\" prompt is required)',\n },\n ],\n isTokenStorageSupported: true,\n};\n\nexport const defaultTimeout = 5000;\n\n// https://developers.google.com/identity/gsi/web/guides/verify-google-id-token\nexport const jwksUri = 'https://www.googleapis.com/oauth2/v3/certs';\n","import { z } from 'zod';\n\nimport { GoogleConnector } from '@logto/connector-kit';\n\nexport const accessTokenResponseGuard = z.object({\n access_token: z.string(),\n scope: z.string(),\n token_type: z.string(),\n expires_in: z.number().or(z.string()).optional(),\n refresh_token: z.string().optional(),\n});\n\nexport type AccessTokenResponse = z.infer<typeof accessTokenResponseGuard>;\n\nexport const userInfoResponseGuard = z.object({\n sub: z.string(),\n name: z.string().optional(),\n given_name: z.string().optional(),\n family_name: z.string().optional(),\n picture: z.string().optional(),\n email: z.string().optional(),\n email_verified: z.boolean().optional(),\n locale: z.string().optional(),\n});\n\nexport type UserInfoResponse = z.infer<typeof userInfoResponseGuard>;\n\nexport const authResponseGuard = z.object({\n code: z.string(),\n redirectUri: z.string(),\n});\n\n/**\n * Response payload from Google One Tap. Note the CSRF token is not included since it should be\n * verified by the web server.\n */\nexport const googleOneTapDataGuard = z.object({\n [GoogleConnector.oneTapParams.credential]: z.string(),\n});\n"],"mappings":";AAIA,SAAS,aAAa,cAA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AO;AAAA,IACL,UAAU;AAAA,IACV,MAAM,cAAc;AAAA,IACpB,aAAaA,iBAAgB;AAAA,IAC7B,qBAAqB,oBAAoB,SAAS;AAAA,IAClD,aAAa,YAAY,SAAS;AAAA,IAClC,6BAA6B,4BAA4B,SAAS;AAAA,IAClE,8BAA8B,6BAA6B,SAAS;AAAA,EACtE;AACF;AAEA,IAAO,gBAAQ;","names":["GoogleConnector","GoogleConnector","GoogleConnector","scope"]}
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@logto/connector-google",
3
- "version": "1.6.1",
3
+ "version": "1.8.0",
4
4
  "description": "Google web connector implementation.",
5
5
  "author": "Silverhand Inc. <contact@silverhand.io>",
6
6
  "dependencies": {
7
- "@logto/connector-kit": "^4.1.1",
8
7
  "@silverhand/essentials": "^2.9.1",
9
8
  "got": "^14.0.0",
10
9
  "jose": "^5.6.3",
11
10
  "snakecase-keys": "^8.0.1",
12
- "zod": "^3.23.8"
11
+ "zod": "3.24.3",
12
+ "@logto/connector-kit": "^4.4.0"
13
13
  },
14
14
  "main": "./lib/index.js",
15
15
  "module": "./lib/index.js",
@@ -23,7 +23,7 @@
23
23
  "logo-dark.svg"
24
24
  ],
25
25
  "engines": {
26
- "node": "^20.9.0"
26
+ "node": "^22.14.0"
27
27
  },
28
28
  "eslintConfig": {
29
29
  "extends": "@silverhand",
@@ -44,17 +44,17 @@
44
44
  "devDependencies": {
45
45
  "@silverhand/eslint-config": "6.0.1",
46
46
  "@silverhand/ts-config": "6.0.0",
47
- "@types/node": "^20.11.20",
47
+ "@types/node": "^22.14.0",
48
48
  "@types/supertest": "^6.0.2",
49
- "@vitest/coverage-v8": "^2.1.9",
49
+ "@vitest/coverage-v8": "^3.1.1",
50
50
  "eslint": "^8.56.0",
51
51
  "lint-staged": "^15.0.2",
52
- "nock": "^13.3.1",
53
- "prettier": "^3.0.0",
52
+ "nock": "^14.0.3",
53
+ "prettier": "^3.5.3",
54
54
  "supertest": "^7.0.0",
55
- "tsup": "^8.3.0",
55
+ "tsup": "^8.5.0",
56
56
  "typescript": "^5.5.3",
57
- "vitest": "^2.1.9"
57
+ "vitest": "^3.1.1"
58
58
  },
59
59
  "scripts": {
60
60
  "precommit": "lint-staged",