@aws-amplify/auth
Version:
Auth category of aws-amplify
1 lines • 6.31 kB
Source Map (JSON)
{"version":3,"file":"Errors.mjs","sources":["../../src/Errors.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n// TODO: delete this module when the Auth class is removed.\nimport { ConsoleLogger } from '@aws-amplify/core';\nimport { AuthErrorStrings } from './common/AuthErrorStrings';\nconst logger = new ConsoleLogger('AuthError');\nexport class AuthError extends Error {\n constructor(type) {\n const { message, log } = authErrorMessages[type];\n super(message);\n // Hack for making the custom error class work when transpiled to es5\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = AuthError;\n Object.setPrototypeOf(this, AuthError.prototype);\n this.name = 'AuthError';\n this.log = log || message;\n logger.error(this.log);\n }\n}\nexport class NoUserPoolError extends AuthError {\n constructor(type) {\n super(type);\n // Hack for making the custom error class work when transpiled to es5\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = NoUserPoolError;\n Object.setPrototypeOf(this, NoUserPoolError.prototype);\n this.name = 'NoUserPoolError';\n }\n}\nexport const authErrorMessages = {\n oauthSignInError: {\n message: AuthErrorStrings.OAUTH_ERROR,\n log: 'Make sure Cognito Hosted UI has been configured correctly',\n },\n noConfig: {\n message: AuthErrorStrings.DEFAULT_MSG,\n log: `\n Error: Amplify has not been configured correctly.\n This error is typically caused by one of the following scenarios:\n\n 1. Make sure you're passing the awsconfig object to Amplify.configure() in your app's entry point\n See https://aws-amplify.github.io/docs/js/authentication#configure-your-app for more information\n \n 2. There might be multiple conflicting versions of amplify packages in your node_modules.\n\t\t\t\tRefer to our docs site for help upgrading Amplify packages (https://docs.amplify.aws/lib/troubleshooting/upgrading/q/platform/js)\n `,\n },\n missingAuthConfig: {\n message: AuthErrorStrings.DEFAULT_MSG,\n log: `\n Error: Amplify has not been configured correctly. \n The configuration object is missing required auth properties.\n This error is typically caused by one of the following scenarios:\n\n 1. Did you run \\`amplify push\\` after adding auth via \\`amplify add auth\\`?\n See https://aws-amplify.github.io/docs/js/authentication#amplify-project-setup for more information\n\n 2. This could also be caused by multiple conflicting versions of amplify packages, see (https://docs.amplify.aws/lib/troubleshooting/upgrading/q/platform/js) for help upgrading Amplify packages.\n `,\n },\n emptyUsername: {\n message: AuthErrorStrings.EMPTY_USERNAME,\n },\n // TODO: should include a list of valid sign-in types\n invalidUsername: {\n message: AuthErrorStrings.INVALID_USERNAME,\n },\n emptyPassword: {\n message: AuthErrorStrings.EMPTY_PASSWORD,\n },\n emptyCode: {\n message: AuthErrorStrings.EMPTY_CODE,\n },\n signUpError: {\n message: AuthErrorStrings.SIGN_UP_ERROR,\n log: 'The first parameter should either be non-null string or object',\n },\n noMFA: {\n message: AuthErrorStrings.NO_MFA,\n },\n invalidMFA: {\n message: AuthErrorStrings.INVALID_MFA,\n },\n emptyChallengeResponse: {\n message: AuthErrorStrings.EMPTY_CHALLENGE,\n },\n noUserSession: {\n message: AuthErrorStrings.NO_USER_SESSION,\n },\n deviceConfig: {\n message: AuthErrorStrings.DEVICE_CONFIG,\n },\n networkError: {\n message: AuthErrorStrings.NETWORK_ERROR,\n },\n autoSignInError: {\n message: AuthErrorStrings.AUTOSIGNIN_ERROR,\n },\n default: {\n message: AuthErrorStrings.DEFAULT_MSG,\n },\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AACA;AAGA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,WAAW,CAAC;AACtC,MAAM,SAAS,SAAS,KAAK,CAAC;AACrC,IAAI,WAAW,CAAC,IAAI,EAAE;AACtB,QAAQ,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC;AACxD,QAAQ,KAAK,CAAC,OAAO,CAAC;AACtB;AACA;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,SAAS;AACpC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC;AACxD,QAAQ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