@aws-amplify/ui-angular 3.2.16 → 3.2.17

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@aws-amplify/ui'), require('@aws-amplify/core'), require('xstate'), require('nanoid'), require('classnames'), require('qrcode'), require('aws-amplify')) :
3
- typeof define === 'function' && define.amd ? define('@aws-amplify/ui-angular', ['exports', '@angular/core', '@angular/common', '@aws-amplify/ui', '@aws-amplify/core', 'xstate', 'nanoid', 'classnames', 'qrcode', 'aws-amplify'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["aws-amplify"] = global["aws-amplify"] || {}, global["aws-amplify"]["ui-angular"] = {}), global.ng.core, global.ng.common, global.ui, global.core, global.xstate, global.nanoid, global.classnames, global.QRCode, global["aws-amplify"]));
5
- })(this, (function (exports, i0, i6, ui, core, xstate, nanoid, classnames, QRCode, awsAmplify) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@aws-amplify/ui'), require('rxjs'), require('xstate'), require('aws-amplify'), require('@aws-amplify/core'), require('nanoid'), require('classnames'), require('qrcode')) :
3
+ typeof define === 'function' && define.amd ? define('@aws-amplify/ui-angular', ['exports', '@angular/core', '@angular/common', '@aws-amplify/ui', 'rxjs', 'xstate', 'aws-amplify', '@aws-amplify/core', 'nanoid', 'classnames', 'qrcode'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["aws-amplify"] = global["aws-amplify"] || {}, global["aws-amplify"]["ui-angular"] = {}), global.ng.core, global.ng.common, global.ui, global.rxjs, global.xstate, global["aws-amplify"], global.core, global.nanoid, global.classnames, global.QRCode));
5
+ })(this, (function (exports, i0, i6, ui, rxjs, xstate, awsAmplify, core, nanoid, classnames, QRCode) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -29,6 +29,60 @@
29
29
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
30
30
  var QRCode__default = /*#__PURE__*/_interopDefaultLegacy(QRCode);
31
31
 
32
+ var AmplifySlotDirective = /** @class */ (function () {
33
+ function AmplifySlotDirective(template) {
34
+ this.template = template;
35
+ }
36
+ Object.defineProperty(AmplifySlotDirective.prototype, "amplifySlot", {
37
+ set: function (component) {
38
+ this.name = component;
39
+ },
40
+ enumerable: false,
41
+ configurable: true
42
+ });
43
+ return AmplifySlotDirective;
44
+ }());
45
+ AmplifySlotDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: AmplifySlotDirective, deps: [{ token: i0__namespace.TemplateRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
46
+ AmplifySlotDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: AmplifySlotDirective, selector: "[amplifySlot]", inputs: { amplifySlot: "amplifySlot" }, ngImport: i0__namespace });
47
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: AmplifySlotDirective, decorators: [{
48
+ type: i0.Directive,
49
+ args: [{
50
+ selector: '[amplifySlot]',
51
+ }]
52
+ }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }]; }, propDecorators: { amplifySlot: [{
53
+ type: i0.Input
54
+ }] } });
55
+
56
+ /**
57
+ * Stores and provides custom components that users provide with `amplify-slot`.
58
+ */
59
+ var CustomComponentsService = /** @class */ (function () {
60
+ function CustomComponentsService() {
61
+ this._customComponents = {};
62
+ }
63
+ Object.defineProperty(CustomComponentsService.prototype, "customComponents", {
64
+ get: function () {
65
+ return this._customComponents;
66
+ },
67
+ set: function (customComponents) {
68
+ this._customComponents = Object.assign(Object.assign({}, this._customComponents), customComponents);
69
+ },
70
+ enumerable: false,
71
+ configurable: true
72
+ });
73
+ return CustomComponentsService;
74
+ }());
75
+ CustomComponentsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: CustomComponentsService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
76
+ CustomComponentsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: CustomComponentsService, providedIn: 'root' });
77
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: CustomComponentsService, decorators: [{
78
+ type: i0.Injectable,
79
+ args: [{
80
+ providedIn: 'root',
81
+ }]
82
+ }] });
83
+
84
+ var VERSION = '3.2.17';
85
+
32
86
  /******************************************************************************
33
87
  Copyright (c) Microsoft Corporation.
34
88
 
@@ -414,82 +468,24 @@
414
468
  return typeof state === "function" ? receiver === state : state.has(receiver);
415
469
  }
416
470
 
417
- var AmplifySlotDirective = /** @class */ (function () {
418
- function AmplifySlotDirective(template) {
419
- this.template = template;
420
- }
421
- Object.defineProperty(AmplifySlotDirective.prototype, "amplifySlot", {
422
- set: function (component) {
423
- this.name = component;
424
- },
425
- enumerable: false,
426
- configurable: true
427
- });
428
- return AmplifySlotDirective;
429
- }());
430
- AmplifySlotDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: AmplifySlotDirective, deps: [{ token: i0__namespace.TemplateRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
431
- AmplifySlotDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: AmplifySlotDirective, selector: "[amplifySlot]", inputs: { amplifySlot: "amplifySlot" }, ngImport: i0__namespace });
432
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: AmplifySlotDirective, decorators: [{
433
- type: i0.Directive,
434
- args: [{
435
- selector: '[amplifySlot]',
436
- }]
437
- }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }]; }, propDecorators: { amplifySlot: [{
438
- type: i0.Input
439
- }] } });
440
-
441
- /**
442
- * Stores and provides custom components that users provide with `amplify-slot`.
443
- */
444
- var CustomComponentsService = /** @class */ (function () {
445
- function CustomComponentsService() {
446
- this._customComponents = {};
447
- }
448
- Object.defineProperty(CustomComponentsService.prototype, "customComponents", {
449
- get: function () {
450
- return this._customComponents;
451
- },
452
- set: function (customComponents) {
453
- this._customComponents = Object.assign(Object.assign({}, this._customComponents), customComponents);
454
- },
455
- enumerable: false,
456
- configurable: true
457
- });
458
- return CustomComponentsService;
459
- }());
460
- CustomComponentsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: CustomComponentsService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
461
- CustomComponentsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: CustomComponentsService, providedIn: 'root' });
462
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: CustomComponentsService, decorators: [{
463
- type: i0.Injectable,
464
- args: [{
465
- providedIn: 'root',
466
- }]
467
- }] });
468
-
469
- var VERSION = '3.2.16';
470
-
471
471
  var logger$1 = new core.Logger('state-machine');
472
472
  /**
473
473
  * AuthenticatorService provides access to the authenticator state and context.
474
474
  */
475
475
  var AuthenticatorService = /** @class */ (function () {
476
476
  function AuthenticatorService() {
477
- var _this = this;
477
+ this._authStatus = 'configuring';
478
478
  var machine = ui.createAuthenticatorMachine();
479
- var authService = xstate.interpret(machine).start();
480
- this._machineSubscription = authService.subscribe(function (state) {
481
- var newState = state;
482
- _this._authState = newState;
483
- _this._facade = ui.getServiceFacade({
484
- send: authService.send,
485
- state: newState,
486
- });
487
- });
488
- this._authService = authService;
479
+ this._authService = xstate.interpret(machine).start();
480
+ this.setupMachineSubscription();
481
+ this.setupHubListener();
482
+ this.getInitialAuthStatus();
489
483
  }
490
484
  AuthenticatorService.prototype.ngOnDestroy = function () {
491
485
  if (this._machineSubscription)
492
486
  this._machineSubscription.unsubscribe();
487
+ if (this._unsubscribeHub)
488
+ this._unsubscribeHub();
493
489
  };
494
490
  Object.defineProperty(AuthenticatorService.prototype, "error", {
495
491
  /**
@@ -528,8 +524,7 @@
528
524
  });
529
525
  Object.defineProperty(AuthenticatorService.prototype, "authStatus", {
530
526
  get: function () {
531
- var _a;
532
- return (_a = this._facade) === null || _a === void 0 ? void 0 : _a.authStatus;
527
+ return this._authStatus;
533
528
  },
534
529
  enumerable: false,
535
530
  configurable: true
@@ -684,6 +679,14 @@
684
679
  enumerable: false,
685
680
  configurable: true
686
681
  });
682
+ Object.defineProperty(AuthenticatorService.prototype, "hubSubject", {
683
+ /** @deprecated For internal use only */
684
+ get: function () {
685
+ return this._hubSubject;
686
+ },
687
+ enumerable: false,
688
+ configurable: true
689
+ });
687
690
  AuthenticatorService.prototype.subscribe = function (callback) {
688
691
  var _this = this;
689
692
  if (!this._authService) {
@@ -698,6 +701,59 @@
698
701
  AuthenticatorService.prototype.send = function (event) {
699
702
  this.authService.send(event);
700
703
  };
704
+ AuthenticatorService.prototype.getInitialAuthStatus = function () {
705
+ return __awaiter(this, void 0, void 0, function () {
706
+ var e_1;
707
+ return __generator(this, function (_b) {
708
+ switch (_b.label) {
709
+ case 0:
710
+ _b.trys.push([0, 2, , 3]);
711
+ return [4 /*yield*/, awsAmplify.Auth.currentAuthenticatedUser()];
712
+ case 1:
713
+ _b.sent();
714
+ this._authStatus = 'authenticated';
715
+ return [3 /*break*/, 3];
716
+ case 2:
717
+ e_1 = _b.sent();
718
+ this._authStatus = 'unauthenticated';
719
+ return [3 /*break*/, 3];
720
+ case 3: return [2 /*return*/];
721
+ }
722
+ });
723
+ });
724
+ };
725
+ AuthenticatorService.prototype.setupHubListener = function () {
726
+ var _this = this;
727
+ this._hubSubject = new rxjs.Subject();
728
+ var onSignIn = function () {
729
+ _this._authStatus = 'authenticated';
730
+ };
731
+ var onSignOut = function () {
732
+ _this._authStatus = 'unauthenticated';
733
+ };
734
+ this._unsubscribeHub = ui.listenToAuthHub(this._authService, function (data, service) { return __awaiter(_this, void 0, void 0, function () {
735
+ return __generator(this, function (_b) {
736
+ switch (_b.label) {
737
+ case 0: return [4 /*yield*/, ui.defaultAuthHubHandler(data, service, { onSignIn: onSignIn, onSignOut: onSignOut })];
738
+ case 1:
739
+ _b.sent();
740
+ this._hubSubject.next();
741
+ return [2 /*return*/];
742
+ }
743
+ });
744
+ }); });
745
+ };
746
+ AuthenticatorService.prototype.setupMachineSubscription = function () {
747
+ var _this = this;
748
+ this._machineSubscription = this._authService.subscribe(function (state) {
749
+ var newState = state;
750
+ _this._authState = newState;
751
+ _this._facade = ui.getServiceFacade({
752
+ send: _this._authService.send,
753
+ state: newState,
754
+ });
755
+ });
756
+ };
701
757
  return AuthenticatorService;
702
758
  }());
703
759
  AuthenticatorService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: AuthenticatorService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -1838,34 +1894,26 @@
1838
1894
  packageName: '@aws-amplify/ui-angular',
1839
1895
  version: VERSION,
1840
1896
  });
1841
- var _b = this.authenticator, authService = _b.authService, initializeMachine = _b.initializeMachine;
1842
- this.unsubscribeHub = ui.listenToAuthHub(authService, function (data, service) { return __awaiter(_this, void 0, void 0, function () {
1843
- return __generator(this, function (_a) {
1844
- switch (_a.label) {
1845
- case 0: return [4 /*yield*/, ui.defaultAuthHubHandler(data, service)];
1846
- case 1:
1847
- _a.sent();
1848
- /**
1849
- * Hub events aren't properly caught by Angular, because they are
1850
- * synchronous events. Angular tracks async network events and
1851
- * html events, but not synchronous events like hub.
1852
- *
1853
- * On any notable hub events, we run change detection manually.
1854
- */
1855
- this.changeDetector.detectChanges();
1856
- /**
1857
- * Hub events that we handle can lead to multiple state changes:
1858
- * e.g. `authenticated` -> `signOut` -> initialState.
1859
- *
1860
- * We want to ensure change detection runs all the way, until
1861
- * we reach back to the initial state. Setting the below flag
1862
- * to true to until we reach initial state.
1863
- */
1864
- this.isHandlingHubEvent = true;
1865
- return [2 /*return*/];
1866
- }
1867
- });
1868
- }); });
1897
+ var initializeMachine = this.authenticator.initializeMachine;
1898
+ this.authenticator.hubSubject.subscribe(function () {
1899
+ /*
1900
+ * Hub events aren't properly caught by Angular, because they are
1901
+ * synchronous events. Angular tracks async network events and
1902
+ * html events, but not synchronous events like hub.
1903
+ *
1904
+ * On any notable hub events, we run change detection manually.
1905
+ */
1906
+ _this.changeDetector.detectChanges();
1907
+ /*
1908
+ * Hub events that we handle can lead to multiple state changes:
1909
+ * e.g. `authenticated` -> `signOut` -> initialState.
1910
+ *
1911
+ * We want to ensure change detection runs all the way, until
1912
+ * we reach back to the initial state. Setting the below flag
1913
+ * to true to until we reach initial state.
1914
+ */
1915
+ _this.isHandlingHubEvent = true;
1916
+ });
1869
1917
  /**
1870
1918
  * Subscribes to state machine changes and sends INIT event
1871
1919
  * once machine reaches 'setup' state.
@@ -1908,8 +1956,6 @@
1908
1956
  AuthenticatorComponent.prototype.ngOnDestroy = function () {
1909
1957
  if (this.unsubscribeMachine)
1910
1958
  this.unsubscribeMachine();
1911
- if (this.unsubscribeHub)
1912
- this.unsubscribeHub();
1913
1959
  };
1914
1960
  Object.defineProperty(AuthenticatorComponent.prototype, "context", {
1915
1961
  /**