1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | var __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 | })();
|
26 | import { ConsoleLogger as Logger } from '@aws-amplify/core';
|
27 | import { AuthErrorStrings } from './common/AuthErrorStrings';
|
28 | var logger = new Logger('AuthError');
|
29 | var AuthError = (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 |
|
36 |
|
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));
|
46 | export { AuthError };
|
47 | var NoUserPoolError = (function (_super) {
|
48 | __extends(NoUserPoolError, _super);
|
49 | function NoUserPoolError(type) {
|
50 | var _this = _super.call(this, type) || this;
|
51 |
|
52 |
|
53 | _this.constructor = NoUserPoolError;
|
54 | Object.setPrototypeOf(_this, NoUserPoolError.prototype);
|
55 | _this.name = 'NoUserPoolError';
|
56 | return _this;
|
57 | }
|
58 | return NoUserPoolError;
|
59 | }(AuthError));
|
60 | export { NoUserPoolError };
|
61 | export 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 |
|
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 |
|
\ | No newline at end of file |