UNPKG

@aws-amplify/auth

Version:
1 lines 2.93 kB
{"version":3,"file":"handleSelectChallenge.mjs","sources":["../../../../../src/client/flows/userAuth/handleSelectChallenge.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthAction } from '@aws-amplify/core/internals/utils';\nimport { createRespondToAuthChallengeClient } from '../../../foundation/factories/serviceClients/cognitoIdentityProvider';\nimport { createCognitoUserPoolEndpointResolver } from '../../../providers/cognito/factories';\nimport { getRegionFromUserPoolId } from '../../../foundation/parsers';\nimport { getAuthUserAgentValue } from '../../../utils';\n/**\n * Handles the SELECT_CHALLENGE response for authentication.\n * Initiates the selected authentication challenge based on user choice.\n *\n * @param {Object} params - The parameters for handling the selected challenge\n * @param {string} params.username - The username for authentication\n * @param {string} params.session - The current authentication session token\n * @param {string} params.selectedChallenge - The challenge type selected by the user\n * @param {CognitoUserPoolConfig} params.config - Cognito User Pool configuration\n * @param {ClientMetadata} [params.clientMetadata] - Optional metadata to be sent with auth requests\n *\n * @returns {Promise<RespondToAuthChallengeCommandOutput>} The challenge response\n */\nexport async function initiateSelectedChallenge({ username, session, selectedChallenge, config, clientMetadata, }) {\n const respondToAuthChallenge = createRespondToAuthChallengeClient({\n endpointResolver: createCognitoUserPoolEndpointResolver({\n endpointOverride: config.userPoolEndpoint,\n }),\n });\n return respondToAuthChallenge({\n region: getRegionFromUserPoolId(config.userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.ConfirmSignIn),\n }, {\n ChallengeName: 'SELECT_CHALLENGE',\n ChallengeResponses: {\n USERNAME: username,\n ANSWER: selectedChallenge,\n },\n ClientId: config.userPoolClientId,\n Session: session,\n ClientMetadata: clientMetadata,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,yBAAyB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,GAAG,EAAE;AACnH,IAAI,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AACtE,QAAQ,gBAAgB,EAAE,qCAAqC,CAAC;AAChE,YAAY,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;AACrD,SAAS,CAAC;AACV,KAAK,CAAC;AACN,IAAI,OAAO,sBAAsB,CAAC;AAClC,QAAQ,MAAM,EAAE,uBAAuB,CAAC,MAAM,CAAC,UAAU,CAAC;AAC1D,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,aAAa,CAAC;AACvE,KAAK,EAAE;AACP,QAAQ,aAAa,EAAE,kBAAkB;AACzC,QAAQ,kBAAkB,EAAE;AAC5B,YAAY,QAAQ,EAAE,QAAQ;AAC9B,YAAY,MAAM,EAAE,iBAAiB;AACrC,SAAS;AACT,QAAQ,QAAQ,EAAE,MAAM,CAAC,gBAAgB;AACzC,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,cAAc,EAAE,cAAc;AACtC,KAAK,CAAC;AACN;;;;"}