@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/dist/index.esm.js CHANGED
@@ -3814,7 +3814,7 @@ var Qt = /*#__PURE__*/function () {
3814
3814
  },
3815
3815
  sdk: {
3816
3816
  identifier: "Stytch.js Javascript SDK",
3817
- version: "4.1.0"
3817
+ version: "4.1.1"
3818
3818
  }
3819
3819
  });
3820
3820
  }
@@ -4377,7 +4377,7 @@ var nn = /*#__PURE__*/function () {
4377
4377
  removeItem: function removeItem(e) {
4378
4378
  return sessionStorage.removeItem(tn(_this7.publicToken, e));
4379
4379
  }
4380
- }, this.publicToken = e, this.state = null, this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (Ke("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);
4380
+ }, this.publicToken = e, this.state = null, this.stateKeysUpdated = new Set(), this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (Ke("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);
4381
4381
  var n = localStorage.getItem(tn(this.publicToken));
4382
4382
  if (!n) return;
4383
4383
  var r;
@@ -4503,6 +4503,15 @@ var nn = /*#__PURE__*/function () {
4503
4503
  value: function removeItem(e) {
4504
4504
  return localStorage.removeItem(tn(this.publicToken, e));
4505
4505
  }
4506
+ }, {
4507
+ key: "markStateKeysUpdated",
4508
+ value: function markStateKeysUpdated(e) {
4509
+ var _this9 = this;
4510
+ var t = this.stateKeysUpdated.size;
4511
+ return e.forEach(function (e) {
4512
+ return _this9.stateKeysUpdated.add(e);
4513
+ }), t !== this.stateKeysUpdated.size;
4514
+ }
4506
4515
  }], [{
4507
4516
  key: "generateCookieOpts",
4508
4517
  value: function generateCookieOpts(_ref7) {
@@ -4562,13 +4571,13 @@ var on = Symbol["for"]("__stytch_DataLayer"),
4562
4571
  });
4563
4572
  var ln = /*#__PURE__*/function () {
4564
4573
  function ln(e, t) {
4565
- var _this9 = this;
4574
+ var _this10 = this;
4566
4575
  _classCallCheck(this, ln);
4567
4576
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4568
- if (e.key !== tn(_this9._publicToken)) return;
4569
- if (null === e.newValue || "null" === e.newValue) return void _this9.destroyState();
4577
+ if (e.key !== tn(_this10._publicToken)) return;
4578
+ if (null === e.newValue || "null" === e.newValue) return void _this10.destroyState();
4570
4579
  var t = JSON.parse(e.newValue);
4571
- _this9.updateState(t);
4580
+ _this10.updateState(t);
4572
4581
  }, window.addEventListener("storage", this._listen);
4573
4582
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4574
4583
  n = _this$_datalayer$read.session_token;
@@ -4605,7 +4614,9 @@ var ln = /*#__PURE__*/function () {
4605
4614
  value: function _updateStateAndTokensInternal(e) {
4606
4615
  var t = this._datalayer.state,
4607
4616
  n = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4608
- this._datalayer.state = n, cn(t, n) || sn(this._datalayer.subscriptions, n);
4617
+ this._datalayer.state = n;
4618
+ var r = e.state ? Object.keys(e.state) : [];
4619
+ !this._datalayer.markStateKeysUpdated(r) && cn(t, n) || sn(this._datalayer.subscriptions, n);
4609
4620
  }
4610
4621
  }, {
4611
4622
  key: "updateStateAndTokens",
@@ -4617,7 +4628,11 @@ var ln = /*#__PURE__*/function () {
4617
4628
  value: function updateState(e) {
4618
4629
  var t = this._datalayer.state,
4619
4630
  n = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e);
4620
- this._datalayer.state = n, cn(t, n) || (sn(this._datalayer.subscriptions, n), this._datalayer.syncToLocalStorage());
4631
+ this._datalayer.state = n;
4632
+ var r = e ? Object.keys(e) : [],
4633
+ i = this._datalayer.markStateKeysUpdated(r),
4634
+ o = !cn(t, n);
4635
+ (i || o) && (sn(this._datalayer.subscriptions, n), o && this._datalayer.syncToLocalStorage());
4621
4636
  }
4622
4637
  }, {
4623
4638
  key: "updateTokens",
@@ -4663,20 +4678,20 @@ var un = /*#__PURE__*/function (_ln) {
4663
4678
  _inherits(un, _ln);
4664
4679
  var _super3 = _createSuper(un);
4665
4680
  function un() {
4666
- var _this10;
4681
+ var _this11;
4667
4682
  _classCallCheck(this, un);
4668
- _this10 = _super3.apply(this, arguments), _this10.updateUser = function (e) {
4669
- return _this10.updateState({
4683
+ _this11 = _super3.apply(this, arguments), _this11.updateUser = function (e) {
4684
+ return _this11.updateState({
4670
4685
  user: e
4671
4686
  });
4672
- }, _this10.getUser = function () {
4687
+ }, _this11.getUser = function () {
4673
4688
  var e, t;
4674
- return null !== (t = null === (e = _this10.getState()) || void 0 === e ? void 0 : e.user) && void 0 !== t ? t : null;
4675
- }, _this10.getSession = function () {
4689
+ return null !== (t = null === (e = _this11.getState()) || void 0 === e ? void 0 : e.user) && void 0 !== t ? t : null;
4690
+ }, _this11.getSession = function () {
4676
4691
  var e, t;
4677
- return null !== (t = null === (e = _this10.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4692
+ return null !== (t = null === (e = _this11.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4678
4693
  };
4679
- return _this10;
4694
+ return _this11;
4680
4695
  }
4681
4696
  return _createClass(un);
4682
4697
  }(ln);
@@ -4687,7 +4702,7 @@ var dn = Symbol["for"]("stytch__internal_b2c"),
4687
4702
  return t[dn];
4688
4703
  };
4689
4704
  var hn = /*#__PURE__*/_createClass(function hn(e, t) {
4690
- var _this11 = this;
4705
+ var _this12 = this;
4691
4706
  _classCallCheck(this, hn);
4692
4707
  var n;
4693
4708
  Ge("StytchHeadlessClient"), "string" != typeof (n = e) ? Ze("Public token is malformed. Expected a string, got ".concat(de(n), ".").concat(Ve)) : "" === n ? Ze('Public token is malformed. Expected "public-token-...", got an empty string.'.concat(Ve)) : n.startsWith("public-token-") || Ze('Public token is malformed. Expected "public-token-...", got '.concat(n, ".").concat(Ve));
@@ -4710,8 +4725,8 @@ var hn = /*#__PURE__*/_createClass(function hn(e, t) {
4710
4725
  this._networkClient = new Qt(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4711
4726
  var e, t, n, r;
4712
4727
  return {
4713
- stytch_user_id: null === (t = null === (e = _this11._dataLayer.state) || void 0 === e ? void 0 : e.user) || void 0 === t ? void 0 : t.user_id,
4714
- stytch_session_id: null === (r = null === (n = _this11._dataLayer.state) || void 0 === n ? void 0 : n.session) || void 0 === r ? void 0 : r.session_id
4728
+ stytch_user_id: null === (t = null === (e = _this12._dataLayer.state) || void 0 === e ? void 0 : e.user) || void 0 === t ? void 0 : t.user_id,
4729
+ stytch_session_id: null === (r = null === (n = _this12._dataLayer.state) || void 0 === n ? void 0 : n.session) || void 0 === r ? void 0 : r.session_id
4715
4730
  };
4716
4731
  });
4717
4732
  var a = new Dt(e, this._networkClient, this._dataLayer),
@@ -7074,12 +7089,12 @@ function _s(e, t) {
7074
7089
  _inherits(r, _HTMLElement);
7075
7090
  var _super4 = _createSuper(r);
7076
7091
  function r(e) {
7077
- var _this12;
7092
+ var _this13;
7078
7093
  _classCallCheck(this, r);
7079
- _this12 = _super4.call(this), _this12.props = e, _this12.rootRef = _this12.attachShadow({
7094
+ _this13 = _super4.call(this), _this13.props = e, _this13.rootRef = _this13.attachShadow({
7080
7095
  mode: "open"
7081
7096
  });
7082
- return _this12;
7097
+ return _this13;
7083
7098
  }
7084
7099
  _createClass(r, [{
7085
7100
  key: "connectedCallback",
@@ -7125,10 +7140,10 @@ function _s(e, t) {
7125
7140
  _inherits(r, _HTMLElement2);
7126
7141
  var _super5 = _createSuper(r);
7127
7142
  function r(e) {
7128
- var _this13;
7143
+ var _this14;
7129
7144
  _classCallCheck(this, r);
7130
- _this13 = _super5.call(this), _this13.props = e, _this13.rootRef = document.createElement("div"), _this13.append(_this13.rootRef);
7131
- return _this13;
7145
+ _this14 = _super5.call(this), _this14.props = e, _this14.rootRef = document.createElement("div"), _this14.append(_this14.rootRef);
7146
+ return _this14;
7132
7147
  }
7133
7148
  _createClass(r, [{
7134
7149
  key: "connectedCallback",
@@ -14810,13 +14825,13 @@ var _f = /*#__PURE__*/function (_hn) {
14810
14825
  _inherits(_f, _hn);
14811
14826
  var _super6 = _createSuper(_f);
14812
14827
  function _f() {
14813
- var _this14;
14828
+ var _this15;
14814
14829
  _classCallCheck(this, _f);
14815
14830
  for (var _len7 = arguments.length, e = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
14816
14831
  e[_key7] = arguments[_key7];
14817
14832
  }
14818
- Ge("StytchUIClient"), _this14 = _super6.call.apply(_super6, [this].concat(e));
14819
- return _this14;
14833
+ Ge("StytchUIClient"), _this15 = _super6.call.apply(_super6, [this].concat(e));
14834
+ return _this15;
14820
14835
  }
14821
14836
  _createClass(_f, [{
14822
14837
  key: "mountLogin",
@@ -3796,7 +3796,7 @@ var Nt = /*#__PURE__*/function () {
3796
3796
  },
3797
3797
  sdk: {
3798
3798
  identifier: "Stytch.js Javascript SDK",
3799
- version: "4.1.0"
3799
+ version: "4.1.1"
3800
3800
  }
3801
3801
  });
3802
3802
  }
@@ -4326,7 +4326,7 @@ var Jt = /*#__PURE__*/function () {
4326
4326
  removeItem: function removeItem(e) {
4327
4327
  return sessionStorage.removeItem(Vt(_this7.publicToken, e));
4328
4328
  }
4329
- }, this.publicToken = e, this.state = null, this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (ze("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);
4329
+ }, this.publicToken = e, this.state = null, this.stateKeysUpdated = new Set(), this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (ze("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);
4330
4330
  var r = localStorage.getItem(Vt(this.publicToken));
4331
4331
  if (!r) return;
4332
4332
  var n;
@@ -4452,6 +4452,15 @@ var Jt = /*#__PURE__*/function () {
4452
4452
  value: function removeItem(e) {
4453
4453
  return localStorage.removeItem(Vt(this.publicToken, e));
4454
4454
  }
4455
+ }, {
4456
+ key: "markStateKeysUpdated",
4457
+ value: function markStateKeysUpdated(e) {
4458
+ var _this9 = this;
4459
+ var t = this.stateKeysUpdated.size;
4460
+ return e.forEach(function (e) {
4461
+ return _this9.stateKeysUpdated.add(e);
4462
+ }), t !== this.stateKeysUpdated.size;
4463
+ }
4455
4464
  }], [{
4456
4465
  key: "generateCookieOpts",
4457
4466
  value: function generateCookieOpts(_ref7) {
@@ -4511,13 +4520,13 @@ var Xt = Symbol["for"]("__stytch_DataLayer"),
4511
4520
  });
4512
4521
  var tr = /*#__PURE__*/function () {
4513
4522
  function tr(e, t) {
4514
- var _this9 = this;
4523
+ var _this10 = this;
4515
4524
  _classCallCheck(this, tr);
4516
4525
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4517
- if (e.key !== Vt(_this9._publicToken)) return;
4518
- if (null === e.newValue || "null" === e.newValue) return void _this9.destroyState();
4526
+ if (e.key !== Vt(_this10._publicToken)) return;
4527
+ if (null === e.newValue || "null" === e.newValue) return void _this10.destroyState();
4519
4528
  var t = JSON.parse(e.newValue);
4520
- _this9.updateState(t);
4529
+ _this10.updateState(t);
4521
4530
  }, window.addEventListener("storage", this._listen);
4522
4531
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4523
4532
  r = _this$_datalayer$read.session_token;
@@ -4554,7 +4563,9 @@ var tr = /*#__PURE__*/function () {
4554
4563
  value: function _updateStateAndTokensInternal(e) {
4555
4564
  var t = this._datalayer.state,
4556
4565
  r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4557
- this._datalayer.state = r, er(t, r) || Qt(this._datalayer.subscriptions, r);
4566
+ this._datalayer.state = r;
4567
+ var n = e.state ? Object.keys(e.state) : [];
4568
+ !this._datalayer.markStateKeysUpdated(n) && er(t, r) || Qt(this._datalayer.subscriptions, r);
4558
4569
  }
4559
4570
  }, {
4560
4571
  key: "updateStateAndTokens",
@@ -4566,7 +4577,11 @@ var tr = /*#__PURE__*/function () {
4566
4577
  value: function updateState(e) {
4567
4578
  var t = this._datalayer.state,
4568
4579
  r = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e);
4569
- this._datalayer.state = r, er(t, r) || (Qt(this._datalayer.subscriptions, r), this._datalayer.syncToLocalStorage());
4580
+ this._datalayer.state = r;
4581
+ var n = e ? Object.keys(e) : [],
4582
+ i = this._datalayer.markStateKeysUpdated(n),
4583
+ s = !er(t, r);
4584
+ (i || s) && (Qt(this._datalayer.subscriptions, r), s && this._datalayer.syncToLocalStorage());
4570
4585
  }
4571
4586
  }, {
4572
4587
  key: "updateTokens",
@@ -4612,26 +4627,26 @@ var rr = /*#__PURE__*/function (_tr) {
4612
4627
  _inherits(rr, _tr);
4613
4628
  var _super3 = _createSuper(rr);
4614
4629
  function rr() {
4615
- var _this10;
4630
+ var _this11;
4616
4631
  _classCallCheck(this, rr);
4617
- _this10 = _super3.apply(this, arguments), _this10.updateUser = function (e) {
4618
- return _this10.updateState({
4632
+ _this11 = _super3.apply(this, arguments), _this11.updateUser = function (e) {
4633
+ return _this11.updateState({
4619
4634
  user: e
4620
4635
  });
4621
- }, _this10.getUser = function () {
4636
+ }, _this11.getUser = function () {
4622
4637
  var e, t;
4623
- return null !== (t = null === (e = _this10.getState()) || void 0 === e ? void 0 : e.user) && void 0 !== t ? t : null;
4624
- }, _this10.getSession = function () {
4638
+ return null !== (t = null === (e = _this11.getState()) || void 0 === e ? void 0 : e.user) && void 0 !== t ? t : null;
4639
+ }, _this11.getSession = function () {
4625
4640
  var e, t;
4626
- return null !== (t = null === (e = _this10.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4641
+ return null !== (t = null === (e = _this11.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4627
4642
  };
4628
- return _this10;
4643
+ return _this11;
4629
4644
  }
4630
4645
  return _createClass(rr);
4631
4646
  }(tr);
4632
4647
  var nr = Symbol["for"]("stytch__internal_b2c");
4633
4648
  var ir = /*#__PURE__*/_createClass(function ir(e, t) {
4634
- var _this11 = this;
4649
+ var _this12 = this;
4635
4650
  _classCallCheck(this, ir);
4636
4651
  var r;
4637
4652
  !function (e) {
@@ -4655,8 +4670,8 @@ var ir = /*#__PURE__*/_createClass(function ir(e, t) {
4655
4670
  this._networkClient = new Nt(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4656
4671
  var e, t, r, n;
4657
4672
  return {
4658
- stytch_user_id: null === (t = null === (e = _this11._dataLayer.state) || void 0 === e ? void 0 : e.user) || void 0 === t ? void 0 : t.user_id,
4659
- stytch_session_id: null === (n = null === (r = _this11._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.session_id
4673
+ stytch_user_id: null === (t = null === (e = _this12._dataLayer.state) || void 0 === e ? void 0 : e.user) || void 0 === t ? void 0 : t.user_id,
4674
+ stytch_session_id: null === (n = null === (r = _this12._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.session_id
4660
4675
  };
4661
4676
  });
4662
4677
  var v = new Ft(e, this._networkClient, this._dataLayer),
@@ -317,7 +317,7 @@ var y,
317
317
  }
318
318
  return r(o);
319
319
  }(),
320
- N = function (e) {
320
+ U = function (e) {
321
321
  i(o, E);
322
322
  var t = s(o);
323
323
  function o() {
@@ -325,7 +325,7 @@ var y,
325
325
  }
326
326
  return r(o);
327
327
  }(),
328
- U = function (e) {
328
+ N = function (e) {
329
329
  i(o, E);
330
330
  var t = s(o);
331
331
  function o() {
@@ -1179,7 +1179,7 @@ function Be(e, t) {
1179
1179
  function Me(e, t) {
1180
1180
  return new Promise(function (r, n) {
1181
1181
  var i = function (e) {
1182
- var t = Ne(e);
1182
+ var t = Ue(e);
1183
1183
  if (t[0]) return t[0];
1184
1184
  }(e);
1185
1185
  if (i && "true" === i.dataset.loaded) try {
@@ -1203,10 +1203,10 @@ function Me(e, t) {
1203
1203
  });
1204
1204
  });
1205
1205
  }
1206
- var Ne = function Ne(e) {
1206
+ var Ue = function Ue(e) {
1207
1207
  return document.querySelectorAll('script[src="'.concat(e, '"]'));
1208
1208
  };
1209
- var Ue,
1209
+ var Ne,
1210
1210
  Ke = ["[Stytch]"],
1211
1211
  qe = function qe() {
1212
1212
  for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++) r[n] = arguments[n];
@@ -1590,7 +1590,7 @@ var Ue,
1590
1590
  }();
1591
1591
  !function (e) {
1592
1592
  e.LoginOrCreateEML = "login_or_create_eml", e.LoginOrCreateOTP = "login_or_create_otp", e.ResetPassword = "reset_password";
1593
- }(Ue || (Ue = {}));
1593
+ }(Ne || (Ne = {}));
1594
1594
  var Ze = pe(function e(t, r) {
1595
1595
  var n = this;
1596
1596
  fe(this, e), this._networkClient = t, this._subscriptionService = r, this.get = function () {
@@ -3714,7 +3714,7 @@ var Mt = /*#__PURE__*/function () {
3714
3714
  },
3715
3715
  sdk: {
3716
3716
  identifier: "Stytch.js Javascript SDK",
3717
- version: "4.1.0"
3717
+ version: "4.1.1"
3718
3718
  }
3719
3719
  });
3720
3720
  }
@@ -3828,12 +3828,12 @@ var Mt = /*#__PURE__*/function () {
3828
3828
  }]);
3829
3829
  return Mt;
3830
3830
  }();
3831
- var Nt = /*#__PURE__*/function () {
3832
- function Nt(e, t, r) {
3833
- _classCallCheck(this, Nt);
3831
+ var Ut = /*#__PURE__*/function () {
3832
+ function Ut(e, t, r) {
3833
+ _classCallCheck(this, Ut);
3834
3834
  this._googleClient = e, this._publicToken = t, this._clientId = r;
3835
3835
  }
3836
- _createClass(Nt, [{
3836
+ _createClass(Ut, [{
3837
3837
  key: "cancel",
3838
3838
  value: function cancel() {
3839
3839
  this._googleClient.cancel();
@@ -3885,12 +3885,12 @@ var Nt = /*#__PURE__*/function () {
3885
3885
  });
3886
3886
  }
3887
3887
  }]);
3888
- return Nt;
3888
+ return Ut;
3889
3889
  }();
3890
- var Ut = /*#__PURE__*/function () {
3891
- function Ut(e, t) {
3890
+ var Nt = /*#__PURE__*/function () {
3891
+ function Nt(e, t) {
3892
3892
  var _this6 = this;
3893
- _classCallCheck(this, Ut);
3893
+ _classCallCheck(this, Nt);
3894
3894
  this._publicToken = e, this.clientsideServices = t, this.createOnSuccessHandler = function (_ref5) {
3895
3895
  var e = _ref5.loginRedirectUrl,
3896
3896
  t = _ref5.signupRedirectUrl,
@@ -3923,7 +3923,7 @@ var Ut = /*#__PURE__*/function () {
3923
3923
  window.location.href = e;
3924
3924
  };
3925
3925
  }
3926
- _createClass(Ut, [{
3926
+ _createClass(Nt, [{
3927
3927
  key: "createOneTapClient",
3928
3928
  value: function createOneTapClient() {
3929
3929
  return Ft(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
@@ -3957,7 +3957,7 @@ var Ut = /*#__PURE__*/function () {
3957
3957
  });
3958
3958
  case 12:
3959
3959
  _context8.t1 = !0;
3960
- _context8.t2 = Nt;
3960
+ _context8.t2 = Ut;
3961
3961
  _context8.next = 16;
3962
3962
  return Be(Se, function () {
3963
3963
  return window.google.accounts.id;
@@ -4028,10 +4028,10 @@ var Ut = /*#__PURE__*/function () {
4028
4028
  }, {
4029
4029
  key: "WillGoogleOneTapShowEmbedded",
4030
4030
  value: function WillGoogleOneTapShowEmbedded() {
4031
- return !Ut.WillGoogleOneTapShowBannerForUA(navigator.userAgent);
4031
+ return !Nt.WillGoogleOneTapShowBannerForUA(navigator.userAgent);
4032
4032
  }
4033
4033
  }]);
4034
- return Ut;
4034
+ return Nt;
4035
4035
  }();
4036
4036
  function Kt(e) {
4037
4037
  var t = e.toString(16);
@@ -4244,7 +4244,7 @@ var Vt = /*#__PURE__*/function () {
4244
4244
  removeItem: function removeItem(e) {
4245
4245
  return sessionStorage.removeItem(Yt(_this7.publicToken, e));
4246
4246
  }
4247
- }, this.publicToken = e, this.state = null, this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (He("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);
4247
+ }, this.publicToken = e, this.state = null, this.stateKeysUpdated = new Set(), this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (He("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);
4248
4248
  var r = localStorage.getItem(Yt(this.publicToken));
4249
4249
  if (!r) return;
4250
4250
  var n;
@@ -4370,6 +4370,15 @@ var Vt = /*#__PURE__*/function () {
4370
4370
  value: function removeItem(e) {
4371
4371
  return localStorage.removeItem(Yt(this.publicToken, e));
4372
4372
  }
4373
+ }, {
4374
+ key: "markStateKeysUpdated",
4375
+ value: function markStateKeysUpdated(e) {
4376
+ var _this9 = this;
4377
+ var t = this.stateKeysUpdated.size;
4378
+ return e.forEach(function (e) {
4379
+ return _this9.stateKeysUpdated.add(e);
4380
+ }), t !== this.stateKeysUpdated.size;
4381
+ }
4373
4382
  }], [{
4374
4383
  key: "generateCookieOpts",
4375
4384
  value: function generateCookieOpts(_ref7) {
@@ -4429,13 +4438,13 @@ var $t = Symbol["for"]("__stytch_DataLayer"),
4429
4438
  });
4430
4439
  var er = /*#__PURE__*/function () {
4431
4440
  function er(e, t) {
4432
- var _this9 = this;
4441
+ var _this10 = this;
4433
4442
  _classCallCheck(this, er);
4434
4443
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4435
- if (e.key !== Yt(_this9._publicToken)) return;
4436
- if (null === e.newValue || "null" === e.newValue) return void _this9.destroyState();
4444
+ if (e.key !== Yt(_this10._publicToken)) return;
4445
+ if (null === e.newValue || "null" === e.newValue) return void _this10.destroyState();
4437
4446
  var t = JSON.parse(e.newValue);
4438
- _this9.updateState(t);
4447
+ _this10.updateState(t);
4439
4448
  }, window.addEventListener("storage", this._listen);
4440
4449
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4441
4450
  r = _this$_datalayer$read.session_token;
@@ -4472,7 +4481,9 @@ var er = /*#__PURE__*/function () {
4472
4481
  value: function _updateStateAndTokensInternal(e) {
4473
4482
  var t = this._datalayer.state,
4474
4483
  r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4475
- this._datalayer.state = r, Qt(t, r) || Zt(this._datalayer.subscriptions, r);
4484
+ this._datalayer.state = r;
4485
+ var n = e.state ? Object.keys(e.state) : [];
4486
+ !this._datalayer.markStateKeysUpdated(n) && Qt(t, r) || Zt(this._datalayer.subscriptions, r);
4476
4487
  }
4477
4488
  }, {
4478
4489
  key: "updateStateAndTokens",
@@ -4484,7 +4495,11 @@ var er = /*#__PURE__*/function () {
4484
4495
  value: function updateState(e) {
4485
4496
  var t = this._datalayer.state,
4486
4497
  r = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e);
4487
- this._datalayer.state = r, Qt(t, r) || (Zt(this._datalayer.subscriptions, r), this._datalayer.syncToLocalStorage());
4498
+ this._datalayer.state = r;
4499
+ var n = e ? Object.keys(e) : [],
4500
+ i = this._datalayer.markStateKeysUpdated(n),
4501
+ s = !Qt(t, r);
4502
+ (i || s) && (Zt(this._datalayer.subscriptions, r), s && this._datalayer.syncToLocalStorage());
4488
4503
  }
4489
4504
  }, {
4490
4505
  key: "updateTokens",
@@ -4530,27 +4545,27 @@ var tr = /*#__PURE__*/function (_er) {
4530
4545
  _inherits(tr, _er);
4531
4546
  var _super3 = _createSuper(tr);
4532
4547
  function tr() {
4533
- var _this10;
4548
+ var _this11;
4534
4549
  _classCallCheck(this, tr);
4535
- _this10 = _super3.apply(this, arguments), _this10.updateUser = function (e) {
4536
- return _this10.updateState({
4550
+ _this11 = _super3.apply(this, arguments), _this11.updateUser = function (e) {
4551
+ return _this11.updateState({
4537
4552
  user: e
4538
4553
  });
4539
- }, _this10.getUser = function () {
4554
+ }, _this11.getUser = function () {
4540
4555
  var e, t;
4541
- return null !== (t = null === (e = _this10.getState()) || void 0 === e ? void 0 : e.user) && void 0 !== t ? t : null;
4542
- }, _this10.getSession = function () {
4556
+ return null !== (t = null === (e = _this11.getState()) || void 0 === e ? void 0 : e.user) && void 0 !== t ? t : null;
4557
+ }, _this11.getSession = function () {
4543
4558
  var e, t;
4544
- return null !== (t = null === (e = _this10.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4559
+ return null !== (t = null === (e = _this11.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4545
4560
  };
4546
- return _this10;
4561
+ return _this11;
4547
4562
  }
4548
4563
  return _createClass(tr);
4549
4564
  }(er);
4550
4565
  var rr = Symbol["for"]("stytch__internal_b2c");
4551
- exports.BiometricsFailedError = X, exports.BiometricsUnavailableError = F, exports.ChallengeSigningFailedError = z, exports.DeviceCredentialsNotAllowedError = U, exports.FailedCodeChallengeError = V, exports.FailedToDecryptDataError = $, exports.InternalError = R, exports.InvalidAuthorizationCredentialError = G, exports.InvalidCredentialTypeError = te, exports.InvalidRedirectSchemeError = Q, exports.InvalidStartUrlError = Z, exports.JSONDataNotConvertibleToStringError = ne, exports.KeyInvalidatedError = j, exports.KeystoreUnavailableError = L, exports.MissingAttestationObjectError = re, exports.MissingAuthorizationCredentialIDTokenError = W, exports.MissingGoogleClientIDError = K, exports.MissingPKCEError = q, exports.MissingPublicKeyError = H, exports.MissingUrlError = ee, exports.NoBiometricsEnrolledError = B, exports.NoBiometricsRegistrationError = I, exports.NoCurrentSessionError = D, exports.PasskeysInvalidEncoding = se, exports.PasskeysUnsupportedError = J, exports.RandomNumberGenerationFailed = ie, exports.SDKAPIUnreachableError = k, exports.SDKNotConfiguredError = Y, exports.StytchAPIError = T, exports.StytchAPISchemaError = A, exports.StytchAPIUnreachableError = O, exports.StytchError = C, exports.StytchHeadlessClient = /*#__PURE__*/function () {
4566
+ exports.BiometricsFailedError = X, exports.BiometricsUnavailableError = F, exports.ChallengeSigningFailedError = z, exports.DeviceCredentialsNotAllowedError = N, exports.FailedCodeChallengeError = V, exports.FailedToDecryptDataError = $, exports.InternalError = R, exports.InvalidAuthorizationCredentialError = G, exports.InvalidCredentialTypeError = te, exports.InvalidRedirectSchemeError = Q, exports.InvalidStartUrlError = Z, exports.JSONDataNotConvertibleToStringError = ne, exports.KeyInvalidatedError = j, exports.KeystoreUnavailableError = L, exports.MissingAttestationObjectError = re, exports.MissingAuthorizationCredentialIDTokenError = W, exports.MissingGoogleClientIDError = K, exports.MissingPKCEError = q, exports.MissingPublicKeyError = H, exports.MissingUrlError = ee, exports.NoBiometricsEnrolledError = B, exports.NoBiometricsRegistrationError = I, exports.NoCurrentSessionError = D, exports.PasskeysInvalidEncoding = se, exports.PasskeysUnsupportedError = J, exports.RandomNumberGenerationFailed = ie, exports.SDKAPIUnreachableError = k, exports.SDKNotConfiguredError = Y, exports.StytchAPIError = T, exports.StytchAPISchemaError = A, exports.StytchAPIUnreachableError = O, exports.StytchError = C, exports.StytchHeadlessClient = /*#__PURE__*/function () {
4552
4567
  function _class(e, t) {
4553
- var _this11 = this;
4568
+ var _this12 = this;
4554
4569
  _classCallCheck(this, _class);
4555
4570
  var r;
4556
4571
  !function (e) {
@@ -4574,15 +4589,15 @@ exports.BiometricsFailedError = X, exports.BiometricsUnavailableError = F, expor
4574
4589
  this._networkClient = new Mt(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4575
4590
  var e, t, r, n;
4576
4591
  return {
4577
- stytch_user_id: null === (t = null === (e = _this11._dataLayer.state) || void 0 === e ? void 0 : e.user) || void 0 === t ? void 0 : t.user_id,
4578
- stytch_session_id: null === (n = null === (r = _this11._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.session_id
4592
+ stytch_user_id: null === (t = null === (e = _this12._dataLayer.state) || void 0 === e ? void 0 : e.user) || void 0 === t ? void 0 : t.user_id,
4593
+ stytch_session_id: null === (n = null === (r = _this12._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.session_id
4579
4594
  };
4580
4595
  });
4581
4596
  var m = new It(e, this._networkClient, this._dataLayer),
4582
4597
  y = new jt(m.getAsync()),
4583
4598
  g = new Ve(e, i.endpoints.dfpBackendURL, m.getAsync(), y.executeRecaptcha),
4584
4599
  b = new Lt(i.endpoints.clientsideServicesIframeURL),
4585
- k = new Ut(e, b),
4600
+ k = new Nt(e, b),
4586
4601
  w = new Wt(this._networkClient);
4587
4602
  var S, x;
4588
4603
  this.user = new Ze(this._networkClient, this._subscriptionService), this.session = new Qe(this._networkClient, this._subscriptionService), this.magicLinks = new tt(this._networkClient, this._subscriptionService, new qt(this._dataLayer, "magic_links"), v, m.getAsync(), g), this.otps = new rt(this._networkClient, this._subscriptionService, y.executeRecaptcha, g), this.oauth = new Bt(this._networkClient, this._subscriptionService, new qt(this._dataLayer, "oauth"), m.getAsync(), {
@@ -4608,7 +4623,7 @@ exports.BiometricsFailedError = X, exports.BiometricsUnavailableError = F, expor
4608
4623
  }, Object.assign(S, _defineProperty({}, rr, x));
4609
4624
  }
4610
4625
  return _createClass(_class);
4611
- }(), exports.StytchSDKAPIError = x, exports.StytchSDKError = E, exports.StytchSDKSchemaError = S, exports.StytchSDKUsageError = w, exports.UNRECOVERABLE_ERROR_TYPES = P, exports.UserCancellationError = M, exports.UserLockedOutError = N, exports.errorToStytchError = function (e) {
4626
+ }(), exports.StytchSDKAPIError = x, exports.StytchSDKError = E, exports.StytchSDKSchemaError = S, exports.StytchSDKUsageError = w, exports.UNRECOVERABLE_ERROR_TYPES = P, exports.UserCancellationError = M, exports.UserLockedOutError = U, exports.errorToStytchError = function (e) {
4612
4627
  switch (e.message) {
4613
4628
  case "internal_error":
4614
4629
  return new R(e.message);
@@ -4629,11 +4644,11 @@ exports.BiometricsFailedError = X, exports.BiometricsUnavailableError = F, expor
4629
4644
  case "keystore_unavailable":
4630
4645
  return new L();
4631
4646
  case "device_credentials_not_allowed":
4632
- return new U();
4647
+ return new N();
4633
4648
  case "user_cancellation":
4634
4649
  return new M();
4635
4650
  case "user_locked_out":
4636
- return new N();
4651
+ return new U();
4637
4652
  case "google_onetap_missing_id_token":
4638
4653
  case "oauth_apple_missing_id_token":
4639
4654
  case "missing_authorization_credential_id_token":