@stytch/vanilla-js 4.8.0 → 4.9.0

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.
@@ -156,7 +156,7 @@ var g,
156
156
  }
157
157
  return a(t, c(Error)), r(t);
158
158
  }(),
159
- P = function (e) {
159
+ C = function (e) {
160
160
  function t(e) {
161
161
  var r, n;
162
162
  i(this, t), (r = s(this, t)).name = "StytchSDKSchemaError";
@@ -167,7 +167,7 @@ var g,
167
167
  }
168
168
  return a(t, c(Error)), r(t);
169
169
  }(),
170
- O = function (e) {
170
+ P = function (e) {
171
171
  function t(e) {
172
172
  var r;
173
173
  i(this, t), (r = s(this, t)).name = "StytchSDKAPIError";
@@ -180,7 +180,7 @@ var g,
180
180
  }
181
181
  return a(t, c(Error)), r(t);
182
182
  }(),
183
- C = ["unauthorized_credentials", "user_unauthenticated", "invalid_secret_authentication", "session_not_found"],
183
+ O = ["unauthorized_credentials", "user_unauthenticated", "invalid_secret_authentication", "session_not_found"],
184
184
  T = function (e) {
185
185
  function t(e, r) {
186
186
  var n;
@@ -413,6 +413,39 @@ var g,
413
413
  return a(t, R), r(t);
414
414
  }();
415
415
  function le(e, t) {
416
+ return function (e) {
417
+ if (Array.isArray(e)) return e;
418
+ }(e) || function (e, t) {
419
+ var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
420
+ if (null != r) {
421
+ var n,
422
+ i,
423
+ s,
424
+ o,
425
+ a = [],
426
+ c = !0,
427
+ u = !1;
428
+ try {
429
+ if (s = (r = r.call(e)).next, 0 === t) {
430
+ if (Object(r) !== r) return;
431
+ c = !1;
432
+ } else for (; !(c = (n = s.call(r)).done) && (a.push(n.value), a.length !== t); c = !0);
433
+ } catch (e) {
434
+ u = !0, i = e;
435
+ } finally {
436
+ try {
437
+ if (!c && null != r["return"] && (o = r["return"](), Object(o) !== o)) return;
438
+ } finally {
439
+ if (u) throw i;
440
+ }
441
+ }
442
+ return a;
443
+ }
444
+ }(e, t) || he(e, t) || function () {
445
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
446
+ }();
447
+ }
448
+ function de(e, t) {
416
449
  var r = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
417
450
  if (!r) {
418
451
  if (Array.isArray(e) || (r = he(e)) || t && e && "number" == typeof e.length) {
@@ -460,39 +493,6 @@ function le(e, t) {
460
493
  }
461
494
  };
462
495
  }
463
- function de(e, t) {
464
- return function (e) {
465
- if (Array.isArray(e)) return e;
466
- }(e) || function (e, t) {
467
- var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
468
- if (null != r) {
469
- var n,
470
- i,
471
- s,
472
- o,
473
- a = [],
474
- c = !0,
475
- u = !1;
476
- try {
477
- if (s = (r = r.call(e)).next, 0 === t) {
478
- if (Object(r) !== r) return;
479
- c = !1;
480
- } else for (; !(c = (n = s.call(r)).done) && (a.push(n.value), a.length !== t); c = !0);
481
- } catch (e) {
482
- u = !0, i = e;
483
- } finally {
484
- try {
485
- if (!c && null != r["return"] && (o = r["return"](), Object(o) !== o)) return;
486
- } finally {
487
- if (u) throw i;
488
- }
489
- }
490
- return a;
491
- }
492
- }(e, t) || he(e, t) || function () {
493
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
494
- }();
495
- }
496
496
  function he(e, t) {
497
497
  if (e) {
498
498
  if ("string" == typeof e) return pe(e, t);
@@ -548,7 +548,7 @@ function _e() {
548
548
  o = Object.create(s.prototype),
549
549
  a = new E(n || []);
550
550
  return i(o, "_invoke", {
551
- value: O(e, r, a)
551
+ value: P(e, r, a)
552
552
  }), o;
553
553
  }
554
554
  function d(e, t, r) {
@@ -588,7 +588,7 @@ function _e() {
588
588
  });
589
589
  });
590
590
  }
591
- function P(e, t) {
591
+ function C(e, t) {
592
592
  function r(i, s, o, a) {
593
593
  var c = d(e[i], e, s);
594
594
  if ("throw" !== c.type) {
@@ -618,7 +618,7 @@ function _e() {
618
618
  }
619
619
  });
620
620
  }
621
- function O(t, r, n) {
621
+ function P(t, r, n) {
622
622
  var i = h;
623
623
  return function (s, o) {
624
624
  if (i === f) throw new Error("Generator is already running");
@@ -632,7 +632,7 @@ function _e() {
632
632
  for (n.method = s, n.arg = o;;) {
633
633
  var a = n.delegate;
634
634
  if (a) {
635
- var c = C(a, n);
635
+ var c = O(a, n);
636
636
  if (c) {
637
637
  if (c === m) continue;
638
638
  return c;
@@ -655,10 +655,10 @@ function _e() {
655
655
  }
656
656
  };
657
657
  }
658
- function C(t, r) {
658
+ function O(t, r) {
659
659
  var n = r.method,
660
660
  i = t.iterator[n];
661
- 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;
661
+ if (i === e) return r.delegate = null, "throw" === n && t.iterator["return"] && (r.method = "return", r.arg = e, O(t, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), m;
662
662
  var s = d(i, t.iterator, r.arg);
663
663
  if ("throw" === s.type) return r.method = "throw", r.arg = s.arg, r.delegate = null, m;
664
664
  var o = s.arg;
@@ -710,11 +710,11 @@ function _e() {
710
710
  return {
711
711
  __await: e
712
712
  };
713
- }, x(P.prototype), u(P.prototype, a, function () {
713
+ }, x(C.prototype), u(C.prototype, a, function () {
714
714
  return this;
715
- }), t.AsyncIterator = P, t.async = function (e, r, n, i, s) {
715
+ }), t.AsyncIterator = C, t.async = function (e, r, n, i, s) {
716
716
  void 0 === s && (s = Promise);
717
- var o = new P(l(e, r, n, i), s);
717
+ var o = new C(l(e, r, n, i), s);
718
718
  return t.isGeneratorFunction(r) ? o : o.next().then(function (e) {
719
719
  return e.done ? e.value : o.next();
720
720
  });
@@ -904,9 +904,9 @@ function xe(e) {
904
904
  }, xe(e);
905
905
  }
906
906
  exports.B2BProducts = void 0, (g = exports.B2BProducts || (exports.B2BProducts = {})).emailMagicLinks = "emailMagicLinks", g.sso = "sso", g.passwords = "passwords", g.oauth = "oauth", exports.AuthFlowType = void 0, (b = exports.AuthFlowType || (exports.AuthFlowType = {})).Discovery = "Discovery", b.Organization = "Organization", b.PasswordReset = "PasswordReset", exports.B2BMFAProducts = void 0, (k = exports.B2BMFAProducts || (exports.B2BMFAProducts = {})).smsOtp = "smsOtp", k.totp = "totp", exports.B2BOAuthProviders = void 0, (w = exports.B2BOAuthProviders || (exports.B2BOAuthProviders = {})).Google = "google", w.Microsoft = "microsoft";
907
- var Pe,
908
- Oe = "https://accounts.google.com/gsi",
909
- Ce = "".concat(Oe, "/client");
907
+ var Ce,
908
+ Pe = "https://accounts.google.com/gsi",
909
+ Oe = "".concat(Pe, "/client");
910
910
  function Te(e, t) {
911
911
  var r = {};
912
912
  for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
@@ -943,7 +943,7 @@ function Ae(e, t, r, n) {
943
943
  }
944
944
  "function" == typeof SuppressedError && SuppressedError, function (e) {
945
945
  e.RequiredCatcha = "Catcha Required";
946
- }(Pe || (Pe = {}));
946
+ }(Ce || (Ce = {}));
947
947
  var Ee,
948
948
  De = function (e) {
949
949
  function t(e) {
@@ -1037,7 +1037,7 @@ function Re(e) {
1037
1037
  e.next = 49;
1038
1038
  break;
1039
1039
  }
1040
- throw new De(Pe.RequiredCatcha);
1040
+ throw new De(Ce.RequiredCatcha);
1041
1041
  case 49:
1042
1042
  throw new A("Invalid response from the Stytch servers.");
1043
1043
  case 50:
@@ -1152,7 +1152,7 @@ var Ge,
1152
1152
  isStringArray: function isStringArray(r, n) {
1153
1153
  if (!Array.isArray(n)) throw new x(e, r + " must be an array of strings.");
1154
1154
  var i,
1155
- s = le(n);
1155
+ s = de(n);
1156
1156
  try {
1157
1157
  for (s.s(); !(i = s.n()).done;) {
1158
1158
  if ("string" != typeof i.value) throw new x(e, r + " must be an array of strings.");
@@ -1285,7 +1285,7 @@ var Ge,
1285
1285
  case 0:
1286
1286
  return r.next = 2, this.state;
1287
1287
  case 2:
1288
- if (n = r.sent, i = n.enabled, s = n.executeRecaptcha, e.type !== Pe.RequiredCatcha || !i) {
1288
+ if (n = r.sent, i = n.enabled, s = n.executeRecaptcha, e.type !== Ce.RequiredCatcha || !i) {
1289
1289
  r.next = 14;
1290
1290
  break;
1291
1291
  }
@@ -1430,13 +1430,13 @@ var Ge,
1430
1430
  case "SDKAPIUnreachableError":
1431
1431
  return e.inflate(S, t);
1432
1432
  case "StytchSDKSchemaError":
1433
- return e.inflate(P, t);
1433
+ return e.inflate(C, t);
1434
1434
  case "StytchAPIUnreachableError":
1435
1435
  return e.inflate(A, t);
1436
1436
  case "StytchAPISchemaError":
1437
1437
  return e.inflate(E, t);
1438
1438
  case "StytchSDKAPIError":
1439
- return e.inflate(O, t);
1439
+ return e.inflate(P, t);
1440
1440
  case "StytchAPIError":
1441
1441
  return e.inflate(D, t);
1442
1442
  case "TypeError":
@@ -1529,6 +1529,11 @@ var rt = ve(function e(t, r) {
1529
1529
  }));
1530
1530
  }, this.getSync = function () {
1531
1531
  return n._subscriptionService.getUser();
1532
+ }, this.getInfo = function () {
1533
+ return {
1534
+ user: n.getSync(),
1535
+ fromCache: n._subscriptionService.getFromCache()
1536
+ };
1532
1537
  }, this.update = function (e) {
1533
1538
  return Ae(n, void 0, void 0, _e().mark(function t() {
1534
1539
  var r, n;
@@ -1676,6 +1681,11 @@ var rt = ve(function e(t, r) {
1676
1681
  var n = this;
1677
1682
  ge(this, e), this._networkClient = t, this._subscriptionService = r, this.getSync = function () {
1678
1683
  return n._subscriptionService.getSession();
1684
+ }, this.getInfo = function () {
1685
+ return {
1686
+ session: n.getSync(),
1687
+ fromCache: n._subscriptionService.getFromCache()
1688
+ };
1679
1689
  }, this.onChange = function (e) {
1680
1690
  var t = n._subscriptionService.getSession();
1681
1691
  return n._subscriptionService.subscribeToState(function (r) {
@@ -1696,7 +1706,7 @@ var rt = ve(function e(t, r) {
1696
1706
  case 3:
1697
1707
  return r = t.sent, this._subscriptionService.destroyState(), t.abrupt("return", r);
1698
1708
  case 8:
1699
- throw t.prev = 8, t.t0 = t["catch"](0), ((null == e ? void 0 : e.forceClear) || C.includes(t.t0.error_type)) && this._subscriptionService.destroyState(), t.t0;
1709
+ throw t.prev = 8, t.t0 = t["catch"](0), ((null == e ? void 0 : e.forceClear) || O.includes(t.t0.error_type)) && this._subscriptionService.destroyState(), t.t0;
1700
1710
  case 12:
1701
1711
  case "end":
1702
1712
  return t.stop();
@@ -1747,7 +1757,7 @@ var rt = ve(function e(t, r) {
1747
1757
  }
1748
1758
  return t.abrupt("return", this.authenticate(e));
1749
1759
  case 17:
1750
- throw C.includes(t.t0.error_type) && this._subscriptionService.destroySession(), t.t0;
1760
+ throw O.includes(t.t0.error_type) && this._subscriptionService.destroySession(), t.t0;
1751
1761
  case 19:
1752
1762
  case "end":
1753
1763
  return t.stop();
@@ -2534,7 +2544,7 @@ function lt(e) {
2534
2544
  function dt(e) {
2535
2545
  var t,
2536
2546
  r = "",
2537
- n = le(new Uint8Array(e));
2547
+ n = de(new Uint8Array(e));
2538
2548
  try {
2539
2549
  for (n.s(); !(t = n.n()).done;) {
2540
2550
  var i = t.value;
@@ -2557,7 +2567,7 @@ function ft(e, t, r) {
2557
2567
  });
2558
2568
  if (t instanceof Object) {
2559
2569
  for (var n = {}, i = 0, s = Object.entries(t); i < s.length; i++) {
2560
- var o = de(s[i], 2),
2570
+ var o = le(s[i], 2),
2561
2571
  a = o[0],
2562
2572
  c = o[1];
2563
2573
  if (c.derive) {
@@ -2665,21 +2675,21 @@ var yt = {
2665
2675
  return e.getClientExtensionResults();
2666
2676
  })
2667
2677
  };
2668
- function Pt(e) {
2678
+ function Ct(e) {
2669
2679
  return ft(lt, kt, e);
2670
2680
  }
2671
- function Ot(e) {
2681
+ function Pt(e) {
2672
2682
  return ft(dt, wt, e);
2673
2683
  }
2674
- function Ct(e) {
2684
+ function Ot(e) {
2675
2685
  return Ae(this, void 0, void 0, _e().mark(function t() {
2676
2686
  var r;
2677
2687
  return _e().wrap(function (t) {
2678
2688
  for (;;) switch (t.prev = t.next) {
2679
2689
  case 0:
2680
- return t.next = 2, navigator.credentials.create(Pt(e));
2690
+ return t.next = 2, navigator.credentials.create(Ct(e));
2681
2691
  case 2:
2682
- return r = t.sent, t.abrupt("return", Ot(r));
2692
+ return r = t.sent, t.abrupt("return", Pt(r));
2683
2693
  case 4:
2684
2694
  case "end":
2685
2695
  return t.stop();
@@ -2736,7 +2746,7 @@ var Dt = function () {
2736
2746
  }
2737
2747
  });
2738
2748
  case 3:
2739
- return i = n.sent, s = i.public_key_credential_creation_options, o = JSON.parse(s), n.next = 8, Ct({
2749
+ return i = n.sent, s = i.public_key_credential_creation_options, o = JSON.parse(s), n.next = 8, Ot({
2740
2750
  publicKey: o
2741
2751
  });
2742
2752
  case 8:
@@ -3306,7 +3316,9 @@ var Ft = function () {
3306
3316
  function e(t, r) {
3307
3317
  var n = this;
3308
3318
  ge(this, e), this._subscriptionService = t, this._headlessSessionClient = r, this._onDataChange = function (e) {
3309
- (null == e ? void 0 : e.session) ? n.scheduleBackgroundRefresh() : n.cancelBackgroundRefresh();
3319
+ !function (e) {
3320
+ return !!(null == e ? void 0 : e.session);
3321
+ }(e) ? n.cancelBackgroundRefresh() : n.scheduleBackgroundRefresh();
3310
3322
  }, this._reauthenticateWithBackoff = function () {
3311
3323
  return Ae(n, void 0, void 0, _e().mark(function t() {
3312
3324
  var r;
@@ -3372,22 +3384,30 @@ var Ft = function () {
3372
3384
  }, {
3373
3385
  key: "isUnrecoverableError",
3374
3386
  value: function value(e) {
3375
- return C.includes(e.error_type);
3387
+ return O.includes(e.error_type);
3376
3388
  }
3377
3389
  }]), e;
3378
3390
  }();
3379
3391
  Bt.REFRESH_INTERVAL_MS = 18e4;
3380
- var Lt = "bootstrap";
3381
- var Mt = /*#__PURE__*/function () {
3382
- function Mt(e, t, r) {
3392
+ var Lt = ve(function e(t, r) {
3393
+ var n = this;
3394
+ ge(this, e), this._subscriptionService = t, this.emptyState = r, this.onStateChange = function (e) {
3395
+ return n._subscriptionService.subscribeToState(function (t) {
3396
+ e(null != t ? t : n.emptyState);
3397
+ });
3398
+ };
3399
+ });
3400
+ var Mt = "bootstrap";
3401
+ var Nt = /*#__PURE__*/function () {
3402
+ function Nt(e, t, r) {
3383
3403
  var _this = this;
3384
- _classCallCheck(this, Mt);
3404
+ _classCallCheck(this, Nt);
3385
3405
  this._publicToken = e, this._networkClient = t, this._dataLayer = r, this._bootstrapDataPromise = this._networkClient.fetchSDK({
3386
3406
  url: "/projects/bootstrap/".concat(this._publicToken),
3387
3407
  method: "GET",
3388
3408
  errorMessage: "Error fetching bootstrap data for SDK for ".concat(this._publicToken)
3389
- }).then(Mt.mapBootstrapData).then(function (e) {
3390
- return _this._dataLayer.setItem(Lt, JSON.stringify(e)), e;
3409
+ }).then(Nt.mapBootstrapData).then(function (e) {
3410
+ return _this._dataLayer.setItem(Mt, JSON.stringify(e)), e;
3391
3411
  })["catch"](function (e) {
3392
3412
  return Ve(e), {
3393
3413
  displayWatermark: !1,
@@ -3408,10 +3428,10 @@ var Mt = /*#__PURE__*/function () {
3408
3428
  };
3409
3429
  });
3410
3430
  }
3411
- _createClass(Mt, [{
3431
+ _createClass(Nt, [{
3412
3432
  key: "getSync",
3413
3433
  value: function getSync() {
3414
- var e = this._dataLayer.getItem(Lt);
3434
+ var e = this._dataLayer.getItem(Mt);
3415
3435
  if (null === e) return {
3416
3436
  displayWatermark: !1,
3417
3437
  cnameDomain: null,
@@ -3482,9 +3502,9 @@ var Mt = /*#__PURE__*/function () {
3482
3502
  };
3483
3503
  }
3484
3504
  }]);
3485
- return Mt;
3505
+ return Nt;
3486
3506
  }();
3487
- function Nt(e, t, r, n) {
3507
+ function Ut(e, t, r, n) {
3488
3508
  return new (r || (r = Promise))(function (i, s) {
3489
3509
  function o(e) {
3490
3510
  try {
@@ -3510,11 +3530,11 @@ function Nt(e, t, r, n) {
3510
3530
  });
3511
3531
  }
3512
3532
  "function" == typeof SuppressedError && SuppressedError;
3513
- var Ut = /*#__PURE__*/_createClass(function Ut(e) {
3533
+ var Kt = /*#__PURE__*/_createClass(function Kt(e) {
3514
3534
  var _this2 = this;
3515
- _classCallCheck(this, Ut);
3535
+ _classCallCheck(this, Kt);
3516
3536
  this.bootstrapPromise = e, this.executeRecaptcha = function () {
3517
- return Nt(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3537
+ return Ut(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3518
3538
  var _yield$this$state, e, t, r;
3519
3539
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3520
3540
  while (1) switch (_context.prev = _context.next) {
@@ -3545,7 +3565,7 @@ var Ut = /*#__PURE__*/_createClass(function Ut(e) {
3545
3565
  }, _callee, this);
3546
3566
  }));
3547
3567
  }, this.state = e.then(function (e) {
3548
- return Nt(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
3568
+ return Ut(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
3549
3569
  var t;
3550
3570
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3551
3571
  while (1) switch (_context2.prev = _context2.next) {
@@ -3583,10 +3603,10 @@ var Ut = /*#__PURE__*/_createClass(function Ut(e) {
3583
3603
  }));
3584
3604
  });
3585
3605
  });
3586
- var Kt = /*#__PURE__*/function () {
3587
- function Kt(e) {
3606
+ var qt = /*#__PURE__*/function () {
3607
+ function qt(e) {
3588
3608
  var _this3 = this;
3589
- _classCallCheck(this, Kt);
3609
+ _classCallCheck(this, qt);
3590
3610
  this.iframeURL = e, this.oneTapStart = function (e) {
3591
3611
  return _this3.call("oneTapStart", e);
3592
3612
  }, this.oneTapSubmit = function (e) {
@@ -3595,7 +3615,7 @@ var Kt = /*#__PURE__*/function () {
3595
3615
  return _this3.call("parsedPhoneNumber", e);
3596
3616
  };
3597
3617
  }
3598
- _createClass(Kt, [{
3618
+ _createClass(qt, [{
3599
3619
  key: "frameClient",
3600
3620
  get: function get() {
3601
3621
  var e;
@@ -3607,15 +3627,15 @@ var Kt = /*#__PURE__*/function () {
3607
3627
  return this.frameClient.call(e, [t]);
3608
3628
  }
3609
3629
  }]);
3610
- return Kt;
3630
+ return qt;
3611
3631
  }();
3612
- var qt = /*#__PURE__*/function (_at) {
3613
- _inherits(qt, _at);
3614
- function qt(e, t, r, n, i, s) {
3632
+ var Wt = /*#__PURE__*/function (_at) {
3633
+ _inherits(Wt, _at);
3634
+ function Wt(e, t, r, n, i, s) {
3615
3635
  var _this4;
3616
- _classCallCheck(this, qt);
3617
- _this4 = _callSuper(this, qt, [e, t, r, n, i]), _this4._oneTap = s, _this4.startOneTap = function (e) {
3618
- return Nt(_assertThisInitialized(_this4), void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
3636
+ _classCallCheck(this, Wt);
3637
+ _this4 = _callSuper(this, Wt, [e, t, r, n, i]), _this4._oneTap = s, _this4.startOneTap = function (e) {
3638
+ return Ut(_assertThisInitialized(_this4), void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
3619
3639
  var t, r, n;
3620
3640
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3621
3641
  while (1) switch (_context3.prev = _context3.next) {
@@ -3653,11 +3673,11 @@ var qt = /*#__PURE__*/function (_at) {
3653
3673
  };
3654
3674
  return _this4;
3655
3675
  }
3656
- return _createClass(qt);
3676
+ return _createClass(Wt);
3657
3677
  }(at);
3658
- var Wt = /*#__PURE__*/function () {
3659
- function Wt(e, t, r, n) {
3660
- _classCallCheck(this, Wt);
3678
+ var Gt = /*#__PURE__*/function () {
3679
+ function Gt(e, t, r, n) {
3680
+ _classCallCheck(this, Gt);
3661
3681
  this._publicToken = e, this._subscriptionDataLayer = t, this.baseURL = r, this.additionalTelemetryDataFn = n, this.updateSessionToken = function () {
3662
3682
  return null;
3663
3683
  }, this.eventLogger = new tt({
@@ -3666,7 +3686,7 @@ var Wt = /*#__PURE__*/function () {
3666
3686
  logEventURL: this.buildSDKUrl("/events")
3667
3687
  });
3668
3688
  }
3669
- _createClass(Wt, [{
3689
+ _createClass(Gt, [{
3670
3690
  key: "logEvent",
3671
3691
  value: function logEvent(_ref) {
3672
3692
  var e = _ref.name,
@@ -3697,7 +3717,7 @@ var Wt = /*#__PURE__*/function () {
3697
3717
  },
3698
3718
  sdk: {
3699
3719
  identifier: "Stytch.js Javascript SDK",
3700
- version: "4.8.0"
3720
+ version: "4.9.0"
3701
3721
  }
3702
3722
  });
3703
3723
  }
@@ -3708,7 +3728,7 @@ var Wt = /*#__PURE__*/function () {
3708
3728
  t = _ref2.body,
3709
3729
  r = _ref2.errorMessage,
3710
3730
  n = _ref2.method;
3711
- return Nt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
3731
+ return Ut(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
3712
3732
  var i, s, o, a;
3713
3733
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3714
3734
  while (1) switch (_context4.prev = _context4.next) {
@@ -3738,7 +3758,7 @@ var Wt = /*#__PURE__*/function () {
3738
3758
  r = _ref3.errorMessage,
3739
3759
  n = _ref3.method,
3740
3760
  i = _ref3.retryCallback;
3741
- return Nt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
3761
+ return Ut(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
3742
3762
  var s, o, a, c;
3743
3763
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
3744
3764
  while (1) switch (_context5.prev = _context5.next) {
@@ -3809,18 +3829,18 @@ var Wt = /*#__PURE__*/function () {
3809
3829
  return "".concat(this.baseURL, "/sdk/v1").concat(e);
3810
3830
  }
3811
3831
  }]);
3812
- return Wt;
3832
+ return Gt;
3813
3833
  }();
3814
- var Gt = "undefined" != typeof window && "IdentityCredential" in window,
3815
- Ht = function Ht(e) {
3834
+ var Ht = "undefined" != typeof window && "IdentityCredential" in window,
3835
+ zt = function zt(e) {
3816
3836
  return e === exports.OneTapPositions.forceLegacyEmbedded ? "force" : e === exports.OneTapPositions.embeddedOnly || e === exports.OneTapPositions.embedded || e === exports.OneTapPositions.floatingOrEmbedded;
3817
3837
  };
3818
- var zt = /*#__PURE__*/function () {
3819
- function zt(e, t, r) {
3820
- _classCallCheck(this, zt);
3838
+ var Vt = /*#__PURE__*/function () {
3839
+ function Vt(e, t, r) {
3840
+ _classCallCheck(this, Vt);
3821
3841
  this._googleClient = e, this._publicToken = t, this._clientId = r;
3822
3842
  }
3823
- _createClass(zt, [{
3843
+ _createClass(Vt, [{
3824
3844
  key: "cancel",
3825
3845
  value: function cancel() {
3826
3846
  this._googleClient.cancel();
@@ -3831,15 +3851,15 @@ var zt = /*#__PURE__*/function () {
3831
3851
  var e = _ref4.callback,
3832
3852
  t = _ref4.onOneTapCancelled,
3833
3853
  r = _ref4.style;
3834
- return Nt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
3854
+ return Ut(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
3835
3855
  var _this5 = this;
3836
3856
  var n, i, s;
3837
3857
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
3838
3858
  while (1) switch (_context6.prev = _context6.next) {
3839
3859
  case 0:
3840
- n = Ht(r.position), i = function (e) {
3841
- var t = Ht(e);
3842
- return "force" === t || t && !Gt;
3860
+ n = zt(r.position), i = function (e) {
3861
+ var t = zt(e);
3862
+ return "force" === t || t && !Ht;
3843
3863
  }(r.position), s = {
3844
3864
  client_id: this._clientId,
3845
3865
  callback: e,
@@ -3877,22 +3897,22 @@ var zt = /*#__PURE__*/function () {
3877
3897
  key: "styleFrame",
3878
3898
  value: function styleFrame(e) {
3879
3899
  e && Array.from(document.getElementsByTagName("iframe")).forEach(function (e) {
3880
- e.src.includes(Oe) && (e.style.width = "100%");
3900
+ e.src.includes(Pe) && (e.style.width = "100%");
3881
3901
  });
3882
3902
  }
3883
3903
  }]);
3884
- return zt;
3904
+ return Vt;
3885
3905
  }();
3886
- var Vt = /*#__PURE__*/function () {
3887
- function Vt(e, t) {
3906
+ var Yt = /*#__PURE__*/function () {
3907
+ function Yt(e, t) {
3888
3908
  var _this6 = this;
3889
- _classCallCheck(this, Vt);
3909
+ _classCallCheck(this, Yt);
3890
3910
  this._publicToken = e, this.clientsideServices = t, this.createOnSuccessHandler = function (_ref5) {
3891
3911
  var e = _ref5.loginRedirectUrl,
3892
3912
  t = _ref5.signupRedirectUrl,
3893
3913
  r = _ref5.onSuccess;
3894
3914
  return function (n) {
3895
- return Nt(_this6, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
3915
+ return Ut(_this6, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
3896
3916
  var i, _yield$this$submitGoo, s;
3897
3917
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
3898
3918
  while (1) switch (_context7.prev = _context7.next) {
@@ -3919,10 +3939,10 @@ var Vt = /*#__PURE__*/function () {
3919
3939
  window.location.href = e;
3920
3940
  };
3921
3941
  }
3922
- _createClass(Vt, [{
3942
+ _createClass(Yt, [{
3923
3943
  key: "createOneTapClient",
3924
3944
  value: function createOneTapClient() {
3925
- return Nt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
3945
+ return Ut(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
3926
3946
  var e, _yield$this$fetchGoog;
3927
3947
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
3928
3948
  while (1) switch (_context8.prev = _context8.next) {
@@ -3953,9 +3973,9 @@ var Vt = /*#__PURE__*/function () {
3953
3973
  });
3954
3974
  case 12:
3955
3975
  _context8.t1 = !0;
3956
- _context8.t2 = zt;
3976
+ _context8.t2 = Vt;
3957
3977
  _context8.next = 16;
3958
- return Ke(Ce, function () {
3978
+ return Ke(Oe, function () {
3959
3979
  return window.google.accounts.id;
3960
3980
  });
3961
3981
  case 16:
@@ -3987,7 +4007,7 @@ var Vt = /*#__PURE__*/function () {
3987
4007
  var e = _ref6.credential,
3988
4008
  t = _ref6.loginRedirectUrl,
3989
4009
  r = _ref6.signupRedirectUrl;
3990
- return Nt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
4010
+ return Ut(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
3991
4011
  var _yield$this$fetchGoog2, n;
3992
4012
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
3993
4013
  while (1) switch (_context9.prev = _context9.next) {
@@ -4024,21 +4044,21 @@ var Vt = /*#__PURE__*/function () {
4024
4044
  }, {
4025
4045
  key: "WillGoogleOneTapShowEmbedded",
4026
4046
  value: function WillGoogleOneTapShowEmbedded() {
4027
- return !Vt.WillGoogleOneTapShowBannerForUA(navigator.userAgent);
4047
+ return !Yt.WillGoogleOneTapShowBannerForUA(navigator.userAgent);
4028
4048
  }
4029
4049
  }]);
4030
- return Vt;
4050
+ return Yt;
4031
4051
  }();
4032
- function Yt(e) {
4052
+ function Jt(e) {
4033
4053
  var t = e.toString(16);
4034
4054
  return 1 === t.length && (t = "0" + t), t;
4035
4055
  }
4036
- var Jt = /*#__PURE__*/function () {
4037
- function Jt(e, t) {
4038
- _classCallCheck(this, Jt);
4056
+ var $t = /*#__PURE__*/function () {
4057
+ function $t(e, t) {
4058
+ _classCallCheck(this, $t);
4039
4059
  this._dataLayer = e, this.namespace = t;
4040
4060
  }
4041
- _createClass(Jt, [{
4061
+ _createClass($t, [{
4042
4062
  key: "key",
4043
4063
  value: function key() {
4044
4064
  return "PKCE_VERIFIER:" + this.namespace;
@@ -4046,13 +4066,13 @@ var Jt = /*#__PURE__*/function () {
4046
4066
  }, {
4047
4067
  key: "startPKCETransaction",
4048
4068
  value: function startPKCETransaction() {
4049
- return Nt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
4069
+ return Ut(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
4050
4070
  var e;
4051
4071
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
4052
4072
  while (1) switch (_context10.prev = _context10.next) {
4053
4073
  case 0:
4054
4074
  _context10.next = 2;
4055
- return Jt.createProofkeyPair();
4075
+ return $t.createProofkeyPair();
4056
4076
  case 2:
4057
4077
  e = _context10.sent;
4058
4078
  return _context10.abrupt("return", (this._dataLayer.setItem(this.key(), JSON.stringify(e)), e));
@@ -4081,7 +4101,7 @@ var Jt = /*#__PURE__*/function () {
4081
4101
  }], [{
4082
4102
  key: "createProofkeyPair",
4083
4103
  value: function createProofkeyPair() {
4084
- return Nt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
4104
+ return Ut(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
4085
4105
  var _String$fromCharCode;
4086
4106
  var e, t, r, n;
4087
4107
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
@@ -4089,7 +4109,7 @@ var Jt = /*#__PURE__*/function () {
4089
4109
  case 0:
4090
4110
  e = new Uint32Array(16);
4091
4111
  window.crypto.getRandomValues(e);
4092
- t = Array.from(e).map(Yt).join("");
4112
+ t = Array.from(e).map(Jt).join("");
4093
4113
  _context11.next = 5;
4094
4114
  return window.crypto.subtle.digest("SHA-256", new TextEncoder().encode(t));
4095
4115
  case 5:
@@ -4106,9 +4126,9 @@ var Jt = /*#__PURE__*/function () {
4106
4126
  }));
4107
4127
  }
4108
4128
  }]);
4109
- return Jt;
4129
+ return $t;
4110
4130
  }();
4111
- var $t = function $t(e) {
4131
+ var Xt = function Xt(e) {
4112
4132
  return (document.cookie ? document.cookie.split("; ") : []).filter(function (t) {
4113
4133
  var _t$split = t.split("="),
4114
4134
  _t$split2 = _slicedToArray(_t$split, 1),
@@ -4117,17 +4137,17 @@ var $t = function $t(e) {
4117
4137
  }).length > 1;
4118
4138
  };
4119
4139
  /*! js-cookie v3.0.1 | MIT */
4120
- function Xt(e) {
4140
+ function Zt(e) {
4121
4141
  for (var t = 1; t < arguments.length; t++) {
4122
4142
  var r = arguments[t];
4123
4143
  for (var n in r) e[n] = r[n];
4124
4144
  }
4125
4145
  return e;
4126
4146
  }
4127
- var Zt = function e(t, r) {
4147
+ var Qt = function e(t, r) {
4128
4148
  function n(e, n, i) {
4129
4149
  if ("undefined" != typeof document) {
4130
- "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);
4150
+ "number" == typeof (i = Zt({}, 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);
4131
4151
  var s = "";
4132
4152
  for (var o in i) i[o] && (s += "; " + o, !0 !== i[o] && (s += "=" + i[o].split(";")[0]));
4133
4153
  return document.cookie = e + "=" + t.write(n, e) + s;
@@ -4149,15 +4169,15 @@ var Zt = function e(t, r) {
4149
4169
  }
4150
4170
  },
4151
4171
  remove: function remove(e, t) {
4152
- n(e, "", Xt({}, t, {
4172
+ n(e, "", Zt({}, t, {
4153
4173
  expires: -1
4154
4174
  }));
4155
4175
  },
4156
4176
  withAttributes: function withAttributes(t) {
4157
- return e(this.converter, Xt({}, this.attributes, t));
4177
+ return e(this.converter, Zt({}, this.attributes, t));
4158
4178
  },
4159
4179
  withConverter: function withConverter(t) {
4160
- return e(Xt({}, this.converter, t), this.attributes);
4180
+ return e(Zt({}, this.converter, t), this.attributes);
4161
4181
  }
4162
4182
  }, {
4163
4183
  attributes: {
@@ -4177,37 +4197,37 @@ var Zt = function e(t, r) {
4177
4197
  }, {
4178
4198
  path: "/"
4179
4199
  });
4180
- var Qt = function Qt(e) {
4200
+ var er = function er(e) {
4181
4201
  var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
4182
4202
  return "stytch_sdk_state_".concat(e).concat(t ? "::".concat(t) : "");
4183
4203
  },
4184
- er = new Map(),
4185
- tr = function tr(e) {
4186
- clearTimeout(er.get(e));
4204
+ tr = new Map(),
4205
+ rr = function rr(e) {
4206
+ clearTimeout(tr.get(e));
4187
4207
  },
4188
- rr = function rr(e, t, r) {
4189
- tr(e);
4208
+ nr = function nr(e, t, r) {
4209
+ rr(e);
4190
4210
  var n = setTimeout(function () {
4191
- void 0 === Zt.get(e) && Zt.set(e, t, r);
4211
+ void 0 === Qt.get(e) && Qt.set(e, t, r);
4192
4212
  }, 10);
4193
- return er.set(e, n), Zt.set(e, t, r);
4213
+ return tr.set(e, n), Qt.set(e, t, r);
4194
4214
  };
4195
- var nr = /*#__PURE__*/function () {
4196
- function nr(e, t) {
4215
+ var ir = /*#__PURE__*/function () {
4216
+ function ir(e, t) {
4197
4217
  var _this7 = this;
4198
- _classCallCheck(this, nr);
4218
+ _classCallCheck(this, ir);
4199
4219
  this.browserSessionStorage = {
4200
4220
  getItem: function getItem(e) {
4201
- return sessionStorage.getItem(Qt(_this7.publicToken, e));
4221
+ return sessionStorage.getItem(er(_this7.publicToken, e));
4202
4222
  },
4203
4223
  setItem: function setItem(e, t) {
4204
- return sessionStorage.setItem(Qt(_this7.publicToken, e), t);
4224
+ return sessionStorage.setItem(er(_this7.publicToken, e), t);
4205
4225
  },
4206
4226
  removeItem: function removeItem(e) {
4207
- return sessionStorage.removeItem(Qt(_this7.publicToken, e));
4227
+ return sessionStorage.removeItem(er(_this7.publicToken, e));
4208
4228
  }
4209
4229
  }, this.publicToken = e, this.state = null, this.stateKeysUpdated = new Set(), this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (Je("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
- var r = localStorage.getItem(Qt(this.publicToken));
4230
+ var r = localStorage.getItem(er(this.publicToken));
4211
4231
  if (!r) return;
4212
4232
  var n;
4213
4233
  try {
@@ -4217,7 +4237,7 @@ var nr = /*#__PURE__*/function () {
4217
4237
  }
4218
4238
  this.state = n;
4219
4239
  }
4220
- _createClass(nr, [{
4240
+ _createClass(ir, [{
4221
4241
  key: "opaqueTokenCookieName",
4222
4242
  get: function get() {
4223
4243
  var e;
@@ -4239,14 +4259,14 @@ var nr = /*#__PURE__*/function () {
4239
4259
  key: "readSessionCookie",
4240
4260
  value: function readSessionCookie() {
4241
4261
  return {
4242
- session_token: Zt.get(this.opaqueTokenCookieName),
4243
- session_jwt: Zt.get(this.jwtCookieName)
4262
+ session_token: Qt.get(this.opaqueTokenCookieName),
4263
+ session_jwt: Qt.get(this.jwtCookieName)
4244
4264
  };
4245
4265
  }
4246
4266
  }, {
4247
4267
  key: "readIntermediateSessionTokenCookie",
4248
4268
  value: function readIntermediateSessionTokenCookie() {
4249
- return Zt.get(this.istCookieName);
4269
+ return Qt.get(this.istCookieName);
4250
4270
  }
4251
4271
  }, {
4252
4272
  key: "writeSessionCookie",
@@ -4255,32 +4275,32 @@ var nr = /*#__PURE__*/function () {
4255
4275
  var s = e.state,
4256
4276
  o = e.session_token,
4257
4277
  a = e.session_jwt,
4258
- c = nr.generateCookieOpts({
4278
+ c = ir.generateCookieOpts({
4259
4279
  expiresAt: null !== (r = null === (t = null == s ? void 0 : s.session) || void 0 === t ? void 0 : t.expires_at) && void 0 !== r ? r : "",
4260
4280
  availableToSubdomains: this._cookieAvailableToSubdomains,
4261
4281
  path: this._cookiePath,
4262
4282
  domain: this._domain
4263
4283
  });
4264
- rr(this.opaqueTokenCookieName, o, c), rr(this.jwtCookieName, a, c);
4265
- var u = nr.generateCookieOpts({
4284
+ nr(this.opaqueTokenCookieName, o, c), nr(this.jwtCookieName, a, c);
4285
+ var u = ir.generateCookieOpts({
4266
4286
  expiresAt: null !== (i = null === (n = null == s ? void 0 : s.session) || void 0 === n ? void 0 : n.expires_at) && void 0 !== i ? i : "",
4267
4287
  availableToSubdomains: !this._cookieAvailableToSubdomains,
4268
4288
  path: this._cookiePath,
4269
4289
  domain: this._domain
4270
4290
  });
4271
- $t(this.jwtCookieName) && Zt.remove(this.jwtCookieName, u), $t(this.opaqueTokenCookieName) && Zt.remove(this.opaqueTokenCookieName, u), $t(this.jwtCookieName) && ze("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), $t(this.opaqueTokenCookieName) && ze("Could not remove extraneous opaque token cookie.");
4291
+ Xt(this.jwtCookieName) && Qt.remove(this.jwtCookieName, u), Xt(this.opaqueTokenCookieName) && Qt.remove(this.opaqueTokenCookieName, u), Xt(this.jwtCookieName) && ze("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), Xt(this.opaqueTokenCookieName) && ze("Could not remove extraneous opaque token cookie.");
4272
4292
  }
4273
4293
  }, {
4274
4294
  key: "writeIntermediateSessionTokenCookie",
4275
4295
  value: function writeIntermediateSessionTokenCookie(e) {
4276
4296
  var t = new Date(Date.now() + 6e5),
4277
- r = nr.generateCookieOpts({
4297
+ r = ir.generateCookieOpts({
4278
4298
  expiresAt: t.toString(),
4279
4299
  availableToSubdomains: this._cookieAvailableToSubdomains,
4280
4300
  path: this._cookiePath,
4281
4301
  domain: this._domain
4282
4302
  });
4283
- rr(this.istCookieName, e, r);
4303
+ nr(this.istCookieName, e, r);
4284
4304
  }
4285
4305
  }, {
4286
4306
  key: "removeSessionCookie",
@@ -4299,47 +4319,38 @@ var nr = /*#__PURE__*/function () {
4299
4319
  [!0, !1].forEach(function (t) {
4300
4320
  [_this8._cookiePath, null].forEach(function (r) {
4301
4321
  [_this8._domain, null].forEach(function (n) {
4302
- var i = nr.generateCookieOpts({
4322
+ var i = ir.generateCookieOpts({
4303
4323
  expiresAt: new Date(0).toString(),
4304
4324
  availableToSubdomains: t,
4305
4325
  path: r,
4306
4326
  domain: n
4307
4327
  });
4308
4328
  e.forEach(function (e) {
4309
- Zt.remove(e, i);
4329
+ Qt.remove(e, i);
4310
4330
  });
4311
4331
  });
4312
4332
  });
4313
- }), e.forEach(tr);
4333
+ }), e.forEach(rr);
4314
4334
  }
4315
4335
  }, {
4316
4336
  key: "syncToLocalStorage",
4317
4337
  value: function syncToLocalStorage() {
4318
- localStorage.setItem(Qt(this.publicToken), JSON.stringify(this.state));
4338
+ localStorage.setItem(er(this.publicToken), JSON.stringify(this.state));
4319
4339
  }
4320
4340
  }, {
4321
4341
  key: "getItem",
4322
4342
  value: function getItem(e) {
4323
- return localStorage.getItem(Qt(this.publicToken, e));
4343
+ return localStorage.getItem(er(this.publicToken, e));
4324
4344
  }
4325
4345
  }, {
4326
4346
  key: "setItem",
4327
4347
  value: function setItem(e, t) {
4328
- return localStorage.setItem(Qt(this.publicToken, e), t);
4348
+ return localStorage.setItem(er(this.publicToken, e), t);
4329
4349
  }
4330
4350
  }, {
4331
4351
  key: "removeItem",
4332
4352
  value: function removeItem(e) {
4333
- return localStorage.removeItem(Qt(this.publicToken, e));
4334
- }
4335
- }, {
4336
- key: "markStateKeysUpdated",
4337
- value: function markStateKeysUpdated(e) {
4338
- var _this9 = this;
4339
- var t = this.stateKeysUpdated.size;
4340
- return e.forEach(function (e) {
4341
- return _this9.stateKeysUpdated.add(e);
4342
- }), t !== this.stateKeysUpdated.size;
4353
+ return localStorage.removeItem(er(this.publicToken, e));
4343
4354
  }
4344
4355
  }], [{
4345
4356
  key: "generateCookieOpts",
@@ -4355,62 +4366,65 @@ var nr = /*#__PURE__*/function () {
4355
4366
  return e && (i.path = e), Boolean("localhost" === window.location.hostname || "[::1]" === window.location.hostname || window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)) ? i.secure = !1 : (r && (i.domain = t || window.location.host), i.secure = !0), i;
4356
4367
  }
4357
4368
  }]);
4358
- return nr;
4369
+ return ir;
4359
4370
  }();
4360
- var ir = /*#__PURE__*/function (_nr) {
4361
- _inherits(ir, _nr);
4362
- function ir() {
4363
- _classCallCheck(this, ir);
4364
- return _callSuper(this, ir, arguments);
4371
+ var sr = /*#__PURE__*/function (_ir) {
4372
+ _inherits(sr, _ir);
4373
+ function sr() {
4374
+ _classCallCheck(this, sr);
4375
+ return _callSuper(this, sr, arguments);
4365
4376
  }
4366
- return _createClass(ir);
4367
- }(nr);
4368
- var sr = Symbol["for"]("__stytch_DataLayer"),
4369
- or = function or(e, t) {
4377
+ return _createClass(sr);
4378
+ }(ir);
4379
+ var or = Symbol["for"]("__stytch_DataLayer"),
4380
+ ar = function ar(e, t) {
4370
4381
  var r = function () {
4371
4382
  var e = window;
4372
- return e[sr] || (e[sr] = {}), e[sr];
4383
+ return e[or] || (e[or] = {}), e[or];
4373
4384
  }();
4374
- return r[e] || (r[e] = new ir(e, t)), r[e];
4385
+ return r[e] || (r[e] = new sr(e, t)), r[e];
4375
4386
  },
4376
- ar = function ar(e, t) {
4387
+ cr = function cr(e, t) {
4377
4388
  Object.values(e).forEach(function (e) {
4378
4389
  return e(t);
4379
4390
  });
4380
4391
  },
4381
- cr = function () {
4382
- var e = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).KEYS_TO_EXCLUDE,
4383
- t = void 0 === e ? [] : e;
4384
- return function e(r, n) {
4385
- return fe(r) === fe(n) && (null === r || null === n ? r === n : "object" === fe(r) ? Object.keys(r).length === Object.keys(n).length && !Object.keys(r).some(function (e) {
4392
+ ur = function () {
4393
+ var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
4394
+ _ref8$KEYS_TO_EXCLUDE = _ref8.KEYS_TO_EXCLUDE,
4395
+ e = _ref8$KEYS_TO_EXCLUDE === void 0 ? [] : _ref8$KEYS_TO_EXCLUDE;
4396
+ var t = function t(r, n) {
4397
+ return _typeof(r) == _typeof(n) && (null === r || null === n ? r === n : "object" == _typeof(r) ? Object.keys(r).length === Object.keys(n).length && !Object.keys(r).some(function (e) {
4386
4398
  return !(e in n);
4387
- }) && Object.entries(r).filter(function (e) {
4388
- var r = de(e, 1)[0];
4389
- return !t.includes(r);
4390
- }).every(function (t) {
4391
- var r = de(t, 2),
4392
- i = r[0],
4393
- s = r[1];
4394
- return e(s, n[i]);
4399
+ }) && Object.entries(r).filter(function (_ref9) {
4400
+ var _ref10 = _slicedToArray(_ref9, 1),
4401
+ t = _ref10[0];
4402
+ return !e.includes(t);
4403
+ }).every(function (_ref11) {
4404
+ var _ref12 = _slicedToArray(_ref11, 2),
4405
+ e = _ref12[0],
4406
+ r = _ref12[1];
4407
+ return t(r, n[e]);
4395
4408
  }) : r === n);
4396
4409
  };
4410
+ return t;
4397
4411
  }({
4398
4412
  KEYS_TO_EXCLUDE: ["last_accessed_at"]
4399
4413
  });
4400
- var ur = /*#__PURE__*/function () {
4401
- function ur(e, t) {
4402
- var _this10 = this;
4403
- _classCallCheck(this, ur);
4404
- this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4405
- if (e.key !== Qt(_this10._publicToken)) return;
4414
+ var lr = /*#__PURE__*/function () {
4415
+ function lr(e, t) {
4416
+ var _this9 = this;
4417
+ _classCallCheck(this, lr);
4418
+ this._publicToken = e, this._datalayer = t, this.fromCache = !0, this._listen = function (e) {
4419
+ if (e.key !== er(_this9._publicToken)) return;
4406
4420
  var t = null === e.newValue || "null" === e.newValue ? null : JSON.parse(e.newValue);
4407
- _this10.updateState(t, !0);
4421
+ _this9.updateState(t, !0);
4408
4422
  }, window.addEventListener("storage", this._listen);
4409
4423
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4410
4424
  r = _this$_datalayer$read.session_token;
4411
4425
  r || this.destroySession();
4412
4426
  }
4413
- _createClass(ur, [{
4427
+ _createClass(lr, [{
4414
4428
  key: "getTokens",
4415
4429
  value: function getTokens() {
4416
4430
  var _this$_datalayer$read2 = this._datalayer.readSessionCookie(),
@@ -4447,8 +4461,8 @@ var ur = /*#__PURE__*/function () {
4447
4461
  var t = this._datalayer.state,
4448
4462
  r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4449
4463
  this._datalayer.state = r;
4450
- var n = e.state ? Object.keys(e.state) : [];
4451
- !this._datalayer.markStateKeysUpdated(n) && cr(t, r) || ar(this._datalayer.subscriptions, r);
4464
+ var n = this.getFromCache();
4465
+ this.setCacheRefreshed(), !n && ur(t, r) || cr(this._datalayer.subscriptions, r);
4452
4466
  }
4453
4467
  }, {
4454
4468
  key: "updateStateAndTokens",
@@ -4462,10 +4476,10 @@ var ur = /*#__PURE__*/function () {
4462
4476
  var r = this._datalayer.state,
4463
4477
  n = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e);
4464
4478
  this._datalayer.state = n;
4465
- var i = e ? Object.keys(e) : [],
4466
- s = this._datalayer.markStateKeysUpdated(i),
4467
- o = !cr(r, n);
4468
- (s || o) && (ar(this._datalayer.subscriptions, n), o && !t && this._datalayer.syncToLocalStorage());
4479
+ var i = this.getFromCache();
4480
+ this.setCacheRefreshed();
4481
+ var s = !ur(r, n);
4482
+ (i || s) && (cr(this._datalayer.subscriptions, n), s && !t && this._datalayer.syncToLocalStorage());
4469
4483
  }
4470
4484
  }, {
4471
4485
  key: "updateTokens",
@@ -4504,33 +4518,43 @@ var ur = /*#__PURE__*/function () {
4504
4518
  value: function syncFromDeviceStorage() {
4505
4519
  return null;
4506
4520
  }
4521
+ }, {
4522
+ key: "getFromCache",
4523
+ value: function getFromCache() {
4524
+ return this.fromCache;
4525
+ }
4526
+ }, {
4527
+ key: "setCacheRefreshed",
4528
+ value: function setCacheRefreshed() {
4529
+ this.fromCache = !1;
4530
+ }
4507
4531
  }]);
4508
- return ur;
4532
+ return lr;
4509
4533
  }();
4510
- var lr = /*#__PURE__*/function (_ur) {
4511
- _inherits(lr, _ur);
4512
- function lr() {
4513
- var _this11;
4514
- _classCallCheck(this, lr);
4515
- _this11 = _callSuper(this, lr, arguments), _this11.updateUser = function (e) {
4516
- return _this11.updateState({
4534
+ var dr = /*#__PURE__*/function (_lr) {
4535
+ _inherits(dr, _lr);
4536
+ function dr() {
4537
+ var _this10;
4538
+ _classCallCheck(this, dr);
4539
+ _this10 = _callSuper(this, dr, arguments), _this10.updateUser = function (e) {
4540
+ return _this10.updateState({
4517
4541
  user: e
4518
4542
  });
4519
- }, _this11.getUser = function () {
4543
+ }, _this10.getUser = function () {
4520
4544
  var e, t;
4521
- return null !== (t = null === (e = _this11.getState()) || void 0 === e ? void 0 : e.user) && void 0 !== t ? t : null;
4522
- }, _this11.getSession = function () {
4545
+ return null !== (t = null === (e = _this10.getState()) || void 0 === e ? void 0 : e.user) && void 0 !== t ? t : null;
4546
+ }, _this10.getSession = function () {
4523
4547
  var e, t;
4524
- return null !== (t = null === (e = _this11.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4548
+ return null !== (t = null === (e = _this10.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4525
4549
  };
4526
- return _this11;
4550
+ return _this10;
4527
4551
  }
4528
- return _createClass(lr);
4529
- }(ur);
4530
- var dr = Symbol["for"]("stytch__internal_b2c");
4552
+ return _createClass(dr);
4553
+ }(lr);
4554
+ var hr = Symbol["for"]("stytch__internal_b2c");
4531
4555
  exports.BiometricsFailedError = Q, exports.BiometricsUnavailableError = B, exports.ChallengeSigningFailedError = Y, exports.DeviceCredentialsNotAllowedError = q, exports.FailedCodeChallengeError = $, exports.FailedToDecryptDataError = Z, exports.InternalError = F, exports.InvalidAuthorizationCredentialError = z, exports.InvalidCredentialTypeError = ne, exports.InvalidRedirectSchemeError = te, exports.InvalidStartUrlError = ee, exports.JSONDataNotConvertibleToStringError = se, exports.KeyInvalidatedError = L, exports.KeystoreUnavailableError = M, exports.MissingAttestationObjectError = ie, exports.MissingAuthorizationCredentialIDTokenError = H, exports.MissingGoogleClientIDError = W, exports.MissingPKCEError = G, exports.MissingPublicKeyError = V, exports.MissingUrlError = re, exports.NoBiometricsEnrolledError = N, exports.NoBiometricsRegistrationError = j, exports.NoCurrentSessionError = I, exports.PasskeysInvalidEncoding = ae, exports.PasskeysMisconfigured = ce, exports.PasskeysUnsupportedError = X, exports.RandomNumberGenerationFailed = oe, exports.SDKAPIUnreachableError = S, exports.SDKNotConfiguredError = J, exports.SignInWithAppleMisconfigured = ue, exports.StytchAPIError = D, exports.StytchAPISchemaError = E, exports.StytchAPIUnreachableError = A, exports.StytchError = T, exports.StytchHeadlessClient = /*#__PURE__*/function () {
4532
4556
  function _class(e, t) {
4533
- var _this12 = this;
4557
+ var _this11 = this;
4534
4558
  _classCallCheck(this, _class);
4535
4559
  var r;
4536
4560
  !function (e) {
@@ -4549,23 +4573,26 @@ exports.BiometricsFailedError = Q, exports.BiometricsUnavailableError = B, expor
4549
4573
  }
4550
4574
  };
4551
4575
  var s, o, a, c, u, l, d, h, p, f, _;
4552
- this._dataLayer = or(e, n), this._subscriptionService = new lr(e, this._dataLayer);
4553
- var m = new Jt(this._dataLayer, "passwords");
4554
- this._networkClient = new Wt(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4576
+ this._dataLayer = ar(e, n), this._subscriptionService = new dr(e, this._dataLayer), this._stateChangeClient = new Lt(this._subscriptionService, {}), this.onStateChange = function () {
4577
+ var _this11$_stateChangeC;
4578
+ return (_this11$_stateChangeC = _this11._stateChangeClient).onStateChange.apply(_this11$_stateChangeC, arguments);
4579
+ };
4580
+ var m = new $t(this._dataLayer, "passwords");
4581
+ this._networkClient = new Gt(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4555
4582
  var e, t, r, n;
4556
4583
  return {
4557
- 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,
4558
- 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
4584
+ 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,
4585
+ 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
4559
4586
  };
4560
4587
  });
4561
- var v = new Mt(e, this._networkClient, this._dataLayer),
4562
- y = new Ut(v.getAsync()),
4588
+ var v = new Nt(e, this._networkClient, this._dataLayer),
4589
+ y = new Kt(v.getAsync()),
4563
4590
  g = new Ze(e, i.endpoints.dfpBackendURL, v.getAsync(), y.executeRecaptcha),
4564
- b = new Kt(i.endpoints.clientsideServicesIframeURL),
4565
- k = new Vt(e, b),
4591
+ b = new qt(i.endpoints.clientsideServicesIframeURL),
4592
+ k = new Yt(e, b),
4566
4593
  w = new jt(this._networkClient, g);
4567
4594
  var S, x;
4568
- this.user = new rt(this._networkClient, this._subscriptionService), this.session = new nt(this._networkClient, this._subscriptionService), this.magicLinks = new st(this._networkClient, this._subscriptionService, new Jt(this._dataLayer, "magic_links"), m, v.getAsync(), g), this.otps = new ot(this._networkClient, this._subscriptionService, y.executeRecaptcha, g), this.oauth = new qt(this._networkClient, this._subscriptionService, new Jt(this._dataLayer, "oauth"), v.getAsync(), {
4595
+ this.user = new rt(this._networkClient, this._subscriptionService), this.session = new nt(this._networkClient, this._subscriptionService), this.magicLinks = new st(this._networkClient, this._subscriptionService, new $t(this._dataLayer, "magic_links"), m, v.getAsync(), g), this.otps = new ot(this._networkClient, this._subscriptionService, y.executeRecaptcha, g), this.oauth = new Wt(this._networkClient, this._subscriptionService, new $t(this._dataLayer, "oauth"), v.getAsync(), {
4569
4596
  publicToken: e,
4570
4597
  testAPIURL: i.endpoints.testAPIURL,
4571
4598
  liveAPIURL: i.endpoints.liveAPIURL
@@ -4585,10 +4612,10 @@ exports.BiometricsFailedError = Q, exports.BiometricsUnavailableError = B, expor
4585
4612
  publicToken: e,
4586
4613
  dataLayer: this._dataLayer,
4587
4614
  networkClient: this._networkClient
4588
- }, Object.assign(S, _defineProperty({}, dr, x));
4615
+ }, Object.assign(S, _defineProperty({}, hr, x));
4589
4616
  }
4590
4617
  return _createClass(_class);
4591
- }(), exports.StytchSDKAPIError = O, exports.StytchSDKError = R, exports.StytchSDKSchemaError = P, exports.StytchSDKUsageError = x, exports.UNRECOVERABLE_ERROR_TYPES = C, exports.UserCancellationError = U, exports.UserLockedOutError = K, exports.errorToStytchError = function (e) {
4618
+ }(), exports.StytchSDKAPIError = P, exports.StytchSDKError = R, exports.StytchSDKSchemaError = C, exports.StytchSDKUsageError = x, exports.UNRECOVERABLE_ERROR_TYPES = O, exports.UserCancellationError = U, exports.UserLockedOutError = K, exports.errorToStytchError = function (e) {
4592
4619
  switch (e.message) {
4593
4620
  case "internal_error":
4594
4621
  return new F(e.message);