UNPKG

@aws-amplify/auth

Version:
1 lines 3.06 kB
{"version":3,"file":"sendUserAttributeVerificationCode.mjs","sources":["../../../../../src/providers/cognito/apis/sendUserAttributeVerificationCode.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify, fetchAuthSession } from '@aws-amplify/core';\nimport { AuthAction, assertTokenProviderConfig, } from '@aws-amplify/core/internals/utils';\nimport { getUserAttributeVerificationCode } from '../utils/clients/CognitoIdentityProvider';\nimport { assertAuthTokens } from '../utils/types';\nimport { getRegion } from '../utils/clients/CognitoIdentityProvider/utils';\nimport { getAuthUserAgentValue } from '../../../utils';\n/**\n * Resends user's confirmation code when updating attributes while authenticated.\n *\n * @param input - The SendUserAttributeVerificationCodeInput object\n * @returns SendUserAttributeVerificationCodeOutput\n * @throws - {@link GetUserAttributeVerificationException}\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport const sendUserAttributeVerificationCode = async (input) => {\n const { userAttributeKey, options } = input;\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n const clientMetadata = options?.clientMetadata;\n assertTokenProviderConfig(authConfig);\n const { tokens } = await fetchAuthSession({ forceRefresh: false });\n assertAuthTokens(tokens);\n const { CodeDeliveryDetails } = await getUserAttributeVerificationCode({\n region: getRegion(authConfig.userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.SendUserAttributeVerificationCode),\n }, {\n AccessToken: tokens.accessToken.toString(),\n ClientMetadata: clientMetadata,\n AttributeName: userAttributeKey,\n });\n const { DeliveryMedium, AttributeName, Destination } = {\n ...CodeDeliveryDetails,\n };\n return {\n destination: Destination,\n deliveryMedium: DeliveryMedium,\n attributeName: AttributeName,\n };\n};\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,iCAAiC,GAAG,OAAO,KAAK,KAAK;AAClE,IAAI,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;AAChD,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;AACzD,IAAI,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc,CAAC;AACnD,IAAI,yBAAyB,CAAC,UAAU,CAAC,CAAC;AAC1C,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAgB,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;AACvE,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAC7B,IAAI,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,gCAAgC,CAAC;AAC3E,QAAQ,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC;AAChD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,iCAAiC,CAAC;AAC3F,KAAK,EAAE;AACP,QAAQ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;AAClD,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,aAAa,EAAE,gBAAgB;AACvC,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG;AAC3D,QAAQ,GAAG,mBAAmB;AAC9B,KAAK,CAAC;AACN,IAAI,OAAO;AACX,QAAQ,WAAW,EAAE,WAAW;AAChC,QAAQ,cAAc,EAAE,cAAc;AACtC,QAAQ,aAAa,EAAE,aAAa;AACpC,KAAK,CAAC;AACN;;;;"}