UNPKG

@aws-amplify/auth

Version:
1 lines 2.12 kB
{"version":3,"file":"deleteUser.mjs","sources":["../../../../../src/providers/cognito/apis/deleteUser.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 { getRegion } from '../utils/clients/CognitoIdentityProvider/utils';\nimport { assertAuthTokens } from '../utils/types';\nimport { deleteUser as serviceDeleteUser } from '../utils/clients/CognitoIdentityProvider';\nimport { tokenOrchestrator } from '../tokenProvider';\nimport { getAuthUserAgentValue } from '../../../utils';\nimport { signOut } from './signOut';\n/**\n * Deletes a user from the user pool while authenticated.\n *\n * @throws - {@link DeleteUserException}\n * @throws AuthTokenConfigException - Thrown when the token provider config is invalid.\n */\nexport async function deleteUser() {\n const authConfig = Amplify.getConfig().Auth?.Cognito;\n assertTokenProviderConfig(authConfig);\n const { tokens } = await fetchAuthSession();\n assertAuthTokens(tokens);\n await serviceDeleteUser({\n region: getRegion(authConfig.userPoolId),\n userAgentValue: getAuthUserAgentValue(AuthAction.DeleteUser),\n }, {\n AccessToken: tokens.accessToken.toString(),\n });\n await tokenOrchestrator.clearDeviceMetadata();\n await signOut();\n}\n"],"names":["serviceDeleteUser"],"mappings":";;;;;;;;;;;AAAA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,UAAU,GAAG;AACnC,IAAI,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;AACzD,IAAI,yBAAyB,CAAC,UAAU,CAAC,CAAC;AAC1C,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAgB,EAAE,CAAC;AAChD,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAC7B,IAAI,MAAMA,YAAiB,CAAC;AAC5B,QAAQ,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC;AAChD,QAAQ,cAAc,EAAE,qBAAqB,CAAC,UAAU,CAAC,UAAU,CAAC;AACpE,KAAK,EAAE;AACP,QAAQ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;AAClD,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,iBAAiB,CAAC,mBAAmB,EAAE,CAAC;AAClD,IAAI,MAAM,OAAO,EAAE,CAAC;AACpB;;;;"}