@stytch/vanilla-js 5.6.1 → 5.7.0

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.
@@ -204,6 +204,7 @@ var StytchEventType;
204
204
  StytchEventType["B2BDiscoveryOrganizationsCreate"] = "B2B_DISCOVERY_ORGANIZATIONS_CREATE";
205
205
  StytchEventType["B2BDiscoveryIntermediateSessionExchange"] = "B2B_DISCOVERY_INTERMEDIATE_SESSION_EXCHANGE";
206
206
  StytchEventType["B2BPasswordAuthenticate"] = "B2B_PASSWORD_AUTHENTICATE";
207
+ StytchEventType["B2BPasswordDiscoveryAuthenticate"] = "B2B_PASSWORD_DISCOVERY_AUTHENTICATE";
207
208
  StytchEventType["B2BPasswordResetByEmailStart"] = "B2B_PASSWORD_RESET_BY_EMAIL_START";
208
209
  StytchEventType["B2BPasswordResetByEmail"] = "B2B_PASSWORD_RESET_BY_EMAIL";
209
210
  StytchEventType["B2BPasswordResetBySession"] = "B2B_PASSWORD_RESET_BY_SESSION";
@@ -212,6 +213,8 @@ var StytchEventType;
212
213
  StytchEventType["B2BTOTPCreate"] = "B2B_TOTP_CREATE";
213
214
  StytchEventType["B2BTOTPAuthenticate"] = "B2B_TOTP_AUTHENTICATE";
214
215
  StytchEventType["B2BRecoveryCodesRecover"] = "B2B_RECOVERY_CODES_RECOVER";
216
+ StytchEventType["B2BPasswordDiscoveryResetStart"] = "B2B_PASSWORD_DISCOVERY_RESET_BY_EMAIL_START";
217
+ StytchEventType["B2BDiscoveryPasswordReset"] = "B2B_PASSWORD_DISCOVERY_RESET_BY_EMAIL";
215
218
  })(StytchEventType || (StytchEventType = {}));
216
219
  var RNUIProducts;
217
220
  (function (RNUIProducts) {
@@ -4227,6 +4230,7 @@ var DefaultDynamicConfig = Promise.resolve({
4227
4230
  });
4228
4231
  var HeadlessB2BPasswordsClient = /*#__PURE__*/function () {
4229
4232
  function HeadlessB2BPasswordsClient(_networkClient, _subscriptionService, _pkceManager) {
4233
+ var _this19 = this;
4230
4234
  var _config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DefaultDynamicConfig;
4231
4235
  var dfpProtectedAuth = arguments.length > 4 ? arguments[4] : undefined;
4232
4236
  _classCallCheck(this, HeadlessB2BPasswordsClient);
@@ -4235,110 +4239,267 @@ var HeadlessB2BPasswordsClient = /*#__PURE__*/function () {
4235
4239
  this._pkceManager = _pkceManager;
4236
4240
  this._config = _config;
4237
4241
  this.dfpProtectedAuth = dfpProtectedAuth;
4242
+ this.discovery = {
4243
+ resetByEmailStart: function resetByEmailStart(options) {
4244
+ return __awaiter$1(_this19, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee119() {
4245
+ var code_challenge, _yield$this$dfpProtec24, dfp_telemetry_id, captcha_token;
4246
+ return _regeneratorRuntime().wrap(function _callee119$(_context119) {
4247
+ while (1) switch (_context119.prev = _context119.next) {
4248
+ case 0:
4249
+ validate('stytch.passwords.discovery.resetByEmailStart').isString('email', options.email_address).isOptionalString('login_redirect_url', options.discovery_redirect_url).isOptionalString('reset_password_redirect_url', options.reset_password_redirect_url).isOptionalString('reset_password_template_id', options.reset_password_template_id).isOptionalNumber('reset_password_expiration_minutes', options.reset_password_expiration_minutes);
4250
+ _context119.next = 3;
4251
+ return this.getCodeChallenge();
4252
+ case 3:
4253
+ code_challenge = _context119.sent;
4254
+ _context119.next = 6;
4255
+ return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4256
+ case 6:
4257
+ _yield$this$dfpProtec24 = _context119.sent;
4258
+ dfp_telemetry_id = _yield$this$dfpProtec24.dfp_telemetry_id;
4259
+ captcha_token = _yield$this$dfpProtec24.captcha_token;
4260
+ return _context119.abrupt("return", this._networkClient.retriableFetchSDK({
4261
+ url: '/b2b/passwords/discovery/reset/start',
4262
+ method: 'POST',
4263
+ body: {
4264
+ email_address: options.email_address,
4265
+ discovery_redirect_url: options.discovery_redirect_url,
4266
+ reset_password_redirect_url: options.reset_password_redirect_url,
4267
+ reset_password_expiration_minutes: options.reset_password_expiration_minutes,
4268
+ reset_password_template_id: options.reset_password_template_id,
4269
+ code_challenge: code_challenge,
4270
+ captcha_token: captcha_token,
4271
+ dfp_telemetry_id: dfp_telemetry_id
4272
+ },
4273
+ retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
4274
+ }));
4275
+ case 10:
4276
+ case "end":
4277
+ return _context119.stop();
4278
+ }
4279
+ }, _callee119, this);
4280
+ }));
4281
+ },
4282
+ resetByEmail: function resetByEmail(options) {
4283
+ return __awaiter$1(_this19, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee120() {
4284
+ var _yield$this$dfpProtec25, dfp_telemetry_id, captcha_token, pkPair, code_verifier, resp;
4285
+ return _regeneratorRuntime().wrap(function _callee120$(_context120) {
4286
+ while (1) switch (_context120.prev = _context120.next) {
4287
+ case 0:
4288
+ validate('stytch.passwords.discovery.resetByEmail').isString('password_reset_token', options.password_reset_token).isString('password', options.password);
4289
+ _context120.next = 3;
4290
+ return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4291
+ case 3:
4292
+ _yield$this$dfpProtec25 = _context120.sent;
4293
+ dfp_telemetry_id = _yield$this$dfpProtec25.dfp_telemetry_id;
4294
+ captcha_token = _yield$this$dfpProtec25.captcha_token;
4295
+ _context120.next = 8;
4296
+ return this._pkceManager.getPKPair();
4297
+ case 8:
4298
+ pkPair = _context120.sent;
4299
+ code_verifier = pkPair === null || pkPair === void 0 ? void 0 : pkPair.code_verifier;
4300
+ _context120.t0 = this._networkClient;
4301
+ _context120.t1 = options.password_reset_token;
4302
+ _context120.t2 = options.password;
4303
+ _context120.t3 = captcha_token;
4304
+ _context120.t4 = dfp_telemetry_id;
4305
+ _context120.t5 = code_verifier;
4306
+ _context120.next = 18;
4307
+ return this._subscriptionService.getIntermediateSessionToken();
4308
+ case 18:
4309
+ _context120.t6 = _context120.sent;
4310
+ if (_context120.t6) {
4311
+ _context120.next = 21;
4312
+ break;
4313
+ }
4314
+ _context120.t6 = undefined;
4315
+ case 21:
4316
+ _context120.t7 = _context120.t6;
4317
+ _context120.t8 = {
4318
+ password_reset_token: _context120.t1,
4319
+ password: _context120.t2,
4320
+ captcha_token: _context120.t3,
4321
+ dfp_telemetry_id: _context120.t4,
4322
+ code_verifier: _context120.t5,
4323
+ intermediate_session_token: _context120.t7
4324
+ };
4325
+ _context120.t9 = this.dfpProtectedAuth.retryWithCaptchaAndDFP;
4326
+ _context120.t10 = {
4327
+ url: '/b2b/passwords/discovery/reset',
4328
+ method: 'POST',
4329
+ body: _context120.t8,
4330
+ retryCallback: _context120.t9
4331
+ };
4332
+ _context120.next = 27;
4333
+ return _context120.t0.retriableFetchSDK.call(_context120.t0, _context120.t10);
4334
+ case 27:
4335
+ resp = _context120.sent;
4336
+ this._pkceManager.clearPKPair();
4337
+ this._subscriptionService.updateStateAndTokens({
4338
+ state: null,
4339
+ session_token: null,
4340
+ session_jwt: null,
4341
+ intermediate_session_token: resp.intermediate_session_token
4342
+ });
4343
+ return _context120.abrupt("return", resp);
4344
+ case 31:
4345
+ case "end":
4346
+ return _context120.stop();
4347
+ }
4348
+ }, _callee120, this);
4349
+ }));
4350
+ },
4351
+ authenticate: function authenticate(options) {
4352
+ return __awaiter$1(_this19, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee121() {
4353
+ var pkPair, code_verifier, _yield$this$dfpProtec26, dfp_telemetry_id, captcha_token, resp;
4354
+ return _regeneratorRuntime().wrap(function _callee121$(_context121) {
4355
+ while (1) switch (_context121.prev = _context121.next) {
4356
+ case 0:
4357
+ validate('stytch.passwords.discovery.authenticate').isString('password', options.password).isString('email_address', options.email_address);
4358
+ _context121.next = 3;
4359
+ return this._pkceManager.getPKPair();
4360
+ case 3:
4361
+ pkPair = _context121.sent;
4362
+ code_verifier = pkPair === null || pkPair === void 0 ? void 0 : pkPair.code_verifier;
4363
+ _context121.next = 7;
4364
+ return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4365
+ case 7:
4366
+ _yield$this$dfpProtec26 = _context121.sent;
4367
+ dfp_telemetry_id = _yield$this$dfpProtec26.dfp_telemetry_id;
4368
+ captcha_token = _yield$this$dfpProtec26.captcha_token;
4369
+ _context121.next = 12;
4370
+ return this._networkClient.retriableFetchSDK({
4371
+ url: '/b2b/passwords/discovery/authenticate',
4372
+ method: 'POST',
4373
+ body: {
4374
+ email_address: options.email_address,
4375
+ password: options.password,
4376
+ captcha_token: captcha_token,
4377
+ dfp_telemetry_id: dfp_telemetry_id,
4378
+ code_verifier: code_verifier
4379
+ },
4380
+ retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
4381
+ });
4382
+ case 12:
4383
+ resp = _context121.sent;
4384
+ this._subscriptionService.updateStateAndTokens({
4385
+ state: null,
4386
+ session_token: null,
4387
+ session_jwt: null,
4388
+ intermediate_session_token: resp.intermediate_session_token
4389
+ });
4390
+ return _context121.abrupt("return", resp);
4391
+ case 15:
4392
+ case "end":
4393
+ return _context121.stop();
4394
+ }
4395
+ }, _callee121, this);
4396
+ }));
4397
+ }
4398
+ };
4238
4399
  }
4239
4400
  _createClass(HeadlessB2BPasswordsClient, [{
4240
4401
  key: "getCodeChallenge",
4241
4402
  value: function getCodeChallenge() {
4242
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee119() {
4403
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee122() {
4243
4404
  var _yield$this$_config6, pkceRequiredForPasswordResets, keyPair;
4244
- return _regeneratorRuntime().wrap(function _callee119$(_context119) {
4245
- while (1) switch (_context119.prev = _context119.next) {
4405
+ return _regeneratorRuntime().wrap(function _callee122$(_context122) {
4406
+ while (1) switch (_context122.prev = _context122.next) {
4246
4407
  case 0:
4247
- _context119.next = 2;
4408
+ _context122.next = 2;
4248
4409
  return this._config;
4249
4410
  case 2:
4250
- _yield$this$_config6 = _context119.sent;
4411
+ _yield$this$_config6 = _context122.sent;
4251
4412
  pkceRequiredForPasswordResets = _yield$this$_config6.pkceRequiredForPasswordResets;
4252
4413
  if (pkceRequiredForPasswordResets) {
4253
- _context119.next = 6;
4414
+ _context122.next = 6;
4254
4415
  break;
4255
4416
  }
4256
- return _context119.abrupt("return", undefined);
4417
+ return _context122.abrupt("return", undefined);
4257
4418
  case 6:
4258
- _context119.next = 8;
4419
+ _context122.next = 8;
4259
4420
  return this._pkceManager.getPKPair();
4260
4421
  case 8:
4261
- keyPair = _context119.sent;
4422
+ keyPair = _context122.sent;
4262
4423
  if (!keyPair) {
4263
- _context119.next = 11;
4424
+ _context122.next = 11;
4264
4425
  break;
4265
4426
  }
4266
- return _context119.abrupt("return", keyPair.code_challenge);
4427
+ return _context122.abrupt("return", keyPair.code_challenge);
4267
4428
  case 11:
4268
- _context119.next = 13;
4429
+ _context122.next = 13;
4269
4430
  return this._pkceManager.startPKCETransaction();
4270
4431
  case 13:
4271
- keyPair = _context119.sent;
4272
- return _context119.abrupt("return", keyPair.code_challenge);
4432
+ keyPair = _context122.sent;
4433
+ return _context122.abrupt("return", keyPair.code_challenge);
4273
4434
  case 15:
4274
4435
  case "end":
4275
- return _context119.stop();
4436
+ return _context122.stop();
4276
4437
  }
4277
- }, _callee119, this);
4438
+ }, _callee122, this);
4278
4439
  }));
4279
4440
  }
4280
4441
  }, {
4281
4442
  key: "authenticate",
4282
4443
  value: function authenticate(options) {
4283
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee120() {
4284
- var pkPair, code_verifier, _yield$this$dfpProtec24, dfp_telemetry_id, captcha_token, resp;
4285
- return _regeneratorRuntime().wrap(function _callee120$(_context120) {
4286
- while (1) switch (_context120.prev = _context120.next) {
4444
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee123() {
4445
+ var pkPair, code_verifier, _yield$this$dfpProtec27, dfp_telemetry_id, captcha_token, resp;
4446
+ return _regeneratorRuntime().wrap(function _callee123$(_context123) {
4447
+ while (1) switch (_context123.prev = _context123.next) {
4287
4448
  case 0:
4288
4449
  validate('stytch.passwords.authenticate').isString('org_id', options.organization_id).isString('password', options.password).isString('email_address', options.email_address).isNumber('session_duration_minutes', options.session_duration_minutes).isOptionalString('locale', options.locale);
4289
- _context120.next = 3;
4450
+ _context123.next = 3;
4290
4451
  return this._pkceManager.getPKPair();
4291
4452
  case 3:
4292
- pkPair = _context120.sent;
4453
+ pkPair = _context123.sent;
4293
4454
  code_verifier = pkPair === null || pkPair === void 0 ? void 0 : pkPair.code_verifier;
4294
- _context120.next = 7;
4455
+ _context123.next = 7;
4295
4456
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4296
4457
  case 7:
4297
- _yield$this$dfpProtec24 = _context120.sent;
4298
- dfp_telemetry_id = _yield$this$dfpProtec24.dfp_telemetry_id;
4299
- captcha_token = _yield$this$dfpProtec24.captcha_token;
4300
- _context120.t0 = this._networkClient;
4301
- _context120.t1 = options.organization_id;
4302
- _context120.t2 = options.email_address;
4303
- _context120.t3 = options.password;
4304
- _context120.t4 = options.session_duration_minutes;
4305
- _context120.t5 = options.locale;
4306
- _context120.t6 = captcha_token;
4307
- _context120.t7 = dfp_telemetry_id;
4308
- _context120.t8 = code_verifier;
4309
- _context120.next = 21;
4458
+ _yield$this$dfpProtec27 = _context123.sent;
4459
+ dfp_telemetry_id = _yield$this$dfpProtec27.dfp_telemetry_id;
4460
+ captcha_token = _yield$this$dfpProtec27.captcha_token;
4461
+ _context123.t0 = this._networkClient;
4462
+ _context123.t1 = options.organization_id;
4463
+ _context123.t2 = options.email_address;
4464
+ _context123.t3 = options.password;
4465
+ _context123.t4 = options.session_duration_minutes;
4466
+ _context123.t5 = options.locale;
4467
+ _context123.t6 = captcha_token;
4468
+ _context123.t7 = dfp_telemetry_id;
4469
+ _context123.t8 = code_verifier;
4470
+ _context123.next = 21;
4310
4471
  return this._subscriptionService.getIntermediateSessionToken();
4311
4472
  case 21:
4312
- _context120.t9 = _context120.sent;
4313
- if (_context120.t9) {
4314
- _context120.next = 24;
4473
+ _context123.t9 = _context123.sent;
4474
+ if (_context123.t9) {
4475
+ _context123.next = 24;
4315
4476
  break;
4316
4477
  }
4317
- _context120.t9 = undefined;
4478
+ _context123.t9 = undefined;
4318
4479
  case 24:
4319
- _context120.t10 = _context120.t9;
4320
- _context120.t11 = {
4321
- organization_id: _context120.t1,
4322
- email_address: _context120.t2,
4323
- password: _context120.t3,
4324
- session_duration_minutes: _context120.t4,
4325
- locale: _context120.t5,
4326
- captcha_token: _context120.t6,
4327
- dfp_telemetry_id: _context120.t7,
4328
- code_verifier: _context120.t8,
4329
- intermediate_session_token: _context120.t10
4480
+ _context123.t10 = _context123.t9;
4481
+ _context123.t11 = {
4482
+ organization_id: _context123.t1,
4483
+ email_address: _context123.t2,
4484
+ password: _context123.t3,
4485
+ session_duration_minutes: _context123.t4,
4486
+ locale: _context123.t5,
4487
+ captcha_token: _context123.t6,
4488
+ dfp_telemetry_id: _context123.t7,
4489
+ code_verifier: _context123.t8,
4490
+ intermediate_session_token: _context123.t10
4330
4491
  };
4331
- _context120.t12 = this.dfpProtectedAuth.retryWithCaptchaAndDFP;
4332
- _context120.t13 = {
4492
+ _context123.t12 = this.dfpProtectedAuth.retryWithCaptchaAndDFP;
4493
+ _context123.t13 = {
4333
4494
  url: '/b2b/passwords/authenticate',
4334
4495
  method: 'POST',
4335
- body: _context120.t11,
4336
- retryCallback: _context120.t12
4496
+ body: _context123.t11,
4497
+ retryCallback: _context123.t12
4337
4498
  };
4338
- _context120.next = 30;
4339
- return _context120.t0.retriableFetchSDK.call(_context120.t0, _context120.t13);
4499
+ _context123.next = 30;
4500
+ return _context123.t0.retriableFetchSDK.call(_context123.t0, _context123.t13);
4340
4501
  case 30:
4341
- resp = _context120.sent;
4502
+ resp = _context123.sent;
4342
4503
  if (resp.member_session) {
4343
4504
  this._subscriptionService.updateStateAndTokens({
4344
4505
  state: {
@@ -4358,34 +4519,34 @@ var HeadlessB2BPasswordsClient = /*#__PURE__*/function () {
4358
4519
  intermediate_session_token: resp.intermediate_session_token
4359
4520
  });
4360
4521
  }
4361
- return _context120.abrupt("return", resp);
4522
+ return _context123.abrupt("return", resp);
4362
4523
  case 33:
4363
4524
  case "end":
4364
- return _context120.stop();
4525
+ return _context123.stop();
4365
4526
  }
4366
- }, _callee120, this);
4527
+ }, _callee123, this);
4367
4528
  }));
4368
4529
  }
4369
4530
  }, {
4370
4531
  key: "resetByEmailStart",
4371
4532
  value: function resetByEmailStart(options) {
4372
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee121() {
4373
- var code_challenge, _yield$this$dfpProtec25, dfp_telemetry_id, captcha_token;
4374
- return _regeneratorRuntime().wrap(function _callee121$(_context121) {
4375
- while (1) switch (_context121.prev = _context121.next) {
4533
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee124() {
4534
+ var code_challenge, _yield$this$dfpProtec28, dfp_telemetry_id, captcha_token;
4535
+ return _regeneratorRuntime().wrap(function _callee124$(_context124) {
4536
+ while (1) switch (_context124.prev = _context124.next) {
4376
4537
  case 0:
4377
4538
  validate('stytch.passwords.resetByEmailStart').isString('email', options.email_address).isOptionalString('login_redirect_url', options.login_redirect_url).isOptionalString('reset_password_redirect_url', options.reset_password_redirect_url).isOptionalString('reset_password_template_id', options.reset_password_template_id).isOptionalNumber('reset_password_expiration_minutes', options.reset_password_expiration_minutes);
4378
- _context121.next = 3;
4539
+ _context124.next = 3;
4379
4540
  return this.getCodeChallenge();
4380
4541
  case 3:
4381
- code_challenge = _context121.sent;
4382
- _context121.next = 6;
4542
+ code_challenge = _context124.sent;
4543
+ _context124.next = 6;
4383
4544
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4384
4545
  case 6:
4385
- _yield$this$dfpProtec25 = _context121.sent;
4386
- dfp_telemetry_id = _yield$this$dfpProtec25.dfp_telemetry_id;
4387
- captcha_token = _yield$this$dfpProtec25.captcha_token;
4388
- return _context121.abrupt("return", this._networkClient.retriableFetchSDK({
4546
+ _yield$this$dfpProtec28 = _context124.sent;
4547
+ dfp_telemetry_id = _yield$this$dfpProtec28.dfp_telemetry_id;
4548
+ captcha_token = _yield$this$dfpProtec28.captcha_token;
4549
+ return _context124.abrupt("return", this._networkClient.retriableFetchSDK({
4389
4550
  url: '/b2b/passwords/email/reset/start',
4390
4551
  method: 'POST',
4391
4552
  body: {
@@ -4403,71 +4564,71 @@ var HeadlessB2BPasswordsClient = /*#__PURE__*/function () {
4403
4564
  }));
4404
4565
  case 10:
4405
4566
  case "end":
4406
- return _context121.stop();
4567
+ return _context124.stop();
4407
4568
  }
4408
- }, _callee121, this);
4569
+ }, _callee124, this);
4409
4570
  }));
4410
4571
  }
4411
4572
  }, {
4412
4573
  key: "resetByEmail",
4413
4574
  value: function resetByEmail(options) {
4414
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee122() {
4415
- var _yield$this$dfpProtec26, dfp_telemetry_id, captcha_token, pkPair, code_verifier, resp;
4416
- return _regeneratorRuntime().wrap(function _callee122$(_context122) {
4417
- while (1) switch (_context122.prev = _context122.next) {
4575
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee125() {
4576
+ var _yield$this$dfpProtec29, dfp_telemetry_id, captcha_token, pkPair, code_verifier, resp;
4577
+ return _regeneratorRuntime().wrap(function _callee125$(_context125) {
4578
+ while (1) switch (_context125.prev = _context125.next) {
4418
4579
  case 0:
4419
4580
  validate('stytch.passwords.resetByEmail').isString('password_reset_token', options.password_reset_token).isString('password', options.password).isNumber('session_duration_minutes', options.session_duration_minutes).isOptionalString('locale', options.locale);
4420
- _context122.next = 3;
4581
+ _context125.next = 3;
4421
4582
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4422
4583
  case 3:
4423
- _yield$this$dfpProtec26 = _context122.sent;
4424
- dfp_telemetry_id = _yield$this$dfpProtec26.dfp_telemetry_id;
4425
- captcha_token = _yield$this$dfpProtec26.captcha_token;
4426
- _context122.next = 8;
4584
+ _yield$this$dfpProtec29 = _context125.sent;
4585
+ dfp_telemetry_id = _yield$this$dfpProtec29.dfp_telemetry_id;
4586
+ captcha_token = _yield$this$dfpProtec29.captcha_token;
4587
+ _context125.next = 8;
4427
4588
  return this._pkceManager.getPKPair();
4428
4589
  case 8:
4429
- pkPair = _context122.sent;
4590
+ pkPair = _context125.sent;
4430
4591
  code_verifier = pkPair === null || pkPair === void 0 ? void 0 : pkPair.code_verifier;
4431
- _context122.t0 = this._networkClient;
4432
- _context122.t1 = options.password_reset_token;
4433
- _context122.t2 = options.password;
4434
- _context122.t3 = options.session_duration_minutes;
4435
- _context122.t4 = options.locale;
4436
- _context122.t5 = captcha_token;
4437
- _context122.t6 = dfp_telemetry_id;
4438
- _context122.t7 = code_verifier;
4439
- _context122.next = 20;
4592
+ _context125.t0 = this._networkClient;
4593
+ _context125.t1 = options.password_reset_token;
4594
+ _context125.t2 = options.password;
4595
+ _context125.t3 = options.session_duration_minutes;
4596
+ _context125.t4 = options.locale;
4597
+ _context125.t5 = captcha_token;
4598
+ _context125.t6 = dfp_telemetry_id;
4599
+ _context125.t7 = code_verifier;
4600
+ _context125.next = 20;
4440
4601
  return this._subscriptionService.getIntermediateSessionToken();
4441
4602
  case 20:
4442
- _context122.t8 = _context122.sent;
4443
- if (_context122.t8) {
4444
- _context122.next = 23;
4603
+ _context125.t8 = _context125.sent;
4604
+ if (_context125.t8) {
4605
+ _context125.next = 23;
4445
4606
  break;
4446
4607
  }
4447
- _context122.t8 = undefined;
4608
+ _context125.t8 = undefined;
4448
4609
  case 23:
4449
- _context122.t9 = _context122.t8;
4450
- _context122.t10 = {
4451
- password_reset_token: _context122.t1,
4452
- password: _context122.t2,
4453
- session_duration_minutes: _context122.t3,
4454
- locale: _context122.t4,
4455
- captcha_token: _context122.t5,
4456
- dfp_telemetry_id: _context122.t6,
4457
- code_verifier: _context122.t7,
4458
- intermediate_session_token: _context122.t9
4610
+ _context125.t9 = _context125.t8;
4611
+ _context125.t10 = {
4612
+ password_reset_token: _context125.t1,
4613
+ password: _context125.t2,
4614
+ session_duration_minutes: _context125.t3,
4615
+ locale: _context125.t4,
4616
+ captcha_token: _context125.t5,
4617
+ dfp_telemetry_id: _context125.t6,
4618
+ code_verifier: _context125.t7,
4619
+ intermediate_session_token: _context125.t9
4459
4620
  };
4460
- _context122.t11 = this.dfpProtectedAuth.retryWithCaptchaAndDFP;
4461
- _context122.t12 = {
4621
+ _context125.t11 = this.dfpProtectedAuth.retryWithCaptchaAndDFP;
4622
+ _context125.t12 = {
4462
4623
  url: '/b2b/passwords/email/reset',
4463
4624
  method: 'POST',
4464
- body: _context122.t10,
4465
- retryCallback: _context122.t11
4625
+ body: _context125.t10,
4626
+ retryCallback: _context125.t11
4466
4627
  };
4467
- _context122.next = 29;
4468
- return _context122.t0.retriableFetchSDK.call(_context122.t0, _context122.t12);
4628
+ _context125.next = 29;
4629
+ return _context125.t0.retriableFetchSDK.call(_context125.t0, _context125.t12);
4469
4630
  case 29:
4470
- resp = _context122.sent;
4631
+ resp = _context125.sent;
4471
4632
  this._pkceManager.clearPKPair();
4472
4633
  if (resp.member_session) {
4473
4634
  this._subscriptionService.updateStateAndTokens({
@@ -4488,30 +4649,30 @@ var HeadlessB2BPasswordsClient = /*#__PURE__*/function () {
4488
4649
  intermediate_session_token: resp.intermediate_session_token
4489
4650
  });
4490
4651
  }
4491
- return _context122.abrupt("return", resp);
4652
+ return _context125.abrupt("return", resp);
4492
4653
  case 33:
4493
4654
  case "end":
4494
- return _context122.stop();
4655
+ return _context125.stop();
4495
4656
  }
4496
- }, _callee122, this);
4657
+ }, _callee125, this);
4497
4658
  }));
4498
4659
  }
4499
4660
  }, {
4500
4661
  key: "resetByExistingPassword",
4501
4662
  value: function resetByExistingPassword(options) {
4502
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee123() {
4503
- var _yield$this$dfpProtec27, dfp_telemetry_id, captcha_token, resp;
4504
- return _regeneratorRuntime().wrap(function _callee123$(_context123) {
4505
- while (1) switch (_context123.prev = _context123.next) {
4663
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee126() {
4664
+ var _yield$this$dfpProtec30, dfp_telemetry_id, captcha_token, resp;
4665
+ return _regeneratorRuntime().wrap(function _callee126$(_context126) {
4666
+ while (1) switch (_context126.prev = _context126.next) {
4506
4667
  case 0:
4507
4668
  validate('stytch.passwords.resetByExistingPassword').isString('email', options.email_address).isString('existing_password', options.existing_password).isString('new_password', options.new_password).isOptionalString('locale', options.locale);
4508
- _context123.next = 3;
4669
+ _context126.next = 3;
4509
4670
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4510
4671
  case 3:
4511
- _yield$this$dfpProtec27 = _context123.sent;
4512
- dfp_telemetry_id = _yield$this$dfpProtec27.dfp_telemetry_id;
4513
- captcha_token = _yield$this$dfpProtec27.captcha_token;
4514
- _context123.next = 8;
4672
+ _yield$this$dfpProtec30 = _context126.sent;
4673
+ dfp_telemetry_id = _yield$this$dfpProtec30.dfp_telemetry_id;
4674
+ captcha_token = _yield$this$dfpProtec30.captcha_token;
4675
+ _context126.next = 8;
4515
4676
  return this._networkClient.retriableFetchSDK({
4516
4677
  url: '/b2b/passwords/existing_password/reset',
4517
4678
  method: 'POST',
@@ -4528,7 +4689,7 @@ var HeadlessB2BPasswordsClient = /*#__PURE__*/function () {
4528
4689
  retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
4529
4690
  });
4530
4691
  case 8:
4531
- resp = _context123.sent;
4692
+ resp = _context126.sent;
4532
4693
  if (resp.member_session) {
4533
4694
  this._subscriptionService.updateStateAndTokens({
4534
4695
  state: {
@@ -4548,30 +4709,30 @@ var HeadlessB2BPasswordsClient = /*#__PURE__*/function () {
4548
4709
  intermediate_session_token: resp.intermediate_session_token
4549
4710
  });
4550
4711
  }
4551
- return _context123.abrupt("return", resp);
4712
+ return _context126.abrupt("return", resp);
4552
4713
  case 11:
4553
4714
  case "end":
4554
- return _context123.stop();
4715
+ return _context126.stop();
4555
4716
  }
4556
- }, _callee123, this);
4717
+ }, _callee126, this);
4557
4718
  }));
4558
4719
  }
4559
4720
  }, {
4560
4721
  key: "resetBySession",
4561
4722
  value: function resetBySession(options) {
4562
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee124() {
4563
- var _yield$this$dfpProtec28, dfp_telemetry_id, captcha_token, resp;
4564
- return _regeneratorRuntime().wrap(function _callee124$(_context124) {
4565
- while (1) switch (_context124.prev = _context124.next) {
4723
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee127() {
4724
+ var _yield$this$dfpProtec31, dfp_telemetry_id, captcha_token, resp;
4725
+ return _regeneratorRuntime().wrap(function _callee127$(_context127) {
4726
+ while (1) switch (_context127.prev = _context127.next) {
4566
4727
  case 0:
4567
4728
  validate('stytch.passwords.resetBySession').isString('password', options.password);
4568
- _context124.next = 3;
4729
+ _context127.next = 3;
4569
4730
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4570
4731
  case 3:
4571
- _yield$this$dfpProtec28 = _context124.sent;
4572
- dfp_telemetry_id = _yield$this$dfpProtec28.dfp_telemetry_id;
4573
- captcha_token = _yield$this$dfpProtec28.captcha_token;
4574
- _context124.next = 8;
4732
+ _yield$this$dfpProtec31 = _context127.sent;
4733
+ dfp_telemetry_id = _yield$this$dfpProtec31.dfp_telemetry_id;
4734
+ captcha_token = _yield$this$dfpProtec31.captcha_token;
4735
+ _context127.next = 8;
4575
4736
  return this._networkClient.retriableFetchSDK({
4576
4737
  url: '/b2b/passwords/session/reset',
4577
4738
  method: 'POST',
@@ -4583,7 +4744,7 @@ var HeadlessB2BPasswordsClient = /*#__PURE__*/function () {
4583
4744
  retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
4584
4745
  });
4585
4746
  case 8:
4586
- resp = _context124.sent;
4747
+ resp = _context127.sent;
4587
4748
  this._subscriptionService.updateStateAndTokens({
4588
4749
  state: {
4589
4750
  session: resp.member_session,
@@ -4594,23 +4755,23 @@ var HeadlessB2BPasswordsClient = /*#__PURE__*/function () {
4594
4755
  session_jwt: resp.session_jwt,
4595
4756
  intermediate_session_token: null
4596
4757
  });
4597
- return _context124.abrupt("return", resp);
4758
+ return _context127.abrupt("return", resp);
4598
4759
  case 11:
4599
4760
  case "end":
4600
- return _context124.stop();
4761
+ return _context127.stop();
4601
4762
  }
4602
- }, _callee124, this);
4763
+ }, _callee127, this);
4603
4764
  }));
4604
4765
  }
4605
4766
  }, {
4606
4767
  key: "strengthCheck",
4607
4768
  value: function strengthCheck(options) {
4608
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee125() {
4609
- return _regeneratorRuntime().wrap(function _callee125$(_context125) {
4610
- while (1) switch (_context125.prev = _context125.next) {
4769
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee128() {
4770
+ return _regeneratorRuntime().wrap(function _callee128$(_context128) {
4771
+ while (1) switch (_context128.prev = _context128.next) {
4611
4772
  case 0:
4612
4773
  validate('stytch.passwords.strengthCheck').isOptionalString('email', options.email_address).isString('password', options.password);
4613
- return _context125.abrupt("return", this._networkClient.fetchSDK({
4774
+ return _context128.abrupt("return", this._networkClient.fetchSDK({
4614
4775
  url: '/b2b/passwords/strength_check',
4615
4776
  method: 'POST',
4616
4777
  body: {
@@ -4620,106 +4781,106 @@ var HeadlessB2BPasswordsClient = /*#__PURE__*/function () {
4620
4781
  }));
4621
4782
  case 2:
4622
4783
  case "end":
4623
- return _context125.stop();
4784
+ return _context128.stop();
4624
4785
  }
4625
- }, _callee125, this);
4786
+ }, _callee128, this);
4626
4787
  }));
4627
4788
  }
4628
4789
  }]);
4629
4790
  return HeadlessB2BPasswordsClient;
4630
4791
  }();
4631
4792
  var HeadlessB2BOTPsClient = /*#__PURE__*/_createClass(function HeadlessB2BOTPsClient(_networkClient, _subscriptionService, dfpProtectedAuth) {
4632
- var _this19 = this;
4793
+ var _this20 = this;
4633
4794
  _classCallCheck(this, HeadlessB2BOTPsClient);
4634
4795
  this._networkClient = _networkClient;
4635
4796
  this._subscriptionService = _subscriptionService;
4636
4797
  this.dfpProtectedAuth = dfpProtectedAuth;
4637
4798
  this.sms = {
4638
4799
  send: function send(data) {
4639
- return __awaiter$1(_this19, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee126() {
4640
- var _yield$this$dfpProtec29, dfp_telemetry_id, captcha_token;
4641
- return _regeneratorRuntime().wrap(function _callee126$(_context126) {
4642
- while (1) switch (_context126.prev = _context126.next) {
4800
+ return __awaiter$1(_this20, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee129() {
4801
+ var _yield$this$dfpProtec32, dfp_telemetry_id, captcha_token;
4802
+ return _regeneratorRuntime().wrap(function _callee129$(_context129) {
4803
+ while (1) switch (_context129.prev = _context129.next) {
4643
4804
  case 0:
4644
4805
  validate('stytch.otps.sms.send').isString('organization_id', data.organization_id).isString('member_id', data.member_id).isOptionalString('mfa_phone_number', data.mfa_phone_number).isOptionalString('locale', data.locale);
4645
- _context126.next = 3;
4806
+ _context129.next = 3;
4646
4807
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4647
4808
  case 3:
4648
- _yield$this$dfpProtec29 = _context126.sent;
4649
- dfp_telemetry_id = _yield$this$dfpProtec29.dfp_telemetry_id;
4650
- captcha_token = _yield$this$dfpProtec29.captcha_token;
4651
- _context126.t0 = this._networkClient;
4652
- _context126.t1 = Object;
4653
- _context126.t2 = Object.assign({}, data);
4654
- _context126.t3 = dfp_telemetry_id;
4655
- _context126.t4 = captcha_token;
4656
- _context126.next = 13;
4809
+ _yield$this$dfpProtec32 = _context129.sent;
4810
+ dfp_telemetry_id = _yield$this$dfpProtec32.dfp_telemetry_id;
4811
+ captcha_token = _yield$this$dfpProtec32.captcha_token;
4812
+ _context129.t0 = this._networkClient;
4813
+ _context129.t1 = Object;
4814
+ _context129.t2 = Object.assign({}, data);
4815
+ _context129.t3 = dfp_telemetry_id;
4816
+ _context129.t4 = captcha_token;
4817
+ _context129.next = 13;
4657
4818
  return this._subscriptionService.getIntermediateSessionToken();
4658
4819
  case 13:
4659
- _context126.t5 = _context126.sent;
4660
- if (_context126.t5) {
4661
- _context126.next = 16;
4820
+ _context129.t5 = _context129.sent;
4821
+ if (_context129.t5) {
4822
+ _context129.next = 16;
4662
4823
  break;
4663
4824
  }
4664
- _context126.t5 = undefined;
4825
+ _context129.t5 = undefined;
4665
4826
  case 16:
4666
- _context126.t6 = _context126.t5;
4667
- _context126.t7 = {
4668
- dfp_telemetry_id: _context126.t3,
4669
- captcha_token: _context126.t4,
4670
- intermediate_session_token: _context126.t6
4827
+ _context129.t6 = _context129.t5;
4828
+ _context129.t7 = {
4829
+ dfp_telemetry_id: _context129.t3,
4830
+ captcha_token: _context129.t4,
4831
+ intermediate_session_token: _context129.t6
4671
4832
  };
4672
- _context126.t8 = _context126.t1.assign.call(_context126.t1, _context126.t2, _context126.t7);
4673
- _context126.t9 = this.dfpProtectedAuth.retryWithCaptchaAndDFP;
4674
- _context126.t10 = {
4833
+ _context129.t8 = _context129.t1.assign.call(_context129.t1, _context129.t2, _context129.t7);
4834
+ _context129.t9 = this.dfpProtectedAuth.retryWithCaptchaAndDFP;
4835
+ _context129.t10 = {
4675
4836
  url: '/b2b/otps/sms/send',
4676
- body: _context126.t8,
4837
+ body: _context129.t8,
4677
4838
  method: 'POST',
4678
- retryCallback: _context126.t9
4839
+ retryCallback: _context129.t9
4679
4840
  };
4680
- return _context126.abrupt("return", _context126.t0.retriableFetchSDK.call(_context126.t0, _context126.t10));
4841
+ return _context129.abrupt("return", _context129.t0.retriableFetchSDK.call(_context129.t0, _context129.t10));
4681
4842
  case 22:
4682
4843
  case "end":
4683
- return _context126.stop();
4844
+ return _context129.stop();
4684
4845
  }
4685
- }, _callee126, this);
4846
+ }, _callee129, this);
4686
4847
  }));
4687
4848
  },
4688
4849
  authenticate: function authenticate(data) {
4689
- return __awaiter$1(_this19, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee127() {
4690
- var _yield$this$dfpProtec30, dfp_telemetry_id, captcha_token, requestBody, resp;
4691
- return _regeneratorRuntime().wrap(function _callee127$(_context127) {
4692
- while (1) switch (_context127.prev = _context127.next) {
4850
+ return __awaiter$1(_this20, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee130() {
4851
+ var _yield$this$dfpProtec33, dfp_telemetry_id, captcha_token, requestBody, resp;
4852
+ return _regeneratorRuntime().wrap(function _callee130$(_context130) {
4853
+ while (1) switch (_context130.prev = _context130.next) {
4693
4854
  case 0:
4694
4855
  validate('stytch.otps.sms.authenticate').isString('organization_id', data.organization_id).isString('member_id', data.member_id).isString('code', data.code).isOptionalString('set_mfa_enrollment', data.set_mfa_enrollment);
4695
- _context127.next = 3;
4856
+ _context130.next = 3;
4696
4857
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4697
4858
  case 3:
4698
- _yield$this$dfpProtec30 = _context127.sent;
4699
- dfp_telemetry_id = _yield$this$dfpProtec30.dfp_telemetry_id;
4700
- captcha_token = _yield$this$dfpProtec30.captcha_token;
4701
- _context127.t0 = Object;
4702
- _context127.t1 = Object.assign({}, data);
4703
- _context127.t2 = dfp_telemetry_id;
4704
- _context127.t3 = captcha_token;
4705
- _context127.next = 12;
4859
+ _yield$this$dfpProtec33 = _context130.sent;
4860
+ dfp_telemetry_id = _yield$this$dfpProtec33.dfp_telemetry_id;
4861
+ captcha_token = _yield$this$dfpProtec33.captcha_token;
4862
+ _context130.t0 = Object;
4863
+ _context130.t1 = Object.assign({}, data);
4864
+ _context130.t2 = dfp_telemetry_id;
4865
+ _context130.t3 = captcha_token;
4866
+ _context130.next = 12;
4706
4867
  return this._subscriptionService.getIntermediateSessionToken();
4707
4868
  case 12:
4708
- _context127.t4 = _context127.sent;
4709
- if (_context127.t4) {
4710
- _context127.next = 15;
4869
+ _context130.t4 = _context130.sent;
4870
+ if (_context130.t4) {
4871
+ _context130.next = 15;
4711
4872
  break;
4712
4873
  }
4713
- _context127.t4 = undefined;
4874
+ _context130.t4 = undefined;
4714
4875
  case 15:
4715
- _context127.t5 = _context127.t4;
4716
- _context127.t6 = {
4717
- dfp_telemetry_id: _context127.t2,
4718
- captcha_token: _context127.t3,
4719
- intermediate_session_token: _context127.t5
4876
+ _context130.t5 = _context130.t4;
4877
+ _context130.t6 = {
4878
+ dfp_telemetry_id: _context130.t2,
4879
+ captcha_token: _context130.t3,
4880
+ intermediate_session_token: _context130.t5
4720
4881
  };
4721
- requestBody = _context127.t0.assign.call(_context127.t0, _context127.t1, _context127.t6);
4722
- _context127.next = 20;
4882
+ requestBody = _context130.t0.assign.call(_context130.t0, _context130.t1, _context130.t6);
4883
+ _context130.next = 20;
4723
4884
  return this._networkClient.retriableFetchSDK({
4724
4885
  url: '/b2b/otps/sms/authenticate',
4725
4886
  body: requestBody,
@@ -4727,7 +4888,7 @@ var HeadlessB2BOTPsClient = /*#__PURE__*/_createClass(function HeadlessB2BOTPsCl
4727
4888
  retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
4728
4889
  });
4729
4890
  case 20:
4730
- resp = _context127.sent;
4891
+ resp = _context130.sent;
4731
4892
  this._subscriptionService.updateStateAndTokens({
4732
4893
  state: {
4733
4894
  session: resp.member_session,
@@ -4738,30 +4899,30 @@ var HeadlessB2BOTPsClient = /*#__PURE__*/_createClass(function HeadlessB2BOTPsCl
4738
4899
  session_jwt: resp.session_jwt,
4739
4900
  intermediate_session_token: null
4740
4901
  });
4741
- return _context127.abrupt("return", resp);
4902
+ return _context130.abrupt("return", resp);
4742
4903
  case 23:
4743
4904
  case "end":
4744
- return _context127.stop();
4905
+ return _context130.stop();
4745
4906
  }
4746
- }, _callee127, this);
4907
+ }, _callee130, this);
4747
4908
  }));
4748
4909
  }
4749
4910
  };
4750
4911
  this.email = {
4751
4912
  loginOrSignup: function loginOrSignup(data) {
4752
- return __awaiter$1(_this19, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee128() {
4753
- var _yield$this$dfpProtec31, dfp_telemetry_id, captcha_token;
4754
- return _regeneratorRuntime().wrap(function _callee128$(_context128) {
4755
- while (1) switch (_context128.prev = _context128.next) {
4913
+ return __awaiter$1(_this20, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee131() {
4914
+ var _yield$this$dfpProtec34, dfp_telemetry_id, captcha_token;
4915
+ return _regeneratorRuntime().wrap(function _callee131$(_context131) {
4916
+ while (1) switch (_context131.prev = _context131.next) {
4756
4917
  case 0:
4757
4918
  validate('stytch.otps.email.loginOrSignup').isString('organization_id', data.organization_id).isString('email_address', data.email_address).isOptionalString('login_template_id', data.login_template_id).isOptionalString('signup_template_id', data.signup_template_id).isOptionalString('locale', data.locale);
4758
- _context128.next = 3;
4919
+ _context131.next = 3;
4759
4920
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4760
4921
  case 3:
4761
- _yield$this$dfpProtec31 = _context128.sent;
4762
- dfp_telemetry_id = _yield$this$dfpProtec31.dfp_telemetry_id;
4763
- captcha_token = _yield$this$dfpProtec31.captcha_token;
4764
- return _context128.abrupt("return", this._networkClient.retriableFetchSDK({
4922
+ _yield$this$dfpProtec34 = _context131.sent;
4923
+ dfp_telemetry_id = _yield$this$dfpProtec34.dfp_telemetry_id;
4924
+ captcha_token = _yield$this$dfpProtec34.captcha_token;
4925
+ return _context131.abrupt("return", this._networkClient.retriableFetchSDK({
4765
4926
  url: '/b2b/otps/email/login_or_signup',
4766
4927
  body: Object.assign(Object.assign({}, data), {
4767
4928
  dfp_telemetry_id: dfp_telemetry_id,
@@ -4772,57 +4933,57 @@ var HeadlessB2BOTPsClient = /*#__PURE__*/_createClass(function HeadlessB2BOTPsCl
4772
4933
  }));
4773
4934
  case 7:
4774
4935
  case "end":
4775
- return _context128.stop();
4936
+ return _context131.stop();
4776
4937
  }
4777
- }, _callee128, this);
4938
+ }, _callee131, this);
4778
4939
  }));
4779
4940
  },
4780
4941
  authenticate: function authenticate(data) {
4781
- return __awaiter$1(_this19, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee129() {
4782
- var _yield$this$dfpProtec32, dfp_telemetry_id, captcha_token, resp;
4783
- return _regeneratorRuntime().wrap(function _callee129$(_context129) {
4784
- while (1) switch (_context129.prev = _context129.next) {
4942
+ return __awaiter$1(_this20, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee132() {
4943
+ var _yield$this$dfpProtec35, dfp_telemetry_id, captcha_token, resp;
4944
+ return _regeneratorRuntime().wrap(function _callee132$(_context132) {
4945
+ while (1) switch (_context132.prev = _context132.next) {
4785
4946
  case 0:
4786
4947
  validate('stytch.otps.email.authenticate').isString('code', data.code).isString('member_id', data.member_id).isString('organization_id', data.organization_id).isNumber('session_duration_minutes', data.session_duration_minutes).isOptionalString('locale', data.locale);
4787
- _context129.next = 3;
4948
+ _context132.next = 3;
4788
4949
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4789
4950
  case 3:
4790
- _yield$this$dfpProtec32 = _context129.sent;
4791
- dfp_telemetry_id = _yield$this$dfpProtec32.dfp_telemetry_id;
4792
- captcha_token = _yield$this$dfpProtec32.captcha_token;
4793
- _context129.t0 = this._networkClient;
4794
- _context129.t1 = Object;
4795
- _context129.t2 = Object.assign({}, data);
4796
- _context129.next = 11;
4951
+ _yield$this$dfpProtec35 = _context132.sent;
4952
+ dfp_telemetry_id = _yield$this$dfpProtec35.dfp_telemetry_id;
4953
+ captcha_token = _yield$this$dfpProtec35.captcha_token;
4954
+ _context132.t0 = this._networkClient;
4955
+ _context132.t1 = Object;
4956
+ _context132.t2 = Object.assign({}, data);
4957
+ _context132.next = 11;
4797
4958
  return this._subscriptionService.getIntermediateSessionToken();
4798
4959
  case 11:
4799
- _context129.t3 = _context129.sent;
4800
- if (_context129.t3) {
4801
- _context129.next = 14;
4960
+ _context132.t3 = _context132.sent;
4961
+ if (_context132.t3) {
4962
+ _context132.next = 14;
4802
4963
  break;
4803
4964
  }
4804
- _context129.t3 = undefined;
4965
+ _context132.t3 = undefined;
4805
4966
  case 14:
4806
- _context129.t4 = _context129.t3;
4807
- _context129.t5 = dfp_telemetry_id;
4808
- _context129.t6 = captcha_token;
4809
- _context129.t7 = {
4810
- intermediate_session_token: _context129.t4,
4811
- dfp_telemetry_id: _context129.t5,
4812
- captcha_token: _context129.t6
4967
+ _context132.t4 = _context132.t3;
4968
+ _context132.t5 = dfp_telemetry_id;
4969
+ _context132.t6 = captcha_token;
4970
+ _context132.t7 = {
4971
+ intermediate_session_token: _context132.t4,
4972
+ dfp_telemetry_id: _context132.t5,
4973
+ captcha_token: _context132.t6
4813
4974
  };
4814
- _context129.t8 = _context129.t1.assign.call(_context129.t1, _context129.t2, _context129.t7);
4815
- _context129.t9 = this.dfpProtectedAuth.retryWithCaptchaAndDFP;
4816
- _context129.t10 = {
4975
+ _context132.t8 = _context132.t1.assign.call(_context132.t1, _context132.t2, _context132.t7);
4976
+ _context132.t9 = this.dfpProtectedAuth.retryWithCaptchaAndDFP;
4977
+ _context132.t10 = {
4817
4978
  url: '/b2b/otps/email/authenticate',
4818
- body: _context129.t8,
4979
+ body: _context132.t8,
4819
4980
  method: 'POST',
4820
- retryCallback: _context129.t9
4981
+ retryCallback: _context132.t9
4821
4982
  };
4822
- _context129.next = 23;
4823
- return _context129.t0.retriableFetchSDK.call(_context129.t0, _context129.t10);
4983
+ _context132.next = 23;
4984
+ return _context132.t0.retriableFetchSDK.call(_context132.t0, _context132.t10);
4824
4985
  case 23:
4825
- resp = _context129.sent;
4986
+ resp = _context132.sent;
4826
4987
  if (resp && resp.member_session) {
4827
4988
  this._subscriptionService.updateStateAndTokens({
4828
4989
  state: {
@@ -4835,33 +4996,33 @@ var HeadlessB2BOTPsClient = /*#__PURE__*/_createClass(function HeadlessB2BOTPsCl
4835
4996
  intermediate_session_token: null
4836
4997
  });
4837
4998
  }
4838
- return _context129.abrupt("return", resp);
4999
+ return _context132.abrupt("return", resp);
4839
5000
  case 26:
4840
5001
  case "end":
4841
- return _context129.stop();
5002
+ return _context132.stop();
4842
5003
  }
4843
- }, _callee129, this);
5004
+ }, _callee132, this);
4844
5005
  }));
4845
5006
  },
4846
5007
  discovery: {
4847
5008
  send: function send(data) {
4848
- return __awaiter$1(_this19, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee130() {
4849
- var _yield$this$dfpProtec33, dfp_telemetry_id, captcha_token, requestBody;
4850
- return _regeneratorRuntime().wrap(function _callee130$(_context130) {
4851
- while (1) switch (_context130.prev = _context130.next) {
5009
+ return __awaiter$1(_this20, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee133() {
5010
+ var _yield$this$dfpProtec36, dfp_telemetry_id, captcha_token, requestBody;
5011
+ return _regeneratorRuntime().wrap(function _callee133$(_context133) {
5012
+ while (1) switch (_context133.prev = _context133.next) {
4852
5013
  case 0:
4853
5014
  validate('stytch.otps.email.discovery.send').isString('email_address', data.email_address).isOptionalString('login_template_id', data.login_template_id).isOptionalString('locale', data.locale);
4854
- _context130.next = 3;
5015
+ _context133.next = 3;
4855
5016
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4856
5017
  case 3:
4857
- _yield$this$dfpProtec33 = _context130.sent;
4858
- dfp_telemetry_id = _yield$this$dfpProtec33.dfp_telemetry_id;
4859
- captcha_token = _yield$this$dfpProtec33.captcha_token;
5018
+ _yield$this$dfpProtec36 = _context133.sent;
5019
+ dfp_telemetry_id = _yield$this$dfpProtec36.dfp_telemetry_id;
5020
+ captcha_token = _yield$this$dfpProtec36.captcha_token;
4860
5021
  requestBody = Object.assign(Object.assign({}, data), {
4861
5022
  dfp_telemetry_id: dfp_telemetry_id,
4862
5023
  captcha_token: captcha_token
4863
5024
  });
4864
- return _context130.abrupt("return", this._networkClient.retriableFetchSDK({
5025
+ return _context133.abrupt("return", this._networkClient.retriableFetchSDK({
4865
5026
  url: '/b2b/otps/email/discovery/send',
4866
5027
  body: requestBody,
4867
5028
  method: 'POST',
@@ -4869,29 +5030,29 @@ var HeadlessB2BOTPsClient = /*#__PURE__*/_createClass(function HeadlessB2BOTPsCl
4869
5030
  }));
4870
5031
  case 8:
4871
5032
  case "end":
4872
- return _context130.stop();
5033
+ return _context133.stop();
4873
5034
  }
4874
- }, _callee130, this);
5035
+ }, _callee133, this);
4875
5036
  }));
4876
5037
  },
4877
5038
  authenticate: function authenticate(data) {
4878
- return __awaiter$1(_this19, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee131() {
4879
- var _yield$this$dfpProtec34, dfp_telemetry_id, captcha_token, requestBody, resp;
4880
- return _regeneratorRuntime().wrap(function _callee131$(_context131) {
4881
- while (1) switch (_context131.prev = _context131.next) {
5039
+ return __awaiter$1(_this20, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee134() {
5040
+ var _yield$this$dfpProtec37, dfp_telemetry_id, captcha_token, requestBody, resp;
5041
+ return _regeneratorRuntime().wrap(function _callee134$(_context134) {
5042
+ while (1) switch (_context134.prev = _context134.next) {
4882
5043
  case 0:
4883
5044
  validate('stytch.otps.email.discovery.authenticate').isString('code', data.code).isString('email_address', data.email_address);
4884
- _context131.next = 3;
5045
+ _context134.next = 3;
4885
5046
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4886
5047
  case 3:
4887
- _yield$this$dfpProtec34 = _context131.sent;
4888
- dfp_telemetry_id = _yield$this$dfpProtec34.dfp_telemetry_id;
4889
- captcha_token = _yield$this$dfpProtec34.captcha_token;
5048
+ _yield$this$dfpProtec37 = _context134.sent;
5049
+ dfp_telemetry_id = _yield$this$dfpProtec37.dfp_telemetry_id;
5050
+ captcha_token = _yield$this$dfpProtec37.captcha_token;
4890
5051
  requestBody = Object.assign({
4891
5052
  dfp_telemetry_id: dfp_telemetry_id,
4892
5053
  captcha_token: captcha_token
4893
5054
  }, data);
4894
- _context131.next = 9;
5055
+ _context134.next = 9;
4895
5056
  return this._networkClient.retriableFetchSDK({
4896
5057
  url: '/b2b/otps/email/discovery/authenticate',
4897
5058
  body: requestBody,
@@ -4899,19 +5060,19 @@ var HeadlessB2BOTPsClient = /*#__PURE__*/_createClass(function HeadlessB2BOTPsCl
4899
5060
  retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
4900
5061
  });
4901
5062
  case 9:
4902
- resp = _context131.sent;
5063
+ resp = _context134.sent;
4903
5064
  this._subscriptionService.updateStateAndTokens({
4904
5065
  state: null,
4905
5066
  session_token: null,
4906
5067
  session_jwt: null,
4907
5068
  intermediate_session_token: resp.intermediate_session_token
4908
5069
  });
4909
- return _context131.abrupt("return", resp);
5070
+ return _context134.abrupt("return", resp);
4910
5071
  case 12:
4911
5072
  case "end":
4912
- return _context131.stop();
5073
+ return _context134.stop();
4913
5074
  }
4914
- }, _callee131, this);
5075
+ }, _callee134, this);
4915
5076
  }));
4916
5077
  }
4917
5078
  }
@@ -4927,92 +5088,92 @@ var HeadlessB2BTOTPsClient = /*#__PURE__*/function () {
4927
5088
  _createClass(HeadlessB2BTOTPsClient, [{
4928
5089
  key: "create",
4929
5090
  value: function create(data) {
4930
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee132() {
4931
- var _yield$this$dfpProtec35, dfp_telemetry_id, captcha_token;
4932
- return _regeneratorRuntime().wrap(function _callee132$(_context132) {
4933
- while (1) switch (_context132.prev = _context132.next) {
5091
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee135() {
5092
+ var _yield$this$dfpProtec38, dfp_telemetry_id, captcha_token;
5093
+ return _regeneratorRuntime().wrap(function _callee135$(_context135) {
5094
+ while (1) switch (_context135.prev = _context135.next) {
4934
5095
  case 0:
4935
5096
  validate('stytch.totp.create').isString('organization_id', data.organization_id).isString('member_id', data.member_id).isOptionalNumber('expiration_minutes', data.expiration_minutes);
4936
- _context132.next = 3;
5097
+ _context135.next = 3;
4937
5098
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4938
5099
  case 3:
4939
- _yield$this$dfpProtec35 = _context132.sent;
4940
- dfp_telemetry_id = _yield$this$dfpProtec35.dfp_telemetry_id;
4941
- captcha_token = _yield$this$dfpProtec35.captcha_token;
4942
- _context132.t0 = this._networkClient;
4943
- _context132.t1 = Object;
4944
- _context132.t2 = Object.assign({}, data);
4945
- _context132.t3 = dfp_telemetry_id;
4946
- _context132.t4 = captcha_token;
4947
- _context132.next = 13;
5100
+ _yield$this$dfpProtec38 = _context135.sent;
5101
+ dfp_telemetry_id = _yield$this$dfpProtec38.dfp_telemetry_id;
5102
+ captcha_token = _yield$this$dfpProtec38.captcha_token;
5103
+ _context135.t0 = this._networkClient;
5104
+ _context135.t1 = Object;
5105
+ _context135.t2 = Object.assign({}, data);
5106
+ _context135.t3 = dfp_telemetry_id;
5107
+ _context135.t4 = captcha_token;
5108
+ _context135.next = 13;
4948
5109
  return this._subscriptionService.getIntermediateSessionToken();
4949
5110
  case 13:
4950
- _context132.t5 = _context132.sent;
4951
- if (_context132.t5) {
4952
- _context132.next = 16;
5111
+ _context135.t5 = _context135.sent;
5112
+ if (_context135.t5) {
5113
+ _context135.next = 16;
4953
5114
  break;
4954
5115
  }
4955
- _context132.t5 = undefined;
5116
+ _context135.t5 = undefined;
4956
5117
  case 16:
4957
- _context132.t6 = _context132.t5;
4958
- _context132.t7 = {
4959
- dfp_telemetry_id: _context132.t3,
4960
- captcha_token: _context132.t4,
4961
- intermediate_session_token: _context132.t6
5118
+ _context135.t6 = _context135.t5;
5119
+ _context135.t7 = {
5120
+ dfp_telemetry_id: _context135.t3,
5121
+ captcha_token: _context135.t4,
5122
+ intermediate_session_token: _context135.t6
4962
5123
  };
4963
- _context132.t8 = _context132.t1.assign.call(_context132.t1, _context132.t2, _context132.t7);
4964
- _context132.t9 = this.dfpProtectedAuth.retryWithCaptchaAndDFP;
4965
- _context132.t10 = {
5124
+ _context135.t8 = _context135.t1.assign.call(_context135.t1, _context135.t2, _context135.t7);
5125
+ _context135.t9 = this.dfpProtectedAuth.retryWithCaptchaAndDFP;
5126
+ _context135.t10 = {
4966
5127
  url: '/b2b/totp',
4967
- body: _context132.t8,
5128
+ body: _context135.t8,
4968
5129
  method: 'POST',
4969
- retryCallback: _context132.t9
5130
+ retryCallback: _context135.t9
4970
5131
  };
4971
- return _context132.abrupt("return", _context132.t0.retriableFetchSDK.call(_context132.t0, _context132.t10));
5132
+ return _context135.abrupt("return", _context135.t0.retriableFetchSDK.call(_context135.t0, _context135.t10));
4972
5133
  case 22:
4973
5134
  case "end":
4974
- return _context132.stop();
5135
+ return _context135.stop();
4975
5136
  }
4976
- }, _callee132, this);
5137
+ }, _callee135, this);
4977
5138
  }));
4978
5139
  }
4979
5140
  }, {
4980
5141
  key: "authenticate",
4981
5142
  value: function authenticate(data) {
4982
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee133() {
4983
- var _yield$this$dfpProtec36, dfp_telemetry_id, captcha_token, requestBody, resp;
4984
- return _regeneratorRuntime().wrap(function _callee133$(_context133) {
4985
- while (1) switch (_context133.prev = _context133.next) {
5143
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee136() {
5144
+ var _yield$this$dfpProtec39, dfp_telemetry_id, captcha_token, requestBody, resp;
5145
+ return _regeneratorRuntime().wrap(function _callee136$(_context136) {
5146
+ while (1) switch (_context136.prev = _context136.next) {
4986
5147
  case 0:
4987
5148
  validate('stytch.totp.authenticate').isString('organization_id', data.organization_id).isString('member_id', data.member_id).isString('code', data.code).isOptionalString('set_mfa_enrollment', data.set_mfa_enrollment).isOptionalBoolean('set_default_mfa', data.set_default_mfa);
4988
- _context133.next = 3;
5149
+ _context136.next = 3;
4989
5150
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
4990
5151
  case 3:
4991
- _yield$this$dfpProtec36 = _context133.sent;
4992
- dfp_telemetry_id = _yield$this$dfpProtec36.dfp_telemetry_id;
4993
- captcha_token = _yield$this$dfpProtec36.captcha_token;
4994
- _context133.t0 = Object;
4995
- _context133.t1 = Object.assign({}, data);
4996
- _context133.t2 = dfp_telemetry_id;
4997
- _context133.t3 = captcha_token;
4998
- _context133.next = 12;
5152
+ _yield$this$dfpProtec39 = _context136.sent;
5153
+ dfp_telemetry_id = _yield$this$dfpProtec39.dfp_telemetry_id;
5154
+ captcha_token = _yield$this$dfpProtec39.captcha_token;
5155
+ _context136.t0 = Object;
5156
+ _context136.t1 = Object.assign({}, data);
5157
+ _context136.t2 = dfp_telemetry_id;
5158
+ _context136.t3 = captcha_token;
5159
+ _context136.next = 12;
4999
5160
  return this._subscriptionService.getIntermediateSessionToken();
5000
5161
  case 12:
5001
- _context133.t4 = _context133.sent;
5002
- if (_context133.t4) {
5003
- _context133.next = 15;
5162
+ _context136.t4 = _context136.sent;
5163
+ if (_context136.t4) {
5164
+ _context136.next = 15;
5004
5165
  break;
5005
5166
  }
5006
- _context133.t4 = undefined;
5167
+ _context136.t4 = undefined;
5007
5168
  case 15:
5008
- _context133.t5 = _context133.t4;
5009
- _context133.t6 = {
5010
- dfp_telemetry_id: _context133.t2,
5011
- captcha_token: _context133.t3,
5012
- intermediate_session_token: _context133.t5
5169
+ _context136.t5 = _context136.t4;
5170
+ _context136.t6 = {
5171
+ dfp_telemetry_id: _context136.t2,
5172
+ captcha_token: _context136.t3,
5173
+ intermediate_session_token: _context136.t5
5013
5174
  };
5014
- requestBody = _context133.t0.assign.call(_context133.t0, _context133.t1, _context133.t6);
5015
- _context133.next = 20;
5175
+ requestBody = _context136.t0.assign.call(_context136.t0, _context136.t1, _context136.t6);
5176
+ _context136.next = 20;
5016
5177
  return this._networkClient.retriableFetchSDK({
5017
5178
  url: '/b2b/totp/authenticate',
5018
5179
  body: requestBody,
@@ -5020,7 +5181,7 @@ var HeadlessB2BTOTPsClient = /*#__PURE__*/function () {
5020
5181
  retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
5021
5182
  });
5022
5183
  case 20:
5023
- resp = _context133.sent;
5184
+ resp = _context136.sent;
5024
5185
  this._subscriptionService.updateStateAndTokens({
5025
5186
  state: {
5026
5187
  session: resp.member_session,
@@ -5031,12 +5192,12 @@ var HeadlessB2BTOTPsClient = /*#__PURE__*/function () {
5031
5192
  session_jwt: resp.session_jwt,
5032
5193
  intermediate_session_token: null
5033
5194
  });
5034
- return _context133.abrupt("return", resp);
5195
+ return _context136.abrupt("return", resp);
5035
5196
  case 23:
5036
5197
  case "end":
5037
- return _context133.stop();
5198
+ return _context136.stop();
5038
5199
  }
5039
- }, _callee133, this);
5200
+ }, _callee136, this);
5040
5201
  }));
5041
5202
  }
5042
5203
  }]);
@@ -5052,40 +5213,40 @@ var HeadlessB2BRecoveryCodesClient = /*#__PURE__*/function () {
5052
5213
  _createClass(HeadlessB2BRecoveryCodesClient, [{
5053
5214
  key: "recover",
5054
5215
  value: function recover(data) {
5055
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee134() {
5056
- var _yield$this$dfpProtec37, dfp_telemetry_id, captcha_token, requestBody, resp;
5057
- return _regeneratorRuntime().wrap(function _callee134$(_context134) {
5058
- while (1) switch (_context134.prev = _context134.next) {
5216
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee137() {
5217
+ var _yield$this$dfpProtec40, dfp_telemetry_id, captcha_token, requestBody, resp;
5218
+ return _regeneratorRuntime().wrap(function _callee137$(_context137) {
5219
+ while (1) switch (_context137.prev = _context137.next) {
5059
5220
  case 0:
5060
5221
  validate('stytch.recoveryCodes.recover').isString('organization_id', data.organization_id).isString('member_id', data.member_id).isString('recovery_code', data.recovery_code);
5061
- _context134.next = 3;
5222
+ _context137.next = 3;
5062
5223
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
5063
5224
  case 3:
5064
- _yield$this$dfpProtec37 = _context134.sent;
5065
- dfp_telemetry_id = _yield$this$dfpProtec37.dfp_telemetry_id;
5066
- captcha_token = _yield$this$dfpProtec37.captcha_token;
5067
- _context134.t0 = Object;
5068
- _context134.t1 = Object.assign({}, data);
5069
- _context134.t2 = dfp_telemetry_id;
5070
- _context134.t3 = captcha_token;
5071
- _context134.next = 12;
5225
+ _yield$this$dfpProtec40 = _context137.sent;
5226
+ dfp_telemetry_id = _yield$this$dfpProtec40.dfp_telemetry_id;
5227
+ captcha_token = _yield$this$dfpProtec40.captcha_token;
5228
+ _context137.t0 = Object;
5229
+ _context137.t1 = Object.assign({}, data);
5230
+ _context137.t2 = dfp_telemetry_id;
5231
+ _context137.t3 = captcha_token;
5232
+ _context137.next = 12;
5072
5233
  return this._subscriptionService.getIntermediateSessionToken();
5073
5234
  case 12:
5074
- _context134.t4 = _context134.sent;
5075
- if (_context134.t4) {
5076
- _context134.next = 15;
5235
+ _context137.t4 = _context137.sent;
5236
+ if (_context137.t4) {
5237
+ _context137.next = 15;
5077
5238
  break;
5078
5239
  }
5079
- _context134.t4 = undefined;
5240
+ _context137.t4 = undefined;
5080
5241
  case 15:
5081
- _context134.t5 = _context134.t4;
5082
- _context134.t6 = {
5083
- dfp_telemetry_id: _context134.t2,
5084
- captcha_token: _context134.t3,
5085
- intermediate_session_token: _context134.t5
5242
+ _context137.t5 = _context137.t4;
5243
+ _context137.t6 = {
5244
+ dfp_telemetry_id: _context137.t2,
5245
+ captcha_token: _context137.t3,
5246
+ intermediate_session_token: _context137.t5
5086
5247
  };
5087
- requestBody = _context134.t0.assign.call(_context134.t0, _context134.t1, _context134.t6);
5088
- _context134.next = 20;
5248
+ requestBody = _context137.t0.assign.call(_context137.t0, _context137.t1, _context137.t6);
5249
+ _context137.next = 20;
5089
5250
  return this._networkClient.retriableFetchSDK({
5090
5251
  url: '/b2b/recovery_codes/recover',
5091
5252
  body: requestBody,
@@ -5093,7 +5254,7 @@ var HeadlessB2BRecoveryCodesClient = /*#__PURE__*/function () {
5093
5254
  retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
5094
5255
  });
5095
5256
  case 20:
5096
- resp = _context134.sent;
5257
+ resp = _context137.sent;
5097
5258
  this._subscriptionService.updateStateAndTokens({
5098
5259
  state: {
5099
5260
  session: resp.member_session,
@@ -5104,29 +5265,29 @@ var HeadlessB2BRecoveryCodesClient = /*#__PURE__*/function () {
5104
5265
  session_jwt: resp.session_jwt,
5105
5266
  intermediate_session_token: null
5106
5267
  });
5107
- return _context134.abrupt("return", resp);
5268
+ return _context137.abrupt("return", resp);
5108
5269
  case 23:
5109
5270
  case "end":
5110
- return _context134.stop();
5271
+ return _context137.stop();
5111
5272
  }
5112
- }, _callee134, this);
5273
+ }, _callee137, this);
5113
5274
  }));
5114
5275
  }
5115
5276
  }, {
5116
5277
  key: "rotate",
5117
5278
  value: function rotate() {
5118
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee135() {
5119
- var _yield$this$dfpProtec38, dfp_telemetry_id, captcha_token;
5120
- return _regeneratorRuntime().wrap(function _callee135$(_context135) {
5121
- while (1) switch (_context135.prev = _context135.next) {
5279
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee138() {
5280
+ var _yield$this$dfpProtec41, dfp_telemetry_id, captcha_token;
5281
+ return _regeneratorRuntime().wrap(function _callee138$(_context138) {
5282
+ while (1) switch (_context138.prev = _context138.next) {
5122
5283
  case 0:
5123
- _context135.next = 2;
5284
+ _context138.next = 2;
5124
5285
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
5125
5286
  case 2:
5126
- _yield$this$dfpProtec38 = _context135.sent;
5127
- dfp_telemetry_id = _yield$this$dfpProtec38.dfp_telemetry_id;
5128
- captcha_token = _yield$this$dfpProtec38.captcha_token;
5129
- return _context135.abrupt("return", this._networkClient.retriableFetchSDK({
5287
+ _yield$this$dfpProtec41 = _context138.sent;
5288
+ dfp_telemetry_id = _yield$this$dfpProtec41.dfp_telemetry_id;
5289
+ captcha_token = _yield$this$dfpProtec41.captcha_token;
5290
+ return _context138.abrupt("return", this._networkClient.retriableFetchSDK({
5130
5291
  url: '/b2b/recovery_codes/rotate',
5131
5292
  body: {
5132
5293
  dfp_telemetry_id: dfp_telemetry_id,
@@ -5137,27 +5298,27 @@ var HeadlessB2BRecoveryCodesClient = /*#__PURE__*/function () {
5137
5298
  }));
5138
5299
  case 6:
5139
5300
  case "end":
5140
- return _context135.stop();
5301
+ return _context138.stop();
5141
5302
  }
5142
- }, _callee135, this);
5303
+ }, _callee138, this);
5143
5304
  }));
5144
5305
  }
5145
5306
  }, {
5146
5307
  key: "get",
5147
5308
  value: function get() {
5148
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee136() {
5149
- return _regeneratorRuntime().wrap(function _callee136$(_context136) {
5150
- while (1) switch (_context136.prev = _context136.next) {
5309
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee139() {
5310
+ return _regeneratorRuntime().wrap(function _callee139$(_context139) {
5311
+ while (1) switch (_context139.prev = _context139.next) {
5151
5312
  case 0:
5152
- return _context136.abrupt("return", this._networkClient.fetchSDK({
5313
+ return _context139.abrupt("return", this._networkClient.fetchSDK({
5153
5314
  url: '/b2b/recovery_codes',
5154
5315
  method: 'GET'
5155
5316
  }));
5156
5317
  case 1:
5157
5318
  case "end":
5158
- return _context136.stop();
5319
+ return _context139.stop();
5159
5320
  }
5160
- }, _callee136, this);
5321
+ }, _callee139, this);
5161
5322
  }));
5162
5323
  }
5163
5324
  }]);
@@ -5165,16 +5326,16 @@ var HeadlessB2BRecoveryCodesClient = /*#__PURE__*/function () {
5165
5326
  }();
5166
5327
  var HeadlessB2BRBACClient = /*#__PURE__*/function () {
5167
5328
  function HeadlessB2BRBACClient(cachedConfig, dynamicConfig, _subscriptionService) {
5168
- var _this20 = this;
5329
+ var _this21 = this;
5169
5330
  _classCallCheck(this, HeadlessB2BRBACClient);
5170
5331
  this._subscriptionService = _subscriptionService;
5171
5332
  this.isAuthorizedSync = function (resourceId, action) {
5172
5333
  var _a;
5173
- return !!((_a = _this20.cachedPolicy) === null || _a === void 0 ? void 0 : _a.callerIsAuthorized(_this20.roleIds(), resourceId, action));
5334
+ return !!((_a = _this21.cachedPolicy) === null || _a === void 0 ? void 0 : _a.callerIsAuthorized(_this21.roleIds(), resourceId, action));
5174
5335
  };
5175
5336
  this.isAuthorized = function (resourceId, action) {
5176
- return _this20.policyPromise.then(function (policy) {
5177
- return policy.callerIsAuthorized(_this20.roleIds(), resourceId, action);
5337
+ return _this21.policyPromise.then(function (policy) {
5338
+ return policy.callerIsAuthorized(_this21.roleIds(), resourceId, action);
5178
5339
  });
5179
5340
  };
5180
5341
  this.cachedPolicy = cachedConfig.rbacPolicy ? RBACPolicy.fromJSON(cachedConfig.rbacPolicy) : null;
@@ -5183,16 +5344,16 @@ var HeadlessB2BRBACClient = /*#__PURE__*/function () {
5183
5344
  logger.error('Unable to retrieve RBAC policy from servers. Assuming caller has no permissions.');
5184
5345
  return new RBACPolicy([], []);
5185
5346
  }
5186
- _this20.cachedPolicy = RBACPolicy.fromJSON(data.rbacPolicy);
5187
- return _this20.cachedPolicy;
5347
+ _this21.cachedPolicy = RBACPolicy.fromJSON(data.rbacPolicy);
5348
+ return _this21.cachedPolicy;
5188
5349
  });
5189
5350
  }
5190
5351
  _createClass(HeadlessB2BRBACClient, [{
5191
5352
  key: "allPermissions",
5192
5353
  value: function allPermissions() {
5193
- var _this21 = this;
5354
+ var _this22 = this;
5194
5355
  return this.policyPromise.then(function (policy) {
5195
- return policy.allPermissionsForCaller(_this21.roleIds());
5356
+ return policy.allPermissionsForCaller(_this22.roleIds());
5196
5357
  });
5197
5358
  }
5198
5359
  }, {
@@ -5245,18 +5406,18 @@ var IframeHostClient = /*#__PURE__*/function () {
5245
5406
  }, {
5246
5407
  key: "call",
5247
5408
  value: function call(method, args) {
5248
- return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee137() {
5249
- var _this22 = this;
5409
+ return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee140() {
5410
+ var _this23 = this;
5250
5411
  var frame, channel;
5251
- return _regeneratorRuntime().wrap(function _callee137$(_context137) {
5252
- while (1) switch (_context137.prev = _context137.next) {
5412
+ return _regeneratorRuntime().wrap(function _callee140$(_context140) {
5413
+ while (1) switch (_context140.prev = _context140.next) {
5253
5414
  case 0:
5254
- _context137.next = 2;
5415
+ _context140.next = 2;
5255
5416
  return this.frame;
5256
5417
  case 2:
5257
- frame = _context137.sent;
5418
+ frame = _context140.sent;
5258
5419
  channel = new MessageChannel();
5259
- return _context137.abrupt("return", new Promise(function (resolve, reject) {
5420
+ return _context140.abrupt("return", new Promise(function (resolve, reject) {
5260
5421
  var _a;
5261
5422
  channel.port1.onmessage = function (event) {
5262
5423
  var resp = event.data;
@@ -5271,13 +5432,13 @@ var IframeHostClient = /*#__PURE__*/function () {
5271
5432
  method: method,
5272
5433
  args: args
5273
5434
  };
5274
- (_a = frame.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(message, _this22.iframeURL, [channel.port2]);
5435
+ (_a = frame.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(message, _this23.iframeURL, [channel.port2]);
5275
5436
  }));
5276
5437
  case 5:
5277
5438
  case "end":
5278
- return _context137.stop();
5439
+ return _context140.stop();
5279
5440
  }
5280
- }, _callee137, this);
5441
+ }, _callee140, this);
5281
5442
  }));
5282
5443
  }
5283
5444
  }]);
@@ -5292,11 +5453,11 @@ var SearchDataManager = /*#__PURE__*/function () {
5292
5453
  _createClass(SearchDataManager, [{
5293
5454
  key: "searchUser",
5294
5455
  value: function searchUser(email) {
5295
- var _this24 = this;
5456
+ var _this25 = this;
5296
5457
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha().then(function (_ref7) {
5297
5458
  var dfp_telemetry_id = _ref7.dfp_telemetry_id,
5298
5459
  captcha_token = _ref7.captcha_token;
5299
- return _this24._networkClient.fetchSDK({
5460
+ return _this25._networkClient.fetchSDK({
5300
5461
  url: "/users/search",
5301
5462
  method: 'POST',
5302
5463
  body: {
@@ -5327,52 +5488,52 @@ var shouldTryRefresh = function shouldTryRefresh(state) {
5327
5488
  };
5328
5489
  var SessionManager = /*#__PURE__*/function () {
5329
5490
  function SessionManager(_subscriptionService, _headlessSessionClient) {
5330
- var _this25 = this;
5491
+ var _this26 = this;
5331
5492
  _classCallCheck(this, SessionManager);
5332
5493
  this._subscriptionService = _subscriptionService;
5333
5494
  this._headlessSessionClient = _headlessSessionClient;
5334
5495
  this._onDataChange = function (state) {
5335
5496
  if (shouldTryRefresh(state)) {
5336
- _this25.scheduleBackgroundRefresh();
5497
+ _this26.scheduleBackgroundRefresh();
5337
5498
  } else {
5338
- _this25.cancelBackgroundRefresh();
5499
+ _this26.cancelBackgroundRefresh();
5339
5500
  }
5340
5501
  };
5341
5502
  this._reauthenticateWithBackoff = function () {
5342
- return __awaiter$1(_this25, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee139() {
5503
+ return __awaiter$1(_this26, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee142() {
5343
5504
  var count;
5344
- return _regeneratorRuntime().wrap(function _callee139$(_context139) {
5345
- while (1) switch (_context139.prev = _context139.next) {
5505
+ return _regeneratorRuntime().wrap(function _callee142$(_context142) {
5506
+ while (1) switch (_context142.prev = _context142.next) {
5346
5507
  case 0:
5347
5508
  count = 0;
5348
5509
  case 1:
5349
- _context139.prev = 2;
5350
- _context139.next = 5;
5510
+ _context142.prev = 2;
5511
+ _context142.next = 5;
5351
5512
  return this._headlessSessionClient.authenticate();
5352
5513
  case 5:
5353
- return _context139.abrupt("return", _context139.sent);
5514
+ return _context142.abrupt("return", _context142.sent);
5354
5515
  case 8:
5355
- _context139.prev = 8;
5356
- _context139.t0 = _context139["catch"](2);
5357
- if (!SessionManager.isUnrecoverableError(_context139.t0)) {
5358
- _context139.next = 12;
5516
+ _context142.prev = 8;
5517
+ _context142.t0 = _context142["catch"](2);
5518
+ if (!SessionManager.isUnrecoverableError(_context142.t0)) {
5519
+ _context142.next = 12;
5359
5520
  break;
5360
5521
  }
5361
- return _context139.abrupt("return", Promise.reject(_context139.t0));
5522
+ return _context142.abrupt("return", Promise.reject(_context142.t0));
5362
5523
  case 12:
5363
5524
  count++;
5364
- _context139.next = 15;
5525
+ _context142.next = 15;
5365
5526
  return new Promise(function (done) {
5366
5527
  return setTimeout(done, SessionManager.timeoutForAttempt(count));
5367
5528
  });
5368
5529
  case 15:
5369
- _context139.next = 1;
5530
+ _context142.next = 1;
5370
5531
  break;
5371
5532
  case 17:
5372
5533
  case "end":
5373
- return _context139.stop();
5534
+ return _context142.stop();
5374
5535
  }
5375
- }, _callee139, this, [[2, 8]]);
5536
+ }, _callee142, this, [[2, 8]]);
5376
5537
  }));
5377
5538
  };
5378
5539
  this.timeout = null;
@@ -5381,23 +5542,23 @@ var SessionManager = /*#__PURE__*/function () {
5381
5542
  _createClass(SessionManager, [{
5382
5543
  key: "performBackgroundRefresh",
5383
5544
  value: function performBackgroundRefresh() {
5384
- var _this26 = this;
5545
+ var _this27 = this;
5385
5546
  this._reauthenticateWithBackoff().then(function () {
5386
- _this26.scheduleBackgroundRefresh();
5547
+ _this27.scheduleBackgroundRefresh();
5387
5548
  })["catch"](function (error) {
5388
5549
  logger.warn('Session background refresh failed. Signalling to app that user is logged out.', {
5389
5550
  error: error
5390
5551
  });
5391
- _this26._subscriptionService.destroySession();
5552
+ _this27._subscriptionService.destroySession();
5392
5553
  });
5393
5554
  }
5394
5555
  }, {
5395
5556
  key: "scheduleBackgroundRefresh",
5396
5557
  value: function scheduleBackgroundRefresh() {
5397
- var _this27 = this;
5558
+ var _this28 = this;
5398
5559
  this.cancelBackgroundRefresh();
5399
5560
  this.timeout = setTimeout(function () {
5400
- _this27.performBackgroundRefresh();
5561
+ _this28.performBackgroundRefresh();
5401
5562
  }, SessionManager.REFRESH_INTERVAL_MS);
5402
5563
  }
5403
5564
  }, {
@@ -5426,34 +5587,34 @@ var SessionManager = /*#__PURE__*/function () {
5426
5587
  }();
5427
5588
  SessionManager.REFRESH_INTERVAL_MS = 1000 * 60 * 3;
5428
5589
  var StateChangeClient = /*#__PURE__*/_createClass(function StateChangeClient(_subscriptionService, emptyState) {
5429
- var _this28 = this;
5590
+ var _this29 = this;
5430
5591
  _classCallCheck(this, StateChangeClient);
5431
5592
  this._subscriptionService = _subscriptionService;
5432
5593
  this.emptyState = emptyState;
5433
5594
  this.onStateChange = function (callback) {
5434
- return _this28._subscriptionService.subscribeToState(function (state) {
5435
- callback(state !== null && state !== void 0 ? state : _this28.emptyState);
5595
+ return _this29._subscriptionService.subscribeToState(function (state) {
5596
+ callback(state !== null && state !== void 0 ? state : _this29.emptyState);
5436
5597
  });
5437
5598
  };
5438
5599
  });
5439
5600
  var WILDCARD_ACTION = '*';
5440
5601
  var RBACPolicy = /*#__PURE__*/function () {
5441
5602
  function RBACPolicy(roles, resources) {
5442
- var _this34 = this;
5603
+ var _this35 = this;
5443
5604
  _classCallCheck(this, RBACPolicy);
5444
5605
  this.roles = roles;
5445
5606
  this.resources = resources;
5446
5607
  this.rolesByID = {};
5447
5608
  roles.forEach(function (role) {
5448
- return _this34.rolesByID[role.role_id] = role;
5609
+ return _this35.rolesByID[role.role_id] = role;
5449
5610
  });
5450
5611
  }
5451
5612
  _createClass(RBACPolicy, [{
5452
5613
  key: "callerIsAuthorized",
5453
5614
  value: function callerIsAuthorized(memberRoles, resourceId, action) {
5454
- var _this35 = this;
5615
+ var _this36 = this;
5455
5616
  return !!memberRoles.map(function (roleId) {
5456
- return _this35.rolesByID[roleId];
5617
+ return _this36.rolesByID[roleId];
5457
5618
  }).filter(function (v) {
5458
5619
  return v;
5459
5620
  }).flatMap(function (role) {
@@ -5467,12 +5628,12 @@ var RBACPolicy = /*#__PURE__*/function () {
5467
5628
  }, {
5468
5629
  key: "allPermissionsForCaller",
5469
5630
  value: function allPermissionsForCaller(memberRoles) {
5470
- var _this36 = this;
5631
+ var _this37 = this;
5471
5632
  var allPermsMap = Object.create(null);
5472
5633
  this.resources.forEach(function (resource) {
5473
5634
  allPermsMap[resource.resource_id] = {};
5474
5635
  resource.actions.forEach(function (action) {
5475
- allPermsMap[resource.resource_id][action] = _this36.callerIsAuthorized(memberRoles, resource.resource_id, action);
5636
+ allPermsMap[resource.resource_id][action] = _this37.callerIsAuthorized(memberRoles, resource.resource_id, action);
5476
5637
  });
5477
5638
  });
5478
5639
  return allPermsMap;