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