Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,20 @@ export async function signInWithRedirect(
await assertUserNotAuthenticated();

let provider = 'COGNITO'; // Default
let isProviderIdpIdentifier: boolean = false;

if (typeof input?.provider === 'string') {
provider = cognitoHostedUIIdentityProviderMap[input.provider];
} else if (input?.provider?.custom) {
provider = input.provider.custom;
isProviderIdpIdentifier = !!input.provider.isIdpIdentifier;
}

return oauthSignIn({
oauthConfig: authConfig.loginWith.oauth,
clientId: authConfig.userPoolClientId,
provider,
isProviderIdpIdentifier,
customState: input?.customState,
preferPrivateSession: input?.options?.preferPrivateSession,
options: {
Expand All @@ -68,13 +71,15 @@ export async function signInWithRedirect(
const oauthSignIn = async ({
oauthConfig,
provider,
isProviderIdpIdentifier,
clientId,
customState,
preferPrivateSession,
options,
}: {
oauthConfig: OAuthConfig;
provider: string;
isProviderIdpIdentifier: boolean;
clientId: string;
customState?: string;
preferPrivateSession?: boolean;
Expand Down Expand Up @@ -105,7 +110,8 @@ const oauthSignIn = async ({
redirect_uri: redirectUri,
response_type: responseType,
client_id: clientId,
identity_provider: provider,
...(!isProviderIdpIdentifier && { identity_provider: provider }),
...(isProviderIdpIdentifier && { idp_identifier: provider }),
scope: scopes.join(' '),
// eslint-disable-next-line camelcase
...(loginHint && { login_hint: loginHint }),
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/types/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface AuthSignOutInput {
export type AuthProvider = 'Amazon' | 'Apple' | 'Facebook' | 'Google';

export interface AuthSignInWithRedirectInput {
provider?: AuthProvider | { custom: string };
provider?: AuthProvider | { custom: string; isIdpIdentifier?: boolean };
customState?: string;
options?: {
/**
Expand Down