@stytch/vanilla-js 4.3.2 → 4.4.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.
@@ -209,8 +209,8 @@ var b,
209
209
  }
210
210
  return r(s);
211
211
  }(),
212
- A = ["unauthorized_credentials", "user_unauthenticated", "invalid_secret_authentication", "session_not_found"],
213
- C = function (e) {
212
+ C = ["unauthorized_credentials", "user_unauthenticated", "invalid_secret_authentication", "session_not_found"],
213
+ A = function (e) {
214
214
  i(s, a(Error));
215
215
  var t = o(s);
216
216
  function s(e, r) {
@@ -220,7 +220,7 @@ var b,
220
220
  return r(s);
221
221
  }(),
222
222
  T = function (e) {
223
- i(a, C);
223
+ i(a, A);
224
224
  var t = o(a);
225
225
  function a(e) {
226
226
  var r;
@@ -229,7 +229,7 @@ var b,
229
229
  return r(a);
230
230
  }(),
231
231
  O = function (e) {
232
- i(s, C);
232
+ i(s, A);
233
233
  var t = o(s);
234
234
  function s(e) {
235
235
  var r;
@@ -242,7 +242,7 @@ var b,
242
242
  return r(s);
243
243
  }(),
244
244
  E = function (e) {
245
- i(s, C);
245
+ i(s, A);
246
246
  var t = o(s);
247
247
  function s(e) {
248
248
  var r;
@@ -257,7 +257,7 @@ var b,
257
257
  return r(s);
258
258
  }(),
259
259
  x = function (e) {
260
- i(s, C);
260
+ i(s, A);
261
261
  var t = o(s);
262
262
  function s(e, r, i) {
263
263
  var o;
@@ -273,7 +273,7 @@ var b,
273
273
  }
274
274
  return r(s);
275
275
  }(),
276
- R = function (e) {
276
+ I = function (e) {
277
277
  i(s, x);
278
278
  var t = o(s);
279
279
  function s(e) {
@@ -281,7 +281,7 @@ var b,
281
281
  }
282
282
  return r(s);
283
283
  }(),
284
- I = function (e) {
284
+ R = function (e) {
285
285
  i(s, x);
286
286
  var t = o(s);
287
287
  function s() {
@@ -313,7 +313,7 @@ var b,
313
313
  }
314
314
  return r(s);
315
315
  }(),
316
- j = function (e) {
316
+ F = function (e) {
317
317
  i(s, x);
318
318
  var t = o(s);
319
319
  function s() {
@@ -321,7 +321,7 @@ var b,
321
321
  }
322
322
  return r(s);
323
323
  }(),
324
- F = function (e) {
324
+ j = function (e) {
325
325
  i(s, x);
326
326
  var t = o(s);
327
327
  function s() {
@@ -329,7 +329,7 @@ var b,
329
329
  }
330
330
  return r(s);
331
331
  }(),
332
- N = function (e) {
332
+ K = function (e) {
333
333
  i(s, x);
334
334
  var t = o(s);
335
335
  function s() {
@@ -337,7 +337,7 @@ var b,
337
337
  }
338
338
  return r(s);
339
339
  }(),
340
- K = function (e) {
340
+ N = function (e) {
341
341
  i(s, x);
342
342
  var t = o(s);
343
343
  function s() {
@@ -500,12 +500,12 @@ var b,
500
500
  function se(e) {
501
501
  switch (e.message) {
502
502
  case "internal_error":
503
- return new R(e.message);
503
+ return new I(e.message);
504
504
  case "no_current_session":
505
505
  return new D();
506
506
  case "no_biometrics_registration":
507
507
  case "no_biometrics_registration":
508
- return new I();
508
+ return new R();
509
509
  case "biometrics_unavailable":
510
510
  case "device_hardware_error":
511
511
  case "biometrics_not_available":
@@ -514,15 +514,15 @@ function se(e) {
514
514
  case "no_biometric_key":
515
515
  return new L();
516
516
  case "no_biometrics_enrolled":
517
- return new j();
517
+ return new F();
518
518
  case "keystore_unavailable":
519
519
  return new M();
520
520
  case "device_credentials_not_allowed":
521
- return new K();
521
+ return new N();
522
522
  case "user_cancellation":
523
- return new F();
523
+ return new j();
524
524
  case "user_locked_out":
525
- return new N();
525
+ return new K();
526
526
  case "google_onetap_missing_id_token":
527
527
  case "oauth_apple_missing_id_token":
528
528
  case "missing_authorization_credential_id_token":
@@ -653,7 +653,7 @@ function de() {
653
653
  s = Object.create(o.prototype),
654
654
  a = new x(n || []);
655
655
  return i(s, "_invoke", {
656
- value: C(e, r, a)
656
+ value: A(e, r, a)
657
657
  }), s;
658
658
  }
659
659
  function d(e, t, r) {
@@ -693,7 +693,7 @@ function de() {
693
693
  });
694
694
  });
695
695
  }
696
- function A(e, t) {
696
+ function C(e, t) {
697
697
  function r(i, o, s, a) {
698
698
  var c = d(e[i], e, o);
699
699
  if ("throw" !== c.type) {
@@ -723,7 +723,7 @@ function de() {
723
723
  }
724
724
  });
725
725
  }
726
- function C(t, r, n) {
726
+ function A(t, r, n) {
727
727
  var i = h;
728
728
  return function (o, s) {
729
729
  if (i === _) throw new Error("Generator is already running");
@@ -815,11 +815,11 @@ function de() {
815
815
  return {
816
816
  __await: e
817
817
  };
818
- }, P(A.prototype), u(A.prototype, a, function () {
818
+ }, P(C.prototype), u(C.prototype, a, function () {
819
819
  return this;
820
- }), t.AsyncIterator = A, t.async = function (e, r, n, i, o) {
820
+ }), t.AsyncIterator = C, t.async = function (e, r, n, i, o) {
821
821
  void 0 === o && (o = Promise);
822
- var s = new A(l(e, r, n, i), o);
822
+ var s = new C(l(e, r, n, i), o);
823
823
  return t.isGeneratorFunction(r) ? s : s.next().then(function (e) {
824
824
  return e.done ? e.value : s.next();
825
825
  });
@@ -1073,7 +1073,7 @@ var Se,
1073
1073
  }
1074
1074
  return pe(r);
1075
1075
  }();
1076
- function Ae(e) {
1076
+ function Ce(e) {
1077
1077
  var t,
1078
1078
  r = e.method,
1079
1079
  n = e.finalURL,
@@ -1157,10 +1157,10 @@ function Ae(e) {
1157
1157
  }, e, null, [[3, 9], [15, 22], [26, 32], [38, 44]]);
1158
1158
  }));
1159
1159
  }
1160
- var Ce = new Uint8Array(16);
1160
+ var Ae = new Uint8Array(16);
1161
1161
  function Te() {
1162
1162
  if (!Se && !(Se = "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");
1163
- return Se(Ce);
1163
+ return Se(Ae);
1164
1164
  }
1165
1165
  var Oe = /^(?:[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;
1166
1166
  for (var Ee = [], xe = 0; xe < 256; ++xe) Ee.push((xe + 256).toString(16).substr(1));
@@ -1172,7 +1172,7 @@ function De(e) {
1172
1172
  }(r)) throw TypeError("Stringified UUID is invalid");
1173
1173
  return r;
1174
1174
  }
1175
- function Re(e, t, r) {
1175
+ function Ie(e, t, r) {
1176
1176
  var n = (e = e || {}).random || (e.rng || Te)();
1177
1177
  if (n[6] = 15 & n[6] | 64, n[8] = 63 & n[8] | 128, t) {
1178
1178
  r = r || 0;
@@ -1181,19 +1181,19 @@ function Re(e, t, r) {
1181
1181
  }
1182
1182
  return De(n);
1183
1183
  }
1184
- var Ie = {};
1184
+ var Re = {};
1185
1185
  function Be(e, t) {
1186
1186
  return we(this, void 0, void 0, de().mark(function r() {
1187
1187
  return de().wrap(function (r) {
1188
1188
  for (;;) switch (r.prev = r.next) {
1189
1189
  case 0:
1190
- if (void 0 === Ie[e]) {
1190
+ if (void 0 === Re[e]) {
1191
1191
  r.next = 2;
1192
1192
  break;
1193
1193
  }
1194
- return r.abrupt("return", Ie[e]);
1194
+ return r.abrupt("return", Re[e]);
1195
1195
  case 2:
1196
- return Ie[e] = Le(e, t), r.abrupt("return", Ie[e]);
1196
+ return Re[e] = Le(e, t), r.abrupt("return", Re[e]);
1197
1197
  case 4:
1198
1198
  case "end":
1199
1199
  return r.stop();
@@ -1231,15 +1231,15 @@ function Le(e, t) {
1231
1231
  var Me = function Me(e) {
1232
1232
  return document.querySelectorAll('script[src="'.concat(e, '"]'));
1233
1233
  };
1234
- var je,
1235
- Fe = ["[Stytch]"],
1236
- Ne = function Ne() {
1234
+ var Fe,
1235
+ je = ["[Stytch]"],
1236
+ Ke = function Ke() {
1237
1237
  for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++) r[n] = arguments[n];
1238
- return (e = console).warn.apply(e, Fe.concat(r));
1238
+ return (e = console).warn.apply(e, je.concat(r));
1239
1239
  },
1240
- Ke = function Ke() {
1240
+ Ne = function Ne() {
1241
1241
  for (var e, t = arguments.length, r = new Array(t), n = 0; n < t; n++) r[n] = arguments[n];
1242
- return (e = console).error.apply(e, Fe.concat(r));
1242
+ return (e = console).error.apply(e, je.concat(r));
1243
1243
  },
1244
1244
  ze = "\nYou can find your public token at https://stytch.com/dashboard/api-keys.",
1245
1245
  Ue = function Ue(e) {
@@ -1607,7 +1607,7 @@ var je,
1607
1607
  }();
1608
1608
  !function (e) {
1609
1609
  e.LoginOrCreateEML = "login_or_create_eml", e.LoginOrCreateOTP = "login_or_create_otp", e.ResetPassword = "reset_password";
1610
- }(je || (je = {})), Promise.resolve({
1610
+ }(Fe || (Fe = {})), Promise.resolve({
1611
1611
  pkceRequiredForEmailMagicLinks: !1
1612
1612
  }), Promise.resolve({
1613
1613
  pkceRequiredForPasswordResets: !1
@@ -2073,7 +2073,7 @@ var Ye = Promise.resolve({
2073
2073
  case 0:
2074
2074
  return qe("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();
2075
2075
  case 3:
2076
- return (r = t.sent) || Ne("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();
2076
+ return (r = t.sent) || Ke("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();
2077
2077
  case 7:
2078
2078
  return n = t.sent, i = n.dfp_telemetry_id, o = n.captcha_token, t.next = 12, this._networkClient.retriableFetchSDK({
2079
2079
  url: "/b2b/sso/authenticate",
@@ -2461,7 +2461,7 @@ var Ye = Promise.resolve({
2461
2461
  case 0:
2462
2462
  return qe("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();
2463
2463
  case 3:
2464
- return (r = t.sent) || Ne("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();
2464
+ return (r = t.sent) || Ke("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();
2465
2465
  case 7:
2466
2466
  return n = t.sent, i = n.dfp_telemetry_id, o = n.captcha_token, t.next = 12, this._networkClient.retriableFetchSDK({
2467
2467
  url: "/b2b/oauth/authenticate",
@@ -2632,7 +2632,7 @@ var Ye = Promise.resolve({
2632
2632
  case 3:
2633
2633
  return r = t.sent, this._subscriptionService.destroyState(), t.abrupt("return", r);
2634
2634
  case 8:
2635
- throw t.prev = 8, t.t0 = t["catch"](0), ((null == e ? void 0 : e.forceClear) || A.includes(t.t0.error_type)) && this._subscriptionService.destroyState(), t.t0;
2635
+ 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;
2636
2636
  case 12:
2637
2637
  case "end":
2638
2638
  return t.stop();
@@ -2684,7 +2684,7 @@ var Ye = Promise.resolve({
2684
2684
  }
2685
2685
  return t.abrupt("return", this.authenticate(e));
2686
2686
  case 17:
2687
- throw A.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
2687
+ throw C.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
2688
2688
  case 19:
2689
2689
  case "end":
2690
2690
  return t.stop();
@@ -2875,17 +2875,26 @@ var tt = pe(function e(t, r) {
2875
2875
  case 0:
2876
2876
  return qe("stytch.otps.sms.send").isString("organization_id", e.organization_id).isString("member_id", e.member_id).isOptionalString("mfa_phone_number", e.mfa_phone_number).isOptionalString("locale", e.locale), t.next = 3, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
2877
2877
  case 3:
2878
- return r = t.sent, n = r.dfp_telemetry_id, i = r.captcha_token, t.abrupt("return", this._networkClient.retriableFetchSDK({
2878
+ return r = t.sent, n = r.dfp_telemetry_id, i = r.captcha_token, t.t0 = this._networkClient, t.t1 = Object, t.t2 = Object.assign({}, e), t.t3 = n, t.t4 = i, t.next = 13, this._subscriptionService.getIntermediateSessionToken();
2879
+ case 13:
2880
+ if (t.t5 = t.sent, t.t5) {
2881
+ t.next = 16;
2882
+ break;
2883
+ }
2884
+ t.t5 = void 0;
2885
+ case 16:
2886
+ return t.t6 = t.t5, t.t7 = {
2887
+ dfp_telemetry_id: t.t3,
2888
+ captcha_token: t.t4,
2889
+ intermediate_session_token: t.t6
2890
+ }, t.t8 = t.t1.assign.call(t.t1, t.t2, t.t7), t.t9 = this.dfpProtectedAuth.retryWithCaptchaAndDFP, t.t10 = {
2879
2891
  url: "/b2b/otps/sms/send",
2880
- body: Object.assign(Object.assign({}, e), {
2881
- dfp_telemetry_id: n,
2882
- captcha_token: i
2883
- }),
2892
+ body: t.t8,
2884
2893
  errorMessage: "Failed to send one time passcode",
2885
2894
  method: "POST",
2886
- retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
2887
- }));
2888
- case 7:
2895
+ retryCallback: t.t9
2896
+ }, t.abrupt("return", t.t0.retriableFetchSDK.call(t.t0, t.t10));
2897
+ case 22:
2889
2898
  case "end":
2890
2899
  return t.stop();
2891
2900
  }
@@ -2954,17 +2963,26 @@ var tt = pe(function e(t, r) {
2954
2963
  case 0:
2955
2964
  return qe("stytch.totp.create").isString("organization_id", e.organization_id).isString("member_id", e.member_id).isOptionalNumber("expiration_minutes", e.expiration_minutes), t.next = 3, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
2956
2965
  case 3:
2957
- return r = t.sent, n = r.dfp_telemetry_id, i = r.captcha_token, t.abrupt("return", this._networkClient.retriableFetchSDK({
2966
+ return r = t.sent, n = r.dfp_telemetry_id, i = r.captcha_token, t.t0 = this._networkClient, t.t1 = Object, t.t2 = Object.assign({}, e), t.t3 = n, t.t4 = i, t.next = 13, this._subscriptionService.getIntermediateSessionToken();
2967
+ case 13:
2968
+ if (t.t5 = t.sent, t.t5) {
2969
+ t.next = 16;
2970
+ break;
2971
+ }
2972
+ t.t5 = void 0;
2973
+ case 16:
2974
+ return t.t6 = t.t5, t.t7 = {
2975
+ dfp_telemetry_id: t.t3,
2976
+ captcha_token: t.t4,
2977
+ intermediate_session_token: t.t6
2978
+ }, t.t8 = t.t1.assign.call(t.t1, t.t2, t.t7), t.t9 = this.dfpProtectedAuth.retryWithCaptchaAndDFP, t.t10 = {
2958
2979
  url: "/b2b/totp",
2959
- body: Object.assign(Object.assign({}, e), {
2960
- dfp_telemetry_id: n,
2961
- captcha_token: i
2962
- }),
2980
+ body: t.t8,
2963
2981
  errorMessage: "Failed to create TOTP",
2964
2982
  method: "POST",
2965
- retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
2966
- }));
2967
- case 7:
2983
+ retryCallback: t.t9
2984
+ }, t.abrupt("return", t.t0.retriableFetchSDK.call(t.t0, t.t10));
2985
+ case 22:
2968
2986
  case "end":
2969
2987
  return t.stop();
2970
2988
  }
@@ -3021,6 +3039,106 @@ var tt = pe(function e(t, r) {
3021
3039
  }]), e;
3022
3040
  }(),
3023
3041
  nt = function () {
3042
+ function e(t, r) {
3043
+ var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : Ge();
3044
+ _e(this, e), this._networkClient = t, this._subscriptionService = r, this.dfpProtectedAuth = n;
3045
+ }
3046
+ return pe(e, [{
3047
+ key: "recover",
3048
+ value: function value(e) {
3049
+ return we(this, void 0, void 0, de().mark(function t() {
3050
+ var r, n, i, o, s;
3051
+ return de().wrap(function (t) {
3052
+ for (;;) switch (t.prev = t.next) {
3053
+ case 0:
3054
+ return qe("stytch.recoveryCodes.recover").isString("organization_id", e.organization_id).isString("member_id", e.member_id).isString("recovery_code", e.recovery_code), t.next = 3, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
3055
+ case 3:
3056
+ return r = t.sent, n = r.dfp_telemetry_id, i = r.captcha_token, t.t0 = Object, t.t1 = Object.assign({}, e), t.t2 = n, t.t3 = i, t.next = 12, this._subscriptionService.getIntermediateSessionToken();
3057
+ case 12:
3058
+ if (t.t4 = t.sent, t.t4) {
3059
+ t.next = 15;
3060
+ break;
3061
+ }
3062
+ t.t4 = void 0;
3063
+ case 15:
3064
+ return t.t5 = t.t4, t.t6 = {
3065
+ dfp_telemetry_id: t.t2,
3066
+ captcha_token: t.t3,
3067
+ intermediate_session_token: t.t5
3068
+ }, o = t.t0.assign.call(t.t0, t.t1, t.t6), t.next = 20, this._networkClient.retriableFetchSDK({
3069
+ url: "/b2b/recovery_codes/recover",
3070
+ body: o,
3071
+ errorMessage: "Failed to recover using recovery code",
3072
+ method: "POST",
3073
+ retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
3074
+ });
3075
+ case 20:
3076
+ return s = t.sent, this._subscriptionService.updateStateAndTokens({
3077
+ state: {
3078
+ session: s.member_session,
3079
+ member: s.member,
3080
+ organization: s.organization
3081
+ },
3082
+ session_token: s.session_token,
3083
+ session_jwt: s.session_jwt,
3084
+ intermediate_session_token: null
3085
+ }), t.abrupt("return", s);
3086
+ case 23:
3087
+ case "end":
3088
+ return t.stop();
3089
+ }
3090
+ }, t, this);
3091
+ }));
3092
+ }
3093
+ }, {
3094
+ key: "rotate",
3095
+ value: function value() {
3096
+ return we(this, void 0, void 0, de().mark(function e() {
3097
+ var t, r, n;
3098
+ return de().wrap(function (e) {
3099
+ for (;;) switch (e.prev = e.next) {
3100
+ case 0:
3101
+ return e.next = 2, this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
3102
+ case 2:
3103
+ return t = e.sent, r = t.dfp_telemetry_id, n = t.captcha_token, e.abrupt("return", this._networkClient.retriableFetchSDK({
3104
+ url: "/b2b/recovery_codes/rotate",
3105
+ body: {
3106
+ dfp_telemetry_id: r,
3107
+ captcha_token: n
3108
+ },
3109
+ errorMessage: "Failed to rotate recovery codes",
3110
+ method: "POST",
3111
+ retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
3112
+ }));
3113
+ case 6:
3114
+ case "end":
3115
+ return e.stop();
3116
+ }
3117
+ }, e, this);
3118
+ }));
3119
+ }
3120
+ }, {
3121
+ key: "get",
3122
+ value: function value() {
3123
+ return we(this, void 0, void 0, de().mark(function e() {
3124
+ return de().wrap(function (e) {
3125
+ for (;;) switch (e.prev = e.next) {
3126
+ case 0:
3127
+ return e.abrupt("return", this._networkClient.fetchSDK({
3128
+ url: "/b2b/recovery_codes",
3129
+ errorMessage: "Failed to get recovery codes",
3130
+ method: "GET"
3131
+ }));
3132
+ case 1:
3133
+ case "end":
3134
+ return e.stop();
3135
+ }
3136
+ }, e, this);
3137
+ }));
3138
+ }
3139
+ }]), e;
3140
+ }(),
3141
+ it = function () {
3024
3142
  function e(t, r, n) {
3025
3143
  var i = this;
3026
3144
  _e(this, e), this._subscriptionService = n, this.isAuthorizedSync = function (e, t) {
@@ -3030,8 +3148,8 @@ var tt = pe(function e(t, r) {
3030
3148
  return i.policyPromise.then(function (r) {
3031
3149
  return r.callerIsAuthorized(i.roleIds(), e, t);
3032
3150
  });
3033
- }, this.cachedPolicy = t.rbacPolicy ? ft.fromJSON(t.rbacPolicy) : null, this.policyPromise = r.then(function (e) {
3034
- return e.rbacPolicy ? (i.cachedPolicy = ft.fromJSON(e.rbacPolicy), i.cachedPolicy) : (Ke("Unable to retrieve RBAC policy from servers. Assuming caller has no permissions."), new ft([], []));
3151
+ }, this.cachedPolicy = t.rbacPolicy ? mt.fromJSON(t.rbacPolicy) : null, this.policyPromise = r.then(function (e) {
3152
+ return e.rbacPolicy ? (i.cachedPolicy = mt.fromJSON(e.rbacPolicy), i.cachedPolicy) : (Ne("Unable to retrieve RBAC policy from servers. Assuming caller has no permissions."), new mt([], []));
3035
3153
  });
3036
3154
  }
3037
3155
  return pe(e, [{
@@ -3051,7 +3169,7 @@ var tt = pe(function e(t, r) {
3051
3169
  }
3052
3170
  }]), e;
3053
3171
  }(),
3054
- it = function () {
3172
+ ot = function () {
3055
3173
  function e(t, r) {
3056
3174
  var n = this;
3057
3175
  _e(this, e), this._subscriptionService = t, this._headlessSessionClient = r, this._onDataChange = function (e) {
@@ -3095,7 +3213,7 @@ var tt = pe(function e(t, r) {
3095
3213
  this._reauthenticateWithBackoff().then(function () {
3096
3214
  e.scheduleBackgroundRefresh();
3097
3215
  })["catch"](function (t) {
3098
- Ne("Session background refresh failed. Signalling to app that user is logged out.", {
3216
+ Ke("Session background refresh failed. Signalling to app that user is logged out.", {
3099
3217
  error: t
3100
3218
  }), e._subscriptionService.destroyState();
3101
3219
  });
@@ -3121,13 +3239,12 @@ var tt = pe(function e(t, r) {
3121
3239
  }, {
3122
3240
  key: "isUnrecoverableError",
3123
3241
  value: function value(e) {
3124
- return A.includes(e.error_type);
3242
+ return C.includes(e.error_type);
3125
3243
  }
3126
3244
  }]), e;
3127
3245
  }();
3128
- it.REFRESH_INTERVAL_MS = 18e4;
3129
- var ot,
3130
- st,
3246
+ ot.REFRESH_INTERVAL_MS = 18e4;
3247
+ var st,
3131
3248
  at,
3132
3249
  ct,
3133
3250
  ut,
@@ -3136,7 +3253,8 @@ var ot,
3136
3253
  ht,
3137
3254
  pt,
3138
3255
  _t,
3139
- ft = function () {
3256
+ ft,
3257
+ mt = function () {
3140
3258
  function e(t, r) {
3141
3259
  var n = this;
3142
3260
  _e(this, e), this.roles = t, this.resources = r, this.rolesByID = {}, t.forEach(function (e) {
@@ -3177,7 +3295,7 @@ var ot,
3177
3295
  }
3178
3296
  }]), e;
3179
3297
  }();
3180
- function mt(e, t, r, n) {
3298
+ function vt(e, t, r, n) {
3181
3299
  return new (r || (r = Promise))(function (i, o) {
3182
3300
  function s(e) {
3183
3301
  try {
@@ -3204,61 +3322,61 @@ function mt(e, t, r, n) {
3204
3322
  }
3205
3323
  "function" == typeof SuppressedError && SuppressedError, function (e) {
3206
3324
  e.emailMagicLinks = "emailMagicLinks", e.oauth = "oauth", e.otp = "otp", e.crypto = "crypto", e.passwords = "passwords", e.passkeys = "passkeys";
3207
- }(ot || (ot = {})), function (e) {
3208
- e.Google = "google", e.Microsoft = "microsoft", e.Apple = "apple", e.Github = "github", e.GitLab = "gitlab", e.Facebook = "facebook", e.Discord = "discord", e.Salesforce = "salesforce", e.Slack = "slack", e.Amazon = "amazon", e.Bitbucket = "bitbucket", e.LinkedIn = "linkedin", e.Coinbase = "coinbase", e.Twitch = "twitch", e.Twitter = "twitter", e.TikTok = "tiktok", e.Snapchat = "snapchat", e.Figma = "figma", e.Yahoo = "yahoo";
3209
3325
  }(st || (st = {})), function (e) {
3210
- e.Vessel = "Vessel", e.Phantom = "Phantom", e.Metamask = "Metamask", e.Coinbase = "Coinbase", e.Binance = "Binance", e.GenericEthereumWallet = "Other Ethereum Wallet", e.GenericSolanaWallet = "Other Solana Wallet";
3326
+ e.Google = "google", e.Microsoft = "microsoft", e.Apple = "apple", e.Github = "github", e.GitLab = "gitlab", e.Facebook = "facebook", e.Discord = "discord", e.Salesforce = "salesforce", e.Slack = "slack", e.Amazon = "amazon", e.Bitbucket = "bitbucket", e.LinkedIn = "linkedin", e.Coinbase = "coinbase", e.Twitch = "twitch", e.Twitter = "twitter", e.TikTok = "tiktok", e.Snapchat = "snapchat", e.Figma = "figma", e.Yahoo = "yahoo";
3211
3327
  }(at || (at = {})), function (e) {
3212
- e.embedded = "embedded", e.floating = "floating";
3328
+ e.Vessel = "Vessel", e.Phantom = "Phantom", e.Metamask = "Metamask", e.Coinbase = "Coinbase", e.Binance = "Binance", e.GenericEthereumWallet = "Other Ethereum Wallet", e.GenericSolanaWallet = "Other Solana Wallet";
3213
3329
  }(ct || (ct = {})), function (e) {
3214
- e.SMS = "sms", e.WhatsApp = "whatsapp", e.Email = "email";
3330
+ e.embedded = "embedded", e.floating = "floating";
3215
3331
  }(ut || (ut = {})), function (e) {
3332
+ e.SMS = "sms", e.WhatsApp = "whatsapp", e.Email = "email";
3333
+ }(lt || (lt = {})), function (e) {
3216
3334
  e.MagicLinkLoginOrCreateEvent = "MAGIC_LINK_LOGIN_OR_CREATE", e.OTPsLoginOrCreateEvent = "OTP_LOGIN_OR_CREATE", e.OTPsAuthenticate = "OTP_AUTHENTICATE", e.CryptoWalletAuthenticateStart = "CRYPTO_WALLET_AUTHENTICATE_START", e.CryptoWalletAuthenticate = "CRYPTO_WALLET_AUTHENTICATE", e.PasswordCreate = "PASSWORD_CREATE", e.PasswordAuthenticate = "PASSWORD_AUTHENTICATE", e.PasswordResetByEmailStart = "PASSWORD_RESET_BY_EMAIL_START", e.PasswordResetByEmail = "PASSWORD_RESET_BY_EMAIL", e.PasskeyRegister = "PASSKEY_REGISTER", e.PasskeyAuthenticate = "PASSKEY_AUTHENTICATE", e.PasskeySkip = "PASSKEY_SKIP", e.PasskeyDone = "PASSKEY_DONE", e.B2BMagicLinkEmailLoginOrSignup = "B2B_MAGIC_LINK_EMAIL_LOGIN_OR_SIGNUP", e.B2BMagicLinkAuthenticate = "B2B_MAGIC_LINK_AUTHENTICATE", e.B2BMagicLinkEmailDiscoverySend = "B2B_MAGIC_LINK_EMAIL_DISCOVERY_SEND", e.B2BMagicLinkDiscoveryAuthenticate = "B2B_MAGIC_LINK_DISCOVERY_AUTHENTICATE", e.B2BSSOStart = "B2B_SSO_START", e.B2BSSOAuthenticate = "B2B_SSO_AUTHENTICATE", e.B2BOAuthAuthenticate = "B2B_OAUTH_AUTHENTICATE", e.B2BOAuthDiscoveryAuthenticate = "B2B_OAUTH_DISCOVERY_AUTHENTICATE", e.B2BDiscoveryOrganizationsCreate = "B2B_DISCOVERY_ORGANIZATIONS_CREATE", e.B2BDiscoveryIntermediateSessionExchange = "B2B_DISCOVERY_INTERMEDIATE_SESSION_EXCHANGE", e.B2BPasswordAuthenticate = "B2B_PASSWORD_AUTHENTICATE", e.B2BPasswordResetByEmailStart = "B2B_PASSWORD_RESET_BY_EMAIL_START", e.B2BPasswordResetByEmail = "B2B_PASSWORD_RESET_BY_EMAIL", e.B2BPasswordResetBySession = "B2B_PASSWORD_RESET_BY_SESSION";
3217
- }(lt || (lt = {}));
3218
- var vt = /*#__PURE__*/function (_Error) {
3219
- _inherits(vt, _Error);
3220
- var _super = _createSuper(vt);
3221
- function vt(e, t) {
3335
+ }(dt || (dt = {}));
3336
+ var bt = /*#__PURE__*/function (_Error) {
3337
+ _inherits(bt, _Error);
3338
+ var _super = _createSuper(bt);
3339
+ function bt(e, t) {
3222
3340
  var _this;
3223
- _classCallCheck(this, vt);
3341
+ _classCallCheck(this, bt);
3224
3342
  _this = _super.call(this), _this.name = "StytchSDKUsageError", _this.message = "Invalid call to ".concat(e, "\n") + t;
3225
3343
  return _this;
3226
3344
  }
3227
- return _createClass(vt);
3345
+ return _createClass(bt);
3228
3346
  }( /*#__PURE__*/_wrapNativeSuper(Error));
3229
3347
  !function (e) {
3230
3348
  e.emailMagicLinks = "emailMagicLinks", e.sso = "sso", e.passwords = "passwords", e.oauth = "oauth";
3231
- }(dt || (dt = {})), function (e) {
3232
- e.Discovery = "Discovery", e.Organization = "Organization", e.PasswordReset = "PasswordReset";
3233
3349
  }(ht || (ht = {})), function (e) {
3234
- e.Google = "google", e.Microsoft = "microsoft";
3350
+ e.Discovery = "Discovery", e.Organization = "Organization", e.PasswordReset = "PasswordReset";
3235
3351
  }(pt || (pt = {})), function (e) {
3352
+ e.Google = "google", e.Microsoft = "microsoft";
3353
+ }(_t || (_t = {})), function (e) {
3236
3354
  e.RequiredCatcha = "Catcha Required";
3237
- }(_t || (_t = {}));
3238
- var bt = function bt(e) {
3355
+ }(ft || (ft = {}));
3356
+ var gt = function gt(e) {
3239
3357
  var t = {
3240
3358
  isObject: function isObject(r, n) {
3241
- if (!("object" == _typeof(n) && !Array.isArray(n) && null !== n)) throw new vt(e, r + " must be an object.");
3359
+ if (!("object" == _typeof(n) && !Array.isArray(n) && null !== n)) throw new bt(e, r + " must be an object.");
3242
3360
  return t;
3243
3361
  },
3244
3362
  isOptionalObject: function isOptionalObject(e, r) {
3245
3363
  return void 0 === r ? t : t.isObject(e, r);
3246
3364
  },
3247
3365
  isString: function isString(r, n) {
3248
- if ("string" != typeof n) throw new vt(e, r + " must be a string.");
3366
+ if ("string" != typeof n) throw new bt(e, r + " must be a string.");
3249
3367
  return t;
3250
3368
  },
3251
3369
  isOptionalString: function isOptionalString(e, r) {
3252
3370
  return void 0 === r ? t : t.isString(e, r);
3253
3371
  },
3254
3372
  isStringArray: function isStringArray(r, n) {
3255
- if (!Array.isArray(n)) throw new vt(e, r + " must be an array of strings.");
3373
+ if (!Array.isArray(n)) throw new bt(e, r + " must be an array of strings.");
3256
3374
  var _iterator = _createForOfIteratorHelper(n),
3257
3375
  _step;
3258
3376
  try {
3259
3377
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
3260
3378
  var _t2 = _step.value;
3261
- if ("string" != typeof _t2) throw new vt(e, r + " must be an array of strings.");
3379
+ if ("string" != typeof _t2) throw new bt(e, r + " must be an array of strings.");
3262
3380
  }
3263
3381
  } catch (err) {
3264
3382
  _iterator.e(err);
@@ -3271,14 +3389,14 @@ var bt = function bt(e) {
3271
3389
  return void 0 === r ? t : t.isStringArray(e, r);
3272
3390
  },
3273
3391
  isNumber: function isNumber(r, n) {
3274
- if ("number" != typeof n) throw new vt(e, r + " must be a number.");
3392
+ if ("number" != typeof n) throw new bt(e, r + " must be a number.");
3275
3393
  return t;
3276
3394
  },
3277
3395
  isOptionalNumber: function isOptionalNumber(e, r) {
3278
3396
  return void 0 === r ? t : t.isNumber(e, r);
3279
3397
  },
3280
3398
  isBoolean: function isBoolean(r, n) {
3281
- if ("boolean" != typeof n) throw new vt(e, r + " must be a boolean.");
3399
+ if ("boolean" != typeof n) throw new bt(e, r + " must be a boolean.");
3282
3400
  return t;
3283
3401
  },
3284
3402
  isOptionalBoolean: function isOptionalBoolean(e, r) {
@@ -3287,26 +3405,26 @@ var bt = function bt(e) {
3287
3405
  };
3288
3406
  return t;
3289
3407
  };
3290
- var gt;
3408
+ var yt;
3291
3409
  !function (e) {
3292
3410
  e.LoginOrCreateEML = "login_or_create_eml", e.LoginOrCreateOTP = "login_or_create_otp", e.ResetPassword = "reset_password";
3293
- }(gt || (gt = {})), Promise.resolve({
3411
+ }(yt || (yt = {})), Promise.resolve({
3294
3412
  pkceRequiredForEmailMagicLinks: !1
3295
3413
  }), Promise.resolve({
3296
3414
  pkceRequiredForPasswordResets: !1
3297
3415
  }), Promise.resolve({
3298
3416
  pkceRequiredForEmailMagicLinks: !1
3299
3417
  });
3300
- var yt = Promise.resolve({
3418
+ var kt = Promise.resolve({
3301
3419
  pkceRequiredForPasswordResets: !1
3302
3420
  });
3303
- var kt = /*#__PURE__*/function () {
3304
- function kt(e, t, r) {
3305
- var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : yt;
3421
+ var wt = /*#__PURE__*/function () {
3422
+ function wt(e, t, r) {
3423
+ var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : kt;
3306
3424
  var i = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function () {
3307
3425
  return {
3308
3426
  isEnabled: function isEnabled() {
3309
- return mt(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3427
+ return vt(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
3310
3428
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3311
3429
  while (1) switch (_context.prev = _context.next) {
3312
3430
  case 0:
@@ -3319,7 +3437,7 @@ var kt = /*#__PURE__*/function () {
3319
3437
  }));
3320
3438
  },
3321
3439
  getTelemetryID: function getTelemetryID() {
3322
- return mt(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
3440
+ return vt(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
3323
3441
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3324
3442
  while (1) switch (_context2.prev = _context2.next) {
3325
3443
  case 0:
@@ -3330,7 +3448,7 @@ var kt = /*#__PURE__*/function () {
3330
3448
  }));
3331
3449
  },
3332
3450
  getDFPTelemetryIDAndCaptcha: function getDFPTelemetryIDAndCaptcha() {
3333
- return mt(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
3451
+ return vt(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
3334
3452
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3335
3453
  while (1) switch (_context3.prev = _context3.next) {
3336
3454
  case 0:
@@ -3346,7 +3464,7 @@ var kt = /*#__PURE__*/function () {
3346
3464
  }));
3347
3465
  },
3348
3466
  retryWithCaptchaAndDFP: function retryWithCaptchaAndDFP() {
3349
- return mt(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
3467
+ return vt(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
3350
3468
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3351
3469
  while (1) switch (_context4.prev = _context4.next) {
3352
3470
  case 0:
@@ -3360,13 +3478,13 @@ var kt = /*#__PURE__*/function () {
3360
3478
  }
3361
3479
  };
3362
3480
  }();
3363
- _classCallCheck(this, kt);
3481
+ _classCallCheck(this, wt);
3364
3482
  this._networkClient = e, this._subscriptionService = t, this._pkceManager = r, this._config = n, this.dfpProtectedAuth = i;
3365
3483
  }
3366
- _createClass(kt, [{
3484
+ _createClass(wt, [{
3367
3485
  key: "getCodeChallenge",
3368
3486
  value: function getCodeChallenge() {
3369
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
3487
+ return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
3370
3488
  var _yield$this$_config, e, t;
3371
3489
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
3372
3490
  while (1) switch (_context5.prev = _context5.next) {
@@ -3407,12 +3525,12 @@ var kt = /*#__PURE__*/function () {
3407
3525
  }, {
3408
3526
  key: "authenticate",
3409
3527
  value: function authenticate(e) {
3410
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
3528
+ return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
3411
3529
  var t, r, _yield$this$dfpProtec, n, i, o;
3412
3530
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
3413
3531
  while (1) switch (_context6.prev = _context6.next) {
3414
3532
  case 0:
3415
- bt("stytch.passwords.authenticate").isString("org_id", e.organization_id).isString("password", e.password).isString("email_address", e.email_address).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale);
3533
+ gt("stytch.passwords.authenticate").isString("org_id", e.organization_id).isString("password", e.password).isString("email_address", e.email_address).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale);
3416
3534
  _context6.next = 3;
3417
3535
  return this._pkceManager.getPKPair();
3418
3536
  case 3:
@@ -3468,12 +3586,12 @@ var kt = /*#__PURE__*/function () {
3468
3586
  }, {
3469
3587
  key: "resetByEmailStart",
3470
3588
  value: function resetByEmailStart(e) {
3471
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
3589
+ return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
3472
3590
  var t, _yield$this$dfpProtec2, r, n;
3473
3591
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
3474
3592
  while (1) switch (_context7.prev = _context7.next) {
3475
3593
  case 0:
3476
- bt("stytch.passwords.resetByEmailStart").isString("email", e.email_address).isOptionalString("login_redirect_url", e.login_redirect_url).isOptionalString("reset_password_redirect_url", e.reset_password_redirect_url).isOptionalString("reset_password_template_id", e.reset_password_template_id).isOptionalNumber("reset_password_expiration_minutes", e.reset_password_expiration_minutes);
3594
+ gt("stytch.passwords.resetByEmailStart").isString("email", e.email_address).isOptionalString("login_redirect_url", e.login_redirect_url).isOptionalString("reset_password_redirect_url", e.reset_password_redirect_url).isOptionalString("reset_password_template_id", e.reset_password_template_id).isOptionalNumber("reset_password_expiration_minutes", e.reset_password_expiration_minutes);
3477
3595
  _context7.next = 3;
3478
3596
  return this.getCodeChallenge();
3479
3597
  case 3:
@@ -3511,12 +3629,12 @@ var kt = /*#__PURE__*/function () {
3511
3629
  }, {
3512
3630
  key: "resetByEmail",
3513
3631
  value: function resetByEmail(e) {
3514
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
3632
+ return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
3515
3633
  var _yield$this$dfpProtec3, t, r, n, i, o;
3516
3634
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
3517
3635
  while (1) switch (_context8.prev = _context8.next) {
3518
3636
  case 0:
3519
- bt("stytch.passwords.resetByEmail").isString("password_reset_token", e.password_reset_token).isString("password", e.password).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale);
3637
+ gt("stytch.passwords.resetByEmail").isString("password_reset_token", e.password_reset_token).isString("password", e.password).isNumber("session_duration_minutes", e.session_duration_minutes).isOptionalString("locale", e.locale);
3520
3638
  _context8.next = 3;
3521
3639
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
3522
3640
  case 3:
@@ -3571,12 +3689,12 @@ var kt = /*#__PURE__*/function () {
3571
3689
  }, {
3572
3690
  key: "resetByExistingPassword",
3573
3691
  value: function resetByExistingPassword(e) {
3574
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
3692
+ return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
3575
3693
  var _yield$this$dfpProtec4, t, r, n;
3576
3694
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
3577
3695
  while (1) switch (_context9.prev = _context9.next) {
3578
3696
  case 0:
3579
- bt("stytch.passwords.resetByExistingPassword").isString("email", e.email_address).isString("existing_password", e.existing_password).isString("new_password", e.new_password).isOptionalString("locale", e.locale);
3697
+ gt("stytch.passwords.resetByExistingPassword").isString("email", e.email_address).isString("existing_password", e.existing_password).isString("new_password", e.new_password).isOptionalString("locale", e.locale);
3580
3698
  _context9.next = 3;
3581
3699
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
3582
3700
  case 3:
@@ -3626,12 +3744,12 @@ var kt = /*#__PURE__*/function () {
3626
3744
  }, {
3627
3745
  key: "resetBySession",
3628
3746
  value: function resetBySession(e) {
3629
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
3747
+ return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
3630
3748
  var _yield$this$dfpProtec5, t, r, n;
3631
3749
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
3632
3750
  while (1) switch (_context10.prev = _context10.next) {
3633
3751
  case 0:
3634
- bt("stytch.passwords.resetBySession").isString("password", e.password);
3752
+ gt("stytch.passwords.resetBySession").isString("password", e.password);
3635
3753
  _context10.next = 3;
3636
3754
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
3637
3755
  case 3:
@@ -3672,11 +3790,11 @@ var kt = /*#__PURE__*/function () {
3672
3790
  }, {
3673
3791
  key: "strengthCheck",
3674
3792
  value: function strengthCheck(e) {
3675
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
3793
+ return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
3676
3794
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
3677
3795
  while (1) switch (_context11.prev = _context11.next) {
3678
3796
  case 0:
3679
- return _context11.abrupt("return", (bt("stytch.passwords.strengthCheck").isOptionalString("email", e.email_address).isString("password", e.password), this._networkClient.fetchSDK({
3797
+ return _context11.abrupt("return", (gt("stytch.passwords.strengthCheck").isOptionalString("email", e.email_address).isString("password", e.password), this._networkClient.fetchSDK({
3680
3798
  url: "/b2b/passwords/strength_check",
3681
3799
  method: "POST",
3682
3800
  errorMessage: "Failed to check password strength.",
@@ -3693,21 +3811,21 @@ var kt = /*#__PURE__*/function () {
3693
3811
  }));
3694
3812
  }
3695
3813
  }]);
3696
- return kt;
3814
+ return wt;
3697
3815
  }();
3698
- var wt = "bootstrap";
3699
- var St = /*#__PURE__*/function () {
3700
- function St(e, t, r) {
3816
+ var St = "bootstrap";
3817
+ var Pt = /*#__PURE__*/function () {
3818
+ function Pt(e, t, r) {
3701
3819
  var _this2 = this;
3702
- _classCallCheck(this, St);
3820
+ _classCallCheck(this, Pt);
3703
3821
  this._publicToken = e, this._networkClient = t, this._dataLayer = r, this._bootstrapDataPromise = this._networkClient.fetchSDK({
3704
3822
  url: "/projects/bootstrap/".concat(this._publicToken),
3705
3823
  method: "GET",
3706
3824
  errorMessage: "Error fetching bootstrap data for SDK for ".concat(this._publicToken)
3707
- }).then(St.mapBootstrapData).then(function (e) {
3708
- return _this2._dataLayer.setItem(wt, JSON.stringify(e)), e;
3825
+ }).then(Pt.mapBootstrapData).then(function (e) {
3826
+ return _this2._dataLayer.setItem(St, JSON.stringify(e)), e;
3709
3827
  })["catch"](function (e) {
3710
- return Ke(e), {
3828
+ return Ne(e), {
3711
3829
  displayWatermark: !1,
3712
3830
  cnameDomain: null,
3713
3831
  emailDomains: ["stytch.com"],
@@ -3726,10 +3844,10 @@ var St = /*#__PURE__*/function () {
3726
3844
  };
3727
3845
  });
3728
3846
  }
3729
- _createClass(St, [{
3847
+ _createClass(Pt, [{
3730
3848
  key: "getSync",
3731
3849
  value: function getSync() {
3732
- var e = this._dataLayer.getItem(wt);
3850
+ var e = this._dataLayer.getItem(St);
3733
3851
  if (null === e) return {
3734
3852
  displayWatermark: !1,
3735
3853
  cnameDomain: null,
@@ -3800,13 +3918,39 @@ var St = /*#__PURE__*/function () {
3800
3918
  };
3801
3919
  }
3802
3920
  }]);
3803
- return St;
3921
+ return Pt;
3804
3922
  }();
3805
- var Pt = /*#__PURE__*/_createClass(function Pt(e) {
3923
+ function Ct(e, t, r, n) {
3924
+ return new (r || (r = Promise))(function (i, o) {
3925
+ function s(e) {
3926
+ try {
3927
+ c(n.next(e));
3928
+ } catch (e) {
3929
+ o(e);
3930
+ }
3931
+ }
3932
+ function a(e) {
3933
+ try {
3934
+ c(n["throw"](e));
3935
+ } catch (e) {
3936
+ o(e);
3937
+ }
3938
+ }
3939
+ function c(e) {
3940
+ var t;
3941
+ e.done ? i(e.value) : (t = e.value, t instanceof r ? t : new r(function (e) {
3942
+ e(t);
3943
+ })).then(s, a);
3944
+ }
3945
+ c((n = n.apply(e, t || [])).next());
3946
+ });
3947
+ }
3948
+ "function" == typeof SuppressedError && SuppressedError;
3949
+ var At = /*#__PURE__*/_createClass(function At(e) {
3806
3950
  var _this3 = this;
3807
- _classCallCheck(this, Pt);
3951
+ _classCallCheck(this, At);
3808
3952
  this.bootstrapPromise = e, this.executeRecaptcha = function () {
3809
- return mt(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
3953
+ return Ct(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
3810
3954
  var _yield$this$state, e, t, r;
3811
3955
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
3812
3956
  while (1) switch (_context12.prev = _context12.next) {
@@ -3837,7 +3981,7 @@ var Pt = /*#__PURE__*/_createClass(function Pt(e) {
3837
3981
  }, _callee12, this);
3838
3982
  }));
3839
3983
  }, this.state = e.then(function (e) {
3840
- return mt(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
3984
+ return Ct(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
3841
3985
  var t;
3842
3986
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
3843
3987
  while (1) switch (_context13.prev = _context13.next) {
@@ -3875,9 +4019,9 @@ var Pt = /*#__PURE__*/_createClass(function Pt(e) {
3875
4019
  }));
3876
4020
  });
3877
4021
  });
3878
- var At = /*#__PURE__*/function () {
3879
- function At(e, t, r, n) {
3880
- _classCallCheck(this, At);
4022
+ var Tt = /*#__PURE__*/function () {
4023
+ function Tt(e, t, r, n) {
4024
+ _classCallCheck(this, Tt);
3881
4025
  this._publicToken = e, this._subscriptionDataLayer = t, this.baseURL = r, this.additionalTelemetryDataFn = n, this.updateSessionToken = function () {
3882
4026
  return null;
3883
4027
  }, this.eventLogger = new He({
@@ -3886,7 +4030,7 @@ var At = /*#__PURE__*/function () {
3886
4030
  logEventURL: this.buildSDKUrl("/events")
3887
4031
  });
3888
4032
  }
3889
- _createClass(At, [{
4033
+ _createClass(Tt, [{
3890
4034
  key: "logEvent",
3891
4035
  value: function logEvent(_ref) {
3892
4036
  var e = _ref.name,
@@ -3906,9 +4050,9 @@ var At = /*#__PURE__*/function () {
3906
4050
  key: "createTelemetryBlob",
3907
4051
  value: function createTelemetryBlob() {
3908
4052
  return Object.assign(Object.assign({
3909
- event_id: "event-id-".concat(Re()),
3910
- app_session_id: "app-session-id-".concat(Re()),
3911
- persistent_id: "persistent-id-".concat(Re()),
4053
+ event_id: "event-id-".concat(Ie()),
4054
+ app_session_id: "app-session-id-".concat(Ie()),
4055
+ persistent_id: "persistent-id-".concat(Ie()),
3912
4056
  client_sent_at: new Date().toISOString(),
3913
4057
  timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
3914
4058
  }, this.additionalTelemetryDataFn()), {
@@ -3917,7 +4061,7 @@ var At = /*#__PURE__*/function () {
3917
4061
  },
3918
4062
  sdk: {
3919
4063
  identifier: "Stytch.js Javascript SDK",
3920
- version: "4.3.2"
4064
+ version: "4.4.1"
3921
4065
  }
3922
4066
  });
3923
4067
  }
@@ -3928,13 +4072,13 @@ var At = /*#__PURE__*/function () {
3928
4072
  t = _ref2.body,
3929
4073
  r = _ref2.errorMessage,
3930
4074
  n = _ref2.method;
3931
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
4075
+ return Ct(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
3932
4076
  var i, o, s, a;
3933
4077
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
3934
4078
  while (1) switch (_context14.prev = _context14.next) {
3935
4079
  case 0:
3936
4080
  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 _context14.abrupt("return", Ae({
4081
+ return _context14.abrupt("return", Ce({
3938
4082
  basicAuthHeader: o,
3939
4083
  body: t,
3940
4084
  errorMessage: r,
@@ -3958,7 +4102,7 @@ var At = /*#__PURE__*/function () {
3958
4102
  r = _ref3.errorMessage,
3959
4103
  n = _ref3.method,
3960
4104
  i = _ref3.retryCallback;
3961
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
4105
+ return Ct(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
3962
4106
  var o, s, a, c;
3963
4107
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
3964
4108
  while (1) switch (_context15.prev = _context15.next) {
@@ -3986,7 +4130,7 @@ var At = /*#__PURE__*/function () {
3986
4130
  xSDKClientHeader: o,
3987
4131
  xSDKParentHostHeader: s,
3988
4132
  body: a
3989
- }, e.prev = 1, e.next = 4, Ae(u);
4133
+ }, e.prev = 1, e.next = 4, Ce(u);
3990
4134
  case 4:
3991
4135
  case 15:
3992
4136
  return e.abrupt("return", e.sent);
@@ -3997,7 +4141,7 @@ var At = /*#__PURE__*/function () {
3997
4141
  }
3998
4142
  return e.next = 12, c(e.t0, u);
3999
4143
  case 12:
4000
- return u = e.sent, e.next = 15, Ae(u);
4144
+ return u = e.sent, e.next = 15, Ce(u);
4001
4145
  case 16:
4002
4146
  throw e.t0;
4003
4147
  case 17:
@@ -4029,18 +4173,18 @@ var At = /*#__PURE__*/function () {
4029
4173
  return "".concat(this.baseURL, "/sdk/v1").concat(e);
4030
4174
  }
4031
4175
  }]);
4032
- return At;
4176
+ return Tt;
4033
4177
  }();
4034
- function Ct(e) {
4178
+ function Ot(e) {
4035
4179
  var t = e.toString(16);
4036
4180
  return 1 === t.length && (t = "0" + t), t;
4037
4181
  }
4038
- var Tt = /*#__PURE__*/function () {
4039
- function Tt(e, t) {
4040
- _classCallCheck(this, Tt);
4182
+ var Et = /*#__PURE__*/function () {
4183
+ function Et(e, t) {
4184
+ _classCallCheck(this, Et);
4041
4185
  this._dataLayer = e, this.namespace = t;
4042
4186
  }
4043
- _createClass(Tt, [{
4187
+ _createClass(Et, [{
4044
4188
  key: "key",
4045
4189
  value: function key() {
4046
4190
  return "PKCE_VERIFIER:" + this.namespace;
@@ -4048,13 +4192,13 @@ var Tt = /*#__PURE__*/function () {
4048
4192
  }, {
4049
4193
  key: "startPKCETransaction",
4050
4194
  value: function startPKCETransaction() {
4051
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
4195
+ return Ct(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
4052
4196
  var e;
4053
4197
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
4054
4198
  while (1) switch (_context16.prev = _context16.next) {
4055
4199
  case 0:
4056
4200
  _context16.next = 2;
4057
- return Tt.createProofkeyPair();
4201
+ return Et.createProofkeyPair();
4058
4202
  case 2:
4059
4203
  e = _context16.sent;
4060
4204
  return _context16.abrupt("return", (this._dataLayer.setItem(this.key(), JSON.stringify(e)), e));
@@ -4072,7 +4216,7 @@ var Tt = /*#__PURE__*/function () {
4072
4216
  if (null !== e) try {
4073
4217
  return JSON.parse(e);
4074
4218
  } catch (e) {
4075
- return void Ne("Found malformed Proof Key pair in localstorage.");
4219
+ return void Ke("Found malformed Proof Key pair in localstorage.");
4076
4220
  }
4077
4221
  }
4078
4222
  }, {
@@ -4083,7 +4227,7 @@ var Tt = /*#__PURE__*/function () {
4083
4227
  }], [{
4084
4228
  key: "createProofkeyPair",
4085
4229
  value: function createProofkeyPair() {
4086
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
4230
+ return Ct(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
4087
4231
  var _String$fromCharCode;
4088
4232
  var e, t, r, n;
4089
4233
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
@@ -4091,7 +4235,7 @@ var Tt = /*#__PURE__*/function () {
4091
4235
  case 0:
4092
4236
  e = new Uint32Array(16);
4093
4237
  window.crypto.getRandomValues(e);
4094
- t = Array.from(e).map(Ct).join("");
4238
+ t = Array.from(e).map(Ot).join("");
4095
4239
  _context17.next = 5;
4096
4240
  return window.crypto.subtle.digest("SHA-256", new TextEncoder().encode(t));
4097
4241
  case 5:
@@ -4108,14 +4252,14 @@ var Tt = /*#__PURE__*/function () {
4108
4252
  }));
4109
4253
  }
4110
4254
  }]);
4111
- return Tt;
4255
+ return Et;
4112
4256
  }();
4113
- var Ot = /*#__PURE__*/function () {
4114
- function Ot(e) {
4115
- _classCallCheck(this, Ot);
4257
+ var xt = /*#__PURE__*/function () {
4258
+ function xt(e) {
4259
+ _classCallCheck(this, xt);
4116
4260
  this._networkClient = e;
4117
4261
  }
4118
- _createClass(Ot, [{
4262
+ _createClass(xt, [{
4119
4263
  key: "searchUser",
4120
4264
  value: function searchUser(e) {
4121
4265
  return this._networkClient.fetchSDK({
@@ -4153,9 +4297,9 @@ var Ot = /*#__PURE__*/function () {
4153
4297
  });
4154
4298
  }
4155
4299
  }]);
4156
- return Ot;
4300
+ return xt;
4157
4301
  }();
4158
- var Et = function Et(e) {
4302
+ var Dt = function Dt(e) {
4159
4303
  return (document.cookie ? document.cookie.split("; ") : []).filter(function (t) {
4160
4304
  var _t$split = t.split("="),
4161
4305
  _t$split2 = _slicedToArray(_t$split, 1),
@@ -4164,17 +4308,17 @@ var Et = function Et(e) {
4164
4308
  }).length > 1;
4165
4309
  };
4166
4310
  /*! js-cookie v3.0.1 | MIT */
4167
- function xt(e) {
4311
+ function It(e) {
4168
4312
  for (var t = 1; t < arguments.length; t++) {
4169
4313
  var r = arguments[t];
4170
4314
  for (var n in r) e[n] = r[n];
4171
4315
  }
4172
4316
  return e;
4173
4317
  }
4174
- var Dt = function e(t, r) {
4318
+ var Rt = function e(t, r) {
4175
4319
  function n(e, n, i) {
4176
4320
  if ("undefined" != typeof document) {
4177
- "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);
4321
+ "number" == typeof (i = It({}, 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);
4178
4322
  var o = "";
4179
4323
  for (var s in i) i[s] && (o += "; " + s, !0 !== i[s] && (o += "=" + i[s].split(";")[0]));
4180
4324
  return document.cookie = e + "=" + t.write(n, e) + o;
@@ -4196,15 +4340,15 @@ var Dt = function e(t, r) {
4196
4340
  }
4197
4341
  },
4198
4342
  remove: function remove(e, t) {
4199
- n(e, "", xt({}, t, {
4343
+ n(e, "", It({}, t, {
4200
4344
  expires: -1
4201
4345
  }));
4202
4346
  },
4203
4347
  withAttributes: function withAttributes(t) {
4204
- return e(this.converter, xt({}, this.attributes, t));
4348
+ return e(this.converter, It({}, this.attributes, t));
4205
4349
  },
4206
4350
  withConverter: function withConverter(t) {
4207
- return e(xt({}, this.converter, t), this.attributes);
4351
+ return e(It({}, this.converter, t), this.attributes);
4208
4352
  }
4209
4353
  }, {
4210
4354
  attributes: {
@@ -4224,26 +4368,26 @@ var Dt = function e(t, r) {
4224
4368
  }, {
4225
4369
  path: "/"
4226
4370
  });
4227
- var Rt = function Rt(e) {
4371
+ var Bt = function Bt(e) {
4228
4372
  var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
4229
4373
  return "stytch_sdk_state_".concat(e).concat(t ? "::".concat(t) : "");
4230
4374
  };
4231
- var It = /*#__PURE__*/function () {
4232
- function It(e, t) {
4375
+ var Lt = /*#__PURE__*/function () {
4376
+ function Lt(e, t) {
4233
4377
  var _this4 = this;
4234
- _classCallCheck(this, It);
4378
+ _classCallCheck(this, Lt);
4235
4379
  this.browserSessionStorage = {
4236
4380
  getItem: function getItem(e) {
4237
- return sessionStorage.getItem(Rt(_this4.publicToken, e));
4381
+ return sessionStorage.getItem(Bt(_this4.publicToken, e));
4238
4382
  },
4239
4383
  setItem: function setItem(e, t) {
4240
- return sessionStorage.setItem(Rt(_this4.publicToken, e), t);
4384
+ return sessionStorage.setItem(Bt(_this4.publicToken, e), t);
4241
4385
  },
4242
4386
  removeItem: function removeItem(e) {
4243
- return sessionStorage.removeItem(Rt(_this4.publicToken, e));
4387
+ return sessionStorage.removeItem(Bt(_this4.publicToken, e));
4244
4388
  }
4245
4389
  }, this.publicToken = e, this.state = null, this.stateKeysUpdated = new Set(), this.subscriptions = {}, (null == t ? void 0 : t.cookieOptions) ? (qe("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);
4246
- var r = localStorage.getItem(Rt(this.publicToken));
4390
+ var r = localStorage.getItem(Bt(this.publicToken));
4247
4391
  if (!r) return;
4248
4392
  var n;
4249
4393
  try {
@@ -4253,7 +4397,7 @@ var It = /*#__PURE__*/function () {
4253
4397
  }
4254
4398
  this.state = n;
4255
4399
  }
4256
- _createClass(It, [{
4400
+ _createClass(Lt, [{
4257
4401
  key: "opaqueTokenCookieName",
4258
4402
  get: function get() {
4259
4403
  var e;
@@ -4275,14 +4419,14 @@ var It = /*#__PURE__*/function () {
4275
4419
  key: "readSessionCookie",
4276
4420
  value: function readSessionCookie() {
4277
4421
  return {
4278
- session_token: Dt.get(this.opaqueTokenCookieName),
4279
- session_jwt: Dt.get(this.jwtCookieName)
4422
+ session_token: Rt.get(this.opaqueTokenCookieName),
4423
+ session_jwt: Rt.get(this.jwtCookieName)
4280
4424
  };
4281
4425
  }
4282
4426
  }, {
4283
4427
  key: "readIntermediateSessionTokenCookie",
4284
4428
  value: function readIntermediateSessionTokenCookie() {
4285
- return Dt.get(this.istCookieName);
4429
+ return Rt.get(this.istCookieName);
4286
4430
  }
4287
4431
  }, {
4288
4432
  key: "writeSessionCookie",
@@ -4291,32 +4435,32 @@ var It = /*#__PURE__*/function () {
4291
4435
  var o = e.state,
4292
4436
  s = e.session_token,
4293
4437
  a = e.session_jwt,
4294
- c = It.generateCookieOpts({
4438
+ c = Lt.generateCookieOpts({
4295
4439
  expiresAt: null !== (r = null === (t = null == o ? void 0 : o.session) || void 0 === t ? void 0 : t.expires_at) && void 0 !== r ? r : "",
4296
4440
  availableToSubdomains: this._cookieAvailableToSubdomains,
4297
4441
  path: this._cookiePath,
4298
4442
  domain: this._domain
4299
4443
  });
4300
- Dt.set(this.opaqueTokenCookieName, s, c), Dt.set(this.jwtCookieName, a, c);
4301
- var u = It.generateCookieOpts({
4444
+ Rt.set(this.opaqueTokenCookieName, s, c), Rt.set(this.jwtCookieName, a, c);
4445
+ var u = Lt.generateCookieOpts({
4302
4446
  expiresAt: null !== (i = null === (n = null == o ? void 0 : o.session) || void 0 === n ? void 0 : n.expires_at) && void 0 !== i ? i : "",
4303
4447
  availableToSubdomains: !this._cookieAvailableToSubdomains,
4304
4448
  path: this._cookiePath,
4305
4449
  domain: this._domain
4306
4450
  });
4307
- Et(this.jwtCookieName) && Dt.remove(this.jwtCookieName, u), Et(this.opaqueTokenCookieName) && Dt.remove(this.opaqueTokenCookieName, u), Et(this.jwtCookieName) && Ne("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), Et(this.opaqueTokenCookieName) && Ne("Could not remove extraneous opaque token cookie.");
4451
+ Dt(this.jwtCookieName) && Rt.remove(this.jwtCookieName, u), Dt(this.opaqueTokenCookieName) && Rt.remove(this.opaqueTokenCookieName, u), Dt(this.jwtCookieName) && Ke("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."), Dt(this.opaqueTokenCookieName) && Ke("Could not remove extraneous opaque token cookie.");
4308
4452
  }
4309
4453
  }, {
4310
4454
  key: "writeIntermediateSessionTokenCookie",
4311
4455
  value: function writeIntermediateSessionTokenCookie(e) {
4312
4456
  var t = new Date(Date.now() + 6e5),
4313
- r = It.generateCookieOpts({
4457
+ r = Lt.generateCookieOpts({
4314
4458
  expiresAt: t.toString(),
4315
4459
  availableToSubdomains: this._cookieAvailableToSubdomains,
4316
4460
  path: this._cookiePath,
4317
4461
  domain: this._domain
4318
4462
  });
4319
- Dt.set(this.istCookieName, e, r);
4463
+ Rt.set(this.istCookieName, e, r);
4320
4464
  }
4321
4465
  }, {
4322
4466
  key: "removeSessionCookie",
@@ -4335,14 +4479,14 @@ var It = /*#__PURE__*/function () {
4335
4479
  [!0, !1].forEach(function (t) {
4336
4480
  [_this5._cookiePath, null].forEach(function (r) {
4337
4481
  [_this5._domain, null].forEach(function (n) {
4338
- var i = It.generateCookieOpts({
4482
+ var i = Lt.generateCookieOpts({
4339
4483
  expiresAt: new Date(0).toString(),
4340
4484
  availableToSubdomains: t,
4341
4485
  path: r,
4342
4486
  domain: n
4343
4487
  });
4344
4488
  e.forEach(function (e) {
4345
- Dt.remove(e, i);
4489
+ Rt.remove(e, i);
4346
4490
  });
4347
4491
  });
4348
4492
  });
@@ -4351,22 +4495,22 @@ var It = /*#__PURE__*/function () {
4351
4495
  }, {
4352
4496
  key: "syncToLocalStorage",
4353
4497
  value: function syncToLocalStorage() {
4354
- localStorage.setItem(Rt(this.publicToken), JSON.stringify(this.state));
4498
+ localStorage.setItem(Bt(this.publicToken), JSON.stringify(this.state));
4355
4499
  }
4356
4500
  }, {
4357
4501
  key: "getItem",
4358
4502
  value: function getItem(e) {
4359
- return localStorage.getItem(Rt(this.publicToken, e));
4503
+ return localStorage.getItem(Bt(this.publicToken, e));
4360
4504
  }
4361
4505
  }, {
4362
4506
  key: "setItem",
4363
4507
  value: function setItem(e, t) {
4364
- return localStorage.setItem(Rt(this.publicToken, e), t);
4508
+ return localStorage.setItem(Bt(this.publicToken, e), t);
4365
4509
  }
4366
4510
  }, {
4367
4511
  key: "removeItem",
4368
4512
  value: function removeItem(e) {
4369
- return localStorage.removeItem(Rt(this.publicToken, e));
4513
+ return localStorage.removeItem(Bt(this.publicToken, e));
4370
4514
  }
4371
4515
  }, {
4372
4516
  key: "markStateKeysUpdated",
@@ -4391,31 +4535,31 @@ var It = /*#__PURE__*/function () {
4391
4535
  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;
4392
4536
  }
4393
4537
  }]);
4394
- return It;
4538
+ return Lt;
4395
4539
  }();
4396
- var Bt = /*#__PURE__*/function (_It) {
4397
- _inherits(Bt, _It);
4398
- var _super2 = _createSuper(Bt);
4399
- function Bt() {
4400
- _classCallCheck(this, Bt);
4540
+ var Mt = /*#__PURE__*/function (_Lt) {
4541
+ _inherits(Mt, _Lt);
4542
+ var _super2 = _createSuper(Mt);
4543
+ function Mt() {
4544
+ _classCallCheck(this, Mt);
4401
4545
  return _super2.apply(this, arguments);
4402
4546
  }
4403
- return _createClass(Bt);
4404
- }(It);
4405
- var Lt = Symbol["for"]("__stytch_b2b_DataLayer"),
4406
- Mt = function Mt(e, t) {
4547
+ return _createClass(Mt);
4548
+ }(Lt);
4549
+ var Ft = Symbol["for"]("__stytch_b2b_DataLayer"),
4550
+ jt = function jt(e, t) {
4407
4551
  var r = function () {
4408
4552
  var e = window;
4409
- return e[Lt] || (e[Lt] = {}), e[Lt];
4553
+ return e[Ft] || (e[Ft] = {}), e[Ft];
4410
4554
  }();
4411
- return r[e] || (r[e] = new Bt(e, t)), r[e];
4555
+ return r[e] || (r[e] = new Mt(e, t)), r[e];
4412
4556
  },
4413
- jt = function jt(e, t) {
4557
+ Kt = function Kt(e, t) {
4414
4558
  Object.values(e).forEach(function (e) {
4415
4559
  return e(t);
4416
4560
  });
4417
4561
  },
4418
- Ft = function () {
4562
+ Nt = function () {
4419
4563
  var e = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).KEYS_TO_EXCLUDE,
4420
4564
  t = void 0 === e ? [] : e;
4421
4565
  return function e(r, n) {
@@ -4434,12 +4578,12 @@ var Lt = Symbol["for"]("__stytch_b2b_DataLayer"),
4434
4578
  }({
4435
4579
  KEYS_TO_EXCLUDE: ["last_accessed_at"]
4436
4580
  });
4437
- var Nt = /*#__PURE__*/function () {
4438
- function Nt(e, t) {
4581
+ var zt = /*#__PURE__*/function () {
4582
+ function zt(e, t) {
4439
4583
  var _this7 = this;
4440
- _classCallCheck(this, Nt);
4584
+ _classCallCheck(this, zt);
4441
4585
  this._publicToken = e, this._datalayer = t, this._listen = function (e) {
4442
- if (e.key !== Rt(_this7._publicToken)) return;
4586
+ if (e.key !== Bt(_this7._publicToken)) return;
4443
4587
  if (null === e.newValue || "null" === e.newValue) return void _this7.destroyState();
4444
4588
  var t = JSON.parse(e.newValue);
4445
4589
  _this7.updateState(t);
@@ -4448,7 +4592,7 @@ var Nt = /*#__PURE__*/function () {
4448
4592
  r = _this$_datalayer$read.session_token;
4449
4593
  r || this.destroyState();
4450
4594
  }
4451
- _createClass(Nt, [{
4595
+ _createClass(zt, [{
4452
4596
  key: "getTokens",
4453
4597
  value: function getTokens() {
4454
4598
  var _this$_datalayer$read2 = this._datalayer.readSessionCookie(),
@@ -4481,7 +4625,7 @@ var Nt = /*#__PURE__*/function () {
4481
4625
  r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4482
4626
  this._datalayer.state = r;
4483
4627
  var n = e.state ? Object.keys(e.state) : [];
4484
- !this._datalayer.markStateKeysUpdated(n) && Ft(t, r) || jt(this._datalayer.subscriptions, r);
4628
+ !this._datalayer.markStateKeysUpdated(n) && Nt(t, r) || Kt(this._datalayer.subscriptions, r);
4485
4629
  }
4486
4630
  }, {
4487
4631
  key: "updateStateAndTokens",
@@ -4496,8 +4640,8 @@ var Nt = /*#__PURE__*/function () {
4496
4640
  this._datalayer.state = r;
4497
4641
  var n = e ? Object.keys(e) : [],
4498
4642
  i = this._datalayer.markStateKeysUpdated(n),
4499
- o = !Ft(t, r);
4500
- (i || o) && (jt(this._datalayer.subscriptions, r), o && this._datalayer.syncToLocalStorage());
4643
+ o = !Nt(t, r);
4644
+ (i || o) && (Kt(this._datalayer.subscriptions, r), o && this._datalayer.syncToLocalStorage());
4501
4645
  }
4502
4646
  }, {
4503
4647
  key: "updateTokens",
@@ -4537,14 +4681,14 @@ var Nt = /*#__PURE__*/function () {
4537
4681
  return null;
4538
4682
  }
4539
4683
  }]);
4540
- return Nt;
4684
+ return zt;
4541
4685
  }();
4542
- var Kt = /*#__PURE__*/function (_Nt) {
4543
- _inherits(Kt, _Nt);
4544
- var _super3 = _createSuper(Kt);
4545
- function Kt() {
4686
+ var Ut = /*#__PURE__*/function (_zt) {
4687
+ _inherits(Ut, _zt);
4688
+ var _super3 = _createSuper(Ut);
4689
+ function Ut() {
4546
4690
  var _this8;
4547
- _classCallCheck(this, Kt);
4691
+ _classCallCheck(this, Ut);
4548
4692
  _this8 = _super3.apply(this, arguments), _this8.updateMember = function (e) {
4549
4693
  return _this8.updateState({
4550
4694
  member: e
@@ -4565,16 +4709,16 @@ var Kt = /*#__PURE__*/function (_Nt) {
4565
4709
  };
4566
4710
  return _this8;
4567
4711
  }
4568
- return _createClass(Kt);
4569
- }(Nt);
4570
- var zt = Symbol["for"]("stytch__internal_b2b");
4571
- var Ut = /*#__PURE__*/_createClass(function Ut(e, t) {
4712
+ return _createClass(Ut);
4713
+ }(zt);
4714
+ var qt = Symbol["for"]("stytch__internal_b2b");
4715
+ var Wt = /*#__PURE__*/_createClass(function Wt(e, t) {
4572
4716
  var _this9 = this;
4573
- _classCallCheck(this, Ut);
4717
+ _classCallCheck(this, Wt);
4574
4718
  var r;
4575
4719
  !function (e) {
4576
4720
  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"));
4577
- }("StytchB2BHeadlessClient"), "string" != typeof (r = e) ? Ne("Public token is malformed. Expected a string, got ".concat(le(r), ".").concat(ze)) : "" === r ? Ne('Public token is malformed. Expected "public-token-...", got an empty string.'.concat(ze)) : r.startsWith("public-token-") || Ne('Public token is malformed. Expected "public-token-...", got '.concat(r, ".").concat(ze));
4721
+ }("StytchB2BHeadlessClient"), "string" != typeof (r = e) ? Ke("Public token is malformed. Expected a string, got ".concat(le(r), ".").concat(ze)) : "" === r ? Ke('Public token is malformed. Expected "public-token-...", got an empty string.'.concat(ze)) : r.startsWith("public-token-") || Ke('Public token is malformed. Expected "public-token-...", got '.concat(r, ".").concat(ze));
4578
4722
  var n = t,
4579
4723
  i = {
4580
4724
  cookieOptions: null == (o = n) ? void 0 : o.cookieOptions,
@@ -4587,28 +4731,28 @@ var Ut = /*#__PURE__*/_createClass(function Ut(e, t) {
4587
4731
  }
4588
4732
  };
4589
4733
  var o, s, a, c, u, l, d, h, p, _, f;
4590
- this._dataLayer = Mt(e, n), this._subscriptionService = new Kt(e, this._dataLayer);
4591
- var m = new Tt(this._dataLayer, "passwords");
4592
- this._networkClient = new At(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4734
+ this._dataLayer = jt(e, n), this._subscriptionService = new Ut(e, this._dataLayer);
4735
+ var m = new Et(this._dataLayer, "passwords");
4736
+ this._networkClient = new Tt(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4593
4737
  var e, t, r, n;
4594
4738
  return {
4595
4739
  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,
4596
4740
  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
4597
4741
  };
4598
4742
  });
4599
- var v = new St(e, this._networkClient, this._dataLayer),
4600
- b = new Pt(v.getAsync()),
4743
+ var v = new Pt(e, this._networkClient, this._dataLayer),
4744
+ b = new At(v.getAsync()),
4601
4745
  g = new We(e, i.endpoints.dfpBackendURL, v.getAsync(), b.executeRecaptcha);
4602
- this.organization = new Xe(this._networkClient, this._subscriptionService), this.member = new Je(this._networkClient, this._subscriptionService), this.self = new Je(this._networkClient, this._subscriptionService), this.session = new Qe(this._networkClient, this._subscriptionService), this.magicLinks = new Ve(this._networkClient, this._subscriptionService, new Tt(this._dataLayer, "magic_links"), m, v.getAsync(), g), this.oauth = new Ze(this._networkClient, this._subscriptionService, new Tt(this._dataLayer, "oauth"), v.getAsync(), {
4746
+ this.organization = new Xe(this._networkClient, this._subscriptionService), this.member = new Je(this._networkClient, this._subscriptionService), this.self = new Je(this._networkClient, this._subscriptionService), this.session = new Qe(this._networkClient, this._subscriptionService), this.magicLinks = new Ve(this._networkClient, this._subscriptionService, new Et(this._dataLayer, "magic_links"), m, v.getAsync(), g), this.oauth = new Ze(this._networkClient, this._subscriptionService, new Et(this._dataLayer, "oauth"), v.getAsync(), {
4603
4747
  publicToken: e,
4604
4748
  testAPIURL: i.endpoints.testAPIURL,
4605
4749
  liveAPIURL: i.endpoints.liveAPIURL
4606
- }, g), this.sso = new $e(this._networkClient, this._subscriptionService, new Tt(this._dataLayer, "sso"), v.getAsync(), {
4750
+ }, g), this.sso = new $e(this._networkClient, this._subscriptionService, new Et(this._dataLayer, "sso"), v.getAsync(), {
4607
4751
  publicToken: e,
4608
4752
  testAPIURL: i.endpoints.testAPIURL,
4609
4753
  liveAPIURL: i.endpoints.liveAPIURL
4610
- }), this.discovery = new et(this._networkClient, this._subscriptionService), this.passwords = new kt(this._networkClient, this._subscriptionService, m, v.getAsync(), g), this.otps = new tt(this._networkClient, this._subscriptionService, g), this.totp = new rt(this._networkClient, this._subscriptionService, g), this.rbac = new nt(v.getSync(), v.getAsync(), this._subscriptionService), this._sessionManager = new it(this._subscriptionService, this.session);
4611
- var y = new Ot(this._networkClient);
4754
+ }), this.discovery = new et(this._networkClient, this._subscriptionService), this.passwords = new wt(this._networkClient, this._subscriptionService, m, v.getAsync(), g), this.otps = new tt(this._networkClient, this._subscriptionService, g), this.totp = new rt(this._networkClient, this._subscriptionService, g), this.recoveryCodes = new nt(this._networkClient, this._subscriptionService, g), this.rbac = new it(v.getSync(), v.getAsync(), this._subscriptionService), this._sessionManager = new ot(this._subscriptionService, this.session);
4755
+ var y = new xt(this._networkClient);
4612
4756
  this._dataLayer.readSessionCookie().session_token && this._sessionManager.performBackgroundRefresh(), this._networkClient.logEvent({
4613
4757
  name: "b2b_sdk_instance_instantiated",
4614
4758
  details: {
@@ -4618,7 +4762,7 @@ var Ut = /*#__PURE__*/_createClass(function Ut(e, t) {
4618
4762
  }
4619
4763
  });
4620
4764
  (function (e, t) {
4621
- Object.assign(e, _defineProperty({}, zt, t));
4765
+ Object.assign(e, _defineProperty({}, qt, t));
4622
4766
  })(this, {
4623
4767
  bootstrap: v,
4624
4768
  publicToken: e,
@@ -4627,4 +4771,4 @@ var Ut = /*#__PURE__*/_createClass(function Ut(e, t) {
4627
4771
  networkClient: this._networkClient
4628
4772
  });
4629
4773
  });
4630
- export { g as AuthFlowType, y as B2BOAuthProviders, b as B2BProducts, X as BiometricsFailedError, B as BiometricsUnavailableError, H as ChallengeSigningFailedError, K as DeviceCredentialsNotAllowedError, V as FailedCodeChallengeError, $ as FailedToDecryptDataError, R as InternalError, W as InvalidAuthorizationCredentialError, te as InvalidCredentialTypeError, Q as InvalidRedirectSchemeError, Z as InvalidStartUrlError, ne as JSONDataNotConvertibleToStringError, L as KeyInvalidatedError, M as KeystoreUnavailableError, re as MissingAttestationObjectError, q as MissingAuthorizationCredentialIDTokenError, z as MissingGoogleClientIDError, U as MissingPKCEError, G as MissingPublicKeyError, ee as MissingUrlError, j as NoBiometricsEnrolledError, I as NoBiometricsRegistrationError, D as NoCurrentSessionError, p as OAuthProviders, m as OTPMethods, f as OneTapPositions, oe as PasskeysInvalidEncoding, J as PasskeysUnsupportedError, h as Products, ie as RandomNumberGenerationFailed, k as SDKAPIUnreachableError, Y as SDKNotConfiguredError, E as StytchAPIError, O as StytchAPISchemaError, T as StytchAPIUnreachableError, Ut as StytchB2BHeadlessClient, C as StytchError, v as StytchEventType, P as StytchSDKAPIError, x as StytchSDKError, S as StytchSDKSchemaError, w as StytchSDKUsageError, A as UNRECOVERABLE_ERROR_TYPES, F as UserCancellationError, N as UserLockedOutError, _ as Wallets, se as errorToStytchError };
4774
+ export { g as AuthFlowType, y as B2BOAuthProviders, b as B2BProducts, X as BiometricsFailedError, B as BiometricsUnavailableError, H as ChallengeSigningFailedError, N as DeviceCredentialsNotAllowedError, V as FailedCodeChallengeError, $ as FailedToDecryptDataError, I as InternalError, W as InvalidAuthorizationCredentialError, te as InvalidCredentialTypeError, Q as InvalidRedirectSchemeError, Z as InvalidStartUrlError, ne as JSONDataNotConvertibleToStringError, L as KeyInvalidatedError, M as KeystoreUnavailableError, re as MissingAttestationObjectError, q as MissingAuthorizationCredentialIDTokenError, z as MissingGoogleClientIDError, U as MissingPKCEError, G as MissingPublicKeyError, ee as MissingUrlError, F as NoBiometricsEnrolledError, R as NoBiometricsRegistrationError, D as NoCurrentSessionError, p as OAuthProviders, m as OTPMethods, f as OneTapPositions, oe as PasskeysInvalidEncoding, J as PasskeysUnsupportedError, h as Products, ie as RandomNumberGenerationFailed, k as SDKAPIUnreachableError, Y as SDKNotConfiguredError, E as StytchAPIError, O as StytchAPISchemaError, T as StytchAPIUnreachableError, Wt as StytchB2BHeadlessClient, A as StytchError, v as StytchEventType, P as StytchSDKAPIError, x as StytchSDKError, S as StytchSDKSchemaError, w as StytchSDKUsageError, C as UNRECOVERABLE_ERROR_TYPES, j as UserCancellationError, K as UserLockedOutError, _ as Wallets, se as errorToStytchError };