@aws-amplify/ui-react 1.2.26-unstable.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/esm/index.css +1 -0
  2. package/dist/esm/index.css.map +7 -0
  3. package/dist/esm/index.js +1 -0
  4. package/dist/esm/index.js.map +7 -0
  5. package/dist/esm/legacy.js +1 -0
  6. package/dist/esm/legacy.js.map +7 -0
  7. package/dist/index.css +1 -0
  8. package/dist/index.css.map +7 -0
  9. package/dist/index.d.ts +7533 -0
  10. package/dist/index.js +1 -0
  11. package/dist/index.js.map +7 -0
  12. package/dist/legacy.d.ts +1 -0
  13. package/dist/legacy.js +1 -0
  14. package/dist/legacy.js.map +7 -0
  15. package/dist/primitives.json +22168 -0
  16. package/legacy/package.json +7 -0
  17. package/package.json +82 -40
  18. package/CHANGELOG.md +0 -339
  19. package/README.md +0 -1
  20. package/build.js +0 -5
  21. package/dist/0.js +0 -269
  22. package/dist/0.js.map +0 -1
  23. package/dist/1.js +0 -2111
  24. package/dist/1.js.map +0 -1
  25. package/dist/10.js +0 -707
  26. package/dist/10.js.map +0 -1
  27. package/dist/11.js +0 -45
  28. package/dist/11.js.map +0 -1
  29. package/dist/12.js +0 -1152
  30. package/dist/12.js.map +0 -1
  31. package/dist/13.js +0 -114
  32. package/dist/13.js.map +0 -1
  33. package/dist/14.js +0 -1194
  34. package/dist/14.js.map +0 -1
  35. package/dist/15.js +0 -61
  36. package/dist/15.js.map +0 -1
  37. package/dist/16.js +0 -37
  38. package/dist/16.js.map +0 -1
  39. package/dist/17.js +0 -127
  40. package/dist/17.js.map +0 -1
  41. package/dist/18.js +0 -90
  42. package/dist/18.js.map +0 -1
  43. package/dist/19.js +0 -267
  44. package/dist/19.js.map +0 -1
  45. package/dist/2.js +0 -766
  46. package/dist/2.js.map +0 -1
  47. package/dist/20.js +0 -74
  48. package/dist/20.js.map +0 -1
  49. package/dist/21.js +0 -50
  50. package/dist/21.js.map +0 -1
  51. package/dist/22.js +0 -57
  52. package/dist/22.js.map +0 -1
  53. package/dist/23.js +0 -50
  54. package/dist/23.js.map +0 -1
  55. package/dist/24.js +0 -271
  56. package/dist/24.js.map +0 -1
  57. package/dist/25.js +0 -102
  58. package/dist/25.js.map +0 -1
  59. package/dist/26.js +0 -64
  60. package/dist/26.js.map +0 -1
  61. package/dist/27.js +0 -379
  62. package/dist/27.js.map +0 -1
  63. package/dist/28.js +0 -47
  64. package/dist/28.js.map +0 -1
  65. package/dist/29.js +0 -46
  66. package/dist/29.js.map +0 -1
  67. package/dist/3.js +0 -2787
  68. package/dist/3.js.map +0 -1
  69. package/dist/30.js +0 -503
  70. package/dist/30.js.map +0 -1
  71. package/dist/31.js +0 -2
  72. package/dist/31.js.map +0 -1
  73. package/dist/32.js +0 -2
  74. package/dist/32.js.map +0 -1
  75. package/dist/33.js +0 -13
  76. package/dist/33.js.map +0 -1
  77. package/dist/4.js +0 -4126
  78. package/dist/4.js.map +0 -1
  79. package/dist/5.js +0 -817
  80. package/dist/5.js.map +0 -1
  81. package/dist/6.js +0 -619
  82. package/dist/6.js.map +0 -1
  83. package/dist/7.js +0 -662
  84. package/dist/7.js.map +0 -1
  85. package/dist/8.js +0 -614
  86. package/dist/8.js.map +0 -1
  87. package/dist/9.js +0 -665
  88. package/dist/9.js.map +0 -1
  89. package/dist/@aws-amplify/ui-react.js +0 -31875
  90. package/dist/@aws-amplify/ui-react.js.map +0 -1
  91. package/dist/aws-amplify-react.min.js +0 -28
  92. package/dist/aws-amplify-react.min.js.map +0 -1
  93. package/dist/polyfills-core-js.js +0 -5211
  94. package/dist/polyfills-core-js.js.map +0 -1
  95. package/dist/polyfills-css-shim.js +0 -467
  96. package/dist/polyfills-css-shim.js.map +0 -1
  97. package/dist/polyfills-dom.js +0 -2098
  98. package/dist/polyfills-dom.js.map +0 -1
  99. package/jest.config.js +0 -12
  100. package/lib/components.d.ts +0 -56
  101. package/lib/components.js +0 -64
  102. package/lib/components.js.map +0 -1
  103. package/lib/index.d.ts +0 -2
  104. package/lib/index.js +0 -9
  105. package/lib/index.js.map +0 -1
  106. package/lib/react-component-lib/createComponent.d.ts +0 -2
  107. package/lib/react-component-lib/createComponent.js +0 -91
  108. package/lib/react-component-lib/createComponent.js.map +0 -1
  109. package/lib/react-component-lib/createControllerComponent.d.ts +0 -43
  110. package/lib/react-component-lib/createControllerComponent.js +0 -152
  111. package/lib/react-component-lib/createControllerComponent.js.map +0 -1
  112. package/lib/react-component-lib/createOverlayComponent.d.ts +0 -45
  113. package/lib/react-component-lib/createOverlayComponent.js +0 -148
  114. package/lib/react-component-lib/createOverlayComponent.js.map +0 -1
  115. package/lib/react-component-lib/index.d.ts +0 -3
  116. package/lib/react-component-lib/index.js +0 -9
  117. package/lib/react-component-lib/index.js.map +0 -1
  118. package/lib/react-component-lib/utils/attachEventProps.d.ts +0 -8
  119. package/lib/react-component-lib/utils/attachEventProps.js +0 -85
  120. package/lib/react-component-lib/utils/attachEventProps.js.map +0 -1
  121. package/lib/react-component-lib/utils/index.d.ts +0 -8
  122. package/lib/react-component-lib/utils/index.js +0 -36
  123. package/lib/react-component-lib/utils/index.js.map +0 -1
  124. package/lib/withAuthenticator.d.ts +0 -3
  125. package/lib/withAuthenticator.js +0 -127
  126. package/lib/withAuthenticator.js.map +0 -1
  127. package/lib-esm/components.d.ts +0 -56
  128. package/lib-esm/components.js +0 -62
  129. package/lib-esm/components.js.map +0 -1
  130. package/lib-esm/index.d.ts +0 -2
  131. package/lib-esm/index.js +0 -3
  132. package/lib-esm/index.js.map +0 -1
  133. package/lib-esm/react-component-lib/createComponent.d.ts +0 -2
  134. package/lib-esm/react-component-lib/createComponent.js +0 -86
  135. package/lib-esm/react-component-lib/createComponent.js.map +0 -1
  136. package/lib-esm/react-component-lib/createControllerComponent.d.ts +0 -43
  137. package/lib-esm/react-component-lib/createControllerComponent.js +0 -146
  138. package/lib-esm/react-component-lib/createControllerComponent.js.map +0 -1
  139. package/lib-esm/react-component-lib/createOverlayComponent.d.ts +0 -45
  140. package/lib-esm/react-component-lib/createOverlayComponent.js +0 -142
  141. package/lib-esm/react-component-lib/createOverlayComponent.js.map +0 -1
  142. package/lib-esm/react-component-lib/index.d.ts +0 -3
  143. package/lib-esm/react-component-lib/index.js +0 -4
  144. package/lib-esm/react-component-lib/index.js.map +0 -1
  145. package/lib-esm/react-component-lib/utils/attachEventProps.d.ts +0 -8
  146. package/lib-esm/react-component-lib/utils/attachEventProps.js +0 -79
  147. package/lib-esm/react-component-lib/utils/attachEventProps.js.map +0 -1
  148. package/lib-esm/react-component-lib/utils/index.d.ts +0 -8
  149. package/lib-esm/react-component-lib/utils/index.js +0 -28
  150. package/lib-esm/react-component-lib/utils/index.js.map +0 -1
  151. package/lib-esm/withAuthenticator.d.ts +0 -3
  152. package/lib-esm/withAuthenticator.js +0 -121
  153. package/lib-esm/withAuthenticator.js.map +0 -1
  154. package/src/components.ts +0 -65
  155. package/src/index.ts +0 -3
  156. package/src/react-component-lib/createComponent.tsx +0 -69
  157. package/src/react-component-lib/createControllerComponent.tsx +0 -71
  158. package/src/react-component-lib/createOverlayComponent.tsx +0 -79
  159. package/src/react-component-lib/index.ts +0 -3
  160. package/src/react-component-lib/utils/attachEventProps.ts +0 -87
  161. package/src/react-component-lib/utils/index.tsx +0 -31
  162. package/src/withAuthenticator.tsx +0 -62
  163. package/webpack.config.dev.js +0 -6
  164. package/webpack.config.js +0 -56
package/dist/3.js DELETED
@@ -1,2787 +0,0 @@
1
- (this["webpackJsonpaws_amplify_react"] = this["webpackJsonpaws_amplify_react"] || []).push([[3],{
2
-
3
- /***/ "../amplify-ui-components/dist/esm-es5/amplify-confirm-sign-in_7.entry.js":
4
- /*!********************************************************************************!*\
5
- !*** ../amplify-ui-components/dist/esm-es5/amplify-confirm-sign-in_7.entry.js ***!
6
- \********************************************************************************/
7
- /*! exports provided: amplify_confirm_sign_in, amplify_confirm_sign_up, amplify_forgot_password, amplify_require_new_password, amplify_sign_in, amplify_sign_up, amplify_verify_contact */
8
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
9
-
10
- "use strict";
11
- __webpack_require__.r(__webpack_exports__);
12
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_confirm_sign_in", function() { return AmplifyConfirmSignIn; });
13
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_confirm_sign_up", function() { return AmplifyConfirmSignUp; });
14
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_forgot_password", function() { return AmplifyForgotPassword; });
15
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_require_new_password", function() { return AmplifyRequireNewPassword; });
16
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_sign_in", function() { return AmplifySignIn; });
17
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_sign_up", function() { return AmplifySignUp; });
18
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_verify_contact", function() { return AmplifyVerifyContact; });
19
- /* harmony import */ var _index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./index-83f2275b.js */ "../amplify-ui-components/dist/esm-es5/index-83f2275b.js");
20
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
21
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__);
22
- /* harmony import */ var _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./auth-types-78df304e.js */ "../amplify-ui-components/dist/esm-es5/auth-types-78df304e.js");
23
- /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
24
- /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__);
25
- /* harmony import */ var _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Translations-108d469f.js */ "../amplify-ui-components/dist/esm-es5/Translations-108d469f.js");
26
- /* harmony import */ var _constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants-c8ecaa24.js */ "../amplify-ui-components/dist/esm-es5/constants-c8ecaa24.js");
27
- /* harmony import */ var _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./helpers-14fcb50c.js */ "../amplify-ui-components/dist/esm-es5/helpers-14fcb50c.js");
28
- /* harmony import */ var _auth_helpers_557b83fc_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./auth-helpers-557b83fc.js */ "../amplify-ui-components/dist/esm-es5/auth-helpers-557b83fc.js");
29
- var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
30
- function adopt(value) {
31
- return value instanceof P ? value : new P(function (resolve) {
32
- resolve(value);
33
- });
34
- }
35
-
36
- return new (P || (P = Promise))(function (resolve, reject) {
37
- function fulfilled(value) {
38
- try {
39
- step(generator.next(value));
40
- } catch (e) {
41
- reject(e);
42
- }
43
- }
44
-
45
- function rejected(value) {
46
- try {
47
- step(generator["throw"](value));
48
- } catch (e) {
49
- reject(e);
50
- }
51
- }
52
-
53
- function step(result) {
54
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
55
- }
56
-
57
- step((generator = generator.apply(thisArg, _arguments || [])).next());
58
- });
59
- };
60
-
61
- var __generator = undefined && undefined.__generator || function (thisArg, body) {
62
- var _ = {
63
- label: 0,
64
- sent: function sent() {
65
- if (t[0] & 1) throw t[1];
66
- return t[1];
67
- },
68
- trys: [],
69
- ops: []
70
- },
71
- f,
72
- y,
73
- t,
74
- g;
75
- return g = {
76
- next: verb(0),
77
- "throw": verb(1),
78
- "return": verb(2)
79
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
80
- return this;
81
- }), g;
82
-
83
- function verb(n) {
84
- return function (v) {
85
- return step([n, v]);
86
- };
87
- }
88
-
89
- function step(op) {
90
- if (f) throw new TypeError("Generator is already executing.");
91
-
92
- while (_) {
93
- try {
94
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
95
- if (y = 0, t) op = [op[0] & 2, t.value];
96
-
97
- switch (op[0]) {
98
- case 0:
99
- case 1:
100
- t = op;
101
- break;
102
-
103
- case 4:
104
- _.label++;
105
- return {
106
- value: op[1],
107
- done: false
108
- };
109
-
110
- case 5:
111
- _.label++;
112
- y = op[1];
113
- op = [0];
114
- continue;
115
-
116
- case 7:
117
- op = _.ops.pop();
118
-
119
- _.trys.pop();
120
-
121
- continue;
122
-
123
- default:
124
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
125
- _ = 0;
126
- continue;
127
- }
128
-
129
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
130
- _.label = op[1];
131
- break;
132
- }
133
-
134
- if (op[0] === 6 && _.label < t[1]) {
135
- _.label = t[1];
136
- t = op;
137
- break;
138
- }
139
-
140
- if (t && _.label < t[2]) {
141
- _.label = t[2];
142
-
143
- _.ops.push(op);
144
-
145
- break;
146
- }
147
-
148
- if (t[2]) _.ops.pop();
149
-
150
- _.trys.pop();
151
-
152
- continue;
153
- }
154
-
155
- op = body.call(thisArg, _);
156
- } catch (e) {
157
- op = [6, e];
158
- y = 0;
159
- } finally {
160
- f = t = 0;
161
- }
162
- }
163
-
164
- if (op[0] & 5) throw op[1];
165
- return {
166
- value: op[0] ? op[1] : void 0,
167
- done: true
168
- };
169
- }
170
- };
171
-
172
- var __spreadArrays = undefined && undefined.__spreadArrays || function () {
173
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
174
- s += arguments[i].length;
175
- }
176
-
177
- for (var r = Array(s), k = 0, i = 0; i < il; i++) {
178
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {
179
- r[k] = a[j];
180
- }
181
- }
182
-
183
- return r;
184
- };
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
-
195
- var AmplifyConfirmSignIn =
196
- /** @class */
197
- function () {
198
- function class_1(hostRef) {
199
- var _this = this;
200
-
201
- Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
202
- /** Fires when confirm sign in form is submitted */
203
-
204
- this.handleSubmit = function (event) {
205
- return _this.confirm(event);
206
- };
207
- /** Used for header text in confirm sign in component */
208
-
209
-
210
- this.headerText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM_SMS_CODE;
211
- /** Used for the submit button text in confirm sign in component */
212
-
213
- this.submitButtonText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM;
214
- /** Auth state change handler for this component */
215
-
216
- this.handleAuthStateChange = _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["d"];
217
- /** Default form field */
218
-
219
- this.defaultFormFields = [{
220
- type: 'code',
221
- required: true,
222
- handleInputChange: function handleInputChange(event) {
223
- return _this.handleCodeChange(event);
224
- }
225
- }];
226
- /**
227
- * Form fields allows you to utilize our pre-built components such as username field, code field, password field, email field, etc.
228
- * by passing an array of strings that you would like the order of the form to be in. If you need more customization, such as changing
229
- * text for a label or adjust a placeholder, you can follow the structure below in order to do just that.
230
- * ```
231
- * [
232
- * {
233
- * type: string,
234
- * label: string,
235
- * placeholder: string,
236
- * hint: string | Functional Component | null,
237
- * required: boolean
238
- * }
239
- * ]
240
- * ```
241
- */
242
-
243
- this.formFields = this.defaultFormFields;
244
- /** The MFA option to confirm with */
245
-
246
- this.mfaOption = _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["M"].SMS;
247
- /* Whether or not the confirm-sign-in component is loading */
248
-
249
- this.loading = false;
250
- }
251
-
252
- class_1.prototype.componentWillLoad = function () {
253
- this.setup();
254
- };
255
-
256
- class_1.prototype.userHandler = function () {
257
- this.setup();
258
- };
259
-
260
- class_1.prototype.setup = function () {
261
- if (this.user && this.user['challengeName'] === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["C"].SoftwareTokenMFA) {
262
- this.mfaOption = _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["M"].TOTP; // If header text is using default use TOTP string
263
-
264
- if (this.headerText === _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM_SMS_CODE) {
265
- this.headerText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM_TOTP_CODE;
266
- }
267
- }
268
-
269
- this.constructedFormFieldOptions = this.constructFormFieldOptions(this.formFields);
270
- };
271
-
272
- class_1.prototype.handleCodeChange = function (event) {
273
- this.code = event.target.value;
274
- };
275
-
276
- class_1.prototype.confirm = function (event) {
277
- return __awaiter(this, void 0, void 0, function () {
278
- var mfaType, error_1;
279
- return __generator(this, function (_a) {
280
- switch (_a.label) {
281
- case 0:
282
- if (event) {
283
- event.preventDefault();
284
- }
285
-
286
- mfaType = this.user['challengeName'] === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["C"].SoftwareTokenMFA ? _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["C"].SoftwareTokenMFA : null;
287
-
288
- if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].confirmSignIn !== 'function') {
289
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
290
- }
291
-
292
- this.loading = true;
293
- _a.label = 1;
294
-
295
- case 1:
296
- _a.trys.push([1, 4, 5, 6]);
297
-
298
- return [4
299
- /*yield*/
300
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].confirmSignIn(this.user, this.code, mfaType)];
301
-
302
- case 2:
303
- _a.sent();
304
-
305
- return [4
306
- /*yield*/
307
- , Object(_auth_helpers_557b83fc_js__WEBPACK_IMPORTED_MODULE_7__["c"])(this.user, this.handleAuthStateChange)];
308
-
309
- case 3:
310
- _a.sent();
311
-
312
- return [3
313
- /*break*/
314
- , 6];
315
-
316
- case 4:
317
- error_1 = _a.sent();
318
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error_1);
319
- return [3
320
- /*break*/
321
- , 6];
322
-
323
- case 5:
324
- this.loading = false;
325
- return [7
326
- /*endfinally*/
327
- ];
328
-
329
- case 6:
330
- return [2
331
- /*return*/
332
- ];
333
- }
334
- });
335
- });
336
- };
337
-
338
- class_1.prototype.constructFormFieldOptions = function (formFields) {
339
- var _this = this;
340
-
341
- var content = [];
342
- if (formFields === undefined) return undefined;
343
- if (formFields.length <= 0) return this.defaultFormFields;
344
- formFields.forEach(function (formField) {
345
- if (typeof formField === 'string' || formField.type !== 'code') {
346
- // This is either a `string`, and/or a custom field that isn't `code`. Pass this directly.
347
- content.push(formField);
348
- } else {
349
- // This is a code input field. Attach input handler.
350
- content.push(Object.assign({
351
- handleInputChange: function handleInputChange(event) {
352
- return _this.handleCodeChange(event);
353
- }
354
- }, formField));
355
- }
356
- });
357
- return content;
358
- };
359
-
360
- class_1.prototype.render = function () {
361
- var _this = this;
362
-
363
- return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["H"], null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-form-section", {
364
- headerText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.headerText),
365
- handleSubmit: this.handleSubmit,
366
- submitButtonText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.submitButtonText),
367
- loading: this.loading,
368
- secondaryFooterContent: Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("span", null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
369
- variant: "anchor",
370
- onClick: function onClick() {
371
- return _this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignIn);
372
- }
373
- }, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].BACK_TO_SIGN_IN)))
374
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-auth-fields", {
375
- formFields: this.constructedFormFieldOptions
376
- })));
377
- };
378
-
379
- Object.defineProperty(class_1, "watchers", {
380
- get: function get() {
381
- return {
382
- "user": ["userHandler"]
383
- };
384
- },
385
- enumerable: false,
386
- configurable: true
387
- });
388
- return class_1;
389
- }();
390
-
391
- var AmplifyConfirmSignUp =
392
- /** @class */
393
- function () {
394
- function class_2(hostRef) {
395
- var _this = this;
396
-
397
- Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
398
- /** Fires when sign up form is submitted */
399
-
400
- this.handleSubmit = function (event) {
401
- return _this.confirmSignUp(event);
402
- };
403
- /** Used for header text in confirm sign up component */
404
-
405
-
406
- this.headerText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM_SIGN_UP_HEADER_TEXT;
407
- /** Used for the submit button text in confirm sign up component */
408
-
409
- this.submitButtonText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM_SIGN_UP_SUBMIT_BUTTON_TEXT;
410
- /**
411
- * Form fields allows you to utilize our pre-built components such as username field, code field, password field, email field, etc.
412
- * by passing an array of strings that you would like the order of the form to be in. If you need more customization, such as changing
413
- * text for a label or adjust a placeholder, you can follow the structure below in order to do just that.
414
- * ```
415
- * [
416
- * {
417
- * type: string,
418
- * label: string,
419
- * placeholder: string,
420
- * hint: string | Functional Component | null,
421
- * required: boolean
422
- * }
423
- * ]
424
- * ```
425
- */
426
-
427
- this.formFields = [];
428
- /** Auth state change handler for this components
429
- * e.g. SignIn -> 'Create Account' link -> SignUp
430
- */
431
-
432
- this.handleAuthStateChange = _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["d"];
433
- /** Username Alias is used to setup authentication with `username`, `email` or `phone_number` */
434
-
435
- this.usernameAlias = 'username';
436
- this.loading = false;
437
- this.newFormFields = [];
438
- this.phoneNumber = {
439
- countryDialCodeValue: _constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["g"],
440
- phoneNumberValue: null
441
- };
442
- }
443
-
444
- class_2.prototype.componentWillLoad = function () {
445
- this.setup();
446
- };
447
-
448
- class_2.prototype.formFieldsHandler = function () {
449
- this.buildFormFields();
450
- };
451
-
452
- class_2.prototype.userHandler = function () {
453
- this.setup();
454
- };
455
-
456
- class_2.prototype.setup = function () {
457
- // TODO: Use optional chaining instead
458
- this.userInput = this.user && this.user.username;
459
- this._signUpAttrs = this.user && this.user.signUpAttrs;
460
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["c"])(this.usernameAlias);
461
- this.buildFormFields();
462
- };
463
-
464
- class_2.prototype.buildDefaultFormFields = function () {
465
- var _this = this;
466
-
467
- this.newFormFields = [{
468
- type: "" + this.usernameAlias,
469
- required: true,
470
- handleInputChange: this.handleFormFieldInputChange("" + this.usernameAlias),
471
- value: this.userInput,
472
- disabled: this.userInput ? true : false,
473
- inputProps: {
474
- autocomplete: 'username'
475
- }
476
- }, {
477
- type: 'code',
478
- label: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM_SIGN_UP_CODE_LABEL),
479
- placeholder: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM_SIGN_UP_CODE_PLACEHOLDER),
480
- required: true,
481
- hint: Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", null, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM_SIGN_UP_LOST_CODE), ' ', Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
482
- variant: "anchor",
483
- onClick: function onClick() {
484
- return _this.resendConfirmCode();
485
- }
486
- }, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM_SIGN_UP_RESEND_CODE))),
487
- handleInputChange: this.handleFormFieldInputChange('code')
488
- }];
489
- };
490
-
491
- class_2.prototype.buildFormFields = function () {
492
- var _this = this;
493
-
494
- if (this.formFields.length === 0) {
495
- this.buildDefaultFormFields();
496
- } else {
497
- var newFields_1 = [];
498
- this.formFields.forEach(function (field) {
499
- var newField = Object.assign({}, field);
500
-
501
- if (newField.type === 'code') {
502
- newField['hint'] = Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["i"])(newField) ? Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", null, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM_SIGN_UP_LOST_CODE), ' ', Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
503
- variant: "anchor",
504
- onClick: function onClick() {
505
- return _this.resendConfirmCode();
506
- }
507
- }, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM_SIGN_UP_RESEND_CODE))) : newField['hint'];
508
- }
509
-
510
- newField['handleInputChange'] = function (event) {
511
- return _this.handleFormFieldInputWithCallback(event, field);
512
- };
513
-
514
- newFields_1.push(newField);
515
- });
516
- this.newFormFields = newFields_1;
517
- }
518
- };
519
-
520
- class_2.prototype.handleFormFieldInputChange = function (fieldType) {
521
- var _this = this;
522
-
523
- switch (fieldType) {
524
- case 'username':
525
- case 'email':
526
- return function (event) {
527
- return _this.userInput = event.target.value;
528
- };
529
-
530
- case 'phone_number':
531
- return function (event) {
532
- return Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["h"])(event, _this.phoneNumber);
533
- };
534
-
535
- case 'code':
536
- return function (event) {
537
- return _this.code = event.target.value;
538
- };
539
-
540
- default:
541
- return;
542
- }
543
- };
544
-
545
- class_2.prototype.setFieldValue = function (field) {
546
- switch (field.type) {
547
- case 'username':
548
- case 'email':
549
- if (field.value === undefined) {
550
- this.userInput = '';
551
- } else {
552
- this.userInput = field.value;
553
- }
554
-
555
- break;
556
-
557
- case 'phone_number':
558
- if (field.dialCode) {
559
- this.phoneNumber.countryDialCodeValue = field.dialCode;
560
- }
561
-
562
- this.phoneNumber.phoneNumberValue = field.value;
563
- break;
564
- }
565
- };
566
-
567
- class_2.prototype.handleFormFieldInputWithCallback = function (event, field) {
568
- var fnToCall = field['handleInputChange'] ? field['handleInputChange'] : function (event, cb) {
569
- cb(event);
570
- };
571
- var callback = this.handleFormFieldInputChange(field.type);
572
- fnToCall(event, callback.bind(this));
573
- };
574
- /**
575
- * Returns the username of the user to confirm. If a valid `user.username` has been passed as a prop, we return that.
576
- * Otherwise, we return the `userInput` on the form.
577
- */
578
-
579
-
580
- class_2.prototype.getUsername = function () {
581
- if (this.user && this.user.username) return this.user.username;
582
-
583
- switch (this.usernameAlias) {
584
- case 'username':
585
- case 'email':
586
- return this.userInput;
587
-
588
- case 'phone_number':
589
- return Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["b"])(this.phoneNumber);
590
- }
591
- };
592
-
593
- class_2.prototype.resendConfirmCode = function () {
594
- return __awaiter(this, void 0, void 0, function () {
595
- var username, error_2;
596
- return __generator(this, function (_a) {
597
- switch (_a.label) {
598
- case 0:
599
- if (event) {
600
- event.preventDefault();
601
- }
602
-
603
- if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].resendSignUp !== 'function') {
604
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
605
- }
606
-
607
- _a.label = 1;
608
-
609
- case 1:
610
- _a.trys.push([1, 3,, 4]);
611
-
612
- username = this.getUsername();
613
- if (!username) throw new Error(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].EMPTY_USERNAME);
614
- return [4
615
- /*yield*/
616
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].resendSignUp(username.trim())];
617
-
618
- case 2:
619
- _a.sent();
620
-
621
- return [3
622
- /*break*/
623
- , 4];
624
-
625
- case 3:
626
- error_2 = _a.sent();
627
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error_2);
628
- return [3
629
- /*break*/
630
- , 4];
631
-
632
- case 4:
633
- return [2
634
- /*return*/
635
- ];
636
- }
637
- });
638
- });
639
- }; // TODO: Add validation
640
- // TODO: Prefix
641
-
642
-
643
- class_2.prototype.confirmSignUp = function (event) {
644
- return __awaiter(this, void 0, void 0, function () {
645
- var username, confirmSignUpResult, error_3;
646
- return __generator(this, function (_a) {
647
- switch (_a.label) {
648
- case 0:
649
- if (event) {
650
- event.preventDefault();
651
- }
652
-
653
- if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].confirmSignUp !== 'function') {
654
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
655
- }
656
-
657
- this.loading = true;
658
- _a.label = 1;
659
-
660
- case 1:
661
- _a.trys.push([1, 6, 7, 8]);
662
-
663
- username = this.getUsername();
664
- if (!username) throw new Error(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].EMPTY_USERNAME);
665
- username = username.trim();
666
- return [4
667
- /*yield*/
668
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].confirmSignUp(username, this.code)];
669
-
670
- case 2:
671
- confirmSignUpResult = _a.sent();
672
-
673
- if (!confirmSignUpResult) {
674
- throw new Error(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CONFIRM_SIGN_UP_FAILED));
675
- }
676
-
677
- if (!(this._signUpAttrs && this._signUpAttrs.password && this._signUpAttrs.password !== '')) return [3
678
- /*break*/
679
- , 4]; // Auto sign in user if password is available from previous workflow
680
-
681
- return [4
682
- /*yield*/
683
- , Object(_auth_helpers_557b83fc_js__WEBPACK_IMPORTED_MODULE_7__["h"])(username, this._signUpAttrs.password, this.handleAuthStateChange)];
684
-
685
- case 3:
686
- // Auto sign in user if password is available from previous workflow
687
- _a.sent();
688
-
689
- return [3
690
- /*break*/
691
- , 5];
692
-
693
- case 4:
694
- this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignIn);
695
- _a.label = 5;
696
-
697
- case 5:
698
- return [3
699
- /*break*/
700
- , 8];
701
-
702
- case 6:
703
- error_3 = _a.sent();
704
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error_3);
705
- return [3
706
- /*break*/
707
- , 8];
708
-
709
- case 7:
710
- this.loading = false;
711
- return [7
712
- /*endfinally*/
713
- ];
714
-
715
- case 8:
716
- return [2
717
- /*return*/
718
- ];
719
- }
720
- });
721
- });
722
- };
723
-
724
- class_2.prototype.render = function () {
725
- var _this = this;
726
-
727
- return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["H"], null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-form-section", {
728
- headerText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.headerText),
729
- submitButtonText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.submitButtonText),
730
- handleSubmit: this.handleSubmit,
731
- loading: this.loading,
732
- secondaryFooterContent: Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("span", null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
733
- variant: "anchor",
734
- onClick: function onClick() {
735
- return _this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignIn);
736
- }
737
- }, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].BACK_TO_SIGN_IN))))
738
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-auth-fields", {
739
- formFields: this.newFormFields
740
- })));
741
- };
742
-
743
- Object.defineProperty(class_2, "watchers", {
744
- get: function get() {
745
- return {
746
- "formFields": ["formFieldsHandler"],
747
- "user": ["userHandler"]
748
- };
749
- },
750
- enumerable: false,
751
- configurable: true
752
- });
753
- return class_2;
754
- }();
755
-
756
- var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Logger"]('ForgotPassword');
757
-
758
- var AmplifyForgotPassword =
759
- /** @class */
760
- function () {
761
- function class_3(hostRef) {
762
- var _this = this;
763
-
764
- Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
765
- /** The header text of the forgot password section */
766
-
767
- this.headerText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].RESET_YOUR_PASSWORD;
768
- /** The text displayed inside of the send code button for the form */
769
-
770
- this.sendButtonText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SEND_CODE;
771
- /** The text displayed inside of the submit button for the form */
772
-
773
- this.submitButtonText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SUBMIT;
774
- /** The form fields displayed inside of the forgot password form */
775
-
776
- this.formFields = [];
777
- /** The function called when making a request to reset password */
778
-
779
- this.handleSend = function (event) {
780
- return _this.send(event);
781
- };
782
- /** The function called when submitting a new password */
783
-
784
-
785
- this.handleSubmit = function (event) {
786
- return _this.submit(event);
787
- };
788
- /** Auth state change handler for this component */
789
-
790
-
791
- this.handleAuthStateChange = _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["d"];
792
- /** Username Alias is used to setup authentication with `username`, `email` or `phone_number` */
793
-
794
- this.usernameAlias = 'username';
795
- this.delivery = null;
796
- this.loading = false;
797
- this.phoneNumber = {
798
- countryDialCodeValue: _constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["g"],
799
- phoneNumberValue: null
800
- };
801
- this.newFormFields = [];
802
- this.forgotPasswordAttrs = {
803
- userInput: '',
804
- password: '',
805
- code: ''
806
- };
807
- }
808
-
809
- class_3.prototype.componentWillLoad = function () {
810
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["c"])(this.usernameAlias);
811
- this.buildFormFields();
812
- };
813
-
814
- class_3.prototype.formFieldsHandler = function () {
815
- this.buildFormFields();
816
- };
817
-
818
- class_3.prototype.buildFormFields = function () {
819
- var _this = this;
820
-
821
- if (this.formFields.length === 0) {
822
- this.buildDefaultFormFields();
823
- } else {
824
- var newFields_2 = [];
825
- this.formFields.forEach(function (field) {
826
- var newField = Object.assign({}, field);
827
-
828
- newField['handleInputChange'] = function (event) {
829
- return _this.handleFormFieldInputWithCallback(event, field);
830
- };
831
-
832
- newFields_2.push(newField);
833
- });
834
- this.newFormFields = newFields_2;
835
- }
836
- };
837
-
838
- class_3.prototype.buildDefaultFormFields = function () {
839
- switch (this.usernameAlias) {
840
- case 'email':
841
- this.newFormFields = [{
842
- type: 'email',
843
- required: true,
844
- handleInputChange: this.handleFormFieldInputChange('email'),
845
- inputProps: {
846
- 'data-test': 'forgot-password-email-input'
847
- }
848
- }];
849
- break;
850
-
851
- case 'phone_number':
852
- this.newFormFields = [{
853
- type: 'phone_number',
854
- required: true,
855
- handleInputChange: this.handleFormFieldInputChange('phone_number'),
856
- inputProps: {
857
- 'data-test': 'forgot-password-phone-number-input'
858
- }
859
- }];
860
- break;
861
-
862
- case 'username':
863
- default:
864
- this.newFormFields = [{
865
- type: 'username',
866
- required: true,
867
- handleInputChange: this.handleFormFieldInputChange('username'),
868
- inputProps: {
869
- 'data-test': 'forgot-password-username-input'
870
- }
871
- }];
872
- break;
873
- }
874
- };
875
-
876
- class_3.prototype.handleFormFieldInputChange = function (fieldType) {
877
- var _this = this;
878
-
879
- switch (fieldType) {
880
- case 'username':
881
- case 'email':
882
- return function (event) {
883
- return _this.forgotPasswordAttrs.userInput = event.target.value;
884
- };
885
-
886
- case 'phone_number':
887
- return function (event) {
888
- return Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["h"])(event, _this.phoneNumber);
889
- };
890
-
891
- case 'password':
892
- case 'code':
893
- return function (event) {
894
- return _this.forgotPasswordAttrs[fieldType] = event.target.value;
895
- };
896
-
897
- default:
898
- return;
899
- }
900
- };
901
-
902
- class_3.prototype.setFieldValue = function (field, formAttributes) {
903
- switch (field.type) {
904
- case 'username':
905
- case 'email':
906
- if (field.value === undefined) {
907
- formAttributes.userInput = '';
908
- } else {
909
- formAttributes.userInput = field.value;
910
- }
911
-
912
- break;
913
-
914
- case 'phone_number':
915
- if (field.dialCode) {
916
- this.phoneNumber.countryDialCodeValue = field.dialCode;
917
- }
918
-
919
- this.phoneNumber.phoneNumberValue = field.value;
920
- break;
921
-
922
- case 'password':
923
- case 'code':
924
- if (field.value === undefined) {
925
- formAttributes[field.type] = '';
926
- } else {
927
- formAttributes[field.type] = field.value;
928
- }
929
-
930
- break;
931
- }
932
- };
933
-
934
- class_3.prototype.handleFormFieldInputWithCallback = function (event, field) {
935
- var fnToCall = field['handleInputChange'] ? field['handleInputChange'] : function (event, cb) {
936
- cb(event);
937
- };
938
- var callback = this.handleFormFieldInputChange(field.type);
939
- fnToCall(event, callback.bind(this));
940
- };
941
-
942
- class_3.prototype.send = function (event) {
943
- return __awaiter(this, void 0, void 0, function () {
944
- var data, error_4;
945
- return __generator(this, function (_a) {
946
- switch (_a.label) {
947
- case 0:
948
- if (event) {
949
- event.preventDefault();
950
- }
951
-
952
- if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].forgotPassword !== 'function') {
953
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
954
- }
955
-
956
- this.loading = true;
957
-
958
- switch (this.usernameAlias) {
959
- case 'phone_number':
960
- try {
961
- this.forgotPasswordAttrs.userInput = Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["b"])(this.phoneNumber);
962
- } catch (error) {
963
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error);
964
- }
965
-
966
- break;
967
- }
968
-
969
- _a.label = 1;
970
-
971
- case 1:
972
- _a.trys.push([1, 3, 4, 5]);
973
-
974
- return [4
975
- /*yield*/
976
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].forgotPassword(this.forgotPasswordAttrs.userInput.trim())];
977
-
978
- case 2:
979
- data = _a.sent();
980
- logger.debug(data);
981
- this.newFormFields = [{
982
- type: 'code',
983
- required: true,
984
- handleInputChange: this.handleFormFieldInputChange('code'),
985
- inputProps: {
986
- 'data-test': 'forgot-password-code-input'
987
- }
988
- }, {
989
- type: 'password',
990
- required: true,
991
- handleInputChange: this.handleFormFieldInputChange('password'),
992
- label: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].NEW_PASSWORD_LABEL),
993
- placeholder: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].NEW_PASSWORD_PLACEHOLDER)
994
- }];
995
- this.delivery = data.CodeDeliveryDetails;
996
- return [3
997
- /*break*/
998
- , 5];
999
-
1000
- case 3:
1001
- error_4 = _a.sent();
1002
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error_4);
1003
- return [3
1004
- /*break*/
1005
- , 5];
1006
-
1007
- case 4:
1008
- this.loading = false;
1009
- return [7
1010
- /*endfinally*/
1011
- ];
1012
-
1013
- case 5:
1014
- return [2
1015
- /*return*/
1016
- ];
1017
- }
1018
- });
1019
- });
1020
- };
1021
-
1022
- class_3.prototype.submit = function (event) {
1023
- return __awaiter(this, void 0, void 0, function () {
1024
- var _a, userInput, code, password, data, error_5;
1025
-
1026
- return __generator(this, function (_b) {
1027
- switch (_b.label) {
1028
- case 0:
1029
- if (event) {
1030
- event.preventDefault();
1031
- }
1032
-
1033
- if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].forgotPasswordSubmit !== 'function') {
1034
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
1035
- }
1036
-
1037
- this.loading = true;
1038
- _b.label = 1;
1039
-
1040
- case 1:
1041
- _b.trys.push([1, 3, 4, 5]);
1042
-
1043
- _a = this.forgotPasswordAttrs, userInput = _a.userInput, code = _a.code, password = _a.password;
1044
- return [4
1045
- /*yield*/
1046
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].forgotPasswordSubmit(userInput.trim(), code, password)];
1047
-
1048
- case 2:
1049
- data = _b.sent();
1050
- logger.debug(data);
1051
- this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignIn);
1052
- this.delivery = null;
1053
- return [3
1054
- /*break*/
1055
- , 5];
1056
-
1057
- case 3:
1058
- error_5 = _b.sent();
1059
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error_5);
1060
- return [3
1061
- /*break*/
1062
- , 5];
1063
-
1064
- case 4:
1065
- this.loading = false;
1066
- return [7
1067
- /*endfinally*/
1068
- ];
1069
-
1070
- case 5:
1071
- return [2
1072
- /*return*/
1073
- ];
1074
- }
1075
- });
1076
- });
1077
- };
1078
-
1079
- class_3.prototype.render = function () {
1080
- var _this = this;
1081
-
1082
- var submitFn = this.delivery ? function (event) {
1083
- return _this.handleSubmit(event);
1084
- } : function (event) {
1085
- return _this.handleSend(event);
1086
- };
1087
- var submitButtonText = this.delivery ? this.submitButtonText : this.sendButtonText;
1088
- return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["H"], null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-form-section", {
1089
- headerText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.headerText),
1090
- handleSubmit: submitFn,
1091
- loading: this.loading,
1092
- secondaryFooterContent: Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
1093
- variant: "anchor",
1094
- onClick: function onClick() {
1095
- return _this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignIn);
1096
- },
1097
- "data-test": "forgot-password-back-to-sign-in-link"
1098
- }, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].BACK_TO_SIGN_IN)),
1099
- testDataPrefix: 'forgot-password',
1100
- submitButtonText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(submitButtonText)
1101
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-auth-fields", {
1102
- formFields: this.newFormFields
1103
- })));
1104
- };
1105
-
1106
- Object.defineProperty(class_3, "watchers", {
1107
- get: function get() {
1108
- return {
1109
- "formFields": ["formFieldsHandler"]
1110
- };
1111
- },
1112
- enumerable: false,
1113
- configurable: true
1114
- });
1115
- return class_3;
1116
- }();
1117
-
1118
- var logger$1 = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('amplify-require-new-password');
1119
-
1120
- var AmplifyRequireNewPassword =
1121
- /** @class */
1122
- function () {
1123
- function class_4(hostRef) {
1124
- var _this = this;
1125
-
1126
- Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
1127
- /** The header text of the forgot password section */
1128
-
1129
- this.headerText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CHANGE_PASSWORD;
1130
- /** The text displayed inside of the submit button for the form */
1131
-
1132
- this.submitButtonText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CHANGE_PASSWORD_ACTION;
1133
- /** The function called when submitting a new password */
1134
-
1135
- this.handleSubmit = function (event) {
1136
- return _this.completeNewPassword(event);
1137
- };
1138
- /** Auth state change handler for this component */
1139
-
1140
-
1141
- this.handleAuthStateChange = _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["d"];
1142
- /** The form fields displayed inside of the forgot password form */
1143
-
1144
- this.formFields = [{
1145
- type: _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["a"].Password,
1146
- required: true,
1147
- handleInputChange: function handleInputChange(event) {
1148
- return _this.handlePasswordChange(event);
1149
- },
1150
- label: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].NEW_PASSWORD_LABEL),
1151
- placeholder: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].NEW_PASSWORD_PLACEHOLDER),
1152
- inputProps: {
1153
- 'data-test': 'require-new-password-password-input'
1154
- }
1155
- }];
1156
- this.loading = false;
1157
- this.requiredAttributes = {};
1158
- this.newFormFields = this.formFields;
1159
- this.phoneNumber = {
1160
- countryDialCodeValue: _constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["g"],
1161
- phoneNumberValue: ' '
1162
- };
1163
- }
1164
-
1165
- class_4.prototype.userHandler = function () {
1166
- this.setCurrentUser();
1167
- };
1168
-
1169
- class_4.prototype.handleRequiredAttributeInputChange = function (attribute, event) {
1170
- if (attribute === 'phone_number') {
1171
- this.formatPhoneNumber(event);
1172
- } else {
1173
- this.requiredAttributes[attribute] = event.target.value;
1174
- }
1175
- };
1176
-
1177
- class_4.prototype.setCurrentUser = function () {
1178
- return __awaiter(this, void 0, void 0, function () {
1179
- var user, error_6, userRequiredAttributes, requiredAttributesMap_1;
1180
-
1181
- var _this = this;
1182
-
1183
- return __generator(this, function (_a) {
1184
- switch (_a.label) {
1185
- case 0:
1186
- if (!!this.user) return [3
1187
- /*break*/
1188
- , 5];
1189
- _a.label = 1;
1190
-
1191
- case 1:
1192
- _a.trys.push([1, 3,, 4]);
1193
-
1194
- return [4
1195
- /*yield*/
1196
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].currentAuthenticatedUser()];
1197
-
1198
- case 2:
1199
- user = _a.sent();
1200
- if (user) this.currentUser = user;
1201
- return [3
1202
- /*break*/
1203
- , 4];
1204
-
1205
- case 3:
1206
- error_6 = _a.sent();
1207
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error_6);
1208
- return [3
1209
- /*break*/
1210
- , 4];
1211
-
1212
- case 4:
1213
- return [3
1214
- /*break*/
1215
- , 6];
1216
-
1217
- case 5:
1218
- this.currentUser = this.user;
1219
- _a.label = 6;
1220
-
1221
- case 6:
1222
- if (this.currentUser && this.currentUser.challengeParam && this.currentUser.challengeParam.requiredAttributes) {
1223
- userRequiredAttributes = this.currentUser.challengeParam.requiredAttributes;
1224
- requiredAttributesMap_1 = Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["g"])();
1225
- userRequiredAttributes.forEach(function (attribute) {
1226
- var formField = {
1227
- type: attribute,
1228
- required: true,
1229
- label: requiredAttributesMap_1[attribute].label,
1230
- placeholder: requiredAttributesMap_1[attribute].placeholder,
1231
- handleInputChange: function handleInputChange(event) {
1232
- return _this.handleRequiredAttributeInputChange(attribute, event);
1233
- },
1234
- inputProps: {
1235
- 'data-test': "require-new-password-" + attribute + "-input"
1236
- }
1237
- };
1238
- _this.newFormFields = __spreadArrays(_this.newFormFields, [formField]);
1239
- });
1240
- }
1241
-
1242
- return [2
1243
- /*return*/
1244
- ];
1245
- }
1246
- });
1247
- });
1248
- };
1249
-
1250
- class_4.prototype.componentWillLoad = function () {
1251
- return this.setCurrentUser();
1252
- };
1253
-
1254
- class_4.prototype.handlePasswordChange = function (event) {
1255
- this.password = event.target.value;
1256
- };
1257
-
1258
- class_4.prototype.formatPhoneNumber = function (event) {
1259
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["h"])(event, this.phoneNumber);
1260
- /**
1261
- * composePhoneNumberInput will throw an error if the phoneNumberValue it receives
1262
- * is empty. Adding a check here to try and make sure that doesn't happen...but will
1263
- * wrap it in a try/catch block just in case as well
1264
- */
1265
-
1266
- try {
1267
- if (event.target.name === _constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["b"] && this.phoneNumber.phoneNumberValue) {
1268
- var composedInput = Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["b"])(this.phoneNumber);
1269
- this.requiredAttributes['phone_number'] = composedInput;
1270
- }
1271
- } catch (err) {
1272
- logger$1.error("error in phone number field - " + err);
1273
- }
1274
- };
1275
-
1276
- class_4.prototype.completeNewPassword = function (event) {
1277
- return __awaiter(this, void 0, void 0, function () {
1278
- var user, _a, error_7;
1279
-
1280
- return __generator(this, function (_b) {
1281
- switch (_b.label) {
1282
- case 0:
1283
- if (event) {
1284
- event.preventDefault();
1285
- }
1286
-
1287
- if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].completeNewPassword !== 'function') {
1288
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
1289
- }
1290
-
1291
- this.loading = true;
1292
- _b.label = 1;
1293
-
1294
- case 1:
1295
- _b.trys.push([1, 8, 9, 10]);
1296
-
1297
- return [4
1298
- /*yield*/
1299
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].completeNewPassword(this.currentUser, this.password, this.requiredAttributes)];
1300
-
1301
- case 2:
1302
- user = _b.sent();
1303
- logger$1.debug('complete new password', user);
1304
- _a = user.challengeName;
1305
-
1306
- switch (_a) {
1307
- case _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["C"].SMSMFA:
1308
- return [3
1309
- /*break*/
1310
- , 3];
1311
-
1312
- case _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["C"].MFASetup:
1313
- return [3
1314
- /*break*/
1315
- , 4];
1316
- }
1317
-
1318
- return [3
1319
- /*break*/
1320
- , 5];
1321
-
1322
- case 3:
1323
- this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].ConfirmSignIn, user);
1324
- return [3
1325
- /*break*/
1326
- , 7];
1327
-
1328
- case 4:
1329
- logger$1.debug('TOTP setup', user.challengeParam);
1330
- this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].TOTPSetup, user);
1331
- return [3
1332
- /*break*/
1333
- , 7];
1334
-
1335
- case 5:
1336
- return [4
1337
- /*yield*/
1338
- , Object(_auth_helpers_557b83fc_js__WEBPACK_IMPORTED_MODULE_7__["c"])(user, this.handleAuthStateChange)];
1339
-
1340
- case 6:
1341
- _b.sent();
1342
-
1343
- _b.label = 7;
1344
-
1345
- case 7:
1346
- return [3
1347
- /*break*/
1348
- , 10];
1349
-
1350
- case 8:
1351
- error_7 = _b.sent();
1352
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error_7);
1353
- return [3
1354
- /*break*/
1355
- , 10];
1356
-
1357
- case 9:
1358
- this.loading = false;
1359
- return [7
1360
- /*endfinally*/
1361
- ];
1362
-
1363
- case 10:
1364
- return [2
1365
- /*return*/
1366
- ];
1367
- }
1368
- });
1369
- });
1370
- };
1371
-
1372
- class_4.prototype.render = function () {
1373
- var _this = this;
1374
-
1375
- return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["H"], null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-form-section", {
1376
- headerText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.headerText),
1377
- handleSubmit: this.handleSubmit,
1378
- loading: this.loading,
1379
- secondaryFooterContent: Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
1380
- variant: "anchor",
1381
- onClick: function onClick() {
1382
- return _this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignIn);
1383
- }
1384
- }, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].BACK_TO_SIGN_IN)),
1385
- submitButtonText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.submitButtonText)
1386
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-auth-fields", {
1387
- formFields: this.newFormFields
1388
- })));
1389
- };
1390
-
1391
- Object.defineProperty(class_4, "watchers", {
1392
- get: function get() {
1393
- return {
1394
- "user": ["userHandler"]
1395
- };
1396
- },
1397
- enumerable: false,
1398
- configurable: true
1399
- });
1400
- return class_4;
1401
- }();
1402
-
1403
- var amplifySignInCss = ":host{--footer-size:var(--amplify-text-sm);--footer-color:var(--amplify-grey);--footer-font-family:var(--amplify-font-family);--font-weight:var(--amplify-font-weight)}.sign-in-form-footer{font-family:var(--footer-font-family);font-size:var(--footer-size);color:var(--footer-color);font-weight:--font-weight;display:-ms-flexbox;display:flex;-ms-flex-direction:column-reverse;flex-direction:column-reverse;-ms-flex-align:center;align-items:center;-ms-flex-pack:distribute;justify-content:space-around}.sign-in-form-footer amplify-button{margin-bottom:0.625rem}@media (min-width: 672px){.sign-in-form-footer{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:baseline;align-items:baseline}.sign-in-form-footer amplify-button{margin-bottom:0}}.sign-in-form-footer *+*{margin-bottom:15px}.full-width-footer-content{width:100%}";
1404
-
1405
- var AmplifySignIn =
1406
- /** @class */
1407
- function () {
1408
- function class_5(hostRef) {
1409
- var _this = this;
1410
-
1411
- Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
1412
- /** Fires when sign in form is submitted */
1413
-
1414
- this.handleSubmit = function (event) {
1415
- return _this.signIn(event);
1416
- };
1417
- /** Used for header text in sign in component */
1418
-
1419
-
1420
- this.headerText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_IN_HEADER_TEXT;
1421
- /** Used for the submit button text in sign in component */
1422
-
1423
- this.submitButtonText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_IN_ACTION;
1424
- /** Auth state change handler for this component */
1425
- // prettier-ignore
1426
-
1427
- this.handleAuthStateChange = _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["d"];
1428
- /** Username Alias is used to setup authentication with `username`, `email` or `phone_number` */
1429
-
1430
- this.usernameAlias = 'username';
1431
- /**
1432
- * Form fields allows you to utilize our pre-built components such as username field, code field, password field, email field, etc.
1433
- * by passing an array of strings that you would like the order of the form to be in. If you need more customization, such as changing
1434
- * text for a label or adjust a placeholder, you can follow the structure below in order to do just that.
1435
- * ```
1436
- * [
1437
- * {
1438
- * type: string,
1439
- * label: string,
1440
- * placeholder: string,
1441
- * hint: string | Functional Component | null,
1442
- * required: boolean
1443
- * }
1444
- * ]
1445
- * ```
1446
- */
1447
-
1448
- this.formFields = [];
1449
- /** Hides the sign up link */
1450
-
1451
- this.hideSignUp = false;
1452
- this.newFormFields = [];
1453
- /* Whether or not the sign-in component is loading */
1454
-
1455
- this.loading = false;
1456
- this.phoneNumber = {
1457
- countryDialCodeValue: _constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["g"],
1458
- phoneNumberValue: null
1459
- };
1460
- this.signInAttributes = {
1461
- userInput: '',
1462
- password: ''
1463
- };
1464
- }
1465
-
1466
- class_5.prototype.componentWillLoad = function () {
1467
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["c"])(this.usernameAlias);
1468
- this.buildFormFields();
1469
- };
1470
-
1471
- class_5.prototype.formFieldsHandler = function () {
1472
- this.buildFormFields();
1473
- };
1474
-
1475
- class_5.prototype.handleFormFieldInputChange = function (fieldType) {
1476
- var _this = this;
1477
-
1478
- switch (fieldType) {
1479
- case 'username':
1480
- case 'email':
1481
- return function (event) {
1482
- return _this.signInAttributes.userInput = event.target.value;
1483
- };
1484
-
1485
- case 'phone_number':
1486
- return function (event) {
1487
- return Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["h"])(event, _this.phoneNumber);
1488
- };
1489
-
1490
- case 'password':
1491
- return function (event) {
1492
- return _this.signInAttributes.password = event.target.value;
1493
- };
1494
-
1495
- default:
1496
- return function () {};
1497
- }
1498
- };
1499
-
1500
- class_5.prototype.handleFormFieldInputWithCallback = function (event, field) {
1501
- var fnToCall = field['handleInputChange'] ? field['handleInputChange'] : function (event, cb) {
1502
- cb(event);
1503
- };
1504
- var callback = this.handleFormFieldInputChange(field.type);
1505
- fnToCall(event, callback.bind(this));
1506
- };
1507
-
1508
- class_5.prototype.signIn = function (event) {
1509
- return __awaiter(this, void 0, void 0, function () {
1510
- var username;
1511
- return __generator(this, function (_a) {
1512
- switch (_a.label) {
1513
- case 0:
1514
- // avoid submitting the form
1515
- if (event) {
1516
- event.preventDefault();
1517
- }
1518
-
1519
- this.loading = true;
1520
-
1521
- switch (this.usernameAlias) {
1522
- case 'phone_number':
1523
- try {
1524
- this.signInAttributes.userInput = Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["b"])(this.phoneNumber);
1525
- } catch (error) {
1526
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error);
1527
- }
1528
-
1529
- }
1530
-
1531
- username = this.signInAttributes.userInput.trim();
1532
- return [4
1533
- /*yield*/
1534
- , Object(_auth_helpers_557b83fc_js__WEBPACK_IMPORTED_MODULE_7__["h"])(username, this.signInAttributes.password, this.handleAuthStateChange, this.usernameAlias)];
1535
-
1536
- case 1:
1537
- _a.sent();
1538
-
1539
- this.loading = false;
1540
- return [2
1541
- /*return*/
1542
- ];
1543
- }
1544
- });
1545
- });
1546
- };
1547
-
1548
- class_5.prototype.buildDefaultFormFields = function () {
1549
- var _this = this;
1550
-
1551
- var formFieldInputs = [];
1552
-
1553
- switch (this.usernameAlias) {
1554
- case 'email':
1555
- formFieldInputs.push({
1556
- type: 'email',
1557
- required: true,
1558
- handleInputChange: this.handleFormFieldInputChange('email'),
1559
- inputProps: {
1560
- 'data-test': 'sign-in-email-input',
1561
- autocomplete: 'username'
1562
- }
1563
- });
1564
- break;
1565
-
1566
- case 'phone_number':
1567
- formFieldInputs.push({
1568
- type: 'phone_number',
1569
- required: true,
1570
- handleInputChange: this.handleFormFieldInputChange('phone_number'),
1571
- inputProps: {
1572
- 'data-test': 'sign-in-phone-number-input',
1573
- autocomplete: 'username'
1574
- }
1575
- });
1576
- break;
1577
-
1578
- case 'username':
1579
- default:
1580
- formFieldInputs.push({
1581
- type: 'username',
1582
- required: true,
1583
- handleInputChange: this.handleFormFieldInputChange('username'),
1584
- inputProps: {
1585
- 'data-test': 'sign-in-username-input',
1586
- autocomplete: 'username'
1587
- }
1588
- });
1589
- break;
1590
- }
1591
-
1592
- formFieldInputs.push({
1593
- type: 'password',
1594
- hint: Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", null, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].FORGOT_PASSWORD_TEXT), ' ', Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
1595
- variant: "anchor",
1596
- onClick: function onClick() {
1597
- return _this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].ForgotPassword);
1598
- },
1599
- "data-test": "sign-in-forgot-password-link"
1600
- }, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].RESET_PASSWORD_TEXT))),
1601
- required: true,
1602
- handleInputChange: this.handleFormFieldInputChange('password'),
1603
- inputProps: {
1604
- 'data-test': 'sign-in-password-input'
1605
- }
1606
- });
1607
- this.newFormFields = __spreadArrays(formFieldInputs);
1608
- };
1609
-
1610
- class_5.prototype.buildFormFields = function () {
1611
- var _this = this;
1612
-
1613
- if (this.formFields.length === 0) {
1614
- this.buildDefaultFormFields();
1615
- } else {
1616
- var newFields_3 = [];
1617
- this.formFields.forEach(function (field) {
1618
- var newField = Object.assign({}, field); // TODO: handle hint better
1619
-
1620
- if (newField.type === 'password') {
1621
- newField['hint'] = Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["i"])(newField) ? Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", null, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].FORGOT_PASSWORD_TEXT), ' ', Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
1622
- variant: "anchor",
1623
- onClick: function onClick() {
1624
- return _this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].ForgotPassword);
1625
- },
1626
- "data-test": "sign-in-forgot-password-link"
1627
- }, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].RESET_PASSWORD_TEXT))) : newField['hint'];
1628
- }
1629
-
1630
- newField['handleInputChange'] = function (event) {
1631
- return _this.handleFormFieldInputWithCallback(event, field);
1632
- };
1633
-
1634
- _this.setFieldValue(newField, _this.signInAttributes);
1635
-
1636
- newFields_3.push(newField);
1637
- });
1638
- this.newFormFields = newFields_3;
1639
- }
1640
- };
1641
-
1642
- class_5.prototype.setFieldValue = function (field, formAttributes) {
1643
- switch (field.type) {
1644
- case 'username':
1645
- case 'email':
1646
- if (field.value === undefined) {
1647
- formAttributes.userInput = '';
1648
- } else {
1649
- formAttributes.userInput = field.value;
1650
- }
1651
-
1652
- break;
1653
-
1654
- case 'phone_number':
1655
- if (field.dialCode) {
1656
- this.phoneNumber.countryDialCodeValue = field.dialCode;
1657
- }
1658
-
1659
- this.phoneNumber.phoneNumberValue = field.value;
1660
- break;
1661
-
1662
- case 'password':
1663
- if (field.value === undefined) {
1664
- formAttributes.password = '';
1665
- } else {
1666
- formAttributes.password = field.value;
1667
- }
1668
-
1669
- break;
1670
- }
1671
- };
1672
-
1673
- class_5.prototype.render = function () {
1674
- var _this = this;
1675
-
1676
- return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["H"], null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-form-section", {
1677
- headerText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.headerText),
1678
- handleSubmit: this.handleSubmit,
1679
- testDataPrefix: 'sign-in'
1680
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", {
1681
- slot: "subtitle"
1682
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("slot", {
1683
- name: "header-subtitle"
1684
- })), Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("slot", {
1685
- name: "federated-buttons"
1686
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-federated-buttons", {
1687
- handleAuthStateChange: this.handleAuthStateChange,
1688
- federated: this.federated
1689
- })), !Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["isEmpty"])(this.federated) && Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-strike", null, "or"), Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-auth-fields", {
1690
- formFields: this.newFormFields
1691
- }), Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", {
1692
- slot: "amplify-form-section-footer",
1693
- "class": "sign-in-form-footer"
1694
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("slot", {
1695
- name: "footer"
1696
- }, !this.hideSignUp && Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("slot", {
1697
- name: "secondary-footer-content"
1698
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("span", null, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].NO_ACCOUNT_TEXT), ' ', Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
1699
- variant: "anchor",
1700
- onClick: function onClick() {
1701
- return _this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignUp);
1702
- },
1703
- "data-test": "sign-in-create-account-link"
1704
- }, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CREATE_ACCOUNT_TEXT)))), Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", {
1705
- "class": this.hideSignUp ? 'full-width-footer-content' : ''
1706
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("slot", {
1707
- name: "primary-footer-content"
1708
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
1709
- type: "submit",
1710
- disabled: this.loading,
1711
- "data-test": "sign-in-sign-in-button"
1712
- }, this.loading ? Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-loading-spinner", null) : Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("span", null, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.submitButtonText)))))))));
1713
- };
1714
-
1715
- Object.defineProperty(class_5, "watchers", {
1716
- get: function get() {
1717
- return {
1718
- "formFields": ["formFieldsHandler"]
1719
- };
1720
- },
1721
- enumerable: false,
1722
- configurable: true
1723
- });
1724
- return class_5;
1725
- }();
1726
-
1727
- AmplifySignIn.style = amplifySignInCss;
1728
- var amplifySignUpCss = "amplify-sign-up{--footer-font-family:var(--amplify-font-family);--footer-font-size:var(--amplify-text-sm);--footer-color:var(--amplify-grey);--font-weight:var(--amplify-font-weight)}.sign-up-form-footer{font-family:var(--footer-font-family);font-size:var(--footer-font-size);color:var(--footer-color);font-weight:--font-weight;display:-ms-flexbox;display:flex;-ms-flex-direction:column-reverse;flex-direction:column-reverse;-ms-flex-align:center;align-items:center;-ms-flex-pack:distribute;justify-content:space-around}.sign-up-form-footer amplify-button{margin-bottom:0.625rem}@media (min-width: 672px){.sign-up-form-footer{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:baseline;align-items:baseline}.sign-up-form-footer amplify-button{margin-bottom:0}}.sign-up-form-footer *+*{margin-bottom:15px}";
1729
-
1730
- var AmplifySignUp =
1731
- /** @class */
1732
- function () {
1733
- function class_6(hostRef) {
1734
- var _this = this;
1735
-
1736
- Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
1737
- /** Fires when sign up form is submitted */
1738
-
1739
- this.handleSubmit = function (event) {
1740
- return _this.signUp(event);
1741
- };
1742
- /** Override for handling the Auth.SignUp API call */
1743
-
1744
-
1745
- this.handleSignUp = function (params) {
1746
- return _this.authSignUp(params);
1747
- };
1748
- /** Used for header text in sign up component */
1749
-
1750
-
1751
- this.headerText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_UP_HEADER_TEXT;
1752
- /** Used for the submit button text in sign up component */
1753
-
1754
- this.submitButtonText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_UP_SUBMIT_BUTTON_TEXT;
1755
- /** Used for the submit button text in sign up component */
1756
-
1757
- this.haveAccountText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_UP_HAVE_ACCOUNT_TEXT;
1758
- /** Text used for the sign in hyperlink */
1759
-
1760
- this.signInText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_IN_TEXT;
1761
- /**
1762
- * Form fields allows you to utilize our pre-built components such as username field, code field, password field, email field, etc.
1763
- * by passing an array of strings that you would like the order of the form to be in. If you need more customization, such as changing
1764
- * text for a label or adjust a placeholder, you can follow the structure below in order to do just that.
1765
- * ```
1766
- * [
1767
- * {
1768
- * type: string,
1769
- * label: string,
1770
- * placeholder: string,
1771
- * hint: string | Functional Component | null,
1772
- * required: boolean
1773
- * }
1774
- * ]
1775
- * ```
1776
- */
1777
-
1778
- this.formFields = [];
1779
- /** Auth state change handler for this component
1780
- * e.g. SignIn -> 'Create Account' link -> SignUp
1781
- */
1782
- // prettier-ignore
1783
-
1784
- this.handleAuthStateChange = _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["d"];
1785
- /** Username Alias is used to setup authentication with `username`, `email` or `phone_number` */
1786
-
1787
- this.usernameAlias = 'username'; // private userInput: string | PhoneNumberInterface;
1788
-
1789
- this.newFormFields = [];
1790
- this.phoneNumber = {
1791
- countryDialCodeValue: _constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["g"],
1792
- phoneNumberValue: null
1793
- };
1794
- this.loading = false;
1795
- this.signUpAttributes = {
1796
- username: '',
1797
- password: '',
1798
- attributes: {}
1799
- };
1800
- }
1801
-
1802
- class_6.prototype.handleFormFieldInputChange = function (fieldType) {
1803
- var _this = this;
1804
-
1805
- switch (fieldType) {
1806
- case 'username':
1807
- return function (event) {
1808
- return _this.signUpAttributes.username = event.target.value;
1809
- };
1810
-
1811
- case 'password':
1812
- return function (event) {
1813
- return _this.signUpAttributes.password = event.target.value;
1814
- };
1815
-
1816
- case 'email':
1817
- return function (event) {
1818
- return _this.signUpAttributes.attributes.email = event.target.value;
1819
- };
1820
-
1821
- case 'phone_number':
1822
- return function (event) {
1823
- return Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["h"])(event, _this.phoneNumber);
1824
- };
1825
-
1826
- default:
1827
- return function (event) {
1828
- return _this.signUpAttributes.attributes[fieldType] = event.target.value;
1829
- };
1830
- }
1831
- };
1832
-
1833
- class_6.prototype.handleFormFieldInputWithCallback = function (event, field) {
1834
- var fnToCall = field['handleInputChange'] ? field['handleInputChange'] : function (event, cb) {
1835
- cb(event);
1836
- };
1837
- var callback = this.handleFormFieldInputChange(field.type);
1838
- fnToCall(event, callback.bind(this));
1839
- };
1840
-
1841
- class_6.prototype.authSignUp = function (params) {
1842
- return __awaiter(this, void 0, void 0, function () {
1843
- var data;
1844
- return __generator(this, function (_a) {
1845
- switch (_a.label) {
1846
- case 0:
1847
- return [4
1848
- /*yield*/
1849
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].signUp(params)];
1850
-
1851
- case 1:
1852
- data = _a.sent();
1853
-
1854
- if (!data) {
1855
- throw new Error(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_UP_FAILED);
1856
- }
1857
-
1858
- return [2
1859
- /*return*/
1860
- , data];
1861
- }
1862
- });
1863
- });
1864
- };
1865
-
1866
- class_6.prototype.assignPhoneNumberToSignUpAttributes = function () {
1867
- if (this.phoneNumber.phoneNumberValue) {
1868
- try {
1869
- this.signUpAttributes.attributes.phone_number = Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["b"])(this.phoneNumber);
1870
- } catch (error) {
1871
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error);
1872
- }
1873
- }
1874
- };
1875
-
1876
- class_6.prototype.assignUserNameAliasToSignUpAttributes = function () {
1877
- switch (this.usernameAlias) {
1878
- case 'email':
1879
- case 'phone_number':
1880
- this.signUpAttributes.username = this.signUpAttributes.attributes[this.usernameAlias];
1881
- break;
1882
- }
1883
- };
1884
-
1885
- class_6.prototype.assignFormInputToSignUpAttributes = function () {
1886
- this.assignPhoneNumberToSignUpAttributes();
1887
- this.assignUserNameAliasToSignUpAttributes();
1888
- };
1889
-
1890
- class_6.prototype.validateSignUpAttributes = function () {
1891
- if (!this.signUpAttributes.username) {
1892
- if (this.usernameAlias === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["U"].email) {
1893
- throw new Error(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].EMPTY_EMAIL);
1894
- } else if (this.usernameAlias === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["U"].phone_number) {
1895
- throw new Error(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].EMPTY_PHONE);
1896
- } else {
1897
- throw new Error(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].EMPTY_USERNAME);
1898
- }
1899
- }
1900
-
1901
- if (this.signUpAttributes.username.indexOf(' ') >= 0) {
1902
- throw new Error(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].USERNAME_REMOVE_WHITESPACE);
1903
- }
1904
-
1905
- if (this.signUpAttributes.password !== this.signUpAttributes.password.trim()) {
1906
- throw new Error(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].PASSWORD_REMOVE_WHITESPACE);
1907
- }
1908
- }; // TODO: Add validation
1909
- // TODO: Prefix
1910
-
1911
-
1912
- class_6.prototype.signUp = function (event) {
1913
- return __awaiter(this, void 0, void 0, function () {
1914
- var data, signUpAttrs, error_8;
1915
- return __generator(this, function (_a) {
1916
- switch (_a.label) {
1917
- case 0:
1918
- if (event) {
1919
- event.preventDefault();
1920
- }
1921
-
1922
- if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].signUp !== 'function') {
1923
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
1924
- }
1925
-
1926
- this.loading = true;
1927
- this.assignFormInputToSignUpAttributes();
1928
- _a.label = 1;
1929
-
1930
- case 1:
1931
- _a.trys.push([1, 6, 7, 8]);
1932
-
1933
- this.validateSignUpAttributes();
1934
- return [4
1935
- /*yield*/
1936
- , this.handleSignUp(this.signUpAttributes)];
1937
-
1938
- case 2:
1939
- data = _a.sent();
1940
- if (!data.userConfirmed) return [3
1941
- /*break*/
1942
- , 4];
1943
- return [4
1944
- /*yield*/
1945
- , Object(_auth_helpers_557b83fc_js__WEBPACK_IMPORTED_MODULE_7__["h"])(this.signUpAttributes.username, this.signUpAttributes.password, this.handleAuthStateChange)];
1946
-
1947
- case 3:
1948
- _a.sent();
1949
-
1950
- return [3
1951
- /*break*/
1952
- , 5];
1953
-
1954
- case 4:
1955
- signUpAttrs = Object.assign({}, this.signUpAttributes);
1956
- this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].ConfirmSignUp, Object.assign(Object.assign({}, data.user), {
1957
- signUpAttrs: signUpAttrs
1958
- }));
1959
- _a.label = 5;
1960
-
1961
- case 5:
1962
- return [3
1963
- /*break*/
1964
- , 8];
1965
-
1966
- case 6:
1967
- error_8 = _a.sent();
1968
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error_8);
1969
- return [3
1970
- /*break*/
1971
- , 8];
1972
-
1973
- case 7:
1974
- this.loading = false;
1975
- return [7
1976
- /*endfinally*/
1977
- ];
1978
-
1979
- case 8:
1980
- return [2
1981
- /*return*/
1982
- ];
1983
- }
1984
- });
1985
- });
1986
- };
1987
-
1988
- class_6.prototype.buildDefaultFormFields = function () {
1989
- switch (this.usernameAlias) {
1990
- case 'email':
1991
- this.newFormFields = [{
1992
- type: 'email',
1993
- placeholder: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_UP_EMAIL_PLACEHOLDER),
1994
- required: true,
1995
- handleInputChange: this.handleFormFieldInputChange('email'),
1996
- inputProps: {
1997
- 'data-test': 'sign-up-email-input',
1998
- autocomplete: 'username'
1999
- }
2000
- }, {
2001
- type: 'password',
2002
- placeholder: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_UP_PASSWORD_PLACEHOLDER),
2003
- required: true,
2004
- handleInputChange: this.handleFormFieldInputChange('password'),
2005
- inputProps: {
2006
- 'data-test': 'sign-up-password-input',
2007
- autocomplete: 'new-password'
2008
- }
2009
- }, {
2010
- type: 'phone_number',
2011
- required: true,
2012
- handleInputChange: this.handleFormFieldInputChange('phone_number'),
2013
- inputProps: {
2014
- 'data-test': 'sign-up-phone-number-input',
2015
- autocomplete: 'tel-national'
2016
- }
2017
- }];
2018
- break;
2019
-
2020
- case 'phone_number':
2021
- this.newFormFields = [{
2022
- type: 'phone_number',
2023
- required: true,
2024
- handleInputChange: this.handleFormFieldInputChange('phone_number'),
2025
- inputProps: {
2026
- 'data-test': 'sign-up-phone-number-input',
2027
- autocomplete: 'username'
2028
- }
2029
- }, {
2030
- type: 'password',
2031
- placeholder: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_UP_PASSWORD_PLACEHOLDER),
2032
- required: true,
2033
- handleInputChange: this.handleFormFieldInputChange('password'),
2034
- inputProps: {
2035
- 'data-test': 'sign-up-password-input',
2036
- autocomplete: 'new-password'
2037
- }
2038
- }, {
2039
- type: 'email',
2040
- placeholder: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_UP_EMAIL_PLACEHOLDER),
2041
- required: true,
2042
- handleInputChange: this.handleFormFieldInputChange('email'),
2043
- inputProps: {
2044
- 'data-test': 'sign-up-email-input',
2045
- autocomplete: 'email'
2046
- }
2047
- }];
2048
- break;
2049
-
2050
- case 'username':
2051
- default:
2052
- this.newFormFields = [{
2053
- type: 'username',
2054
- placeholder: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_UP_USERNAME_PLACEHOLDER),
2055
- required: true,
2056
- handleInputChange: this.handleFormFieldInputChange('username'),
2057
- inputProps: {
2058
- 'data-test': 'sign-up-username-input',
2059
- autocomplete: 'username'
2060
- }
2061
- }, {
2062
- type: 'password',
2063
- placeholder: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_UP_PASSWORD_PLACEHOLDER),
2064
- required: true,
2065
- handleInputChange: this.handleFormFieldInputChange('password'),
2066
- inputProps: {
2067
- 'data-test': 'sign-up-password-input',
2068
- autocomplete: 'new-password'
2069
- }
2070
- }, {
2071
- type: 'email',
2072
- placeholder: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_UP_EMAIL_PLACEHOLDER),
2073
- required: true,
2074
- handleInputChange: this.handleFormFieldInputChange('email'),
2075
- inputProps: {
2076
- 'data-test': 'sign-up-email-input'
2077
- }
2078
- }, {
2079
- type: 'phone_number',
2080
- required: true,
2081
- handleInputChange: this.handleFormFieldInputChange('phone_number'),
2082
- inputProps: {
2083
- 'data-test': 'sign-up-phone-number-input'
2084
- }
2085
- }];
2086
- break;
2087
- }
2088
- };
2089
-
2090
- class_6.prototype.buildFormFields = function () {
2091
- var _this = this;
2092
-
2093
- if (this.formFields.length === 0) {
2094
- this.buildDefaultFormFields();
2095
- } else {
2096
- var newFields_4 = [];
2097
- this.formFields.forEach(function (field) {
2098
- var newField = Object.assign({}, field);
2099
-
2100
- newField['handleInputChange'] = function (event) {
2101
- return _this.handleFormFieldInputWithCallback(event, field);
2102
- };
2103
-
2104
- _this.setFieldValue(field, _this.signUpAttributes);
2105
-
2106
- newFields_4.push(newField);
2107
- });
2108
- this.newFormFields = newFields_4;
2109
- }
2110
- };
2111
-
2112
- class_6.prototype.setFieldValue = function (field, formAttributes) {
2113
- switch (field.type) {
2114
- case 'username':
2115
- if (field.value === undefined) {
2116
- formAttributes.username = '';
2117
- } else {
2118
- formAttributes.username = field.value;
2119
- }
2120
-
2121
- break;
2122
-
2123
- case 'password':
2124
- if (field.value === undefined) {
2125
- formAttributes.password = '';
2126
- } else {
2127
- formAttributes.password = field.value;
2128
- }
2129
-
2130
- break;
2131
-
2132
- case 'email':
2133
- formAttributes.attributes.email = field.value;
2134
- break;
2135
-
2136
- case 'phone_number':
2137
- if (field.dialCode) {
2138
- this.phoneNumber.countryDialCodeValue = field.dialCode;
2139
- }
2140
-
2141
- this.phoneNumber.phoneNumberValue = field.value;
2142
- break;
2143
-
2144
- default:
2145
- formAttributes.attributes[field.type] = field.value;
2146
- break;
2147
- }
2148
- };
2149
-
2150
- class_6.prototype.componentWillLoad = function () {
2151
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["c"])(this.usernameAlias);
2152
- this.buildFormFields();
2153
- };
2154
-
2155
- class_6.prototype.formFieldsHandler = function () {
2156
- this.buildFormFields();
2157
- };
2158
-
2159
- class_6.prototype.render = function () {
2160
- var _this = this;
2161
-
2162
- return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["H"], null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-form-section", {
2163
- headerText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.headerText),
2164
- handleSubmit: this.handleSubmit,
2165
- testDataPrefix: 'sign-up'
2166
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", {
2167
- slot: "subtitle"
2168
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("slot", {
2169
- name: "header-subtitle"
2170
- })), Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-auth-fields", {
2171
- formFields: this.newFormFields
2172
- }), Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", {
2173
- "class": "sign-up-form-footer",
2174
- slot: "amplify-form-section-footer"
2175
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("slot", {
2176
- name: "footer"
2177
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("slot", {
2178
- name: "secondary-footer-content"
2179
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("span", null, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.haveAccountText), ' ', Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
2180
- variant: "anchor",
2181
- onClick: function onClick() {
2182
- return _this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignIn);
2183
- },
2184
- "data-test": "sign-up-sign-in-link"
2185
- }, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.signInText)))), Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("slot", {
2186
- name: "primary-footer-content"
2187
- }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
2188
- type: "submit",
2189
- "data-test": "sign-up-create-account-button",
2190
- disabled: this.loading
2191
- }, this.loading ? Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-loading-spinner", null) : Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("span", null, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.submitButtonText))))))));
2192
- };
2193
-
2194
- Object.defineProperty(class_6, "watchers", {
2195
- get: function get() {
2196
- return {
2197
- "formFields": ["formFieldsHandler"]
2198
- };
2199
- },
2200
- enumerable: false,
2201
- configurable: true
2202
- });
2203
- return class_6;
2204
- }();
2205
-
2206
- AmplifySignUp.style = amplifySignUpCss;
2207
- var logger$2 = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Logger"]('AmplifyVerifyContact');
2208
-
2209
- var AmplifyVerifyContact =
2210
- /** @class */
2211
- function () {
2212
- function class_7(hostRef) {
2213
- Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
2214
- /** Authentication state handler */
2215
-
2216
- this.handleAuthStateChange = _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["d"];
2217
- this.loading = false;
2218
- }
2219
-
2220
- class_7.prototype.handleSubmit = function (event) {
2221
- event.preventDefault();
2222
- this.verifyAttr ? this.submit(this.code) : this.verify(this.contact);
2223
- };
2224
-
2225
- class_7.prototype.submit = function (code) {
2226
- return __awaiter(this, void 0, void 0, function () {
2227
- var attr, data, error_9;
2228
- return __generator(this, function (_a) {
2229
- switch (_a.label) {
2230
- case 0:
2231
- attr = this.verifyAttr;
2232
-
2233
- if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].verifyCurrentUserAttributeSubmit !== 'function') {
2234
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
2235
- }
2236
-
2237
- this.loading = true;
2238
- _a.label = 1;
2239
-
2240
- case 1:
2241
- _a.trys.push([1, 3, 4, 5]);
2242
-
2243
- return [4
2244
- /*yield*/
2245
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].verifyCurrentUserAttributeSubmit(attr, code)];
2246
-
2247
- case 2:
2248
- data = _a.sent();
2249
- logger$2.debug(data);
2250
- this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignedIn, this.user);
2251
- this.verifyAttr = null;
2252
- return [3
2253
- /*break*/
2254
- , 5];
2255
-
2256
- case 3:
2257
- error_9 = _a.sent();
2258
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error_9);
2259
- logger$2.error(error_9);
2260
- return [3
2261
- /*break*/
2262
- , 5];
2263
-
2264
- case 4:
2265
- this.loading = false;
2266
- return [7
2267
- /*endfinally*/
2268
- ];
2269
-
2270
- case 5:
2271
- return [2
2272
- /*return*/
2273
- ];
2274
- }
2275
- });
2276
- });
2277
- };
2278
-
2279
- class_7.prototype.verify = function (contact) {
2280
- return __awaiter(this, void 0, void 0, function () {
2281
- var data, error_10;
2282
- return __generator(this, function (_a) {
2283
- switch (_a.label) {
2284
- case 0:
2285
- if (!contact) {
2286
- logger$2.error('Neither Email nor Phone Number selected');
2287
- return [2
2288
- /*return*/
2289
- ];
2290
- }
2291
-
2292
- if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].verifyCurrentUserAttribute !== 'function') {
2293
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
2294
- }
2295
-
2296
- this.loading = true;
2297
- _a.label = 1;
2298
-
2299
- case 1:
2300
- _a.trys.push([1, 3, 4, 5]);
2301
-
2302
- return [4
2303
- /*yield*/
2304
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].verifyCurrentUserAttribute(contact)];
2305
-
2306
- case 2:
2307
- data = _a.sent();
2308
- logger$2.debug(data);
2309
- this.verifyAttr = contact;
2310
- return [3
2311
- /*break*/
2312
- , 5];
2313
-
2314
- case 3:
2315
- error_10 = _a.sent();
2316
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error_10);
2317
- logger$2.error(error_10);
2318
- return [3
2319
- /*break*/
2320
- , 5];
2321
-
2322
- case 4:
2323
- this.loading = false;
2324
- return [7
2325
- /*endfinally*/
2326
- ];
2327
-
2328
- case 5:
2329
- return [2
2330
- /*return*/
2331
- ];
2332
- }
2333
- });
2334
- });
2335
- };
2336
-
2337
- class_7.prototype.handleInputChange = function (event) {
2338
- var inputName = event.target.name;
2339
-
2340
- if (inputName === 'code') {
2341
- this.code = event.target.value;
2342
- } else if (inputName === 'contact') {
2343
- this.contact = event.target.value;
2344
- }
2345
- };
2346
-
2347
- class_7.prototype.renderSubmit = function () {
2348
- var _this = this;
2349
-
2350
- return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-input", {
2351
- inputProps: {
2352
- autocomplete: 'off',
2353
- 'data-test': 'verify-contact-code-input'
2354
- },
2355
- name: "code",
2356
- placeholder: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].CODE_PLACEHOLDER),
2357
- handleInputChange: function handleInputChange(event) {
2358
- return _this.handleInputChange(event);
2359
- }
2360
- }));
2361
- };
2362
-
2363
- class_7.prototype.renderVerify = function () {
2364
- var _this = this;
2365
-
2366
- var user = this.user;
2367
-
2368
- if (!user) {
2369
- logger$2.debug('No user to verify');
2370
- return null;
2371
- }
2372
-
2373
- var unverified = user.unverified;
2374
-
2375
- if (!unverified) {
2376
- logger$2.debug('Unverified variable does not exist on user');
2377
- return null;
2378
- }
2379
-
2380
- var email = unverified.email,
2381
- phone_number = unverified.phone_number;
2382
- return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", null, email && Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-radio-button", {
2383
- label: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].VERIFY_CONTACT_EMAIL_LABEL),
2384
- key: "email",
2385
- name: "contact",
2386
- value: "email",
2387
- handleInputChange: function handleInputChange(event) {
2388
- return _this.handleInputChange(event);
2389
- },
2390
- inputProps: {
2391
- 'data-test': 'verify-contact-email-radio'
2392
- }
2393
- }), phone_number && Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-radio-button", {
2394
- label: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].VERIFY_CONTACT_PHONE_LABEL),
2395
- key: "phone_number",
2396
- name: "contact",
2397
- value: "phone_number",
2398
- handleInputChange: function handleInputChange(event) {
2399
- return _this.handleInputChange(event);
2400
- },
2401
- inputProps: {
2402
- 'data-test': 'verify-contact-phone-number-radio'
2403
- }
2404
- }));
2405
- };
2406
-
2407
- class_7.prototype.render = function () {
2408
- var _this = this;
2409
-
2410
- return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["H"], null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-form-section", {
2411
- handleSubmit: function handleSubmit(event) {
2412
- return _this.handleSubmit(event);
2413
- },
2414
- headerText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].VERIFY_CONTACT_HEADER_TEXT),
2415
- loading: this.loading,
2416
- secondaryFooterContent: Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("span", null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-button", {
2417
- variant: "anchor",
2418
- onClick: function onClick() {
2419
- return _this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignedIn, _this.user);
2420
- },
2421
- "data-test": "verify-contact-skip-link"
2422
- }, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SKIP))),
2423
- submitButtonText: this.verifyAttr ? _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].VERIFY_CONTACT_SUBMIT_LABEL) : _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].VERIFY_CONTACT_VERIFY_LABEL)
2424
- }, this.verifyAttr ? this.renderSubmit() : this.renderVerify()));
2425
- };
2426
-
2427
- return class_7;
2428
- }();
2429
-
2430
-
2431
-
2432
- /***/ }),
2433
-
2434
- /***/ "../amplify-ui-components/dist/esm-es5/auth-helpers-557b83fc.js":
2435
- /*!**********************************************************************!*\
2436
- !*** ../amplify-ui-components/dist/esm-es5/auth-helpers-557b83fc.js ***!
2437
- \**********************************************************************/
2438
- /*! exports provided: c, h */
2439
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
2440
-
2441
- "use strict";
2442
- __webpack_require__.r(__webpack_exports__);
2443
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return checkContact; });
2444
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return handleSignIn; });
2445
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
2446
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__);
2447
- /* harmony import */ var _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./auth-types-78df304e.js */ "../amplify-ui-components/dist/esm-es5/auth-types-78df304e.js");
2448
- /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
2449
- /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__);
2450
- /* harmony import */ var _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Translations-108d469f.js */ "../amplify-ui-components/dist/esm-es5/Translations-108d469f.js");
2451
- /* harmony import */ var _constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./constants-c8ecaa24.js */ "../amplify-ui-components/dist/esm-es5/constants-c8ecaa24.js");
2452
- /* harmony import */ var _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./helpers-14fcb50c.js */ "../amplify-ui-components/dist/esm-es5/helpers-14fcb50c.js");
2453
- var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
2454
- function adopt(value) {
2455
- return value instanceof P ? value : new P(function (resolve) {
2456
- resolve(value);
2457
- });
2458
- }
2459
-
2460
- return new (P || (P = Promise))(function (resolve, reject) {
2461
- function fulfilled(value) {
2462
- try {
2463
- step(generator.next(value));
2464
- } catch (e) {
2465
- reject(e);
2466
- }
2467
- }
2468
-
2469
- function rejected(value) {
2470
- try {
2471
- step(generator["throw"](value));
2472
- } catch (e) {
2473
- reject(e);
2474
- }
2475
- }
2476
-
2477
- function step(result) {
2478
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
2479
- }
2480
-
2481
- step((generator = generator.apply(thisArg, _arguments || [])).next());
2482
- });
2483
- };
2484
-
2485
- var __generator = undefined && undefined.__generator || function (thisArg, body) {
2486
- var _ = {
2487
- label: 0,
2488
- sent: function sent() {
2489
- if (t[0] & 1) throw t[1];
2490
- return t[1];
2491
- },
2492
- trys: [],
2493
- ops: []
2494
- },
2495
- f,
2496
- y,
2497
- t,
2498
- g;
2499
- return g = {
2500
- next: verb(0),
2501
- "throw": verb(1),
2502
- "return": verb(2)
2503
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
2504
- return this;
2505
- }), g;
2506
-
2507
- function verb(n) {
2508
- return function (v) {
2509
- return step([n, v]);
2510
- };
2511
- }
2512
-
2513
- function step(op) {
2514
- if (f) throw new TypeError("Generator is already executing.");
2515
-
2516
- while (_) {
2517
- try {
2518
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
2519
- if (y = 0, t) op = [op[0] & 2, t.value];
2520
-
2521
- switch (op[0]) {
2522
- case 0:
2523
- case 1:
2524
- t = op;
2525
- break;
2526
-
2527
- case 4:
2528
- _.label++;
2529
- return {
2530
- value: op[1],
2531
- done: false
2532
- };
2533
-
2534
- case 5:
2535
- _.label++;
2536
- y = op[1];
2537
- op = [0];
2538
- continue;
2539
-
2540
- case 7:
2541
- op = _.ops.pop();
2542
-
2543
- _.trys.pop();
2544
-
2545
- continue;
2546
-
2547
- default:
2548
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
2549
- _ = 0;
2550
- continue;
2551
- }
2552
-
2553
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
2554
- _.label = op[1];
2555
- break;
2556
- }
2557
-
2558
- if (op[0] === 6 && _.label < t[1]) {
2559
- _.label = t[1];
2560
- t = op;
2561
- break;
2562
- }
2563
-
2564
- if (t && _.label < t[2]) {
2565
- _.label = t[2];
2566
-
2567
- _.ops.push(op);
2568
-
2569
- break;
2570
- }
2571
-
2572
- if (t[2]) _.ops.pop();
2573
-
2574
- _.trys.pop();
2575
-
2576
- continue;
2577
- }
2578
-
2579
- op = body.call(thisArg, _);
2580
- } catch (e) {
2581
- op = [6, e];
2582
- y = 0;
2583
- } finally {
2584
- f = t = 0;
2585
- }
2586
- }
2587
-
2588
- if (op[0] & 5) throw op[1];
2589
- return {
2590
- value: op[0] ? op[1] : void 0,
2591
- done: true
2592
- };
2593
- }
2594
- };
2595
-
2596
-
2597
-
2598
-
2599
-
2600
-
2601
-
2602
- var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Logger"]('auth-helpers');
2603
-
2604
- function checkContact(user, handleAuthStateChange) {
2605
- return __awaiter(this, void 0, void 0, function () {
2606
- var data, newUser, error_1;
2607
- return __generator(this, function (_a) {
2608
- switch (_a.label) {
2609
- case 0:
2610
- if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"].verifiedContact !== 'function') {
2611
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_4__["N"]);
2612
- } // If `user` is a federated user, we shouldn't call `verifiedContact`
2613
- // since `user` isn't `CognitoUser`
2614
-
2615
-
2616
- if (!isCognitoUser(user)) {
2617
- handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].SignedIn, user);
2618
- return [2
2619
- /*return*/
2620
- ];
2621
- }
2622
-
2623
- _a.label = 1;
2624
-
2625
- case 1:
2626
- _a.trys.push([1, 3,, 4]);
2627
-
2628
- return [4
2629
- /*yield*/
2630
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"].verifiedContact(user)];
2631
-
2632
- case 2:
2633
- data = _a.sent();
2634
-
2635
- if (!Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["isEmpty"])(data.verified) || Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["isEmpty"])(data.unverified)) {
2636
- handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].SignedIn, user);
2637
- } else {
2638
- newUser = Object.assign(user, data);
2639
- handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].VerifyContact, newUser);
2640
- }
2641
-
2642
- return [3
2643
- /*break*/
2644
- , 4];
2645
-
2646
- case 3:
2647
- error_1 = _a.sent();
2648
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_5__["a"])(error_1);
2649
- return [3
2650
- /*break*/
2651
- , 4];
2652
-
2653
- case 4:
2654
- return [2
2655
- /*return*/
2656
- ];
2657
- }
2658
- });
2659
- });
2660
- }
2661
-
2662
- var handleSignIn = function handleSignIn(username, password, handleAuthStateChange, usernameAlias) {
2663
- return __awaiter(void 0, void 0, void 0, function () {
2664
- var user, error_2;
2665
- return __generator(this, function (_a) {
2666
- switch (_a.label) {
2667
- case 0:
2668
- if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"].signIn !== 'function') {
2669
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_4__["N"]);
2670
- }
2671
-
2672
- _a.label = 1;
2673
-
2674
- case 1:
2675
- _a.trys.push([1, 9,, 10]);
2676
-
2677
- return [4
2678
- /*yield*/
2679
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"].signIn(username, password)];
2680
-
2681
- case 2:
2682
- user = _a.sent();
2683
- logger.debug(user);
2684
- if (!(user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].SMSMFA || user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].SoftwareTokenMFA)) return [3
2685
- /*break*/
2686
- , 3];
2687
- logger.debug('confirm user with ' + user.challengeName);
2688
- handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].ConfirmSignIn, user);
2689
- return [3
2690
- /*break*/
2691
- , 8];
2692
-
2693
- case 3:
2694
- if (!(user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].NewPasswordRequired)) return [3
2695
- /*break*/
2696
- , 4];
2697
- logger.debug('require new password', user.challengeParam);
2698
- handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].ResetPassword, user);
2699
- return [3
2700
- /*break*/
2701
- , 8];
2702
-
2703
- case 4:
2704
- if (!(user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].MFASetup)) return [3
2705
- /*break*/
2706
- , 5];
2707
- logger.debug('TOTP setup', user.challengeParam);
2708
- handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].TOTPSetup, user);
2709
- return [3
2710
- /*break*/
2711
- , 8];
2712
-
2713
- case 5:
2714
- if (!(user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].CustomChallenge && user.challengeParam && user.challengeParam.trigger === 'true')) return [3
2715
- /*break*/
2716
- , 6];
2717
- logger.debug('custom challenge', user.challengeParam);
2718
- handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].CustomConfirmSignIn, user);
2719
- return [3
2720
- /*break*/
2721
- , 8];
2722
-
2723
- case 6:
2724
- return [4
2725
- /*yield*/
2726
- , checkContact(user, handleAuthStateChange)];
2727
-
2728
- case 7:
2729
- _a.sent();
2730
-
2731
- _a.label = 8;
2732
-
2733
- case 8:
2734
- return [3
2735
- /*break*/
2736
- , 10];
2737
-
2738
- case 9:
2739
- error_2 = _a.sent();
2740
-
2741
- if (error_2.code === 'UserNotConfirmedException') {
2742
- logger.debug('the user is not confirmed');
2743
- handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].ConfirmSignUp, {
2744
- username: username
2745
- });
2746
- } else if (error_2.code === 'PasswordResetRequiredException') {
2747
- logger.debug('the user requires a new password');
2748
- handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].ForgotPassword, {
2749
- username: username
2750
- });
2751
- } else if (error_2.code === 'InvalidParameterException' && password === '') {
2752
- logger.debug('Password cannot be empty');
2753
- error_2.message = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_3__["T"].EMPTY_PASSWORD;
2754
- } else if (error_2.message === _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_3__["T"].EMPTY_USERNAME) {
2755
- if (usernameAlias === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["U"].email) {
2756
- error_2.message = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_3__["T"].EMPTY_EMAIL;
2757
- }
2758
-
2759
- if (usernameAlias === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["U"].phone_number) {
2760
- error_2.message = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_3__["T"].EMPTY_PHONE;
2761
- }
2762
- }
2763
-
2764
- Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_5__["a"])(error_2);
2765
- return [3
2766
- /*break*/
2767
- , 10];
2768
-
2769
- case 10:
2770
- return [2
2771
- /*return*/
2772
- ];
2773
- }
2774
- });
2775
- });
2776
- };
2777
-
2778
- var isCognitoUser = function isCognitoUser(user) {
2779
- return user instanceof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["CognitoUser"];
2780
- };
2781
-
2782
-
2783
-
2784
- /***/ })
2785
-
2786
- }]);
2787
- //# sourceMappingURL=3.js.map