@aws-amplify/ui-react 1.2.26 → 1.2.54-legacy-ui.10

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 (77) hide show
  1. package/CHANGELOG.md +224 -0
  2. package/dist/0.js.map +1 -1
  3. package/dist/1.js +656 -2000
  4. package/dist/1.js.map +1 -1
  5. package/dist/10.js +23 -681
  6. package/dist/10.js.map +1 -1
  7. package/dist/11.js +1157 -20
  8. package/dist/11.js.map +1 -1
  9. package/dist/12.js +61 -1087
  10. package/dist/12.js.map +1 -1
  11. package/dist/13.js +1146 -64
  12. package/dist/13.js.map +1 -1
  13. package/dist/14.js +34 -1163
  14. package/dist/14.js.map +1 -1
  15. package/dist/15.js +17 -37
  16. package/dist/15.js.map +1 -1
  17. package/dist/16.js +109 -13
  18. package/dist/16.js.map +1 -1
  19. package/dist/17.js +32 -67
  20. package/dist/17.js.map +1 -1
  21. package/dist/18.js +236 -46
  22. package/dist/18.js.map +1 -1
  23. package/dist/19.js +35 -224
  24. package/dist/19.js.map +1 -1
  25. package/dist/2.js +2190 -159
  26. package/dist/2.js.map +1 -1
  27. package/dist/20.js +28 -48
  28. package/dist/20.js.map +1 -1
  29. package/dist/21.js +46 -25
  30. package/dist/21.js.map +1 -1
  31. package/dist/22.js +22 -25
  32. package/dist/22.js.map +1 -1
  33. package/dist/23.js +254 -25
  34. package/dist/23.js.map +1 -1
  35. package/dist/24.js +62 -230
  36. package/dist/24.js.map +1 -1
  37. package/dist/25.js +28 -62
  38. package/dist/25.js.map +1 -1
  39. package/dist/26.js +349 -30
  40. package/dist/26.js.map +1 -1
  41. package/dist/27.js +24 -352
  42. package/dist/27.js.map +1 -1
  43. package/dist/28.js +25 -22
  44. package/dist/28.js.map +1 -1
  45. package/dist/29.js +483 -26
  46. package/dist/29.js.map +1 -1
  47. package/dist/3.js +2710 -1818
  48. package/dist/3.js.map +1 -1
  49. package/dist/30.js +1 -502
  50. package/dist/30.js.map +1 -1
  51. package/dist/31.js +1 -1
  52. package/dist/31.js.map +1 -1
  53. package/dist/32.js +12 -1
  54. package/dist/32.js.map +1 -1
  55. package/dist/4.js +361 -3669
  56. package/dist/4.js.map +1 -1
  57. package/dist/5.js +48 -242
  58. package/dist/5.js.map +1 -1
  59. package/dist/6.js +118 -74
  60. package/dist/6.js.map +1 -1
  61. package/dist/7.js +55 -99
  62. package/dist/7.js.map +1 -1
  63. package/dist/8.js +98 -46
  64. package/dist/8.js.map +1 -1
  65. package/dist/9.js +474 -412
  66. package/dist/9.js.map +1 -1
  67. package/dist/@aws-amplify/ui-react.js +50 -44
  68. package/dist/@aws-amplify/ui-react.js.map +1 -1
  69. package/dist/aws-amplify-react.min.js +2 -2
  70. package/dist/aws-amplify-react.min.js.map +1 -1
  71. package/dist/polyfills-core-js.js +5 -11
  72. package/dist/polyfills-core-js.js.map +1 -1
  73. package/dist/polyfills-css-shim.js.map +1 -1
  74. package/dist/polyfills-dom.js.map +1 -1
  75. package/package.json +3 -3
  76. package/dist/33.js +0 -13
  77. package/dist/33.js.map +0 -1
package/dist/9.js CHANGED
@@ -1,26 +1,28 @@
1
1
  (this["webpackJsonpaws_amplify_react"] = this["webpackJsonpaws_amplify_react"] || []).push([[9],{
2
2
 
3
- /***/ "../amplify-ui-components/dist/esm-es5/amplify-s3-text.entry.js":
4
- /*!**********************************************************************!*\
5
- !*** ../amplify-ui-components/dist/esm-es5/amplify-s3-text.entry.js ***!
6
- \**********************************************************************/
7
- /*! exports provided: amplify_s3_text */
3
+ /***/ "../amplify-ui-components/dist/esm-es5/amplify-amazon-button_5.entry.js":
4
+ /*!******************************************************************************!*\
5
+ !*** ../amplify-ui-components/dist/esm-es5/amplify-amazon-button_5.entry.js ***!
6
+ \******************************************************************************/
7
+ /*! exports provided: amplify_amazon_button, amplify_auth0_button, amplify_facebook_button, amplify_google_button, amplify_oauth_button */
8
8
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
9
9
 
10
10
  "use strict";
11
11
  __webpack_require__.r(__webpack_exports__);
12
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_s3_text", function() { return AmplifyS3Text; });
12
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_amazon_button", function() { return AmplifyAmazonButton; });
13
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_auth0_button", function() { return AmplifyAuth0Button; });
14
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_facebook_button", function() { return AmplifyFacebookButton; });
15
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_google_button", function() { return AmplifyGoogleButton; });
16
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "amplify_oauth_button", function() { return AmplifyOAuthButton; });
13
17
  /* harmony import */ var _index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./index-83f2275b.js */ "../amplify-ui-components/dist/esm-es5/index-83f2275b.js");
14
18
  /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
15
19
  /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__);
16
- /* harmony import */ var _storage_types_f257c0f2_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./storage-types-f257c0f2.js */ "../amplify-ui-components/dist/esm-es5/storage-types-f257c0f2.js");
20
+ /* 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");
17
21
  /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
18
22
  /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__);
19
23
  /* harmony import */ var _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Translations-108d469f.js */ "../amplify-ui-components/dist/esm-es5/Translations-108d469f.js");
20
24
  /* harmony import */ var _constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants-c8ecaa24.js */ "../amplify-ui-components/dist/esm-es5/constants-c8ecaa24.js");
21
- /* harmony import */ var _aws_amplify_storage__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @aws-amplify/storage */ "@aws-amplify/storage");
22
- /* harmony import */ var _aws_amplify_storage__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_storage__WEBPACK_IMPORTED_MODULE_6__);
23
- /* harmony import */ var _storage_helpers_1afafead_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./storage-helpers-1afafead.js */ "../amplify-ui-components/dist/esm-es5/storage-helpers-1afafead.js");
25
+ /* harmony import */ var _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./helpers-14fcb50c.js */ "../amplify-ui-components/dist/esm-es5/helpers-14fcb50c.js");
24
26
  var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
25
27
  function adopt(value) {
26
28
  return value instanceof P ? value : new P(function (resolve) {
@@ -171,491 +173,551 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
171
173
 
172
174
 
173
175
 
176
+ var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('amplify-amazon-button');
174
177
 
175
- var amplifyS3TextCss = ":host{--container-color:var(--amplify-smoke-white);--border-color:var(--amplify-light-grey);--font-size:var(--amplify-text-md);--text-color:var(--amplify-secondary-color)}.text-container{background-color:var(--container-color);border:1px solid var(--border-color);border-radius:5px;margin-bottom:10px}pre{display:block;margin:0.5rem 0;padding:0.5rem;line-height:1rem;max-height:50rem;font-size:var(--font-size);color:var(--text-color);word-break:break-all;overflow-y:scroll;overflow-x:auto}";
176
- var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Logger"]('S3Text');
177
-
178
- var AmplifyS3Text =
178
+ var AmplifyAmazonButton =
179
179
  /** @class */
180
180
  function () {
181
181
  function class_1(hostRef) {
182
- Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
183
- /** The content type header used when uploading to S3 */
182
+ var _this = this;
184
183
 
185
- this.contentType = 'text/*';
186
- /** The access level of the text file */
184
+ Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
185
+ /** Auth state change handler for this component
186
+ * e.g. SignIn -> 'Create Account' link -> SignUp
187
+ */
187
188
 
188
- this.level = _storage_types_f257c0f2_js__WEBPACK_IMPORTED_MODULE_2__["A"].Public;
189
- /** Fallback content */
189
+ this.handleAuthStateChange = _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["d"];
190
190
 
191
- this.fallbackText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].TEXT_FALLBACK_CONTENT;
192
- }
191
+ this.federatedSignIn = function (response) {
192
+ var access_token = response.access_token,
193
+ expires_in = response.expires_in;
193
194
 
194
- class_1.prototype.watchHandler = function () {
195
- return __awaiter(this, void 0, void 0, function () {
196
- return __generator(this, function (_a) {
197
- switch (_a.label) {
198
- case 0:
199
- return [4
200
- /*yield*/
201
- , this.load()];
195
+ if (!access_token) {
196
+ return;
197
+ }
202
198
 
203
- case 1:
204
- _a.sent();
199
+ if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].federatedSignIn !== 'function' || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].currentAuthenticatedUser !== 'function') {
200
+ throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
201
+ }
205
202
 
206
- return [2
207
- /*return*/
208
- ];
209
- }
203
+ var date = new Date();
204
+ var expires_at = expires_in * 1000 + date.getTime();
205
+ window['amazon'].Login.retrieveProfile(function (userInfo) {
206
+ return __awaiter(_this, void 0, void 0, function () {
207
+ var user, authenticatedUser;
208
+ return __generator(this, function (_a) {
209
+ switch (_a.label) {
210
+ case 0:
211
+ if (!userInfo.success) {
212
+ return [2
213
+ /*return*/
214
+ , logger.debug('Get user Info failed')];
215
+ }
216
+
217
+ user = {
218
+ name: userInfo.profile.Name,
219
+ email: userInfo.profile.PrimaryEmail
220
+ };
221
+ return [4
222
+ /*yield*/
223
+ , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].federatedSignIn('amazon', {
224
+ token: access_token,
225
+ expires_at: expires_at
226
+ }, user)];
227
+
228
+ case 1:
229
+ _a.sent();
230
+
231
+ return [4
232
+ /*yield*/
233
+ , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].currentAuthenticatedUser()];
234
+
235
+ case 2:
236
+ authenticatedUser = _a.sent();
237
+ this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignedIn, authenticatedUser);
238
+ return [2
239
+ /*return*/
240
+ ];
241
+ }
242
+ });
243
+ });
210
244
  });
211
- });
212
- };
245
+ };
246
+ }
213
247
 
214
248
  class_1.prototype.componentWillLoad = function () {
215
- return __awaiter(this, void 0, void 0, function () {
216
- return __generator(this, function (_a) {
217
- switch (_a.label) {
218
- case 0:
219
- return [4
220
- /*yield*/
221
- , this.load()];
222
-
223
- case 1:
224
- _a.sent();
225
-
226
- return [2
227
- /*return*/
228
- ];
229
- }
230
- });
231
- });
249
+ console.warn('Version `1.x` of Amplify UI has been deprecated and will be removed in a future major version of `aws-amplify`. Please visit https://ui.docs.amplify.aws/ for the current version of Amplify UI.');
232
250
  };
251
+ /**
252
+ * @see https://developer.amazon.com/docs/login-with-amazon/install-sdk-javascript.html
253
+ */
233
254
 
234
- class_1.prototype.load = function () {
235
- return __awaiter(this, void 0, void 0, function () {
236
- var _a, path, textKey, body, contentType, level, track, identityId, key, _b, err_1;
237
-
238
- return __generator(this, function (_c) {
239
- switch (_c.label) {
240
- case 0:
241
- _a = this, path = _a.path, textKey = _a.textKey, body = _a.body, contentType = _a.contentType, level = _a.level, track = _a.track, identityId = _a.identityId;
242
-
243
- if (!textKey && !path) {
244
- logger.debug('empty textKey and path');
245
- return [2
246
- /*return*/
247
- ];
248
- }
249
-
250
- key = textKey || path;
251
- logger.debug('loading ' + key + '...');
252
- if (!body) return [3
253
- /*break*/
254
- , 2];
255
- return [4
256
- /*yield*/
257
- , Object(_storage_helpers_1afafead_js__WEBPACK_IMPORTED_MODULE_7__["p"])(textKey, body, level, track, contentType, logger)];
258
-
259
- case 1:
260
- _c.sent();
261
255
 
262
- _c.label = 2;
256
+ class_1.prototype.signInWithAmazon = function (event) {
257
+ var _this = this;
263
258
 
264
- case 2:
265
- _c.trys.push([2, 4,, 5]);
266
-
267
- _b = this;
268
- return [4
269
- /*yield*/
270
- , Object(_storage_helpers_1afafead_js__WEBPACK_IMPORTED_MODULE_7__["a"])(key, level, track, identityId, logger)];
271
-
272
- case 3:
273
- _b.src = _c.sent();
274
- return [3
275
- /*break*/
276
- , 5];
259
+ event.preventDefault();
260
+ window['amazon'].Login.setClientId(this.clientId);
261
+ window['amazon'].Login.authorize({
262
+ scope: 'profile'
263
+ }, function (response) {
264
+ if (response.error) {
265
+ return logger.debug('Failed to login with amazon: ' + response.error);
266
+ }
277
267
 
278
- case 4:
279
- err_1 = _c.sent();
280
- logger.debug(err_1);
281
- throw new Error(err_1);
268
+ try {
269
+ window.localStorage.setItem(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["h"], JSON.stringify({
270
+ provider: 'amazon'
271
+ }));
272
+ } catch (e) {
273
+ logger.debug('Failed to cache auth source into localStorage', e);
274
+ }
282
275
 
283
- case 5:
284
- return [2
285
- /*return*/
286
- ];
287
- }
288
- });
276
+ _this.federatedSignIn(response);
289
277
  });
290
278
  };
291
279
 
292
280
  class_1.prototype.render = function () {
293
- return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", {
294
- "class": "text-container"
295
- }, this.src ? Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("pre", null, this.src) : Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("pre", null, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.fallbackText))));
281
+ var _this = this;
282
+
283
+ return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-sign-in-button", {
284
+ onClick: function onClick(event) {
285
+ return _this.signInWithAmazon(event);
286
+ },
287
+ provider: "amazon"
288
+ }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("script", {
289
+ src: "https://assets.loginwithamazon.com/sdk/na/login1.js"
290
+ }), _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_IN_WITH_AMAZON));
296
291
  };
297
292
 
298
- Object.defineProperty(class_1, "watchers", {
299
- get: function get() {
300
- return {
301
- "textKey": ["watchHandler"],
302
- "body": ["watchHandler"]
303
- };
304
- },
305
- enumerable: false,
306
- configurable: true
307
- });
308
293
  return class_1;
309
294
  }();
310
295
 
311
- AmplifyS3Text.style = amplifyS3TextCss;
296
+ var logger$1 = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('amplify-auth0-button');
312
297
 
298
+ var AmplifyAuth0Button =
299
+ /** @class */
300
+ function () {
301
+ function class_2(hostRef) {
302
+ var _this = this;
313
303
 
314
- /***/ }),
304
+ Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
305
+ /** Auth state change handler for this component */
315
306
 
316
- /***/ "../amplify-ui-components/dist/esm-es5/storage-helpers-1afafead.js":
317
- /*!*************************************************************************!*\
318
- !*** ../amplify-ui-components/dist/esm-es5/storage-helpers-1afafead.js ***!
319
- \*************************************************************************/
320
- /*! exports provided: a, c, g, i, p */
321
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
307
+ this.handleAuthStateChange = _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["d"];
322
308
 
323
- "use strict";
324
- __webpack_require__.r(__webpack_exports__);
325
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getTextSource; });
326
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return calcKey; });
327
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return getStorageObject; });
328
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return imageFileType; });
329
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return putStorageObject; });
330
- /* harmony import */ var _constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants-c8ecaa24.js */ "../amplify-ui-components/dist/esm-es5/constants-c8ecaa24.js");
331
- /* harmony import */ var _aws_amplify_storage__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @aws-amplify/storage */ "@aws-amplify/storage");
332
- /* harmony import */ var _aws_amplify_storage__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_storage__WEBPACK_IMPORTED_MODULE_1__);
333
- var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
334
- function adopt(value) {
335
- return value instanceof P ? value : new P(function (resolve) {
336
- resolve(value);
337
- });
338
- }
309
+ this.handleLoad = function () {
310
+ // @ts-ignore Property 'auth0' does not exist on type '{}'.
311
+ var _a = _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].configure().oauth,
312
+ oauth = _a === void 0 ? {} : _a; // @ts-ignore Property 'auth0' does not exist on type '{}'.
339
313
 
340
- return new (P || (P = Promise))(function (resolve, reject) {
341
- function fulfilled(value) {
342
- try {
343
- step(generator.next(value));
344
- } catch (e) {
345
- reject(e);
314
+ var _b = _this.config,
315
+ config = _b === void 0 ? oauth.auth0 : _b;
316
+
317
+ if (!config) {
318
+ logger$1.debug('Auth0 is not configured');
319
+ return;
346
320
  }
347
- }
348
321
 
349
- function rejected(value) {
350
- try {
351
- step(generator["throw"](value));
352
- } catch (e) {
353
- reject(e);
322
+ logger$1.debug('auth0 configuration', config);
323
+
324
+ if (!_this._auth0) {
325
+ _this._auth0 = new window['auth0'].WebAuth(config);
354
326
  }
355
- }
356
327
 
357
- function step(result) {
358
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
359
- }
328
+ _this._auth0.parseHash(function (err, authResult) {
329
+ if (err) {
330
+ logger$1.debug('Failed to parse the url for Auth0', err);
331
+ return;
332
+ }
360
333
 
361
- step((generator = generator.apply(thisArg, _arguments || [])).next());
362
- });
363
- };
334
+ if (!authResult) {
335
+ logger$1.debug('Auth0 found no authResult in hash');
336
+ return;
337
+ }
364
338
 
365
- var __generator = undefined && undefined.__generator || function (thisArg, body) {
366
- var _ = {
367
- label: 0,
368
- sent: function sent() {
369
- if (t[0] & 1) throw t[1];
370
- return t[1];
371
- },
372
- trys: [],
373
- ops: []
374
- },
375
- f,
376
- y,
377
- t,
378
- g;
379
- return g = {
380
- next: verb(0),
381
- "throw": verb(1),
382
- "return": verb(2)
383
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
384
- return this;
385
- }), g;
339
+ var payload = {
340
+ provider: 'auth0',
341
+ opts: {
342
+ returnTo: config.returnTo,
343
+ clientID: config.clientID,
344
+ federated: config.federated
345
+ }
346
+ };
386
347
 
387
- function verb(n) {
388
- return function (v) {
389
- return step([n, v]);
348
+ try {
349
+ localStorage.setItem(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["h"], JSON.stringify(payload));
350
+ } catch (e) {
351
+ logger$1.debug('Failed to cache auth source into localStorage', e);
352
+ }
353
+
354
+ _this._auth0.client.userInfo(authResult.accessToken, function (err, user) {
355
+ return __awaiter(_this, void 0, void 0, function () {
356
+ var username, email, authenticatedUser;
357
+ return __generator(this, function (_a) {
358
+ switch (_a.label) {
359
+ case 0:
360
+ username = undefined;
361
+ email = undefined;
362
+
363
+ if (err) {
364
+ logger$1.debug('Failed to get the user info', err);
365
+ } else {
366
+ username = user.name;
367
+ email = user.email;
368
+ }
369
+
370
+ return [4
371
+ /*yield*/
372
+ , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].federatedSignIn(config.domain, {
373
+ token: authResult.idToken,
374
+ expires_at: authResult.expiresIn * 1000 + new Date().getTime()
375
+ }, {
376
+ name: username,
377
+ email: email
378
+ })];
379
+
380
+ case 1:
381
+ _a.sent();
382
+
383
+ return [4
384
+ /*yield*/
385
+ , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].currentAuthenticatedUser()];
386
+
387
+ case 2:
388
+ authenticatedUser = _a.sent();
389
+ this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignedIn, authenticatedUser);
390
+ return [2
391
+ /*return*/
392
+ ];
393
+ }
394
+ });
395
+ });
396
+ });
397
+ });
390
398
  };
391
399
  }
392
400
 
393
- function step(op) {
394
- if (f) throw new TypeError("Generator is already executing.");
401
+ class_2.prototype.componentWillLoad = function () {
402
+ console.warn('Version `1.x` of Amplify UI has been deprecated and will be removed in a future major version of `aws-amplify`. Please visit https://ui.docs.amplify.aws/ for the current version of Amplify UI.');
403
+ };
395
404
 
396
- while (_) {
397
- try {
398
- 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;
399
- if (y = 0, t) op = [op[0] & 2, t.value];
405
+ class_2.prototype.signInWithAuth0 = function (event) {
406
+ event.preventDefault();
400
407
 
401
- switch (op[0]) {
402
- case 0:
403
- case 1:
404
- t = op;
405
- break;
408
+ if (!this._auth0) {
409
+ throw new Error('the auth0 client is not configured');
410
+ }
406
411
 
407
- case 4:
408
- _.label++;
409
- return {
410
- value: op[1],
411
- done: false
412
- };
412
+ this._auth0.authorize();
413
+ };
413
414
 
414
- case 5:
415
- _.label++;
416
- y = op[1];
417
- op = [0];
418
- continue;
415
+ class_2.prototype.render = function () {
416
+ var _this = this;
417
+
418
+ return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-sign-in-button", {
419
+ onClick: function onClick(event) {
420
+ return _this.signInWithAuth0(event);
421
+ },
422
+ provider: "auth0"
423
+ }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("script", {
424
+ onLoad: this.handleLoad,
425
+ src: "https://cdn.auth0.com/js/auth0/9.11/auth0.min.js"
426
+ }), _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_IN_WITH_AUTH0));
427
+ };
419
428
 
420
- case 7:
421
- op = _.ops.pop();
429
+ return class_2;
430
+ }();
422
431
 
423
- _.trys.pop();
432
+ var logger$2 = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('amplify-facebook-button');
424
433
 
425
- continue;
434
+ var AmplifyFacebookButton =
435
+ /** @class */
436
+ function () {
437
+ function class_3(hostRef) {
438
+ var _this = this;
426
439
 
427
- default:
428
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
429
- _ = 0;
430
- continue;
431
- }
440
+ Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
441
+ /** Auth state change handler for this component
442
+ * e.g. SignIn -> 'Create Account' link -> SignUp
443
+ */
432
444
 
433
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
434
- _.label = op[1];
435
- break;
436
- }
445
+ this.handleAuthStateChange = _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["d"];
437
446
 
438
- if (op[0] === 6 && _.label < t[1]) {
439
- _.label = t[1];
440
- t = op;
441
- break;
442
- }
447
+ this.federatedSignIn = function (authResponse) {
448
+ var accessToken = authResponse.accessToken,
449
+ expiresIn = authResponse.expiresIn;
443
450
 
444
- if (t && _.label < t[2]) {
445
- _.label = t[2];
451
+ if (!accessToken) {
452
+ return;
453
+ }
446
454
 
447
- _.ops.push(op);
455
+ if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].federatedSignIn !== 'function' || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].currentAuthenticatedUser !== 'function') {
456
+ throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
457
+ }
448
458
 
449
- break;
459
+ var date = new Date();
460
+ var expires_at = expiresIn * 1000 + date.getTime();
461
+ var fields = 'name,email';
462
+ window['FB'].api('/me', {
463
+ fields: fields
464
+ }, function (response) {
465
+ return __awaiter(_this, void 0, void 0, function () {
466
+ var user, authenticatedUser;
467
+ return __generator(this, function (_a) {
468
+ switch (_a.label) {
469
+ case 0:
470
+ user = {
471
+ name: response.name,
472
+ email: response.email
473
+ };
474
+ return [4
475
+ /*yield*/
476
+ , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].federatedSignIn('facebook', {
477
+ token: accessToken,
478
+ expires_at: expires_at
479
+ }, user)];
480
+
481
+ case 1:
482
+ _a.sent();
483
+
484
+ return [4
485
+ /*yield*/
486
+ , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].currentAuthenticatedUser()];
487
+
488
+ case 2:
489
+ authenticatedUser = _a.sent();
490
+ this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignedIn, authenticatedUser);
491
+ return [2
492
+ /*return*/
493
+ ];
450
494
  }
495
+ });
496
+ });
497
+ });
498
+ };
451
499
 
452
- if (t[2]) _.ops.pop();
453
-
454
- _.trys.pop();
500
+ this.getLoginStatus = function () {
501
+ window['FB'].getLoginStatus(function (response) {
502
+ try {
503
+ window.localStorage.setItem(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["h"], JSON.stringify({
504
+ provider: 'facebook'
505
+ }));
506
+ } catch (e) {
507
+ logger$2.debug('Failed to cache auth source into localStorage', e);
508
+ }
455
509
 
456
- continue;
510
+ if (response.status === 'connected') {
511
+ return _this.federatedSignIn(response.authResponse);
457
512
  }
458
513
 
459
- op = body.call(thisArg, _);
460
- } catch (e) {
461
- op = [6, e];
462
- y = 0;
463
- } finally {
464
- f = t = 0;
465
- }
466
- }
514
+ _this.login();
515
+ });
516
+ };
467
517
 
468
- if (op[0] & 5) throw op[1];
469
- return {
470
- value: op[0] ? op[1] : void 0,
471
- done: true
518
+ this.login = function () {
519
+ var scope = 'public_profile,email';
520
+ window['FB'].login(function (response) {
521
+ if (response && response.authResponse) {
522
+ _this.federatedSignIn(response.authResponse);
523
+ }
524
+ }, {
525
+ scope: scope
526
+ });
472
527
  };
473
528
  }
474
- };
475
529
 
530
+ class_3.prototype.componentWillLoad = function () {
531
+ console.warn('Version `1.x` of Amplify UI has been deprecated and will be removed in a future major version of `aws-amplify`. Please visit https://ui.docs.amplify.aws/ for the current version of Amplify UI.');
532
+ };
533
+ /**
534
+ * @see https://developers.facebook.com/docs/javascript/reference/FB.init/v5.0
535
+ */
536
+
537
+
538
+ class_3.prototype.signInWithFacebook = function (event) {
539
+ event.preventDefault();
540
+ window['FB'].init({
541
+ appId: this.appId,
542
+ cookie: true,
543
+ xfbml: false,
544
+ version: 'v5.0'
545
+ });
546
+ this.getLoginStatus();
547
+ };
548
+
549
+ class_3.prototype.render = function () {
550
+ var _this = this;
551
+
552
+ return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-sign-in-button", {
553
+ onClick: function onClick(event) {
554
+ return _this.signInWithFacebook(event);
555
+ },
556
+ provider: "facebook"
557
+ }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("script", {
558
+ async: true,
559
+ defer: true,
560
+ src: "https://connect.facebook.net/en_US/sdk.js"
561
+ }), _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_IN_WITH_FACEBOOK));
562
+ };
563
+
564
+ return class_3;
565
+ }();
566
+
567
+ var logger$3 = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('amplify-google-button');
568
+
569
+ var AmplifyGoogleButton =
570
+ /** @class */
571
+ function () {
572
+ function class_4(hostRef) {
573
+ var _this = this;
574
+
575
+ Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
576
+ /** Auth state change handler for this component
577
+ * e.g. SignIn -> 'Create Account' link -> SignUp
578
+ */
476
579
 
580
+ this.handleAuthStateChange = _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["d"];
477
581
 
478
- var imageFileType = new Set(['apng', 'bmp', 'gif', 'ico', 'cur', 'jpg', 'jpeg', 'jfif', 'pjpeg', 'pjp', 'png', 'svg', 'tif', 'tiff', 'webp']);
582
+ this.handleError = function (error) {
583
+ console.error(error);
584
+ };
585
+ /**
586
+ * @see https://developers.google.com/identity/sign-in/web/build-button#building_a_button_with_a_custom_graphic
587
+ */
479
588
 
480
- var calcKey = function calcKey(file, fileToKey) {
481
- var name = file.name,
482
- size = file.size,
483
- type = file.type;
484
- var key = encodeURI(name);
485
589
 
486
- if (fileToKey) {
487
- if (typeof fileToKey === 'string') {
488
- key = fileToKey;
489
- } else if (typeof fileToKey === 'function') {
490
- key = fileToKey({
491
- name: name,
492
- size: size,
493
- type: type
590
+ this.handleLoad = function () {
591
+ window['gapi'].load('auth2');
592
+ };
593
+
594
+ this.handleUser = function (user) {
595
+ return __awaiter(_this, void 0, void 0, function () {
596
+ var _a, id_token, expires_at, profile, authenticatedUser;
597
+
598
+ return __generator(this, function (_b) {
599
+ switch (_b.label) {
600
+ case 0:
601
+ if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].federatedSignIn !== 'function' || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].currentAuthenticatedUser !== 'function') {
602
+ throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
603
+ }
604
+
605
+ try {
606
+ window.localStorage.setItem(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["h"], JSON.stringify({
607
+ provider: 'google'
608
+ }));
609
+ } catch (e) {
610
+ logger$3.debug('Failed to cache auth source into localStorage', e);
611
+ }
612
+
613
+ _a = user.getAuthResponse(), id_token = _a.id_token, expires_at = _a.expires_at;
614
+ profile = user.getBasicProfile();
615
+ return [4
616
+ /*yield*/
617
+ , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].federatedSignIn('google', {
618
+ token: id_token,
619
+ expires_at: expires_at
620
+ }, {
621
+ email: profile.getEmail(),
622
+ name: profile.getName(),
623
+ picture: profile.getImageUrl()
624
+ })];
625
+
626
+ case 1:
627
+ _b.sent();
628
+
629
+ return [4
630
+ /*yield*/
631
+ , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].currentAuthenticatedUser()];
632
+
633
+ case 2:
634
+ authenticatedUser = _b.sent();
635
+
636
+ try {
637
+ this.handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].SignedIn, authenticatedUser);
638
+ } catch (error) {
639
+ this.handleError(error);
640
+ }
641
+
642
+ return [2
643
+ /*return*/
644
+ ];
645
+ }
646
+ });
494
647
  });
495
- } else {
496
- key = encodeURI(JSON.stringify(fileToKey));
497
- }
648
+ };
649
+ }
650
+
651
+ class_4.prototype.componentWillLoad = function () {
652
+ console.warn('Version `1.x` of Amplify UI has been deprecated and will be removed in a future major version of `aws-amplify`. Please visit https://ui.docs.amplify.aws/ for the current version of Amplify UI.');
653
+ };
498
654
 
499
- if (!key) {
500
- key = 'empty_key';
655
+ class_4.prototype.getAuthInstance = function () {
656
+ if (window['gapi'] && window['gapi'].auth2) {
657
+ return window['gapi'].auth2.getAuthInstance() || window['gapi'].auth2.init({
658
+ client_id: this.clientId,
659
+ cookiepolicy: 'single_host_origin',
660
+ scope: 'profile email openid'
661
+ });
501
662
  }
502
- }
503
663
 
504
- return key.replace(/\s/g, '_');
505
- };
664
+ return null;
665
+ };
506
666
 
507
- var getStorageObject = function getStorageObject(key, level, track, identityId, logger) {
508
- return __awaiter(void 0, void 0, void 0, function () {
509
- var src, error_1;
510
- return __generator(this, function (_a) {
511
- switch (_a.label) {
512
- case 0:
513
- if (!_aws_amplify_storage__WEBPACK_IMPORTED_MODULE_1__["Storage"] || typeof _aws_amplify_storage__WEBPACK_IMPORTED_MODULE_1__["Storage"].get !== 'function') {
514
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_0__["d"]);
515
- }
667
+ class_4.prototype.signInWithGoogle = function (event) {
668
+ event.preventDefault();
669
+ this.getAuthInstance().signIn().then(this.handleUser)["catch"](this.handleError);
670
+ };
516
671
 
517
- _a.label = 1;
518
-
519
- case 1:
520
- _a.trys.push([1, 3,, 4]);
521
-
522
- return [4
523
- /*yield*/
524
- , _aws_amplify_storage__WEBPACK_IMPORTED_MODULE_1__["Storage"].get(key, {
525
- level: level,
526
- track: track,
527
- identityId: identityId
528
- })];
529
-
530
- case 2:
531
- src = _a.sent();
532
- logger.debug('Storage image get', src);
533
- return [2
534
- /*return*/
535
- , src];
536
-
537
- case 3:
538
- error_1 = _a.sent();
539
- throw new Error(error_1);
540
-
541
- case 4:
542
- return [2
543
- /*return*/
544
- ];
545
- }
546
- });
547
- });
548
- };
672
+ class_4.prototype.render = function () {
673
+ var _this = this;
674
+
675
+ return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-sign-in-button", {
676
+ onClick: function onClick(event) {
677
+ return _this.signInWithGoogle(event);
678
+ },
679
+ provider: "google"
680
+ }, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("script", {
681
+ onLoad: this.handleLoad,
682
+ src: "https://apis.google.com/js/api:client.js"
683
+ }), _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_IN_WITH_GOOGLE));
684
+ };
549
685
 
550
- var readFileAsync = function readFileAsync(blob) {
551
- return new Promise(function (resolve, reject) {
552
- var reader = new FileReader();
686
+ return class_4;
687
+ }();
553
688
 
554
- reader.onload = function () {
555
- resolve(reader.result);
556
- };
689
+ var AmplifyOAuthButton =
690
+ /** @class */
691
+ function () {
692
+ function AmplifyOAuthButton(hostRef) {
693
+ Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
694
+ /** Federated credentials & configuration. */
557
695
 
558
- reader.onerror = function () {
559
- reject('Failed to read file!');
560
- reader.abort();
561
- };
696
+ this.config = {};
697
+ }
562
698
 
563
- reader.readAsText(blob);
564
- });
565
- };
699
+ AmplifyOAuthButton.prototype.signInWithOAuth = function (event) {
700
+ event.preventDefault();
701
+ _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].federatedSignIn();
702
+ };
566
703
 
567
- var getTextSource = function getTextSource(key, level, track, identityId, logger) {
568
- return __awaiter(void 0, void 0, void 0, function () {
569
- var textSrc, text, error_2;
570
- return __generator(this, function (_a) {
571
- switch (_a.label) {
572
- case 0:
573
- if (!_aws_amplify_storage__WEBPACK_IMPORTED_MODULE_1__["Storage"] || typeof _aws_amplify_storage__WEBPACK_IMPORTED_MODULE_1__["Storage"].get !== 'function') {
574
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_0__["d"]);
575
- }
704
+ AmplifyOAuthButton.prototype.componentWillLoad = function () {
705
+ console.warn('Version `1.x` of Amplify UI has been deprecated and will be removed in a future major version of `aws-amplify`. Please visit https://ui.docs.amplify.aws/ for the current version of Amplify UI.');
706
+ };
576
707
 
577
- _a.label = 1;
578
-
579
- case 1:
580
- _a.trys.push([1, 4,, 5]);
581
-
582
- return [4
583
- /*yield*/
584
- , _aws_amplify_storage__WEBPACK_IMPORTED_MODULE_1__["Storage"].get(key, {
585
- download: true,
586
- level: level,
587
- track: track,
588
- identityId: identityId
589
- })];
590
-
591
- case 2:
592
- textSrc = _a.sent();
593
- logger.debug(textSrc);
594
- return [4
595
- /*yield*/
596
- , readFileAsync(textSrc['Body'])];
597
-
598
- case 3:
599
- text = _a.sent();
600
- return [2
601
- /*return*/
602
- , text];
603
-
604
- case 4:
605
- error_2 = _a.sent();
606
- throw new Error(error_2);
607
-
608
- case 5:
609
- return [2
610
- /*return*/
611
- ];
612
- }
613
- });
614
- });
615
- };
708
+ AmplifyOAuthButton.prototype.render = function () {
709
+ var _this = this;
616
710
 
617
- var putStorageObject = function putStorageObject(key, body, level, track, contentType, logger) {
618
- return __awaiter(void 0, void 0, void 0, function () {
619
- var data, error_3;
620
- return __generator(this, function (_a) {
621
- switch (_a.label) {
622
- case 0:
623
- if (!_aws_amplify_storage__WEBPACK_IMPORTED_MODULE_1__["Storage"] || typeof _aws_amplify_storage__WEBPACK_IMPORTED_MODULE_1__["Storage"].put !== 'function') {
624
- throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_0__["d"]);
625
- }
711
+ return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-sign-in-button", {
712
+ onClick: function onClick(event) {
713
+ return _this.signInWithOAuth(event);
714
+ },
715
+ provider: "oauth"
716
+ }, this.config.label || _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].SIGN_IN_WITH_AWS));
717
+ };
626
718
 
627
- _a.label = 1;
628
-
629
- case 1:
630
- _a.trys.push([1, 3,, 4]);
631
-
632
- return [4
633
- /*yield*/
634
- , _aws_amplify_storage__WEBPACK_IMPORTED_MODULE_1__["Storage"].put(key, body, {
635
- contentType: contentType,
636
- level: level,
637
- track: track
638
- })];
639
-
640
- case 2:
641
- data = _a.sent();
642
- logger.debug('Upload data', data);
643
- return [3
644
- /*break*/
645
- , 4];
646
-
647
- case 3:
648
- error_3 = _a.sent();
649
- throw new Error(error_3);
650
-
651
- case 4:
652
- return [2
653
- /*return*/
654
- ];
655
- }
656
- });
657
- });
658
- };
719
+ return AmplifyOAuthButton;
720
+ }();
659
721
 
660
722
 
661
723