@aws-amplify/ui-angular 2.0.6 → 2.0.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 (23) hide show
  1. package/README.md +1 -1
  2. package/aws-amplify-ui-angular.d.ts +15 -14
  3. package/aws-amplify-ui-angular.metadata.json +1 -1
  4. package/bundles/aws-amplify-ui-angular.umd.js +86 -44
  5. package/bundles/aws-amplify-ui-angular.umd.js.map +1 -1
  6. package/bundles/aws-amplify-ui-angular.umd.min.js +1 -1
  7. package/bundles/aws-amplify-ui-angular.umd.min.js.map +1 -1
  8. package/esm2015/aws-amplify-ui-angular.js +16 -15
  9. package/esm2015/lib/components/authenticator/authenticator.module.js +4 -1
  10. package/esm2015/lib/components/authenticator/components/force-new-password/force-new-password-form-fields/force-new-password-form-fields.component.js +30 -0
  11. package/esm2015/lib/components/authenticator/components/force-new-password/force-new-password.component.js +2 -2
  12. package/esm2015/lib/components/authenticator/components/form-field/form-field.component.js +1 -6
  13. package/esm2015/lib/components/authenticator/components/index.js +2 -1
  14. package/esm2015/lib/components/authenticator/components/setup-totp/setup-totp.component.js +10 -4
  15. package/esm2015/lib/components/authenticator/components/sign-in/sign-in.component.js +7 -4
  16. package/esm2015/lib/services/authenticator.service.js +19 -14
  17. package/fesm2015/aws-amplify-ui-angular.js +62 -24
  18. package/fesm2015/aws-amplify-ui-angular.js.map +1 -1
  19. package/lib/components/authenticator/components/force-new-password/force-new-password-form-fields/force-new-password-form-fields.component.d.ts +8 -0
  20. package/lib/components/authenticator/components/index.d.ts +1 -0
  21. package/lib/components/authenticator/components/setup-totp/setup-totp.component.d.ts +3 -0
  22. package/lib/services/authenticator.service.d.ts +2 -1
  23. package/package.json +4 -4
@@ -88,26 +88,31 @@
88
88
  AuthenticatorService.prototype.startMachine = function (_b) {
89
89
  var _this = this;
90
90
  var initialState = _b.initialState, loginMechanisms = _b.loginMechanisms, services = _b.services, signUpAttributes = _b.signUpAttributes, socialProviders = _b.socialProviders;
91
- var machine = ui.createAuthenticatorMachine({
92
- initialState: initialState,
93
- loginMechanisms: loginMechanisms,
94
- services: services,
95
- signUpAttributes: signUpAttributes,
96
- socialProviders: socialProviders,
91
+ var machine = ui.createAuthenticatorMachine();
92
+ var authService = xstate.interpret(machine).start();
93
+ authService.send({
94
+ type: 'INIT',
95
+ data: {
96
+ initialState: initialState,
97
+ loginMechanisms: loginMechanisms,
98
+ socialProviders: socialProviders,
99
+ signUpAttributes: signUpAttributes,
100
+ services: services,
101
+ },
97
102
  });
98
- var authService = xstate.interpret(machine, {
99
- devTools: process.env.NODE_ENV === 'development',
100
- }).start();
101
- this._subscription = authService.subscribe(function (state) {
103
+ this._machineSubscription = authService.subscribe(function (state) {
102
104
  _this._authState = state;
103
105
  _this._facade = ui.getServiceContextFacade(state);
104
106
  });
107
+ this._hubSubscription = ui.listenToAuthHub(authService.send);
105
108
  this._sendEventAliases = ui.getSendEventAliases(authService.send);
106
109
  this._authService = authService;
107
110
  };
108
111
  AuthenticatorService.prototype.ngOnDestroy = function () {
109
- if (this._subscription)
110
- this._subscription.unsubscribe();
112
+ if (this._machineSubscription)
113
+ this._machineSubscription.unsubscribe();
114
+ if (this._hubSubscription)
115
+ this._hubSubscription();
111
116
  };
112
117
  Object.defineProperty(AuthenticatorService.prototype, "error", {
113
118
  /**
@@ -703,7 +708,7 @@
703
708
  ForceNewPasswordComponent.decorators = [
704
709
  { type: i0.Component, args: [{
705
710
  selector: 'amplify-force-new-password',
706
- template: "<div data-amplify-container>\n <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=\"force-new-password-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ this.headerText }}</h3>\n </amplify-slot>\n <amplify-form-field\n name=\"password\"\n type=\"password\"\n autocomplete=\"new-password\"\n ></amplify-form-field>\n\n <amplify-form-field\n name=\"confirm_password\"\n label=\"Confirm Password\"\n type=\"password\"\n autocomplete=\"new-password\"\n ></amplify-form-field>\n\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ changePasswordText }}\n </button>\n\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.toSignIn()\"\n >\n {{ backToSignInText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"force-new-password-footer\" [context]=\"context\">\n </amplify-slot>\n </form>\n</div>\n"
711
+ template: "<div data-amplify-container>\n <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=\"force-new-password-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ this.headerText }}</h3>\n </amplify-slot>\n <amplify-form-field\n name=\"password\"\n type=\"password\"\n autocomplete=\"new-password\"\n ></amplify-form-field>\n\n <amplify-form-field\n name=\"confirm_password\"\n label=\"Confirm Password\"\n type=\"password\"\n autocomplete=\"new-password\"\n ></amplify-form-field>\n <amplify-slot name=\"force-new-form-fields\" [context]=\"context\">\n <amplify-force-new-password-form-fields></amplify-force-new-password-form-fields>\n </amplify-slot>\n\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ changePasswordText }}\n </button>\n\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.toSignIn()\"\n >\n {{ backToSignInText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"force-new-password-footer\" [context]=\"context\">\n </amplify-slot>\n </form>\n</div>\n"
707
712
  },] }
708
713
  ];
709
714
  ForceNewPasswordComponent.ctorParameters = function () { return [
@@ -714,6 +719,34 @@
714
719
  headerText: [{ type: i0.Input }]
715
720
  };
716
721
 
722
+ var ForceNewPasswordFormFieldsComponent = /** @class */ (function () {
723
+ function ForceNewPasswordFormFieldsComponent(authenticator) {
724
+ this.authenticator = authenticator;
725
+ }
726
+ ForceNewPasswordFormFieldsComponent.prototype.ngOnInit = function () {
727
+ var state = this.authenticator.authState;
728
+ var actorContext = ui.getActorContext(state);
729
+ var requiredAttributes = actorContext.requiredAttributes;
730
+ this.fieldNames = requiredAttributes.filter(function (fieldName) {
731
+ var hasDefaultField = !!ui.authInputAttributes[fieldName];
732
+ if (!hasDefaultField) {
733
+ console.debug("Authenticator does not have a default implementation for " + fieldName + ". Customize Authenticator.SignUp.FormFields to add your own.");
734
+ }
735
+ return hasDefaultField;
736
+ });
737
+ };
738
+ return ForceNewPasswordFormFieldsComponent;
739
+ }());
740
+ ForceNewPasswordFormFieldsComponent.decorators = [
741
+ { type: i0.Component, args: [{
742
+ selector: 'amplify-force-new-password-form-fields',
743
+ template: "<div class=\"amplify-flex\" style=\"flex-direction: column\" data-amplify-fieldset>\n <ng-container *ngFor=\"let field of fieldNames\">\n <amplify-form-field\n [name]=\"field\"\n [labelHidden]=\"false\"\n ></amplify-form-field>\n </ng-container>\n</div>\n"
744
+ },] }
745
+ ];
746
+ ForceNewPasswordFormFieldsComponent.ctorParameters = function () { return [
747
+ { type: AuthenticatorService }
748
+ ]; };
749
+
717
750
  var getAttributeMap = function () { return ui.authInputAttributes; };
718
751
 
719
752
  /**
@@ -741,11 +774,6 @@
741
774
  var state = this.authenticator.authState;
742
775
  var country_code = ui.getActorContext(state).country_code;
743
776
  this.defaultCountryCode = country_code;
744
- // TODO: remove this side-effect
745
- this.authenticator.updateForm({
746
- name: 'country_code',
747
- value: country_code,
748
- });
749
777
  }
750
778
  };
751
779
  Object.defineProperty(FormFieldComponent.prototype, "attributeMap", {
@@ -1190,6 +1218,8 @@
1190
1218
  this.dataAttr = '';
1191
1219
  this.headerText = ui.translate('Setup TOTP');
1192
1220
  this.qrCodeSource = '';
1221
+ this.secretKey = '';
1222
+ this.copyTextLabel = ui.translate('COPY');
1193
1223
  // translated texts
1194
1224
  this.backToSignInText = ui.translate('Back to Sign In');
1195
1225
  this.confirmText = ui.translate('Confirm');
@@ -1206,29 +1236,30 @@
1206
1236
  });
1207
1237
  SetupTotpComponent.prototype.generateQRCode = function () {
1208
1238
  return __awaiter(this, void 0, void 0, function () {
1209
- var state, actorContext, user, secretKey, issuer, totpCode, _a, err_1;
1210
- return __generator(this, function (_b) {
1211
- switch (_b.label) {
1239
+ var state, actorContext, user, _a, issuer, totpCode, _b, err_1;
1240
+ return __generator(this, function (_c) {
1241
+ switch (_c.label) {
1212
1242
  case 0:
1213
1243
  state = this.authenticator.authState;
1214
1244
  actorContext = ui.getActorContext(state);
1215
1245
  user = actorContext.user;
1216
- _b.label = 1;
1246
+ _c.label = 1;
1217
1247
  case 1:
1218
- _b.trys.push([1, 4, , 5]);
1248
+ _c.trys.push([1, 4, , 5]);
1249
+ _a = this;
1219
1250
  return [4 /*yield*/, awsAmplify.Auth.setupTOTP(user)];
1220
1251
  case 2:
1221
- secretKey = _b.sent();
1252
+ _a.secretKey = _c.sent();
1222
1253
  issuer = 'AWSCognito';
1223
- totpCode = "otpauth://totp/" + issuer + ":" + user.username + "?secret=" + secretKey + "&issuer=" + issuer;
1254
+ totpCode = "otpauth://totp/" + issuer + ":" + user.username + "?secret=" + this.secretKey + "&issuer=" + issuer;
1224
1255
  logger.info('totp code was generated:', totpCode);
1225
- _a = this;
1256
+ _b = this;
1226
1257
  return [4 /*yield*/, QRCode__default["default"].toDataURL(totpCode)];
1227
1258
  case 3:
1228
- _a.qrCodeSource = _b.sent();
1259
+ _b.qrCodeSource = _c.sent();
1229
1260
  return [3 /*break*/, 5];
1230
1261
  case 4:
1231
- err_1 = _b.sent();
1262
+ err_1 = _c.sent();
1232
1263
  logger.error(err_1);
1233
1264
  return [3 /*break*/, 5];
1234
1265
  case 5: return [2 /*return*/];
@@ -1245,12 +1276,16 @@
1245
1276
  event.preventDefault();
1246
1277
  this.authenticator.submitForm();
1247
1278
  };
1279
+ SetupTotpComponent.prototype.copyText = function () {
1280
+ navigator.clipboard.writeText(this.secretKey);
1281
+ this.copyTextLabel = ui.translate('COPIED');
1282
+ };
1248
1283
  return SetupTotpComponent;
1249
1284
  }());
1250
1285
  SetupTotpComponent.decorators = [
1251
1286
  { type: i0.Component, args: [{
1252
1287
  selector: 'amplify-setup-totp',
1253
- template: "<div data-amplify-container>\n <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=\"setup-totp-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ this.headerText }}</h3>\n </amplify-slot>\n <p *ngIf=\"!qrCodeSource\">Loading...</p>\n <img\n *ngIf=\"qrCodeSource\"\n [src]=\"qrCodeSource\"\n alt=\"qr code\"\n data-amplify-qrcode\n width=\"228\"\n height=\"228\"\n />\n <amplify-form-field\n name=\"confirmation_code\"\n label=\"Code *\"\n type=\"text\"\n autocomplete=\"one-time-code\"\n ></amplify-form-field>\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ confirmText }}\n </button>\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.toSignIn()\"\n >\n {{ backToSignInText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"setup-totp-footer\" [context]=\"context\"> </amplify-slot>\n </form>\n</div>\n"
1288
+ template: "<div data-amplify-container>\n <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=\"setup-totp-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ this.headerText }}</h3>\n </amplify-slot>\n <p *ngIf=\"!qrCodeSource\">Loading...</p>\n <img\n *ngIf=\"qrCodeSource\"\n [src]=\"qrCodeSource\"\n alt=\"qr code\"\n data-amplify-qrcode\n width=\"228\"\n height=\"228\"\n />\n <div class=\"amplify-flex\" data-amplify-copy>\n <div>{{ secretKey }}</div>\n <div data-amplify-copy-svg (click)=\"copyText()\">\n <div data-amplify-copy-tooltip>{{ copyTextLabel }}</div>\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM15 5H8C6.9 5 6.01 5.9 6.01 7L6 21C6 22.1 6.89 23 7.99 23H19C20.1 23 21 22.1 21 21V11L15 5ZM8 21V7H14V12H19V21H8Z\"\n fill=\"black\"\n />\n </svg>\n </div>\n </div>\n\n <amplify-form-field\n name=\"confirmation_code\"\n label=\"Code *\"\n type=\"text\"\n autocomplete=\"one-time-code\"\n ></amplify-form-field>\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ confirmText }}\n </button>\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.toSignIn()\"\n >\n {{ backToSignInText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"setup-totp-footer\" [context]=\"context\"> </amplify-slot>\n </form>\n</div>\n"
1254
1289
  },] }
1255
1290
  ];
1256
1291
  SetupTotpComponent.ctorParameters = function () { return [
@@ -1265,7 +1300,10 @@
1265
1300
  this.authenticator = authenticator;
1266
1301
  this.dataAttr = '';
1267
1302
  // translated phrases
1268
- this.forgotPasswordText = ui.translate('Forgot your password? ');
1303
+ // Support backwards compatibility for legacy key with trailing space
1304
+ this.forgotPasswordText = !ui.hasTranslation('Forgot your password? ')
1305
+ ? ui.translate('Forgot your password?')
1306
+ : ui.translate('Forgot your password? ');
1269
1307
  this.signInButtonText = ui.translate('Sign in');
1270
1308
  }
1271
1309
  Object.defineProperty(SignInComponent.prototype, "context", {
@@ -1794,6 +1832,7 @@
1794
1832
  FederatedSignInButtonComponent,
1795
1833
  FederatedSignInComponent,
1796
1834
  ForceNewPasswordComponent,
1835
+ ForceNewPasswordFormFieldsComponent,
1797
1836
  FormFieldComponent,
1798
1837
  PasswordFieldComponent,
1799
1838
  PhoneNumberFieldComponent,
@@ -1815,6 +1854,7 @@
1815
1854
  AuthenticatorComponent,
1816
1855
  CheckboxComponent,
1817
1856
  SignUpFormFieldsComponent,
1857
+ ForceNewPasswordFormFieldsComponent,
1818
1858
  TextFieldComponent,
1819
1859
  ],
1820
1860
  },] }
@@ -1843,6 +1883,7 @@
1843
1883
  exports.FederatedSignInButtonComponent = FederatedSignInButtonComponent;
1844
1884
  exports.FederatedSignInComponent = FederatedSignInComponent;
1845
1885
  exports.ForceNewPasswordComponent = ForceNewPasswordComponent;
1886
+ exports.ForceNewPasswordFormFieldsComponent = ForceNewPasswordFormFieldsComponent;
1846
1887
  exports.FormFieldComponent = FormFieldComponent;
1847
1888
  exports.PasswordFieldComponent = PasswordFieldComponent;
1848
1889
  exports.PhoneNumberFieldComponent = PhoneNumberFieldComponent;
@@ -1860,6 +1901,7 @@
1860
1901
  exports.getAttributeMap = getAttributeMap;
1861
1902
  exports["ɵa"] = AmplifySlotComponent;
1862
1903
  exports["ɵb"] = AuthenticatorComponent;
1904
+ exports["ɵba"] = VerifyUserComponent;
1863
1905
  exports["ɵc"] = ButtonComponent;
1864
1906
  exports["ɵd"] = CheckboxComponent;
1865
1907
  exports["ɵe"] = ConfirmResetPasswordComponent;
@@ -1870,20 +1912,20 @@
1870
1912
  exports["ɵj"] = FederatedSignInButtonComponent;
1871
1913
  exports["ɵk"] = FederatedSignInComponent;
1872
1914
  exports["ɵl"] = ForceNewPasswordComponent;
1873
- exports["ɵm"] = FormFieldComponent;
1874
- exports["ɵn"] = PasswordFieldComponent;
1875
- exports["ɵo"] = PhoneNumberFieldComponent;
1876
- exports["ɵp"] = ResetPasswordComponent;
1877
- exports["ɵq"] = SelectComponent;
1878
- exports["ɵr"] = SetupTotpComponent;
1879
- exports["ɵs"] = SignInComponent;
1880
- exports["ɵt"] = SignUpComponent;
1881
- exports["ɵu"] = SignUpFormFieldsComponent;
1882
- exports["ɵv"] = TabItemComponent;
1883
- exports["ɵw"] = TabsComponent;
1884
- exports["ɵx"] = TextFieldComponent;
1885
- exports["ɵy"] = UserNameAliasComponent;
1886
- exports["ɵz"] = VerifyUserComponent;
1915
+ exports["ɵm"] = ForceNewPasswordFormFieldsComponent;
1916
+ exports["ɵn"] = FormFieldComponent;
1917
+ exports["ɵo"] = PasswordFieldComponent;
1918
+ exports["ɵp"] = PhoneNumberFieldComponent;
1919
+ exports["ɵq"] = ResetPasswordComponent;
1920
+ exports["ɵr"] = SelectComponent;
1921
+ exports["ɵs"] = SetupTotpComponent;
1922
+ exports["ɵt"] = SignInComponent;
1923
+ exports["ɵu"] = SignUpComponent;
1924
+ exports["ɵv"] = SignUpFormFieldsComponent;
1925
+ exports["ɵw"] = TabItemComponent;
1926
+ exports["ɵx"] = TabsComponent;
1927
+ exports["ɵy"] = TextFieldComponent;
1928
+ exports["ɵz"] = UserNameAliasComponent;
1887
1929
 
1888
1930
  Object.defineProperty(exports, '__esModule', { value: true });
1889
1931