@stytch/vanilla-js 2.2.2 → 3.0.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.
@@ -591,8 +591,8 @@ var A,
591
591
  E,
592
592
  P,
593
593
  x,
594
- D,
595
- R = function (e) {
594
+ R,
595
+ D = function (e) {
596
596
  u(r, h(Error));
597
597
  var t = l(r);
598
598
  function r(e, n) {
@@ -649,7 +649,7 @@ var A,
649
649
  e.Google = "google", e.Microsoft = "microsoft";
650
650
  }(x || (x = {})), function (e) {
651
651
  e.RequiredCatcha = "Catcha Required";
652
- }(D || (D = {}));
652
+ }(R || (R = {}));
653
653
  var j,
654
654
  M = function (e) {
655
655
  u(r, h(Error));
@@ -690,7 +690,7 @@ function N(e) {
690
690
  e.next = 13;
691
691
  break;
692
692
  }
693
- throw new R(r, "Unable to contact the Stytch servers. Are you online?");
693
+ throw new D(r, "Unable to contact the Stytch servers. Are you online?");
694
694
  case 13:
695
695
  throw e.t0;
696
696
  case 14:
@@ -703,15 +703,15 @@ function N(e) {
703
703
  h = e.sent, e.next = 24;
704
704
  break;
705
705
  case 21:
706
- throw e.prev = 21, e.t1 = e["catch"](15), new R(r, "Invalid response from the Stytch servers.");
706
+ throw e.prev = 21, e.t1 = e["catch"](15), new D(r, "Invalid response from the Stytch servers.");
707
707
  case 24:
708
708
  if (!h.includes("Captcha required")) {
709
709
  e.next = 26;
710
710
  break;
711
711
  }
712
- throw new M(D.RequiredCatcha);
712
+ throw new M(R.RequiredCatcha);
713
713
  case 26:
714
- throw new R(r, "Invalid response from the Stytch servers.");
714
+ throw new D(r, "Invalid response from the Stytch servers.");
715
715
  case 27:
716
716
  if (200 === d.status) {
717
717
  e.next = 40;
@@ -722,7 +722,7 @@ function N(e) {
722
722
  p = e.sent, e.next = 37;
723
723
  break;
724
724
  case 34:
725
- throw e.prev = 34, e.t2 = e["catch"](28), new R(r, "Invalid or no response from server");
725
+ throw e.prev = 34, e.t2 = e["catch"](28), new D(r, "Invalid or no response from server");
726
726
  case 37:
727
727
  if (!("body" in p || "params" in p || "query" in p)) {
728
728
  e.next = 39;
@@ -736,7 +736,7 @@ function N(e) {
736
736
  case 43:
737
737
  return f = e.sent, e.abrupt("return", f.data);
738
738
  case 47:
739
- throw e.prev = 47, e.t3 = e["catch"](40), new R(r, "Invalid response from the Stytch servers.");
739
+ throw e.prev = 47, e.t3 = e["catch"](40), new D(r, "Invalid response from the Stytch servers.");
740
740
  case 50:
741
741
  case "end":
742
742
  return e.stop();
@@ -982,7 +982,7 @@ var X,
982
982
  case 0:
983
983
  return r.next = 2, this.state;
984
984
  case 2:
985
- if (n = r.sent, i = n.enabled, o = n.executeRecaptcha, e.type !== D.RequiredCatcha || !i) {
985
+ if (n = r.sent, i = n.enabled, o = n.executeRecaptcha, e.type !== R.RequiredCatcha || !i) {
986
986
  r.next = 14;
987
987
  break;
988
988
  }
@@ -1125,7 +1125,7 @@ var X,
1125
1125
  value: function value(t) {
1126
1126
  if ("name" in t) switch (t.name) {
1127
1127
  case "SDKAPIUnreachableError":
1128
- return e.inflate(R, t);
1128
+ return e.inflate(D, t);
1129
1129
  case "StytchSDKSchemaError":
1130
1130
  return e.inflate(B, t);
1131
1131
  case "StytchSDKAPIError":
@@ -2319,7 +2319,7 @@ var Te = {
2319
2319
  }),
2320
2320
  signal: Ce(ge)
2321
2321
  },
2322
- De = {
2322
+ Re = {
2323
2323
  type: Se(ge),
2324
2324
  id: Se(ge),
2325
2325
  rawId: Se(be),
@@ -2334,7 +2334,7 @@ var Te = {
2334
2334
  return e.getClientExtensionResults();
2335
2335
  })
2336
2336
  };
2337
- function Re(e) {
2337
+ function De(e) {
2338
2338
  return ke(ve, Ee, e);
2339
2339
  }
2340
2340
  function Ie(e) {
@@ -2346,7 +2346,7 @@ function Be(e) {
2346
2346
  return s().wrap(function (t) {
2347
2347
  for (;;) switch (t.prev = t.next) {
2348
2348
  case 0:
2349
- return t.next = 2, navigator.credentials.create(Re(e));
2349
+ return t.next = 2, navigator.credentials.create(De(e));
2350
2350
  case 2:
2351
2351
  return r = t.sent, t.abrupt("return", Ie(r));
2352
2352
  case 4:
@@ -2360,7 +2360,7 @@ function Le(e) {
2360
2360
  return ke(ve, xe, e);
2361
2361
  }
2362
2362
  function Fe(e) {
2363
- return ke(ye, De, e);
2363
+ return ke(ye, Re, e);
2364
2364
  }
2365
2365
  function je(e) {
2366
2366
  return O(this, void 0, void 0, s().mark(function t() {
@@ -3423,7 +3423,7 @@ var St = /*#__PURE__*/function () {
3423
3423
  },
3424
3424
  sdk: {
3425
3425
  identifier: "Stytch.js Javascript SDK",
3426
- version: "2.2.2"
3426
+ version: "3.0.1"
3427
3427
  }
3428
3428
  });
3429
3429
  }
@@ -3882,7 +3882,7 @@ function xt(e) {
3882
3882
  }
3883
3883
  return e;
3884
3884
  }
3885
- var Dt = function e(t, r) {
3885
+ var Rt = function e(t, r) {
3886
3886
  function n(e, n, i) {
3887
3887
  if ("undefined" != typeof document) {
3888
3888
  "number" == typeof (i = xt({}, r, i)).expires && (i.expires = new Date(Date.now() + 864e5 * i.expires)), i.expires && (i.expires = i.expires.toUTCString()), e = encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
@@ -3935,7 +3935,7 @@ var Dt = function e(t, r) {
3935
3935
  }, {
3936
3936
  path: "/"
3937
3937
  });
3938
- var Rt = function Rt(e) {
3938
+ var Dt = function Dt(e) {
3939
3939
  var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
3940
3940
  return "stytch_sdk_state_".concat(e).concat(t ? "::".concat(t) : "");
3941
3941
  };
@@ -3945,16 +3945,16 @@ var It = /*#__PURE__*/function () {
3945
3945
  _classCallCheck(this, It);
3946
3946
  this.browserSessionStorage = {
3947
3947
  getItem: function getItem(e) {
3948
- return sessionStorage.getItem(Rt(_this7.publicToken, e));
3948
+ return sessionStorage.getItem(Dt(_this7.publicToken, e));
3949
3949
  },
3950
3950
  setItem: function setItem(e, t) {
3951
- return sessionStorage.setItem(Rt(_this7.publicToken, e), t);
3951
+ return sessionStorage.setItem(Dt(_this7.publicToken, e), t);
3952
3952
  },
3953
3953
  removeItem: function removeItem(e) {
3954
- return sessionStorage.removeItem(Rt(_this7.publicToken, e));
3954
+ return sessionStorage.removeItem(Dt(_this7.publicToken, e));
3955
3955
  }
3956
3956
  }, 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);
3957
- var r = localStorage.getItem(Rt(this.publicToken));
3957
+ var r = localStorage.getItem(Dt(this.publicToken));
3958
3958
  if (!r) return;
3959
3959
  var n;
3960
3960
  try {
@@ -3986,14 +3986,14 @@ var It = /*#__PURE__*/function () {
3986
3986
  key: "readSessionCookie",
3987
3987
  value: function readSessionCookie() {
3988
3988
  return {
3989
- session_token: Dt.get(this.opaqueTokenCookieName),
3990
- session_jwt: Dt.get(this.jwtCookieName)
3989
+ session_token: Rt.get(this.opaqueTokenCookieName),
3990
+ session_jwt: Rt.get(this.jwtCookieName)
3991
3991
  };
3992
3992
  }
3993
3993
  }, {
3994
3994
  key: "readIntermediateSessionTokenCookie",
3995
3995
  value: function readIntermediateSessionTokenCookie() {
3996
- return Dt.get(this.istCookieName);
3996
+ return Rt.get(this.istCookieName);
3997
3997
  }
3998
3998
  }, {
3999
3999
  key: "writeSessionCookie",
@@ -4008,14 +4008,14 @@ var It = /*#__PURE__*/function () {
4008
4008
  path: this._cookiePath,
4009
4009
  domain: this._domain
4010
4010
  });
4011
- Dt.set(this.opaqueTokenCookieName, o, c), Dt.set(this.jwtCookieName, a, c);
4011
+ Rt.set(this.opaqueTokenCookieName, o, c), Rt.set(this.jwtCookieName, a, c);
4012
4012
  var u = It.generateCookieOpts({
4013
4013
  expiresAt: null !== (i = null === (n = null == s ? void 0 : s.session) || void 0 === n ? void 0 : n.expires_at) && void 0 !== i ? i : "",
4014
4014
  availableToSubdomains: !this._cookieAvailableToSubdomains,
4015
4015
  path: this._cookiePath,
4016
4016
  domain: this._domain
4017
4017
  });
4018
- Pt(this.jwtCookieName) && Dt.remove(this.jwtCookieName, u), Pt(this.opaqueTokenCookieName) && Dt.remove(this.opaqueTokenCookieName, u), Pt(this.jwtCookieName) && Q("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), Pt(this.opaqueTokenCookieName) && Q("Could not remove extraneous opaque token cookie.");
4018
+ Pt(this.jwtCookieName) && Rt.remove(this.jwtCookieName, u), Pt(this.opaqueTokenCookieName) && Rt.remove(this.opaqueTokenCookieName, u), Pt(this.jwtCookieName) && Q("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), Pt(this.opaqueTokenCookieName) && Q("Could not remove extraneous opaque token cookie.");
4019
4019
  }
4020
4020
  }, {
4021
4021
  key: "writeIntermediateSessionTokenCookie",
@@ -4027,7 +4027,7 @@ var It = /*#__PURE__*/function () {
4027
4027
  path: this._cookiePath,
4028
4028
  domain: this._domain
4029
4029
  });
4030
- Dt.set(this.istCookieName, e, r);
4030
+ Rt.set(this.istCookieName, e, r);
4031
4031
  }
4032
4032
  }, {
4033
4033
  key: "removeSessionCookie",
@@ -4053,7 +4053,7 @@ var It = /*#__PURE__*/function () {
4053
4053
  domain: n
4054
4054
  });
4055
4055
  e.forEach(function (e) {
4056
- Dt.remove(e, i);
4056
+ Rt.remove(e, i);
4057
4057
  });
4058
4058
  });
4059
4059
  });
@@ -4062,22 +4062,22 @@ var It = /*#__PURE__*/function () {
4062
4062
  }, {
4063
4063
  key: "syncToLocalStorage",
4064
4064
  value: function syncToLocalStorage() {
4065
- localStorage.setItem(Rt(this.publicToken), JSON.stringify(this.state));
4065
+ localStorage.setItem(Dt(this.publicToken), JSON.stringify(this.state));
4066
4066
  }
4067
4067
  }, {
4068
4068
  key: "getItem",
4069
4069
  value: function getItem(e) {
4070
- return localStorage.getItem(Rt(this.publicToken, e));
4070
+ return localStorage.getItem(Dt(this.publicToken, e));
4071
4071
  }
4072
4072
  }, {
4073
4073
  key: "setItem",
4074
4074
  value: function setItem(e, t) {
4075
- return localStorage.setItem(Rt(this.publicToken, e), t);
4075
+ return localStorage.setItem(Dt(this.publicToken, e), t);
4076
4076
  }
4077
4077
  }, {
4078
4078
  key: "removeItem",
4079
4079
  value: function removeItem(e) {
4080
- return localStorage.removeItem(Rt(this.publicToken, e));
4080
+ return localStorage.removeItem(Dt(this.publicToken, e));
4081
4081
  }
4082
4082
  }], [{
4083
4083
  key: "generateCookieOpts",
@@ -4140,18 +4140,15 @@ var Nt = /*#__PURE__*/function () {
4140
4140
  function Nt(e, t) {
4141
4141
  var _this9 = this;
4142
4142
  _classCallCheck(this, Nt);
4143
- var r;
4144
4143
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4145
- if (e.key !== Rt(_this9._publicToken)) return;
4144
+ if (e.key !== Dt(_this9._publicToken)) return;
4146
4145
  if (null === e.newValue || "null" === e.newValue) return void _this9.destroyState();
4147
4146
  var t = JSON.parse(e.newValue);
4148
4147
  _this9.updateState(t);
4149
4148
  }, window.addEventListener("storage", this._listen);
4150
- var n = null === (r = this._datalayer.state) || void 0 === r ? void 0 : r.session;
4151
- if (n && Date.parse(n.expires_at) < Date.now()) return void this.destroyState();
4152
4149
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4153
- i = _this$_datalayer$read.session_token;
4154
- i || this.destroyState();
4150
+ r = _this$_datalayer$read.session_token;
4151
+ r || this.destroyState();
4155
4152
  }
4156
4153
  _createClass(Nt, [{
4157
4154
  key: "getTokens",
@@ -596,8 +596,8 @@ var A,
596
596
  E,
597
597
  P,
598
598
  x,
599
- D,
600
- R = function (e) {
599
+ R,
600
+ D = function (e) {
601
601
  u(r, h(Error));
602
602
  var t = l(r);
603
603
  function r(e, n) {
@@ -654,7 +654,7 @@ var A,
654
654
  e.Google = "google", e.Microsoft = "microsoft";
655
655
  }(x || (x = {})), function (e) {
656
656
  e.RequiredCatcha = "Catcha Required";
657
- }(D || (D = {}));
657
+ }(R || (R = {}));
658
658
  var j,
659
659
  M = function (e) {
660
660
  u(r, h(Error));
@@ -695,7 +695,7 @@ function N(e) {
695
695
  e.next = 13;
696
696
  break;
697
697
  }
698
- throw new R(r, "Unable to contact the Stytch servers. Are you online?");
698
+ throw new D(r, "Unable to contact the Stytch servers. Are you online?");
699
699
  case 13:
700
700
  throw e.t0;
701
701
  case 14:
@@ -708,15 +708,15 @@ function N(e) {
708
708
  h = e.sent, e.next = 24;
709
709
  break;
710
710
  case 21:
711
- throw e.prev = 21, e.t1 = e["catch"](15), new R(r, "Invalid response from the Stytch servers.");
711
+ throw e.prev = 21, e.t1 = e["catch"](15), new D(r, "Invalid response from the Stytch servers.");
712
712
  case 24:
713
713
  if (!h.includes("Captcha required")) {
714
714
  e.next = 26;
715
715
  break;
716
716
  }
717
- throw new M(D.RequiredCatcha);
717
+ throw new M(R.RequiredCatcha);
718
718
  case 26:
719
- throw new R(r, "Invalid response from the Stytch servers.");
719
+ throw new D(r, "Invalid response from the Stytch servers.");
720
720
  case 27:
721
721
  if (200 === d.status) {
722
722
  e.next = 40;
@@ -727,7 +727,7 @@ function N(e) {
727
727
  p = e.sent, e.next = 37;
728
728
  break;
729
729
  case 34:
730
- throw e.prev = 34, e.t2 = e["catch"](28), new R(r, "Invalid or no response from server");
730
+ throw e.prev = 34, e.t2 = e["catch"](28), new D(r, "Invalid or no response from server");
731
731
  case 37:
732
732
  if (!("body" in p || "params" in p || "query" in p)) {
733
733
  e.next = 39;
@@ -741,7 +741,7 @@ function N(e) {
741
741
  case 43:
742
742
  return f = e.sent, e.abrupt("return", f.data);
743
743
  case 47:
744
- throw e.prev = 47, e.t3 = e["catch"](40), new R(r, "Invalid response from the Stytch servers.");
744
+ throw e.prev = 47, e.t3 = e["catch"](40), new D(r, "Invalid response from the Stytch servers.");
745
745
  case 50:
746
746
  case "end":
747
747
  return e.stop();
@@ -987,7 +987,7 @@ var X,
987
987
  case 0:
988
988
  return r.next = 2, this.state;
989
989
  case 2:
990
- if (n = r.sent, i = n.enabled, s = n.executeRecaptcha, e.type !== D.RequiredCatcha || !i) {
990
+ if (n = r.sent, i = n.enabled, s = n.executeRecaptcha, e.type !== R.RequiredCatcha || !i) {
991
991
  r.next = 14;
992
992
  break;
993
993
  }
@@ -1130,7 +1130,7 @@ var X,
1130
1130
  value: function value(t) {
1131
1131
  if ("name" in t) switch (t.name) {
1132
1132
  case "SDKAPIUnreachableError":
1133
- return e.inflate(R, t);
1133
+ return e.inflate(D, t);
1134
1134
  case "StytchSDKSchemaError":
1135
1135
  return e.inflate(I, t);
1136
1136
  case "StytchSDKAPIError":
@@ -2324,7 +2324,7 @@ var Ce = {
2324
2324
  }),
2325
2325
  signal: Te(ge)
2326
2326
  },
2327
- De = {
2327
+ Re = {
2328
2328
  type: Se(ge),
2329
2329
  id: Se(ge),
2330
2330
  rawId: Se(be),
@@ -2339,7 +2339,7 @@ var Ce = {
2339
2339
  return e.getClientExtensionResults();
2340
2340
  })
2341
2341
  };
2342
- function Re(e) {
2342
+ function De(e) {
2343
2343
  return ke(ve, Ee, e);
2344
2344
  }
2345
2345
  function Be(e) {
@@ -2351,7 +2351,7 @@ function Ie(e) {
2351
2351
  return o().wrap(function (t) {
2352
2352
  for (;;) switch (t.prev = t.next) {
2353
2353
  case 0:
2354
- return t.next = 2, navigator.credentials.create(Re(e));
2354
+ return t.next = 2, navigator.credentials.create(De(e));
2355
2355
  case 2:
2356
2356
  return r = t.sent, t.abrupt("return", Be(r));
2357
2357
  case 4:
@@ -2365,7 +2365,7 @@ function Le(e) {
2365
2365
  return ke(ve, xe, e);
2366
2366
  }
2367
2367
  function Fe(e) {
2368
- return ke(ye, De, e);
2368
+ return ke(ye, Re, e);
2369
2369
  }
2370
2370
  function je(e) {
2371
2371
  return O(this, void 0, void 0, o().mark(function t() {
@@ -3422,7 +3422,7 @@ var ht = /*#__PURE__*/function () {
3422
3422
  },
3423
3423
  sdk: {
3424
3424
  identifier: "Stytch.js Javascript SDK",
3425
- version: "2.2.2"
3425
+ version: "3.0.1"
3426
3426
  }
3427
3427
  });
3428
3428
  }
@@ -4139,18 +4139,15 @@ var Et = /*#__PURE__*/function () {
4139
4139
  function Et(e, t) {
4140
4140
  var _this9 = this;
4141
4141
  _classCallCheck(this, Et);
4142
- var r;
4143
4142
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4144
4143
  if (e.key !== kt(_this9._publicToken)) return;
4145
4144
  if (null === e.newValue || "null" === e.newValue) return void _this9.destroyState();
4146
4145
  var t = JSON.parse(e.newValue);
4147
4146
  _this9.updateState(t);
4148
4147
  }, window.addEventListener("storage", this._listen);
4149
- var n = null === (r = this._datalayer.state) || void 0 === r ? void 0 : r.session;
4150
- if (n && Date.parse(n.expires_at) < Date.now()) return void this.destroyState();
4151
4148
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4152
- i = _this$_datalayer$read.session_token;
4153
- i || this.destroyState();
4149
+ r = _this$_datalayer$read.session_token;
4150
+ r || this.destroyState();
4154
4151
  }
4155
4152
  _createClass(Et, [{
4156
4153
  key: "getTokens",