Skip to content

Commit

Permalink
chore(auth): Use the cognito languages as suggestions and add docs fo…
Browse files Browse the repository at this point in the history
…r parameters
  • Loading branch information
Alevale committed Jan 8, 2025
1 parent 81bbf85 commit b9b8f1d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
17 changes: 8 additions & 9 deletions packages/auth/src/providers/cognito/apis/signInWithRedirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ export async function signInWithRedirect(
provider,
customState: input?.customState,
preferPrivateSession: input?.options?.preferPrivateSession,
loginHint: input?.options?.loginHint,
lang: input?.options?.lang,
nonce: input?.options?.nonce,
options: {
loginHint: input?.options?.loginHint,
lang: input?.options?.lang,
nonce: input?.options?.nonce,
},
});
}

Expand All @@ -69,20 +71,17 @@ const oauthSignIn = async ({
clientId,
customState,
preferPrivateSession,
loginHint,
lang,
nonce,
options,
}: {
oauthConfig: OAuthConfig;
provider: string;
clientId: string;
customState?: string;
preferPrivateSession?: boolean;
loginHint?: string;
lang?: string;
nonce?: string;
options?: SignInWithRedirectInput['options'];
}) => {
const { domain, redirectSignIn, responseType, scopes } = oauthConfig;
const { loginHint, lang, nonce } = options ?? {};
const randomState = generateState();

/* encodeURIComponent is not URL safe, use urlSafeEncode instead. Cognito
Expand Down
26 changes: 25 additions & 1 deletion packages/auth/src/types/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,32 @@ export interface AuthSignInWithRedirectInput {
* On all other platforms, this flag is ignored.
*/
preferPrivateSession?: boolean;
/**
* A username prompt that you want to pass to the authorization server. You can collect a username, email address or phone number from your user and allow the destination provider to pre-populate the user's sign-in name. When you submit a `login_hint` parameter and no `idp_identifier` or `identity_provider` parameters to the `/oauth2/authorize` endpoint, managed login fills the username field with your hint value. You can also pass this parameter to the Login endpoint and automatically fill the username value.
* @see https://docs.aws.amazon.com/cognito/latest/developerguide/authorization-endpoint.html
*/
loginHint?: string;
lang?: string;
/**
* The language that you want to display user-interactive pages in. Managed login pages can be localized, but hosted UI (classic) pages can not
* @see https://docs.aws.amazon.com/cognito/latest/developerguide/authorization-endpoint.html
*/
lang?:
| 'de'
| 'en'
| 'es'
| 'fr'
| 'id'
| 'it'
| 'ja'
| 'ko'
| 'pt-BR'
| 'zh-CN'
| 'zh-TW'
| (string & NonNullable<unknown>);
/**
* A random value that you can add to the request. The nonce value that you provide is included in the ID token that Amazon Cognito issues. To guard against replay attacks, your app can inspect the `nonce` claim in the ID token and compare it to the one you generated.
* @see https://docs.aws.amazon.com/cognito/latest/developerguide/authorization-endpoint.html
*/
nonce?: string;
};
}
Expand Down

0 comments on commit b9b8f1d

Please sign in to comment.