@stytch/vanilla-js 4.1.0 → 4.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @stytch/vanilla-js
2
2
 
3
+ ## 4.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - bf841b1: Fix B2B discovery flow when SSO is enabled with auth methods besides magic links
8
+
9
+ ## 4.1.1
10
+
11
+ ### Patch Changes
12
+
13
+ - e6832cb: Fix an issue where `fromCache` would not update to `false` after cached data was refreshed
14
+
3
15
  ## 4.1.0
4
16
 
5
17
  ### 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.2"
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),
@@ -9875,47 +9890,47 @@ var iu = Wa(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n
9875
9890
  _as12 = _slicedToArray(_as11, 2),
9876
9891
  e = _as12[1],
9877
9892
  t = ss().passwordOptions,
9878
- _Kn17 = Kn(!0),
9879
- _Kn18 = _slicedToArray(_Kn17, 2),
9880
- n = _Kn18[0],
9881
- r = _Kn18[1],
9882
9893
  _tu2 = tu(),
9883
- i = _tu2.stytch,
9884
- o = _tu2.email,
9885
- a = _tu2.setEmail,
9886
- s = _tu2.password,
9887
- c = _tu2.setPassword,
9888
- l = _tu2.organization,
9889
- u = _tu2.errorMessage,
9890
- d = _tu2.setErrorMessage,
9891
- p = _tu2.isSubmitting,
9892
- h = _tu2.setIsSubmitting,
9893
- f = _tu2.submitPassword,
9894
- m = _tu2.handleNonMemberReset;
9894
+ n = _tu2.stytch,
9895
+ r = _tu2.email,
9896
+ i = _tu2.setEmail,
9897
+ o = _tu2.password,
9898
+ a = _tu2.setPassword,
9899
+ s = _tu2.organization,
9900
+ c = _tu2.errorMessage,
9901
+ l = _tu2.setErrorMessage,
9902
+ u = _tu2.isSubmitting,
9903
+ d = _tu2.setIsSubmitting,
9904
+ p = _tu2.submitPassword,
9905
+ h = _tu2.handleNonMemberReset,
9906
+ _Kn17 = Kn(!r),
9907
+ _Kn18 = _slicedToArray(_Kn17, 2),
9908
+ f = _Kn18[0],
9909
+ m = _Kn18[1];
9895
9910
  if (!t) return ui.createElement(ui.Fragment, null);
9896
- if (!l) return ui.createElement(ui.Fragment, null);
9911
+ if (!s) return ui.createElement(ui.Fragment, null);
9897
9912
  return ui.createElement(Uc, {
9898
9913
  direction: "column",
9899
9914
  gap: 36
9900
9915
  }, ui.createElement("form", {
9901
9916
  onSubmit: function onSubmit(t) {
9902
9917
  return _t(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
9903
- var a;
9918
+ var i;
9904
9919
  return _regeneratorRuntime().wrap(function _callee25$(_context25) {
9905
9920
  while (1) switch (_context25.prev = _context25.next) {
9906
9921
  case 0:
9907
9922
  t.preventDefault();
9908
- a = l.organization_id;
9909
- n ? o.match(Pt) ? (d(""), h(!0), $t(i).searchManager.searchMember(o, l.organization_id).then(function (_ref51) {
9923
+ i = s.organization_id;
9924
+ f ? r.match(Pt) ? (l(""), d(!0), $t(n).searchManager.searchMember(r, s.organization_id).then(function (_ref51) {
9910
9925
  var t = _ref51.member;
9911
- if (null == t ? void 0 : t.member_password_id) return r(!1), h(!1), void e({
9926
+ if (null == t ? void 0 : t.member_password_id) return m(!1), d(!1), void e({
9912
9927
  type: "set_password_state",
9913
- email: o
9928
+ email: r
9914
9929
  });
9915
- m();
9930
+ h();
9916
9931
  })["catch"](function (e) {
9917
- h(!1), d(e.message);
9918
- })) : d("Invalid email address") : f(a);
9932
+ d(!1), l(e.message);
9933
+ })) : l("Invalid email address") : p(i);
9919
9934
  case 3:
9920
9935
  case "end":
9921
9936
  return _context25.stop();
@@ -9933,28 +9948,28 @@ var iu = Wa(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n
9933
9948
  size: "helper",
9934
9949
  color: "secondary"
9935
9950
  }, "Email"), ui.createElement(pu, {
9936
- email: o,
9937
- setEmail: a
9938
- })), !n && ui.createElement(Uc, {
9951
+ email: r,
9952
+ setEmail: i
9953
+ })), !f && ui.createElement(Uc, {
9939
9954
  direction: "column",
9940
9955
  gap: 2
9941
9956
  }, ui.createElement(Qc, {
9942
9957
  size: "helper",
9943
9958
  color: "secondary"
9944
9959
  }, "Password"), ui.createElement(Iu, {
9945
- password: s,
9946
- setPassword: c,
9960
+ password: o,
9961
+ setPassword: a,
9947
9962
  type: "current"
9948
9963
  })), ui.createElement(fu, {
9949
- errorMessage: u
9964
+ errorMessage: c
9950
9965
  }), ui.createElement(uu, {
9951
- isSubmitting: p,
9966
+ isSubmitting: u,
9952
9967
  text: "Continue"
9953
- }), !n && ui.createElement(Uc, {
9968
+ }), !f && ui.createElement(Uc, {
9954
9969
  onClick: function onClick() {
9955
9970
  e({
9956
9971
  type: "set_password_state",
9957
- email: o
9972
+ email: r
9958
9973
  }), e({
9959
9974
  type: "transition",
9960
9975
  screen: Xa.PasswordForgotForm
@@ -10605,7 +10620,8 @@ var td = Ja.a(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral([
10605
10620
  _Xl2 = Xl(),
10606
10621
  a = _Xl2.createOrganizationEnabled;
10607
10622
  qn(function () {
10608
- var e = function (e, t) {
10623
+ var e;
10624
+ var n = function (e, t) {
10609
10625
  if (!(null == t ? void 0 : t.status)) return null;
10610
10626
  var n = e.filter(function (e) {
10611
10627
  return "active_member" === e.membership.type;
@@ -10615,12 +10631,21 @@ var td = Ja.a(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral([
10615
10631
  });
10616
10632
  return 1 !== n.length || r ? null : n[0];
10617
10633
  }(t.formState.discoveryState.discoveredOrganizations, i.directLoginForSingleMembership);
10618
- o && null !== e && s(e.organization);
10634
+ o && null !== n && s(n.organization, n.member_authenticated, null === (e = n.membership.member) || void 0 === e ? void 0 : e.email_address);
10619
10635
  }, [o, t.formState.discoveryState.discoveredOrganizations, i.directLoginForSingleMembership]);
10620
- var s = function s(e) {
10621
- null != e.allowed_auth_methods && 1 == e.allowed_auth_methods.length && e.allowed_auth_methods.includes("sso") && null != e.sso_default_connection_id ? c(e.sso_default_connection_id) : l({
10636
+ var s = function s(e, t, r) {
10637
+ t ? l({
10622
10638
  organizationId: e.organization_id
10623
- });
10639
+ }) : e.allowed_auth_methods && 1 === e.allowed_auth_methods.length && "sso" === e.allowed_auth_methods[0] && e.sso_default_connection_id ? c(e.sso_default_connection_id) : (n({
10640
+ type: "set_organization",
10641
+ organization: e
10642
+ }), n({
10643
+ type: "set_password_state",
10644
+ email: null != r ? r : ""
10645
+ }), n({
10646
+ type: "transition",
10647
+ screen: Xa.Main
10648
+ }));
10624
10649
  },
10625
10650
  c = Zn(function (e) {
10626
10651
  r.sso.start({
@@ -10673,14 +10698,16 @@ var td = Ja.a(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral([
10673
10698
  direction: "column"
10674
10699
  }, t.formState.discoveryState.discoveredOrganizations.map(function (_ref69) {
10675
10700
  var e = _ref69.organization,
10676
- t = _ref69.membership;
10701
+ t = _ref69.membership,
10702
+ n = _ref69.member_authenticated;
10677
10703
  return an(cd, {
10678
10704
  padding: 8,
10679
10705
  justifyContent: "space-between",
10680
10706
  key: e.organization_id,
10681
10707
  alignItems: "center",
10682
10708
  onClick: function onClick() {
10683
- return s(e);
10709
+ var r;
10710
+ return s(e, n, null === (r = t.member) || void 0 === r ? void 0 : r.email_address);
10684
10711
  }
10685
10712
  }, an(Uc, {
10686
10713
  gap: 4,
@@ -11619,12 +11646,12 @@ var td = Ja.a(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral([
11619
11646
  _inherits(r, _HTMLElement);
11620
11647
  var _super4 = _createSuper(r);
11621
11648
  function r(e) {
11622
- var _this9;
11649
+ var _this10;
11623
11650
  _classCallCheck(this, r);
11624
- _this9 = _super4.call(this), _this9.props = e, _this9.rootRef = _this9.attachShadow({
11651
+ _this10 = _super4.call(this), _this10.props = e, _this10.rootRef = _this10.attachShadow({
11625
11652
  mode: "open"
11626
11653
  });
11627
- return _this9;
11654
+ return _this10;
11628
11655
  }
11629
11656
  _createClass(r, [{
11630
11657
  key: "connectedCallback",
@@ -11670,10 +11697,10 @@ var td = Ja.a(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral([
11670
11697
  _inherits(r, _HTMLElement2);
11671
11698
  var _super5 = _createSuper(r);
11672
11699
  function r(e) {
11673
- var _this10;
11700
+ var _this11;
11674
11701
  _classCallCheck(this, r);
11675
- _this10 = _super5.call(this), _this10.props = e, _this10.rootRef = document.createElement("div"), _this10.append(_this10.rootRef);
11676
- return _this10;
11702
+ _this11 = _super5.call(this), _this11.props = e, _this11.rootRef = document.createElement("div"), _this11.append(_this11.rootRef);
11703
+ return _this11;
11677
11704
  }
11678
11705
  _createClass(r, [{
11679
11706
  key: "connectedCallback",
@@ -11707,7 +11734,7 @@ var Fd = /*#__PURE__*/function (_Ht) {
11707
11734
  _inherits(Fd, _Ht);
11708
11735
  var _super6 = _createSuper(Fd);
11709
11736
  function Fd() {
11710
- var _this11;
11737
+ var _this12;
11711
11738
  _classCallCheck(this, Fd);
11712
11739
  for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
11713
11740
  e[_key6] = arguments[_key6];
@@ -11715,8 +11742,8 @@ var Fd = /*#__PURE__*/function (_Ht) {
11715
11742
  !function (e) {
11716
11743
  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
11744
  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;
11745
+ }("StytchUIClient"), _this12 = _super6.call.apply(_super6, [this].concat(e));
11746
+ return _this12;
11720
11747
  }
11721
11748
  _createClass(Fd, [{
11722
11749
  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.2"
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),