From f0586b984e341bf080a8c2419f36e5742c4d8f79 Mon Sep 17 00:00:00 2001 From: David Philipson Date: Tue, 24 Sep 2024 15:40:44 -0700 Subject: [PATCH] feat: add auth0connection param Allow users to set the `connection` query param when using Auth0, which allows them to link directly to one particular auth method in Auth0 rather than a selection screen. --- account-kit/signer/src/client/index.ts | 4 ++++ account-kit/signer/src/oauth.ts | 4 ---- account-kit/signer/src/signer.ts | 21 ++++++++++++++++----- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/account-kit/signer/src/client/index.ts b/account-kit/signer/src/client/index.ts index 47aff23b3..5f500c001 100644 --- a/account-kit/signer/src/client/index.ts +++ b/account-kit/signer/src/client/index.ts @@ -483,6 +483,7 @@ export class AlchemySignerWebClient extends BaseSignerClient const { authProviderId, isCustomProvider, + auth0Connection, scope: providedScope, claims: providedClaims, mode, @@ -547,6 +548,9 @@ export class AlchemySignerWebClient extends BaseSignerClient if (claims) { params.claims = claims; } + if (auth0Connection) { + params.connection = auth0Connection; + } authUrl.search = new URLSearchParams(params).toString(); return authUrl.toString(); }; diff --git a/account-kit/signer/src/oauth.ts b/account-kit/signer/src/oauth.ts index 4e1761707..f0e9554df 100644 --- a/account-kit/signer/src/oauth.ts +++ b/account-kit/signer/src/oauth.ts @@ -19,10 +19,6 @@ const DEFAULT_SCOPE_AND_CLAIMS: Record = { google: { scope: "openid email" }, apple: { scope: "openid email" }, facebook: { scope: "openid email" }, - twitch: { - scope: "openid user:read:email", - claims: JSON.stringify({ id_token: { email: null } }), - }, }; /** diff --git a/account-kit/signer/src/signer.ts b/account-kit/signer/src/signer.ts index 6ab59cf6e..f69355f2b 100644 --- a/account-kit/signer/src/signer.ts +++ b/account-kit/signer/src/signer.ts @@ -27,19 +27,30 @@ export type AuthParams = } | ({ type: "oauth"; - authProviderId: string; - isCustomProvider?: boolean; scope?: string; claims?: string; - } & RedirectConfig) + } & OauthProviderConfig & + OauthRedirectConfig) | { type: "oauthReturn"; bundle: string; orgId: string }; -export type OauthMode = "redirect" | "popup"; +export type OauthProviderConfig = + | { + authProviderId: "auth0"; + isCustomProvider?: false; + auth0Connection?: string; + } + | { + authProviderId: string; + isCustomProvider?: boolean; + auth0Connection?: never; + }; -export type RedirectConfig = +export type OauthRedirectConfig = | { mode: "redirect"; redirectUrl: string } | { mode: "popup"; redirectUrl?: never }; +export type OauthMode = "redirect" | "popup"; + export const AlchemySignerParamsSchema = z .object({ client: z