@aws-amplify/ui-angular 2.3.15 → 2.4.2

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 (23) hide show
  1. package/aws-amplify-ui-angular.metadata.json +1 -1
  2. package/bundles/aws-amplify-ui-angular.umd.js +45 -6
  3. package/bundles/aws-amplify-ui-angular.umd.js.map +1 -1
  4. package/bundles/aws-amplify-ui-angular.umd.min.js +1 -1
  5. package/bundles/aws-amplify-ui-angular.umd.min.js.map +1 -1
  6. package/esm2015/lib/components/authenticator/components/authenticator/authenticator.component.js +39 -5
  7. package/esm2015/lib/components/authenticator/components/setup-totp/setup-totp.component.js +2 -2
  8. package/esm2015/lib/services/authenticator.service.js +6 -5
  9. package/fesm2015/aws-amplify-ui-angular.js +43 -8
  10. package/fesm2015/aws-amplify-ui-angular.js.map +1 -1
  11. package/lib/components/authenticator/components/authenticator/authenticator.component.d.ts +7 -2
  12. package/lib/components/authenticator/components/confirm-reset-password/amplify-confirm-reset-password.component.d.ts +2 -0
  13. package/lib/components/authenticator/components/confirm-sign-in/confirm-sign-in.component.d.ts +2 -0
  14. package/lib/components/authenticator/components/confirm-sign-up/confirm-sign-up.component.d.ts +2 -0
  15. package/lib/components/authenticator/components/confirm-verify-user/amplify-confirm-verify-user.component.d.ts +2 -0
  16. package/lib/components/authenticator/components/force-new-password/force-new-password.component.d.ts +2 -0
  17. package/lib/components/authenticator/components/reset-password/reset-password.component.d.ts +2 -0
  18. package/lib/components/authenticator/components/setup-totp/setup-totp.component.d.ts +2 -0
  19. package/lib/components/authenticator/components/sign-in/sign-in.component.d.ts +2 -0
  20. package/lib/components/authenticator/components/sign-up/sign-up.component.d.ts +2 -0
  21. package/lib/components/authenticator/components/verify-user/verify-user.component.d.ts +2 -0
  22. package/lib/services/authenticator.service.d.ts +3 -1
  23. package/package.json +2 -2
@@ -91,15 +91,12 @@
91
91
  _this._authState = state;
92
92
  _this._facade = ui.getServiceContextFacade(state);
93
93
  });
94
- this._hubSubscription = ui.listenToAuthHub(authService.send);
95
94
  this._sendEventAliases = ui.getSendEventAliases(authService.send);
96
95
  this._authService = authService;
97
96
  }
98
97
  AuthenticatorService.prototype.ngOnDestroy = function () {
99
98
  if (this._machineSubscription)
100
99
  this._machineSubscription.unsubscribe();
101
- if (this._hubSubscription)
102
- this._hubSubscription();
103
100
  };
104
101
  Object.defineProperty(AuthenticatorService.prototype, "error", {
105
102
  /**
@@ -136,6 +133,14 @@
136
133
  enumerable: false,
137
134
  configurable: true
138
135
  });
136
+ Object.defineProperty(AuthenticatorService.prototype, "authStatus", {
137
+ get: function () {
138
+ var _a;
139
+ return (_a = this._facade) === null || _a === void 0 ? void 0 : _a.authStatus;
140
+ },
141
+ enumerable: false,
142
+ configurable: true
143
+ });
139
144
  Object.defineProperty(AuthenticatorService.prototype, "user", {
140
145
  get: function () {
141
146
  var _a;
@@ -296,24 +301,55 @@
296
301
  AuthenticatorService.ctorParameters = function () { return []; };
297
302
 
298
303
  var AuthenticatorComponent = /** @class */ (function () {
299
- function AuthenticatorComponent(authenticator, contextService) {
304
+ function AuthenticatorComponent(authenticator, contextService, changeDetector) {
300
305
  this.authenticator = authenticator;
301
306
  this.contextService = contextService;
307
+ this.changeDetector = changeDetector;
302
308
  this.customComponentQuery = null;
303
309
  // translated texts
304
310
  this.signInTitle = ui.translate('Sign In');
305
311
  this.signUpTitle = ui.translate('Create Account');
306
312
  this.hasInitialized = false;
313
+ this.isHandlingHubEvent = false;
307
314
  }
308
315
  AuthenticatorComponent.prototype.ngOnInit = function () {
309
316
  var _this = this;
310
317
  var _a = this, initialState = _a.initialState, loginMechanisms = _a.loginMechanisms, services = _a.services, signUpAttributes = _a.signUpAttributes, socialProviders = _a.socialProviders, formFields = _a.formFields;
318
+ this.unsubscribeHub = ui.listenToAuthHub(function (event) {
319
+ /**
320
+ * Hub events aren't properly caught by Angular, because they are
321
+ * synchronous events. Angular tracks async network events and
322
+ * html events, but not synchronous events like hub.
323
+ *
324
+ * On any notable hub events, we run change detection manually.
325
+ */
326
+ var state = _this.authenticator.authService.send(event);
327
+ _this.changeDetector.detectChanges();
328
+ /**
329
+ * Hub events that we handle can lead to multiple state changes:
330
+ * e.g. `authenticated` -> `signOut` -> initialState.
331
+ *
332
+ * We want to ensure change detection runs all the way, until
333
+ * we reach back to the initial state. Setting the below flag
334
+ * to true to until we reach initial state.
335
+ */
336
+ _this.isHandlingHubEvent = true;
337
+ return state;
338
+ });
311
339
  /**
312
340
  * Subscribes to state machine changes and sends INIT event
313
341
  * once machine reaches 'setup' state.
314
342
  */
315
343
  this.unsubscribeMachine = this.authenticator.subscribe(function () {
316
344
  var route = _this.authenticator.route;
345
+ if (_this.isHandlingHubEvent) {
346
+ _this.changeDetector.detectChanges();
347
+ var initialStateWithDefault = initialState !== null && initialState !== void 0 ? initialState : 'signIn';
348
+ // We can stop manual change detection if we're back to the initial state
349
+ if (route === initialStateWithDefault) {
350
+ _this.isHandlingHubEvent = false;
351
+ }
352
+ }
317
353
  if (!_this.hasInitialized && route === 'setup') {
318
354
  _this.authenticator.send({
319
355
  type: 'INIT',
@@ -345,6 +381,8 @@
345
381
  AuthenticatorComponent.prototype.ngOnDestroy = function () {
346
382
  if (this.unsubscribeMachine)
347
383
  this.unsubscribeMachine();
384
+ if (this.unsubscribeHub)
385
+ this.unsubscribeHub();
348
386
  };
349
387
  Object.defineProperty(AuthenticatorComponent.prototype, "context", {
350
388
  /**
@@ -398,7 +436,8 @@
398
436
  ];
399
437
  AuthenticatorComponent.ctorParameters = function () { return [
400
438
  { type: AuthenticatorService },
401
- { type: CustomComponentsService }
439
+ { type: CustomComponentsService },
440
+ { type: i0.ChangeDetectorRef }
402
441
  ]; };
403
442
  AuthenticatorComponent.propDecorators = {
404
443
  formFields: [{ type: i0.Input }],
@@ -1195,7 +1234,7 @@
1195
1234
  _g.secretKey = _j.sent();
1196
1235
  issuer = (_c = (_b = (_a = this.formOverrides) === null || _a === void 0 ? void 0 : _a['QR']) === null || _b === void 0 ? void 0 : _b.totpIssuer) !== null && _c !== void 0 ? _c : 'AWSCognito';
1197
1236
  username = (_f = (_e = (_d = this.formOverrides) === null || _d === void 0 ? void 0 : _d['QR']) === null || _e === void 0 ? void 0 : _e.totpUsername) !== null && _f !== void 0 ? _f : user.username;
1198
- totpCode = "otpauth://totp/" + issuer + ":" + username + "?secret=" + this.secretKey + "&issuer=" + issuer;
1237
+ totpCode = encodeURI("otpauth://totp/" + issuer + ":" + username + "?secret=" + this.secretKey + "&issuer=" + issuer);
1199
1238
  logger.info('totp code was generated:', totpCode);
1200
1239
  _h = this;
1201
1240
  return [4 /*yield*/, QRCode__default["default"].toDataURL(totpCode)];