@stytch/vanilla-js 4.3.1 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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();
@@ -2641,36 +2641,55 @@ var Ye = Promise.resolve({
2641
2641
  }));
2642
2642
  }, this.authenticate = function (e) {
2643
2643
  return we(n, void 0, void 0, de().mark(function t() {
2644
- var r, n;
2644
+ var r,
2645
+ n,
2646
+ i,
2647
+ o,
2648
+ s = this;
2645
2649
  return de().wrap(function (t) {
2646
2650
  for (;;) switch (t.prev = t.next) {
2647
2651
  case 0:
2648
- return t.prev = 0, r = {
2652
+ return r = this._subscriptionService.getSession(), n = function n() {
2653
+ var e;
2654
+ return (null == r ? void 0 : r.member_session_id) !== (null === (e = s._subscriptionService.getSession()) || void 0 === e ? void 0 : e.member_session_id);
2655
+ }, t.prev = 2, i = {
2649
2656
  session_duration_minutes: null == e ? void 0 : e.session_duration_minutes
2650
- }, t.next = 4, this._networkClient.fetchSDK({
2657
+ }, t.next = 6, this._networkClient.fetchSDK({
2651
2658
  url: "/b2b/sessions/authenticate",
2652
- body: r,
2659
+ body: i,
2653
2660
  errorMessage: "Error authenticating session",
2654
2661
  method: "POST"
2655
2662
  });
2656
- case 4:
2657
- return n = t.sent, this._subscriptionService.updateStateAndTokens({
2663
+ case 6:
2664
+ if (o = t.sent, !n()) {
2665
+ t.next = 9;
2666
+ break;
2667
+ }
2668
+ return t.abrupt("return", this.authenticate(e));
2669
+ case 9:
2670
+ return this._subscriptionService.updateStateAndTokens({
2658
2671
  state: {
2659
- session: n.member_session,
2660
- member: n.member,
2661
- organization: n.organization
2672
+ session: o.member_session,
2673
+ member: o.member,
2674
+ organization: o.organization
2662
2675
  },
2663
- session_token: n.session_token,
2664
- session_jwt: n.session_jwt,
2676
+ session_token: o.session_token,
2677
+ session_jwt: o.session_jwt,
2665
2678
  intermediate_session_token: null
2666
- }), t.abrupt("return", n);
2667
- case 9:
2668
- throw t.prev = 9, t.t0 = t["catch"](0), A.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
2679
+ }), t.abrupt("return", o);
2669
2680
  case 13:
2681
+ if (t.prev = 13, t.t0 = t["catch"](2), !n()) {
2682
+ t.next = 17;
2683
+ break;
2684
+ }
2685
+ return t.abrupt("return", this.authenticate(e));
2686
+ case 17:
2687
+ throw C.includes(t.t0.error_type) && this._subscriptionService.destroyState(), t.t0;
2688
+ case 19:
2670
2689
  case "end":
2671
2690
  return t.stop();
2672
2691
  }
2673
- }, t, this, [[0, 9]]);
2692
+ }, t, this, [[2, 13]]);
2674
2693
  }));
2675
2694
  }, this.exchange = function (e) {
2676
2695
  return we(n, void 0, void 0, de().mark(function t() {
@@ -2856,17 +2875,26 @@ var tt = pe(function e(t, r) {
2856
2875
  case 0:
2857
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();
2858
2877
  case 3:
2859
- 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 = {
2860
2891
  url: "/b2b/otps/sms/send",
2861
- body: Object.assign(Object.assign({}, e), {
2862
- dfp_telemetry_id: n,
2863
- captcha_token: i
2864
- }),
2892
+ body: t.t8,
2865
2893
  errorMessage: "Failed to send one time passcode",
2866
2894
  method: "POST",
2867
- retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
2868
- }));
2869
- case 7:
2895
+ retryCallback: t.t9
2896
+ }, t.abrupt("return", t.t0.retriableFetchSDK.call(t.t0, t.t10));
2897
+ case 22:
2870
2898
  case "end":
2871
2899
  return t.stop();
2872
2900
  }
@@ -2935,17 +2963,26 @@ var tt = pe(function e(t, r) {
2935
2963
  case 0:
2936
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();
2937
2965
  case 3:
2938
- 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 = {
2939
2979
  url: "/b2b/totp",
2940
- body: Object.assign(Object.assign({}, e), {
2941
- dfp_telemetry_id: n,
2942
- captcha_token: i
2943
- }),
2980
+ body: t.t8,
2944
2981
  errorMessage: "Failed to create TOTP",
2945
2982
  method: "POST",
2946
- retryCallback: this.dfpProtectedAuth.retryWithCaptchaAndDFP
2947
- }));
2948
- case 7:
2983
+ retryCallback: t.t9
2984
+ }, t.abrupt("return", t.t0.retriableFetchSDK.call(t.t0, t.t10));
2985
+ case 22:
2949
2986
  case "end":
2950
2987
  return t.stop();
2951
2988
  }
@@ -3002,6 +3039,106 @@ var tt = pe(function e(t, r) {
3002
3039
  }]), e;
3003
3040
  }(),
3004
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 () {
3005
3142
  function e(t, r, n) {
3006
3143
  var i = this;
3007
3144
  _e(this, e), this._subscriptionService = n, this.isAuthorizedSync = function (e, t) {
@@ -3011,8 +3148,8 @@ var tt = pe(function e(t, r) {
3011
3148
  return i.policyPromise.then(function (r) {
3012
3149
  return r.callerIsAuthorized(i.roleIds(), e, t);
3013
3150
  });
3014
- }, this.cachedPolicy = t.rbacPolicy ? ft.fromJSON(t.rbacPolicy) : null, this.policyPromise = r.then(function (e) {
3015
- 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([], []));
3016
3153
  });
3017
3154
  }
3018
3155
  return pe(e, [{
@@ -3032,7 +3169,7 @@ var tt = pe(function e(t, r) {
3032
3169
  }
3033
3170
  }]), e;
3034
3171
  }(),
3035
- it = function () {
3172
+ ot = function () {
3036
3173
  function e(t, r) {
3037
3174
  var n = this;
3038
3175
  _e(this, e), this._subscriptionService = t, this._headlessSessionClient = r, this._onDataChange = function (e) {
@@ -3076,7 +3213,7 @@ var tt = pe(function e(t, r) {
3076
3213
  this._reauthenticateWithBackoff().then(function () {
3077
3214
  e.scheduleBackgroundRefresh();
3078
3215
  })["catch"](function (t) {
3079
- 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.", {
3080
3217
  error: t
3081
3218
  }), e._subscriptionService.destroyState();
3082
3219
  });
@@ -3102,13 +3239,12 @@ var tt = pe(function e(t, r) {
3102
3239
  }, {
3103
3240
  key: "isUnrecoverableError",
3104
3241
  value: function value(e) {
3105
- return A.includes(e.error_type);
3242
+ return C.includes(e.error_type);
3106
3243
  }
3107
3244
  }]), e;
3108
3245
  }();
3109
- it.REFRESH_INTERVAL_MS = 18e4;
3110
- var ot,
3111
- st,
3246
+ ot.REFRESH_INTERVAL_MS = 18e4;
3247
+ var st,
3112
3248
  at,
3113
3249
  ct,
3114
3250
  ut,
@@ -3117,7 +3253,8 @@ var ot,
3117
3253
  ht,
3118
3254
  pt,
3119
3255
  _t,
3120
- ft = function () {
3256
+ ft,
3257
+ mt = function () {
3121
3258
  function e(t, r) {
3122
3259
  var n = this;
3123
3260
  _e(this, e), this.roles = t, this.resources = r, this.rolesByID = {}, t.forEach(function (e) {
@@ -3158,7 +3295,7 @@ var ot,
3158
3295
  }
3159
3296
  }]), e;
3160
3297
  }();
3161
- function mt(e, t, r, n) {
3298
+ function vt(e, t, r, n) {
3162
3299
  return new (r || (r = Promise))(function (i, o) {
3163
3300
  function s(e) {
3164
3301
  try {
@@ -3185,61 +3322,61 @@ function mt(e, t, r, n) {
3185
3322
  }
3186
3323
  "function" == typeof SuppressedError && SuppressedError, function (e) {
3187
3324
  e.emailMagicLinks = "emailMagicLinks", e.oauth = "oauth", e.otp = "otp", e.crypto = "crypto", e.passwords = "passwords", e.passkeys = "passkeys";
3188
- }(ot || (ot = {})), function (e) {
3189
- 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";
3190
3325
  }(st || (st = {})), function (e) {
3191
- 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";
3192
3327
  }(at || (at = {})), function (e) {
3193
- 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";
3194
3329
  }(ct || (ct = {})), function (e) {
3195
- e.SMS = "sms", e.WhatsApp = "whatsapp", e.Email = "email";
3330
+ e.embedded = "embedded", e.floating = "floating";
3196
3331
  }(ut || (ut = {})), function (e) {
3332
+ e.SMS = "sms", e.WhatsApp = "whatsapp", e.Email = "email";
3333
+ }(lt || (lt = {})), function (e) {
3197
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";
3198
- }(lt || (lt = {}));
3199
- var vt = /*#__PURE__*/function (_Error) {
3200
- _inherits(vt, _Error);
3201
- var _super = _createSuper(vt);
3202
- 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) {
3203
3340
  var _this;
3204
- _classCallCheck(this, vt);
3341
+ _classCallCheck(this, bt);
3205
3342
  _this = _super.call(this), _this.name = "StytchSDKUsageError", _this.message = "Invalid call to ".concat(e, "\n") + t;
3206
3343
  return _this;
3207
3344
  }
3208
- return _createClass(vt);
3345
+ return _createClass(bt);
3209
3346
  }( /*#__PURE__*/_wrapNativeSuper(Error));
3210
3347
  !function (e) {
3211
3348
  e.emailMagicLinks = "emailMagicLinks", e.sso = "sso", e.passwords = "passwords", e.oauth = "oauth";
3212
- }(dt || (dt = {})), function (e) {
3213
- e.Discovery = "Discovery", e.Organization = "Organization", e.PasswordReset = "PasswordReset";
3214
3349
  }(ht || (ht = {})), function (e) {
3215
- e.Google = "google", e.Microsoft = "microsoft";
3350
+ e.Discovery = "Discovery", e.Organization = "Organization", e.PasswordReset = "PasswordReset";
3216
3351
  }(pt || (pt = {})), function (e) {
3352
+ e.Google = "google", e.Microsoft = "microsoft";
3353
+ }(_t || (_t = {})), function (e) {
3217
3354
  e.RequiredCatcha = "Catcha Required";
3218
- }(_t || (_t = {}));
3219
- var bt = function bt(e) {
3355
+ }(ft || (ft = {}));
3356
+ var gt = function gt(e) {
3220
3357
  var t = {
3221
3358
  isObject: function isObject(r, n) {
3222
- 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.");
3223
3360
  return t;
3224
3361
  },
3225
3362
  isOptionalObject: function isOptionalObject(e, r) {
3226
3363
  return void 0 === r ? t : t.isObject(e, r);
3227
3364
  },
3228
3365
  isString: function isString(r, n) {
3229
- 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.");
3230
3367
  return t;
3231
3368
  },
3232
3369
  isOptionalString: function isOptionalString(e, r) {
3233
3370
  return void 0 === r ? t : t.isString(e, r);
3234
3371
  },
3235
3372
  isStringArray: function isStringArray(r, n) {
3236
- 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.");
3237
3374
  var _iterator = _createForOfIteratorHelper(n),
3238
3375
  _step;
3239
3376
  try {
3240
3377
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
3241
3378
  var _t2 = _step.value;
3242
- 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.");
3243
3380
  }
3244
3381
  } catch (err) {
3245
3382
  _iterator.e(err);
@@ -3252,14 +3389,14 @@ var bt = function bt(e) {
3252
3389
  return void 0 === r ? t : t.isStringArray(e, r);
3253
3390
  },
3254
3391
  isNumber: function isNumber(r, n) {
3255
- 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.");
3256
3393
  return t;
3257
3394
  },
3258
3395
  isOptionalNumber: function isOptionalNumber(e, r) {
3259
3396
  return void 0 === r ? t : t.isNumber(e, r);
3260
3397
  },
3261
3398
  isBoolean: function isBoolean(r, n) {
3262
- 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.");
3263
3400
  return t;
3264
3401
  },
3265
3402
  isOptionalBoolean: function isOptionalBoolean(e, r) {
@@ -3268,26 +3405,26 @@ var bt = function bt(e) {
3268
3405
  };
3269
3406
  return t;
3270
3407
  };
3271
- var gt;
3408
+ var yt;
3272
3409
  !function (e) {
3273
3410
  e.LoginOrCreateEML = "login_or_create_eml", e.LoginOrCreateOTP = "login_or_create_otp", e.ResetPassword = "reset_password";
3274
- }(gt || (gt = {})), Promise.resolve({
3411
+ }(yt || (yt = {})), Promise.resolve({
3275
3412
  pkceRequiredForEmailMagicLinks: !1
3276
3413
  }), Promise.resolve({
3277
3414
  pkceRequiredForPasswordResets: !1
3278
3415
  }), Promise.resolve({
3279
3416
  pkceRequiredForEmailMagicLinks: !1
3280
3417
  });
3281
- var yt = Promise.resolve({
3418
+ var kt = Promise.resolve({
3282
3419
  pkceRequiredForPasswordResets: !1
3283
3420
  });
3284
- var kt = /*#__PURE__*/function () {
3285
- function kt(e, t, r) {
3286
- 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;
3287
3424
  var i = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function () {
3288
3425
  return {
3289
3426
  isEnabled: function isEnabled() {
3290
- 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() {
3291
3428
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3292
3429
  while (1) switch (_context.prev = _context.next) {
3293
3430
  case 0:
@@ -3300,7 +3437,7 @@ var kt = /*#__PURE__*/function () {
3300
3437
  }));
3301
3438
  },
3302
3439
  getTelemetryID: function getTelemetryID() {
3303
- 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() {
3304
3441
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3305
3442
  while (1) switch (_context2.prev = _context2.next) {
3306
3443
  case 0:
@@ -3311,7 +3448,7 @@ var kt = /*#__PURE__*/function () {
3311
3448
  }));
3312
3449
  },
3313
3450
  getDFPTelemetryIDAndCaptcha: function getDFPTelemetryIDAndCaptcha() {
3314
- 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() {
3315
3452
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3316
3453
  while (1) switch (_context3.prev = _context3.next) {
3317
3454
  case 0:
@@ -3327,7 +3464,7 @@ var kt = /*#__PURE__*/function () {
3327
3464
  }));
3328
3465
  },
3329
3466
  retryWithCaptchaAndDFP: function retryWithCaptchaAndDFP() {
3330
- 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() {
3331
3468
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
3332
3469
  while (1) switch (_context4.prev = _context4.next) {
3333
3470
  case 0:
@@ -3341,13 +3478,13 @@ var kt = /*#__PURE__*/function () {
3341
3478
  }
3342
3479
  };
3343
3480
  }();
3344
- _classCallCheck(this, kt);
3481
+ _classCallCheck(this, wt);
3345
3482
  this._networkClient = e, this._subscriptionService = t, this._pkceManager = r, this._config = n, this.dfpProtectedAuth = i;
3346
3483
  }
3347
- _createClass(kt, [{
3484
+ _createClass(wt, [{
3348
3485
  key: "getCodeChallenge",
3349
3486
  value: function getCodeChallenge() {
3350
- 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() {
3351
3488
  var _yield$this$_config, e, t;
3352
3489
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
3353
3490
  while (1) switch (_context5.prev = _context5.next) {
@@ -3388,12 +3525,12 @@ var kt = /*#__PURE__*/function () {
3388
3525
  }, {
3389
3526
  key: "authenticate",
3390
3527
  value: function authenticate(e) {
3391
- 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() {
3392
3529
  var t, r, _yield$this$dfpProtec, n, i, o;
3393
3530
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
3394
3531
  while (1) switch (_context6.prev = _context6.next) {
3395
3532
  case 0:
3396
- 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);
3397
3534
  _context6.next = 3;
3398
3535
  return this._pkceManager.getPKPair();
3399
3536
  case 3:
@@ -3449,12 +3586,12 @@ var kt = /*#__PURE__*/function () {
3449
3586
  }, {
3450
3587
  key: "resetByEmailStart",
3451
3588
  value: function resetByEmailStart(e) {
3452
- 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() {
3453
3590
  var t, _yield$this$dfpProtec2, r, n;
3454
3591
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
3455
3592
  while (1) switch (_context7.prev = _context7.next) {
3456
3593
  case 0:
3457
- 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);
3458
3595
  _context7.next = 3;
3459
3596
  return this.getCodeChallenge();
3460
3597
  case 3:
@@ -3492,12 +3629,12 @@ var kt = /*#__PURE__*/function () {
3492
3629
  }, {
3493
3630
  key: "resetByEmail",
3494
3631
  value: function resetByEmail(e) {
3495
- 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() {
3496
3633
  var _yield$this$dfpProtec3, t, r, n, i, o;
3497
3634
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
3498
3635
  while (1) switch (_context8.prev = _context8.next) {
3499
3636
  case 0:
3500
- 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);
3501
3638
  _context8.next = 3;
3502
3639
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
3503
3640
  case 3:
@@ -3552,12 +3689,12 @@ var kt = /*#__PURE__*/function () {
3552
3689
  }, {
3553
3690
  key: "resetByExistingPassword",
3554
3691
  value: function resetByExistingPassword(e) {
3555
- 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() {
3556
3693
  var _yield$this$dfpProtec4, t, r, n;
3557
3694
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
3558
3695
  while (1) switch (_context9.prev = _context9.next) {
3559
3696
  case 0:
3560
- 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);
3561
3698
  _context9.next = 3;
3562
3699
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
3563
3700
  case 3:
@@ -3607,12 +3744,12 @@ var kt = /*#__PURE__*/function () {
3607
3744
  }, {
3608
3745
  key: "resetBySession",
3609
3746
  value: function resetBySession(e) {
3610
- 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() {
3611
3748
  var _yield$this$dfpProtec5, t, r, n;
3612
3749
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
3613
3750
  while (1) switch (_context10.prev = _context10.next) {
3614
3751
  case 0:
3615
- bt("stytch.passwords.resetBySession").isString("password", e.password);
3752
+ gt("stytch.passwords.resetBySession").isString("password", e.password);
3616
3753
  _context10.next = 3;
3617
3754
  return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();
3618
3755
  case 3:
@@ -3653,11 +3790,11 @@ var kt = /*#__PURE__*/function () {
3653
3790
  }, {
3654
3791
  key: "strengthCheck",
3655
3792
  value: function strengthCheck(e) {
3656
- 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() {
3657
3794
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
3658
3795
  while (1) switch (_context11.prev = _context11.next) {
3659
3796
  case 0:
3660
- 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({
3661
3798
  url: "/b2b/passwords/strength_check",
3662
3799
  method: "POST",
3663
3800
  errorMessage: "Failed to check password strength.",
@@ -3674,21 +3811,21 @@ var kt = /*#__PURE__*/function () {
3674
3811
  }));
3675
3812
  }
3676
3813
  }]);
3677
- return kt;
3814
+ return wt;
3678
3815
  }();
3679
- var wt = "bootstrap";
3680
- var St = /*#__PURE__*/function () {
3681
- function St(e, t, r) {
3816
+ var St = "bootstrap";
3817
+ var Pt = /*#__PURE__*/function () {
3818
+ function Pt(e, t, r) {
3682
3819
  var _this2 = this;
3683
- _classCallCheck(this, St);
3820
+ _classCallCheck(this, Pt);
3684
3821
  this._publicToken = e, this._networkClient = t, this._dataLayer = r, this._bootstrapDataPromise = this._networkClient.fetchSDK({
3685
3822
  url: "/projects/bootstrap/".concat(this._publicToken),
3686
3823
  method: "GET",
3687
3824
  errorMessage: "Error fetching bootstrap data for SDK for ".concat(this._publicToken)
3688
- }).then(St.mapBootstrapData).then(function (e) {
3689
- 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;
3690
3827
  })["catch"](function (e) {
3691
- return Ke(e), {
3828
+ return Ne(e), {
3692
3829
  displayWatermark: !1,
3693
3830
  cnameDomain: null,
3694
3831
  emailDomains: ["stytch.com"],
@@ -3707,10 +3844,10 @@ var St = /*#__PURE__*/function () {
3707
3844
  };
3708
3845
  });
3709
3846
  }
3710
- _createClass(St, [{
3847
+ _createClass(Pt, [{
3711
3848
  key: "getSync",
3712
3849
  value: function getSync() {
3713
- var e = this._dataLayer.getItem(wt);
3850
+ var e = this._dataLayer.getItem(St);
3714
3851
  if (null === e) return {
3715
3852
  displayWatermark: !1,
3716
3853
  cnameDomain: null,
@@ -3781,13 +3918,13 @@ var St = /*#__PURE__*/function () {
3781
3918
  };
3782
3919
  }
3783
3920
  }]);
3784
- return St;
3921
+ return Pt;
3785
3922
  }();
3786
- var Pt = /*#__PURE__*/_createClass(function Pt(e) {
3923
+ var Ct = /*#__PURE__*/_createClass(function Ct(e) {
3787
3924
  var _this3 = this;
3788
- _classCallCheck(this, Pt);
3925
+ _classCallCheck(this, Ct);
3789
3926
  this.bootstrapPromise = e, this.executeRecaptcha = function () {
3790
- return mt(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
3927
+ return vt(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
3791
3928
  var _yield$this$state, e, t, r;
3792
3929
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
3793
3930
  while (1) switch (_context12.prev = _context12.next) {
@@ -3818,7 +3955,7 @@ var Pt = /*#__PURE__*/_createClass(function Pt(e) {
3818
3955
  }, _callee12, this);
3819
3956
  }));
3820
3957
  }, this.state = e.then(function (e) {
3821
- return mt(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
3958
+ return vt(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
3822
3959
  var t;
3823
3960
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
3824
3961
  while (1) switch (_context13.prev = _context13.next) {
@@ -3887,9 +4024,9 @@ var At = /*#__PURE__*/function () {
3887
4024
  key: "createTelemetryBlob",
3888
4025
  value: function createTelemetryBlob() {
3889
4026
  return Object.assign(Object.assign({
3890
- event_id: "event-id-".concat(Re()),
3891
- app_session_id: "app-session-id-".concat(Re()),
3892
- persistent_id: "persistent-id-".concat(Re()),
4027
+ event_id: "event-id-".concat(Ie()),
4028
+ app_session_id: "app-session-id-".concat(Ie()),
4029
+ persistent_id: "persistent-id-".concat(Ie()),
3893
4030
  client_sent_at: new Date().toISOString(),
3894
4031
  timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
3895
4032
  }, this.additionalTelemetryDataFn()), {
@@ -3898,7 +4035,7 @@ var At = /*#__PURE__*/function () {
3898
4035
  },
3899
4036
  sdk: {
3900
4037
  identifier: "Stytch.js Javascript SDK",
3901
- version: "4.3.1"
4038
+ version: "4.4.0"
3902
4039
  }
3903
4040
  });
3904
4041
  }
@@ -3909,13 +4046,13 @@ var At = /*#__PURE__*/function () {
3909
4046
  t = _ref2.body,
3910
4047
  r = _ref2.errorMessage,
3911
4048
  n = _ref2.method;
3912
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
4049
+ return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
3913
4050
  var i, o, s, a;
3914
4051
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
3915
4052
  while (1) switch (_context14.prev = _context14.next) {
3916
4053
  case 0:
3917
4054
  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;
3918
- return _context14.abrupt("return", Ae({
4055
+ return _context14.abrupt("return", Ce({
3919
4056
  basicAuthHeader: o,
3920
4057
  body: t,
3921
4058
  errorMessage: r,
@@ -3939,7 +4076,7 @@ var At = /*#__PURE__*/function () {
3939
4076
  r = _ref3.errorMessage,
3940
4077
  n = _ref3.method,
3941
4078
  i = _ref3.retryCallback;
3942
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
4079
+ return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
3943
4080
  var o, s, a, c;
3944
4081
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
3945
4082
  while (1) switch (_context15.prev = _context15.next) {
@@ -3967,7 +4104,7 @@ var At = /*#__PURE__*/function () {
3967
4104
  xSDKClientHeader: o,
3968
4105
  xSDKParentHostHeader: s,
3969
4106
  body: a
3970
- }, e.prev = 1, e.next = 4, Ae(u);
4107
+ }, e.prev = 1, e.next = 4, Ce(u);
3971
4108
  case 4:
3972
4109
  case 15:
3973
4110
  return e.abrupt("return", e.sent);
@@ -3978,7 +4115,7 @@ var At = /*#__PURE__*/function () {
3978
4115
  }
3979
4116
  return e.next = 12, c(e.t0, u);
3980
4117
  case 12:
3981
- return u = e.sent, e.next = 15, Ae(u);
4118
+ return u = e.sent, e.next = 15, Ce(u);
3982
4119
  case 16:
3983
4120
  throw e.t0;
3984
4121
  case 17:
@@ -4012,16 +4149,16 @@ var At = /*#__PURE__*/function () {
4012
4149
  }]);
4013
4150
  return At;
4014
4151
  }();
4015
- function Ct(e) {
4152
+ function Tt(e) {
4016
4153
  var t = e.toString(16);
4017
4154
  return 1 === t.length && (t = "0" + t), t;
4018
4155
  }
4019
- var Tt = /*#__PURE__*/function () {
4020
- function Tt(e, t) {
4021
- _classCallCheck(this, Tt);
4156
+ var Ot = /*#__PURE__*/function () {
4157
+ function Ot(e, t) {
4158
+ _classCallCheck(this, Ot);
4022
4159
  this._dataLayer = e, this.namespace = t;
4023
4160
  }
4024
- _createClass(Tt, [{
4161
+ _createClass(Ot, [{
4025
4162
  key: "key",
4026
4163
  value: function key() {
4027
4164
  return "PKCE_VERIFIER:" + this.namespace;
@@ -4029,13 +4166,13 @@ var Tt = /*#__PURE__*/function () {
4029
4166
  }, {
4030
4167
  key: "startPKCETransaction",
4031
4168
  value: function startPKCETransaction() {
4032
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
4169
+ return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
4033
4170
  var e;
4034
4171
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
4035
4172
  while (1) switch (_context16.prev = _context16.next) {
4036
4173
  case 0:
4037
4174
  _context16.next = 2;
4038
- return Tt.createProofkeyPair();
4175
+ return Ot.createProofkeyPair();
4039
4176
  case 2:
4040
4177
  e = _context16.sent;
4041
4178
  return _context16.abrupt("return", (this._dataLayer.setItem(this.key(), JSON.stringify(e)), e));
@@ -4053,7 +4190,7 @@ var Tt = /*#__PURE__*/function () {
4053
4190
  if (null !== e) try {
4054
4191
  return JSON.parse(e);
4055
4192
  } catch (e) {
4056
- return void Ne("Found malformed Proof Key pair in localstorage.");
4193
+ return void Ke("Found malformed Proof Key pair in localstorage.");
4057
4194
  }
4058
4195
  }
4059
4196
  }, {
@@ -4064,7 +4201,7 @@ var Tt = /*#__PURE__*/function () {
4064
4201
  }], [{
4065
4202
  key: "createProofkeyPair",
4066
4203
  value: function createProofkeyPair() {
4067
- return mt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
4204
+ return vt(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
4068
4205
  var _String$fromCharCode;
4069
4206
  var e, t, r, n;
4070
4207
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
@@ -4072,7 +4209,7 @@ var Tt = /*#__PURE__*/function () {
4072
4209
  case 0:
4073
4210
  e = new Uint32Array(16);
4074
4211
  window.crypto.getRandomValues(e);
4075
- t = Array.from(e).map(Ct).join("");
4212
+ t = Array.from(e).map(Tt).join("");
4076
4213
  _context17.next = 5;
4077
4214
  return window.crypto.subtle.digest("SHA-256", new TextEncoder().encode(t));
4078
4215
  case 5:
@@ -4089,14 +4226,14 @@ var Tt = /*#__PURE__*/function () {
4089
4226
  }));
4090
4227
  }
4091
4228
  }]);
4092
- return Tt;
4229
+ return Ot;
4093
4230
  }();
4094
- var Ot = /*#__PURE__*/function () {
4095
- function Ot(e) {
4096
- _classCallCheck(this, Ot);
4231
+ var Et = /*#__PURE__*/function () {
4232
+ function Et(e) {
4233
+ _classCallCheck(this, Et);
4097
4234
  this._networkClient = e;
4098
4235
  }
4099
- _createClass(Ot, [{
4236
+ _createClass(Et, [{
4100
4237
  key: "searchUser",
4101
4238
  value: function searchUser(e) {
4102
4239
  return this._networkClient.fetchSDK({
@@ -4134,9 +4271,9 @@ var Ot = /*#__PURE__*/function () {
4134
4271
  });
4135
4272
  }
4136
4273
  }]);
4137
- return Ot;
4274
+ return Et;
4138
4275
  }();
4139
- var Et = function Et(e) {
4276
+ var xt = function xt(e) {
4140
4277
  return (document.cookie ? document.cookie.split("; ") : []).filter(function (t) {
4141
4278
  var _t$split = t.split("="),
4142
4279
  _t$split2 = _slicedToArray(_t$split, 1),
@@ -4145,17 +4282,17 @@ var Et = function Et(e) {
4145
4282
  }).length > 1;
4146
4283
  };
4147
4284
  /*! js-cookie v3.0.1 | MIT */
4148
- function xt(e) {
4285
+ function Dt(e) {
4149
4286
  for (var t = 1; t < arguments.length; t++) {
4150
4287
  var r = arguments[t];
4151
4288
  for (var n in r) e[n] = r[n];
4152
4289
  }
4153
4290
  return e;
4154
4291
  }
4155
- var Dt = function e(t, r) {
4292
+ var It = function e(t, r) {
4156
4293
  function n(e, n, i) {
4157
4294
  if ("undefined" != typeof document) {
4158
- "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);
4295
+ "number" == typeof (i = Dt({}, 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);
4159
4296
  var o = "";
4160
4297
  for (var s in i) i[s] && (o += "; " + s, !0 !== i[s] && (o += "=" + i[s].split(";")[0]));
4161
4298
  return document.cookie = e + "=" + t.write(n, e) + o;
@@ -4177,15 +4314,15 @@ var Dt = function e(t, r) {
4177
4314
  }
4178
4315
  },
4179
4316
  remove: function remove(e, t) {
4180
- n(e, "", xt({}, t, {
4317
+ n(e, "", Dt({}, t, {
4181
4318
  expires: -1
4182
4319
  }));
4183
4320
  },
4184
4321
  withAttributes: function withAttributes(t) {
4185
- return e(this.converter, xt({}, this.attributes, t));
4322
+ return e(this.converter, Dt({}, this.attributes, t));
4186
4323
  },
4187
4324
  withConverter: function withConverter(t) {
4188
- return e(xt({}, this.converter, t), this.attributes);
4325
+ return e(Dt({}, this.converter, t), this.attributes);
4189
4326
  }
4190
4327
  }, {
4191
4328
  attributes: {
@@ -4209,10 +4346,10 @@ var Rt = function Rt(e) {
4209
4346
  var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
4210
4347
  return "stytch_sdk_state_".concat(e).concat(t ? "::".concat(t) : "");
4211
4348
  };
4212
- var It = /*#__PURE__*/function () {
4213
- function It(e, t) {
4349
+ var Bt = /*#__PURE__*/function () {
4350
+ function Bt(e, t) {
4214
4351
  var _this4 = this;
4215
- _classCallCheck(this, It);
4352
+ _classCallCheck(this, Bt);
4216
4353
  this.browserSessionStorage = {
4217
4354
  getItem: function getItem(e) {
4218
4355
  return sessionStorage.getItem(Rt(_this4.publicToken, e));
@@ -4234,7 +4371,7 @@ var It = /*#__PURE__*/function () {
4234
4371
  }
4235
4372
  this.state = n;
4236
4373
  }
4237
- _createClass(It, [{
4374
+ _createClass(Bt, [{
4238
4375
  key: "opaqueTokenCookieName",
4239
4376
  get: function get() {
4240
4377
  var e;
@@ -4256,14 +4393,14 @@ var It = /*#__PURE__*/function () {
4256
4393
  key: "readSessionCookie",
4257
4394
  value: function readSessionCookie() {
4258
4395
  return {
4259
- session_token: Dt.get(this.opaqueTokenCookieName),
4260
- session_jwt: Dt.get(this.jwtCookieName)
4396
+ session_token: It.get(this.opaqueTokenCookieName),
4397
+ session_jwt: It.get(this.jwtCookieName)
4261
4398
  };
4262
4399
  }
4263
4400
  }, {
4264
4401
  key: "readIntermediateSessionTokenCookie",
4265
4402
  value: function readIntermediateSessionTokenCookie() {
4266
- return Dt.get(this.istCookieName);
4403
+ return It.get(this.istCookieName);
4267
4404
  }
4268
4405
  }, {
4269
4406
  key: "writeSessionCookie",
@@ -4272,32 +4409,32 @@ var It = /*#__PURE__*/function () {
4272
4409
  var o = e.state,
4273
4410
  s = e.session_token,
4274
4411
  a = e.session_jwt,
4275
- c = It.generateCookieOpts({
4412
+ c = Bt.generateCookieOpts({
4276
4413
  expiresAt: null !== (r = null === (t = null == o ? void 0 : o.session) || void 0 === t ? void 0 : t.expires_at) && void 0 !== r ? r : "",
4277
4414
  availableToSubdomains: this._cookieAvailableToSubdomains,
4278
4415
  path: this._cookiePath,
4279
4416
  domain: this._domain
4280
4417
  });
4281
- Dt.set(this.opaqueTokenCookieName, s, c), Dt.set(this.jwtCookieName, a, c);
4282
- var u = It.generateCookieOpts({
4418
+ It.set(this.opaqueTokenCookieName, s, c), It.set(this.jwtCookieName, a, c);
4419
+ var u = Bt.generateCookieOpts({
4283
4420
  expiresAt: null !== (i = null === (n = null == o ? void 0 : o.session) || void 0 === n ? void 0 : n.expires_at) && void 0 !== i ? i : "",
4284
4421
  availableToSubdomains: !this._cookieAvailableToSubdomains,
4285
4422
  path: this._cookiePath,
4286
4423
  domain: this._domain
4287
4424
  });
4288
- 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.");
4425
+ xt(this.jwtCookieName) && It.remove(this.jwtCookieName, u), xt(this.opaqueTokenCookieName) && It.remove(this.opaqueTokenCookieName, u), xt(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."), xt(this.opaqueTokenCookieName) && Ke("Could not remove extraneous opaque token cookie.");
4289
4426
  }
4290
4427
  }, {
4291
4428
  key: "writeIntermediateSessionTokenCookie",
4292
4429
  value: function writeIntermediateSessionTokenCookie(e) {
4293
4430
  var t = new Date(Date.now() + 6e5),
4294
- r = It.generateCookieOpts({
4431
+ r = Bt.generateCookieOpts({
4295
4432
  expiresAt: t.toString(),
4296
4433
  availableToSubdomains: this._cookieAvailableToSubdomains,
4297
4434
  path: this._cookiePath,
4298
4435
  domain: this._domain
4299
4436
  });
4300
- Dt.set(this.istCookieName, e, r);
4437
+ It.set(this.istCookieName, e, r);
4301
4438
  }
4302
4439
  }, {
4303
4440
  key: "removeSessionCookie",
@@ -4316,14 +4453,14 @@ var It = /*#__PURE__*/function () {
4316
4453
  [!0, !1].forEach(function (t) {
4317
4454
  [_this5._cookiePath, null].forEach(function (r) {
4318
4455
  [_this5._domain, null].forEach(function (n) {
4319
- var i = It.generateCookieOpts({
4456
+ var i = Bt.generateCookieOpts({
4320
4457
  expiresAt: new Date(0).toString(),
4321
4458
  availableToSubdomains: t,
4322
4459
  path: r,
4323
4460
  domain: n
4324
4461
  });
4325
4462
  e.forEach(function (e) {
4326
- Dt.remove(e, i);
4463
+ It.remove(e, i);
4327
4464
  });
4328
4465
  });
4329
4466
  });
@@ -4372,31 +4509,31 @@ var It = /*#__PURE__*/function () {
4372
4509
  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;
4373
4510
  }
4374
4511
  }]);
4375
- return It;
4512
+ return Bt;
4376
4513
  }();
4377
- var Bt = /*#__PURE__*/function (_It) {
4378
- _inherits(Bt, _It);
4379
- var _super2 = _createSuper(Bt);
4380
- function Bt() {
4381
- _classCallCheck(this, Bt);
4514
+ var Lt = /*#__PURE__*/function (_Bt) {
4515
+ _inherits(Lt, _Bt);
4516
+ var _super2 = _createSuper(Lt);
4517
+ function Lt() {
4518
+ _classCallCheck(this, Lt);
4382
4519
  return _super2.apply(this, arguments);
4383
4520
  }
4384
- return _createClass(Bt);
4385
- }(It);
4386
- var Lt = Symbol["for"]("__stytch_b2b_DataLayer"),
4387
- Mt = function Mt(e, t) {
4521
+ return _createClass(Lt);
4522
+ }(Bt);
4523
+ var Mt = Symbol["for"]("__stytch_b2b_DataLayer"),
4524
+ Ft = function Ft(e, t) {
4388
4525
  var r = function () {
4389
4526
  var e = window;
4390
- return e[Lt] || (e[Lt] = {}), e[Lt];
4527
+ return e[Mt] || (e[Mt] = {}), e[Mt];
4391
4528
  }();
4392
- return r[e] || (r[e] = new Bt(e, t)), r[e];
4529
+ return r[e] || (r[e] = new Lt(e, t)), r[e];
4393
4530
  },
4394
4531
  jt = function jt(e, t) {
4395
4532
  Object.values(e).forEach(function (e) {
4396
4533
  return e(t);
4397
4534
  });
4398
4535
  },
4399
- Ft = function () {
4536
+ Kt = function () {
4400
4537
  var e = (arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}).KEYS_TO_EXCLUDE,
4401
4538
  t = void 0 === e ? [] : e;
4402
4539
  return function e(r, n) {
@@ -4462,7 +4599,7 @@ var Nt = /*#__PURE__*/function () {
4462
4599
  r = null === e.state ? null : Object.assign(Object.assign({}, this._datalayer.state), e.state);
4463
4600
  this._datalayer.state = r;
4464
4601
  var n = e.state ? Object.keys(e.state) : [];
4465
- !this._datalayer.markStateKeysUpdated(n) && Ft(t, r) || jt(this._datalayer.subscriptions, r);
4602
+ !this._datalayer.markStateKeysUpdated(n) && Kt(t, r) || jt(this._datalayer.subscriptions, r);
4466
4603
  }
4467
4604
  }, {
4468
4605
  key: "updateStateAndTokens",
@@ -4477,7 +4614,7 @@ var Nt = /*#__PURE__*/function () {
4477
4614
  this._datalayer.state = r;
4478
4615
  var n = e ? Object.keys(e) : [],
4479
4616
  i = this._datalayer.markStateKeysUpdated(n),
4480
- o = !Ft(t, r);
4617
+ o = !Kt(t, r);
4481
4618
  (i || o) && (jt(this._datalayer.subscriptions, r), o && this._datalayer.syncToLocalStorage());
4482
4619
  }
4483
4620
  }, {
@@ -4520,12 +4657,12 @@ var Nt = /*#__PURE__*/function () {
4520
4657
  }]);
4521
4658
  return Nt;
4522
4659
  }();
4523
- var Kt = /*#__PURE__*/function (_Nt) {
4524
- _inherits(Kt, _Nt);
4525
- var _super3 = _createSuper(Kt);
4526
- function Kt() {
4660
+ var zt = /*#__PURE__*/function (_Nt) {
4661
+ _inherits(zt, _Nt);
4662
+ var _super3 = _createSuper(zt);
4663
+ function zt() {
4527
4664
  var _this8;
4528
- _classCallCheck(this, Kt);
4665
+ _classCallCheck(this, zt);
4529
4666
  _this8 = _super3.apply(this, arguments), _this8.updateMember = function (e) {
4530
4667
  return _this8.updateState({
4531
4668
  member: e
@@ -4546,16 +4683,16 @@ var Kt = /*#__PURE__*/function (_Nt) {
4546
4683
  };
4547
4684
  return _this8;
4548
4685
  }
4549
- return _createClass(Kt);
4686
+ return _createClass(zt);
4550
4687
  }(Nt);
4551
- var zt = Symbol["for"]("stytch__internal_b2b");
4552
- var Ut = /*#__PURE__*/_createClass(function Ut(e, t) {
4688
+ var Ut = Symbol["for"]("stytch__internal_b2b");
4689
+ var qt = /*#__PURE__*/_createClass(function qt(e, t) {
4553
4690
  var _this9 = this;
4554
- _classCallCheck(this, Ut);
4691
+ _classCallCheck(this, qt);
4555
4692
  var r;
4556
4693
  !function (e) {
4557
4694
  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"));
4558
- }("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));
4695
+ }("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));
4559
4696
  var n = t,
4560
4697
  i = {
4561
4698
  cookieOptions: null == (o = n) ? void 0 : o.cookieOptions,
@@ -4568,8 +4705,8 @@ var Ut = /*#__PURE__*/_createClass(function Ut(e, t) {
4568
4705
  }
4569
4706
  };
4570
4707
  var o, s, a, c, u, l, d, h, p, _, f;
4571
- this._dataLayer = Mt(e, n), this._subscriptionService = new Kt(e, this._dataLayer);
4572
- var m = new Tt(this._dataLayer, "passwords");
4708
+ this._dataLayer = Ft(e, n), this._subscriptionService = new zt(e, this._dataLayer);
4709
+ var m = new Ot(this._dataLayer, "passwords");
4573
4710
  this._networkClient = new At(e, this._dataLayer, i.endpoints.sdkBackendURL, function () {
4574
4711
  var e, t, r, n;
4575
4712
  return {
@@ -4577,19 +4714,19 @@ var Ut = /*#__PURE__*/_createClass(function Ut(e, t) {
4577
4714
  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
4578
4715
  };
4579
4716
  });
4580
- var v = new St(e, this._networkClient, this._dataLayer),
4581
- b = new Pt(v.getAsync()),
4717
+ var v = new Pt(e, this._networkClient, this._dataLayer),
4718
+ b = new Ct(v.getAsync()),
4582
4719
  g = new We(e, i.endpoints.dfpBackendURL, v.getAsync(), b.executeRecaptcha);
4583
- 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(), {
4720
+ 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 Ot(this._dataLayer, "magic_links"), m, v.getAsync(), g), this.oauth = new Ze(this._networkClient, this._subscriptionService, new Ot(this._dataLayer, "oauth"), v.getAsync(), {
4584
4721
  publicToken: e,
4585
4722
  testAPIURL: i.endpoints.testAPIURL,
4586
4723
  liveAPIURL: i.endpoints.liveAPIURL
4587
- }, g), this.sso = new $e(this._networkClient, this._subscriptionService, new Tt(this._dataLayer, "sso"), v.getAsync(), {
4724
+ }, g), this.sso = new $e(this._networkClient, this._subscriptionService, new Ot(this._dataLayer, "sso"), v.getAsync(), {
4588
4725
  publicToken: e,
4589
4726
  testAPIURL: i.endpoints.testAPIURL,
4590
4727
  liveAPIURL: i.endpoints.liveAPIURL
4591
- }), 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);
4592
- var y = new Ot(this._networkClient);
4728
+ }), 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);
4729
+ var y = new Et(this._networkClient);
4593
4730
  this._dataLayer.readSessionCookie().session_token && this._sessionManager.performBackgroundRefresh(), this._networkClient.logEvent({
4594
4731
  name: "b2b_sdk_instance_instantiated",
4595
4732
  details: {
@@ -4599,7 +4736,7 @@ var Ut = /*#__PURE__*/_createClass(function Ut(e, t) {
4599
4736
  }
4600
4737
  });
4601
4738
  (function (e, t) {
4602
- Object.assign(e, _defineProperty({}, zt, t));
4739
+ Object.assign(e, _defineProperty({}, Ut, t));
4603
4740
  })(this, {
4604
4741
  bootstrap: v,
4605
4742
  publicToken: e,
@@ -4608,4 +4745,4 @@ var Ut = /*#__PURE__*/_createClass(function Ut(e, t) {
4608
4745
  networkClient: this._networkClient
4609
4746
  });
4610
4747
  });
4611
- 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 };
4748
+ 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, qt 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 };