@stytch/vanilla-js 4.8.0 → 4.9.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.
@@ -181,19 +181,19 @@ var g,
181
181
  return a(t, c(Error)), r(t);
182
182
  }(),
183
183
  T = ["unauthorized_credentials", "user_unauthenticated", "invalid_secret_authentication", "session_not_found"],
184
- O = function (e) {
184
+ E = function (e) {
185
185
  function t(e, r) {
186
186
  var n;
187
187
  return i(this, t), (n = o(this, t, [r])).name = e, n;
188
188
  }
189
189
  return a(t, c(Error)), r(t);
190
190
  }(),
191
- E = function (e) {
191
+ O = function (e) {
192
192
  function t(e) {
193
193
  var r;
194
194
  return i(this, t), r = o(this, t, ["StytchAPIUnreachableError", e]), Object.setPrototypeOf(s(r), t.prototype), r;
195
195
  }
196
- return a(t, O), r(t);
196
+ return a(t, E), r(t);
197
197
  }(),
198
198
  A = function (e) {
199
199
  function t(e) {
@@ -204,7 +204,7 @@ var g,
204
204
  }).join("\n");
205
205
  return o(this, t, ["StytchAPISchemaError", "Request does not match expected schema\n".concat(n)]);
206
206
  }
207
- return a(t, O), r(t);
207
+ return a(t, E), r(t);
208
208
  }(),
209
209
  D = function (e) {
210
210
  function t(e) {
@@ -217,14 +217,14 @@ var g,
217
217
  u = e.request_id;
218
218
  return (r = o(this, t, ["StytchAPIError", "[".concat(n, "] ").concat(s, "\n") + "".concat(a, "\n") + "See ".concat(c, " for more information.\n") + (u ? "request_id: ".concat(u, "\n") : "")])).error_type = s, r.error_message = a, r.error_url = c, r.request_id = u, r.status_code = n, r;
219
219
  }
220
- return a(t, O), r(t);
220
+ return a(t, E), r(t);
221
221
  }(),
222
222
  I = function (e) {
223
223
  function t(e, r, n) {
224
224
  var s;
225
225
  return i(this, t), (s = o(this, t, [e, r])).options = n, s;
226
226
  }
227
- return a(t, O), r(t);
227
+ return a(t, E), r(t);
228
228
  }(),
229
229
  R = function (e) {
230
230
  function t() {
@@ -232,19 +232,19 @@ var g,
232
232
  }
233
233
  return a(t, I), r(t);
234
234
  }(),
235
- B = function (e) {
235
+ F = function (e) {
236
236
  function t(e) {
237
237
  return i(this, t), o(this, t, ["InternalError", e || "An internal error has occurred. Please contact Stytch if this occurs."]);
238
238
  }
239
239
  return a(t, I), r(t);
240
240
  }(),
241
- M = function (e) {
241
+ B = function (e) {
242
242
  function t() {
243
243
  return i(this, t), o(this, t, ["NoBiometricsRegistrationError", "There is no biometric registration available. Authenticate with another method and add a new biometric registration first."]);
244
244
  }
245
245
  return a(t, I), r(t);
246
246
  }(),
247
- F = function (e) {
247
+ M = function (e) {
248
248
  function t() {
249
249
  return i(this, t), o(this, t, ["BiometricsUnavailableError", "Biometrics is not available on the device."]);
250
250
  }
@@ -274,13 +274,13 @@ var g,
274
274
  }
275
275
  return a(t, I), r(t);
276
276
  }(),
277
- U = function (e) {
277
+ z = function (e) {
278
278
  function t() {
279
279
  return i(this, t), o(this, t, ["UserLockedOutError", "The user has been locked out due to too many failed attempts. Ask the user to try again later."]);
280
280
  }
281
281
  return a(t, I), r(t);
282
282
  }(),
283
- z = function (e) {
283
+ U = function (e) {
284
284
  function t() {
285
285
  return i(this, t), o(this, t, ["DeviceCredentialsNotAllowedError", "The device credentials allowment is mismatched. Change the allowDeviceCredentials parameter to be the same in both the register and authenticate methods."]);
286
286
  }
@@ -312,145 +312,166 @@ var g,
312
312
  }(),
313
313
  V = function (e) {
314
314
  function t() {
315
- return i(this, t), o(this, t, ["MissingPublicKeyError", "Failed to retrieve the public key. Add a new biometric registration."]);
315
+ return i(this, t), o(this, t, ["NoCredentialsPresentError", "The user did not provide credentials for a Google OneTap attempt"]);
316
316
  }
317
317
  return a(t, I), r(t);
318
318
  }(),
319
319
  Y = function (e) {
320
320
  function t() {
321
- return i(this, t), o(this, t, ["ChallengeSigningFailedError", "Failed to sign the challenge with the key."]);
321
+ return i(this, t), o(this, t, ["MissingPublicKeyError", "Failed to retrieve the public key. Add a new biometric registration."]);
322
322
  }
323
323
  return a(t, I), r(t);
324
324
  }(),
325
325
  J = function (e) {
326
326
  function t() {
327
- return i(this, t), o(this, t, ["SDKNotConfiguredError", "Stytch client is not confiured. You must call the configure method before using the SDK"]);
327
+ return i(this, t), o(this, t, ["ChallengeSigningFailedError", "Failed to sign the challenge with the key."]);
328
328
  }
329
329
  return a(t, I), r(t);
330
330
  }(),
331
331
  $ = function (e) {
332
332
  function t() {
333
- return i(this, t), o(this, t, ["FailedCodeChallengeError", "Failed to create a code challenge"]);
333
+ return i(this, t), o(this, t, ["SDKNotConfiguredError", "Stytch client is not confiured. You must call the configure method before using the SDK"]);
334
334
  }
335
335
  return a(t, I), r(t);
336
336
  }(),
337
337
  X = function (e) {
338
338
  function t() {
339
- return i(this, t), o(this, t, ["PasskeysUnsupportedError", "Passkeys are not supported on this device"]);
339
+ return i(this, t), o(this, t, ["FailedCodeChallengeError", "Failed to create a code challenge"]);
340
340
  }
341
341
  return a(t, I), r(t);
342
342
  }(),
343
343
  Z = function (e) {
344
344
  function t() {
345
- return i(this, t), o(this, t, ["FailedToDecryptDataError", "Failed to decrypt user data"]);
345
+ return i(this, t), o(this, t, ["PasskeysUnsupportedError", "Passkeys are not supported on this device"]);
346
346
  }
347
347
  return a(t, I), r(t);
348
348
  }(),
349
349
  Q = function (e) {
350
350
  function t() {
351
- return i(this, t), o(this, t, ["BiometricsFailedError", "Biometric authentication failed"]);
351
+ return i(this, t), o(this, t, ["FailedToDecryptDataError", "Failed to decrypt user data"]);
352
352
  }
353
353
  return a(t, I), r(t);
354
354
  }(),
355
355
  ee = function (e) {
356
356
  function t() {
357
- return i(this, t), o(this, t, ["InvalidStartUrlError", "The start URL was invalid or improperly formatted."]);
357
+ return i(this, t), o(this, t, ["BiometricsFailedError", "Biometric authentication failed"]);
358
358
  }
359
359
  return a(t, I), r(t);
360
360
  }(),
361
361
  te = function (e) {
362
362
  function t() {
363
- return i(this, t), o(this, t, ["InvalidRedirectSchemeError", "The scheme from the given redirect urls was invalid. Possible reasons include: nil scheme, non-custom scheme (using http or https), or differing schemes for login/signup urls."]);
363
+ return i(this, t), o(this, t, ["InvalidStartUrlError", "The start URL was invalid or improperly formatted."]);
364
364
  }
365
365
  return a(t, I), r(t);
366
366
  }(),
367
367
  re = function (e) {
368
368
  function t() {
369
- return i(this, t), o(this, t, ["MissingUrlError", "The underlying web authentication service failed to return a URL."]);
369
+ return i(this, t), o(this, t, ["InvalidRedirectSchemeError", "The scheme from the given redirect urls was invalid. Possible reasons include: nil scheme, non-custom scheme (using http or https), or differing schemes for login/signup urls."]);
370
370
  }
371
371
  return a(t, I), r(t);
372
372
  }(),
373
373
  ne = function (e) {
374
374
  function t() {
375
- return i(this, t), o(this, t, ["InvalidCredentialTypeError", "The public key credential type was not of the expected type."]);
375
+ return i(this, t), o(this, t, ["MissingUrlError", "The underlying web authentication service failed to return a URL."]);
376
376
  }
377
377
  return a(t, I), r(t);
378
378
  }(),
379
379
  ie = function (e) {
380
380
  function t() {
381
- return i(this, t), o(this, t, ["MissingAttestationObjectError", "The public key credential is missing the attestation object."]);
381
+ return i(this, t), o(this, t, ["InvalidCredentialTypeError", "The public key credential type was not of the expected type."]);
382
382
  }
383
383
  return a(t, I), r(t);
384
384
  }(),
385
385
  oe = function (e) {
386
386
  function t() {
387
- return i(this, t), o(this, t, ["JSONDataNotConvertibleToStringError", "JSON data unable to be converted to String type."]);
387
+ return i(this, t), o(this, t, ["MissingAttestationObjectError", "The public key credential is missing the attestation object."]);
388
388
  }
389
389
  return a(t, I), r(t);
390
390
  }(),
391
391
  se = function (e) {
392
392
  function t() {
393
- return i(this, t), o(this, t, ["RandomNumberGenerationFailed", "Random number generation failed"]);
393
+ return i(this, t), o(this, t, ["JSONDataNotConvertibleToStringError", "JSON data unable to be converted to String type."]);
394
394
  }
395
395
  return a(t, I), r(t);
396
396
  }(),
397
397
  ae = function (e) {
398
398
  function t() {
399
- return i(this, t), o(this, t, ["PasskeysInvalidEncoding", "Invalid passkey encoding"]);
399
+ return i(this, t), o(this, t, ["RandomNumberGenerationFailed", "Random number generation failed"]);
400
400
  }
401
401
  return a(t, I), r(t);
402
402
  }(),
403
403
  ce = function (e) {
404
404
  function t() {
405
- return i(this, t), o(this, t, ["PasskeysMisconfigured", "Passkeys are misconfigured. Verify that you have added the correct associated domain for your application, and that the signing information is correct."]);
405
+ return i(this, t), o(this, t, ["PasskeysInvalidEncoding", "Invalid passkey encoding"]);
406
406
  }
407
407
  return a(t, I), r(t);
408
408
  }(),
409
409
  ue = function (e) {
410
+ function t() {
411
+ return i(this, t), o(this, t, ["PasskeysMisconfigured", "Passkeys are misconfigured. Verify that you have added the correct associated domain for your application, and that the signing information is correct."]);
412
+ }
413
+ return a(t, I), r(t);
414
+ }(),
415
+ le = function (e) {
410
416
  function t() {
411
417
  return i(this, t), o(this, t, ["SignInWithAppleMisconfigured", "Sign In With Apple is misconfigured. Verify that you have correctly configured Apple OAuth in the Stytch Dashboard and added the Sign In With Apple capability to your project."]);
412
418
  }
413
419
  return a(t, I), r(t);
414
420
  }();
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
- o,
424
- s,
425
- a = [],
426
- c = !0,
427
- u = !1;
421
+ function de(e, t) {
422
+ var r = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
423
+ if (!r) {
424
+ if (Array.isArray(e) || (r = function (e, t) {
425
+ if (!e) return;
426
+ if ("string" == typeof e) return he(e, t);
427
+ var r = Object.prototype.toString.call(e).slice(8, -1);
428
+ "Object" === r && e.constructor && (r = e.constructor.name);
429
+ if ("Map" === r || "Set" === r) return Array.from(e);
430
+ if ("Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return he(e, t);
431
+ }(e)) || t && e && "number" == typeof e.length) {
432
+ r && (e = r);
433
+ var _n = 0,
434
+ i = function i() {};
435
+ return {
436
+ s: i,
437
+ n: function n() {
438
+ return _n >= e.length ? {
439
+ done: !0
440
+ } : {
441
+ done: !1,
442
+ value: e[_n++]
443
+ };
444
+ },
445
+ e: function e(_e2) {
446
+ throw _e2;
447
+ },
448
+ f: i
449
+ };
450
+ }
451
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
452
+ }
453
+ var o,
454
+ s = !0,
455
+ a = !1;
456
+ return {
457
+ s: function s() {
458
+ r = r.call(e);
459
+ },
460
+ n: function n() {
461
+ var e = r.next();
462
+ return s = e.done, e;
463
+ },
464
+ e: function e(_e3) {
465
+ a = !0, o = _e3;
466
+ },
467
+ f: function f() {
428
468
  try {
429
- if (o = (r = r.call(e)).next, 0 === t) {
430
- if (Object(r) !== r) return;
431
- c = !1;
432
- } else for (; !(c = (n = o.call(r)).done) && (a.push(n.value), a.length !== t); c = !0);
433
- } catch (e) {
434
- u = !0, i = e;
469
+ s || null == r["return"] || r["return"]();
435
470
  } finally {
436
- try {
437
- if (!c && null != r["return"] && (s = r["return"](), Object(s) !== s)) return;
438
- } finally {
439
- if (u) throw i;
440
- }
471
+ if (a) throw o;
441
472
  }
442
- return a;
443
473
  }
444
- }(e, t) || de(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) {
449
- if (e) {
450
- if ("string" == typeof e) return he(e, t);
451
- var r = Object.prototype.toString.call(e).slice(8, -1);
452
- return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? he(e, t) : void 0;
453
- }
474
+ };
454
475
  }
455
476
  function he(e, t) {
456
477
  (null == t || t > e.length) && (t = e.length);
@@ -616,20 +637,20 @@ function fe() {
616
637
  var s = o.arg;
617
638
  return s ? s.done ? (r[t.resultName] = s.value, r.next = t.nextLoc, "return" !== r.method && (r.method = "next", r.arg = e), r.delegate = null, m) : s : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, m);
618
639
  }
619
- function O(e) {
640
+ function E(e) {
620
641
  var t = {
621
642
  tryLoc: e[0]
622
643
  };
623
644
  1 in e && (t.catchLoc = e[1]), 2 in e && (t.finallyLoc = e[2], t.afterLoc = e[3]), this.tryEntries.push(t);
624
645
  }
625
- function E(e) {
646
+ function O(e) {
626
647
  var t = e.completion || {};
627
648
  t.type = "normal", delete t.arg, e.completion = t;
628
649
  }
629
650
  function A(e) {
630
651
  this.tryEntries = [{
631
652
  tryLoc: "root"
632
- }], e.forEach(O, this), this.reset(!0);
653
+ }], e.forEach(E, this), this.reset(!0);
633
654
  }
634
655
  function D(t) {
635
656
  if (t || "" === t) {
@@ -688,7 +709,7 @@ function fe() {
688
709
  }, t.values = D, A.prototype = {
689
710
  constructor: A,
690
711
  reset: function reset(t) {
691
- if (this.prev = 0, this.next = 0, this.sent = this._sent = e, this.done = !1, this.delegate = null, this.method = "next", this.arg = e, this.tryEntries.forEach(E), !t) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = e);
712
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = e, this.done = !1, this.delegate = null, this.method = "next", this.arg = e, this.tryEntries.forEach(O), !t) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = e);
692
713
  },
693
714
  stop: function stop() {
694
715
  this.done = !0;
@@ -740,7 +761,7 @@ function fe() {
740
761
  finish: function finish(e) {
741
762
  for (var t = this.tryEntries.length - 1; t >= 0; --t) {
742
763
  var r = this.tryEntries[t];
743
- if (r.finallyLoc === e) return this.complete(r.completion, r.afterLoc), E(r), m;
764
+ if (r.finallyLoc === e) return this.complete(r.completion, r.afterLoc), O(r), m;
744
765
  }
745
766
  },
746
767
  "catch": function _catch(e) {
@@ -750,7 +771,7 @@ function fe() {
750
771
  var n = r.completion;
751
772
  if ("throw" === n.type) {
752
773
  var i = n.arg;
753
- E(r);
774
+ O(r);
754
775
  }
755
776
  return i;
756
777
  }
@@ -904,7 +925,7 @@ var Ce,
904
925
  }), t && we(e, t);
905
926
  }(t, ye(Error)), me(t);
906
927
  }();
907
- function Oe(e) {
928
+ function Ee(e) {
908
929
  var t,
909
930
  r = e.method,
910
931
  n = e.finalURL,
@@ -934,7 +955,7 @@ function Oe(e) {
934
955
  e.next = 13;
935
956
  break;
936
957
  }
937
- throw new E("Unable to contact the Stytch servers. Are you online?");
958
+ throw new O("Unable to contact the Stytch servers. Are you online?");
938
959
  case 13:
939
960
  throw e.t0;
940
961
  case 14:
@@ -946,7 +967,7 @@ function Oe(e) {
946
967
  case 18:
947
968
  return d = e.sent, e.abrupt("return", d.data);
948
969
  case 22:
949
- throw e.prev = 22, e.t1 = e["catch"](15), new E("Invalid JSON response from the Stytch servers.");
970
+ throw e.prev = 22, e.t1 = e["catch"](15), new O("Invalid JSON response from the Stytch servers.");
950
971
  case 25:
951
972
  if (200 === l.status || !(null === (t = l.headers.get("content-type")) || void 0 === t ? void 0 : t.includes("application/json"))) {
952
973
  e.next = 38;
@@ -957,7 +978,7 @@ function Oe(e) {
957
978
  h = e.sent, e.next = 35;
958
979
  break;
959
980
  case 32:
960
- throw e.prev = 32, e.t2 = e["catch"](26), new E("Invalid or no response from server");
981
+ throw e.prev = 32, e.t2 = e["catch"](26), new O("Invalid or no response from server");
961
982
  case 35:
962
983
  if (!("body" in h || "params" in h || "query" in h)) {
963
984
  e.next = 37;
@@ -972,7 +993,7 @@ function Oe(e) {
972
993
  p = e.sent, e.next = 47;
973
994
  break;
974
995
  case 44:
975
- throw e.prev = 44, e.t3 = e["catch"](38), new E("Invalid response from the Stytch servers.");
996
+ throw e.prev = 44, e.t3 = e["catch"](38), new O("Invalid response from the Stytch servers.");
976
997
  case 47:
977
998
  if (!p.includes("Captcha required")) {
978
999
  e.next = 49;
@@ -980,7 +1001,7 @@ function Oe(e) {
980
1001
  }
981
1002
  throw new Te(Pe.RequiredCatcha);
982
1003
  case 49:
983
- throw new E("Invalid response from the Stytch servers.");
1004
+ throw new O("Invalid response from the Stytch servers.");
984
1005
  case 50:
985
1006
  case "end":
986
1007
  return e.stop();
@@ -988,14 +1009,14 @@ function Oe(e) {
988
1009
  }, e, null, [[3, 9], [15, 22], [26, 32], [38, 44]]);
989
1010
  }));
990
1011
  }
991
- var Ee = new Uint8Array(16);
1012
+ var Oe = new Uint8Array(16);
992
1013
  function Ae() {
993
1014
  if (!Ce && !(Ce = "undefined" != typeof crypto && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || "undefined" != typeof msCrypto && "function" == typeof msCrypto.getRandomValues && msCrypto.getRandomValues.bind(msCrypto))) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
994
- return Ce(Ee);
1015
+ return Ce(Oe);
995
1016
  }
996
1017
  var De = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
997
1018
  for (var Ie = [], Re = 0; Re < 256; ++Re) Ie.push((Re + 256).toString(16).substr(1));
998
- function Be(e) {
1019
+ function Fe(e) {
999
1020
  var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0,
1000
1021
  r = (Ie[e[t + 0]] + Ie[e[t + 1]] + Ie[e[t + 2]] + Ie[e[t + 3]] + "-" + Ie[e[t + 4]] + Ie[e[t + 5]] + "-" + Ie[e[t + 6]] + Ie[e[t + 7]] + "-" + Ie[e[t + 8]] + Ie[e[t + 9]] + "-" + Ie[e[t + 10]] + Ie[e[t + 11]] + Ie[e[t + 12]] + Ie[e[t + 13]] + Ie[e[t + 14]] + Ie[e[t + 15]]).toLowerCase();
1001
1022
  if (!function (e) {
@@ -1003,28 +1024,28 @@ function Be(e) {
1003
1024
  }(r)) throw TypeError("Stringified UUID is invalid");
1004
1025
  return r;
1005
1026
  }
1006
- function Me(e, t, r) {
1027
+ function Be(e, t, r) {
1007
1028
  var n = (e = e || {}).random || (e.rng || Ae)();
1008
1029
  if (n[6] = 15 & n[6] | 64, n[8] = 63 & n[8] | 128, t) {
1009
1030
  r = r || 0;
1010
1031
  for (var i = 0; i < 16; ++i) t[r + i] = n[i];
1011
1032
  return t;
1012
1033
  }
1013
- return Be(n);
1034
+ return Fe(n);
1014
1035
  }
1015
- var Fe = {};
1036
+ var Me = {};
1016
1037
  function je(e, t) {
1017
1038
  return xe(this, void 0, void 0, fe().mark(function r() {
1018
1039
  return fe().wrap(function (r) {
1019
1040
  for (;;) switch (r.prev = r.next) {
1020
1041
  case 0:
1021
- if (void 0 === Fe[e]) {
1042
+ if (void 0 === Me[e]) {
1022
1043
  r.next = 2;
1023
1044
  break;
1024
1045
  }
1025
- return r.abrupt("return", Fe[e]);
1046
+ return r.abrupt("return", Me[e]);
1026
1047
  case 2:
1027
- return Fe[e] = Le(e, t), r.abrupt("return", Fe[e]);
1048
+ return Me[e] = Le(e, t), r.abrupt("return", Me[e]);
1028
1049
  case 4:
1029
1050
  case "end":
1030
1051
  return r.stop();
@@ -1063,14 +1084,14 @@ var Ke = function Ke(e) {
1063
1084
  return document.querySelectorAll('script[src="'.concat(e, '"]'));
1064
1085
  };
1065
1086
  var Ne,
1066
- Ue = ["[Stytch]"],
1067
- ze = function ze() {
1087
+ ze = ["[Stytch]"],
1088
+ Ue = function Ue() {
1068
1089
  for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++) r[n] = arguments[n];
1069
- return (e = console).warn.apply(e, Ue.concat(r));
1090
+ return (e = console).warn.apply(e, ze.concat(r));
1070
1091
  },
1071
1092
  qe = function qe() {
1072
1093
  for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++) r[n] = arguments[n];
1073
- return (e = console).error.apply(e, Ue.concat(r));
1094
+ return (e = console).error.apply(e, ze.concat(r));
1074
1095
  },
1075
1096
  We = "\nYou can find your public token at https://stytch.com/dashboard/api-keys.",
1076
1097
  He = function He(e) {
@@ -1096,54 +1117,7 @@ var Ne,
1096
1117
  isStringArray: function isStringArray(r, n) {
1097
1118
  if (!Array.isArray(n)) throw new P(e, r + " must be an array of strings.");
1098
1119
  var i,
1099
- o = function (e, t) {
1100
- var r = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
1101
- if (!r) {
1102
- if (Array.isArray(e) || (r = de(e)) || t && e && "number" == typeof e.length) {
1103
- r && (e = r);
1104
- var _n = 0,
1105
- i = function i() {};
1106
- return {
1107
- s: i,
1108
- n: function n() {
1109
- return _n >= e.length ? {
1110
- done: !0
1111
- } : {
1112
- done: !1,
1113
- value: e[_n++]
1114
- };
1115
- },
1116
- e: function e(_e2) {
1117
- throw _e2;
1118
- },
1119
- f: i
1120
- };
1121
- }
1122
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1123
- }
1124
- var o,
1125
- s = !0,
1126
- a = !1;
1127
- return {
1128
- s: function s() {
1129
- r = r.call(e);
1130
- },
1131
- n: function n() {
1132
- var e = r.next();
1133
- return s = e.done, e;
1134
- },
1135
- e: function e(_e3) {
1136
- a = !0, o = _e3;
1137
- },
1138
- f: function f() {
1139
- try {
1140
- s || null == r["return"] || r["return"]();
1141
- } finally {
1142
- if (a) throw o;
1143
- }
1144
- }
1145
- };
1146
- }(n);
1120
+ o = de(n);
1147
1121
  try {
1148
1122
  for (o.s(); !(i = o.n()).done;) {
1149
1123
  if ("string" != typeof i.value) throw new P(e, r + " must be an array of strings.");
@@ -1417,7 +1391,7 @@ var Ne,
1417
1391
  case "StytchSDKSchemaError":
1418
1392
  return e.inflate(x, t);
1419
1393
  case "StytchAPIUnreachableError":
1420
- return e.inflate(E, t);
1394
+ return e.inflate(O, t);
1421
1395
  case "StytchAPISchemaError":
1422
1396
  return e.inflate(A, t);
1423
1397
  case "StytchSDKAPIError":
@@ -1763,6 +1737,11 @@ var Xe = Promise.resolve({
1763
1737
  }));
1764
1738
  }, this.getSync = function () {
1765
1739
  return n._subscriptionService.getMember();
1740
+ }, this.getInfo = function () {
1741
+ return {
1742
+ member: n.getSync(),
1743
+ fromCache: n._subscriptionService.getFromCache()
1744
+ };
1766
1745
  }, this.onChange = function (e) {
1767
1746
  return n._subscriptionService.subscribeToState(function (t) {
1768
1747
  var r;
@@ -1984,7 +1963,7 @@ var Xe = Promise.resolve({
1984
1963
  case 0:
1985
1964
  return Ge("stytch.sso.authenticate").isString("sso_token", e.sso_token).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale), t.next = 3, this._pkceManager.getPKPair();
1986
1965
  case 3:
1987
- return (r = t.sent) || ze("No code verifier found in local storage for SSO flow.\nConsider using stytch.sso.start() to add PKCE to your SSO flows for added security.\nSee https://stytch.com/docs/oauth#guides_pkce for more information."), t.next = 7, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
1966
+ return (r = t.sent) || Ue("No code verifier found in local storage for SSO flow.\nConsider using stytch.sso.start() to add PKCE to your SSO flows for added security.\nSee https://stytch.com/docs/oauth#guides_pkce for more information."), t.next = 7, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
1988
1967
  case 7:
1989
1968
  return n = t.sent, i = n.dfp_telemetry_id, o = n.captcha_token, t.t0 = this._networkClient, t.t1 = Object, t.t2 = Object.assign({
1990
1969
  pkce_code_verifier: null == r ? void 0 : r.code_verifier
@@ -2150,6 +2129,11 @@ var Xe = Promise.resolve({
2150
2129
  }));
2151
2130
  }, this.getSync = function () {
2152
2131
  return n._subscriptionService.getOrganization();
2132
+ }, this.getInfo = function () {
2133
+ return {
2134
+ organization: n.getSync(),
2135
+ fromCache: n._subscriptionService.getFromCache()
2136
+ };
2153
2137
  }, this.onChange = function (e) {
2154
2138
  return n._subscriptionService.subscribeToState(function (t) {
2155
2139
  var r;
@@ -2398,7 +2382,7 @@ var Xe = Promise.resolve({
2398
2382
  case 0:
2399
2383
  return Ge("stytch.oauth.authenticate").isString("oauth_token", e.oauth_token).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale), t.next = 3, this._pkceManager.getPKPair();
2400
2384
  case 3:
2401
- return (r = t.sent) || ze("No code verifier found in local storage for OAuth flow.\nConsider using stytch.oauth.$provider.start() to add PKCE to your OAuth flows for added security.\nSee https://stytch.com/docs/oauth#guides_pkce for more information."), t.next = 7, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
2385
+ return (r = t.sent) || Ue("No code verifier found in local storage for OAuth flow.\nConsider using stytch.oauth.$provider.start() to add PKCE to your OAuth flows for added security.\nSee https://stytch.com/docs/oauth#guides_pkce for more information."), t.next = 7, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
2402
2386
  case 7:
2403
2387
  return n = t.sent, i = n.dfp_telemetry_id, o = n.captcha_token, t.t0 = this._networkClient, t.t1 = Object, t.t2 = null == r ? void 0 : r.code_verifier, t.t3 = i, t.t4 = o, t.next = 17, this._subscriptionService.getIntermediateSessionToken();
2404
2388
  case 17:
@@ -2559,6 +2543,11 @@ var Xe = Promise.resolve({
2559
2543
  var n = this;
2560
2544
  be(this, e), this._networkClient = t, this._subscriptionService = r, this.getSync = function () {
2561
2545
  return n._subscriptionService.getSession();
2546
+ }, this.getInfo = function () {
2547
+ return {
2548
+ session: n.getSync(),
2549
+ fromCache: n._subscriptionService.getFromCache()
2550
+ };
2562
2551
  }, this.onChange = function (e) {
2563
2552
  return n._subscriptionService.subscribeToState(function (t) {
2564
2553
  var r;
@@ -3407,8 +3396,8 @@ var Xe = Promise.resolve({
3407
3396
  return i.policyPromise.then(function (r) {
3408
3397
  return r.callerIsAuthorized(i.roleIds(), e, t);
3409
3398
  });
3410
- }, this.cachedPolicy = t.rbacPolicy ? ft.fromJSON(t.rbacPolicy) : null, this.policyPromise = r.then(function (e) {
3411
- return e.rbacPolicy ? (i.cachedPolicy = ft.fromJSON(e.rbacPolicy), i.cachedPolicy) : (qe("Unable to retrieve RBAC policy from servers. Assuming caller has no permissions."), new ft([], []));
3399
+ }, this.cachedPolicy = t.rbacPolicy ? _t.fromJSON(t.rbacPolicy) : null, this.policyPromise = r.then(function (e) {
3400
+ return e.rbacPolicy ? (i.cachedPolicy = _t.fromJSON(e.rbacPolicy), i.cachedPolicy) : (qe("Unable to retrieve RBAC policy from servers. Assuming caller has no permissions."), new _t([], []));
3412
3401
  });
3413
3402
  }
3414
3403
  return me(e, [{
@@ -3436,7 +3425,7 @@ var Xe = Promise.resolve({
3436
3425
  key: "createIframe",
3437
3426
  value: function value() {
3438
3427
  var e = document.querySelector('[src~="'.concat(this.iframeURL, '"]'));
3439
- e ? ze("It looks like you're creating multiple copies of the Stytch client. This behavior is unsupported, and unintended side effects may occur. Make sure you are creating the Stytch client at the global level, and not inside a component's render function.") : ((e = document.createElement("iframe")).src = this.iframeURL, e.style.position = "absolute", e.style.width = "0", e.style.height = "0", e.style.border = "0", document.body.appendChild(e)), "true" !== e.dataset.loaded ? this.frame = new Promise(function (t) {
3428
+ e ? Ue("It looks like you're creating multiple copies of the Stytch client. This behavior is unsupported, and unintended side effects may occur. Make sure you are creating the Stytch client at the global level, and not inside a component's render function.") : ((e = document.createElement("iframe")).src = this.iframeURL, e.style.position = "absolute", e.style.width = "0", e.style.height = "0", e.style.border = "0", document.body.appendChild(e)), "true" !== e.dataset.loaded ? this.frame = new Promise(function (t) {
3440
3429
  e.addEventListener("load", function () {
3441
3430
  e.dataset.loaded = "true", t(e);
3442
3431
  }, {
@@ -3531,7 +3520,9 @@ var Xe = Promise.resolve({
3531
3520
  function e(t, r) {
3532
3521
  var n = this;
3533
3522
  be(this, e), this._subscriptionService = t, this._headlessSessionClient = r, this._onDataChange = function (e) {
3534
- (null == e ? void 0 : e.session) ? n.scheduleBackgroundRefresh() : n.cancelBackgroundRefresh();
3523
+ !function (e) {
3524
+ return !!(null == e ? void 0 : e.session);
3525
+ }(e) ? n.cancelBackgroundRefresh() : n.scheduleBackgroundRefresh();
3535
3526
  }, this._reauthenticateWithBackoff = function () {
3536
3527
  return xe(n, void 0, void 0, fe().mark(function t() {
3537
3528
  var r;
@@ -3571,7 +3562,7 @@ var Xe = Promise.resolve({
3571
3562
  this._reauthenticateWithBackoff().then(function () {
3572
3563
  e.scheduleBackgroundRefresh();
3573
3564
  })["catch"](function (t) {
3574
- ze("Session background refresh failed. Signalling to app that user is logged out.", {
3565
+ Ue("Session background refresh failed. Signalling to app that user is logged out.", {
3575
3566
  error: t
3576
3567
  }), e._subscriptionService.destroySession();
3577
3568
  });
@@ -3602,58 +3593,66 @@ var Xe = Promise.resolve({
3602
3593
  }]), e;
3603
3594
  }();
3604
3595
  pt.REFRESH_INTERVAL_MS = 18e4;
3605
- var ft = function () {
3606
- function e(t, r) {
3596
+ var ft = me(function e(t, r) {
3607
3597
  var n = this;
3608
- be(this, e), this.roles = t, this.resources = r, this.rolesByID = {}, t.forEach(function (e) {
3609
- return n.rolesByID[e.role_id] = e;
3610
- });
3611
- }
3612
- return me(e, [{
3613
- key: "callerIsAuthorized",
3614
- value: function value(e, t, r) {
3598
+ be(this, e), this._subscriptionService = t, this.emptyState = r, this.onStateChange = function (e) {
3599
+ return n._subscriptionService.subscribeToState(function (t) {
3600
+ e(null != t ? t : n.emptyState);
3601
+ });
3602
+ };
3603
+ }),
3604
+ _t = function () {
3605
+ function e(t, r) {
3615
3606
  var n = this;
3616
- return !!e.map(function (e) {
3617
- return n.rolesByID[e];
3618
- }).filter(function (e) {
3619
- return e;
3620
- }).flatMap(function (e) {
3621
- return e.permissions;
3622
- }).filter(function (e) {
3623
- return e.resource_id === t;
3624
- }).find(function (e) {
3625
- return e.actions.includes(r) || e.actions.includes("*");
3607
+ be(this, e), this.roles = t, this.resources = r, this.rolesByID = {}, t.forEach(function (e) {
3608
+ return n.rolesByID[e.role_id] = e;
3626
3609
  });
3627
3610
  }
3628
- }, {
3629
- key: "allPermissionsForCaller",
3630
- value: function value(e) {
3631
- var t = this,
3632
- r = {};
3633
- return this.resources.forEach(function (n) {
3634
- r[n.resource_id] = {}, n.actions.forEach(function (i) {
3635
- r[n.resource_id][i] = t.callerIsAuthorized(e, n.resource_id, i);
3611
+ return me(e, [{
3612
+ key: "callerIsAuthorized",
3613
+ value: function value(e, t, r) {
3614
+ var n = this;
3615
+ return !!e.map(function (e) {
3616
+ return n.rolesByID[e];
3617
+ }).filter(function (e) {
3618
+ return e;
3619
+ }).flatMap(function (e) {
3620
+ return e.permissions;
3621
+ }).filter(function (e) {
3622
+ return e.resource_id === t;
3623
+ }).find(function (e) {
3624
+ return e.actions.includes(r) || e.actions.includes("*");
3636
3625
  });
3637
- }), r;
3638
- }
3639
- }], [{
3640
- key: "fromJSON",
3641
- value: function value(t) {
3642
- return new e(t.roles, t.resources);
3643
- }
3644
- }]), e;
3645
- }();
3646
- var _t = "bootstrap";
3647
- var mt = /*#__PURE__*/function () {
3648
- function mt(e, t, r) {
3626
+ }
3627
+ }, {
3628
+ key: "allPermissionsForCaller",
3629
+ value: function value(e) {
3630
+ var t = this,
3631
+ r = {};
3632
+ return this.resources.forEach(function (n) {
3633
+ r[n.resource_id] = {}, n.actions.forEach(function (i) {
3634
+ r[n.resource_id][i] = t.callerIsAuthorized(e, n.resource_id, i);
3635
+ });
3636
+ }), r;
3637
+ }
3638
+ }], [{
3639
+ key: "fromJSON",
3640
+ value: function value(t) {
3641
+ return new e(t.roles, t.resources);
3642
+ }
3643
+ }]), e;
3644
+ }();
3645
+ var mt = "bootstrap";
3646
+ var vt = /*#__PURE__*/function () {
3647
+ function vt(e, t, r) {
3649
3648
  var _this = this;
3650
- _classCallCheck(this, mt);
3649
+ _classCallCheck(this, vt);
3651
3650
  this._publicToken = e, this._networkClient = t, this._dataLayer = r, this._bootstrapDataPromise = this._networkClient.fetchSDK({
3652
3651
  url: "/projects/bootstrap/".concat(this._publicToken),
3653
3652
  method: "GET",
3654
3653
  errorMessage: "Error fetching bootstrap data for SDK for ".concat(this._publicToken)
3655
- }).then(mt.mapBootstrapData).then(function (e) {
3656
- return _this._dataLayer.setItem(_t, JSON.stringify(e)), e;
3654
+ }).then(vt.mapBootstrapData).then(function (e) {
3655
+ return _this._dataLayer.setItem(mt, JSON.stringify(e)), e;
3657
3656
  })["catch"](function (e) {
3658
3657
  return qe(e), {
3659
3658
  displayWatermark: !1,
@@ -3674,10 +3673,10 @@ var mt = /*#__PURE__*/function () {
3674
3673
  };
3675
3674
  });
3676
3675
  }
3677
- _createClass(mt, [{
3676
+ _createClass(vt, [{
3678
3677
  key: "getSync",
3679
3678
  value: function getSync() {
3680
- var e = this._dataLayer.getItem(_t);
3679
+ var e = this._dataLayer.getItem(mt);
3681
3680
  if (null === e) return {
3682
3681
  displayWatermark: !1,
3683
3682
  cnameDomain: null,
@@ -3748,9 +3747,9 @@ var mt = /*#__PURE__*/function () {
3748
3747
  };
3749
3748
  }
3750
3749
  }]);
3751
- return mt;
3750
+ return vt;
3752
3751
  }();
3753
- function vt(e, t, r, n) {
3752
+ function bt(e, t, r, n) {
3754
3753
  return new (r || (r = Promise))(function (i, o) {
3755
3754
  function s(e) {
3756
3755
  try {
@@ -3776,11 +3775,11 @@ function vt(e, t, r, n) {
3776
3775
  });
3777
3776
  }
3778
3777
  "function" == typeof SuppressedError && SuppressedError;
3779
- var bt = /*#__PURE__*/_createClass(function bt(e) {
3778
+ var gt = /*#__PURE__*/_createClass(function gt(e) {
3780
3779
  var _this2 = this;
3781
- _classCallCheck(this, bt);
3780
+ _classCallCheck(this, gt);
3782
3781
  this.bootstrapPromise = e, this.executeRecaptcha = function () {
3783
- return vt(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3782
+ return bt(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3784
3783
  var _yield$this$state, e, t, r;
3785
3784
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3786
3785
  while (1) switch (_context.prev = _context.next) {
@@ -3811,7 +3810,7 @@ var bt = /*#__PURE__*/_createClass(function bt(e) {
3811
3810
  }, _callee, this);
3812
3811
  }));
3813
3812
  }, this.state = e.then(function (e) {
3814
- return vt(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
3813
+ return bt(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
3815
3814
  var t;
3816
3815
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3817
3816
  while (1) switch (_context2.prev = _context2.next) {
@@ -3849,10 +3848,10 @@ var bt = /*#__PURE__*/_createClass(function bt(e) {
3849
3848
  }));
3850
3849
  });
3851
3850
  });
3852
- var gt = /*#__PURE__*/function () {
3853
- function gt(e) {
3851
+ var yt = /*#__PURE__*/function () {
3852
+ function yt(e) {
3854
3853
  var _this3 = this;
3855
- _classCallCheck(this, gt);
3854
+ _classCallCheck(this, yt);
3856
3855
  this.iframeURL = e, this.oneTapStart = function (e) {
3857
3856
  return _this3.call("oneTapStart", e);
3858
3857
  }, this.oneTapSubmit = function (e) {
@@ -3861,7 +3860,7 @@ var gt = /*#__PURE__*/function () {
3861
3860
  return _this3.call("parsedPhoneNumber", e);
3862
3861
  };
3863
3862
  }
3864
- _createClass(gt, [{
3863
+ _createClass(yt, [{
3865
3864
  key: "frameClient",
3866
3865
  get: function get() {
3867
3866
  var e;
@@ -3873,11 +3872,11 @@ var gt = /*#__PURE__*/function () {
3873
3872
  return this.frameClient.call(e, [t]);
3874
3873
  }
3875
3874
  }]);
3876
- return gt;
3875
+ return yt;
3877
3876
  }();
3878
- var yt = /*#__PURE__*/function () {
3879
- function yt(e, t, r, n) {
3880
- _classCallCheck(this, yt);
3877
+ var kt = /*#__PURE__*/function () {
3878
+ function kt(e, t, r, n) {
3879
+ _classCallCheck(this, kt);
3881
3880
  this._publicToken = e, this._subscriptionDataLayer = t, this.baseURL = r, this.additionalTelemetryDataFn = n, this.updateSessionToken = function () {
3882
3881
  return null;
3883
3882
  }, this.eventLogger = new $e({
@@ -3886,7 +3885,7 @@ var yt = /*#__PURE__*/function () {
3886
3885
  logEventURL: this.buildSDKUrl("/events")
3887
3886
  });
3888
3887
  }
3889
- _createClass(yt, [{
3888
+ _createClass(kt, [{
3890
3889
  key: "logEvent",
3891
3890
  value: function logEvent(_ref) {
3892
3891
  var e = _ref.name,
@@ -3906,9 +3905,9 @@ var yt = /*#__PURE__*/function () {
3906
3905
  key: "createTelemetryBlob",
3907
3906
  value: function createTelemetryBlob() {
3908
3907
  return Object.assign(Object.assign({
3909
- event_id: "event-id-".concat(Me()),
3910
- app_session_id: "app-session-id-".concat(Me()),
3911
- persistent_id: "persistent-id-".concat(Me()),
3908
+ event_id: "event-id-".concat(Be()),
3909
+ app_session_id: "app-session-id-".concat(Be()),
3910
+ persistent_id: "persistent-id-".concat(Be()),
3912
3911
  client_sent_at: new Date().toISOString(),
3913
3912
  timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
3914
3913
  }, this.additionalTelemetryDataFn()), {
@@ -3917,7 +3916,7 @@ var yt = /*#__PURE__*/function () {
3917
3916
  },
3918
3917
  sdk: {
3919
3918
  identifier: "Stytch.js Javascript SDK",
3920
- version: "4.8.0"
3919
+ version: "4.9.1"
3921
3920
  }
3922
3921
  });
3923
3922
  }
@@ -3928,13 +3927,13 @@ var yt = /*#__PURE__*/function () {
3928
3927
  t = _ref2.body,
3929
3928
  r = _ref2.errorMessage,
3930
3929
  n = _ref2.method;
3931
- return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
3930
+ return bt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
3932
3931
  var i, o, s, a;
3933
3932
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3934
3933
  while (1) switch (_context3.prev = _context3.next) {
3935
3934
  case 0:
3936
3935
  i = this._subscriptionDataLayer.readSessionCookie().session_token, o = "Basic " + window.btoa(this._publicToken + ":" + (i || this._publicToken)), s = window.btoa(JSON.stringify(this.createTelemetryBlob())), a = window.location.origin;
3937
- return _context3.abrupt("return", Oe({
3936
+ return _context3.abrupt("return", Ee({
3938
3937
  basicAuthHeader: o,
3939
3938
  body: t,
3940
3939
  errorMessage: r,
@@ -3958,7 +3957,7 @@ var yt = /*#__PURE__*/function () {
3958
3957
  r = _ref3.errorMessage,
3959
3958
  n = _ref3.method,
3960
3959
  i = _ref3.retryCallback;
3961
- return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
3960
+ return bt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
3962
3961
  var o, s, a, c;
3963
3962
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3964
3963
  while (1) switch (_context4.prev = _context4.next) {
@@ -3986,7 +3985,7 @@ var yt = /*#__PURE__*/function () {
3986
3985
  xSDKClientHeader: o,
3987
3986
  xSDKParentHostHeader: s,
3988
3987
  body: a
3989
- }, e.prev = 1, e.next = 4, Oe(u);
3988
+ }, e.prev = 1, e.next = 4, Ee(u);
3990
3989
  case 4:
3991
3990
  case 15:
3992
3991
  return e.abrupt("return", e.sent);
@@ -3997,7 +3996,7 @@ var yt = /*#__PURE__*/function () {
3997
3996
  }
3998
3997
  return e.next = 12, c(e.t0, u);
3999
3998
  case 12:
4000
- return u = e.sent, e.next = 15, Oe(u);
3999
+ return u = e.sent, e.next = 15, Ee(u);
4001
4000
  case 16:
4002
4001
  throw e.t0;
4003
4002
  case 17:
@@ -4029,18 +4028,18 @@ var yt = /*#__PURE__*/function () {
4029
4028
  return "".concat(this.baseURL, "/sdk/v1").concat(e);
4030
4029
  }
4031
4030
  }]);
4032
- return yt;
4031
+ return kt;
4033
4032
  }();
4034
- function kt(e) {
4033
+ function wt(e) {
4035
4034
  var t = e.toString(16);
4036
4035
  return 1 === t.length && (t = "0" + t), t;
4037
4036
  }
4038
- var wt = /*#__PURE__*/function () {
4039
- function wt(e, t) {
4040
- _classCallCheck(this, wt);
4037
+ var St = /*#__PURE__*/function () {
4038
+ function St(e, t) {
4039
+ _classCallCheck(this, St);
4041
4040
  this._dataLayer = e, this.namespace = t;
4042
4041
  }
4043
- _createClass(wt, [{
4042
+ _createClass(St, [{
4044
4043
  key: "key",
4045
4044
  value: function key() {
4046
4045
  return "PKCE_VERIFIER:" + this.namespace;
@@ -4048,13 +4047,13 @@ var wt = /*#__PURE__*/function () {
4048
4047
  }, {
4049
4048
  key: "startPKCETransaction",
4050
4049
  value: function startPKCETransaction() {
4051
- return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
4050
+ return bt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
4052
4051
  var e;
4053
4052
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
4054
4053
  while (1) switch (_context5.prev = _context5.next) {
4055
4054
  case 0:
4056
4055
  _context5.next = 2;
4057
- return wt.createProofkeyPair();
4056
+ return St.createProofkeyPair();
4058
4057
  case 2:
4059
4058
  e = _context5.sent;
4060
4059
  return _context5.abrupt("return", (this._dataLayer.setItem(this.key(), JSON.stringify(e)), e));
@@ -4072,7 +4071,7 @@ var wt = /*#__PURE__*/function () {
4072
4071
  if (null !== e) try {
4073
4072
  return JSON.parse(e);
4074
4073
  } catch (e) {
4075
- return void ze("Found malformed Proof Key pair in localstorage.");
4074
+ return void Ue("Found malformed Proof Key pair in localstorage.");
4076
4075
  }
4077
4076
  }
4078
4077
  }, {
@@ -4083,7 +4082,7 @@ var wt = /*#__PURE__*/function () {
4083
4082
  }], [{
4084
4083
  key: "createProofkeyPair",
4085
4084
  value: function createProofkeyPair() {
4086
- return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
4085
+ return bt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
4087
4086
  var _String$fromCharCode;
4088
4087
  var e, t, r, n;
4089
4088
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
@@ -4091,7 +4090,7 @@ var wt = /*#__PURE__*/function () {
4091
4090
  case 0:
4092
4091
  e = new Uint32Array(16);
4093
4092
  window.crypto.getRandomValues(e);
4094
- t = Array.from(e).map(kt).join("");
4093
+ t = Array.from(e).map(wt).join("");
4095
4094
  _context6.next = 5;
4096
4095
  return window.crypto.subtle.digest("SHA-256", new TextEncoder().encode(t));
4097
4096
  case 5:
@@ -4108,9 +4107,9 @@ var wt = /*#__PURE__*/function () {
4108
4107
  }));
4109
4108
  }
4110
4109
  }]);
4111
- return wt;
4110
+ return St;
4112
4111
  }();
4113
- var St = function St(e) {
4112
+ var Pt = function Pt(e) {
4114
4113
  return (document.cookie ? document.cookie.split("; ") : []).filter(function (t) {
4115
4114
  var _t$split = t.split("="),
4116
4115
  _t$split2 = _slicedToArray(_t$split, 1),
@@ -4119,17 +4118,17 @@ var St = function St(e) {
4119
4118
  }).length > 1;
4120
4119
  };
4121
4120
  /*! js-cookie v3.0.1 | MIT */
4122
- function Pt(e) {
4121
+ function xt(e) {
4123
4122
  for (var t = 1; t < arguments.length; t++) {
4124
4123
  var r = arguments[t];
4125
4124
  for (var n in r) e[n] = r[n];
4126
4125
  }
4127
4126
  return e;
4128
4127
  }
4129
- var xt = function e(t, r) {
4128
+ var Ct = function e(t, r) {
4130
4129
  function n(e, n, i) {
4131
4130
  if ("undefined" != typeof document) {
4132
- "number" == typeof (i = Pt({}, 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
+ "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);
4133
4132
  var o = "";
4134
4133
  for (var s in i) i[s] && (o += "; " + s, !0 !== i[s] && (o += "=" + i[s].split(";")[0]));
4135
4134
  return document.cookie = e + "=" + t.write(n, e) + o;
@@ -4151,15 +4150,15 @@ var xt = function e(t, r) {
4151
4150
  }
4152
4151
  },
4153
4152
  remove: function remove(e, t) {
4154
- n(e, "", Pt({}, t, {
4153
+ n(e, "", xt({}, t, {
4155
4154
  expires: -1
4156
4155
  }));
4157
4156
  },
4158
4157
  withAttributes: function withAttributes(t) {
4159
- return e(this.converter, Pt({}, this.attributes, t));
4158
+ return e(this.converter, xt({}, this.attributes, t));
4160
4159
  },
4161
4160
  withConverter: function withConverter(t) {
4162
- return e(Pt({}, this.converter, t), this.attributes);
4161
+ return e(xt({}, this.converter, t), this.attributes);
4163
4162
  }
4164
4163
  }, {
4165
4164
  attributes: {
@@ -4179,37 +4178,37 @@ var xt = function e(t, r) {
4179
4178
  }, {
4180
4179
  path: "/"
4181
4180
  });
4182
- var Ct = function Ct(e) {
4181
+ var Tt = function Tt(e) {
4183
4182
  var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
4184
4183
  return "stytch_sdk_state_".concat(e).concat(t ? "::".concat(t) : "");
4185
4184
  },
4186
- Tt = new Map(),
4185
+ Et = new Map(),
4187
4186
  Ot = function Ot(e) {
4188
- clearTimeout(Tt.get(e));
4187
+ clearTimeout(Et.get(e));
4189
4188
  },
4190
- Et = function Et(e, t, r) {
4189
+ At = function At(e, t, r) {
4191
4190
  Ot(e);
4192
4191
  var n = setTimeout(function () {
4193
- void 0 === xt.get(e) && xt.set(e, t, r);
4192
+ void 0 === Ct.get(e) && Ct.set(e, t, r);
4194
4193
  }, 10);
4195
- return Tt.set(e, n), xt.set(e, t, r);
4194
+ return Et.set(e, n), Ct.set(e, t, r);
4196
4195
  };
4197
- var At = /*#__PURE__*/function () {
4198
- function At(e, t) {
4196
+ var Dt = /*#__PURE__*/function () {
4197
+ function Dt(e, t) {
4199
4198
  var _this4 = this;
4200
- _classCallCheck(this, At);
4199
+ _classCallCheck(this, Dt);
4201
4200
  this.browserSessionStorage = {
4202
4201
  getItem: function getItem(e) {
4203
- return sessionStorage.getItem(Ct(_this4.publicToken, e));
4202
+ return sessionStorage.getItem(Tt(_this4.publicToken, e));
4204
4203
  },
4205
4204
  setItem: function setItem(e, t) {
4206
- return sessionStorage.setItem(Ct(_this4.publicToken, e), t);
4205
+ return sessionStorage.setItem(Tt(_this4.publicToken, e), t);
4207
4206
  },
4208
4207
  removeItem: function removeItem(e) {
4209
- return sessionStorage.removeItem(Ct(_this4.publicToken, e));
4208
+ return sessionStorage.removeItem(Tt(_this4.publicToken, e));
4210
4209
  }
4211
4210
  }, this.publicToken = e, this.state = null, this.stateKeysUpdated = new Set(), this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (Ge("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);
4212
- var r = localStorage.getItem(Ct(this.publicToken));
4211
+ var r = localStorage.getItem(Tt(this.publicToken));
4213
4212
  if (!r) return;
4214
4213
  var n;
4215
4214
  try {
@@ -4219,7 +4218,7 @@ var At = /*#__PURE__*/function () {
4219
4218
  }
4220
4219
  this.state = n;
4221
4220
  }
4222
- _createClass(At, [{
4221
+ _createClass(Dt, [{
4223
4222
  key: "opaqueTokenCookieName",
4224
4223
  get: function get() {
4225
4224
  var e;
@@ -4241,14 +4240,14 @@ var At = /*#__PURE__*/function () {
4241
4240
  key: "readSessionCookie",
4242
4241
  value: function readSessionCookie() {
4243
4242
  return {
4244
- session_token: xt.get(this.opaqueTokenCookieName),
4245
- session_jwt: xt.get(this.jwtCookieName)
4243
+ session_token: Ct.get(this.opaqueTokenCookieName),
4244
+ session_jwt: Ct.get(this.jwtCookieName)
4246
4245
  };
4247
4246
  }
4248
4247
  }, {
4249
4248
  key: "readIntermediateSessionTokenCookie",
4250
4249
  value: function readIntermediateSessionTokenCookie() {
4251
- return xt.get(this.istCookieName);
4250
+ return Ct.get(this.istCookieName);
4252
4251
  }
4253
4252
  }, {
4254
4253
  key: "writeSessionCookie",
@@ -4257,32 +4256,32 @@ var At = /*#__PURE__*/function () {
4257
4256
  var o = e.state,
4258
4257
  s = e.session_token,
4259
4258
  a = e.session_jwt,
4260
- c = At.generateCookieOpts({
4259
+ c = Dt.generateCookieOpts({
4261
4260
  expiresAt: null !== (r = null === (t = null == o ? void 0 : o.session) || void 0 === t ? void 0 : t.expires_at) && void 0 !== r ? r : "",
4262
4261
  availableToSubdomains: this._cookieAvailableToSubdomains,
4263
4262
  path: this._cookiePath,
4264
4263
  domain: this._domain
4265
4264
  });
4266
- Et(this.opaqueTokenCookieName, s, c), Et(this.jwtCookieName, a, c);
4267
- var u = At.generateCookieOpts({
4265
+ At(this.opaqueTokenCookieName, s, c), At(this.jwtCookieName, a, c);
4266
+ var u = Dt.generateCookieOpts({
4268
4267
  expiresAt: null !== (i = null === (n = null == o ? void 0 : o.session) || void 0 === n ? void 0 : n.expires_at) && void 0 !== i ? i : "",
4269
4268
  availableToSubdomains: !this._cookieAvailableToSubdomains,
4270
4269
  path: this._cookiePath,
4271
4270
  domain: this._domain
4272
4271
  });
4273
- St(this.jwtCookieName) && xt.remove(this.jwtCookieName, u), St(this.opaqueTokenCookieName) && xt.remove(this.opaqueTokenCookieName, u), St(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."), St(this.opaqueTokenCookieName) && ze("Could not remove extraneous opaque token cookie.");
4272
+ Pt(this.jwtCookieName) && Ct.remove(this.jwtCookieName, u), Pt(this.opaqueTokenCookieName) && Ct.remove(this.opaqueTokenCookieName, u), Pt(this.jwtCookieName) && Ue("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) && Ue("Could not remove extraneous opaque token cookie.");
4274
4273
  }
4275
4274
  }, {
4276
4275
  key: "writeIntermediateSessionTokenCookie",
4277
4276
  value: function writeIntermediateSessionTokenCookie(e) {
4278
4277
  var t = new Date(Date.now() + 6e5),
4279
- r = At.generateCookieOpts({
4278
+ r = Dt.generateCookieOpts({
4280
4279
  expiresAt: t.toString(),
4281
4280
  availableToSubdomains: this._cookieAvailableToSubdomains,
4282
4281
  path: this._cookiePath,
4283
4282
  domain: this._domain
4284
4283
  });
4285
- Et(this.istCookieName, e, r);
4284
+ At(this.istCookieName, e, r);
4286
4285
  }
4287
4286
  }, {
4288
4287
  key: "removeSessionCookie",
@@ -4301,14 +4300,14 @@ var At = /*#__PURE__*/function () {
4301
4300
  [!0, !1].forEach(function (t) {
4302
4301
  [_this5._cookiePath, null].forEach(function (r) {
4303
4302
  [_this5._domain, null].forEach(function (n) {
4304
- var i = At.generateCookieOpts({
4303
+ var i = Dt.generateCookieOpts({
4305
4304
  expiresAt: new Date(0).toString(),
4306
4305
  availableToSubdomains: t,
4307
4306
  path: r,
4308
4307
  domain: n
4309
4308
  });
4310
4309
  e.forEach(function (e) {
4311
- xt.remove(e, i);
4310
+ Ct.remove(e, i);
4312
4311
  });
4313
4312
  });
4314
4313
  });
@@ -4317,31 +4316,22 @@ var At = /*#__PURE__*/function () {
4317
4316
  }, {
4318
4317
  key: "syncToLocalStorage",
4319
4318
  value: function syncToLocalStorage() {
4320
- localStorage.setItem(Ct(this.publicToken), JSON.stringify(this.state));
4319
+ localStorage.setItem(Tt(this.publicToken), JSON.stringify(this.state));
4321
4320
  }
4322
4321
  }, {
4323
4322
  key: "getItem",
4324
4323
  value: function getItem(e) {
4325
- return localStorage.getItem(Ct(this.publicToken, e));
4324
+ return localStorage.getItem(Tt(this.publicToken, e));
4326
4325
  }
4327
4326
  }, {
4328
4327
  key: "setItem",
4329
4328
  value: function setItem(e, t) {
4330
- return localStorage.setItem(Ct(this.publicToken, e), t);
4329
+ return localStorage.setItem(Tt(this.publicToken, e), t);
4331
4330
  }
4332
4331
  }, {
4333
4332
  key: "removeItem",
4334
4333
  value: function removeItem(e) {
4335
- return localStorage.removeItem(Ct(this.publicToken, e));
4336
- }
4337
- }, {
4338
- key: "markStateKeysUpdated",
4339
- value: function markStateKeysUpdated(e) {
4340
- var _this6 = this;
4341
- var t = this.stateKeysUpdated.size;
4342
- return e.forEach(function (e) {
4343
- return _this6.stateKeysUpdated.add(e);
4344
- }), t !== this.stateKeysUpdated.size;
4334
+ return localStorage.removeItem(Tt(this.publicToken, e));
4345
4335
  }
4346
4336
  }], [{
4347
4337
  key: "generateCookieOpts",
@@ -4357,23 +4347,23 @@ var At = /*#__PURE__*/function () {
4357
4347
  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;
4358
4348
  }
4359
4349
  }]);
4360
- return At;
4350
+ return Dt;
4361
4351
  }();
4362
- var Dt = /*#__PURE__*/function (_At) {
4363
- _inherits(Dt, _At);
4364
- function Dt() {
4365
- _classCallCheck(this, Dt);
4366
- return _callSuper(this, Dt, arguments);
4352
+ var It = /*#__PURE__*/function (_Dt) {
4353
+ _inherits(It, _Dt);
4354
+ function It() {
4355
+ _classCallCheck(this, It);
4356
+ return _callSuper(this, It, arguments);
4367
4357
  }
4368
- return _createClass(Dt);
4369
- }(At);
4370
- var It = Symbol["for"]("__stytch_b2b_DataLayer"),
4371
- Rt = function Rt(e, t) {
4358
+ return _createClass(It);
4359
+ }(Dt);
4360
+ var Rt = Symbol["for"]("__stytch_b2b_DataLayer"),
4361
+ Ft = function Ft(e, t) {
4372
4362
  var r = function () {
4373
4363
  var e = window;
4374
- return e[It] || (e[It] = {}), e[It];
4364
+ return e[Rt] || (e[Rt] = {}), e[Rt];
4375
4365
  }();
4376
- return r[e] || (r[e] = new Dt(e, t)), r[e];
4366
+ return r[e] || (r[e] = new It(e, t)), r[e];
4377
4367
  },
4378
4368
  Bt = function Bt(e, t) {
4379
4369
  Object.values(e).forEach(function (e) {
@@ -4381,38 +4371,41 @@ var It = Symbol["for"]("__stytch_b2b_DataLayer"),
4381
4371
  });
4382
4372
  },
4383
4373
  Mt = function () {
4384
- var e = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).KEYS_TO_EXCLUDE,
4385
- t = void 0 === e ? [] : e;
4386
- return function e(r, n) {
4387
- return pe(r) === pe(n) && (null === r || null === n ? r === n : "object" === pe(r) ? Object.keys(r).length === Object.keys(n).length && !Object.keys(r).some(function (e) {
4374
+ var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
4375
+ _ref5$KEYS_TO_EXCLUDE = _ref5.KEYS_TO_EXCLUDE,
4376
+ e = _ref5$KEYS_TO_EXCLUDE === void 0 ? [] : _ref5$KEYS_TO_EXCLUDE;
4377
+ var t = function t(r, n) {
4378
+ 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) {
4388
4379
  return !(e in n);
4389
- }) && Object.entries(r).filter(function (e) {
4390
- var r = le(e, 1)[0];
4391
- return !t.includes(r);
4392
- }).every(function (t) {
4393
- var r = le(t, 2),
4394
- i = r[0],
4395
- o = r[1];
4396
- return e(o, n[i]);
4380
+ }) && Object.entries(r).filter(function (_ref6) {
4381
+ var _ref7 = _slicedToArray(_ref6, 1),
4382
+ t = _ref7[0];
4383
+ return !e.includes(t);
4384
+ }).every(function (_ref8) {
4385
+ var _ref9 = _slicedToArray(_ref8, 2),
4386
+ e = _ref9[0],
4387
+ r = _ref9[1];
4388
+ return t(r, n[e]);
4397
4389
  }) : r === n);
4398
4390
  };
4391
+ return t;
4399
4392
  }({
4400
4393
  KEYS_TO_EXCLUDE: ["last_accessed_at"]
4401
4394
  });
4402
- var Ft = /*#__PURE__*/function () {
4403
- function Ft(e, t) {
4404
- var _this7 = this;
4405
- _classCallCheck(this, Ft);
4406
- this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4407
- if (e.key !== Ct(_this7._publicToken)) return;
4395
+ var jt = /*#__PURE__*/function () {
4396
+ function jt(e, t) {
4397
+ var _this6 = this;
4398
+ _classCallCheck(this, jt);
4399
+ this._publicToken = e, this._datalayer = t, this.fromCache = !0, this._listen = function (e) {
4400
+ if (e.key !== Tt(_this6._publicToken)) return;
4408
4401
  var t = null === e.newValue || "null" === e.newValue ? null : JSON.parse(e.newValue);
4409
- _this7.updateState(t, !0);
4402
+ _this6.updateState(t, !0);
4410
4403
  }, window.addEventListener("storage", this._listen);
4411
4404
  var _this$_datalayer$read = this._datalayer.readSessionCookie(),
4412
4405
  r = _this$_datalayer$read.session_token;
4413
4406
  r || this.destroySession();
4414
4407
  }
4415
- _createClass(Ft, [{
4408
+ _createClass(jt, [{
4416
4409
  key: "getTokens",
4417
4410
  value: function getTokens() {
4418
4411
  var _this$_datalayer$read2 = this._datalayer.readSessionCookie(),
@@ -4449,8 +4442,8 @@ var Ft = /*#__PURE__*/function () {
4449
4442
  var t = this._datalayer.state,
4450
4443
  r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4451
4444
  this._datalayer.state = r;
4452
- var n = e.state ? Object.keys(e.state) : [];
4453
- !this._datalayer.markStateKeysUpdated(n) && Mt(t, r) || Bt(this._datalayer.subscriptions, r);
4445
+ var n = this.getFromCache();
4446
+ this.setCacheRefreshed(), !n && Mt(t, r) || Bt(this._datalayer.subscriptions, r);
4454
4447
  }
4455
4448
  }, {
4456
4449
  key: "updateStateAndTokens",
@@ -4464,10 +4457,10 @@ var Ft = /*#__PURE__*/function () {
4464
4457
  var r = this._datalayer.state,
4465
4458
  n = null === e ? null : Object.assign(Object.assign({}, this._datalayer.state), e);
4466
4459
  this._datalayer.state = n;
4467
- var i = e ? Object.keys(e) : [],
4468
- o = this._datalayer.markStateKeysUpdated(i),
4469
- s = !Mt(r, n);
4470
- (o || s) && (Bt(this._datalayer.subscriptions, n), s && !t && this._datalayer.syncToLocalStorage());
4460
+ var i = this.getFromCache();
4461
+ this.setCacheRefreshed();
4462
+ var o = !Mt(r, n);
4463
+ (i || o) && (Bt(this._datalayer.subscriptions, n), o && !t && this._datalayer.syncToLocalStorage());
4471
4464
  }
4472
4465
  }, {
4473
4466
  key: "updateTokens",
@@ -4506,45 +4499,55 @@ var Ft = /*#__PURE__*/function () {
4506
4499
  value: function syncFromDeviceStorage() {
4507
4500
  return null;
4508
4501
  }
4502
+ }, {
4503
+ key: "getFromCache",
4504
+ value: function getFromCache() {
4505
+ return this.fromCache;
4506
+ }
4507
+ }, {
4508
+ key: "setCacheRefreshed",
4509
+ value: function setCacheRefreshed() {
4510
+ this.fromCache = !1;
4511
+ }
4509
4512
  }]);
4510
- return Ft;
4513
+ return jt;
4511
4514
  }();
4512
- var jt = /*#__PURE__*/function (_Ft) {
4513
- _inherits(jt, _Ft);
4514
- function jt() {
4515
- var _this8;
4516
- _classCallCheck(this, jt);
4517
- _this8 = _callSuper(this, jt, arguments), _this8.updateMember = function (e) {
4518
- return _this8.updateState({
4515
+ var Lt = /*#__PURE__*/function (_jt) {
4516
+ _inherits(Lt, _jt);
4517
+ function Lt() {
4518
+ var _this7;
4519
+ _classCallCheck(this, Lt);
4520
+ _this7 = _callSuper(this, Lt, arguments), _this7.updateMember = function (e) {
4521
+ return _this7.updateState({
4519
4522
  member: e
4520
4523
  });
4521
- }, _this8.getMember = function () {
4524
+ }, _this7.getMember = function () {
4522
4525
  var e, t;
4523
- return null !== (t = null === (e = _this8.getState()) || void 0 === e ? void 0 : e.member) && void 0 !== t ? t : null;
4524
- }, _this8.updateOrganization = function (e) {
4525
- return _this8.updateState({
4526
+ return null !== (t = null === (e = _this7.getState()) || void 0 === e ? void 0 : e.member) && void 0 !== t ? t : null;
4527
+ }, _this7.updateOrganization = function (e) {
4528
+ return _this7.updateState({
4526
4529
  organization: e
4527
4530
  });
4528
- }, _this8.getOrganization = function () {
4531
+ }, _this7.getOrganization = function () {
4529
4532
  var e, t;
4530
- return null !== (t = null === (e = _this8.getState()) || void 0 === e ? void 0 : e.organization) && void 0 !== t ? t : null;
4531
- }, _this8.getSession = function () {
4533
+ return null !== (t = null === (e = _this7.getState()) || void 0 === e ? void 0 : e.organization) && void 0 !== t ? t : null;
4534
+ }, _this7.getSession = function () {
4532
4535
  var e, t;
4533
- return null !== (t = null === (e = _this8.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4536
+ return null !== (t = null === (e = _this7.getState()) || void 0 === e ? void 0 : e.session) && void 0 !== t ? t : null;
4534
4537
  };
4535
- return _this8;
4538
+ return _this7;
4536
4539
  }
4537
- return _createClass(jt);
4538
- }(Ft);
4539
- var Lt = Symbol["for"]("stytch__internal_b2b");
4540
- exports.BiometricsFailedError = Q, exports.BiometricsUnavailableError = F, exports.ChallengeSigningFailedError = Y, exports.DeviceCredentialsNotAllowedError = z, exports.FailedCodeChallengeError = $, exports.FailedToDecryptDataError = Z, exports.InternalError = B, exports.InvalidAuthorizationCredentialError = G, exports.InvalidCredentialTypeError = ne, exports.InvalidRedirectSchemeError = te, exports.InvalidStartUrlError = ee, exports.JSONDataNotConvertibleToStringError = oe, exports.KeyInvalidatedError = j, exports.KeystoreUnavailableError = L, exports.MissingAttestationObjectError = ie, exports.MissingAuthorizationCredentialIDTokenError = H, exports.MissingGoogleClientIDError = q, exports.MissingPKCEError = W, exports.MissingPublicKeyError = V, exports.MissingUrlError = re, exports.NoBiometricsEnrolledError = K, exports.NoBiometricsRegistrationError = M, exports.NoCurrentSessionError = R, exports.PasskeysInvalidEncoding = ae, exports.PasskeysMisconfigured = ce, exports.PasskeysUnsupportedError = X, exports.RandomNumberGenerationFailed = se, exports.SDKAPIUnreachableError = S, exports.SDKNotConfiguredError = J, exports.SignInWithAppleMisconfigured = ue, exports.StytchAPIError = D, exports.StytchAPISchemaError = A, exports.StytchAPIUnreachableError = E, exports.StytchB2BHeadlessClient = /*#__PURE__*/function () {
4540
+ return _createClass(Lt);
4541
+ }(jt);
4542
+ var Kt = Symbol["for"]("stytch__internal_b2b");
4543
+ exports.BiometricsFailedError = ee, exports.BiometricsUnavailableError = M, exports.ChallengeSigningFailedError = J, exports.DeviceCredentialsNotAllowedError = U, exports.FailedCodeChallengeError = X, exports.FailedToDecryptDataError = Q, exports.InternalError = F, exports.InvalidAuthorizationCredentialError = G, exports.InvalidCredentialTypeError = ie, exports.InvalidRedirectSchemeError = re, exports.InvalidStartUrlError = te, exports.JSONDataNotConvertibleToStringError = se, exports.KeyInvalidatedError = j, exports.KeystoreUnavailableError = L, exports.MissingAttestationObjectError = oe, exports.MissingAuthorizationCredentialIDTokenError = H, exports.MissingGoogleClientIDError = q, exports.MissingPKCEError = W, exports.MissingPublicKeyError = Y, exports.MissingUrlError = ne, exports.NoBiometricsEnrolledError = K, exports.NoBiometricsRegistrationError = B, exports.NoCredentialsPresentError = V, exports.NoCurrentSessionError = R, exports.PasskeysInvalidEncoding = ce, exports.PasskeysMisconfigured = ue, exports.PasskeysUnsupportedError = Z, exports.RandomNumberGenerationFailed = ae, exports.SDKAPIUnreachableError = S, exports.SDKNotConfiguredError = $, exports.SignInWithAppleMisconfigured = le, exports.StytchAPIError = D, exports.StytchAPISchemaError = A, exports.StytchAPIUnreachableError = O, exports.StytchB2BHeadlessClient = /*#__PURE__*/function () {
4541
4544
  function _class(e, t) {
4542
- var _this9 = this;
4545
+ var _this8 = this;
4543
4546
  _classCallCheck(this, _class);
4544
4547
  var r;
4545
4548
  !function (e) {
4546
4549
  if ("undefined" == typeof window) throw new Error("The ".concat(e, " is not compatible with server-side environments.\nIf using nextjs, use the create").concat(e, " method instead.\n```\n").concat("import { createStytchB2BHeadlessClient } from '@stytch/nextjs/b2b';\n \n const stytch = createStytchB2BHeadlessClient('public-token-...');\n ", "\n```\n"));
4547
- }("StytchB2BHeadlessClient"), "string" != typeof (r = e) ? ze("Public token is malformed. Expected a string, got ".concat(pe(r), ".").concat(We)) : "" === r ? ze('Public token is malformed. Expected "public-token-...", got an empty string.'.concat(We)) : r.startsWith("public-token-") || ze('Public token is malformed. Expected "public-token-...", got '.concat(r, ".").concat(We));
4550
+ }("StytchB2BHeadlessClient"), "string" != typeof (r = e) ? Ue("Public token is malformed. Expected a string, got ".concat(pe(r), ".").concat(We)) : "" === r ? Ue('Public token is malformed. Expected "public-token-...", got an empty string.'.concat(We)) : r.startsWith("public-token-") || Ue('Public token is malformed. Expected "public-token-...", got '.concat(r, ".").concat(We));
4548
4551
  var n = t,
4549
4552
  i = {
4550
4553
  cookieOptions: null == (o = n) ? void 0 : o.cookieOptions,
@@ -4557,24 +4560,27 @@ exports.BiometricsFailedError = Q, exports.BiometricsUnavailableError = F, expor
4557
4560
  }
4558
4561
  };
4559
4562
  var o, s, a, c, u, l, d, h, p, f, _;
4560
- this._dataLayer = Rt(e, n), this._subscriptionService = new jt(e, this._dataLayer);
4561
- var m = new wt(this._dataLayer, "passwords");
4562
- this._networkClient = new yt(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4563
+ this._dataLayer = Ft(e, n), this._subscriptionService = new Lt(e, this._dataLayer), this._stateChangeClient = new ft(this._subscriptionService, {}), this.onStateChange = function () {
4564
+ var _this8$_stateChangeCl;
4565
+ return (_this8$_stateChangeCl = _this8._stateChangeClient).onStateChange.apply(_this8$_stateChangeCl, arguments);
4566
+ };
4567
+ var m = new St(this._dataLayer, "passwords");
4568
+ this._networkClient = new kt(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4563
4569
  var e, t, r, n;
4564
4570
  return {
4565
- stytch_member_id: null === (t = null === (e = _this9._dataLayer.state) || void 0 === e ? void 0 : e.member) || void 0 === t ? void 0 : t.member_id,
4566
- stytch_member_session_id: null === (n = null === (r = _this9._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.member_session_id
4571
+ stytch_member_id: null === (t = null === (e = _this8._dataLayer.state) || void 0 === e ? void 0 : e.member) || void 0 === t ? void 0 : t.member_id,
4572
+ stytch_member_session_id: null === (n = null === (r = _this8._dataLayer.state) || void 0 === r ? void 0 : r.session) || void 0 === n ? void 0 : n.member_session_id
4567
4573
  };
4568
4574
  });
4569
- var v = new mt(e, this._networkClient, this._dataLayer),
4570
- b = new bt(v.getAsync()),
4575
+ var v = new vt(e, this._networkClient, this._dataLayer),
4576
+ b = new gt(v.getAsync()),
4571
4577
  g = new Ve(e, i.endpoints.dfpBackendURL, v.getAsync(), b.executeRecaptcha),
4572
- y = new gt(i.endpoints.clientsideServicesIframeURL);
4573
- this.organization = new tt(this._networkClient, this._subscriptionService), this.member = new Qe(this._networkClient, this._subscriptionService), this.self = new Qe(this._networkClient, this._subscriptionService), this.session = new nt(this._networkClient, this._subscriptionService), this.magicLinks = new Ze(this._networkClient, this._subscriptionService, new wt(this._dataLayer, "magic_links"), m, v.getAsync(), g), this.oauth = new rt(this._networkClient, this._subscriptionService, new wt(this._dataLayer, "oauth"), v.getAsync(), {
4578
+ y = new yt(i.endpoints.clientsideServicesIframeURL);
4579
+ this.organization = new tt(this._networkClient, this._subscriptionService), this.member = new Qe(this._networkClient, this._subscriptionService), this.self = new Qe(this._networkClient, this._subscriptionService), this.session = new nt(this._networkClient, this._subscriptionService), this.magicLinks = new Ze(this._networkClient, this._subscriptionService, new St(this._dataLayer, "magic_links"), m, v.getAsync(), g), this.oauth = new rt(this._networkClient, this._subscriptionService, new St(this._dataLayer, "oauth"), v.getAsync(), {
4574
4580
  publicToken: e,
4575
4581
  testAPIURL: i.endpoints.testAPIURL,
4576
4582
  liveAPIURL: i.endpoints.liveAPIURL
4577
- }, g), this.sso = new et(this._networkClient, this._subscriptionService, new wt(this._dataLayer, "sso"), v.getAsync(), {
4583
+ }, g), this.sso = new et(this._networkClient, this._subscriptionService, new St(this._dataLayer, "sso"), v.getAsync(), {
4578
4584
  publicToken: e,
4579
4585
  testAPIURL: i.endpoints.testAPIURL,
4580
4586
  liveAPIURL: i.endpoints.liveAPIURL
@@ -4589,7 +4595,7 @@ exports.BiometricsFailedError = Q, exports.BiometricsUnavailableError = F, expor
4589
4595
  }
4590
4596
  });
4591
4597
  (function (e, t) {
4592
- Object.assign(e, _defineProperty({}, Lt, t));
4598
+ Object.assign(e, _defineProperty({}, Kt, t));
4593
4599
  })(this, {
4594
4600
  bootstrap: v,
4595
4601
  clientsideServices: y,
@@ -4600,18 +4606,18 @@ exports.BiometricsFailedError = Q, exports.BiometricsUnavailableError = F, expor
4600
4606
  });
4601
4607
  }
4602
4608
  return _createClass(_class);
4603
- }(), exports.StytchError = O, exports.StytchSDKAPIError = C, exports.StytchSDKError = I, exports.StytchSDKSchemaError = x, exports.StytchSDKUsageError = P, exports.UNRECOVERABLE_ERROR_TYPES = T, exports.UserCancellationError = N, exports.UserLockedOutError = U, exports.errorToStytchError = function (e) {
4609
+ }(), exports.StytchError = E, exports.StytchSDKAPIError = C, exports.StytchSDKError = I, exports.StytchSDKSchemaError = x, exports.StytchSDKUsageError = P, exports.UNRECOVERABLE_ERROR_TYPES = T, exports.UserCancellationError = N, exports.UserLockedOutError = z, exports.errorToStytchError = function (e) {
4604
4610
  switch (e.message) {
4605
4611
  case "internal_error":
4606
- return new B(e.message);
4612
+ return new F(e.message);
4607
4613
  case "no_current_session":
4608
4614
  return new R();
4609
4615
  case "no_biometrics_registration":
4610
- return new M();
4616
+ return new B();
4611
4617
  case "biometrics_unavailable":
4612
4618
  case "device_hardware_error":
4613
4619
  case "biometrics_not_available":
4614
- return new F();
4620
+ return new M();
4615
4621
  case "key_invalidated":
4616
4622
  case "no_biometric_key":
4617
4623
  return new j();
@@ -4620,11 +4626,11 @@ exports.BiometricsFailedError = Q, exports.BiometricsUnavailableError = F, expor
4620
4626
  case "keystore_unavailable":
4621
4627
  return new L();
4622
4628
  case "device_credentials_not_allowed":
4623
- return new z();
4629
+ return new U();
4624
4630
  case "user_cancellation":
4625
4631
  return new N();
4626
4632
  case "user_locked_out":
4627
- return new U();
4633
+ return new z();
4628
4634
  case "google_onetap_missing_id_token":
4629
4635
  case "oauth_apple_missing_id_token":
4630
4636
  case "missing_authorization_credential_id_token":
@@ -4634,39 +4640,41 @@ exports.BiometricsFailedError = Q, exports.BiometricsUnavailableError = F, expor
4634
4640
  case "invalid_authorization_credential":
4635
4641
  return new G();
4636
4642
  case "missing_public_key":
4637
- return new V();
4638
- case "challenge_signing_failed":
4639
4643
  return new Y();
4640
- case "sdk_not_configured":
4644
+ case "challenge_signing_failed":
4641
4645
  return new J();
4642
- case "failed_code_challenge":
4646
+ case "no_credentials_present":
4647
+ return new V();
4648
+ case "sdk_not_configured":
4643
4649
  return new $();
4644
- case "passkeys_unsupported":
4650
+ case "failed_code_challenge":
4645
4651
  return new X();
4646
- case "failed_to_decrypt_data":
4652
+ case "passkeys_unsupported":
4647
4653
  return new Z();
4648
- case "biometrics_failed":
4654
+ case "failed_to_decrypt_data":
4649
4655
  return new Q();
4650
- case "invalid_start_url":
4656
+ case "biometrics_failed":
4651
4657
  return new ee();
4652
- case "invalid_redirect_scheme":
4658
+ case "invalid_start_url":
4653
4659
  return new te();
4654
- case "missing_url":
4660
+ case "invalid_redirect_scheme":
4655
4661
  return new re();
4656
- case "invalid_credential_type":
4662
+ case "missing_url":
4657
4663
  return new ne();
4658
- case "missing_attestation_object":
4664
+ case "invalid_credential_type":
4659
4665
  return new ie();
4660
- case "json_data_not_convertible_to_string":
4666
+ case "missing_attestation_object":
4661
4667
  return new oe();
4662
- case "random_number_generation_failed":
4668
+ case "json_data_not_convertible_to_string":
4663
4669
  return new se();
4664
- case "passkeys_invalid_encoding":
4670
+ case "random_number_generation_failed":
4665
4671
  return new ae();
4666
- case "passkeys_misconfigured":
4672
+ case "passkeys_invalid_encoding":
4667
4673
  return new ce();
4668
- case "signinwithapple_misconfigured":
4674
+ case "passkeys_misconfigured":
4669
4675
  return new ue();
4676
+ case "signinwithapple_misconfigured":
4677
+ return new le();
4670
4678
  default:
4671
4679
  return new I(e.name, e.message);
4672
4680
  }