From 6715b790705200bba96ab88f01de5977dcedbe6e Mon Sep 17 00:00:00 2001 From: alevale Date: Wed, 18 Dec 2024 23:34:52 +0100 Subject: [PATCH] feat: Allow sending login_hint, lang and nonce on signInWithRedirects (#8951) --- .../providers/cognito/apis/signInWithRedirect.ts | 13 +++++++++++++ packages/auth/src/types/inputs.ts | 3 +++ 2 files changed, 16 insertions(+) diff --git a/packages/auth/src/providers/cognito/apis/signInWithRedirect.ts b/packages/auth/src/providers/cognito/apis/signInWithRedirect.ts index cab4f018ee7..38fb2a99c6f 100644 --- a/packages/auth/src/providers/cognito/apis/signInWithRedirect.ts +++ b/packages/auth/src/providers/cognito/apis/signInWithRedirect.ts @@ -57,6 +57,9 @@ export async function signInWithRedirect( provider, customState: input?.customState, preferPrivateSession: input?.options?.preferPrivateSession, + loginHint: input?.options?.loginHint, + lang: input?.options?.lang, + nonce: input?.options?.nonce, }); } @@ -66,12 +69,18 @@ const oauthSignIn = async ({ clientId, customState, preferPrivateSession, + loginHint, + lang, + nonce, }: { oauthConfig: OAuthConfig; provider: string; clientId: string; customState?: string; preferPrivateSession?: boolean; + loginHint?: string; + lang?: string; + nonce?: string; }) => { const { domain, redirectSignIn, responseType, scopes } = oauthConfig; const randomState = generateState(); @@ -99,6 +108,10 @@ const oauthSignIn = async ({ client_id: clientId, identity_provider: provider, scope: scopes.join(' '), + // eslint-disable-next-line camelcase + ...(loginHint && { login_hint: loginHint }), + ...(lang && { lang }), + ...(nonce && { nonce }), state, ...(responseType === 'code' && { code_challenge: toCodeChallenge(), diff --git a/packages/auth/src/types/inputs.ts b/packages/auth/src/types/inputs.ts index c2947b4650a..4f6274ee377 100644 --- a/packages/auth/src/types/inputs.ts +++ b/packages/auth/src/types/inputs.ts @@ -68,6 +68,9 @@ export interface AuthSignInWithRedirectInput { * On all other platforms, this flag is ignored. */ preferPrivateSession?: boolean; + loginHint?: string; + lang?: string; + nonce?: string; }; }