UNPKG

5.6 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright 2019-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
6 * the License. A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0/
9 *
10 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
12 * and limitations under the License.
13 */
14var __extends = (this && this.__extends) || (function () {
15 var extendStatics = function (d, b) {
16 extendStatics = Object.setPrototypeOf ||
17 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
18 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
19 return extendStatics(d, b);
20 };
21 return function (d, b) {
22 extendStatics(d, b);
23 function __() { this.constructor = d; }
24 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25 };
26})();
27Object.defineProperty(exports, "__esModule", { value: true });
28var core_1 = require("@aws-amplify/core");
29var AuthErrorStrings_1 = require("./common/AuthErrorStrings");
30var logger = new core_1.ConsoleLogger('AuthError');
31var AuthError = /** @class */ (function (_super) {
32 __extends(AuthError, _super);
33 function AuthError(type) {
34 var _this = this;
35 var _a = exports.authErrorMessages[type], message = _a.message, log = _a.log;
36 _this = _super.call(this, message) || this;
37 // Hack for making the custom error class work when transpiled to es5
38 // TODO: Delete the following 2 lines after we change the build target to >= es2015
39 _this.constructor = AuthError;
40 Object.setPrototypeOf(_this, AuthError.prototype);
41 _this.name = 'AuthError';
42 _this.log = log || message;
43 logger.error(_this.log);
44 return _this;
45 }
46 return AuthError;
47}(Error));
48exports.AuthError = AuthError;
49var NoUserPoolError = /** @class */ (function (_super) {
50 __extends(NoUserPoolError, _super);
51 function NoUserPoolError(type) {
52 var _this = _super.call(this, type) || this;
53 // Hack for making the custom error class work when transpiled to es5
54 // TODO: Delete the following 2 lines after we change the build target to >= es2015
55 _this.constructor = NoUserPoolError;
56 Object.setPrototypeOf(_this, NoUserPoolError.prototype);
57 _this.name = 'NoUserPoolError';
58 return _this;
59 }
60 return NoUserPoolError;
61}(AuthError));
62exports.NoUserPoolError = NoUserPoolError;
63exports.authErrorMessages = {
64 noConfig: {
65 message: AuthErrorStrings_1.AuthErrorStrings.DEFAULT_MSG,
66 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 ",
67 },
68 missingAuthConfig: {
69 message: AuthErrorStrings_1.AuthErrorStrings.DEFAULT_MSG,
70 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 ",
71 },
72 emptyUsername: {
73 message: AuthErrorStrings_1.AuthErrorStrings.EMPTY_USERNAME,
74 },
75 // TODO: should include a list of valid sign-in types
76 invalidUsername: {
77 message: AuthErrorStrings_1.AuthErrorStrings.INVALID_USERNAME,
78 },
79 emptyPassword: {
80 message: AuthErrorStrings_1.AuthErrorStrings.EMPTY_PASSWORD,
81 },
82 emptyCode: {
83 message: AuthErrorStrings_1.AuthErrorStrings.EMPTY_CODE,
84 },
85 signUpError: {
86 message: AuthErrorStrings_1.AuthErrorStrings.SIGN_UP_ERROR,
87 log: 'The first parameter should either be non-null string or object',
88 },
89 noMFA: {
90 message: AuthErrorStrings_1.AuthErrorStrings.NO_MFA,
91 },
92 invalidMFA: {
93 message: AuthErrorStrings_1.AuthErrorStrings.INVALID_MFA,
94 },
95 emptyChallengeResponse: {
96 message: AuthErrorStrings_1.AuthErrorStrings.EMPTY_CHALLENGE,
97 },
98 noUserSession: {
99 message: AuthErrorStrings_1.AuthErrorStrings.NO_USER_SESSION,
100 },
101 deviceConfig: {
102 message: AuthErrorStrings_1.AuthErrorStrings.DEVICE_CONFIG,
103 },
104 networkError: {
105 message: AuthErrorStrings_1.AuthErrorStrings.NETWORK_ERROR,
106 },
107 default: {
108 message: AuthErrorStrings_1.AuthErrorStrings.DEFAULT_MSG,
109 },
110};
111//# sourceMappingURL=Errors.js.map
\No newline at end of file