@aws-amplify/ui-angular 2.3.14 → 2.4.1

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 (24) hide show
  1. package/aws-amplify-ui-angular.metadata.json +1 -1
  2. package/bundles/aws-amplify-ui-angular.umd.js +54 -8
  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/confirm-reset-password/amplify-confirm-reset-password.component.js +11 -4
  8. package/esm2015/lib/components/authenticator/components/setup-totp/setup-totp.component.js +2 -2
  9. package/esm2015/lib/services/authenticator.service.js +6 -5
  10. package/fesm2015/aws-amplify-ui-angular.js +52 -10
  11. package/fesm2015/aws-amplify-ui-angular.js.map +1 -1
  12. package/lib/components/authenticator/components/authenticator/authenticator.component.d.ts +7 -2
  13. package/lib/components/authenticator/components/confirm-reset-password/amplify-confirm-reset-password.component.d.ts +8 -1
  14. package/lib/components/authenticator/components/confirm-sign-in/confirm-sign-in.component.d.ts +2 -0
  15. package/lib/components/authenticator/components/confirm-sign-up/confirm-sign-up.component.d.ts +2 -0
  16. package/lib/components/authenticator/components/confirm-verify-user/amplify-confirm-verify-user.component.d.ts +2 -0
  17. package/lib/components/authenticator/components/force-new-password/force-new-password.component.d.ts +2 -0
  18. package/lib/components/authenticator/components/reset-password/reset-password.component.d.ts +2 -0
  19. package/lib/components/authenticator/components/setup-totp/setup-totp.component.d.ts +2 -0
  20. package/lib/components/authenticator/components/sign-in/sign-in.component.d.ts +2 -0
  21. package/lib/components/authenticator/components/sign-up/sign-up.component.d.ts +2 -0
  22. package/lib/components/authenticator/components/verify-user/verify-user.component.d.ts +2 -0
  23. package/lib/services/authenticator.service.d.ts +3 -1
  24. 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 }],
@@ -418,9 +457,16 @@
418
457
  this.dataAttr = '';
419
458
  this.headerText = ui.translate('Reset your password');
420
459
  // translated strings
421
- this.sendCodeText = ui.translate('Send Code');
422
460
  this.backToSignInText = ui.translate('Back to Sign In');
423
461
  this.resendCodeText = ui.translate('Resend Code');
462
+ /**
463
+ * Support backwards compatibility for erroneous 'Send Code' text
464
+ * See https://github.com/aws-amplify/amplify-ui/issues/1784
465
+ * TODO: Remove support for 'Send Code' translation in next Major release
466
+ */
467
+ this.submitText = ui.hasTranslation('Submit')
468
+ ? ui.translate('Submit')
469
+ : ui.translate('Send Code');
424
470
  }
425
471
  Object.defineProperty(ConfirmResetPasswordComponent.prototype, "context", {
426
472
  get: function () {
@@ -443,7 +489,7 @@
443
489
  ConfirmResetPasswordComponent.decorators = [
444
490
  { type: i0.Component, args: [{
445
491
  selector: 'amplify-confirm-reset-password',
446
- template: "<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot name=\"confirm-reset-password-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ headerText }}</h3>\n </amplify-slot>\n\n <amplify-base-form-fields\n route=\"confirmResetPassword\"\n ></amplify-base-form-fields>\n\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ sendCodeText }}\n </button>\n\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n type=\"button\"\n (click)=\"authenticator.resendCode()\"\n >\n {{ resendCodeText }}\n </button>\n\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"confirm-reset-password-footer\" [context]=\"context\">\n </amplify-slot>\n</form>\n"
492
+ template: "<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot name=\"confirm-reset-password-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ headerText }}</h3>\n </amplify-slot>\n\n <amplify-base-form-fields\n route=\"confirmResetPassword\"\n ></amplify-base-form-fields>\n\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ submitText }}\n </button>\n\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n type=\"button\"\n (click)=\"authenticator.resendCode()\"\n >\n {{ resendCodeText }}\n </button>\n\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"confirm-reset-password-footer\" [context]=\"context\">\n </amplify-slot>\n</form>\n"
447
493
  },] }
448
494
  ];
449
495
  ConfirmResetPasswordComponent.ctorParameters = function () { return [
@@ -1188,7 +1234,7 @@
1188
1234
  _g.secretKey = _j.sent();
1189
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';
1190
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;
1191
- totpCode = "otpauth://totp/" + issuer + ":" + username + "?secret=" + this.secretKey + "&issuer=" + issuer;
1237
+ totpCode = encodeURI("otpauth://totp/" + issuer + ":" + username + "?secret=" + this.secretKey + "&issuer=" + issuer);
1192
1238
  logger.info('totp code was generated:', totpCode);
1193
1239
  _h = this;
1194
1240
  return [4 /*yield*/, QRCode__default["default"].toDataURL(totpCode)];