@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.js CHANGED
@@ -3746,7 +3746,7 @@ var It = /*#__PURE__*/function () {
3746
3746
  },
3747
3747
  sdk: {
3748
3748
  identifier: "Stytch.js Javascript SDK",
3749
- version: "4.1.0"
3749
+ version: "4.1.1"
3750
3750
  }
3751
3751
  });
3752
3752
  }
@@ -4309,7 +4309,7 @@ var Vt = /*#__PURE__*/function () {
4309
4309
  removeItem: function removeItem(e) {
4310
4310
  return sessionStorage.removeItem(Zt(_this7.publicToken, e));
4311
4311
  }
4312
- }, this.publicToken = e, this.state = null, this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (Re("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);
4312
+ }, this.publicToken = e, this.state = null, this.stateKeysUpdated = new Set(), this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (Re("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);
4313
4313
  var n = localStorage.getItem(Zt(this.publicToken));
4314
4314
  if (!n) return;
4315
4315
  var r;
@@ -4435,6 +4435,15 @@ var Vt = /*#__PURE__*/function () {
4435
4435
  value: function removeItem(e) {
4436
4436
  return localStorage.removeItem(Zt(this.publicToken, e));
4437
4437
  }
4438
+ }, {
4439
+ key: "markStateKeysUpdated",
4440
+ value: function markStateKeysUpdated(e) {
4441
+ var _this9 = this;
4442
+ var t = this.stateKeysUpdated.size;
4443
+ return e.forEach(function (e) {
4444
+ return _this9.stateKeysUpdated.add(e);
4445
+ }), t !== this.stateKeysUpdated.size;
4446
+ }
4438
4447
  }], [{
4439
4448
  key: "generateCookieOpts",
4440
4449
  value: function generateCookieOpts(_ref7) {
@@ -4494,13 +4503,13 @@ var Kt = Symbol["for"]("__stytch_DataLayer"),
4494
4503
  });
4495
4504
  var Xt = /*#__PURE__*/function () {
4496
4505
  function Xt(e, t) {
4497
- var _this9 = this;
4506
+ var _this10 = this;
4498
4507
  _classCallCheck(this, Xt);
4499
4508
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4500
- if (e.key !== Zt(_this9._publicToken)) return;
4501
- if (null === e.newValue || "null" === e.newValue) return void _this9.destroyState();
4509
+ if (e.key !== Zt(_this10._publicToken)) return;
4510
+ if (null === e.newValue || "null" === e.newValue) return void _this10.destroyState();
4502
4511
  var t = JSON.parse(e.newValue);
4503
- _this9.updateState(t);
4512
+ _this10.updateState(t);
4504
4513
  }, window.addEventListener("storage", this._listen);
4505
4514
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4506
4515
  n = _this$_datalayer$read.session_token;
@@ -4537,7 +4546,9 @@ var Xt = /*#__PURE__*/function () {
4537
4546
  value: function _updateStateAndTokensInternal(e) {
4538
4547
  var t = this._datalayer.state,
4539
4548
  n = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4540
- this._datalayer.state = n, Jt(t, n) || Yt(this._datalayer.subscriptions, n);
4549
+ this._datalayer.state = n;
4550
+ var r = e.state ? Object.keys(e.state) : [];
4551
+ !this._datalayer.markStateKeysUpdated(r) && Jt(t, n) || Yt(this._datalayer.subscriptions, n);
4541
4552
  }
4542
4553
  }, {
4543
4554
  key: "updateStateAndTokens",
@@ -4549,7 +4560,11 @@ var Xt = /*#__PURE__*/function () {
4549
4560
  value: function updateState(e) {
4550
4561
  var t = this._datalayer.state,
4551
4562
  n = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e);
4552
- this._datalayer.state = n, Jt(t, n) || (Yt(this._datalayer.subscriptions, n), this._datalayer.syncToLocalStorage());
4563
+ this._datalayer.state = n;
4564
+ var r = e ? Object.keys(e) : [],
4565
+ o = this._datalayer.markStateKeysUpdated(r),
4566
+ i = !Jt(t, n);
4567
+ (o || i) && (Yt(this._datalayer.subscriptions, n), i && this._datalayer.syncToLocalStorage());
4553
4568
  }
4554
4569
  }, {
4555
4570
  key: "updateTokens",
@@ -4595,20 +4610,20 @@ var $t = /*#__PURE__*/function (_Xt) {
4595
4610
  _inherits($t, _Xt);
4596
4611
  var _super3 = _createSuper($t);
4597
4612
  function $t() {
4598
- var _this10;
4613
+ var _this11;
4599
4614
  _classCallCheck(this, $t);
4600
- _this10 = _super3.apply(this, arguments), _this10.updateUser = function (e) {
4601
- return _this10.updateState({
4615
+ _this11 = _super3.apply(this, arguments), _this11.updateUser = function (e) {
4616
+ return _this11.updateState({
4602
4617
  user: e
4603
4618
  });
4604
- }, _this10.getUser = function () {
4619
+ }, _this11.getUser = function () {
4605
4620
  var e, t;
4606
- return null !== (t = null === (e = _this10.getState()) || void 0 === e ? void 0 : e.user) && void 0 !== t ? t : null;
4607
- }, _this10.getSession = function () {
4621
+ return null !== (t = null === (e = _this11.getState()) || void 0 === e ? void 0 : e.user) && void 0 !== t ? t : null;
4622
+ }, _this11.getSession = function () {
4608
4623
  var e, t;
4609
- return null !== (t = null === (e = _this10.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4624
+ return null !== (t = null === (e = _this11.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4610
4625
  };
4611
- return _this10;
4626
+ return _this11;
4612
4627
  }
4613
4628
  return _createClass($t);
4614
4629
  }(Xt);
@@ -4619,7 +4634,7 @@ var en = Symbol["for"]("stytch__internal_b2c"),
4619
4634
  return t[en];
4620
4635
  };
4621
4636
  var nn = /*#__PURE__*/_createClass(function nn(e, t) {
4622
- var _this11 = this;
4637
+ var _this12 = this;
4623
4638
  _classCallCheck(this, nn);
4624
4639
  var n;
4625
4640
  Ne("StytchHeadlessClient"), "string" != typeof (n = e) ? Be("Public token is malformed. Expected a string, got ".concat(te(n), ".").concat(De)) : "" === n ? Be('Public token is malformed. Expected "public-token-...", got an empty string.'.concat(De)) : n.startsWith("public-token-") || Be('Public token is malformed. Expected "public-token-...", got '.concat(n, ".").concat(De));
@@ -4642,8 +4657,8 @@ var nn = /*#__PURE__*/_createClass(function nn(e, t) {
4642
4657
  this._networkClient = new It(e, this._dataLayer, o.endpoints.sdkBackendURL, function () {
4643
4658
  var e, t, n, r;
4644
4659
  return {
4645
- 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,
4646
- 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
4660
+ 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,
4661
+ 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
4647
4662
  };
4648
4663
  });
4649
4664
  var a = new St(e, this._networkClient, this._dataLayer),
@@ -7006,12 +7021,12 @@ function us(e, t) {
7006
7021
  _inherits(r, _HTMLElement);
7007
7022
  var _super4 = _createSuper(r);
7008
7023
  function r(e) {
7009
- var _this12;
7024
+ var _this13;
7010
7025
  _classCallCheck(this, r);
7011
- _this12 = _super4.call(this), _this12.props = e, _this12.rootRef = _this12.attachShadow({
7026
+ _this13 = _super4.call(this), _this13.props = e, _this13.rootRef = _this13.attachShadow({
7012
7027
  mode: "open"
7013
7028
  });
7014
- return _this12;
7029
+ return _this13;
7015
7030
  }
7016
7031
  _createClass(r, [{
7017
7032
  key: "connectedCallback",
@@ -7057,10 +7072,10 @@ function us(e, t) {
7057
7072
  _inherits(r, _HTMLElement2);
7058
7073
  var _super5 = _createSuper(r);
7059
7074
  function r(e) {
7060
- var _this13;
7075
+ var _this14;
7061
7076
  _classCallCheck(this, r);
7062
- _this13 = _super5.call(this), _this13.props = e, _this13.rootRef = document.createElement("div"), _this13.append(_this13.rootRef);
7063
- return _this13;
7077
+ _this14 = _super5.call(this), _this14.props = e, _this14.rootRef = document.createElement("div"), _this14.append(_this14.rootRef);
7078
+ return _this14;
7064
7079
  }
7065
7080
  _createClass(r, [{
7066
7081
  key: "connectedCallback",
@@ -14742,13 +14757,13 @@ exports.BiometricsFailedError = Q, exports.BiometricsUnavailableError = k, expor
14742
14757
  _inherits(_class, _nn);
14743
14758
  var _super6 = _createSuper(_class);
14744
14759
  function _class() {
14745
- var _this14;
14760
+ var _this15;
14746
14761
  _classCallCheck(this, _class);
14747
14762
  for (var _len7 = arguments.length, e = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
14748
14763
  e[_key7] = arguments[_key7];
14749
14764
  }
14750
- Ne("StytchUIClient"), _this14 = _super6.call.apply(_super6, [this].concat(e));
14751
- return _this14;
14765
+ Ne("StytchUIClient"), _this15 = _super6.call.apply(_super6, [this].concat(e));
14766
+ return _this15;
14752
14767
  }
14753
14768
  _createClass(_class, [{
14754
14769
  key: "mountLogin",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stytch/vanilla-js",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "Stytch's official Javascript Client Library",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",