1 | "use strict";
|
2 |
|
3 |
|
4 | Object.defineProperty(exports, "__esModule", { value: true });
|
5 | var tslib_1 = require("tslib");
|
6 | var core_1 = require("@aws-amplify/core");
|
7 | var AuthErrorStrings_1 = require("./common/AuthErrorStrings");
|
8 | var logger = new core_1.ConsoleLogger('AuthError');
|
9 | var AuthError = (function (_super) {
|
10 | tslib_1.__extends(AuthError, _super);
|
11 | function AuthError(type) {
|
12 | var _this = this;
|
13 | var _a = exports.authErrorMessages[type], message = _a.message, log = _a.log;
|
14 | _this = _super.call(this, message) || this;
|
15 |
|
16 |
|
17 | _this.constructor = AuthError;
|
18 | Object.setPrototypeOf(_this, AuthError.prototype);
|
19 | _this.name = 'AuthError';
|
20 | _this.log = log || message;
|
21 | logger.error(_this.log);
|
22 | return _this;
|
23 | }
|
24 | return AuthError;
|
25 | }(Error));
|
26 | exports.AuthError = AuthError;
|
27 | var NoUserPoolError = (function (_super) {
|
28 | tslib_1.__extends(NoUserPoolError, _super);
|
29 | function NoUserPoolError(type) {
|
30 | var _this = _super.call(this, type) || this;
|
31 |
|
32 |
|
33 | _this.constructor = NoUserPoolError;
|
34 | Object.setPrototypeOf(_this, NoUserPoolError.prototype);
|
35 | _this.name = 'NoUserPoolError';
|
36 | return _this;
|
37 | }
|
38 | return NoUserPoolError;
|
39 | }(AuthError));
|
40 | exports.NoUserPoolError = NoUserPoolError;
|
41 | exports.authErrorMessages = {
|
42 | noConfig: {
|
43 | message: AuthErrorStrings_1.AuthErrorStrings.DEFAULT_MSG,
|
44 | 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 ",
|
45 | },
|
46 | missingAuthConfig: {
|
47 | message: AuthErrorStrings_1.AuthErrorStrings.DEFAULT_MSG,
|
48 | 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 ",
|
49 | },
|
50 | emptyUsername: {
|
51 | message: AuthErrorStrings_1.AuthErrorStrings.EMPTY_USERNAME,
|
52 | },
|
53 |
|
54 | invalidUsername: {
|
55 | message: AuthErrorStrings_1.AuthErrorStrings.INVALID_USERNAME,
|
56 | },
|
57 | emptyPassword: {
|
58 | message: AuthErrorStrings_1.AuthErrorStrings.EMPTY_PASSWORD,
|
59 | },
|
60 | emptyCode: {
|
61 | message: AuthErrorStrings_1.AuthErrorStrings.EMPTY_CODE,
|
62 | },
|
63 | signUpError: {
|
64 | message: AuthErrorStrings_1.AuthErrorStrings.SIGN_UP_ERROR,
|
65 | log: 'The first parameter should either be non-null string or object',
|
66 | },
|
67 | noMFA: {
|
68 | message: AuthErrorStrings_1.AuthErrorStrings.NO_MFA,
|
69 | },
|
70 | invalidMFA: {
|
71 | message: AuthErrorStrings_1.AuthErrorStrings.INVALID_MFA,
|
72 | },
|
73 | emptyChallengeResponse: {
|
74 | message: AuthErrorStrings_1.AuthErrorStrings.EMPTY_CHALLENGE,
|
75 | },
|
76 | noUserSession: {
|
77 | message: AuthErrorStrings_1.AuthErrorStrings.NO_USER_SESSION,
|
78 | },
|
79 | deviceConfig: {
|
80 | message: AuthErrorStrings_1.AuthErrorStrings.DEVICE_CONFIG,
|
81 | },
|
82 | networkError: {
|
83 | message: AuthErrorStrings_1.AuthErrorStrings.NETWORK_ERROR,
|
84 | },
|
85 | autoSignInError: {
|
86 | message: AuthErrorStrings_1.AuthErrorStrings.AUTOSIGNIN_ERROR,
|
87 | },
|
88 | default: {
|
89 | message: AuthErrorStrings_1.AuthErrorStrings.DEFAULT_MSG,
|
90 | },
|
91 | };
|
92 |
|
\ | No newline at end of file |