From be1b570691594b7fea753fbdcf57522f7caf5b83 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Mon, 17 Jun 2024 12:06:52 +0800 Subject: [PATCH] chore: add comments --- .../connectors/connector-google/src/constant.ts | 3 +++ .../toolkit/connector-kit/src/types/social.ts | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/connectors/connector-google/src/constant.ts b/packages/connectors/connector-google/src/constant.ts index 28fd8a05e..6d31965ce 100644 --- a/packages/connectors/connector-google/src/constant.ts +++ b/packages/connectors/connector-google/src/constant.ts @@ -10,6 +10,9 @@ export const accessTokenEndpoint = 'https://oauth2.googleapis.com/token'; export const userInfoEndpoint = 'https://openidconnect.googleapis.com/v1/userinfo'; export const scope = 'openid profile email'; +// Instead of defining the metadata in the connector, we reuse the metadata from the connector-kit. +// This is not the normal practice, but Google One Tap is a special case. +// @see {@link GoogleConnector} for more information. export const defaultMetadata: ConnectorMetadata = { id: GoogleConnector.factoryId, target: GoogleConnector.target, diff --git a/packages/toolkit/connector-kit/src/types/social.ts b/packages/toolkit/connector-kit/src/types/social.ts index b13b0300a..398560126 100644 --- a/packages/toolkit/connector-kit/src/types/social.ts +++ b/packages/toolkit/connector-kit/src/types/social.ts @@ -81,6 +81,11 @@ export type SocialConnector = BaseConnector & { validateSamlAssertion?: ValidateSamlAssertion; }; +/** + * The configuration object for Google One Tap. + * + * @see {@link https://developers.google.com/identity/gsi/web/reference/html-reference | Sign In With Google HTML API reference} + */ export type GoogleOneTapConfig = { isEnabled?: boolean; autoSelect?: boolean; @@ -95,7 +100,16 @@ export const googleOneTapConfigGuard = z.object({ itpSupport: z.boolean().optional(), }) satisfies ToZodObject; -/** An object that contains the configuration for the official Google connector. */ +/** + * An object that contains the configuration for the official Google connector. + * + * @remarks + * Unlike other connectors, the Google connector supports Google One Tap which needs additional + * configuration and special handling in our system. So we put the constants and configuration + * in this package for reusability, rather than hardcoding them in our system. + * + * Other connectors should not follow this pattern unless there is a strong reason to do so. + */ export const GoogleConnector = Object.freeze({ /** The target of Google connectors. */ target: 'google',