@stytch/vanilla-js 4.4.0 → 4.4.2

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.
@@ -2616,7 +2616,7 @@ var Fe = Promise.resolve({
2616
2616
  }
2617
2617
  return t.abrupt("return", this.authenticate(e));
2618
2618
  case 17:
2619
- throw m.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
2619
+ throw m.includes(t.t0.error_type) && this._subscriptionService.destroySession(), t.t0;
2620
2620
  case 19:
2621
2621
  case "end":
2622
2622
  return t.stop();
@@ -3147,7 +3147,7 @@ var Ge = ne(function e(t, r) {
3147
3147
  })["catch"](function (t) {
3148
3148
  Oe("Session background refresh failed. Signalling to app that user is logged out.", {
3149
3149
  error: t
3150
- }), e._subscriptionService.destroyState();
3150
+ }), e._subscriptionService.destroySession();
3151
3151
  });
3152
3152
  }
3153
3153
  }, {
@@ -3644,6 +3644,7 @@ var ht = /*#__PURE__*/function () {
3644
3644
  existing_password: e.existing_password,
3645
3645
  new_password: e.new_password,
3646
3646
  locale: e.locale,
3647
+ session_duration_minutes: e.session_duration_minutes,
3647
3648
  captcha_token: r,
3648
3649
  dfp_telemetry_id: t
3649
3650
  },
@@ -3852,11 +3853,37 @@ var _t = /*#__PURE__*/function () {
3852
3853
  }]);
3853
3854
  return _t;
3854
3855
  }();
3855
- var ft = /*#__PURE__*/_createClass(function ft(e) {
3856
+ function ft(e, t, r, n) {
3857
+ return new (r || (r = Promise))(function (i, o) {
3858
+ function s(e) {
3859
+ try {
3860
+ c(n.next(e));
3861
+ } catch (e) {
3862
+ o(e);
3863
+ }
3864
+ }
3865
+ function a(e) {
3866
+ try {
3867
+ c(n["throw"](e));
3868
+ } catch (e) {
3869
+ o(e);
3870
+ }
3871
+ }
3872
+ function c(e) {
3873
+ var t;
3874
+ e.done ? i(e.value) : (t = e.value, t instanceof r ? t : new r(function (e) {
3875
+ e(t);
3876
+ })).then(s, a);
3877
+ }
3878
+ c((n = n.apply(e, t || [])).next());
3879
+ });
3880
+ }
3881
+ "function" == typeof SuppressedError && SuppressedError;
3882
+ var mt = /*#__PURE__*/_createClass(function mt(e) {
3856
3883
  var _this3 = this;
3857
- _classCallCheck(this, ft);
3884
+ _classCallCheck(this, mt);
3858
3885
  this.bootstrapPromise = e, this.executeRecaptcha = function () {
3859
- return at(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
3886
+ return ft(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
3860
3887
  var _yield$this$state, e, t, r;
3861
3888
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
3862
3889
  while (1) switch (_context12.prev = _context12.next) {
@@ -3887,7 +3914,7 @@ var ft = /*#__PURE__*/_createClass(function ft(e) {
3887
3914
  }, _callee12, this);
3888
3915
  }));
3889
3916
  }, this.state = e.then(function (e) {
3890
- return at(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
3917
+ return ft(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
3891
3918
  var t;
3892
3919
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
3893
3920
  while (1) switch (_context13.prev = _context13.next) {
@@ -3925,9 +3952,9 @@ var ft = /*#__PURE__*/_createClass(function ft(e) {
3925
3952
  }));
3926
3953
  });
3927
3954
  });
3928
- var mt = /*#__PURE__*/function () {
3929
- function mt(e, t, r, n) {
3930
- _classCallCheck(this, mt);
3955
+ var vt = /*#__PURE__*/function () {
3956
+ function vt(e, t, r, n) {
3957
+ _classCallCheck(this, vt);
3931
3958
  this._publicToken = e, this._subscriptionDataLayer = t, this.baseURL = r, this.additionalTelemetryDataFn = n, this.updateSessionToken = function () {
3932
3959
  return null;
3933
3960
  }, this.eventLogger = new Me({
@@ -3936,7 +3963,7 @@ var mt = /*#__PURE__*/function () {
3936
3963
  logEventURL: this.buildSDKUrl("/events")
3937
3964
  });
3938
3965
  }
3939
- _createClass(mt, [{
3966
+ _createClass(vt, [{
3940
3967
  key: "logEvent",
3941
3968
  value: function logEvent(_ref) {
3942
3969
  var e = _ref.name,
@@ -3967,7 +3994,7 @@ var mt = /*#__PURE__*/function () {
3967
3994
  },
3968
3995
  sdk: {
3969
3996
  identifier: "Stytch.js Javascript SDK",
3970
- version: "4.4.0"
3997
+ version: "4.4.2"
3971
3998
  }
3972
3999
  });
3973
4000
  }
@@ -3978,7 +4005,7 @@ var mt = /*#__PURE__*/function () {
3978
4005
  t = _ref2.body,
3979
4006
  r = _ref2.errorMessage,
3980
4007
  n = _ref2.method;
3981
- return at(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
4008
+ return ft(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
3982
4009
  var i, o, s, a;
3983
4010
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
3984
4011
  while (1) switch (_context14.prev = _context14.next) {
@@ -4008,7 +4035,7 @@ var mt = /*#__PURE__*/function () {
4008
4035
  r = _ref3.errorMessage,
4009
4036
  n = _ref3.method,
4010
4037
  i = _ref3.retryCallback;
4011
- return at(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
4038
+ return ft(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
4012
4039
  var o, s, a, c;
4013
4040
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
4014
4041
  while (1) switch (_context15.prev = _context15.next) {
@@ -4079,18 +4106,18 @@ var mt = /*#__PURE__*/function () {
4079
4106
  return "".concat(this.baseURL, "/sdk/v1").concat(e);
4080
4107
  }
4081
4108
  }]);
4082
- return mt;
4109
+ return vt;
4083
4110
  }();
4084
- function vt(e) {
4111
+ function bt(e) {
4085
4112
  var t = e.toString(16);
4086
4113
  return 1 === t.length && (t = "0" + t), t;
4087
4114
  }
4088
- var bt = /*#__PURE__*/function () {
4089
- function bt(e, t) {
4090
- _classCallCheck(this, bt);
4115
+ var gt = /*#__PURE__*/function () {
4116
+ function gt(e, t) {
4117
+ _classCallCheck(this, gt);
4091
4118
  this._dataLayer = e, this.namespace = t;
4092
4119
  }
4093
- _createClass(bt, [{
4120
+ _createClass(gt, [{
4094
4121
  key: "key",
4095
4122
  value: function key() {
4096
4123
  return "PKCE_VERIFIER:" + this.namespace;
@@ -4098,13 +4125,13 @@ var bt = /*#__PURE__*/function () {
4098
4125
  }, {
4099
4126
  key: "startPKCETransaction",
4100
4127
  value: function startPKCETransaction() {
4101
- return at(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
4128
+ return ft(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
4102
4129
  var e;
4103
4130
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
4104
4131
  while (1) switch (_context16.prev = _context16.next) {
4105
4132
  case 0:
4106
4133
  _context16.next = 2;
4107
- return bt.createProofkeyPair();
4134
+ return gt.createProofkeyPair();
4108
4135
  case 2:
4109
4136
  e = _context16.sent;
4110
4137
  return _context16.abrupt("return", (this._dataLayer.setItem(this.key(), JSON.stringify(e)), e));
@@ -4133,7 +4160,7 @@ var bt = /*#__PURE__*/function () {
4133
4160
  }], [{
4134
4161
  key: "createProofkeyPair",
4135
4162
  value: function createProofkeyPair() {
4136
- return at(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
4163
+ return ft(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
4137
4164
  var _String$fromCharCode;
4138
4165
  var e, t, r, n;
4139
4166
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
@@ -4141,7 +4168,7 @@ var bt = /*#__PURE__*/function () {
4141
4168
  case 0:
4142
4169
  e = new Uint32Array(16);
4143
4170
  window.crypto.getRandomValues(e);
4144
- t = Array.from(e).map(vt).join("");
4171
+ t = Array.from(e).map(bt).join("");
4145
4172
  _context17.next = 5;
4146
4173
  return window.crypto.subtle.digest("SHA-256", new TextEncoder().encode(t));
4147
4174
  case 5:
@@ -4158,14 +4185,14 @@ var bt = /*#__PURE__*/function () {
4158
4185
  }));
4159
4186
  }
4160
4187
  }]);
4161
- return bt;
4188
+ return gt;
4162
4189
  }();
4163
- var gt = /*#__PURE__*/function () {
4164
- function gt(e) {
4165
- _classCallCheck(this, gt);
4190
+ var yt = /*#__PURE__*/function () {
4191
+ function yt(e) {
4192
+ _classCallCheck(this, yt);
4166
4193
  this._networkClient = e;
4167
4194
  }
4168
- _createClass(gt, [{
4195
+ _createClass(yt, [{
4169
4196
  key: "searchUser",
4170
4197
  value: function searchUser(e) {
4171
4198
  return this._networkClient.fetchSDK({
@@ -4203,9 +4230,9 @@ var gt = /*#__PURE__*/function () {
4203
4230
  });
4204
4231
  }
4205
4232
  }]);
4206
- return gt;
4233
+ return yt;
4207
4234
  }();
4208
- var yt = function yt(e) {
4235
+ var kt = function kt(e) {
4209
4236
  return (document.cookie ? document.cookie.split("; ") : []).filter(function (t) {
4210
4237
  var _t$split = t.split("="),
4211
4238
  _t$split2 = _slicedToArray(_t$split, 1),
@@ -4214,17 +4241,17 @@ var yt = function yt(e) {
4214
4241
  }).length > 1;
4215
4242
  };
4216
4243
  /*! js-cookie v3.0.1 | MIT */
4217
- function kt(e) {
4244
+ function wt(e) {
4218
4245
  for (var t = 1; t < arguments.length; t++) {
4219
4246
  var r = arguments[t];
4220
4247
  for (var n in r) e[n] = r[n];
4221
4248
  }
4222
4249
  return e;
4223
4250
  }
4224
- var wt = function e(t, r) {
4251
+ var St = function e(t, r) {
4225
4252
  function n(e, n, i) {
4226
4253
  if ("undefined" != typeof document) {
4227
- "number" == typeof (i = kt({}, r, i)).expires && (i.expires = new Date(Date.now() + 864e5 * i.expires)), i.expires && (i.expires = i.expires.toUTCString()), e = encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
4254
+ "number" == typeof (i = wt({}, r, i)).expires && (i.expires = new Date(Date.now() + 864e5 * i.expires)), i.expires && (i.expires = i.expires.toUTCString()), e = encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
4228
4255
  var o = "";
4229
4256
  for (var s in i) i[s] && (o += "; " + s, !0 !== i[s] && (o += "=" + i[s].split(";")[0]));
4230
4257
  return document.cookie = e + "=" + t.write(n, e) + o;
@@ -4246,15 +4273,15 @@ var wt = function e(t, r) {
4246
4273
  }
4247
4274
  },
4248
4275
  remove: function remove(e, t) {
4249
- n(e, "", kt({}, t, {
4276
+ n(e, "", wt({}, t, {
4250
4277
  expires: -1
4251
4278
  }));
4252
4279
  },
4253
4280
  withAttributes: function withAttributes(t) {
4254
- return e(this.converter, kt({}, this.attributes, t));
4281
+ return e(this.converter, wt({}, this.attributes, t));
4255
4282
  },
4256
4283
  withConverter: function withConverter(t) {
4257
- return e(kt({}, this.converter, t), this.attributes);
4284
+ return e(wt({}, this.converter, t), this.attributes);
4258
4285
  }
4259
4286
  }, {
4260
4287
  attributes: {
@@ -4274,26 +4301,26 @@ var wt = function e(t, r) {
4274
4301
  }, {
4275
4302
  path: "/"
4276
4303
  });
4277
- var St = function St(e) {
4304
+ var Pt = function Pt(e) {
4278
4305
  var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
4279
4306
  return "stytch_sdk_state_".concat(e).concat(t ? "::".concat(t) : "");
4280
4307
  };
4281
- var Pt = /*#__PURE__*/function () {
4282
- function Pt(e, t) {
4308
+ var At = /*#__PURE__*/function () {
4309
+ function At(e, t) {
4283
4310
  var _this4 = this;
4284
- _classCallCheck(this, Pt);
4311
+ _classCallCheck(this, At);
4285
4312
  this.browserSessionStorage = {
4286
4313
  getItem: function getItem(e) {
4287
- return sessionStorage.getItem(St(_this4.publicToken, e));
4314
+ return sessionStorage.getItem(Pt(_this4.publicToken, e));
4288
4315
  },
4289
4316
  setItem: function setItem(e, t) {
4290
- return sessionStorage.setItem(St(_this4.publicToken, e), t);
4317
+ return sessionStorage.setItem(Pt(_this4.publicToken, e), t);
4291
4318
  },
4292
4319
  removeItem: function removeItem(e) {
4293
- return sessionStorage.removeItem(St(_this4.publicToken, e));
4320
+ return sessionStorage.removeItem(Pt(_this4.publicToken, e));
4294
4321
  }
4295
4322
  }, this.publicToken = e, this.state = null, this.stateKeysUpdated = new Set(), this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (Be("SubscriptionDataLayer").isOptionalString("cookieOptions.opaqueTokenCookieName", t.cookieOptions.opaqueTokenCookieName).isOptionalString("cookieOptions.jwtCookieName", t.cookieOptions.jwtCookieName).isOptionalString("cookieOptions.istCookieName", t.cookieOptions.istCookieName).isOptionalString("cookieOptions.path", t.cookieOptions.path).isOptionalString("cookieOptions.domain", t.cookieOptions.domain), this._jwtCookieName = t.cookieOptions.jwtCookieName || null, this._opaqueTokenCookieName = t.cookieOptions.opaqueTokenCookieName || null, this._cookiePath = t.cookieOptions.path || null, this._domain = t.cookieOptions.domain || null, this._cookieAvailableToSubdomains = t.cookieOptions.availableToSubdomains || !1, this._istCookieName = t.cookieOptions.istCookieName || null) : (this._opaqueTokenCookieName = null, this._jwtCookieName = null, this._cookiePath = null, this._domain = null, this._cookieAvailableToSubdomains = !1, this._istCookieName = null);
4296
- var r = localStorage.getItem(St(this.publicToken));
4323
+ var r = localStorage.getItem(Pt(this.publicToken));
4297
4324
  if (!r) return;
4298
4325
  var n;
4299
4326
  try {
@@ -4303,7 +4330,7 @@ var Pt = /*#__PURE__*/function () {
4303
4330
  }
4304
4331
  this.state = n;
4305
4332
  }
4306
- _createClass(Pt, [{
4333
+ _createClass(At, [{
4307
4334
  key: "opaqueTokenCookieName",
4308
4335
  get: function get() {
4309
4336
  var e;
@@ -4325,14 +4352,14 @@ var Pt = /*#__PURE__*/function () {
4325
4352
  key: "readSessionCookie",
4326
4353
  value: function readSessionCookie() {
4327
4354
  return {
4328
- session_token: wt.get(this.opaqueTokenCookieName),
4329
- session_jwt: wt.get(this.jwtCookieName)
4355
+ session_token: St.get(this.opaqueTokenCookieName),
4356
+ session_jwt: St.get(this.jwtCookieName)
4330
4357
  };
4331
4358
  }
4332
4359
  }, {
4333
4360
  key: "readIntermediateSessionTokenCookie",
4334
4361
  value: function readIntermediateSessionTokenCookie() {
4335
- return wt.get(this.istCookieName);
4362
+ return St.get(this.istCookieName);
4336
4363
  }
4337
4364
  }, {
4338
4365
  key: "writeSessionCookie",
@@ -4341,32 +4368,32 @@ var Pt = /*#__PURE__*/function () {
4341
4368
  var o = e.state,
4342
4369
  s = e.session_token,
4343
4370
  a = e.session_jwt,
4344
- c = Pt.generateCookieOpts({
4371
+ c = At.generateCookieOpts({
4345
4372
  expiresAt: null !== (r = null === (t = null == o ? void 0 : o.session) || void 0 === t ? void 0 : t.expires_at) && void 0 !== r ? r : "",
4346
4373
  availableToSubdomains: this._cookieAvailableToSubdomains,
4347
4374
  path: this._cookiePath,
4348
4375
  domain: this._domain
4349
4376
  });
4350
- wt.set(this.opaqueTokenCookieName, s, c), wt.set(this.jwtCookieName, a, c);
4351
- var u = Pt.generateCookieOpts({
4377
+ St.set(this.opaqueTokenCookieName, s, c), St.set(this.jwtCookieName, a, c);
4378
+ var u = At.generateCookieOpts({
4352
4379
  expiresAt: null !== (i = null === (n = null == o ? void 0 : o.session) || void 0 === n ? void 0 : n.expires_at) && void 0 !== i ? i : "",
4353
4380
  availableToSubdomains: !this._cookieAvailableToSubdomains,
4354
4381
  path: this._cookiePath,
4355
4382
  domain: this._domain
4356
4383
  });
4357
- yt(this.jwtCookieName) && wt.remove(this.jwtCookieName, u), yt(this.opaqueTokenCookieName) && wt.remove(this.opaqueTokenCookieName, u), yt(this.jwtCookieName) && Oe("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), yt(this.opaqueTokenCookieName) && Oe("Could not remove extraneous opaque token cookie.");
4384
+ kt(this.jwtCookieName) && St.remove(this.jwtCookieName, u), kt(this.opaqueTokenCookieName) && St.remove(this.opaqueTokenCookieName, u), kt(this.jwtCookieName) && Oe("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), kt(this.opaqueTokenCookieName) && Oe("Could not remove extraneous opaque token cookie.");
4358
4385
  }
4359
4386
  }, {
4360
4387
  key: "writeIntermediateSessionTokenCookie",
4361
4388
  value: function writeIntermediateSessionTokenCookie(e) {
4362
4389
  var t = new Date(Date.now() + 6e5),
4363
- r = Pt.generateCookieOpts({
4390
+ r = At.generateCookieOpts({
4364
4391
  expiresAt: t.toString(),
4365
4392
  availableToSubdomains: this._cookieAvailableToSubdomains,
4366
4393
  path: this._cookiePath,
4367
4394
  domain: this._domain
4368
4395
  });
4369
- wt.set(this.istCookieName, e, r);
4396
+ St.set(this.istCookieName, e, r);
4370
4397
  }
4371
4398
  }, {
4372
4399
  key: "removeSessionCookie",
@@ -4385,14 +4412,14 @@ var Pt = /*#__PURE__*/function () {
4385
4412
  [!0, !1].forEach(function (t) {
4386
4413
  [_this5._cookiePath, null].forEach(function (r) {
4387
4414
  [_this5._domain, null].forEach(function (n) {
4388
- var i = Pt.generateCookieOpts({
4415
+ var i = At.generateCookieOpts({
4389
4416
  expiresAt: new Date(0).toString(),
4390
4417
  availableToSubdomains: t,
4391
4418
  path: r,
4392
4419
  domain: n
4393
4420
  });
4394
4421
  e.forEach(function (e) {
4395
- wt.remove(e, i);
4422
+ St.remove(e, i);
4396
4423
  });
4397
4424
  });
4398
4425
  });
@@ -4401,22 +4428,22 @@ var Pt = /*#__PURE__*/function () {
4401
4428
  }, {
4402
4429
  key: "syncToLocalStorage",
4403
4430
  value: function syncToLocalStorage() {
4404
- localStorage.setItem(St(this.publicToken), JSON.stringify(this.state));
4431
+ localStorage.setItem(Pt(this.publicToken), JSON.stringify(this.state));
4405
4432
  }
4406
4433
  }, {
4407
4434
  key: "getItem",
4408
4435
  value: function getItem(e) {
4409
- return localStorage.getItem(St(this.publicToken, e));
4436
+ return localStorage.getItem(Pt(this.publicToken, e));
4410
4437
  }
4411
4438
  }, {
4412
4439
  key: "setItem",
4413
4440
  value: function setItem(e, t) {
4414
- return localStorage.setItem(St(this.publicToken, e), t);
4441
+ return localStorage.setItem(Pt(this.publicToken, e), t);
4415
4442
  }
4416
4443
  }, {
4417
4444
  key: "removeItem",
4418
4445
  value: function removeItem(e) {
4419
- return localStorage.removeItem(St(this.publicToken, e));
4446
+ return localStorage.removeItem(Pt(this.publicToken, e));
4420
4447
  }
4421
4448
  }, {
4422
4449
  key: "markStateKeysUpdated",
@@ -4441,31 +4468,31 @@ var Pt = /*#__PURE__*/function () {
4441
4468
  return e && (i.path = e), Boolean("localhost" === window.location.hostname || "[::1]" === window.location.hostname || window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)) ? i.secure = !1 : (r && (i.domain = t || window.location.host), i.secure = !0), i;
4442
4469
  }
4443
4470
  }]);
4444
- return Pt;
4471
+ return At;
4445
4472
  }();
4446
- var At = /*#__PURE__*/function (_Pt) {
4447
- _inherits(At, _Pt);
4448
- var _super2 = _createSuper(At);
4449
- function At() {
4450
- _classCallCheck(this, At);
4473
+ var Ct = /*#__PURE__*/function (_At) {
4474
+ _inherits(Ct, _At);
4475
+ var _super2 = _createSuper(Ct);
4476
+ function Ct() {
4477
+ _classCallCheck(this, Ct);
4451
4478
  return _super2.apply(this, arguments);
4452
4479
  }
4453
- return _createClass(At);
4454
- }(Pt);
4455
- var Ct = Symbol["for"]("__stytch_b2b_DataLayer"),
4456
- Et = function Et(e, t) {
4480
+ return _createClass(Ct);
4481
+ }(At);
4482
+ var Et = Symbol["for"]("__stytch_b2b_DataLayer"),
4483
+ Tt = function Tt(e, t) {
4457
4484
  var r = function () {
4458
4485
  var e = window;
4459
- return e[Ct] || (e[Ct] = {}), e[Ct];
4486
+ return e[Et] || (e[Et] = {}), e[Et];
4460
4487
  }();
4461
- return r[e] || (r[e] = new At(e, t)), r[e];
4488
+ return r[e] || (r[e] = new Ct(e, t)), r[e];
4462
4489
  },
4463
- Tt = function Tt(e, t) {
4490
+ Ot = function Ot(e, t) {
4464
4491
  Object.values(e).forEach(function (e) {
4465
4492
  return e(t);
4466
4493
  });
4467
4494
  },
4468
- Ot = function () {
4495
+ xt = function () {
4469
4496
  var e = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).KEYS_TO_EXCLUDE,
4470
4497
  t = void 0 === e ? [] : e;
4471
4498
  return function e(r, n) {
@@ -4484,21 +4511,20 @@ var Ct = Symbol["for"]("__stytch_b2b_DataLayer"),
4484
4511
  }({
4485
4512
  KEYS_TO_EXCLUDE: ["last_accessed_at"]
4486
4513
  });
4487
- var xt = /*#__PURE__*/function () {
4488
- function xt(e, t) {
4514
+ var Dt = /*#__PURE__*/function () {
4515
+ function Dt(e, t) {
4489
4516
  var _this7 = this;
4490
- _classCallCheck(this, xt);
4517
+ _classCallCheck(this, Dt);
4491
4518
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4492
- if (e.key !== St(_this7._publicToken)) return;
4493
- if (null === e.newValue || "null" === e.newValue) return void _this7.destroyState();
4494
- var t = JSON.parse(e.newValue);
4519
+ if (e.key !== Pt(_this7._publicToken)) return;
4520
+ var t = null === e.newValue || "null" === e.newValue ? null : JSON.parse(e.newValue);
4495
4521
  _this7.updateState(t);
4496
4522
  }, window.addEventListener("storage", this._listen);
4497
4523
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4498
4524
  r = _this$_datalayer$read.session_token;
4499
- r || this.destroyState();
4525
+ r || this.destroySession();
4500
4526
  }
4501
- _createClass(xt, [{
4527
+ _createClass(Dt, [{
4502
4528
  key: "getTokens",
4503
4529
  value: function getTokens() {
4504
4530
  var _this$_datalayer$read2 = this._datalayer.readSessionCookie(),
@@ -4524,6 +4550,11 @@ var xt = /*#__PURE__*/function () {
4524
4550
  intermediate_session_token: null
4525
4551
  });
4526
4552
  }
4553
+ }, {
4554
+ key: "destroySession",
4555
+ value: function destroySession() {
4556
+ this._datalayer.removeSessionCookie(), this.updateState(null);
4557
+ }
4527
4558
  }, {
4528
4559
  key: "_updateStateAndTokensInternal",
4529
4560
  value: function _updateStateAndTokensInternal(e) {
@@ -4531,7 +4562,7 @@ var xt = /*#__PURE__*/function () {
4531
4562
  r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4532
4563
  this._datalayer.state = r;
4533
4564
  var n = e.state ? Object.keys(e.state) : [];
4534
- !this._datalayer.markStateKeysUpdated(n) && Ot(t, r) || Tt(this._datalayer.subscriptions, r);
4565
+ !this._datalayer.markStateKeysUpdated(n) && xt(t, r) || Ot(this._datalayer.subscriptions, r);
4535
4566
  }
4536
4567
  }, {
4537
4568
  key: "updateStateAndTokens",
@@ -4546,8 +4577,8 @@ var xt = /*#__PURE__*/function () {
4546
4577
  this._datalayer.state = r;
4547
4578
  var n = e ? Object.keys(e) : [],
4548
4579
  i = this._datalayer.markStateKeysUpdated(n),
4549
- o = !Ot(t, r);
4550
- (i || o) && (Tt(this._datalayer.subscriptions, r), o && this._datalayer.syncToLocalStorage());
4580
+ o = !xt(t, r);
4581
+ (i || o) && (Ot(this._datalayer.subscriptions, r), o && this._datalayer.syncToLocalStorage());
4551
4582
  }
4552
4583
  }, {
4553
4584
  key: "updateTokens",
@@ -4587,14 +4618,14 @@ var xt = /*#__PURE__*/function () {
4587
4618
  return null;
4588
4619
  }
4589
4620
  }]);
4590
- return xt;
4621
+ return Dt;
4591
4622
  }();
4592
- var Dt = /*#__PURE__*/function (_xt) {
4593
- _inherits(Dt, _xt);
4594
- var _super3 = _createSuper(Dt);
4595
- function Dt() {
4623
+ var It = /*#__PURE__*/function (_Dt) {
4624
+ _inherits(It, _Dt);
4625
+ var _super3 = _createSuper(It);
4626
+ function It() {
4596
4627
  var _this8;
4597
- _classCallCheck(this, Dt);
4628
+ _classCallCheck(this, It);
4598
4629
  _this8 = _super3.apply(this, arguments), _this8.updateMember = function (e) {
4599
4630
  return _this8.updateState({
4600
4631
  member: e
@@ -4615,9 +4646,9 @@ var Dt = /*#__PURE__*/function (_xt) {
4615
4646
  };
4616
4647
  return _this8;
4617
4648
  }
4618
- return _createClass(Dt);
4619
- }(xt);
4620
- var It = Symbol["for"]("stytch__internal_b2b");
4649
+ return _createClass(It);
4650
+ }(Dt);
4651
+ var Bt = Symbol["for"]("stytch__internal_b2b");
4621
4652
  exports.BiometricsFailedError = U, exports.BiometricsUnavailableError = A, exports.ChallengeSigningFailedError = F, exports.DeviceCredentialsNotAllowedError = D, exports.FailedCodeChallengeError = K, exports.FailedToDecryptDataError = z, exports.InternalError = S, exports.InvalidAuthorizationCredentialError = L, exports.InvalidCredentialTypeError = H, exports.InvalidRedirectSchemeError = W, exports.InvalidStartUrlError = q, exports.JSONDataNotConvertibleToStringError = V, exports.KeyInvalidatedError = C, exports.KeystoreUnavailableError = E, exports.MissingAttestationObjectError = Y, exports.MissingAuthorizationCredentialIDTokenError = R, exports.MissingGoogleClientIDError = I, exports.MissingPKCEError = B, exports.MissingPublicKeyError = M, exports.MissingUrlError = G, exports.NoBiometricsEnrolledError = T, exports.NoBiometricsRegistrationError = P, exports.NoCurrentSessionError = w, exports.PasskeysInvalidEncoding = $, exports.PasskeysUnsupportedError = N, exports.RandomNumberGenerationFailed = J, exports.SDKAPIUnreachableError = h, exports.SDKNotConfiguredError = j, exports.StytchAPIError = y, exports.StytchAPISchemaError = g, exports.StytchAPIUnreachableError = b, exports.StytchB2BHeadlessClient = /*#__PURE__*/function () {
4622
4653
  function _class(e, t) {
4623
4654
  var _this9 = this;
@@ -4638,9 +4669,9 @@ exports.BiometricsFailedError = U, exports.BiometricsUnavailableError = A, expor
4638
4669
  }
4639
4670
  };
4640
4671
  var o, s, a, c, u, l, d, h, p, _, f;
4641
- this._dataLayer = Et(e, n), this._subscriptionService = new Dt(e, this._dataLayer);
4642
- var m = new bt(this._dataLayer, "passwords");
4643
- this._networkClient = new mt(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4672
+ this._dataLayer = Tt(e, n), this._subscriptionService = new It(e, this._dataLayer);
4673
+ var m = new gt(this._dataLayer, "passwords");
4674
+ this._networkClient = new vt(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4644
4675
  var e, t, r, n;
4645
4676
  return {
4646
4677
  stytch_member_id: null === (t = null === (e = _this9._dataLayer.state) || void 0 === e ? void 0 : e.member) || void 0 === t ? void 0 : t.member_id,
@@ -4648,18 +4679,18 @@ exports.BiometricsFailedError = U, exports.BiometricsUnavailableError = A, expor
4648
4679
  };
4649
4680
  });
4650
4681
  var v = new _t(e, this._networkClient, this._dataLayer),
4651
- b = new ft(v.getAsync()),
4682
+ b = new mt(v.getAsync()),
4652
4683
  g = new Re(e, i.endpoints.dfpBackendURL, v.getAsync(), b.executeRecaptcha);
4653
- this.organization = new ze(this._networkClient, this._subscriptionService), this.member = new Ke(this._networkClient, this._subscriptionService), this.self = new Ke(this._networkClient, this._subscriptionService), this.session = new qe(this._networkClient, this._subscriptionService), this.magicLinks = new je(this._networkClient, this._subscriptionService, new bt(this._dataLayer, "magic_links"), m, v.getAsync(), g), this.oauth = new Ue(this._networkClient, this._subscriptionService, new bt(this._dataLayer, "oauth"), v.getAsync(), {
4684
+ this.organization = new ze(this._networkClient, this._subscriptionService), this.member = new Ke(this._networkClient, this._subscriptionService), this.self = new Ke(this._networkClient, this._subscriptionService), this.session = new qe(this._networkClient, this._subscriptionService), this.magicLinks = new je(this._networkClient, this._subscriptionService, new gt(this._dataLayer, "magic_links"), m, v.getAsync(), g), this.oauth = new Ue(this._networkClient, this._subscriptionService, new gt(this._dataLayer, "oauth"), v.getAsync(), {
4654
4685
  publicToken: e,
4655
4686
  testAPIURL: i.endpoints.testAPIURL,
4656
4687
  liveAPIURL: i.endpoints.liveAPIURL
4657
- }, g), this.sso = new Ne(this._networkClient, this._subscriptionService, new bt(this._dataLayer, "sso"), v.getAsync(), {
4688
+ }, g), this.sso = new Ne(this._networkClient, this._subscriptionService, new gt(this._dataLayer, "sso"), v.getAsync(), {
4658
4689
  publicToken: e,
4659
4690
  testAPIURL: i.endpoints.testAPIURL,
4660
4691
  liveAPIURL: i.endpoints.liveAPIURL
4661
4692
  }), this.discovery = new We(this._networkClient, this._subscriptionService), this.passwords = new ht(this._networkClient, this._subscriptionService, m, v.getAsync(), g), this.otps = new Ge(this._networkClient, this._subscriptionService, g), this.totp = new He(this._networkClient, this._subscriptionService, g), this.recoveryCodes = new Ye(this._networkClient, this._subscriptionService, g), this.rbac = new Ve(v.getSync(), v.getAsync(), this._subscriptionService), this._sessionManager = new Je(this._subscriptionService, this.session);
4662
- var y = new gt(this._networkClient);
4693
+ var y = new yt(this._networkClient);
4663
4694
  this._dataLayer.readSessionCookie().session_token && this._sessionManager.performBackgroundRefresh(), this._networkClient.logEvent({
4664
4695
  name: "b2b_sdk_instance_instantiated",
4665
4696
  details: {
@@ -4669,7 +4700,7 @@ exports.BiometricsFailedError = U, exports.BiometricsUnavailableError = A, expor
4669
4700
  }
4670
4701
  });
4671
4702
  (function (e, t) {
4672
- Object.assign(e, _defineProperty({}, It, t));
4703
+ Object.assign(e, _defineProperty({}, Bt, t));
4673
4704
  })(this, {
4674
4705
  bootstrap: v,
4675
4706
  publicToken: e,