UNPKG

@aws-amplify/auth

Version:
1 lines 2.83 kB
{"version":3,"file":"signIn.mjs","sources":["../../../../../src/providers/cognito/apis/signIn.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { assertUserNotAuthenticated } from '../utils/signInHelpers';\nimport { signInWithCustomAuth } from './signInWithCustomAuth';\nimport { signInWithCustomSRPAuth } from './signInWithCustomSRPAuth';\nimport { signInWithSRP } from './signInWithSRP';\nimport { signInWithUserPassword } from './signInWithUserPassword';\nimport { signInWithUserAuth } from './signInWithUserAuth';\nimport { resetAutoSignIn } from './autoSignIn';\n/**\n * Signs a user in\n *\n * @param input - The SignInInput object\n * @returns SignInOutput\n * @throws service: {@link InitiateAuthException }, {@link RespondToAuthChallengeException }\n * - Cognito service errors thrown during the sign-in process.\n * @throws validation: {@link AuthValidationErrorCode } - Validation errors thrown when either username or password\n * are not defined.\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function signIn(input) {\n // Here we want to reset the store but not reassign the callback.\n // The callback is reset when the underlying promise resolves or rejects.\n // With the advent of session based sign in, this guarantees that the signIn API initiates a new auth flow,\n // regardless of whether it is called for a user currently engaged in an active auto sign in session.\n resetAutoSignIn(false);\n const authFlowType = input.options?.authFlowType;\n await assertUserNotAuthenticated();\n switch (authFlowType) {\n case 'USER_SRP_AUTH':\n return signInWithSRP(input);\n case 'USER_PASSWORD_AUTH':\n return signInWithUserPassword(input);\n case 'CUSTOM_WITHOUT_SRP':\n return signInWithCustomAuth(input);\n case 'CUSTOM_WITH_SRP':\n return signInWithCustomSRPAuth(input);\n case 'USER_AUTH':\n return signInWithUserAuth(input);\n default:\n return signInWithSRP(input);\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,MAAM,CAAC,KAAK,EAAE;AACpC;AACA;AACA;AACA;AACA,IAAI,eAAe,CAAC,KAAK,CAAC;AAC1B,IAAI,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,EAAE,YAAY;AACpD,IAAI,MAAM,0BAA0B,EAAE;AACtC,IAAI,QAAQ,YAAY;AACxB,QAAQ,KAAK,eAAe;AAC5B,YAAY,OAAO,aAAa,CAAC,KAAK,CAAC;AACvC,QAAQ,KAAK,oBAAoB;AACjC,YAAY,OAAO,sBAAsB,CAAC,KAAK,CAAC;AAChD,QAAQ,KAAK,oBAAoB;AACjC,YAAY,OAAO,oBAAoB,CAAC,KAAK,CAAC;AAC9C,QAAQ,KAAK,iBAAiB;AAC9B,YAAY,OAAO,uBAAuB,CAAC,KAAK,CAAC;AACjD,QAAQ,KAAK,WAAW;AACxB,YAAY,OAAO,kBAAkB,CAAC,KAAK,CAAC;AAC5C,QAAQ;AACR,YAAY,OAAO,aAAa,CAAC,KAAK,CAAC;AACvC;AACA;;;;"}