UNPKG

@aws-amplify/auth

Version:

Auth category of aws-amplify

39 lines (36 loc) • 1.77 kB
import { resolveCtxArgs } from '@aws-amplify/core/internals/utils'; import { assertUserNotAuthenticated } from '../utils/signInHelpers.mjs'; import { signInWithCustomAuth } from './signInWithCustomAuth.mjs'; import { signInWithCustomSRPAuth } from './signInWithCustomSRPAuth.mjs'; import { signInWithSRP } from './signInWithSRP.mjs'; import { signInWithUserPassword } from './signInWithUserPassword.mjs'; import { signInWithUserAuth } from './signInWithUserAuth.mjs'; import { resetAutoSignIn } from './autoSignIn.mjs'; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 async function signIn(...args) { const [ctx, input] = resolveCtxArgs(args); // Here we want to reset the store but not reassign the callback. // The callback is reset when the underlying promise resolves or rejects. // With the advent of session based sign in, this guarantees that the signIn API initiates a new auth flow, // regardless of whether it is called for a user currently engaged in an active auto sign in session. resetAutoSignIn(false); const authFlowType = input.options?.authFlowType; await assertUserNotAuthenticated(ctx); switch (authFlowType) { case 'USER_SRP_AUTH': return signInWithSRP(ctx, input); case 'USER_PASSWORD_AUTH': return signInWithUserPassword(ctx, input); case 'CUSTOM_WITHOUT_SRP': return signInWithCustomAuth(ctx, input); case 'CUSTOM_WITH_SRP': return signInWithCustomSRPAuth(ctx, input); case 'USER_AUTH': return signInWithUserAuth(ctx, input); default: return signInWithSRP(ctx, input); } } export { signIn }; //# sourceMappingURL=signIn.mjs.map