UNPKG

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