UNPKG

@aws-amplify/auth

Version:

Auth category of aws-amplify

40 lines (38 loc) • 2.03 kB
'use strict'; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 Object.defineProperty(exports, "__esModule", { value: true }); exports.signIn = signIn; const utils_1 = require("@aws-amplify/core/internals/utils"); const signInHelpers_1 = require("../utils/signInHelpers"); const signInWithCustomAuth_1 = require("./signInWithCustomAuth"); const signInWithCustomSRPAuth_1 = require("./signInWithCustomSRPAuth"); const signInWithSRP_1 = require("./signInWithSRP"); const signInWithUserPassword_1 = require("./signInWithUserPassword"); const signInWithUserAuth_1 = require("./signInWithUserAuth"); const autoSignIn_1 = require("./autoSignIn"); async function signIn(...args) { const [ctx, input] = (0, utils_1.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. (0, autoSignIn_1.resetAutoSignIn)(false); const authFlowType = input.options?.authFlowType; await (0, signInHelpers_1.assertUserNotAuthenticated)(ctx); switch (authFlowType) { case 'USER_SRP_AUTH': return (0, signInWithSRP_1.signInWithSRP)(ctx, input); case 'USER_PASSWORD_AUTH': return (0, signInWithUserPassword_1.signInWithUserPassword)(ctx, input); case 'CUSTOM_WITHOUT_SRP': return (0, signInWithCustomAuth_1.signInWithCustomAuth)(ctx, input); case 'CUSTOM_WITH_SRP': return (0, signInWithCustomSRPAuth_1.signInWithCustomSRPAuth)(ctx, input); case 'USER_AUTH': return (0, signInWithUserAuth_1.signInWithUserAuth)(ctx, input); default: return (0, signInWithSRP_1.signInWithSRP)(ctx, input); } } //# sourceMappingURL=signIn.js.map