@stytch/vanilla-js 4.1.0 → 4.1.1

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @stytch/vanilla-js
2
2
 
3
+ ## 4.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - e6832cb: Fix an issue where `fromCache` would not update to `false` after cached data was refreshed
8
+
3
9
  ## 4.1.0
4
10
 
5
11
  ### Minor Changes
@@ -3880,7 +3880,7 @@ var Et = /*#__PURE__*/function () {
3880
3880
  },
3881
3881
  sdk: {
3882
3882
  identifier: "Stytch.js Javascript SDK",
3883
- version: "4.1.0"
3883
+ version: "4.1.1"
3884
3884
  }
3885
3885
  });
3886
3886
  }
@@ -4206,7 +4206,7 @@ var Mt = /*#__PURE__*/function () {
4206
4206
  removeItem: function removeItem(e) {
4207
4207
  return sessionStorage.removeItem(Rt(_this4.publicToken, e));
4208
4208
  }
4209
- }, this.publicToken = e, this.state = null, this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? ($e("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);
4209
+ }, this.publicToken = e, this.state = null, this.stateKeysUpdated = new Set(), this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? ($e("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);
4210
4210
  var n = localStorage.getItem(Rt(this.publicToken));
4211
4211
  if (!n) return;
4212
4212
  var r;
@@ -4332,6 +4332,15 @@ var Mt = /*#__PURE__*/function () {
4332
4332
  value: function removeItem(e) {
4333
4333
  return localStorage.removeItem(Rt(this.publicToken, e));
4334
4334
  }
4335
+ }, {
4336
+ key: "markStateKeysUpdated",
4337
+ value: function markStateKeysUpdated(e) {
4338
+ var _this6 = this;
4339
+ var t = this.stateKeysUpdated.size;
4340
+ return e.forEach(function (e) {
4341
+ return _this6.stateKeysUpdated.add(e);
4342
+ }), t !== this.stateKeysUpdated.size;
4343
+ }
4335
4344
  }], [{
4336
4345
  key: "generateCookieOpts",
4337
4346
  value: function generateCookieOpts(_ref4) {
@@ -4391,13 +4400,13 @@ var Dt = Symbol["for"]("__stytch_b2b_DataLayer"),
4391
4400
  });
4392
4401
  var Nt = /*#__PURE__*/function () {
4393
4402
  function Nt(e, t) {
4394
- var _this6 = this;
4403
+ var _this7 = this;
4395
4404
  _classCallCheck(this, Nt);
4396
4405
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4397
- if (e.key !== Rt(_this6._publicToken)) return;
4398
- if (null === e.newValue || "null" === e.newValue) return void _this6.destroyState();
4406
+ if (e.key !== Rt(_this7._publicToken)) return;
4407
+ if (null === e.newValue || "null" === e.newValue) return void _this7.destroyState();
4399
4408
  var t = JSON.parse(e.newValue);
4400
- _this6.updateState(t);
4409
+ _this7.updateState(t);
4401
4410
  }, window.addEventListener("storage", this._listen);
4402
4411
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4403
4412
  n = _this$_datalayer$read.session_token;
@@ -4434,7 +4443,9 @@ var Nt = /*#__PURE__*/function () {
4434
4443
  value: function _updateStateAndTokensInternal(e) {
4435
4444
  var t = this._datalayer.state,
4436
4445
  n = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4437
- this._datalayer.state = n, zt(t, n) || Ft(this._datalayer.subscriptions, n);
4446
+ this._datalayer.state = n;
4447
+ var r = e.state ? Object.keys(e.state) : [];
4448
+ !this._datalayer.markStateKeysUpdated(r) && zt(t, n) || Ft(this._datalayer.subscriptions, n);
4438
4449
  }
4439
4450
  }, {
4440
4451
  key: "updateStateAndTokens",
@@ -4446,7 +4457,11 @@ var Nt = /*#__PURE__*/function () {
4446
4457
  value: function updateState(e) {
4447
4458
  var t = this._datalayer.state,
4448
4459
  n = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e);
4449
- this._datalayer.state = n, zt(t, n) || (Ft(this._datalayer.subscriptions, n), this._datalayer.syncToLocalStorage());
4460
+ this._datalayer.state = n;
4461
+ var r = e ? Object.keys(e) : [],
4462
+ i = this._datalayer.markStateKeysUpdated(r),
4463
+ o = !zt(t, n);
4464
+ (i || o) && (Ft(this._datalayer.subscriptions, n), o && this._datalayer.syncToLocalStorage());
4450
4465
  }
4451
4466
  }, {
4452
4467
  key: "updateTokens",
@@ -4492,20 +4507,20 @@ var Ut = /*#__PURE__*/function (_Nt) {
4492
4507
  _inherits(Ut, _Nt);
4493
4508
  var _super3 = _createSuper(Ut);
4494
4509
  function Ut() {
4495
- var _this7;
4510
+ var _this8;
4496
4511
  _classCallCheck(this, Ut);
4497
- _this7 = _super3.apply(this, arguments), _this7.updateMember = function (e) {
4498
- return _this7.updateState({
4512
+ _this8 = _super3.apply(this, arguments), _this8.updateMember = function (e) {
4513
+ return _this8.updateState({
4499
4514
  member: e
4500
4515
  });
4501
- }, _this7.getMember = function () {
4516
+ }, _this8.getMember = function () {
4502
4517
  var e, t;
4503
- return null !== (t = null === (e = _this7.getState()) || void 0 === e ? void 0 : e.member) && void 0 !== t ? t : null;
4504
- }, _this7.getSession = function () {
4518
+ return null !== (t = null === (e = _this8.getState()) || void 0 === e ? void 0 : e.member) && void 0 !== t ? t : null;
4519
+ }, _this8.getSession = function () {
4505
4520
  var e, t;
4506
- return null !== (t = null === (e = _this7.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4521
+ return null !== (t = null === (e = _this8.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4507
4522
  };
4508
- return _this7;
4523
+ return _this8;
4509
4524
  }
4510
4525
  return _createClass(Ut);
4511
4526
  }(Nt);
@@ -4516,7 +4531,7 @@ var Qt = Symbol["for"]("stytch__internal_b2b"),
4516
4531
  return t[Qt];
4517
4532
  };
4518
4533
  var Ht = /*#__PURE__*/_createClass(function Ht(e, t) {
4519
- var _this8 = this;
4534
+ var _this9 = this;
4520
4535
  _classCallCheck(this, Ht);
4521
4536
  var n;
4522
4537
  !function (e) {
@@ -4541,8 +4556,8 @@ var Ht = /*#__PURE__*/_createClass(function Ht(e, t) {
4541
4556
  this._networkClient = new Et(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4542
4557
  var e, t, n, r;
4543
4558
  return {
4544
- stytch_member_id: null === (t = null === (e = _this8._dataLayer.state) || void 0 === e ? void 0 : e.member) || void 0 === t ? void 0 : t.member_id,
4545
- stytch_member_session_id: null === (r = null === (n = _this8._dataLayer.state) || void 0 === n ? void 0 : n.session) || void 0 === r ? void 0 : r.member_session_id
4559
+ 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,
4560
+ stytch_member_session_id: null === (r = null === (n = _this9._dataLayer.state) || void 0 === n ? void 0 : n.session) || void 0 === r ? void 0 : r.member_session_id
4546
4561
  };
4547
4562
  });
4548
4563
  var a = new kt(e, this._networkClient, this._dataLayer),
@@ -11619,12 +11634,12 @@ var td = Ja.a(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral([
11619
11634
  _inherits(r, _HTMLElement);
11620
11635
  var _super4 = _createSuper(r);
11621
11636
  function r(e) {
11622
- var _this9;
11637
+ var _this10;
11623
11638
  _classCallCheck(this, r);
11624
- _this9 = _super4.call(this), _this9.props = e, _this9.rootRef = _this9.attachShadow({
11639
+ _this10 = _super4.call(this), _this10.props = e, _this10.rootRef = _this10.attachShadow({
11625
11640
  mode: "open"
11626
11641
  });
11627
- return _this9;
11642
+ return _this10;
11628
11643
  }
11629
11644
  _createClass(r, [{
11630
11645
  key: "connectedCallback",
@@ -11670,10 +11685,10 @@ var td = Ja.a(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral([
11670
11685
  _inherits(r, _HTMLElement2);
11671
11686
  var _super5 = _createSuper(r);
11672
11687
  function r(e) {
11673
- var _this10;
11688
+ var _this11;
11674
11689
  _classCallCheck(this, r);
11675
- _this10 = _super5.call(this), _this10.props = e, _this10.rootRef = document.createElement("div"), _this10.append(_this10.rootRef);
11676
- return _this10;
11690
+ _this11 = _super5.call(this), _this11.props = e, _this11.rootRef = document.createElement("div"), _this11.append(_this11.rootRef);
11691
+ return _this11;
11677
11692
  }
11678
11693
  _createClass(r, [{
11679
11694
  key: "connectedCallback",
@@ -11707,7 +11722,7 @@ var Fd = /*#__PURE__*/function (_Ht) {
11707
11722
  _inherits(Fd, _Ht);
11708
11723
  var _super6 = _createSuper(Fd);
11709
11724
  function Fd() {
11710
- var _this11;
11725
+ var _this12;
11711
11726
  _classCallCheck(this, Fd);
11712
11727
  for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
11713
11728
  e[_key6] = arguments[_key6];
@@ -11715,8 +11730,8 @@ var Fd = /*#__PURE__*/function (_Ht) {
11715
11730
  !function (e) {
11716
11731
  var t = "StytchUIClient" === e ? "import { createStytchUIClient } from '@stytch/nextjs/ui';\n \nconst stytch = createStytchUIClient('public-token-...');\n" : "import { createStytchHeadlessClient } from '@stytch/nextjs/ui';\n \nconst stytch = createStytchHeadlessClient('public-token-...');\n";
11717
11732
  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(t, "\n```\n"));
11718
- }("StytchUIClient"), _this11 = _super6.call.apply(_super6, [this].concat(e));
11719
- return _this11;
11733
+ }("StytchUIClient"), _this12 = _super6.call.apply(_super6, [this].concat(e));
11734
+ return _this12;
11720
11735
  }
11721
11736
  _createClass(Fd, [{
11722
11737
  key: "mount",
@@ -3878,7 +3878,7 @@ var At = /*#__PURE__*/function () {
3878
3878
  },
3879
3879
  sdk: {
3880
3880
  identifier: "Stytch.js Javascript SDK",
3881
- version: "4.1.0"
3881
+ version: "4.1.1"
3882
3882
  }
3883
3883
  });
3884
3884
  }
@@ -4203,7 +4203,7 @@ var It = /*#__PURE__*/function () {
4203
4203
  removeItem: function removeItem(e) {
4204
4204
  return sessionStorage.removeItem(Rt(_this4.publicToken, e));
4205
4205
  }
4206
- }, this.publicToken = e, this.state = null, 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);
4206
+ }, 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);
4207
4207
  var r = localStorage.getItem(Rt(this.publicToken));
4208
4208
  if (!r) return;
4209
4209
  var n;
@@ -4329,6 +4329,15 @@ var It = /*#__PURE__*/function () {
4329
4329
  value: function removeItem(e) {
4330
4330
  return localStorage.removeItem(Rt(this.publicToken, e));
4331
4331
  }
4332
+ }, {
4333
+ key: "markStateKeysUpdated",
4334
+ value: function markStateKeysUpdated(e) {
4335
+ var _this6 = this;
4336
+ var t = this.stateKeysUpdated.size;
4337
+ return e.forEach(function (e) {
4338
+ return _this6.stateKeysUpdated.add(e);
4339
+ }), t !== this.stateKeysUpdated.size;
4340
+ }
4332
4341
  }], [{
4333
4342
  key: "generateCookieOpts",
4334
4343
  value: function generateCookieOpts(_ref4) {
@@ -4388,13 +4397,13 @@ var Lt = Symbol["for"]("__stytch_b2b_DataLayer"),
4388
4397
  });
4389
4398
  var Nt = /*#__PURE__*/function () {
4390
4399
  function Nt(e, t) {
4391
- var _this6 = this;
4400
+ var _this7 = this;
4392
4401
  _classCallCheck(this, Nt);
4393
4402
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4394
- if (e.key !== Rt(_this6._publicToken)) return;
4395
- if (null === e.newValue || "null" === e.newValue) return void _this6.destroyState();
4403
+ if (e.key !== Rt(_this7._publicToken)) return;
4404
+ if (null === e.newValue || "null" === e.newValue) return void _this7.destroyState();
4396
4405
  var t = JSON.parse(e.newValue);
4397
- _this6.updateState(t);
4406
+ _this7.updateState(t);
4398
4407
  }, window.addEventListener("storage", this._listen);
4399
4408
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4400
4409
  r = _this$_datalayer$read.session_token;
@@ -4431,7 +4440,9 @@ var Nt = /*#__PURE__*/function () {
4431
4440
  value: function _updateStateAndTokensInternal(e) {
4432
4441
  var t = this._datalayer.state,
4433
4442
  r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4434
- this._datalayer.state = r, Ft(t, r) || jt(this._datalayer.subscriptions, r);
4443
+ this._datalayer.state = r;
4444
+ var n = e.state ? Object.keys(e.state) : [];
4445
+ !this._datalayer.markStateKeysUpdated(n) && Ft(t, r) || jt(this._datalayer.subscriptions, r);
4435
4446
  }
4436
4447
  }, {
4437
4448
  key: "updateStateAndTokens",
@@ -4443,7 +4454,11 @@ var Nt = /*#__PURE__*/function () {
4443
4454
  value: function updateState(e) {
4444
4455
  var t = this._datalayer.state,
4445
4456
  r = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e);
4446
- this._datalayer.state = r, Ft(t, r) || (jt(this._datalayer.subscriptions, r), this._datalayer.syncToLocalStorage());
4457
+ this._datalayer.state = r;
4458
+ var n = e ? Object.keys(e) : [],
4459
+ i = this._datalayer.markStateKeysUpdated(n),
4460
+ o = !Ft(t, r);
4461
+ (i || o) && (jt(this._datalayer.subscriptions, r), o && this._datalayer.syncToLocalStorage());
4447
4462
  }
4448
4463
  }, {
4449
4464
  key: "updateTokens",
@@ -4489,26 +4504,26 @@ var Kt = /*#__PURE__*/function (_Nt) {
4489
4504
  _inherits(Kt, _Nt);
4490
4505
  var _super3 = _createSuper(Kt);
4491
4506
  function Kt() {
4492
- var _this7;
4507
+ var _this8;
4493
4508
  _classCallCheck(this, Kt);
4494
- _this7 = _super3.apply(this, arguments), _this7.updateMember = function (e) {
4495
- return _this7.updateState({
4509
+ _this8 = _super3.apply(this, arguments), _this8.updateMember = function (e) {
4510
+ return _this8.updateState({
4496
4511
  member: e
4497
4512
  });
4498
- }, _this7.getMember = function () {
4513
+ }, _this8.getMember = function () {
4499
4514
  var e, t;
4500
- return null !== (t = null === (e = _this7.getState()) || void 0 === e ? void 0 : e.member) && void 0 !== t ? t : null;
4501
- }, _this7.getSession = function () {
4515
+ return null !== (t = null === (e = _this8.getState()) || void 0 === e ? void 0 : e.member) && void 0 !== t ? t : null;
4516
+ }, _this8.getSession = function () {
4502
4517
  var e, t;
4503
- return null !== (t = null === (e = _this7.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4518
+ return null !== (t = null === (e = _this8.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4504
4519
  };
4505
- return _this7;
4520
+ return _this8;
4506
4521
  }
4507
4522
  return _createClass(Kt);
4508
4523
  }(Nt);
4509
4524
  var Ut = Symbol["for"]("stytch__internal_b2b");
4510
4525
  var zt = /*#__PURE__*/_createClass(function zt(e, t) {
4511
- var _this8 = this;
4526
+ var _this9 = this;
4512
4527
  _classCallCheck(this, zt);
4513
4528
  var r;
4514
4529
  !function (e) {
@@ -4531,8 +4546,8 @@ var zt = /*#__PURE__*/_createClass(function zt(e, t) {
4531
4546
  this._networkClient = new At(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4532
4547
  var e, t, r, n;
4533
4548
  return {
4534
- stytch_member_id: null === (t = null === (e = _this8._dataLayer.state) || void 0 === e ? void 0 : e.member) || void 0 === t ? void 0 : t.member_id,
4535
- stytch_member_session_id: null === (n = null === (r = _this8._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.member_session_id
4549
+ 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,
4550
+ stytch_member_session_id: null === (n = null === (r = _this9._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.member_session_id
4536
4551
  };
4537
4552
  });
4538
4553
  var v = new St(e, this._networkClient, this._dataLayer),
@@ -297,7 +297,7 @@ var h = function (e) {
297
297
  }
298
298
  return r(s);
299
299
  }(),
300
- C = function (e) {
300
+ E = function (e) {
301
301
  i(s, k);
302
302
  var t = o(s);
303
303
  function s() {
@@ -305,7 +305,7 @@ var h = function (e) {
305
305
  }
306
306
  return r(s);
307
307
  }(),
308
- E = function (e) {
308
+ C = function (e) {
309
309
  i(s, k);
310
310
  var t = o(s);
311
311
  function s() {
@@ -585,7 +585,7 @@ function te() {
585
585
  s = Object.create(o.prototype),
586
586
  a = new x(n || []);
587
587
  return i(s, "_invoke", {
588
- value: C(e, r, a)
588
+ value: E(e, r, a)
589
589
  }), s;
590
590
  }
591
591
  function d(e, t, r) {
@@ -655,7 +655,7 @@ function te() {
655
655
  }
656
656
  });
657
657
  }
658
- function C(t, r, n) {
658
+ function E(t, r, n) {
659
659
  var i = h;
660
660
  return function (o, s) {
661
661
  if (i === _) throw new Error("Generator is already running");
@@ -669,7 +669,7 @@ function te() {
669
669
  for (n.method = o, n.arg = s;;) {
670
670
  var a = n.delegate;
671
671
  if (a) {
672
- var c = E(a, n);
672
+ var c = C(a, n);
673
673
  if (c) {
674
674
  if (c === m) continue;
675
675
  return c;
@@ -692,10 +692,10 @@ function te() {
692
692
  }
693
693
  };
694
694
  }
695
- function E(t, r) {
695
+ function C(t, r) {
696
696
  var n = r.method,
697
697
  i = t.iterator[n];
698
- if (i === e) return r.delegate = null, "throw" === n && t.iterator["return"] && (r.method = "return", r.arg = e, E(t, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), m;
698
+ if (i === e) return r.delegate = null, "throw" === n && t.iterator["return"] && (r.method = "return", r.arg = e, C(t, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), m;
699
699
  var o = d(i, t.iterator, r.arg);
700
700
  if ("throw" === o.type) return r.method = "throw", r.arg = o.arg, r.delegate = null, m;
701
701
  var s = o.arg;
@@ -1136,7 +1136,7 @@ function Pe(e, t) {
1136
1136
  function Ae(e, t) {
1137
1137
  return new Promise(function (r, n) {
1138
1138
  var i = function (e) {
1139
- var t = Ce(e);
1139
+ var t = Ee(e);
1140
1140
  if (t[0]) return t[0];
1141
1141
  }(e);
1142
1142
  if (i && "true" === i.dataset.loaded) try {
@@ -1160,10 +1160,10 @@ function Ae(e, t) {
1160
1160
  });
1161
1161
  });
1162
1162
  }
1163
- var Ce = function Ce(e) {
1163
+ var Ee = function Ee(e) {
1164
1164
  return document.querySelectorAll('script[src="'.concat(e, '"]'));
1165
1165
  };
1166
- var Ee,
1166
+ var Ce,
1167
1167
  Te = ["[Stytch]"],
1168
1168
  Oe = function Oe() {
1169
1169
  for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++) r[n] = arguments[n];
@@ -1539,7 +1539,7 @@ var Ee,
1539
1539
  }();
1540
1540
  !function (e) {
1541
1541
  e.LoginOrCreateEML = "login_or_create_eml", e.LoginOrCreateOTP = "login_or_create_otp", e.ResetPassword = "reset_password";
1542
- }(Ee || (Ee = {})), Promise.resolve({
1542
+ }(Ce || (Ce = {})), Promise.resolve({
1543
1543
  pkceRequiredForEmailMagicLinks: !1
1544
1544
  }), Promise.resolve({
1545
1545
  pkceRequiredForPasswordResets: !1
@@ -3810,7 +3810,7 @@ var ft = /*#__PURE__*/function () {
3810
3810
  },
3811
3811
  sdk: {
3812
3812
  identifier: "Stytch.js Javascript SDK",
3813
- version: "4.1.0"
3813
+ version: "4.1.1"
3814
3814
  }
3815
3815
  });
3816
3816
  }
@@ -4135,7 +4135,7 @@ var St = /*#__PURE__*/function () {
4135
4135
  removeItem: function removeItem(e) {
4136
4136
  return sessionStorage.removeItem(wt(_this4.publicToken, e));
4137
4137
  }
4138
- }, this.publicToken = e, this.state = null, 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);
4138
+ }, 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);
4139
4139
  var r = localStorage.getItem(wt(this.publicToken));
4140
4140
  if (!r) return;
4141
4141
  var n;
@@ -4261,6 +4261,15 @@ var St = /*#__PURE__*/function () {
4261
4261
  value: function removeItem(e) {
4262
4262
  return localStorage.removeItem(wt(this.publicToken, e));
4263
4263
  }
4264
+ }, {
4265
+ key: "markStateKeysUpdated",
4266
+ value: function markStateKeysUpdated(e) {
4267
+ var _this6 = this;
4268
+ var t = this.stateKeysUpdated.size;
4269
+ return e.forEach(function (e) {
4270
+ return _this6.stateKeysUpdated.add(e);
4271
+ }), t !== this.stateKeysUpdated.size;
4272
+ }
4264
4273
  }], [{
4265
4274
  key: "generateCookieOpts",
4266
4275
  value: function generateCookieOpts(_ref4) {
@@ -4287,14 +4296,14 @@ var Pt = /*#__PURE__*/function (_St) {
4287
4296
  return _createClass(Pt);
4288
4297
  }(St);
4289
4298
  var At = Symbol["for"]("__stytch_b2b_DataLayer"),
4290
- Ct = function Ct(e, t) {
4299
+ Et = function Et(e, t) {
4291
4300
  var r = function () {
4292
4301
  var e = window;
4293
4302
  return e[At] || (e[At] = {}), e[At];
4294
4303
  }();
4295
4304
  return r[e] || (r[e] = new Pt(e, t)), r[e];
4296
4305
  },
4297
- Et = function Et(e, t) {
4306
+ Ct = function Ct(e, t) {
4298
4307
  Object.values(e).forEach(function (e) {
4299
4308
  return e(t);
4300
4309
  });
@@ -4320,13 +4329,13 @@ var At = Symbol["for"]("__stytch_b2b_DataLayer"),
4320
4329
  });
4321
4330
  var Ot = /*#__PURE__*/function () {
4322
4331
  function Ot(e, t) {
4323
- var _this6 = this;
4332
+ var _this7 = this;
4324
4333
  _classCallCheck(this, Ot);
4325
4334
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4326
- if (e.key !== wt(_this6._publicToken)) return;
4327
- if (null === e.newValue || "null" === e.newValue) return void _this6.destroyState();
4335
+ if (e.key !== wt(_this7._publicToken)) return;
4336
+ if (null === e.newValue || "null" === e.newValue) return void _this7.destroyState();
4328
4337
  var t = JSON.parse(e.newValue);
4329
- _this6.updateState(t);
4338
+ _this7.updateState(t);
4330
4339
  }, window.addEventListener("storage", this._listen);
4331
4340
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4332
4341
  r = _this$_datalayer$read.session_token;
@@ -4363,7 +4372,9 @@ var Ot = /*#__PURE__*/function () {
4363
4372
  value: function _updateStateAndTokensInternal(e) {
4364
4373
  var t = this._datalayer.state,
4365
4374
  r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4366
- this._datalayer.state = r, Tt(t, r) || Et(this._datalayer.subscriptions, r);
4375
+ this._datalayer.state = r;
4376
+ var n = e.state ? Object.keys(e.state) : [];
4377
+ !this._datalayer.markStateKeysUpdated(n) && Tt(t, r) || Ct(this._datalayer.subscriptions, r);
4367
4378
  }
4368
4379
  }, {
4369
4380
  key: "updateStateAndTokens",
@@ -4375,7 +4386,11 @@ var Ot = /*#__PURE__*/function () {
4375
4386
  value: function updateState(e) {
4376
4387
  var t = this._datalayer.state,
4377
4388
  r = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e);
4378
- this._datalayer.state = r, Tt(t, r) || (Et(this._datalayer.subscriptions, r), this._datalayer.syncToLocalStorage());
4389
+ this._datalayer.state = r;
4390
+ var n = e ? Object.keys(e) : [],
4391
+ i = this._datalayer.markStateKeysUpdated(n),
4392
+ o = !Tt(t, r);
4393
+ (i || o) && (Ct(this._datalayer.subscriptions, r), o && this._datalayer.syncToLocalStorage());
4379
4394
  }
4380
4395
  }, {
4381
4396
  key: "updateTokens",
@@ -4421,27 +4436,27 @@ var xt = /*#__PURE__*/function (_Ot) {
4421
4436
  _inherits(xt, _Ot);
4422
4437
  var _super3 = _createSuper(xt);
4423
4438
  function xt() {
4424
- var _this7;
4439
+ var _this8;
4425
4440
  _classCallCheck(this, xt);
4426
- _this7 = _super3.apply(this, arguments), _this7.updateMember = function (e) {
4427
- return _this7.updateState({
4441
+ _this8 = _super3.apply(this, arguments), _this8.updateMember = function (e) {
4442
+ return _this8.updateState({
4428
4443
  member: e
4429
4444
  });
4430
- }, _this7.getMember = function () {
4445
+ }, _this8.getMember = function () {
4431
4446
  var e, t;
4432
- return null !== (t = null === (e = _this7.getState()) || void 0 === e ? void 0 : e.member) && void 0 !== t ? t : null;
4433
- }, _this7.getSession = function () {
4447
+ return null !== (t = null === (e = _this8.getState()) || void 0 === e ? void 0 : e.member) && void 0 !== t ? t : null;
4448
+ }, _this8.getSession = function () {
4434
4449
  var e, t;
4435
- return null !== (t = null === (e = _this7.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4450
+ return null !== (t = null === (e = _this8.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4436
4451
  };
4437
- return _this7;
4452
+ return _this8;
4438
4453
  }
4439
4454
  return _createClass(xt);
4440
4455
  }(Ot);
4441
4456
  var Dt = Symbol["for"]("stytch__internal_b2b");
4442
- exports.BiometricsFailedError = z, exports.BiometricsUnavailableError = A, exports.ChallengeSigningFailedError = F, exports.DeviceCredentialsNotAllowedError = D, exports.FailedCodeChallengeError = N, exports.FailedToDecryptDataError = U, 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 = K, exports.RandomNumberGenerationFailed = J, exports.SDKAPIUnreachableError = h, exports.SDKNotConfiguredError = j, exports.StytchAPIError = y, exports.StytchAPISchemaError = g, exports.StytchAPIUnreachableError = b, exports.StytchB2BHeadlessClient = /*#__PURE__*/function () {
4457
+ exports.BiometricsFailedError = z, exports.BiometricsUnavailableError = A, exports.ChallengeSigningFailedError = F, exports.DeviceCredentialsNotAllowedError = D, exports.FailedCodeChallengeError = N, exports.FailedToDecryptDataError = U, exports.InternalError = S, exports.InvalidAuthorizationCredentialError = L, exports.InvalidCredentialTypeError = H, exports.InvalidRedirectSchemeError = W, exports.InvalidStartUrlError = q, exports.JSONDataNotConvertibleToStringError = V, exports.KeyInvalidatedError = E, exports.KeystoreUnavailableError = C, 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 = K, exports.RandomNumberGenerationFailed = J, exports.SDKAPIUnreachableError = h, exports.SDKNotConfiguredError = j, exports.StytchAPIError = y, exports.StytchAPISchemaError = g, exports.StytchAPIUnreachableError = b, exports.StytchB2BHeadlessClient = /*#__PURE__*/function () {
4443
4458
  function _class(e, t) {
4444
- var _this8 = this;
4459
+ var _this9 = this;
4445
4460
  _classCallCheck(this, _class);
4446
4461
  var r;
4447
4462
  !function (e) {
@@ -4459,13 +4474,13 @@ exports.BiometricsFailedError = z, exports.BiometricsUnavailableError = A, expor
4459
4474
  }
4460
4475
  };
4461
4476
  var o, s, a, c, u, l, d, h, p, _, f;
4462
- this._dataLayer = Ct(e, n), this._subscriptionService = new xt(e, this._dataLayer);
4477
+ this._dataLayer = Et(e, n), this._subscriptionService = new xt(e, this._dataLayer);
4463
4478
  var m = new vt(this._dataLayer, "passwords");
4464
4479
  this._networkClient = new ft(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4465
4480
  var e, t, r, n;
4466
4481
  return {
4467
- stytch_member_id: null === (t = null === (e = _this8._dataLayer.state) || void 0 === e ? void 0 : e.member) || void 0 === t ? void 0 : t.member_id,
4468
- stytch_member_session_id: null === (n = null === (r = _this8._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.member_session_id
4482
+ 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,
4483
+ stytch_member_session_id: null === (n = null === (r = _this9._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.member_session_id
4469
4484
  };
4470
4485
  });
4471
4486
  var v = new pt(e, this._networkClient, this._dataLayer),
@@ -4515,11 +4530,11 @@ exports.BiometricsFailedError = z, exports.BiometricsUnavailableError = A, expor
4515
4530
  return new A();
4516
4531
  case "key_invalidated":
4517
4532
  case "no_biometric_key":
4518
- return new C();
4533
+ return new E();
4519
4534
  case "no_biometrics_enrolled":
4520
4535
  return new T();
4521
4536
  case "keystore_unavailable":
4522
- return new E();
4537
+ return new C();
4523
4538
  case "device_credentials_not_allowed":
4524
4539
  return new D();
4525
4540
  case "user_cancellation":