@aws-amplify/ui-angular 2.0.5 → 2.0.9

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.
@@ -88,16 +88,18 @@
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
103
  this._subscription = authService.subscribe(function (state) {
102
104
  _this._authState = state;
103
105
  _this._facade = ui.getServiceContextFacade(state);
@@ -741,11 +743,6 @@
741
743
  var state = this.authenticator.authState;
742
744
  var country_code = ui.getActorContext(state).country_code;
743
745
  this.defaultCountryCode = country_code;
744
- // TODO: remove this side-effect
745
- this.authenticator.updateForm({
746
- name: 'country_code',
747
- value: country_code,
748
- });
749
746
  }
750
747
  };
751
748
  Object.defineProperty(FormFieldComponent.prototype, "attributeMap", {
@@ -1190,6 +1187,8 @@
1190
1187
  this.dataAttr = '';
1191
1188
  this.headerText = ui.translate('Setup TOTP');
1192
1189
  this.qrCodeSource = '';
1190
+ this.secretKey = '';
1191
+ this.copyTextLabel = ui.translate('COPY');
1193
1192
  // translated texts
1194
1193
  this.backToSignInText = ui.translate('Back to Sign In');
1195
1194
  this.confirmText = ui.translate('Confirm');
@@ -1206,29 +1205,30 @@
1206
1205
  });
1207
1206
  SetupTotpComponent.prototype.generateQRCode = function () {
1208
1207
  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) {
1208
+ var state, actorContext, user, _a, issuer, totpCode, _b, err_1;
1209
+ return __generator(this, function (_c) {
1210
+ switch (_c.label) {
1212
1211
  case 0:
1213
1212
  state = this.authenticator.authState;
1214
1213
  actorContext = ui.getActorContext(state);
1215
1214
  user = actorContext.user;
1216
- _b.label = 1;
1215
+ _c.label = 1;
1217
1216
  case 1:
1218
- _b.trys.push([1, 4, , 5]);
1217
+ _c.trys.push([1, 4, , 5]);
1218
+ _a = this;
1219
1219
  return [4 /*yield*/, awsAmplify.Auth.setupTOTP(user)];
1220
1220
  case 2:
1221
- secretKey = _b.sent();
1221
+ _a.secretKey = _c.sent();
1222
1222
  issuer = 'AWSCognito';
1223
- totpCode = "otpauth://totp/" + issuer + ":" + user.username + "?secret=" + secretKey + "&issuer=" + issuer;
1223
+ totpCode = "otpauth://totp/" + issuer + ":" + user.username + "?secret=" + this.secretKey + "&issuer=" + issuer;
1224
1224
  logger.info('totp code was generated:', totpCode);
1225
- _a = this;
1225
+ _b = this;
1226
1226
  return [4 /*yield*/, QRCode__default["default"].toDataURL(totpCode)];
1227
1227
  case 3:
1228
- _a.qrCodeSource = _b.sent();
1228
+ _b.qrCodeSource = _c.sent();
1229
1229
  return [3 /*break*/, 5];
1230
1230
  case 4:
1231
- err_1 = _b.sent();
1231
+ err_1 = _c.sent();
1232
1232
  logger.error(err_1);
1233
1233
  return [3 /*break*/, 5];
1234
1234
  case 5: return [2 /*return*/];
@@ -1245,12 +1245,16 @@
1245
1245
  event.preventDefault();
1246
1246
  this.authenticator.submitForm();
1247
1247
  };
1248
+ SetupTotpComponent.prototype.copyText = function () {
1249
+ navigator.clipboard.writeText(this.secretKey);
1250
+ this.copyTextLabel = ui.translate('COPIED');
1251
+ };
1248
1252
  return SetupTotpComponent;
1249
1253
  }());
1250
1254
  SetupTotpComponent.decorators = [
1251
1255
  { type: i0.Component, args: [{
1252
1256
  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"
1257
+ 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
1258
  },] }
1255
1259
  ];
1256
1260
  SetupTotpComponent.ctorParameters = function () { return [
@@ -1265,7 +1269,10 @@
1265
1269
  this.authenticator = authenticator;
1266
1270
  this.dataAttr = '';
1267
1271
  // translated phrases
1268
- this.forgotPasswordText = ui.translate('Forgot your password? ');
1272
+ // Support backwards compatibility for legacy key with trailing space
1273
+ this.forgotPasswordText = !ui.hasTranslation('Forgot your password? ')
1274
+ ? ui.translate('Forgot your password?')
1275
+ : ui.translate('Forgot your password? ');
1269
1276
  this.signInButtonText = ui.translate('Sign in');
1270
1277
  }
1271
1278
  Object.defineProperty(SignInComponent.prototype, "context", {