@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.
@@ -2684,7 +2684,7 @@ var Ye = Promise.resolve({
2684
2684
  }
2685
2685
  return t.abrupt("return", this.authenticate(e));
2686
2686
  case 17:
2687
- throw C.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
2687
+ throw C.includes(t.t0.error_type) && this._subscriptionService.destroySession(), t.t0;
2688
2688
  case 19:
2689
2689
  case "end":
2690
2690
  return t.stop();
@@ -3215,7 +3215,7 @@ var tt = pe(function e(t, r) {
3215
3215
  })["catch"](function (t) {
3216
3216
  Ke("Session background refresh failed. Signalling to app that user is logged out.", {
3217
3217
  error: t
3218
- }), e._subscriptionService.destroyState();
3218
+ }), e._subscriptionService.destroySession();
3219
3219
  });
3220
3220
  }
3221
3221
  }, {
@@ -3712,6 +3712,7 @@ var wt = /*#__PURE__*/function () {
3712
3712
  existing_password: e.existing_password,
3713
3713
  new_password: e.new_password,
3714
3714
  locale: e.locale,
3715
+ session_duration_minutes: e.session_duration_minutes,
3715
3716
  captcha_token: r,
3716
3717
  dfp_telemetry_id: t
3717
3718
  },
@@ -3920,11 +3921,37 @@ var Pt = /*#__PURE__*/function () {
3920
3921
  }]);
3921
3922
  return Pt;
3922
3923
  }();
3923
- var Ct = /*#__PURE__*/_createClass(function Ct(e) {
3924
+ function Ct(e, t, r, n) {
3925
+ return new (r || (r = Promise))(function (i, o) {
3926
+ function s(e) {
3927
+ try {
3928
+ c(n.next(e));
3929
+ } catch (e) {
3930
+ o(e);
3931
+ }
3932
+ }
3933
+ function a(e) {
3934
+ try {
3935
+ c(n["throw"](e));
3936
+ } catch (e) {
3937
+ o(e);
3938
+ }
3939
+ }
3940
+ function c(e) {
3941
+ var t;
3942
+ e.done ? i(e.value) : (t = e.value, t instanceof r ? t : new r(function (e) {
3943
+ e(t);
3944
+ })).then(s, a);
3945
+ }
3946
+ c((n = n.apply(e, t || [])).next());
3947
+ });
3948
+ }
3949
+ "function" == typeof SuppressedError && SuppressedError;
3950
+ var At = /*#__PURE__*/_createClass(function At(e) {
3924
3951
  var _this3 = this;
3925
- _classCallCheck(this, Ct);
3952
+ _classCallCheck(this, At);
3926
3953
  this.bootstrapPromise = e, this.executeRecaptcha = function () {
3927
- return vt(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
3954
+ return Ct(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
3928
3955
  var _yield$this$state, e, t, r;
3929
3956
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
3930
3957
  while (1) switch (_context12.prev = _context12.next) {
@@ -3955,7 +3982,7 @@ var Ct = /*#__PURE__*/_createClass(function Ct(e) {
3955
3982
  }, _callee12, this);
3956
3983
  }));
3957
3984
  }, this.state = e.then(function (e) {
3958
- return vt(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
3985
+ return Ct(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
3959
3986
  var t;
3960
3987
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
3961
3988
  while (1) switch (_context13.prev = _context13.next) {
@@ -3993,9 +4020,9 @@ var Ct = /*#__PURE__*/_createClass(function Ct(e) {
3993
4020
  }));
3994
4021
  });
3995
4022
  });
3996
- var At = /*#__PURE__*/function () {
3997
- function At(e, t, r, n) {
3998
- _classCallCheck(this, At);
4023
+ var Tt = /*#__PURE__*/function () {
4024
+ function Tt(e, t, r, n) {
4025
+ _classCallCheck(this, Tt);
3999
4026
  this._publicToken = e, this._subscriptionDataLayer = t, this.baseURL = r, this.additionalTelemetryDataFn = n, this.updateSessionToken = function () {
4000
4027
  return null;
4001
4028
  }, this.eventLogger = new He({
@@ -4004,7 +4031,7 @@ var At = /*#__PURE__*/function () {
4004
4031
  logEventURL: this.buildSDKUrl("/events")
4005
4032
  });
4006
4033
  }
4007
- _createClass(At, [{
4034
+ _createClass(Tt, [{
4008
4035
  key: "logEvent",
4009
4036
  value: function logEvent(_ref) {
4010
4037
  var e = _ref.name,
@@ -4035,7 +4062,7 @@ var At = /*#__PURE__*/function () {
4035
4062
  },
4036
4063
  sdk: {
4037
4064
  identifier: "Stytch.js Javascript SDK",
4038
- version: "4.4.0"
4065
+ version: "4.4.2"
4039
4066
  }
4040
4067
  });
4041
4068
  }
@@ -4046,7 +4073,7 @@ var At = /*#__PURE__*/function () {
4046
4073
  t = _ref2.body,
4047
4074
  r = _ref2.errorMessage,
4048
4075
  n = _ref2.method;
4049
- return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
4076
+ return Ct(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
4050
4077
  var i, o, s, a;
4051
4078
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
4052
4079
  while (1) switch (_context14.prev = _context14.next) {
@@ -4076,7 +4103,7 @@ var At = /*#__PURE__*/function () {
4076
4103
  r = _ref3.errorMessage,
4077
4104
  n = _ref3.method,
4078
4105
  i = _ref3.retryCallback;
4079
- return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
4106
+ return Ct(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
4080
4107
  var o, s, a, c;
4081
4108
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
4082
4109
  while (1) switch (_context15.prev = _context15.next) {
@@ -4147,18 +4174,18 @@ var At = /*#__PURE__*/function () {
4147
4174
  return "".concat(this.baseURL, "/sdk/v1").concat(e);
4148
4175
  }
4149
4176
  }]);
4150
- return At;
4177
+ return Tt;
4151
4178
  }();
4152
- function Tt(e) {
4179
+ function Ot(e) {
4153
4180
  var t = e.toString(16);
4154
4181
  return 1 === t.length && (t = "0" + t), t;
4155
4182
  }
4156
- var Ot = /*#__PURE__*/function () {
4157
- function Ot(e, t) {
4158
- _classCallCheck(this, Ot);
4183
+ var Et = /*#__PURE__*/function () {
4184
+ function Et(e, t) {
4185
+ _classCallCheck(this, Et);
4159
4186
  this._dataLayer = e, this.namespace = t;
4160
4187
  }
4161
- _createClass(Ot, [{
4188
+ _createClass(Et, [{
4162
4189
  key: "key",
4163
4190
  value: function key() {
4164
4191
  return "PKCE_VERIFIER:" + this.namespace;
@@ -4166,13 +4193,13 @@ var Ot = /*#__PURE__*/function () {
4166
4193
  }, {
4167
4194
  key: "startPKCETransaction",
4168
4195
  value: function startPKCETransaction() {
4169
- return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
4196
+ return Ct(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
4170
4197
  var e;
4171
4198
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
4172
4199
  while (1) switch (_context16.prev = _context16.next) {
4173
4200
  case 0:
4174
4201
  _context16.next = 2;
4175
- return Ot.createProofkeyPair();
4202
+ return Et.createProofkeyPair();
4176
4203
  case 2:
4177
4204
  e = _context16.sent;
4178
4205
  return _context16.abrupt("return", (this._dataLayer.setItem(this.key(), JSON.stringify(e)), e));
@@ -4201,7 +4228,7 @@ var Ot = /*#__PURE__*/function () {
4201
4228
  }], [{
4202
4229
  key: "createProofkeyPair",
4203
4230
  value: function createProofkeyPair() {
4204
- return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
4231
+ return Ct(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
4205
4232
  var _String$fromCharCode;
4206
4233
  var e, t, r, n;
4207
4234
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
@@ -4209,7 +4236,7 @@ var Ot = /*#__PURE__*/function () {
4209
4236
  case 0:
4210
4237
  e = new Uint32Array(16);
4211
4238
  window.crypto.getRandomValues(e);
4212
- t = Array.from(e).map(Tt).join("");
4239
+ t = Array.from(e).map(Ot).join("");
4213
4240
  _context17.next = 5;
4214
4241
  return window.crypto.subtle.digest("SHA-256", new TextEncoder().encode(t));
4215
4242
  case 5:
@@ -4226,14 +4253,14 @@ var Ot = /*#__PURE__*/function () {
4226
4253
  }));
4227
4254
  }
4228
4255
  }]);
4229
- return Ot;
4256
+ return Et;
4230
4257
  }();
4231
- var Et = /*#__PURE__*/function () {
4232
- function Et(e) {
4233
- _classCallCheck(this, Et);
4258
+ var xt = /*#__PURE__*/function () {
4259
+ function xt(e) {
4260
+ _classCallCheck(this, xt);
4234
4261
  this._networkClient = e;
4235
4262
  }
4236
- _createClass(Et, [{
4263
+ _createClass(xt, [{
4237
4264
  key: "searchUser",
4238
4265
  value: function searchUser(e) {
4239
4266
  return this._networkClient.fetchSDK({
@@ -4271,9 +4298,9 @@ var Et = /*#__PURE__*/function () {
4271
4298
  });
4272
4299
  }
4273
4300
  }]);
4274
- return Et;
4301
+ return xt;
4275
4302
  }();
4276
- var xt = function xt(e) {
4303
+ var Dt = function Dt(e) {
4277
4304
  return (document.cookie ? document.cookie.split("; ") : []).filter(function (t) {
4278
4305
  var _t$split = t.split("="),
4279
4306
  _t$split2 = _slicedToArray(_t$split, 1),
@@ -4282,17 +4309,17 @@ var xt = function xt(e) {
4282
4309
  }).length > 1;
4283
4310
  };
4284
4311
  /*! js-cookie v3.0.1 | MIT */
4285
- function Dt(e) {
4312
+ function It(e) {
4286
4313
  for (var t = 1; t < arguments.length; t++) {
4287
4314
  var r = arguments[t];
4288
4315
  for (var n in r) e[n] = r[n];
4289
4316
  }
4290
4317
  return e;
4291
4318
  }
4292
- var It = function e(t, r) {
4319
+ var Rt = function e(t, r) {
4293
4320
  function n(e, n, i) {
4294
4321
  if ("undefined" != typeof document) {
4295
- "number" == typeof (i = Dt({}, 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);
4322
+ "number" == typeof (i = It({}, 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);
4296
4323
  var o = "";
4297
4324
  for (var s in i) i[s] && (o += "; " + s, !0 !== i[s] && (o += "=" + i[s].split(";")[0]));
4298
4325
  return document.cookie = e + "=" + t.write(n, e) + o;
@@ -4314,15 +4341,15 @@ var It = function e(t, r) {
4314
4341
  }
4315
4342
  },
4316
4343
  remove: function remove(e, t) {
4317
- n(e, "", Dt({}, t, {
4344
+ n(e, "", It({}, t, {
4318
4345
  expires: -1
4319
4346
  }));
4320
4347
  },
4321
4348
  withAttributes: function withAttributes(t) {
4322
- return e(this.converter, Dt({}, this.attributes, t));
4349
+ return e(this.converter, It({}, this.attributes, t));
4323
4350
  },
4324
4351
  withConverter: function withConverter(t) {
4325
- return e(Dt({}, this.converter, t), this.attributes);
4352
+ return e(It({}, this.converter, t), this.attributes);
4326
4353
  }
4327
4354
  }, {
4328
4355
  attributes: {
@@ -4342,26 +4369,26 @@ var It = function e(t, r) {
4342
4369
  }, {
4343
4370
  path: "/"
4344
4371
  });
4345
- var Rt = function Rt(e) {
4372
+ var Bt = function Bt(e) {
4346
4373
  var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
4347
4374
  return "stytch_sdk_state_".concat(e).concat(t ? "::".concat(t) : "");
4348
4375
  };
4349
- var Bt = /*#__PURE__*/function () {
4350
- function Bt(e, t) {
4376
+ var Lt = /*#__PURE__*/function () {
4377
+ function Lt(e, t) {
4351
4378
  var _this4 = this;
4352
- _classCallCheck(this, Bt);
4379
+ _classCallCheck(this, Lt);
4353
4380
  this.browserSessionStorage = {
4354
4381
  getItem: function getItem(e) {
4355
- return sessionStorage.getItem(Rt(_this4.publicToken, e));
4382
+ return sessionStorage.getItem(Bt(_this4.publicToken, e));
4356
4383
  },
4357
4384
  setItem: function setItem(e, t) {
4358
- return sessionStorage.setItem(Rt(_this4.publicToken, e), t);
4385
+ return sessionStorage.setItem(Bt(_this4.publicToken, e), t);
4359
4386
  },
4360
4387
  removeItem: function removeItem(e) {
4361
- return sessionStorage.removeItem(Rt(_this4.publicToken, e));
4388
+ return sessionStorage.removeItem(Bt(_this4.publicToken, e));
4362
4389
  }
4363
4390
  }, this.publicToken = e, this.state = null, this.stateKeysUpdated = new Set(), this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (qe("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);
4364
- var r = localStorage.getItem(Rt(this.publicToken));
4391
+ var r = localStorage.getItem(Bt(this.publicToken));
4365
4392
  if (!r) return;
4366
4393
  var n;
4367
4394
  try {
@@ -4371,7 +4398,7 @@ var Bt = /*#__PURE__*/function () {
4371
4398
  }
4372
4399
  this.state = n;
4373
4400
  }
4374
- _createClass(Bt, [{
4401
+ _createClass(Lt, [{
4375
4402
  key: "opaqueTokenCookieName",
4376
4403
  get: function get() {
4377
4404
  var e;
@@ -4393,14 +4420,14 @@ var Bt = /*#__PURE__*/function () {
4393
4420
  key: "readSessionCookie",
4394
4421
  value: function readSessionCookie() {
4395
4422
  return {
4396
- session_token: It.get(this.opaqueTokenCookieName),
4397
- session_jwt: It.get(this.jwtCookieName)
4423
+ session_token: Rt.get(this.opaqueTokenCookieName),
4424
+ session_jwt: Rt.get(this.jwtCookieName)
4398
4425
  };
4399
4426
  }
4400
4427
  }, {
4401
4428
  key: "readIntermediateSessionTokenCookie",
4402
4429
  value: function readIntermediateSessionTokenCookie() {
4403
- return It.get(this.istCookieName);
4430
+ return Rt.get(this.istCookieName);
4404
4431
  }
4405
4432
  }, {
4406
4433
  key: "writeSessionCookie",
@@ -4409,32 +4436,32 @@ var Bt = /*#__PURE__*/function () {
4409
4436
  var o = e.state,
4410
4437
  s = e.session_token,
4411
4438
  a = e.session_jwt,
4412
- c = Bt.generateCookieOpts({
4439
+ c = Lt.generateCookieOpts({
4413
4440
  expiresAt: null !== (r = null === (t = null == o ? void 0 : o.session) || void 0 === t ? void 0 : t.expires_at) && void 0 !== r ? r : "",
4414
4441
  availableToSubdomains: this._cookieAvailableToSubdomains,
4415
4442
  path: this._cookiePath,
4416
4443
  domain: this._domain
4417
4444
  });
4418
- It.set(this.opaqueTokenCookieName, s, c), It.set(this.jwtCookieName, a, c);
4419
- var u = Bt.generateCookieOpts({
4445
+ Rt.set(this.opaqueTokenCookieName, s, c), Rt.set(this.jwtCookieName, a, c);
4446
+ var u = Lt.generateCookieOpts({
4420
4447
  expiresAt: null !== (i = null === (n = null == o ? void 0 : o.session) || void 0 === n ? void 0 : n.expires_at) && void 0 !== i ? i : "",
4421
4448
  availableToSubdomains: !this._cookieAvailableToSubdomains,
4422
4449
  path: this._cookiePath,
4423
4450
  domain: this._domain
4424
4451
  });
4425
- xt(this.jwtCookieName) && It.remove(this.jwtCookieName, u), xt(this.opaqueTokenCookieName) && It.remove(this.opaqueTokenCookieName, u), xt(this.jwtCookieName) && Ke("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), xt(this.opaqueTokenCookieName) && Ke("Could not remove extraneous opaque token cookie.");
4452
+ Dt(this.jwtCookieName) && Rt.remove(this.jwtCookieName, u), Dt(this.opaqueTokenCookieName) && Rt.remove(this.opaqueTokenCookieName, u), Dt(this.jwtCookieName) && Ke("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), Dt(this.opaqueTokenCookieName) && Ke("Could not remove extraneous opaque token cookie.");
4426
4453
  }
4427
4454
  }, {
4428
4455
  key: "writeIntermediateSessionTokenCookie",
4429
4456
  value: function writeIntermediateSessionTokenCookie(e) {
4430
4457
  var t = new Date(Date.now() + 6e5),
4431
- r = Bt.generateCookieOpts({
4458
+ r = Lt.generateCookieOpts({
4432
4459
  expiresAt: t.toString(),
4433
4460
  availableToSubdomains: this._cookieAvailableToSubdomains,
4434
4461
  path: this._cookiePath,
4435
4462
  domain: this._domain
4436
4463
  });
4437
- It.set(this.istCookieName, e, r);
4464
+ Rt.set(this.istCookieName, e, r);
4438
4465
  }
4439
4466
  }, {
4440
4467
  key: "removeSessionCookie",
@@ -4453,14 +4480,14 @@ var Bt = /*#__PURE__*/function () {
4453
4480
  [!0, !1].forEach(function (t) {
4454
4481
  [_this5._cookiePath, null].forEach(function (r) {
4455
4482
  [_this5._domain, null].forEach(function (n) {
4456
- var i = Bt.generateCookieOpts({
4483
+ var i = Lt.generateCookieOpts({
4457
4484
  expiresAt: new Date(0).toString(),
4458
4485
  availableToSubdomains: t,
4459
4486
  path: r,
4460
4487
  domain: n
4461
4488
  });
4462
4489
  e.forEach(function (e) {
4463
- It.remove(e, i);
4490
+ Rt.remove(e, i);
4464
4491
  });
4465
4492
  });
4466
4493
  });
@@ -4469,22 +4496,22 @@ var Bt = /*#__PURE__*/function () {
4469
4496
  }, {
4470
4497
  key: "syncToLocalStorage",
4471
4498
  value: function syncToLocalStorage() {
4472
- localStorage.setItem(Rt(this.publicToken), JSON.stringify(this.state));
4499
+ localStorage.setItem(Bt(this.publicToken), JSON.stringify(this.state));
4473
4500
  }
4474
4501
  }, {
4475
4502
  key: "getItem",
4476
4503
  value: function getItem(e) {
4477
- return localStorage.getItem(Rt(this.publicToken, e));
4504
+ return localStorage.getItem(Bt(this.publicToken, e));
4478
4505
  }
4479
4506
  }, {
4480
4507
  key: "setItem",
4481
4508
  value: function setItem(e, t) {
4482
- return localStorage.setItem(Rt(this.publicToken, e), t);
4509
+ return localStorage.setItem(Bt(this.publicToken, e), t);
4483
4510
  }
4484
4511
  }, {
4485
4512
  key: "removeItem",
4486
4513
  value: function removeItem(e) {
4487
- return localStorage.removeItem(Rt(this.publicToken, e));
4514
+ return localStorage.removeItem(Bt(this.publicToken, e));
4488
4515
  }
4489
4516
  }, {
4490
4517
  key: "markStateKeysUpdated",
@@ -4509,31 +4536,31 @@ var Bt = /*#__PURE__*/function () {
4509
4536
  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;
4510
4537
  }
4511
4538
  }]);
4512
- return Bt;
4539
+ return Lt;
4513
4540
  }();
4514
- var Lt = /*#__PURE__*/function (_Bt) {
4515
- _inherits(Lt, _Bt);
4516
- var _super2 = _createSuper(Lt);
4517
- function Lt() {
4518
- _classCallCheck(this, Lt);
4541
+ var Mt = /*#__PURE__*/function (_Lt) {
4542
+ _inherits(Mt, _Lt);
4543
+ var _super2 = _createSuper(Mt);
4544
+ function Mt() {
4545
+ _classCallCheck(this, Mt);
4519
4546
  return _super2.apply(this, arguments);
4520
4547
  }
4521
- return _createClass(Lt);
4522
- }(Bt);
4523
- var Mt = Symbol["for"]("__stytch_b2b_DataLayer"),
4524
- Ft = function Ft(e, t) {
4548
+ return _createClass(Mt);
4549
+ }(Lt);
4550
+ var Ft = Symbol["for"]("__stytch_b2b_DataLayer"),
4551
+ jt = function jt(e, t) {
4525
4552
  var r = function () {
4526
4553
  var e = window;
4527
- return e[Mt] || (e[Mt] = {}), e[Mt];
4554
+ return e[Ft] || (e[Ft] = {}), e[Ft];
4528
4555
  }();
4529
- return r[e] || (r[e] = new Lt(e, t)), r[e];
4556
+ return r[e] || (r[e] = new Mt(e, t)), r[e];
4530
4557
  },
4531
- jt = function jt(e, t) {
4558
+ Kt = function Kt(e, t) {
4532
4559
  Object.values(e).forEach(function (e) {
4533
4560
  return e(t);
4534
4561
  });
4535
4562
  },
4536
- Kt = function () {
4563
+ Nt = function () {
4537
4564
  var e = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).KEYS_TO_EXCLUDE,
4538
4565
  t = void 0 === e ? [] : e;
4539
4566
  return function e(r, n) {
@@ -4552,21 +4579,20 @@ var Mt = Symbol["for"]("__stytch_b2b_DataLayer"),
4552
4579
  }({
4553
4580
  KEYS_TO_EXCLUDE: ["last_accessed_at"]
4554
4581
  });
4555
- var Nt = /*#__PURE__*/function () {
4556
- function Nt(e, t) {
4582
+ var zt = /*#__PURE__*/function () {
4583
+ function zt(e, t) {
4557
4584
  var _this7 = this;
4558
- _classCallCheck(this, Nt);
4585
+ _classCallCheck(this, zt);
4559
4586
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4560
- if (e.key !== Rt(_this7._publicToken)) return;
4561
- if (null === e.newValue || "null" === e.newValue) return void _this7.destroyState();
4562
- var t = JSON.parse(e.newValue);
4587
+ if (e.key !== Bt(_this7._publicToken)) return;
4588
+ var t = null === e.newValue || "null" === e.newValue ? null : JSON.parse(e.newValue);
4563
4589
  _this7.updateState(t);
4564
4590
  }, window.addEventListener("storage", this._listen);
4565
4591
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4566
4592
  r = _this$_datalayer$read.session_token;
4567
- r || this.destroyState();
4593
+ r || this.destroySession();
4568
4594
  }
4569
- _createClass(Nt, [{
4595
+ _createClass(zt, [{
4570
4596
  key: "getTokens",
4571
4597
  value: function getTokens() {
4572
4598
  var _this$_datalayer$read2 = this._datalayer.readSessionCookie(),
@@ -4592,6 +4618,11 @@ var Nt = /*#__PURE__*/function () {
4592
4618
  intermediate_session_token: null
4593
4619
  });
4594
4620
  }
4621
+ }, {
4622
+ key: "destroySession",
4623
+ value: function destroySession() {
4624
+ this._datalayer.removeSessionCookie(), this.updateState(null);
4625
+ }
4595
4626
  }, {
4596
4627
  key: "_updateStateAndTokensInternal",
4597
4628
  value: function _updateStateAndTokensInternal(e) {
@@ -4599,7 +4630,7 @@ var Nt = /*#__PURE__*/function () {
4599
4630
  r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4600
4631
  this._datalayer.state = r;
4601
4632
  var n = e.state ? Object.keys(e.state) : [];
4602
- !this._datalayer.markStateKeysUpdated(n) && Kt(t, r) || jt(this._datalayer.subscriptions, r);
4633
+ !this._datalayer.markStateKeysUpdated(n) && Nt(t, r) || Kt(this._datalayer.subscriptions, r);
4603
4634
  }
4604
4635
  }, {
4605
4636
  key: "updateStateAndTokens",
@@ -4614,8 +4645,8 @@ var Nt = /*#__PURE__*/function () {
4614
4645
  this._datalayer.state = r;
4615
4646
  var n = e ? Object.keys(e) : [],
4616
4647
  i = this._datalayer.markStateKeysUpdated(n),
4617
- o = !Kt(t, r);
4618
- (i || o) && (jt(this._datalayer.subscriptions, r), o && this._datalayer.syncToLocalStorage());
4648
+ o = !Nt(t, r);
4649
+ (i || o) && (Kt(this._datalayer.subscriptions, r), o && this._datalayer.syncToLocalStorage());
4619
4650
  }
4620
4651
  }, {
4621
4652
  key: "updateTokens",
@@ -4655,14 +4686,14 @@ var Nt = /*#__PURE__*/function () {
4655
4686
  return null;
4656
4687
  }
4657
4688
  }]);
4658
- return Nt;
4689
+ return zt;
4659
4690
  }();
4660
- var zt = /*#__PURE__*/function (_Nt) {
4661
- _inherits(zt, _Nt);
4662
- var _super3 = _createSuper(zt);
4663
- function zt() {
4691
+ var Ut = /*#__PURE__*/function (_zt) {
4692
+ _inherits(Ut, _zt);
4693
+ var _super3 = _createSuper(Ut);
4694
+ function Ut() {
4664
4695
  var _this8;
4665
- _classCallCheck(this, zt);
4696
+ _classCallCheck(this, Ut);
4666
4697
  _this8 = _super3.apply(this, arguments), _this8.updateMember = function (e) {
4667
4698
  return _this8.updateState({
4668
4699
  member: e
@@ -4683,12 +4714,12 @@ var zt = /*#__PURE__*/function (_Nt) {
4683
4714
  };
4684
4715
  return _this8;
4685
4716
  }
4686
- return _createClass(zt);
4687
- }(Nt);
4688
- var Ut = Symbol["for"]("stytch__internal_b2b");
4689
- var qt = /*#__PURE__*/_createClass(function qt(e, t) {
4717
+ return _createClass(Ut);
4718
+ }(zt);
4719
+ var qt = Symbol["for"]("stytch__internal_b2b");
4720
+ var Wt = /*#__PURE__*/_createClass(function Wt(e, t) {
4690
4721
  var _this9 = this;
4691
- _classCallCheck(this, qt);
4722
+ _classCallCheck(this, Wt);
4692
4723
  var r;
4693
4724
  !function (e) {
4694
4725
  if ("undefined" == typeof window) throw new Error("The ".concat(e, " is not compatible with server-side environments.\nIf using nextjs, use the create").concat(e, " method instead.\n```\n").concat("import { createStytchB2BHeadlessClient } from '@stytch/nextjs/b2b';\n \n const stytch = createStytchB2BHeadlessClient('public-token-...');\n ", "\n```\n"));
@@ -4705,9 +4736,9 @@ var qt = /*#__PURE__*/_createClass(function qt(e, t) {
4705
4736
  }
4706
4737
  };
4707
4738
  var o, s, a, c, u, l, d, h, p, _, f;
4708
- this._dataLayer = Ft(e, n), this._subscriptionService = new zt(e, this._dataLayer);
4709
- var m = new Ot(this._dataLayer, "passwords");
4710
- this._networkClient = new At(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4739
+ this._dataLayer = jt(e, n), this._subscriptionService = new Ut(e, this._dataLayer);
4740
+ var m = new Et(this._dataLayer, "passwords");
4741
+ this._networkClient = new Tt(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4711
4742
  var e, t, r, n;
4712
4743
  return {
4713
4744
  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,
@@ -4715,18 +4746,18 @@ var qt = /*#__PURE__*/_createClass(function qt(e, t) {
4715
4746
  };
4716
4747
  });
4717
4748
  var v = new Pt(e, this._networkClient, this._dataLayer),
4718
- b = new Ct(v.getAsync()),
4749
+ b = new At(v.getAsync()),
4719
4750
  g = new We(e, i.endpoints.dfpBackendURL, v.getAsync(), b.executeRecaptcha);
4720
- this.organization = new Xe(this._networkClient, this._subscriptionService), this.member = new Je(this._networkClient, this._subscriptionService), this.self = new Je(this._networkClient, this._subscriptionService), this.session = new Qe(this._networkClient, this._subscriptionService), this.magicLinks = new Ve(this._networkClient, this._subscriptionService, new Ot(this._dataLayer, "magic_links"), m, v.getAsync(), g), this.oauth = new Ze(this._networkClient, this._subscriptionService, new Ot(this._dataLayer, "oauth"), v.getAsync(), {
4751
+ this.organization = new Xe(this._networkClient, this._subscriptionService), this.member = new Je(this._networkClient, this._subscriptionService), this.self = new Je(this._networkClient, this._subscriptionService), this.session = new Qe(this._networkClient, this._subscriptionService), this.magicLinks = new Ve(this._networkClient, this._subscriptionService, new Et(this._dataLayer, "magic_links"), m, v.getAsync(), g), this.oauth = new Ze(this._networkClient, this._subscriptionService, new Et(this._dataLayer, "oauth"), v.getAsync(), {
4721
4752
  publicToken: e,
4722
4753
  testAPIURL: i.endpoints.testAPIURL,
4723
4754
  liveAPIURL: i.endpoints.liveAPIURL
4724
- }, g), this.sso = new $e(this._networkClient, this._subscriptionService, new Ot(this._dataLayer, "sso"), v.getAsync(), {
4755
+ }, g), this.sso = new $e(this._networkClient, this._subscriptionService, new Et(this._dataLayer, "sso"), v.getAsync(), {
4725
4756
  publicToken: e,
4726
4757
  testAPIURL: i.endpoints.testAPIURL,
4727
4758
  liveAPIURL: i.endpoints.liveAPIURL
4728
4759
  }), this.discovery = new et(this._networkClient, this._subscriptionService), this.passwords = new wt(this._networkClient, this._subscriptionService, m, v.getAsync(), g), this.otps = new tt(this._networkClient, this._subscriptionService, g), this.totp = new rt(this._networkClient, this._subscriptionService, g), this.recoveryCodes = new nt(this._networkClient, this._subscriptionService, g), this.rbac = new it(v.getSync(), v.getAsync(), this._subscriptionService), this._sessionManager = new ot(this._subscriptionService, this.session);
4729
- var y = new Et(this._networkClient);
4760
+ var y = new xt(this._networkClient);
4730
4761
  this._dataLayer.readSessionCookie().session_token && this._sessionManager.performBackgroundRefresh(), this._networkClient.logEvent({
4731
4762
  name: "b2b_sdk_instance_instantiated",
4732
4763
  details: {
@@ -4736,7 +4767,7 @@ var qt = /*#__PURE__*/_createClass(function qt(e, t) {
4736
4767
  }
4737
4768
  });
4738
4769
  (function (e, t) {
4739
- Object.assign(e, _defineProperty({}, Ut, t));
4770
+ Object.assign(e, _defineProperty({}, qt, t));
4740
4771
  })(this, {
4741
4772
  bootstrap: v,
4742
4773
  publicToken: e,
@@ -4745,4 +4776,4 @@ var qt = /*#__PURE__*/_createClass(function qt(e, t) {
4745
4776
  networkClient: this._networkClient
4746
4777
  });
4747
4778
  });
4748
- export { g as AuthFlowType, y as B2BOAuthProviders, b as B2BProducts, X as BiometricsFailedError, B as BiometricsUnavailableError, H as ChallengeSigningFailedError, N as DeviceCredentialsNotAllowedError, V as FailedCodeChallengeError, $ as FailedToDecryptDataError, I as InternalError, W as InvalidAuthorizationCredentialError, te as InvalidCredentialTypeError, Q as InvalidRedirectSchemeError, Z as InvalidStartUrlError, ne as JSONDataNotConvertibleToStringError, L as KeyInvalidatedError, M as KeystoreUnavailableError, re as MissingAttestationObjectError, q as MissingAuthorizationCredentialIDTokenError, z as MissingGoogleClientIDError, U as MissingPKCEError, G as MissingPublicKeyError, ee as MissingUrlError, F as NoBiometricsEnrolledError, R as NoBiometricsRegistrationError, D as NoCurrentSessionError, p as OAuthProviders, m as OTPMethods, f as OneTapPositions, oe as PasskeysInvalidEncoding, J as PasskeysUnsupportedError, h as Products, ie as RandomNumberGenerationFailed, k as SDKAPIUnreachableError, Y as SDKNotConfiguredError, E as StytchAPIError, O as StytchAPISchemaError, T as StytchAPIUnreachableError, qt as StytchB2BHeadlessClient, A as StytchError, v as StytchEventType, P as StytchSDKAPIError, x as StytchSDKError, S as StytchSDKSchemaError, w as StytchSDKUsageError, C as UNRECOVERABLE_ERROR_TYPES, j as UserCancellationError, K as UserLockedOutError, _ as Wallets, se as errorToStytchError };
4779
+ export { g as AuthFlowType, y as B2BOAuthProviders, b as B2BProducts, X as BiometricsFailedError, B as BiometricsUnavailableError, H as ChallengeSigningFailedError, N as DeviceCredentialsNotAllowedError, V as FailedCodeChallengeError, $ as FailedToDecryptDataError, I as InternalError, W as InvalidAuthorizationCredentialError, te as InvalidCredentialTypeError, Q as InvalidRedirectSchemeError, Z as InvalidStartUrlError, ne as JSONDataNotConvertibleToStringError, L as KeyInvalidatedError, M as KeystoreUnavailableError, re as MissingAttestationObjectError, q as MissingAuthorizationCredentialIDTokenError, z as MissingGoogleClientIDError, U as MissingPKCEError, G as MissingPublicKeyError, ee as MissingUrlError, F as NoBiometricsEnrolledError, R as NoBiometricsRegistrationError, D as NoCurrentSessionError, p as OAuthProviders, m as OTPMethods, f as OneTapPositions, oe as PasskeysInvalidEncoding, J as PasskeysUnsupportedError, h as Products, ie as RandomNumberGenerationFailed, k as SDKAPIUnreachableError, Y as SDKNotConfiguredError, E as StytchAPIError, O as StytchAPISchemaError, T as StytchAPIUnreachableError, Wt as StytchB2BHeadlessClient, A as StytchError, v as StytchEventType, P as StytchSDKAPIError, x as StytchSDKError, S as StytchSDKSchemaError, w as StytchSDKUsageError, C as UNRECOVERABLE_ERROR_TYPES, j as UserCancellationError, K as UserLockedOutError, _ as Wallets, se as errorToStytchError };