@passflow/core 0.47.0 → 0.48.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.
package/dist/index.mjs CHANGED
@@ -11,7 +11,7 @@ var a = "__passflowAntiBot", o = (e, t) => {
11
11
  if (typeof e != "object" || !e) return;
12
12
  let t = e[a];
13
13
  return typeof t == "object" && t ? t : void 0;
14
- }, c = "0.47.0", l = "X-Passflow-Clientid", u = "Authorization", d = "X-Passflow-DeviceId", f = "X-Passflow-DeviceType", p = "X-Passflow-Anti-Bot", m = "X-Passflow-Agent-Tool", h = "X-Passflow-Device-Proof", g = "X-Passflow-Fingerprint-Event", _ = "X-Passflow-Stytch-Telemetry", v = "passflow_auth", y = c, b = [
14
+ }, c = "0.48.1", l = "X-Passflow-Clientid", u = "Authorization", d = "X-Passflow-DeviceId", f = "X-Passflow-DeviceType", p = "X-Passflow-Anti-Bot", m = "X-Passflow-Agent-Tool", h = "X-Passflow-Device-Proof", g = "X-Passflow-Fingerprint-Event", _ = "X-Passflow-Stytch-Telemetry", v = "passflow_auth", y = c, b = [
15
15
  "id",
16
16
  "offline",
17
17
  "openid"
@@ -452,32 +452,20 @@ var N = /* @__PURE__ */ function(e) {
452
452
  function _e() {
453
453
  return navigator.credentials;
454
454
  }
455
- function ve() {
456
- if (typeof window > "u" || typeof navigator > "u" || !("IdentityCredential" in window) || typeof navigator.credentials?.get != "function") return !1;
457
- let e = !1, t = !1, n = {
458
- get mode() {
459
- return e = !0, "active";
460
- },
461
- providers: [{
462
- configURL: "https://invalid.example/",
463
- clientId: "probe",
464
- get params() {
465
- return t = !0, {};
466
- }
467
- }]
468
- }, r = new AbortController();
469
- r.abort();
470
- try {
471
- _e().get({
472
- identity: n,
473
- signal: r.signal
474
- }).catch(() => {});
475
- } catch {
476
- return !1;
455
+ var ve = 132;
456
+ function ye() {
457
+ let e = navigator.userAgentData?.brands;
458
+ if (Array.isArray(e)) {
459
+ let t = e.find((e) => e?.brand === "Chromium"), n = Number.parseInt(String(t?.version ?? ""), 10);
460
+ if (Number.isInteger(n) && n > 0) return n;
477
461
  }
478
- return e && t;
462
+ let t = /\b(?:Chrome|Chromium)\/(\d+)/.exec(navigator.userAgent ?? "");
463
+ return t?.[1] ? Number.parseInt(t[1], 10) : void 0;
479
464
  }
480
- function ye(e) {
465
+ function be() {
466
+ return typeof window > "u" || typeof navigator > "u" || !("IdentityCredential" in window) || typeof navigator.credentials?.get != "function" ? !1 : (ye() ?? 0) >= ve;
467
+ }
468
+ function xe(e) {
481
469
  let t = e?.token, n = t;
482
470
  if (typeof t == "string") try {
483
471
  let e = JSON.parse(t);
@@ -486,7 +474,7 @@ function ye(e) {
486
474
  if (typeof n != "string" || n === "") throw new L("provider", "The identity provider returned no ID token");
487
475
  return n;
488
476
  }
489
- function be(e) {
477
+ function Se(e) {
490
478
  if (e instanceof L) return e;
491
479
  let t = e?.name, n = e instanceof Error ? e.message : void 0;
492
480
  switch (t) {
@@ -497,7 +485,7 @@ function be(e) {
497
485
  default: return new L("dismissed", n);
498
486
  }
499
487
  }
500
- async function xe(e) {
488
+ async function Ce(e) {
501
489
  let t = navigator.userActivation;
502
490
  if (e.mode === "active" && t?.isActive === !1) throw new L("unsupported", "The click that started the sign-in is no longer active");
503
491
  let n;
@@ -526,11 +514,11 @@ async function xe(e) {
526
514
  ...e.signal ? { signal: e.signal } : {}
527
515
  });
528
516
  } catch (e) {
529
- throw be(e);
517
+ throw Se(e);
530
518
  }
531
- return ye(n);
519
+ return xe(n);
532
520
  }
533
- var Se = Object.freeze({ get: xe }), Ce = class {
521
+ var we = Object.freeze({ get: Ce }), Te = class {
534
522
  constructor() {
535
523
  this.passkeys = {
536
524
  startRegistration: (e) => i({ optionsJSON: e }),
@@ -622,7 +610,7 @@ var Se = Object.freeze({ get: xe }), Ce = class {
622
610
  });
623
611
  }
624
612
  get identityCredentials() {
625
- return this.identityProbe === void 0 && (this.identityProbe = ve()), this.identityProbe ? Se : void 0;
613
+ return this.identitySupport === void 0 && (this.identitySupport = be()), this.identitySupport ? we : void 0;
626
614
  }
627
615
  btoa(e) {
628
616
  return btoa(e);
@@ -645,16 +633,16 @@ var Se = Object.freeze({ get: xe }), Ce = class {
645
633
  getDeviceType() {
646
634
  return "web";
647
635
  }
648
- }, we = new Ce(), Te = /^[0-9]+$/, Ee = Object.freeze({
636
+ }, Ee = new Te(), De = /^[0-9]+$/, Oe = Object.freeze({
649
637
  unorderable: !1,
650
638
  zero: !1
651
- }), De = (e) => Te.test(e) ? Number.parseInt(e, 10) : void 0, Oe = (e) => {
652
- if (!e) return Ee;
639
+ }), ke = (e) => De.test(e) ? Number.parseInt(e, 10) : void 0, Ae = (e) => {
640
+ if (!e) return Oe;
653
641
  let t = e.split(/\s+/).filter((e) => e !== "");
654
- if (t.length === 0) return Ee;
642
+ if (t.length === 0) return Oe;
655
643
  let n = [];
656
644
  for (let e of t) {
657
- let t = De(e);
645
+ let t = ke(e);
658
646
  t !== void 0 && n.push(t);
659
647
  }
660
648
  if (n.length === 0) return {
@@ -673,17 +661,17 @@ var Se = Object.freeze({ get: xe }), Ce = class {
673
661
  unorderable: !1,
674
662
  zero: !1
675
663
  };
676
- }, ke = (e) => Oe(e).level, Ae = "insufficient_user_authentication", je = "upgrade_required", Me = /([A-Za-z0-9!#$%&'*+\-.^_`|~]+)\s*=\s*(?:"((?:[^"\\]|\\.)*)"|([^\s,]*))/g, Ne = (e) => e.replace(/\\(.)/g, "$1"), Pe = (e) => {
664
+ }, je = (e) => Ae(e).level, Me = "insufficient_user_authentication", Ne = "upgrade_required", Pe = /([A-Za-z0-9!#$%&'*+\-.^_`|~]+)\s*=\s*(?:"((?:[^"\\]|\\.)*)"|([^\s,]*))/g, Fe = (e) => e.replace(/\\(.)/g, "$1"), Ie = (e) => {
677
665
  let t = {};
678
- Me.lastIndex = 0;
679
- for (let n of e.matchAll(Me)) {
666
+ Pe.lastIndex = 0;
667
+ for (let n of e.matchAll(Pe)) {
680
668
  let e = n[1];
681
669
  if (!e) continue;
682
670
  let r = n[2], i = n[3];
683
- t[e.toLowerCase()] = r === void 0 ? i ?? "" : Ne(r);
671
+ t[e.toLowerCase()] = r === void 0 ? i ?? "" : Fe(r);
684
672
  }
685
673
  return t;
686
- }, Fe = (e) => {
674
+ }, Le = (e) => {
687
675
  if (e == null || e === "") return { kind: "absent" };
688
676
  let t = typeof e == "number" ? e : Number.parseInt(String(e), 10);
689
677
  return Number.isFinite(t) && t > 0 ? {
@@ -693,38 +681,38 @@ var Se = Object.freeze({ get: xe }), Ce = class {
693
681
  kind: "invalid",
694
682
  raw: e
695
683
  };
696
- }, Ie = (e) => {
697
- let t = Fe(e);
684
+ }, Re = (e) => {
685
+ let t = Le(e);
698
686
  return t.kind === "valid" ? t.value : void 0;
699
- }, Le = (e, t) => {
687
+ }, ze = (e, t) => {
700
688
  if (!e || !/(^|[\s,])Bearer\b/i.test(e)) return;
701
- let n = Pe(e);
689
+ let n = Ie(e);
702
690
  if (n.error === "insufficient_user_authentication") return {
703
691
  acrValues: n.acr_values || void 0,
704
- maxAge: Ie(n.max_age),
692
+ maxAge: Re(n.max_age),
705
693
  status: t
706
694
  };
707
- }, Re = (e, t) => {
695
+ }, Be = (e, t) => {
708
696
  if (!e || typeof e != "object") return;
709
697
  let n = e;
710
698
  if (n.error !== "upgrade_required") return;
711
699
  let r = Array.isArray(n.available_factors) ? n.available_factors.filter((e) => typeof e == "string") : void 0;
712
700
  return {
713
701
  acrValues: typeof n.acr_values == "string" && n.acr_values ? n.acr_values : void 0,
714
- maxAge: Ie(n.max_age),
702
+ maxAge: Re(n.max_age),
715
703
  status: t,
716
704
  ...r ? { availableFactors: r } : {},
717
705
  ...typeof n.sign_in_required == "boolean" ? { signInRequired: n.sign_in_required } : {}
718
706
  };
719
- }, ze = (e, t, n) => ({
707
+ }, Ve = (e, t, n) => ({
720
708
  channel: e,
721
- acr: Oe(t.acrValues),
722
- maxAge: Fe(n),
709
+ acr: Ae(t.acrValues),
710
+ maxAge: Le(n),
723
711
  raw: t.acrValues
724
- }), Be = (e) => e ? Pe(e) : {}, Ve = (e, t) => {
712
+ }), He = (e) => e ? Ie(e) : {}, Ue = (e, t) => {
725
713
  let { status: n } = e;
726
714
  if (n !== 401 && n !== 403) return { diagnostics: [] };
727
- let r = t?.requireChallengeChannel === "header", i = e.getHeader("www-authenticate"), a = Le(i, n), o = r ? void 0 : Re(e.body, n), s = [], c = (e, t) => {
715
+ let r = t?.requireChallengeChannel === "header", i = e.getHeader("www-authenticate"), a = ze(i, n), o = r ? void 0 : Be(e.body, n), s = [], c = (e, t) => {
728
716
  s.push({
729
717
  status: n,
730
718
  url: "",
@@ -734,9 +722,9 @@ var Se = Object.freeze({ get: xe }), Ce = class {
734
722
  };
735
723
  if (!a && !o) return r && c("header-required-but-absent", i ? { header: i } : void 0), { diagnostics: s };
736
724
  let l = [];
737
- if (a && l.push(ze("header", a, Be(i).max_age)), o) {
725
+ if (a && l.push(Ve("header", a, He(i).max_age)), o) {
738
726
  let t = e.body;
739
- l.push(ze("body", o, t?.max_age));
727
+ l.push(Ve("body", o, t?.max_age));
740
728
  }
741
729
  let u = (e) => e;
742
730
  for (let e of l) e.acr.unorderable && c("channels-unorderable", { [u(e.channel)]: e.raw }), e.acr.zero && c("zero-constraint-ignored", {
@@ -772,23 +760,23 @@ var Se = Object.freeze({ get: xe }), Ce = class {
772
760
  },
773
761
  diagnostics: s
774
762
  };
775
- }, He = (e, t, n) => Ve({
763
+ }, We = (e, t, n) => Ue({
776
764
  status: e,
777
765
  getHeader: t,
778
766
  body: n
779
- }).challenge, Ue = "__passflowUpgradeTransaction", We = "__passflowUpgradeReplayed", Ge = (e, t) => typeof e == "object" && !!e && e[t] === !0, Ke = (e) => ({
767
+ }).challenge, Ge = "__passflowUpgradeTransaction", Ke = "__passflowUpgradeReplayed", qe = (e, t) => typeof e == "object" && !!e && e[t] === !0, Je = (e) => ({
780
768
  ...e ?? {},
781
- [Ue]: !0
782
- }), qe = (e) => Ge(e, Ue), Je = (e) => ({
769
+ [Ge]: !0
770
+ }), Ye = (e) => qe(e, Ge), Xe = (e) => ({
783
771
  ...e,
784
- [We]: !0
785
- }), Ye = (e) => Ge(e, We), Xe = /* @__PURE__ */ function(e) {
772
+ [Ke]: !0
773
+ }), Ze = (e) => qe(e, Ke), Qe = /* @__PURE__ */ function(e) {
786
774
  return e.GET = "get", e.POST = "post", e.PUT = "put", e.PATCH = "patch", e.DELETE = "delete", e;
787
775
  }({}), R = /* @__PURE__ */ function(e) {
788
776
  return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.redirectCheck = "/auth/redirect/check", e.signInWithProvider = "/auth/federated/start/", e.federatedNativeStart = "/auth/federated/native/start/", e.federatedNativeComplete = "/auth/federated/native/complete/", e.passwordless = "/auth/passwordless/start", e.passwordlessComplete = "/auth/passwordless/complete", e.passwordlessStatus = "/auth/passwordless/status", e.passwordlessApprovalInfo = "/auth/passwordless/approval/info", e.passwordlessApprovalDecide = "/auth/passwordless/approval/decide", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.userSessions = "/user/sessions", e.userSessionsRevokeOthers = "/user/sessions/revoke-others", e.userProfile = "/user/profile", e.AddressChangeProof = "/v2/user/address-change/proof", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.twoFactorEnrollment = "/auth/2fa/enrollment", e.twoFactorEnrollmentEmailLink = "/auth/2fa/enrollment/email-link", e.twoFactorEnrollmentBegin = "/auth/2fa/setup/begin", e.twoFactorEnrollmentConfirm = "/auth/2fa/setup/confirm", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorPushStatus = "/v2/auth/2fa/push/status", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.TwoFactorTrustedDevicePushRemove = "/v2/user/2fa/trusted-devices/:id/push", e.TwoFactorPreferredMethod = "/v2/user/2fa/preferred-method", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e.hostedUpgradeStart = "/auth/session/upgrade/start", e.hostedUpgrade = "/auth/session/upgrade", e.antiBotChallenge = "/auth/anti-bot/challenge", e.deviceAntiBotChallenge = "/oidc/device/anti-bot/challenge", e.enterpriseResolve = "/auth/enterprise/resolve", e.enterpriseStart = "/auth/enterprise/start", e.deviceChallenge = "/auth/device/challenge", e.userDeviceKey = "/user/device/key", e;
789
- }({}), Ze = /* @__PURE__ */ function(e) {
777
+ }({}), $e = /* @__PURE__ */ function(e) {
790
778
  return e.passkeyRegisterStart = "/admin/auth/passkey/register/start", e.passkeyRegisterComplete = "/admin/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/admin/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/admin/auth/passkey/authenticate/complete", e.passkeyValidate = "/admin/auth/validate", e.logout = "/admin/auth/logout", e;
791
- }({}), Qe = (e) => {
779
+ }({}), et = (e) => {
792
780
  if (!e) return null;
793
781
  try {
794
782
  let t = new URL(e), n = t.pathname.replace(/\/+$/, "");
@@ -799,125 +787,125 @@ var Se = Object.freeze({ get: xe }), Ce = class {
799
787
  } catch {
800
788
  return null;
801
789
  }
802
- }, $e = (e) => typeof e == "object" && !!e && e.email_verification_required === !0, et = "error.service.unavailable", tt = "Passflow is temporarily unavailable. Please try again in a moment.", z = class extends Error {
790
+ }, tt = (e) => typeof e == "object" && !!e && e.email_verification_required === !0, nt = "error.service.unavailable", rt = "Passflow is temporarily unavailable. Please try again in a moment.", z = class extends Error {
803
791
  constructor(e, t) {
804
792
  super(), this.name = "PassflowError", this.id = e?.id ?? "unknown", this.message = e?.message ?? e ?? "Something went wrong", this.status = e?.status ?? 500, this.location = e?.location ?? "unknown", this.time = e?.time ?? (/* @__PURE__ */ new Date()).toISOString(), t?.cause !== void 0 && (this.cause = t.cause);
805
793
  }
806
- }, nt = "error.api.password.change.required", rt = "error.api.anti_bot.required", it = "error.api.anti_bot.failed", at = "error.api.sign_in.refused", ot = "error.api.anti_bot.unavailable", st = "error.anti_bot.provider_missing", ct = "error.anti_bot.provider_failed", lt = "error.anti_bot.solve_failed", ut = "error.api.enterprise.email_invalid", dt = "error.api.enterprise.start_input", ft = "error.api.enterprise.no_connection", pt = "error.api.enterprise.connection_ambiguous", mt = class extends z {
794
+ }, it = "error.api.password.change.required", at = "error.api.anti_bot.required", ot = "error.api.anti_bot.failed", st = "error.api.sign_in.refused", ct = "error.api.anti_bot.unavailable", lt = "error.anti_bot.provider_missing", ut = "error.anti_bot.provider_failed", dt = "error.anti_bot.solve_failed", ft = "error.api.enterprise.email_invalid", pt = "error.api.enterprise.start_input", mt = "error.api.enterprise.no_connection", ht = "error.api.enterprise.connection_ambiguous", gt = class extends z {
807
795
  constructor(e, t) {
808
796
  super(e, t), this.name = "PassflowPasswordChangeRequiredError";
809
797
  }
810
- }, ht = "error.2fa.sms.quota.exceeded", gt = "error.2fa.rate_limit_exceeded", _t = "error.2fa.recovery_codes.step_up_required", vt = "error.user.address.change.proof.required", yt = class extends z {
798
+ }, _t = "error.2fa.sms.quota.exceeded", vt = "error.2fa.rate_limit_exceeded", yt = "error.2fa.recovery_codes.step_up_required", bt = "error.user.address.change.proof.required", xt = class extends z {
811
799
  constructor(e, t) {
812
800
  super(e, t), this.name = "PassflowSmsQuotaExceededError", this.challenge = t?.challenge;
813
801
  }
814
- }, bt = class extends z {
802
+ }, St = class extends z {
815
803
  constructor(e, t, n) {
816
804
  super(e, n), this.name = "PassflowSendLimitError", this.retryAfter = t, this.challenge = n?.challenge;
817
805
  }
818
- }, xt = class extends z {
806
+ }, Ct = class extends z {
819
807
  constructor(e, t, n) {
820
808
  super(e, n), this.name = "PassflowRecoveryCodesStepUpRequiredError", this.challenge = t;
821
809
  }
822
- }, St = class extends z {
810
+ }, wt = class extends z {
823
811
  constructor(e, t, n) {
824
812
  super(e, n), this.name = "PassflowAntiBotChallengeError", this.antiBot = t;
825
813
  }
826
- }, Ct = class extends z {
814
+ }, Tt = class extends z {
827
815
  constructor(e, t) {
828
816
  super(e, t), this.name = "PassflowAddressChangeProofRequiredError";
829
817
  }
830
- }, wt = /* @__PURE__ */ function(e) {
818
+ }, Et = /* @__PURE__ */ function(e) {
831
819
  return e.google = "google", e.facebook = "facebook", e;
832
- }({}), Tt = Object.freeze([
820
+ }({}), Dt = Object.freeze([
833
821
  "debug_otp_code_for_registration",
834
822
  "fcm_server_key",
835
823
  "webpush_vapid_private_key"
836
- ]), Et = "mask://", Dt = "error.server.update.settings.masked.value.unknown", Ot = (e) => typeof e == "string" && e.startsWith("mask://"), kt = /* @__PURE__ */ function(e) {
824
+ ]), Ot = "mask://", kt = "error.server.update.settings.masked.value.unknown", At = (e) => typeof e == "string" && e.startsWith("mask://"), jt = /* @__PURE__ */ function(e) {
837
825
  return e.web = "web", e.ios = "ios", e.android = "android", e;
838
826
  }({});
839
- function At(e) {
827
+ function Mt(e) {
840
828
  return e;
841
829
  }
842
- function jt(e, t) {
830
+ function Nt(e, t) {
843
831
  let n = e;
844
832
  return Object.entries(t).forEach(([e, t]) => {
845
833
  n = n.replace(`:${e}`, t);
846
834
  }), n;
847
835
  }
848
- var Mt = /* @__PURE__ */ function(e) {
836
+ var Pt = /* @__PURE__ */ function(e) {
849
837
  return e.Disabled = "disabled", e.Optional = "optional", e.Required = "required", e;
850
- }({}), Nt = 3, Pt = 1e3, Ft = (e) => (t) => {
838
+ }({}), Ft = 3, It = 1e3, Lt = (e) => (t) => {
851
839
  let n = e.headers?.[t] ?? e.headers?.[t.toLowerCase()];
852
840
  return Array.isArray(n) ? n.join(", ") : n;
853
- }, It = (e) => He(e.status, Ft(e), e.data), Lt = (e) => It(e) !== void 0, Rt = (e) => {
841
+ }, Rt = (e) => We(e.status, Lt(e), e.data), zt = (e) => Rt(e) !== void 0, Bt = (e) => {
854
842
  let t = e.response?.data?.error;
855
843
  return typeof t?.id == "string" ? t.id : void 0;
856
- }, zt = (e) => {
844
+ }, Vt = (e) => {
857
845
  if (e.response?.status !== 403) return;
858
- let t = Rt(e);
846
+ let t = Bt(e);
859
847
  if (t !== "error.api.anti_bot.required" && t !== "error.api.anti_bot.failed") return;
860
848
  let n = e.response.data?.anti_bot;
861
849
  if (typeof n?.provider == "string" && n.provider !== "") return {
862
850
  provider: n.provider,
863
851
  ...typeof n.site_key == "string" && n.site_key ? { site_key: n.site_key } : {}
864
852
  };
865
- }, Bt = (n) => e.isAxiosError(n) && !n.response && (n.code === t.ERR_NETWORK || !n.code && n.cause instanceof TypeError), Vt = [
853
+ }, Ht = (n) => e.isAxiosError(n) && !n.response && (n.code === t.ERR_NETWORK || !n.code && n.cause instanceof TypeError), Ut = [
866
854
  502,
867
855
  503,
868
856
  504
869
- ], Ht = (e) => typeof e == "object" && !!e && typeof e.error == "object" && e.error !== null, Ut = (e, n) => {
857
+ ], Wt = (e) => typeof e == "object" && !!e && typeof e.error == "object" && e.error !== null, Gt = (e, n) => {
870
858
  let r = new t(e.message, e.code);
871
859
  return e.cause instanceof TypeError && (r.cause = e.cause), new z({
872
- id: et,
873
- message: tt,
860
+ id: nt,
861
+ message: rt,
874
862
  status: n,
875
863
  location: e.config?.url ?? "unknown",
876
864
  time: (/* @__PURE__ */ new Date()).toISOString()
877
865
  }, { cause: r });
878
- }, Wt = [[/(\/auth\/2fa-setup\/)[^/?#]+/g, "$1:token"], [/(\/cli\/auth\/status\/)[^/?#]+/g, "$1:sessionId"]], Gt = (e) => Wt.reduce((e, [t, n]) => e.replace(t, n), e), Kt = (t) => {
879
- if (t instanceof z) return t.location = Gt(t.location), t;
866
+ }, Kt = [[/(\/auth\/2fa-setup\/)[^/?#]+/g, "$1:token"], [/(\/cli\/auth\/status\/)[^/?#]+/g, "$1:sessionId"]], qt = (e) => Kt.reduce((e, [t, n]) => e.replace(t, n), e), Jt = (t) => {
867
+ if (t instanceof z) return t.location = qt(t.location), t;
880
868
  if (!e.isAxiosError(t)) return t;
881
869
  if (t.config) {
882
870
  let { data: e, headers: r, url: i, ...a } = t.config, o = {
883
871
  ...a,
884
- ...i === void 0 ? {} : { url: Gt(i) },
872
+ ...i === void 0 ? {} : { url: qt(i) },
885
873
  headers: new n()
886
874
  };
887
875
  t.config = o, t.response && (t.response.config = o);
888
876
  }
889
877
  return t.request = void 0, t.response && (t.response.request = void 0), t;
890
- }, qt = (e) => e?.includes(R.refresh) ?? !1, Jt = (e) => e?.includes("/auth/session/") ?? !1, Yt = (e) => e?.includes("logout") ?? !1, Xt = "__passflowOwnBearer", Zt = "__passflowRefreshedAfter401", Qt = (e) => typeof e == "object" && !!e && e[Xt] === !0, $t = (e) => e ? {
878
+ }, Yt = (e) => e?.includes(R.refresh) ?? !1, Xt = (e) => e?.includes("/auth/session/") ?? !1, Zt = (e) => e?.includes("logout") ?? !1, Qt = "__passflowOwnBearer", $t = "__passflowRefreshedAfter401", en = (e) => typeof e == "object" && !!e && e[Qt] === !0, tn = (e) => e ? {
891
879
  headers: { [u]: `Bearer ${e}` },
892
- [Xt]: !0
893
- } : {}, en = "__passflowSendRefusal", tn = (e) => typeof e == "object" && !!e && e[en] === !0, nn = (e = {}) => ({
880
+ [Qt]: !0
881
+ } : {}, nn = "__passflowSendRefusal", rn = (e) => typeof e == "object" && !!e && e[nn] === !0, an = (e = {}) => ({
894
882
  ...e,
895
- [en]: !0
896
- }), rn = (e) => {
897
- let t = e ? Ft(e)("Retry-After")?.trim() : void 0;
883
+ [nn]: !0
884
+ }), on = (e) => {
885
+ let t = e ? Lt(e)("Retry-After")?.trim() : void 0;
898
886
  if (!t) return;
899
887
  if (/^\d+$/.test(t)) return Number.parseInt(t, 10);
900
888
  let n = Date.parse(t);
901
889
  return Number.isNaN(n) ? void 0 : Math.max(0, Math.ceil((n - Date.now()) / 1e3));
902
- }, an = (e) => {
890
+ }, sn = (e) => {
903
891
  let { challenge_id: t, suggested_method: n, alternative_methods: r } = e;
904
892
  if (typeof t != "string" || t === "") return;
905
893
  let i = { challenge_id: t };
906
894
  return typeof n == "string" && (i.suggested_method = n), Array.isArray(r) && (i.alternative_methods = r.filter((e) => typeof e == "string")), i;
907
- }, on = (e) => {
895
+ }, cn = (e) => {
908
896
  let t = e.response?.data;
909
- if (!Ht(t)) return;
910
- let { error: n } = t, r = an(t);
897
+ if (!Wt(t)) return;
898
+ let { error: n } = t, r = sn(t);
911
899
  switch (n.id) {
912
- case ht: return new yt(n, { challenge: r });
913
- case gt: return new bt(n, rn(e.response), { challenge: r });
900
+ case _t: return new xt(n, { challenge: r });
901
+ case vt: return new St(n, on(e.response), { challenge: r });
914
902
  default: return;
915
903
  }
916
- }, sn = {
904
+ }, ln = {
917
905
  acrValues: "2",
918
906
  requiredLevel: 2,
919
907
  status: 403
920
- }, cn = class {
908
+ }, un = class {
921
909
  get origin() {
922
910
  return this._platform.getCurrentUrl()?.origin ?? "";
923
911
  }
@@ -936,7 +924,7 @@ var Mt = /* @__PURE__ */ function(e) {
936
924
  "upgrade"
937
925
  ];
938
926
  let { url: i, appId: a, keyStoragePrefix: o } = t;
939
- this._platform = t.platform ?? we, this.url = i || "https://auth.passflow.cloud", this.upgradeDomain = Qe(i), this.storageManager = n ?? new me({
927
+ this._platform = t.platform ?? Ee, this.url = i || "https://auth.passflow.cloud", this.upgradeDomain = et(i), this.storageManager = n ?? new me({
940
928
  prefix: o ?? "",
941
929
  appId: a
942
930
  }), this.deviceService = r ?? new he(this.storageManager), this.tokenService = new A(this.storageManager), this.tokenDeliveryManager = new ue(this.storageManager), a && (this.appId = a, this.defaultHeaders = {
@@ -956,17 +944,17 @@ var Mt = /* @__PURE__ */ function(e) {
956
944
  n && (e.headers[p] = n.value, t.builtin = n.builtin);
957
945
  for (let [t, n] of Object.entries(r ?? {})) e.headers[t] = n;
958
946
  }
959
- if (this.isNonAuthEndpoint(e.url) || Qt(e) || Jt(e.url)) return e;
947
+ if (this.isNonAuthEndpoint(e.url) || en(e) || Xt(e.url)) return e;
960
948
  if (this.storageManager.getDeliveryMode() === P.Cookie) {
961
949
  e.withCredentials = !0;
962
950
  let t = this.storageManager.getCsrfToken();
963
951
  return t && (e.headers["X-CSRF-Token"] = t), e;
964
952
  }
965
- if (qt(e.url)) return e;
953
+ if (Yt(e.url)) return e;
966
954
  let n = this.storageManager.getTokens();
967
955
  if (!n?.access_token) return e;
968
956
  let r = n.access_token;
969
- if (this.refreshHandler && n.refresh_token && !Yt(e.url)) {
957
+ if (this.refreshHandler && n.refresh_token && !Zt(e.url)) {
970
958
  let e = M(n.access_token);
971
959
  if (j(e, 30)) {
972
960
  let t = !j(e, 0);
@@ -981,21 +969,21 @@ var Mt = /* @__PURE__ */ function(e) {
981
969
  }
982
970
  }
983
971
  return e.headers[u] = `Bearer ${r}`, e;
984
- }), this.instance.interceptors.response.use((e) => e, (e) => this.onResponseError(e).catch((e) => Promise.reject(Kt(e))));
972
+ }), this.instance.interceptors.response.use((e) => e, (e) => this.onResponseError(e).catch((e) => Promise.reject(Jt(e))));
985
973
  }
986
974
  async onResponseError(e) {
987
- if (e.response?.status === 401 && !qt(e.config?.url) && !Jt(e.config?.url) && !Qt(e.config) && !this.isUpgradeTransactionError(e)) {
975
+ if (e.response?.status === 401 && !Yt(e.config?.url) && !Xt(e.config?.url) && !en(e.config) && !this.isUpgradeTransactionError(e)) {
988
976
  if (e.config && await this.refreshedAfterUnauthorized(e.config)) return this.instance.request(e.config);
989
977
  this.tokenDeliveryManager.setSessionInvalid();
990
978
  }
991
- let t = s(e.config), n = t && !t.retried ? zt(e) : void 0;
979
+ let t = s(e.config), n = t && !t.retried ? Vt(e) : void 0;
992
980
  if (e.config && t && n) return t.retried = !0, t.settings = {
993
981
  bot_mode: "human_only",
994
982
  anti_bot: n
995
983
  }, this.instance.request(e.config);
996
- if (e.config && e.response?.status === 403 && Rt(e) === "error.api.anti_bot.failed" && t?.builtin && !t.retried) return t.retried = !0, this.instance.request(e.config);
997
- if (e.response && this.upgradeHandler && !Jt(e.config?.url)) {
998
- let t = It(e.response);
984
+ if (e.config && e.response?.status === 403 && Bt(e) === "error.api.anti_bot.failed" && t?.builtin && !t.retried) return t.retried = !0, this.instance.request(e.config);
985
+ if (e.response && this.upgradeHandler && !Xt(e.config?.url)) {
986
+ let t = Rt(e.response);
999
987
  if (t) try {
1000
988
  return await this.upgradeHandler(e, t);
1001
989
  } catch (t) {
@@ -1003,13 +991,13 @@ var Mt = /* @__PURE__ */ function(e) {
1003
991
  }
1004
992
  }
1005
993
  if (e.response?.status === 429) {
1006
- let t = tn(e.config) ? on(e) : void 0;
994
+ let t = rn(e.config) ? cn(e) : void 0;
1007
995
  return t ? Promise.reject(t) : await this.handleRateLimitError(e);
1008
996
  }
1009
997
  return this.handleAxiosError(e);
1010
998
  }
1011
999
  isUpgradeTransactionError(e) {
1012
- return qe(e.config) || e.response !== void 0 && Lt(e.response);
1000
+ return Ye(e.config) || e.response !== void 0 && zt(e.response);
1013
1001
  }
1014
1002
  setUpgradeInterceptor(e) {
1015
1003
  this.upgradeHandler = e;
@@ -1031,8 +1019,8 @@ var Mt = /* @__PURE__ */ function(e) {
1031
1019
  }
1032
1020
  async refreshedAfterUnauthorized(e) {
1033
1021
  let t = e, n = this.storageManager.getDeliveryMode();
1034
- if (!this.refreshHandler || t[Zt] || n !== P.Cookie && n !== P.BFF || this.isNonAuthEndpoint(e.url) || Yt(e.url)) return !1;
1035
- t[Zt] = !0;
1022
+ if (!this.refreshHandler || t[$t] || n !== P.Cookie && n !== P.BFF || this.isNonAuthEndpoint(e.url) || Zt(e.url)) return !1;
1023
+ t[$t] = !0;
1036
1024
  try {
1037
1025
  return await this.refreshHandler({
1038
1026
  trigger: "pre-request",
@@ -1050,7 +1038,7 @@ var Mt = /* @__PURE__ */ function(e) {
1050
1038
  }
1051
1039
  async handleRateLimitError(e) {
1052
1040
  let t = e.config;
1053
- if (!t || qt(t.url)) return Promise.reject(e);
1041
+ if (!t || Yt(t.url)) return Promise.reject(e);
1054
1042
  let n = t.method?.toUpperCase();
1055
1043
  if (![
1056
1044
  "GET",
@@ -1058,8 +1046,8 @@ var Mt = /* @__PURE__ */ function(e) {
1058
1046
  "OPTIONS"
1059
1047
  ].includes(n || "")) return Promise.reject(e);
1060
1048
  let r = t._retryCount || 0;
1061
- if (r >= Nt) return Promise.reject(e);
1062
- let i = Pt * 2 ** r, a = e.response?.headers?.["retry-after"];
1049
+ if (r >= Ft) return Promise.reject(e);
1050
+ let i = It * 2 ** r, a = e.response?.headers?.["retry-after"];
1063
1051
  if (a) {
1064
1052
  let e = Number.parseInt(a, 10);
1065
1053
  if (!Number.isNaN(e)) i = e * 1e3;
@@ -1071,18 +1059,18 @@ var Mt = /* @__PURE__ */ function(e) {
1071
1059
  return await new Promise((e) => setTimeout(e, i)), t._retryCount = r + 1, this.instance.request(t);
1072
1060
  }
1073
1061
  async handleAxiosError(e) {
1074
- if (Bt(e)) return Promise.reject(Ut(e, 0));
1062
+ if (Ht(e)) return Promise.reject(Gt(e, 0));
1075
1063
  if (!e.response) return Promise.reject(e);
1076
1064
  let t = e.response.status;
1077
- if (Vt.includes(t) && !Ht(e.response.data)) return Promise.reject(Ut(e, t));
1065
+ if (Ut.includes(t) && !Wt(e.response.data)) return Promise.reject(Gt(e, t));
1078
1066
  let n = e.response.data;
1079
1067
  if ("error" in n && typeof n.error == "object" && n.error !== null) {
1080
- let { error: t } = n, r = zt(e);
1081
- if (r) return Promise.reject(new St(t, r));
1068
+ let { error: t } = n, r = Vt(e);
1069
+ if (r) return Promise.reject(new wt(t, r));
1082
1070
  switch (t.id) {
1083
- case nt: return Promise.reject(new mt(t));
1084
- case vt: return Promise.reject(new Ct(t));
1085
- case _t: return Promise.reject(new xt(t, It(e.response) ?? { ...sn }));
1071
+ case it: return Promise.reject(new gt(t));
1072
+ case bt: return Promise.reject(new Tt(t));
1073
+ case yt: return Promise.reject(new Ct(t, Rt(e.response) ?? { ...ln }));
1086
1074
  default: return Promise.reject(new z(t));
1087
1075
  }
1088
1076
  }
@@ -1102,28 +1090,28 @@ var Mt = /* @__PURE__ */ function(e) {
1102
1090
  })).data;
1103
1091
  }
1104
1092
  get(e, t) {
1105
- return this.send(Xe.GET, e, t);
1093
+ return this.send(Qe.GET, e, t);
1106
1094
  }
1107
1095
  post(e, t, n) {
1108
- return this.send(Xe.POST, e, {
1096
+ return this.send(Qe.POST, e, {
1109
1097
  data: t,
1110
1098
  ...n
1111
1099
  });
1112
1100
  }
1113
1101
  put(e, t, n) {
1114
- return this.send(Xe.PUT, e, {
1102
+ return this.send(Qe.PUT, e, {
1115
1103
  data: t,
1116
1104
  ...n
1117
1105
  });
1118
1106
  }
1119
1107
  patch(e, t, n) {
1120
- return this.send(Xe.PATCH, e, {
1108
+ return this.send(Qe.PATCH, e, {
1121
1109
  data: t,
1122
1110
  ...n
1123
1111
  });
1124
1112
  }
1125
1113
  delete(e, t) {
1126
- return this.send(Xe.DELETE, e, t);
1114
+ return this.send(Qe.DELETE, e, t);
1127
1115
  }
1128
1116
  setAppId(e) {
1129
1117
  this.appId = e, this.tokenDeliveryManager.reload(), this.defaultHeaders = {
@@ -1131,9 +1119,9 @@ var Mt = /* @__PURE__ */ function(e) {
1131
1119
  [l]: e
1132
1120
  }, this.instance.defaults.headers[l] = e;
1133
1121
  }
1134
- }, ln = class {
1122
+ }, dn = class {
1135
1123
  constructor(e, t, n) {
1136
- this.axiosClient = new cn(e, t, n);
1124
+ this.axiosClient = new un(e, t, n);
1137
1125
  }
1138
1126
  setAppId(e) {
1139
1127
  this.axiosClient.setAppId(e);
@@ -1141,7 +1129,7 @@ var Mt = /* @__PURE__ */ function(e) {
1141
1129
  getAppSettings() {
1142
1130
  return this.axiosClient.get(R.appSettings);
1143
1131
  }
1144
- }, B = { withCredentials: !0 }, un = 15e3, dn = "X-Passflow-CSRF", fn = "Sign-in failed. Start again.", pn = "Something went wrong. Try again later.", mn = (e, t, n, r) => {
1132
+ }, B = { withCredentials: !0 }, fn = 15e3, pn = "X-Passflow-CSRF", mn = "Sign-in failed. Start again.", hn = "Something went wrong. Try again later.", gn = (e, t, n, r) => {
1145
1133
  if (e instanceof z) return e;
1146
1134
  let i = e?.response?.data?.error;
1147
1135
  return new z({
@@ -1158,15 +1146,15 @@ var Mt = /* @__PURE__ */ function(e) {
1158
1146
  ...e?.headers,
1159
1147
  [m]: "1"
1160
1148
  } } : {}
1161
- }, hn = (e, t) => t ? {
1149
+ }, _n = (e, t) => t ? {
1162
1150
  ...e,
1163
1151
  headers: {
1164
1152
  ...e?.headers,
1165
1153
  [h]: t
1166
1154
  }
1167
- } : e, gn = class {
1155
+ } : e, vn = class {
1168
1156
  constructor(e, t, n) {
1169
- this.axiosClient = new cn(e, t, n);
1157
+ this.axiosClient = new un(e, t, n);
1170
1158
  }
1171
1159
  setAppId(e) {
1172
1160
  this.axiosClient.setAppId(e);
@@ -1181,21 +1169,21 @@ var Mt = /* @__PURE__ */ function(e) {
1181
1169
  try {
1182
1170
  return await this.axiosClient.post(R.antiBotChallenge, e);
1183
1171
  } catch (e) {
1184
- throw mn(e, R.antiBotChallenge, "error.anti_bot.challenge", pn);
1172
+ throw gn(e, R.antiBotChallenge, "error.anti_bot.challenge", hn);
1185
1173
  }
1186
1174
  }
1187
1175
  async deviceChallenge() {
1188
1176
  try {
1189
1177
  return await this.axiosClient.post(R.deviceChallenge);
1190
1178
  } catch (e) {
1191
- throw mn(e, R.deviceChallenge, "error.device.challenge", pn);
1179
+ throw gn(e, R.deviceChallenge, "error.device.challenge", hn);
1192
1180
  }
1193
1181
  }
1194
1182
  async deviceAntiBotChallenge(e, t) {
1195
1183
  try {
1196
- return await this.axiosClient.post(R.deviceAntiBotChallenge, e, { headers: { [dn]: t } });
1184
+ return await this.axiosClient.post(R.deviceAntiBotChallenge, e, { headers: { [pn]: t } });
1197
1185
  } catch (e) {
1198
- throw mn(e, R.deviceAntiBotChallenge, "error.anti_bot.challenge", pn);
1186
+ throw gn(e, R.deviceAntiBotChallenge, "error.anti_bot.challenge", hn);
1199
1187
  }
1200
1188
  }
1201
1189
  federatedStart(e, t, n) {
@@ -1209,9 +1197,9 @@ var Mt = /* @__PURE__ */ function(e) {
1209
1197
  }
1210
1198
  async federatedNativeComplete(e, t, n, r) {
1211
1199
  try {
1212
- return await this.axiosClient.post(`${R.federatedNativeComplete}${e}`, t, hn(V(B, void 0, void 0, n), r));
1200
+ return await this.axiosClient.post(`${R.federatedNativeComplete}${e}`, t, _n(V(B, void 0, void 0, n), r));
1213
1201
  } catch (e) {
1214
- throw mn(e, R.federatedNativeComplete, "error.federated.native.complete", fn);
1202
+ throw gn(e, R.federatedNativeComplete, "error.federated.native.complete", mn);
1215
1203
  }
1216
1204
  }
1217
1205
  enterpriseResolve(e) {
@@ -1232,7 +1220,7 @@ var Mt = /* @__PURE__ */ function(e) {
1232
1220
  },
1233
1221
  withCredentials: !0
1234
1222
  } : { headers: { [u]: `Bearer ${e}` } };
1235
- return this.axiosClient.post(R.refresh, a, r ? Ke(o) : o);
1223
+ return this.axiosClient.post(R.refresh, a, r ? Je(o) : o);
1236
1224
  }
1237
1225
  signIn(e, t, n, r, i) {
1238
1226
  let a = {
@@ -1240,7 +1228,7 @@ var Mt = /* @__PURE__ */ function(e) {
1240
1228
  device: t,
1241
1229
  os: n
1242
1230
  };
1243
- return this.axiosClient.post(R.signin, a, hn(V(B, "sign-in", e.email ?? e.phone ?? e.username, r), i));
1231
+ return this.axiosClient.post(R.signin, a, _n(V(B, "sign-in", e.email ?? e.phone ?? e.username, r), i));
1244
1232
  }
1245
1233
  signUp(e, t) {
1246
1234
  let { create_tenant: n, anonymous: r } = e, i = {
@@ -1257,7 +1245,7 @@ var Mt = /* @__PURE__ */ function(e) {
1257
1245
  verifier: t
1258
1246
  }, B);
1259
1247
  } catch (e) {
1260
- throw mn(e, R.pkceExchange, "error.pkce.exchange", fn);
1248
+ throw gn(e, R.pkceExchange, "error.pkce.exchange", mn);
1261
1249
  }
1262
1250
  }
1263
1251
  async passwordlessSignIn(e, t, n, r) {
@@ -1270,46 +1258,46 @@ var Mt = /* @__PURE__ */ function(e) {
1270
1258
  try {
1271
1259
  return await this.axiosClient.post(R.passwordless, a, V(void 0, "passwordless.start", e.email ?? e.phone, r));
1272
1260
  } catch (e) {
1273
- throw mn(e, R.passwordless, "error.passwordless.start", pn);
1261
+ throw gn(e, R.passwordless, "error.passwordless.start", hn);
1274
1262
  }
1275
1263
  }
1276
1264
  async passwordlessSignInComplete(e, t) {
1277
1265
  try {
1278
1266
  return await this.axiosClient.post(R.passwordlessComplete, e, V(B, void 0, void 0, t));
1279
1267
  } catch (e) {
1280
- throw mn(e, R.passwordlessComplete, "error.passwordless.complete", pn);
1268
+ throw gn(e, R.passwordlessComplete, "error.passwordless.complete", hn);
1281
1269
  }
1282
1270
  }
1283
1271
  async passwordlessStatus(e, t) {
1284
1272
  try {
1285
1273
  return await this.axiosClient.post(R.passwordlessStatus, e, {
1286
1274
  ...B,
1287
- timeout: un,
1275
+ timeout: fn,
1288
1276
  signal: t?.signal
1289
1277
  });
1290
1278
  } catch (e) {
1291
- throw mn(e, R.passwordlessStatus, "error.passwordless.status", fn);
1279
+ throw gn(e, R.passwordlessStatus, "error.passwordless.status", mn);
1292
1280
  }
1293
1281
  }
1294
1282
  async checkRedirectUrl(e) {
1295
1283
  try {
1296
1284
  return (await this.axiosClient.post(R.redirectCheck, { redirect_url: e })).redirect_url;
1297
1285
  } catch (e) {
1298
- throw mn(e, R.redirectCheck, "error.redirect.check", pn);
1286
+ throw gn(e, R.redirectCheck, "error.redirect.check", hn);
1299
1287
  }
1300
1288
  }
1301
1289
  async passwordlessApprovalInfo(e) {
1302
1290
  try {
1303
1291
  return await this.axiosClient.post(R.passwordlessApprovalInfo, e);
1304
1292
  } catch (e) {
1305
- throw mn(e, R.passwordlessApprovalInfo, "error.passwordless.approval", pn);
1293
+ throw gn(e, R.passwordlessApprovalInfo, "error.passwordless.approval", hn);
1306
1294
  }
1307
1295
  }
1308
1296
  async passwordlessApprovalDecide(e) {
1309
1297
  try {
1310
1298
  return await this.axiosClient.post(R.passwordlessApprovalDecide, e);
1311
1299
  } catch (e) {
1312
- throw mn(e, R.passwordlessApprovalDecide, "error.passwordless.approval", pn);
1300
+ throw gn(e, R.passwordlessApprovalDecide, "error.passwordless.approval", hn);
1313
1301
  }
1314
1302
  }
1315
1303
  validateEmailCode(e) {
@@ -1323,7 +1311,7 @@ var Mt = /* @__PURE__ */ function(e) {
1323
1311
  refresh_token: t,
1324
1312
  device: e,
1325
1313
  ...r ? { post_logout_redirect_uri: r } : {}
1326
- }, a = n ? Ze.logout : R.logout;
1314
+ }, a = n ? $e.logout : R.logout;
1327
1315
  return this.axiosClient.post(a, i);
1328
1316
  }
1329
1317
  validateSession() {
@@ -1349,7 +1337,7 @@ var Mt = /* @__PURE__ */ function(e) {
1349
1337
  create_tenant: a ?? !1,
1350
1338
  device: t,
1351
1339
  os: n
1352
- }, s = r ? Ze.passkeyRegisterStart : R.passkeyRegisterStart;
1340
+ }, s = r ? $e.passkeyRegisterStart : R.passkeyRegisterStart;
1353
1341
  return this.axiosClient.post(s, o, V(void 0, r ? void 0 : "passkey.register", e.passkey_username, i));
1354
1342
  }
1355
1343
  passkeyRegisterComplete(e, t, n, r = !1, i) {
@@ -1357,7 +1345,7 @@ var Mt = /* @__PURE__ */ function(e) {
1357
1345
  challenge_id: n,
1358
1346
  device: t,
1359
1347
  passkey_data: e
1360
- }, o = r ? Ze.passkeyRegisterComplete : R.passkeyRegisterComplete;
1348
+ }, o = r ? $e.passkeyRegisterComplete : R.passkeyRegisterComplete;
1361
1349
  return this.axiosClient.post(o, a, V(B, void 0, void 0, i));
1362
1350
  }
1363
1351
  passkeyAuthenticateStart(e, t, n, r = !1, i) {
@@ -1366,7 +1354,7 @@ var Mt = /* @__PURE__ */ function(e) {
1366
1354
  user_id: e.user_id ?? "",
1367
1355
  device: t,
1368
1356
  os: n
1369
- }, o = r ? Ze.passkeyAuthenticateStart : R.passkeyAuthenticateStart;
1357
+ }, o = r ? $e.passkeyAuthenticateStart : R.passkeyAuthenticateStart;
1370
1358
  return this.axiosClient.post(o, a, V(void 0, r ? void 0 : "passkey.authenticate", void 0, i));
1371
1359
  }
1372
1360
  passkeyAuthenticateComplete(e, t, n, r = !1, i, a) {
@@ -1374,8 +1362,8 @@ var Mt = /* @__PURE__ */ function(e) {
1374
1362
  challenge_id: n,
1375
1363
  device: t,
1376
1364
  passkey_data: e
1377
- }, s = r ? Ze.passkeyAuthenticateComplete : R.passkeyAuthenticateComplete;
1378
- return this.axiosClient.post(s, o, hn(V(B, void 0, void 0, i), a));
1365
+ }, s = r ? $e.passkeyAuthenticateComplete : R.passkeyAuthenticateComplete;
1366
+ return this.axiosClient.post(s, o, _n(V(B, void 0, void 0, i), a));
1379
1367
  }
1380
1368
  passkeyValidate(e, t, n, r = !1, i) {
1381
1369
  let a = {
@@ -1383,27 +1371,27 @@ var Mt = /* @__PURE__ */ function(e) {
1383
1371
  device: t,
1384
1372
  challenge_id: n
1385
1373
  }, o = R.passkeyValidate;
1386
- !i && r && (o = Ze.passkeyValidate);
1374
+ !i && r && (o = $e.passkeyValidate);
1387
1375
  let s = i ? { [l]: i } : {};
1388
1376
  return this.axiosClient.post(o, a, { headers: s });
1389
1377
  }
1390
- }, _n = class {
1378
+ }, yn = class {
1391
1379
  constructor(e, t, n) {
1392
- this.axiosClient = new cn(e, t, n);
1380
+ this.axiosClient = new un(e, t, n);
1393
1381
  }
1394
1382
  setAppId(e) {
1395
1383
  this.axiosClient.setAppId(e);
1396
1384
  }
1397
1385
  getCLIAuthStatus(e) {
1398
- let t = jt(R.cliAuthStatus, { sessionId: e });
1386
+ let t = Nt(R.cliAuthStatus, { sessionId: e });
1399
1387
  return this.axiosClient.get(t);
1400
1388
  }
1401
1389
  completeCLIAuth(e) {
1402
1390
  return this.axiosClient.post(R.cliAuthComplete, e);
1403
1391
  }
1404
- }, vn = class {
1392
+ }, bn = class {
1405
1393
  constructor(e, t, n) {
1406
- this.axiosClient = new cn(e, t, n);
1394
+ this.axiosClient = new un(e, t, n);
1407
1395
  }
1408
1396
  setAppId(e) {
1409
1397
  this.axiosClient.setAppId(e);
@@ -1414,27 +1402,27 @@ var Mt = /* @__PURE__ */ function(e) {
1414
1402
  getInvitations(e) {
1415
1403
  let t = {};
1416
1404
  e.groupID && (t.group_id = e.groupID.toString()), e.skip !== void 0 && (t.skip = e.skip.toString()), e.limit !== void 0 && (t.limit = e.limit.toString());
1417
- let n = jt(R.invitationsPath, { tenantID: e.tenantID });
1405
+ let n = Nt(R.invitationsPath, { tenantID: e.tenantID });
1418
1406
  return this.axiosClient.get(n, { params: t }).then((e) => ({
1419
1407
  invites: e.invites,
1420
1408
  nextPageSkip: e.next_page_skip
1421
1409
  }));
1422
1410
  }
1423
1411
  deleteInvitation(e) {
1424
- let t = jt(R.invitationDelete, { invitationID: e });
1412
+ let t = Nt(R.invitationDelete, { invitationID: e });
1425
1413
  return this.axiosClient.delete(t);
1426
1414
  }
1427
1415
  resendInvitation(e) {
1428
- let t = jt(R.invitationResend, { invitationID: e });
1416
+ let t = Nt(R.invitationResend, { invitationID: e });
1429
1417
  return this.axiosClient.post(t, {});
1430
1418
  }
1431
1419
  getInvitationLink(e) {
1432
- let t = jt(R.invitationGetLink, { invitationID: e });
1420
+ let t = Nt(R.invitationGetLink, { invitationID: e });
1433
1421
  return this.axiosClient.get(t);
1434
1422
  }
1435
- }, yn = class {
1423
+ }, xn = class {
1436
1424
  constructor(e, t, n) {
1437
- this.axiosClient = new cn(e, t, n);
1425
+ this.axiosClient = new un(e, t, n);
1438
1426
  }
1439
1427
  setAppId(e) {
1440
1428
  this.axiosClient.setAppId(e);
@@ -1448,9 +1436,9 @@ var Mt = /* @__PURE__ */ function(e) {
1448
1436
  getPasskeySettings() {
1449
1437
  return this.axiosClient.get(R.settingsPasskey);
1450
1438
  }
1451
- }, bn = class {
1439
+ }, Sn = class {
1452
1440
  constructor(e, t, n) {
1453
- this.axiosClient = new cn(e, t, n);
1441
+ this.axiosClient = new un(e, t, n);
1454
1442
  }
1455
1443
  setAppId(e) {
1456
1444
  this.axiosClient.setAppId(e);
@@ -1564,58 +1552,58 @@ var Mt = /* @__PURE__ */ function(e) {
1564
1552
  let r = `${R.tenantPath}/${e}/group/${t}/invite/email/${n}`;
1565
1553
  return this.axiosClient.delete(r);
1566
1554
  }
1567
- }, xn = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, Sn = (e) => ({
1555
+ }, Cn = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, wn = (e) => ({
1568
1556
  withCredentials: !0,
1569
- ...xn(e)
1570
- }), Cn = ({ qr_code_image: e, qr_code: t, ...n }) => ({
1557
+ ...Cn(e)
1558
+ }), Tn = ({ qr_code_image: e, qr_code: t, ...n }) => ({
1571
1559
  ...n,
1572
1560
  qr_code: (t ?? e ?? "").replace(/^data:image\/png;base64,/, "")
1573
- }), wn = {
1561
+ }), En = {
1574
1562
  "error.2fa.setup.token.expired": "EXPIRED_TOKEN",
1575
1563
  "error.2fa.setup.token.revoked": "REVOKED_TOKEN",
1576
1564
  "error.2fa.setup.token.already_used": "ALREADY_USED",
1577
1565
  "error.2fa.setup.token.rate.limit.exceeded": "RATE_LIMITED"
1578
- }, Tn = class {
1566
+ }, Dn = class {
1579
1567
  constructor(e, t, n) {
1580
- this.axiosClient = new cn(e, t, n);
1568
+ this.axiosClient = new un(e, t, n);
1581
1569
  }
1582
1570
  setAppId(e) {
1583
1571
  this.axiosClient.setAppId(e);
1584
1572
  }
1585
1573
  getStatus(e) {
1586
- return this.axiosClient.get(R.twoFactorStatus, $t(e));
1574
+ return this.axiosClient.get(R.twoFactorStatus, tn(e));
1587
1575
  }
1588
1576
  async beginSetup(e) {
1589
- return Cn(await this.axiosClient.post(R.twoFactorSetupBegin, {}, $t(e)));
1577
+ return Tn(await this.axiosClient.post(R.twoFactorSetupBegin, {}, tn(e)));
1590
1578
  }
1591
1579
  confirmSetup(e, t) {
1592
- return this.axiosClient.post(R.twoFactorSetupConfirm, e, $t(t));
1580
+ return this.axiosClient.post(R.twoFactorSetupConfirm, e, tn(t));
1593
1581
  }
1594
1582
  getEnrollment(e) {
1595
- return this.axiosClient.get(R.twoFactorEnrollment, $t(e));
1583
+ return this.axiosClient.get(R.twoFactorEnrollment, tn(e));
1596
1584
  }
1597
1585
  sendSetupLink(e) {
1598
- return this.axiosClient.post(R.twoFactorEnrollmentEmailLink, void 0, $t(e));
1586
+ return this.axiosClient.post(R.twoFactorEnrollmentEmailLink, void 0, tn(e));
1599
1587
  }
1600
1588
  async beginEnrollment(e) {
1601
- return Cn(await this.axiosClient.post(R.twoFactorEnrollmentBegin, void 0, $t(e)));
1589
+ return Tn(await this.axiosClient.post(R.twoFactorEnrollmentBegin, void 0, tn(e)));
1602
1590
  }
1603
1591
  confirmEnrollment(e, t) {
1604
- return this.axiosClient.post(R.twoFactorEnrollmentConfirm, t, $t(e));
1592
+ return this.axiosClient.post(R.twoFactorEnrollmentConfirm, t, tn(e));
1605
1593
  }
1606
1594
  verify(e) {
1607
1595
  let { tfa_token: t, code: n, trust_device: r } = e;
1608
1596
  return this.axiosClient.post(R.twoFactorVerify, {
1609
1597
  code: n,
1610
1598
  ...r ? { trust_device: !0 } : {}
1611
- }, Sn(t));
1599
+ }, wn(t));
1612
1600
  }
1613
1601
  useRecoveryCode(e) {
1614
1602
  let { tfa_token: t, recovery_code: n, trust_device: r } = e;
1615
1603
  return this.axiosClient.post(R.twoFactorRecovery, {
1616
1604
  recovery_code: n,
1617
1605
  ...r ? { trust_device: !0 } : {}
1618
- }, Sn(t));
1606
+ }, wn(t));
1619
1607
  }
1620
1608
  disable(e) {
1621
1609
  return this.axiosClient.delete(R.twoFactor, { data: e });
@@ -1645,7 +1633,7 @@ var Mt = /* @__PURE__ */ function(e) {
1645
1633
  if (e instanceof z) return {
1646
1634
  success: !1,
1647
1635
  error: {
1648
- code: wn[e.id] ?? this.mapStatusToErrorCode(e.status),
1636
+ code: En[e.id] ?? this.mapStatusToErrorCode(e.status),
1649
1637
  message: e.message || this.getDefaultErrorMessage(e.status)
1650
1638
  }
1651
1639
  };
@@ -1710,21 +1698,21 @@ var Mt = /* @__PURE__ */ function(e) {
1710
1698
  return this.axiosClient.post(R.TwoFactorSetupStart, {
1711
1699
  method: "recovery_codes",
1712
1700
  via: e
1713
- }, nn());
1701
+ }, an());
1714
1702
  }
1715
1703
  completeRecoveryCodesByCode(e, t) {
1716
1704
  return this.axiosClient.post(R.TwoFactorSetupComplete, {
1717
1705
  method: "recovery_codes",
1718
1706
  setup_id: e,
1719
1707
  code: t
1720
- }, nn());
1708
+ }, an());
1721
1709
  }
1722
1710
  removeMethod(e) {
1723
- let t = jt(R.TwoFactorMethodRemove, { id: e });
1711
+ let t = Nt(R.TwoFactorMethodRemove, { id: e });
1724
1712
  return this.axiosClient.delete(t);
1725
1713
  }
1726
1714
  requestChallenge(e, t) {
1727
- return this.axiosClient.post(R.TwoFactorChallenge, e, nn(xn(t)));
1715
+ return this.axiosClient.post(R.TwoFactorChallenge, e, an(Cn(t)));
1728
1716
  }
1729
1717
  verifyV2(e, t) {
1730
1718
  let { trust_device: n, response: r, ...i } = e;
@@ -1732,13 +1720,13 @@ var Mt = /* @__PURE__ */ function(e) {
1732
1720
  ...i,
1733
1721
  ...r === void 0 ? {} : { response: r },
1734
1722
  ...n ? { trust_device: !0 } : {}
1735
- }, Sn(t));
1723
+ }, wn(t));
1736
1724
  }
1737
1725
  switchToAlternative(e, t) {
1738
- return this.axiosClient.post(R.TwoFactorAlternative, e, nn(xn(t)));
1726
+ return this.axiosClient.post(R.TwoFactorAlternative, e, an(Cn(t)));
1739
1727
  }
1740
1728
  async pushStatus(e, t) {
1741
- let n = await this.axiosClient.post(R.TwoFactorPushStatus, { challenge_id: e }, nn(xn(t)));
1729
+ let n = await this.axiosClient.post(R.TwoFactorPushStatus, { challenge_id: e }, an(Cn(t)));
1742
1730
  return n.status === "approved" ? { status: "approved" } : {
1743
1731
  status: "pending",
1744
1732
  expires_in_seconds: n.expires_in_seconds ?? 0
@@ -1748,11 +1736,11 @@ var Mt = /* @__PURE__ */ function(e) {
1748
1736
  return (await this.axiosClient.get(R.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
1749
1737
  }
1750
1738
  revokeTrustedDevice(e) {
1751
- let t = jt(R.TwoFactorTrustedDeviceRevoke, { id: e });
1739
+ let t = Nt(R.TwoFactorTrustedDeviceRevoke, { id: e });
1752
1740
  return this.axiosClient.delete(t);
1753
1741
  }
1754
1742
  removeTrustedDevicePush(e) {
1755
- let t = jt(R.TwoFactorTrustedDevicePushRemove, { id: e });
1743
+ let t = Nt(R.TwoFactorTrustedDevicePushRemove, { id: e });
1756
1744
  return this.axiosClient.delete(t);
1757
1745
  }
1758
1746
  async getPreferredMethod() {
@@ -1764,15 +1752,15 @@ var Mt = /* @__PURE__ */ function(e) {
1764
1752
  async clearPreferredMethod() {
1765
1753
  await this.axiosClient.delete(R.TwoFactorPreferredMethod);
1766
1754
  }
1767
- }, En = class {
1755
+ }, On = class {
1768
1756
  constructor(e, t, n) {
1769
- this.axiosClient = new cn(e, t, n);
1757
+ this.axiosClient = new un(e, t, n);
1770
1758
  }
1771
1759
  setAppId(e) {
1772
1760
  this.axiosClient.setAppId(e);
1773
1761
  }
1774
1762
  startUpgrade(e) {
1775
- return this.axiosClient.post(R.upgradeStart, e, Ke({}));
1763
+ return this.axiosClient.post(R.upgradeStart, e, Je({}));
1776
1764
  }
1777
1765
  startHostedUpgrade(e) {
1778
1766
  return this.axiosClient.post(R.hostedUpgradeStart, e, { withCredentials: !0 });
@@ -1780,9 +1768,9 @@ var Mt = /* @__PURE__ */ function(e) {
1780
1768
  async commitHostedUpgrade(e) {
1781
1769
  await this.axiosClient.post(R.hostedUpgrade, e, { withCredentials: !0 });
1782
1770
  }
1783
- }, Dn = class {
1771
+ }, kn = class {
1784
1772
  constructor(e, t, n) {
1785
- this.axiosClient = new cn(e, t, n);
1773
+ this.axiosClient = new un(e, t, n);
1786
1774
  }
1787
1775
  setAppId(e) {
1788
1776
  this.axiosClient.setAppId(e);
@@ -1826,73 +1814,73 @@ var Mt = /* @__PURE__ */ function(e) {
1826
1814
  return this.axiosClient.post(R.userSessionsRevokeOthers);
1827
1815
  }
1828
1816
  requestAddressChangeProof(e) {
1829
- return this.axiosClient.post(R.AddressChangeProof, { method: e }, nn());
1817
+ return this.axiosClient.post(R.AddressChangeProof, { method: e }, an());
1830
1818
  }
1831
1819
  updateProfile(e, t) {
1832
1820
  return this.axiosClient.patch(R.userProfile, {
1833
1821
  ...e,
1834
1822
  ...t ? { proof: t } : {}
1835
- }, nn());
1823
+ }, an());
1836
1824
  }
1837
- }, On = "pf-device-proof+jwt", kn = {
1825
+ }, An = "pf-device-proof+jwt", jn = {
1838
1826
  name: "ECDSA",
1839
1827
  hash: "SHA-256"
1840
1828
  };
1841
- function An(e) {
1829
+ function Mn(e) {
1842
1830
  let t = "";
1843
1831
  for (let n of e) t += String.fromCharCode(n);
1844
1832
  return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1845
1833
  }
1846
- function jn(e) {
1847
- return An(new TextEncoder().encode(JSON.stringify(e)));
1834
+ function Nn(e) {
1835
+ return Mn(new TextEncoder().encode(JSON.stringify(e)));
1848
1836
  }
1849
- async function Mn(e) {
1850
- let { kty: t, crv: n, x: r, y: i } = e.jwk, a = `${jn({
1837
+ async function Pn(e) {
1838
+ let { kty: t, crv: n, x: r, y: i } = e.jwk, a = `${Nn({
1851
1839
  alg: "ES256",
1852
- typ: On,
1840
+ typ: An,
1853
1841
  jwk: {
1854
1842
  kty: t,
1855
1843
  crv: n,
1856
1844
  x: r,
1857
1845
  y: i
1858
1846
  }
1859
- })}.${jn({
1847
+ })}.${Nn({
1860
1848
  jti: e.jti,
1861
1849
  ctr: e.ctr,
1862
1850
  did: e.did,
1863
1851
  use: e.use,
1864
1852
  iat: e.iat
1865
- })}`, o = await crypto.subtle.sign(kn, e.privateKey, new TextEncoder().encode(a));
1866
- return `${a}.${An(new Uint8Array(o))}`;
1853
+ })}`, o = await crypto.subtle.sign(jn, e.privateKey, new TextEncoder().encode(a));
1854
+ return `${a}.${Mn(new Uint8Array(o))}`;
1867
1855
  }
1868
- async function Nn(e) {
1856
+ async function Fn(e) {
1869
1857
  let t = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(e));
1870
- return An(new Uint8Array(t));
1858
+ return Mn(new Uint8Array(t));
1871
1859
  }
1872
- async function Pn(e, t = "") {
1860
+ async function In(e, t = "") {
1873
1861
  let n = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${e}\n${t}`));
1874
- return An(new Uint8Array(n));
1862
+ return Mn(new Uint8Array(n));
1875
1863
  }
1876
1864
  // lib/device-key/store.ts
1877
- var Fn = 1, In = "key", Ln = "current", Rn = (e) => new Promise((t, n) => {
1865
+ var Ln = 1, Rn = "key", zn = "current", Bn = (e) => new Promise((t, n) => {
1878
1866
  e.onsuccess = () => t(e.result), e.onerror = () => n(e.error);
1879
- }), zn = (e) => new Promise((t, n) => {
1867
+ }), Vn = (e) => new Promise((t, n) => {
1880
1868
  e.oncomplete = () => t(), e.onerror = () => n(e.error), e.onabort = () => n(e.error ?? /* @__PURE__ */ Error("The device key transaction was aborted"));
1881
1869
  });
1882
- function Bn(e) {
1870
+ function Hn(e) {
1883
1871
  let t, n = () => (t ?? (t = new Promise((t, n) => {
1884
- let r = indexedDB.open(e, Fn);
1872
+ let r = indexedDB.open(e, Ln);
1885
1873
  r.onupgradeneeded = () => {
1886
- r.result.objectStoreNames.contains(In) || r.result.createObjectStore(In);
1874
+ r.result.objectStoreNames.contains(Rn) || r.result.createObjectStore(Rn);
1887
1875
  }, r.onsuccess = () => t(r.result), r.onerror = () => n(r.error), r.onblocked = () => n(/* @__PURE__ */ Error("The device key database is blocked by another tab"));
1888
1876
  }).catch((e) => {
1889
1877
  throw t = void 0, e;
1890
1878
  })), t), r = async (e) => {
1891
- let t = (await n()).transaction(In, "readwrite"), r = zn(t), i = await e(t.objectStore(In));
1879
+ let t = (await n()).transaction(Rn, "readwrite"), r = Vn(t), i = await e(t.objectStore(Rn));
1892
1880
  return await r, i;
1893
- }, i = (e) => Rn(e.get(Ln)), a = async () => {
1881
+ }, i = (e) => Bn(e.get(zn)), a = async () => {
1894
1882
  let e = await n();
1895
- return await i(e.transaction(In, "readonly").objectStore(In));
1883
+ return await i(e.transaction(Rn, "readonly").objectStore(Rn));
1896
1884
  };
1897
1885
  return {
1898
1886
  read: a,
@@ -1908,7 +1896,7 @@ function Bn(e) {
1908
1896
  counter: 0,
1909
1897
  enrolled: !1
1910
1898
  };
1911
- return e.put(r, Ln), r;
1899
+ return e.put(r, zn), r;
1912
1900
  });
1913
1901
  },
1914
1902
  next() {
@@ -1919,7 +1907,7 @@ function Bn(e) {
1919
1907
  ...t,
1920
1908
  counter: n
1921
1909
  };
1922
- return e.put(r, Ln), {
1910
+ return e.put(r, zn), {
1923
1911
  record: r,
1924
1912
  ctr: n
1925
1913
  };
@@ -1931,27 +1919,27 @@ function Bn(e) {
1931
1919
  t && e.put({
1932
1920
  ...t,
1933
1921
  enrolled: !0
1934
- }, Ln);
1922
+ }, zn);
1935
1923
  });
1936
1924
  },
1937
1925
  async clear() {
1938
- await r((e) => Rn(e.delete(Ln)));
1926
+ await r((e) => Bn(e.delete(zn)));
1939
1927
  }
1940
1928
  };
1941
1929
  }
1942
1930
  // lib/device-key/service.ts
1943
- var Vn = "Device keys need IndexedDB and WebCrypto", Hn = {
1931
+ var Un = "Device keys need IndexedDB and WebCrypto", Wn = {
1944
1932
  name: "ECDSA",
1945
1933
  namedCurve: "P-256"
1946
1934
  };
1947
- function Un(e) {
1935
+ function Gn(e) {
1948
1936
  return `${e ? `${e}_` : ""}passflow_device_key`;
1949
1937
  }
1950
- function Wn() {
1938
+ function Kn() {
1951
1939
  return typeof indexedDB < "u" && typeof crypto < "u" && crypto.subtle !== void 0;
1952
1940
  }
1953
- async function Gn() {
1954
- let e = await crypto.subtle.generateKey(Hn, !1, ["sign", "verify"]), { kty: t, crv: n, x: r, y: i } = await crypto.subtle.exportKey("jwk", e.publicKey);
1941
+ async function qn() {
1942
+ let e = await crypto.subtle.generateKey(Wn, !1, ["sign", "verify"]), { kty: t, crv: n, x: r, y: i } = await crypto.subtle.exportKey("jwk", e.publicKey);
1955
1943
  if (t !== "EC" || n !== "P-256" || !r || !i) throw Error("The device key could not be exported");
1956
1944
  return {
1957
1945
  keyPair: e,
@@ -1963,8 +1951,8 @@ async function Gn() {
1963
1951
  }
1964
1952
  };
1965
1953
  }
1966
- function Kn(e) {
1967
- let t = e.now ?? Date.now, n = Wn(), r = n ? Bn(e.dbName) : void 0, i = (n, r, i, a) => Mn({
1954
+ function Jn(e) {
1955
+ let t = e.now ?? Date.now, n = Kn(), r = n ? Hn(e.dbName) : void 0, i = (n, r, i, a) => Pn({
1968
1956
  privateKey: n.keyPair.privateKey,
1969
1957
  jwk: n.jwk,
1970
1958
  jti: a,
@@ -1984,8 +1972,8 @@ function Kn(e) {
1984
1972
  if (n?.record.enrolled) return await i(n.record, n.ctr, e, t);
1985
1973
  },
1986
1974
  async enrolProof(e) {
1987
- if (!r) throw Error(Vn);
1988
- await r.ensure(Gn);
1975
+ if (!r) throw Error(Un);
1976
+ await r.ensure(qn);
1989
1977
  let t = await r.next();
1990
1978
  if (!t) throw Error("The device key was deleted while enrolling");
1991
1979
  return await i(t.record, t.ctr, "enrol", e);
@@ -1998,53 +1986,53 @@ function Kn(e) {
1998
1986
  }
1999
1987
  };
2000
1988
  }
2001
- var qn = {
1989
+ var Yn = {
2002
1990
  keyReused: "error.device.key.reused",
2003
1991
  proofRequired: "error.device.proof.required",
2004
1992
  stepUpRequired: "error.device.key.step_up_required",
2005
1993
  proofUnavailable: "error.device.proof.unavailable"
2006
- }, Jn = (e) => typeof e == "string" && e.startsWith("error.device."), Yn = 10, Xn = 20, Zn = class extends Error {
1994
+ }, Xn = (e) => typeof e == "string" && e.startsWith("error.device."), Zn = 10, Qn = 20, $n = class extends Error {
2007
1995
  constructor(e) {
2008
1996
  super(`Passflow fetch middleware '${e}' resolved without calling next(). Every registered middleware must delegate exactly once; swallowing a request would drop a caller's fetch inside the Passflow wrapper.`), this.name = "FetchMiddlewareContractError", this.middlewareName = e;
2009
1997
  }
2010
- }, Qn = [], $n = 0, er = !1, tr, nr, rr = (e, t) => e.priority - t.priority || e.seq - t.seq, ir = () => typeof globalThis > "u" ? void 0 : globalThis, ar = async (e, t, n, r) => {
1998
+ }, er = [], tr = 0, nr = !1, rr, ir, ar = (e, t) => e.priority - t.priority || e.seq - t.seq, or = () => typeof globalThis > "u" ? void 0 : globalThis, sr = async (e, t, n, r) => {
2011
1999
  if (t >= e.length) {
2012
- let e = tr;
2000
+ let e = rr;
2013
2001
  if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
2014
2002
  return e(n, r);
2015
2003
  }
2016
2004
  let i = e[t];
2017
- if (!i) return ar(e, e.length, n, r);
2018
- let a = !1, o = await i.middleware((n, r) => (a = !0, ar(e, t + 1, n, r)), n, r);
2019
- if (!a) throw new Zn(i.name);
2005
+ if (!i) return sr(e, e.length, n, r);
2006
+ let a = !1, o = await i.middleware((n, r) => (a = !0, sr(e, t + 1, n, r)), n, r);
2007
+ if (!a) throw new $n(i.name);
2020
2008
  return o;
2021
- }, or = () => {
2022
- let e = ir();
2009
+ }, cr = () => {
2010
+ let e = or();
2023
2011
  if (!e || typeof e.fetch != "function") return !1;
2024
- let t = e.fetch.bind(e), n = (e, t) => ar([...Qn].sort(rr), 0, e, t);
2025
- return tr = t, nr = n, e.fetch = n, er = !0, !0;
2026
- }, sr = () => {
2027
- let e = ir();
2028
- e && nr && e.fetch === nr && (tr && (e.fetch = tr), er = !1, nr = void 0, tr = void 0);
2029
- }, cr = (e, t) => {
2030
- if (!er && !or()) return () => {};
2012
+ let t = e.fetch.bind(e), n = (e, t) => sr([...er].sort(ar), 0, e, t);
2013
+ return rr = t, ir = n, e.fetch = n, nr = !0, !0;
2014
+ }, lr = () => {
2015
+ let e = or();
2016
+ e && ir && e.fetch === ir && (rr && (e.fetch = rr), nr = !1, ir = void 0, rr = void 0);
2017
+ }, ur = (e, t) => {
2018
+ if (!nr && !cr()) return () => {};
2031
2019
  let n = {
2032
2020
  middleware: e,
2033
2021
  name: t.name,
2034
2022
  priority: t.priority,
2035
- seq: $n++
2023
+ seq: tr++
2036
2024
  };
2037
- Qn.push(n);
2025
+ er.push(n);
2038
2026
  let r = !1;
2039
2027
  return () => {
2040
- r || (r = !0, Qn = Qn.filter((e) => e !== n), Qn.length === 0 && sr());
2028
+ r || (r = !0, er = er.filter((e) => e !== n), er.length === 0 && lr());
2041
2029
  };
2042
- }, lr = () => {
2043
- let e = ir();
2030
+ }, dr = () => {
2031
+ let e = or();
2044
2032
  return {
2045
- installed: er,
2046
- names: [...Qn].sort(rr).map((e) => e.name),
2047
- foreignPatch: er && !!e && !!nr && e.fetch !== nr
2033
+ installed: nr,
2034
+ names: [...er].sort(ar).map((e) => e.name),
2035
+ foreignPatch: nr && !!e && !!ir && e.fetch !== ir
2048
2036
  };
2049
2037
  }, H = class e extends Error {
2050
2038
  constructor(t) {
@@ -2115,7 +2103,7 @@ var qn = {
2115
2103
  let e = `M2MError [${this.code}]: ${this.message}`;
2116
2104
  return this.status && (e += ` (HTTP ${this.status})`), e;
2117
2105
  }
2118
- }, ur = class extends H {
2106
+ }, fr = class extends H {
2119
2107
  constructor(e, t) {
2120
2108
  super({
2121
2109
  code: "temporarily_unavailable",
@@ -2124,7 +2112,7 @@ var qn = {
2124
2112
  cause: t
2125
2113
  }), this.name = "M2MNetworkError";
2126
2114
  }
2127
- }, dr = class extends H {
2115
+ }, pr = class extends H {
2128
2116
  constructor(e, t) {
2129
2117
  super({
2130
2118
  code: "invalid_request",
@@ -2133,7 +2121,7 @@ var qn = {
2133
2121
  cause: t
2134
2122
  }), this.name = "M2MTokenParseError";
2135
2123
  }
2136
- }, fr = class extends H {
2124
+ }, mr = class extends H {
2137
2125
  constructor(e) {
2138
2126
  super({
2139
2127
  code: "invalid_request",
@@ -2141,7 +2129,7 @@ var qn = {
2141
2129
  status: 400
2142
2130
  }), this.name = "M2MConfigError";
2143
2131
  }
2144
- }, pr = {
2132
+ }, hr = {
2145
2133
  InvalidRequest: "invalid_request",
2146
2134
  InvalidClient: "invalid_client",
2147
2135
  InvalidGrant: "invalid_grant",
@@ -2151,14 +2139,14 @@ var qn = {
2151
2139
  RateLimitExceeded: "rate_limit_exceeded",
2152
2140
  ServerError: "server_error",
2153
2141
  TemporarilyUnavailable: "temporarily_unavailable"
2154
- }, mr = {
2142
+ }, gr = {
2155
2143
  TOKEN_ENDPOINT: "/oauth2/token",
2156
2144
  TIMEOUT: 1e4,
2157
2145
  RETRIES: 3,
2158
2146
  RETRY_DELAY: 1e3,
2159
2147
  REFRESH_THRESHOLD: 30,
2160
2148
  CONTENT_TYPE: "application/x-www-form-urlencoded"
2161
- }, hr = class {
2149
+ }, _r = class {
2162
2150
  constructor() {
2163
2151
  this.cache = /* @__PURE__ */ new Map();
2164
2152
  }
@@ -2175,18 +2163,18 @@ var qn = {
2175
2163
  delete(e) {
2176
2164
  return this.cache.delete(e), Promise.resolve();
2177
2165
  }
2178
- }, gr = {
2166
+ }, vr = {
2179
2167
  shouldRetry(e, t) {
2180
2168
  return t >= 3 ? !1 : e.code === "server_error" || e.code === "temporarily_unavailable" || e.code === "rate_limit_exceeded" || e.status !== void 0 && e.status >= 500;
2181
2169
  },
2182
2170
  getDelay(e) {
2183
2171
  return 2 ** (e - 1) * 1e3;
2184
2172
  }
2185
- }, _r = class {
2173
+ }, yr = class {
2186
2174
  constructor(e) {
2187
- if (!e.url) throw new fr("M2M client requires a URL");
2188
- if (!e.clientId) throw new fr("M2M client requires a clientId");
2189
- if (!e.clientSecret) throw new fr("M2M client requires a clientSecret");
2175
+ if (!e.url) throw new mr("M2M client requires a URL");
2176
+ if (!e.clientId) throw new mr("M2M client requires a clientId");
2177
+ if (!e.clientSecret) throw new mr("M2M client requires a clientSecret");
2190
2178
  let t = e.url.replace(/\/$/, "");
2191
2179
  this.config = {
2192
2180
  url: t,
@@ -2195,16 +2183,16 @@ var qn = {
2195
2183
  scopes: e.scopes,
2196
2184
  audience: e.audience,
2197
2185
  autoRefresh: e.autoRefresh ?? !1,
2198
- refreshThreshold: e.refreshThreshold ?? mr.REFRESH_THRESHOLD,
2199
- timeout: e.timeout ?? mr.TIMEOUT,
2200
- retries: e.retries ?? mr.RETRIES,
2201
- retryDelay: e.retryDelay ?? mr.RETRY_DELAY,
2186
+ refreshThreshold: e.refreshThreshold ?? gr.REFRESH_THRESHOLD,
2187
+ timeout: e.timeout ?? gr.TIMEOUT,
2188
+ retries: e.retries ?? gr.RETRIES,
2189
+ retryDelay: e.retryDelay ?? gr.RETRY_DELAY,
2202
2190
  retryStrategy: e.retryStrategy,
2203
2191
  cache: e.cache,
2204
2192
  onTokenRequest: e.onTokenRequest,
2205
2193
  onTokenResponse: e.onTokenResponse,
2206
2194
  onError: e.onError
2207
- }, this.cache = e.cache ?? new hr(), this.retryStrategy = e.retryStrategy ?? gr, this.tokenEndpoint = `${t}${mr.TOKEN_ENDPOINT}`;
2195
+ }, this.cache = e.cache ?? new _r(), this.retryStrategy = e.retryStrategy ?? vr, this.tokenEndpoint = `${t}${gr.TOKEN_ENDPOINT}`;
2208
2196
  }
2209
2197
  getCacheKey(e, t) {
2210
2198
  let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
@@ -2249,7 +2237,7 @@ var qn = {
2249
2237
  let e = await fetch(this.tokenEndpoint, {
2250
2238
  method: "POST",
2251
2239
  headers: {
2252
- "Content-Type": mr.CONTENT_TYPE,
2240
+ "Content-Type": gr.CONTENT_TYPE,
2253
2241
  Accept: "application/json"
2254
2242
  },
2255
2243
  body: t.toString(),
@@ -2274,7 +2262,7 @@ var qn = {
2274
2262
  }
2275
2263
  return a;
2276
2264
  } catch (e) {
2277
- throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new ur(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new ur(`Network error: ${e.message}`, e) : e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
2265
+ throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new fr(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new fr(`Network error: ${e.message}`, e) : e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
2278
2266
  }
2279
2267
  }
2280
2268
  async executeWithRetry(e) {
@@ -2317,13 +2305,13 @@ var qn = {
2317
2305
  parseToken(e) {
2318
2306
  try {
2319
2307
  let t = e.split(".");
2320
- if (t.length !== 3) throw new dr("Invalid JWT format: expected 3 parts");
2308
+ if (t.length !== 3) throw new pr("Invalid JWT format: expected 3 parts");
2321
2309
  let n = t[1];
2322
- if (!n) throw new dr("Invalid JWT format: missing payload");
2310
+ if (!n) throw new pr("Invalid JWT format: missing payload");
2323
2311
  let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
2324
2312
  return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
2325
2313
  } catch (e) {
2326
- throw e instanceof dr ? e : new dr(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
2314
+ throw e instanceof pr ? e : new pr(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
2327
2315
  }
2328
2316
  }
2329
2317
  clearCache() {
@@ -2338,7 +2326,7 @@ var qn = {
2338
2326
  try {
2339
2327
  let e = await fetch(t, {
2340
2328
  method: "POST",
2341
- headers: { "Content-Type": mr.CONTENT_TYPE },
2329
+ headers: { "Content-Type": gr.CONTENT_TYPE },
2342
2330
  body: n.toString()
2343
2331
  });
2344
2332
  if (!e.ok && e.status !== 200) {
@@ -2365,50 +2353,50 @@ var qn = {
2365
2353
  get audience() {
2366
2354
  return this.config.audience;
2367
2355
  }
2368
- }, vr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", yr = 32, br = (e) => {
2356
+ }, br = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", xr = 32, Sr = (e) => {
2369
2357
  let t = "";
2370
2358
  for (let n = 0; n < e.length; n += 3) {
2371
2359
  let r = e[n], i = e[n + 1], a = e[n + 2];
2372
- t += vr.charAt(r >> 2), t += vr.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += vr.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += vr.charAt(a & 63));
2360
+ t += br.charAt(r >> 2), t += br.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += br.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += br.charAt(a & 63));
2373
2361
  }
2374
2362
  return t;
2375
- }, xr = () => {
2363
+ }, Cr = () => {
2376
2364
  let e = globalThis.crypto;
2377
2365
  if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
2378
2366
  return e;
2379
- }, Sr = async (e) => {
2380
- let t = await xr().subtle.digest("SHA-256", new TextEncoder().encode(e));
2381
- return br(new Uint8Array(t));
2382
- }, Cr = (e = yr) => br(xr().getRandomValues(new Uint8Array(e))), wr = async () => {
2383
- let e = Cr(yr);
2367
+ }, wr = async (e) => {
2368
+ let t = await Cr().subtle.digest("SHA-256", new TextEncoder().encode(e));
2369
+ return Sr(new Uint8Array(t));
2370
+ }, Tr = (e = xr) => Sr(Cr().getRandomValues(new Uint8Array(e))), Er = async () => {
2371
+ let e = Tr(xr);
2384
2372
  return {
2385
2373
  verifier: e,
2386
- challenge: await Sr(e)
2374
+ challenge: await wr(e)
2387
2375
  };
2388
- }, Tr = () => !!globalThis.crypto?.subtle, U = class extends Error {
2376
+ }, Dr = () => !!globalThis.crypto?.subtle, U = class extends Error {
2389
2377
  constructor(e, t) {
2390
2378
  super(t), this.code = e, this.name = "PassflowOidcError";
2391
2379
  }
2392
- }, Er = "Sign in again.", Dr = (e) => `This app is type ${e} and is a confidential client (it has a secret). For a browser app set its type to SPA; a server-side app redeems the code on its server with the secret.`, Or = "This app is a confidential client. For a browser app set its type to SPA (or token_endpoint_auth_method to none); a server-side app must redeem the code on its server with the client secret.", kr = () => new U("TOKENS_IN_URL_NOT_ALLOWED", "Tokens in the URL are accepted only for apps in Simple mode"), Ar = "passflow_oidc_pkce", jr = 6e5, Mr = (e) => {
2380
+ }, Or = "Sign in again.", kr = (e) => `This app is type ${e} and is a confidential client (it has a secret). For a browser app set its type to SPA; a server-side app redeems the code on its server with the secret.`, Ar = "This app is a confidential client. For a browser app set its type to SPA (or token_endpoint_auth_method to none); a server-side app must redeem the code on its server with the client secret.", jr = () => new U("TOKENS_IN_URL_NOT_ALLOWED", "Tokens in the URL are accepted only for apps in Simple mode"), Mr = "passflow_oidc_pkce", Nr = 6e5, Pr = (e) => {
2393
2381
  try {
2394
2382
  let t = new URL(e);
2395
2383
  return `${t.protocol}//${t.host}${t.pathname.replace(/\/+$/, "")}`;
2396
2384
  } catch {
2397
2385
  return e;
2398
2386
  }
2399
- }, Nr = (e) => !e.includes("openid") && (e.includes("id") || e.includes("oidc")) ? [...e, "openid"] : [...e], Pr = async (e) => {
2400
- if (!Tr()) throw new U("SECURE_CONTEXT_REQUIRED", "Sign-in needs the Web Crypto API, which is available only in a secure context (https or localhost)");
2401
- let t = Nr(e.scopes), n = await wr(), r = {
2387
+ }, Fr = (e) => !e.includes("openid") && (e.includes("id") || e.includes("oidc")) ? [...e, "openid"] : [...e], Ir = async (e) => {
2388
+ if (!Dr()) throw new U("SECURE_CONTEXT_REQUIRED", "Sign-in needs the Web Crypto API, which is available only in a secure context (https or localhost)");
2389
+ let t = Fr(e.scopes), n = await Er(), r = {
2402
2390
  verifier: n.verifier,
2403
- state: Cr(),
2404
- ...t.includes("openid") ? { nonce: Cr() } : {},
2391
+ state: Tr(),
2392
+ ...t.includes("openid") ? { nonce: Tr() } : {},
2405
2393
  clientId: e.clientId,
2406
2394
  redirectUri: e.redirectUri,
2407
2395
  scopes: t,
2408
- expiresAt: Date.now() + jr
2396
+ expiresAt: Date.now() + Nr
2409
2397
  };
2410
2398
  try {
2411
- sessionStorage.setItem(Ar, JSON.stringify(r));
2399
+ sessionStorage.setItem(Mr, JSON.stringify(r));
2412
2400
  } catch {
2413
2401
  throw new U("STORAGE_UNAVAILABLE", "Sign-in needs sessionStorage, which cannot be written here");
2414
2402
  }
@@ -2423,37 +2411,37 @@ var qn = {
2423
2411
  code_challenge_method: "S256",
2424
2412
  ...r.nonce ? { nonce: r.nonce } : {}
2425
2413
  }).toString(), i.toString();
2426
- }, Fr = (e) => {
2414
+ }, Lr = (e) => {
2427
2415
  let t = e;
2428
2416
  return typeof t == "object" && !!t && typeof t.verifier == "string" && typeof t.state == "string" && typeof t.clientId == "string" && typeof t.redirectUri == "string" && Array.isArray(t.scopes) && typeof t.expiresAt == "number";
2429
- }, Ir = () => {
2417
+ }, Rr = () => {
2430
2418
  let e;
2431
2419
  try {
2432
- e = sessionStorage.getItem(Ar);
2420
+ e = sessionStorage.getItem(Mr);
2433
2421
  } catch {
2434
2422
  return { status: "none" };
2435
2423
  }
2436
2424
  if (!e) return { status: "none" };
2437
2425
  try {
2438
2426
  let t = JSON.parse(e);
2439
- if (Fr(t) && Date.now() < t.expiresAt) return {
2427
+ if (Lr(t) && Date.now() < t.expiresAt) return {
2440
2428
  status: "live",
2441
2429
  slot: t
2442
2430
  };
2443
2431
  } catch {}
2444
2432
  return { status: "unusable" };
2445
- }, Lr = () => {
2433
+ }, zr = () => {
2446
2434
  try {
2447
- sessionStorage.removeItem(Ar);
2435
+ sessionStorage.removeItem(Mr);
2448
2436
  } catch {}
2449
- }, Rr = async (e) => {
2437
+ }, Br = async (e) => {
2450
2438
  try {
2451
2439
  let t = await e.json();
2452
2440
  return typeof t == "object" && t ? t : void 0;
2453
2441
  } catch {
2454
2442
  return;
2455
2443
  }
2456
- }, zr = async (e, t, n) => {
2444
+ }, Vr = async (e, t, n) => {
2457
2445
  let r;
2458
2446
  try {
2459
2447
  r = await fetch(`${e.replace(/\/+$/, "")}/oidc/token`, {
@@ -2468,11 +2456,11 @@ var qn = {
2468
2456
  }).toString()
2469
2457
  });
2470
2458
  } catch {
2471
- throw new U("TOKEN_EXCHANGE_FAILED", Er);
2459
+ throw new U("TOKEN_EXCHANGE_FAILED", Or);
2472
2460
  }
2473
- let i = await Rr(r);
2474
- if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client", Or) : i?.error === "invalid_grant" ? new U("invalid_grant", Er) : new U("TOKEN_EXCHANGE_FAILED", Er);
2475
- if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED", Er);
2461
+ let i = await Br(r);
2462
+ if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client", Ar) : i?.error === "invalid_grant" ? new U("invalid_grant", Or) : new U("TOKEN_EXCHANGE_FAILED", Or);
2463
+ if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED", Or);
2476
2464
  let a = typeof i.id_token == "string" ? i.id_token : void 0;
2477
2465
  if (n.scopes.includes("openid")) {
2478
2466
  let e;
@@ -2481,7 +2469,7 @@ var qn = {
2481
2469
  } catch {
2482
2470
  e = void 0;
2483
2471
  }
2484
- if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${Er}`);
2472
+ if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${Or}`);
2485
2473
  }
2486
2474
  return {
2487
2475
  access_token: i.access_token,
@@ -2489,13 +2477,13 @@ var qn = {
2489
2477
  ...a ? { id_token: a } : {},
2490
2478
  scopes: n.scopes
2491
2479
  };
2492
- }, Br = "error", Vr = /* @__PURE__ */ new WeakMap(), Hr = (e, t) => {
2480
+ }, Hr = "error", Ur = /* @__PURE__ */ new WeakMap(), Wr = (e, t) => {
2493
2481
  if (typeof t != "object" && typeof t != "function" || t === null) return !0;
2494
- let n = Vr.get(e);
2495
- return n || (n = /* @__PURE__ */ new WeakSet(), Vr.set(e, n)), !n.has(t) && (n.add(t), !0);
2496
- }, W = (e, t) => Hr(e, t.originalError) ? (e.notify(Br, t), !0) : !1, G = /* @__PURE__ */ function(e) {
2482
+ let n = Ur.get(e);
2483
+ return n || (n = /* @__PURE__ */ new WeakSet(), Ur.set(e, n)), !n.has(t) && (n.add(t), !0);
2484
+ }, W = (e, t) => Wr(e, t.originalError) ? (e.notify(Hr, t), !0) : !1, G = /* @__PURE__ */ function(e) {
2497
2485
  return e.SignIn = "signin", e.SignInStart = "signin:start", e.Register = "register", e.RegisterStart = "register:start", e.EmailVerificationRequired = "email-verification:required", e.SignOut = "signout", e.SessionRestored = "session:restored", e.SessionExpired = "session:expired", e.Error = "error", e.Refresh = "refresh", e.RefreshStart = "refresh:start", e.TokenCacheExpired = "token-cache-expired", e.TwoFactorRequired = "2fa:required", e.TwoFactorSetupStarted = "2fa:setup_started", e.TwoFactorEnabled = "2fa:enabled", e.TwoFactorDisabled = "2fa:disabled", e.TwoFactorVerified = "2fa:verified", e.TwoFactorRecoveryUsed = "2fa:recovery_used", e.TwoFactorRecoveryCodesLow = "2fa:recovery_low", e.TwoFactorRecoveryCodesExhausted = "2fa:recovery_exhausted", e.TwoFactorSetupMagicLinkValidated = "2fa:magic_link_validated", e.TwoFactorSetupMagicLinkFailed = "2fa:magic_link_failed", e.TwoFactorChallengeReceived = "two_factor_challenge_received", e.TwoFactorMethodSwitched = "two_factor_method_switched", e.TwoFactorDeviceTrusted = "two_factor_device_trusted", e.RefreshFailing = "refresh:failing", e.RefreshRecovered = "refresh:recovered", e.AntiBotSolving = "anti-bot:solving", e.AntiBotSolved = "anti-bot:solved", e;
2498
- }({}), Ur = class {
2486
+ }({}), Gr = class {
2499
2487
  constructor() {
2500
2488
  this.subscribers = /* @__PURE__ */ new Map();
2501
2489
  }
@@ -2514,40 +2502,40 @@ var qn = {
2514
2502
  n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
2515
2503
  }
2516
2504
  notify(e, t) {
2517
- e === "error" && Hr(this, t?.originalError), this.subscribers.forEach((n, r) => {
2505
+ e === "error" && Wr(this, t?.originalError), this.subscribers.forEach((n, r) => {
2518
2506
  (!n || n.has(e)) && r.onAuthChange?.(e, t);
2519
2507
  });
2520
2508
  }
2521
2509
  notifyError(e) {
2522
2510
  return W(this, e);
2523
2511
  }
2524
- }, Wr = 256, Gr = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), Kr = (e) => {
2512
+ }, Kr = 256, qr = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), Jr = (e) => {
2525
2513
  let t = new Uint8Array(e), n = "";
2526
- for (let e of t) n += Gr[e];
2514
+ for (let e of t) n += qr[e];
2527
2515
  return n;
2528
- }, qr = class extends Error {};
2529
- async function Jr(e, t, n, r = Infinity) {
2516
+ }, Yr = class extends Error {};
2517
+ async function Xr(e, t, n, r = Infinity) {
2530
2518
  let i = globalThis.crypto?.subtle;
2531
2519
  if (!i) throw Error("Web Crypto unavailable");
2532
2520
  let a = t.toLowerCase(), o = new TextEncoder();
2533
- for (let t = 0; t <= n; t += Wr) {
2534
- if (Date.now() > r) throw new qr("Solve timed out");
2535
- let s = Math.min(t + Wr - 1, n), c = [];
2521
+ for (let t = 0; t <= n; t += Kr) {
2522
+ if (Date.now() > r) throw new Yr("Solve timed out");
2523
+ let s = Math.min(t + Kr - 1, n), c = [];
2536
2524
  for (let n = t; n <= s; n++) c.push(i.digest("SHA-256", o.encode(`${e}:${n}`)));
2537
2525
  let l = await Promise.all(c);
2538
- for (let e = 0; e < l.length; e++) if (Kr(l[e]) === a) return t + e;
2526
+ for (let e = 0; e < l.length; e++) if (Jr(l[e]) === a) return t + e;
2539
2527
  }
2540
2528
  return null;
2541
2529
  }
2542
2530
  // lib/anti-bot/solve.ts
2543
- var Yr = "The browser check could not be completed. Try again later.", Xr = "Verification failed. Try again.", Zr = 6e4, Qr = class extends Error {}, $r = (e, t, n, r) => new z({
2531
+ var Zr = "The browser check could not be completed. Try again later.", Qr = "Verification failed. Try again.", $r = 6e4, ei = class extends Error {}, ti = (e, t, n, r) => new z({
2544
2532
  id: e,
2545
2533
  message: t,
2546
2534
  status: 0,
2547
2535
  location: n,
2548
2536
  time: (/* @__PURE__ */ new Date()).toISOString()
2549
- }, r === void 0 ? void 0 : { cause: r }), ei = (e, t) => new Promise((n, r) => {
2550
- let i = new Worker(e), a = setTimeout(() => o(() => r(new Qr())), Zr), o = (e) => {
2537
+ }, r === void 0 ? void 0 : { cause: r }), ni = (e, t) => new Promise((n, r) => {
2538
+ let i = new Worker(e), a = setTimeout(() => o(() => r(new ei())), $r), o = (e) => {
2551
2539
  clearTimeout(a), i.terminate(), e();
2552
2540
  };
2553
2541
  i.addEventListener("message", (e) => {
@@ -2555,23 +2543,23 @@ var Yr = "The browser check could not be completed. Try again later.", Xr = "Ver
2555
2543
  t && "error" in t ? o(() => r(Error(t.error))) : o(() => n(t?.number ?? null));
2556
2544
  }), i.addEventListener("error", () => o(() => r(/* @__PURE__ */ Error("Anti-bot worker failed")))), i.addEventListener("messageerror", () => o(() => r(/* @__PURE__ */ Error("Anti-bot worker message failed")))), i.postMessage(t);
2557
2545
  });
2558
- async function ti(e, t, n = "anti-bot") {
2559
- if (e.algorithm !== "SHA-256") throw $r(lt, Yr, n);
2560
- if (!Number.isSafeInteger(e.max) || e.max < 0 || e.max > 5e6) throw $r(lt, Xr, n);
2546
+ async function ri(e, t, n = "anti-bot") {
2547
+ if (e.algorithm !== "SHA-256") throw ti(dt, Zr, n);
2548
+ if (!Number.isSafeInteger(e.max) || e.max < 0 || e.max > 5e6) throw ti(dt, Qr, n);
2561
2549
  let r = {
2562
2550
  salt: e.salt,
2563
2551
  challenge: e.challenge,
2564
2552
  max: e.max
2565
2553
  }, i;
2566
2554
  try {
2567
- i = t && typeof Worker < "u" ? await ei(t, r) : await Jr(r.salt, r.challenge, r.max, Date.now() + Zr);
2555
+ i = t && typeof Worker < "u" ? await ni(t, r) : await Xr(r.salt, r.challenge, r.max, Date.now() + $r);
2568
2556
  } catch (e) {
2569
- throw $r(lt, e instanceof Qr || e instanceof qr ? Xr : Yr, n, e);
2557
+ throw ti(dt, e instanceof ei || e instanceof Yr ? Qr : Zr, n, e);
2570
2558
  }
2571
- if (i === null) throw $r(lt, Yr, n);
2559
+ if (i === null) throw ti(dt, Zr, n);
2572
2560
  return i;
2573
2561
  }
2574
- function ni(e, t) {
2562
+ function ii(e, t) {
2575
2563
  let n = {
2576
2564
  app: e.app,
2577
2565
  exp: e.exp,
@@ -2584,8 +2572,8 @@ function ni(e, t) {
2584
2572
  return btoa(JSON.stringify(n));
2585
2573
  }
2586
2574
  // lib/anti-bot/anti-bot.ts
2587
- var ri = "This app requires a verification token. Call setAntiBotTokenProvider() before signing in.", ii = "The verification could not be completed. Try again.";
2588
- function ai(e) {
2575
+ var ai = "This app requires a verification token. Call setAntiBotTokenProvider() before signing in.", oi = "The verification could not be completed. Try again.";
2576
+ function si(e) {
2589
2577
  let t, n = async (e, t, n, r) => {
2590
2578
  let i;
2591
2579
  try {
@@ -2596,16 +2584,16 @@ function ai(e) {
2596
2584
  ...r ? { siteKey: r } : {}
2597
2585
  });
2598
2586
  } catch (e) {
2599
- throw $r(ct, ii, t.operation, e);
2587
+ throw ti(ut, oi, t.operation, e);
2600
2588
  }
2601
- if (typeof i != "string" || i === "") throw $r(ct, ii, t.operation);
2589
+ if (typeof i != "string" || i === "") throw ti(ut, oi, t.operation);
2602
2590
  return i;
2603
2591
  }, r = async (t) => {
2604
2592
  let n = await e.fetchChallenge({
2605
2593
  ...t.identifier ? { identifier: t.identifier } : {},
2606
2594
  ...t.device ? { device: t.device } : {}
2607
2595
  });
2608
- return ni(n, await ti(n, e.workerUrl, t.operation));
2596
+ return ii(n, await ri(n, e.workerUrl, t.operation));
2609
2597
  };
2610
2598
  return {
2611
2599
  setTokenProvider(e) {
@@ -2623,7 +2611,7 @@ function ai(e) {
2623
2611
  if (o === "builtin") c = await r(i);
2624
2612
  else {
2625
2613
  let e = t;
2626
- if (!e) throw $r(st, ri, i.operation);
2614
+ if (!e) throw ti(lt, ai, i.operation);
2627
2615
  c = await n(e, i, o, a.anti_bot?.site_key);
2628
2616
  }
2629
2617
  return e.store.notify(G.AntiBotSolved, {
@@ -2637,7 +2625,7 @@ function ai(e) {
2637
2625
  };
2638
2626
  }
2639
2627
  // lib/services/logger.ts
2640
- var oi = class {
2628
+ var ci = class {
2641
2629
  error(e, ...t) {
2642
2630
  console.error(e, ...t);
2643
2631
  }
@@ -2651,19 +2639,19 @@ var oi = class {
2651
2639
  console.debug(e, ...t);
2652
2640
  }
2653
2641
  };
2654
- function si() {
2655
- return new oi();
2642
+ function li() {
2643
+ return new ci();
2656
2644
  }
2657
2645
  // lib/attack-protection/risk-ids.ts
2658
- var ci = (e) => e === "sign-in" || e === "sign-up";
2659
- function li(e) {
2646
+ var ui = (e) => e === "sign-in" || e === "sign-up";
2647
+ function di(e) {
2660
2648
  let t, n = async (e, t, n) => {
2661
2649
  try {
2662
2650
  let r = await e(t);
2663
2651
  if (typeof r == "string" && r !== "") return [n, r];
2664
- si().warn(`Passflow: the risk id function gave no ${t.provider} id; ${n} is not sent.`);
2652
+ li().warn(`Passflow: the risk id function gave no ${t.provider} id; ${n} is not sent.`);
2665
2653
  } catch (e) {
2666
- si().warn(`Passflow: the risk id function failed for ${t.provider}; ${n} is not sent.`, e);
2654
+ li().warn(`Passflow: the risk id function failed for ${t.provider}; ${n} is not sent.`, e);
2667
2655
  }
2668
2656
  };
2669
2657
  return {
@@ -2671,11 +2659,11 @@ function li(e) {
2671
2659
  t = e;
2672
2660
  },
2673
2661
  async headersFor(r) {
2674
- if (!ci(r)) return {};
2662
+ if (!ui(r)) return {};
2675
2663
  let i = (await e.readSettings().catch(() => void 0))?.attack_protection;
2676
2664
  if (!(i?.fingerprint || i?.stytch)) return {};
2677
2665
  let a = t;
2678
- if (!a) return si().warn("Passflow: this app has a browser risk provider on. Call setRiskIdProvider() to send its id with each sign-in."), {};
2666
+ if (!a) return li().warn("Passflow: this app has a browser risk provider on. Call setRiskIdProvider() to send its id with each sign-in."), {};
2679
2667
  let o = await Promise.all([i.fingerprint ? n(a, {
2680
2668
  provider: "fingerprint",
2681
2669
  publicKey: i.fingerprint.public_key,
@@ -2691,97 +2679,97 @@ function li(e) {
2691
2679
  };
2692
2680
  }
2693
2681
  // lib/refresh/constants.ts
2694
- var ui = "passflow-refresh", di = "passflow-refresh-takeover", fi = "passflow-auth", pi = Object.freeze([
2682
+ var fi = "passflow-refresh", pi = "passflow-refresh-takeover", mi = "passflow-auth", hi = Object.freeze([
2695
2683
  1e3,
2696
2684
  3e3,
2697
2685
  1e4,
2698
2686
  3e4,
2699
2687
  6e4
2700
- ]), mi = .2, hi = 6e5, gi = 5e3, K = 2e4, _i = 2e4, vi = 1e3, yi = 2e3, bi = 1e3, xi = 1e4, Si = 5e3;
2688
+ ]), gi = .2, _i = 6e5, vi = 5e3, K = 2e4, yi = 2e4, bi = 1e3, xi = 2e3, Si = 1e3, Ci = 1e4, wi = 5e3;
2701
2689
  // lib/refresh/protocol.ts
2702
- function Ci(e) {
2690
+ function Ti(e) {
2703
2691
  let t = e ? `:${e}` : "";
2704
2692
  return {
2705
- lock: `${ui}${t}`,
2706
- takeoverLock: `${di}${t}`,
2707
- channel: `${fi}${t}`
2693
+ lock: `${fi}${t}`,
2694
+ takeoverLock: `${pi}${t}`,
2695
+ channel: `${mi}${t}`
2708
2696
  };
2709
2697
  }
2710
2698
  function q(e) {
2711
2699
  return typeof e == "string" && e !== "" ? e : void 0;
2712
2700
  }
2713
- function wi(e) {
2701
+ function Ei(e) {
2714
2702
  return typeof e == "number" && Number.isFinite(e) ? e : void 0;
2715
2703
  }
2716
- function Ti(e) {
2704
+ function Di(e) {
2717
2705
  return typeof e == "object" && !!e;
2718
2706
  }
2719
- function Ei(e, t) {
2707
+ function Oi(e, t) {
2720
2708
  for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
2721
2709
  return e;
2722
2710
  }
2723
- function Di(e) {
2724
- if (!Ti(e)) return null;
2711
+ function ki(e) {
2712
+ if (!Di(e)) return null;
2725
2713
  let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
2726
- return Ei({}, {
2714
+ return Oi({}, {
2727
2715
  access_token: q(e.access_token),
2728
2716
  refresh_token: q(e.refresh_token),
2729
2717
  id_token: q(e.id_token),
2730
2718
  scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
2731
2719
  });
2732
2720
  }
2733
- function Oi(e) {
2734
- if (!Ti(e)) return null;
2721
+ function Ai(e) {
2722
+ if (!Di(e)) return null;
2735
2723
  let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
2736
- return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || wi(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Ei({
2724
+ return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || Ei(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Oi({
2737
2725
  kind: t,
2738
2726
  attempt: n,
2739
2727
  nextAt: r,
2740
2728
  strikes: i
2741
2729
  }, {
2742
2730
  from: q(e.from),
2743
- failingSince: wi(e.failingSince)
2731
+ failingSince: Ei(e.failingSince)
2744
2732
  });
2745
2733
  }
2746
- function ki(e) {
2747
- return Ei({}, {
2734
+ function ji(e) {
2735
+ return Oi({}, {
2748
2736
  fp: q(e.fp),
2749
2737
  sub: q(e.sub),
2750
2738
  sid: q(e.sid),
2751
- iat: wi(e.iat)
2739
+ iat: Ei(e.iat)
2752
2740
  });
2753
2741
  }
2754
- function Ai(e) {
2755
- if (!Ti(e)) return null;
2742
+ function Mi(e) {
2743
+ if (!Di(e)) return null;
2756
2744
  let t = e;
2757
2745
  if (t.v !== void 0 && t.v !== 1) return null;
2758
2746
  let n = q(t.tabId);
2759
2747
  if (!n) return null;
2760
2748
  switch (t.type) {
2761
2749
  case "tokens-refreshed": {
2762
- let e = Di(t.tokens), r = q(t.from), i = q(t.to);
2763
- return !e || !r || !i ? null : Ei({
2750
+ let e = ki(t.tokens), r = q(t.from), i = q(t.to);
2751
+ return !e || !r || !i ? null : Oi({
2764
2752
  type: t.type,
2765
2753
  tabId: n,
2766
2754
  tokens: e,
2767
2755
  from: r,
2768
2756
  to: i
2769
2757
  }, {
2770
- fromIat: wi(t.fromIat),
2758
+ fromIat: Ei(t.fromIat),
2771
2759
  fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
2772
- sentAt: wi(t.sentAt)
2760
+ sentAt: Ei(t.sentAt)
2773
2761
  });
2774
2762
  }
2775
2763
  case "session-refreshed": {
2776
- let e = wi(t.at);
2777
- return e === void 0 ? null : Ei({
2764
+ let e = Ei(t.at);
2765
+ return e === void 0 ? null : Oi({
2778
2766
  type: t.type,
2779
2767
  tabId: n,
2780
2768
  at: e
2781
2769
  }, { sub: q(t.sub) });
2782
2770
  }
2783
2771
  case "still-refreshing": {
2784
- let e = t.retry === void 0 ? null : Oi(t.retry);
2772
+ let e = t.retry === void 0 ? null : Ai(t.retry);
2785
2773
  return e ? {
2786
2774
  type: t.type,
2787
2775
  tabId: n,
@@ -2792,7 +2780,7 @@ function Ai(e) {
2792
2780
  };
2793
2781
  }
2794
2782
  case "retry-scheduled": {
2795
- let e = Oi(t);
2783
+ let e = Ai(t);
2796
2784
  return e ? {
2797
2785
  type: t.type,
2798
2786
  tabId: n,
@@ -2813,10 +2801,10 @@ function Ai(e) {
2813
2801
  case "signed-out": return {
2814
2802
  type: t.type,
2815
2803
  tabId: n,
2816
- ...ki(t)
2804
+ ...ji(t)
2817
2805
  };
2818
2806
  case "rate-limited": {
2819
- let e = wi(t.until);
2807
+ let e = Ei(t.until);
2820
2808
  return e === void 0 ? null : {
2821
2809
  type: t.type,
2822
2810
  tabId: n,
@@ -2835,22 +2823,22 @@ function Ai(e) {
2835
2823
  default: return null;
2836
2824
  }
2837
2825
  }
2838
- function ji(e, t) {
2826
+ function Ni(e, t) {
2839
2827
  let n = {
2840
2828
  v: 1,
2841
2829
  tabId: e
2842
2830
  };
2843
2831
  if (t.type === "retry-scheduled") {
2844
2832
  let { retry: e, ...r } = t;
2845
- return Ei(n, {
2833
+ return Oi(n, {
2846
2834
  ...r,
2847
2835
  ...e
2848
2836
  });
2849
2837
  }
2850
- return Ei(n, { ...t });
2838
+ return Oi(n, { ...t });
2851
2839
  }
2852
2840
  // lib/refresh/resolve.ts
2853
- var Mi = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", Ni = {
2841
+ var Pi = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", Fi = {
2854
2842
  now: () => Date.now(),
2855
2843
  random: () => Math.random(),
2856
2844
  setTimeout: (e, t) => {
@@ -2858,28 +2846,28 @@ var Mi = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
2858
2846
  return n.unref?.(), () => clearTimeout(n);
2859
2847
  }
2860
2848
  };
2861
- function Pi() {
2849
+ function Ii() {
2862
2850
  let e = globalThis.crypto;
2863
2851
  return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
2864
2852
  }
2865
- function Fi(e) {
2853
+ function Li(e) {
2866
2854
  return e ? {
2867
2855
  now: () => e.now(),
2868
2856
  setTimeout: (t, n) => e.setTimeout(t, n),
2869
- random: e.random ? () => e.random?.() ?? Math.random() : Ni.random
2870
- } : Ni;
2857
+ random: e.random ? () => e.random?.() ?? Math.random() : Fi.random
2858
+ } : Fi;
2871
2859
  }
2872
- function Ii(e) {
2860
+ function Ri(e) {
2873
2861
  return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
2874
2862
  }
2875
- function Li(e) {
2863
+ function zi(e) {
2876
2864
  try {
2877
2865
  return e.storageSharedAcrossTabs === !0;
2878
2866
  } catch {
2879
2867
  return !1;
2880
2868
  }
2881
2869
  }
2882
- function Ri() {
2870
+ function Bi() {
2883
2871
  try {
2884
2872
  let e = globalThis.navigator?.locks;
2885
2873
  return e && typeof e.request == "function" ? e : void 0;
@@ -2887,7 +2875,7 @@ function Ri() {
2887
2875
  return;
2888
2876
  }
2889
2877
  }
2890
- function zi(e) {
2878
+ function Vi(e) {
2891
2879
  return (t) => {
2892
2880
  let n = (n) => {
2893
2881
  let r = n.key;
@@ -2896,20 +2884,20 @@ function zi(e) {
2896
2884
  return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
2897
2885
  };
2898
2886
  }
2899
- function Bi(e) {
2887
+ function Hi(e) {
2900
2888
  return {
2901
2889
  transports: null,
2902
- names: Ci(e),
2903
- clock: Ni,
2890
+ names: Ti(e),
2891
+ clock: Fi,
2904
2892
  warnOnFirstCycle: !1
2905
2893
  };
2906
2894
  }
2907
- function Vi(e, t, n, r) {
2908
- let i = Ci(n), a = Ii(t), o = a ? zi(r.tokenKeys) : void 0, s = (e) => {
2895
+ function Ui(e, t, n, r) {
2896
+ let i = Ti(n), a = Ri(t), o = a ? Vi(r.tokenKeys) : void 0, s = (e) => {
2909
2897
  let t = {
2910
2898
  transports: null,
2911
2899
  names: i,
2912
- clock: Ni,
2900
+ clock: Fi,
2913
2901
  warnOnFirstCycle: e
2914
2902
  };
2915
2903
  return o && (t.onStorageChange = o), t;
@@ -2919,16 +2907,16 @@ function Vi(e, t, n, r) {
2919
2907
  transports: {
2920
2908
  locks: e.locks,
2921
2909
  channel: e.channel,
2922
- tabId: e.tabId ?? Pi()
2910
+ tabId: e.tabId ?? Ii()
2923
2911
  },
2924
2912
  names: i,
2925
- clock: Fi(e.clock),
2913
+ clock: Li(e.clock),
2926
2914
  warnOnFirstCycle: !1
2927
2915
  };
2928
2916
  return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
2929
2917
  }
2930
- if (e === "none" || !a || !Li(t)) return s(!1);
2931
- let c = Ri();
2918
+ if (e === "none" || !a || !zi(t)) return s(!1);
2919
+ let c = Bi();
2932
2920
  if (!c || typeof BroadcastChannel != "function") return s(!0);
2933
2921
  let l;
2934
2922
  try {
@@ -2940,15 +2928,15 @@ function Vi(e, t, n, r) {
2940
2928
  transports: {
2941
2929
  locks: c,
2942
2930
  channel: l,
2943
- tabId: Pi()
2931
+ tabId: Ii()
2944
2932
  },
2945
2933
  names: i,
2946
- clock: Ni,
2934
+ clock: Fi,
2947
2935
  warnOnFirstCycle: !1
2948
2936
  };
2949
2937
  return o && (u.onStorageChange = o), u;
2950
2938
  }
2951
- var Hi = Object.freeze([
2939
+ var Wi = Object.freeze([
2952
2940
  "error.token.invalid.error",
2953
2941
  "error.api.token.parse.error",
2954
2942
  "error.api.user.blocked",
@@ -2956,28 +2944,28 @@ var Hi = Object.freeze([
2956
2944
  "error.validation.token.invalid.subject",
2957
2945
  "error.not.found"
2958
2946
  ]);
2959
- function Ui(e) {
2947
+ function Gi(e) {
2960
2948
  if (typeof e != "object" || !e) return;
2961
2949
  let t = e;
2962
2950
  return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
2963
2951
  }
2964
- function Wi(e, t) {
2965
- if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(hi, Math.floor(e) * 1e3);
2952
+ function Ki(e, t) {
2953
+ if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(_i, Math.floor(e) * 1e3);
2966
2954
  if (typeof e != "string") return;
2967
2955
  let n = e.trim();
2968
2956
  if (n === "") return;
2969
- if (/^\d+$/.test(n)) return Math.min(hi, Number.parseInt(n, 10) * 1e3);
2957
+ if (/^\d+$/.test(n)) return Math.min(_i, Number.parseInt(n, 10) * 1e3);
2970
2958
  if (!/[a-z]/i.test(n)) return;
2971
2959
  let r = Date.parse(n);
2972
- if (!Number.isNaN(r)) return Math.min(hi, Math.max(0, r - t));
2960
+ if (!Number.isNaN(r)) return Math.min(_i, Math.max(0, r - t));
2973
2961
  }
2974
- function Gi(e) {
2962
+ function qi(e) {
2975
2963
  return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
2976
2964
  }
2977
- function Ki(e) {
2978
- return typeof e == "object" && e ? qi(e) : void 0;
2965
+ function Ji(e) {
2966
+ return typeof e == "object" && e ? Yi(e) : void 0;
2979
2967
  }
2980
- function qi(e) {
2968
+ function Yi(e) {
2981
2969
  if (typeof e.id == "string" && e.id !== "") return e.id;
2982
2970
  let t = e.response?.data;
2983
2971
  if (typeof t != "object" || !t) return;
@@ -2986,10 +2974,10 @@ function qi(e) {
2986
2974
  let r = n.id;
2987
2975
  return typeof r == "string" && r !== "" ? r : void 0;
2988
2976
  }
2989
- function Ji(e, t = Date.now()) {
2977
+ function Xi(e, t = Date.now()) {
2990
2978
  if (typeof e != "object" || !e) return { kind: "transient" };
2991
- let n = e, r = qi(n), i = Gi(n.response?.status) ?? Gi(n.status), a = {};
2992
- if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), Jn(r)) return {
2979
+ let n = e, r = Yi(n), i = qi(n.response?.status) ?? qi(n.status), a = {};
2980
+ if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), Xn(r)) return {
2993
2981
  kind: "auth",
2994
2982
  terminal: !0,
2995
2983
  ...a
@@ -2998,7 +2986,7 @@ function Ji(e, t = Date.now()) {
2998
2986
  kind: "blocked",
2999
2987
  ...a
3000
2988
  };
3001
- if (r !== void 0 && Hi.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
2989
+ if (r !== void 0 && Wi.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
3002
2990
  kind: "auth",
3003
2991
  ...a
3004
2992
  };
@@ -3006,7 +2994,7 @@ function Ji(e, t = Date.now()) {
3006
2994
  kind: "transient",
3007
2995
  ...a
3008
2996
  };
3009
- let o = Wi(n.retryAfter ?? Ui(n.response?.headers), t);
2997
+ let o = Ki(n.retryAfter ?? Gi(n.response?.headers), t);
3010
2998
  return o === void 0 ? {
3011
2999
  kind: "transient",
3012
3000
  ...a
@@ -3016,19 +3004,19 @@ function Ji(e, t = Date.now()) {
3016
3004
  retryAfterMs: o
3017
3005
  };
3018
3006
  }
3019
- function Yi(e, t, n) {
3020
- let r = pi.length, i = pi[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? pi[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * mi * a);
3021
- return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), hi) : 0);
3007
+ function Zi(e, t, n) {
3008
+ let r = hi.length, i = hi[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? hi[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * gi * a);
3009
+ return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), _i) : 0);
3022
3010
  }
3023
3011
  // lib/refresh/coordinator.ts
3024
- var Xi = {
3012
+ var Qi = {
3025
3013
  onGranted: () => !1,
3026
3014
  onLockLost: () => void 0,
3027
3015
  onMessage: () => void 0
3028
3016
  };
3029
- function Zi(e) {
3030
- let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = Xi, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
3031
- g || n.postMessage(ji(r, e));
3017
+ function $i(e) {
3018
+ let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = Qi, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
3019
+ g || n.postMessage(Ni(r, e));
3032
3020
  }, v = () => s !== null && c === null, y = () => {
3033
3021
  f?.(), f = null;
3034
3022
  }, b = (e) => {
@@ -3043,7 +3031,7 @@ function Zi(e) {
3043
3031
  type: "still-refreshing",
3044
3032
  retry: m
3045
3033
  } : { type: "still-refreshing" }), ee());
3046
- }, gi);
3034
+ }, vi);
3047
3035
  }, S = () => {
3048
3036
  y(), x(), u?.(), u = null;
3049
3037
  let e = s;
@@ -3094,7 +3082,7 @@ function Zi(e) {
3094
3082
  });
3095
3083
  }, ne = (e) => {
3096
3084
  if (g) return;
3097
- let t = Ai(e.data);
3085
+ let t = Mi(e.data);
3098
3086
  if (t && t.tabId !== r) {
3099
3087
  switch (t.type) {
3100
3088
  case "still-refreshing":
@@ -3137,8 +3125,8 @@ function Zi(e) {
3137
3125
  }
3138
3126
  };
3139
3127
  }
3140
- function Qi(e = "local") {
3141
- let t = Xi, n = !1, r = !1, i = 0, a = !1, o = () => {
3128
+ function ea(e = "local") {
3129
+ let t = Qi, n = !1, r = !1, i = 0, a = !1, o = () => {
3142
3130
  n = !1, r = !1, i += 1;
3143
3131
  };
3144
3132
  return {
@@ -3186,7 +3174,7 @@ var J = {
3186
3174
  successorTimeout: "error.refresh.successor_timeout",
3187
3175
  identityChanged: "error.refresh.identity_changed",
3188
3176
  disposed: "error.refresh.disposed"
3189
- }, $i = {
3177
+ }, ta = {
3190
3178
  "error.refresh.unavailable": 503,
3191
3179
  "error.refresh.auth_retry": 401,
3192
3180
  "error.refresh.session_ended": 401,
@@ -3194,7 +3182,7 @@ var J = {
3194
3182
  "error.refresh.successor_timeout": 401,
3195
3183
  "error.refresh.identity_changed": 401,
3196
3184
  "error.refresh.disposed": 499
3197
- }, ea = {
3185
+ }, na = {
3198
3186
  "error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
3199
3187
  "error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
3200
3188
  "error.refresh.session_ended": "The session has ended",
@@ -3206,19 +3194,19 @@ var J = {
3206
3194
  constructor(e, t = {}) {
3207
3195
  super({
3208
3196
  id: e,
3209
- message: t.message ?? ea[e],
3210
- status: $i[e],
3197
+ message: t.message ?? na[e],
3198
+ status: ta[e],
3211
3199
  location: "/auth/refresh",
3212
3200
  time: (/* @__PURE__ */ new Date()).toISOString()
3213
3201
  }), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
3214
3202
  }
3215
- }, ta = class extends Error {
3203
+ }, ra = class extends Error {
3216
3204
  constructor(e, t) {
3217
3205
  super(t ?? (e === "lock-timeout" ? "Step-up commit could not take the refresh lock in time" : "Step-up commit answer arrived after the stored session moved on")), this.name = "UpgradeCommitInterruptedError", this.reason = e;
3218
3206
  }
3219
3207
  };
3220
3208
  // lib/refresh/lineage.ts
3221
- function na(e) {
3209
+ function ia(e) {
3222
3210
  if (!e) return;
3223
3211
  let t = 3735928559, n = 1103547991;
3224
3212
  for (let r = 0; r < e.length; r++) {
@@ -3227,24 +3215,24 @@ function na(e) {
3227
3215
  }
3228
3216
  return t = Math.imul(t ^ t >>> 16, 2246822507), t ^= Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507), n ^= Math.imul(t ^ t >>> 13, 3266489909), (4294967296 * (2097151 & n) + (t >>> 0)).toString(16);
3229
3217
  }
3230
- function ra(e) {
3218
+ function aa(e) {
3231
3219
  return typeof e == "string" && e !== "" ? e : void 0;
3232
3220
  }
3233
3221
  function X(e) {
3234
- let t = na(e);
3222
+ let t = ia(e);
3235
3223
  if (!e || !t) return;
3236
3224
  let n = {};
3237
3225
  try {
3238
3226
  let t = M(e);
3239
3227
  typeof t == "object" && t && (n = t);
3240
3228
  } catch {}
3241
- let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = ra(n.sub), o = ra(n.sid);
3229
+ let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = aa(n.sub), o = aa(n.sid);
3242
3230
  return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
3243
3231
  }
3244
- var ia = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
3245
- function aa(e = (e) => si().warn(e)) {
3232
+ var oa = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
3233
+ function sa(e = (e) => li().warn(e)) {
3246
3234
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
3247
- a || (a = !0, e(ia));
3235
+ a || (a = !0, e(oa));
3248
3236
  }, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
3249
3237
  if (!e) return;
3250
3238
  if (e.iat === void 0) {
@@ -3285,16 +3273,16 @@ function aa(e = (e) => si().warn(e)) {
3285
3273
  };
3286
3274
  }
3287
3275
  // lib/refresh/fence.ts
3288
- var oa = class extends Error {
3276
+ var ca = class extends Error {
3289
3277
  constructor(e) {
3290
3278
  super(e === "emptied" ? "The shared token storage was emptied" : "The stored refresh token belongs to an ended session"), this.name = "SessionEnded", this.cause = e;
3291
3279
  }
3292
- }, sa = class extends Error {
3280
+ }, la = class extends Error {
3293
3281
  constructor() {
3294
3282
  super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
3295
3283
  }
3296
3284
  };
3297
- function ca(e) {
3285
+ function ua(e) {
3298
3286
  if (e) try {
3299
3287
  let t = M(e).sub;
3300
3288
  return typeof t == "string" && t !== "" ? t : void 0;
@@ -3303,20 +3291,20 @@ function ca(e) {
3303
3291
  }
3304
3292
  }
3305
3293
  function Z(e) {
3306
- return ca(e?.access_token) ?? ca(e?.refresh_token) ?? ca(e?.id_token);
3294
+ return ua(e?.access_token) ?? ua(e?.refresh_token) ?? ua(e?.id_token);
3307
3295
  }
3308
- function la(e, t) {
3296
+ function da(e, t) {
3309
3297
  return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
3310
3298
  }
3311
- function ua(e) {
3299
+ function fa(e) {
3312
3300
  return typeof e == "object" && !!e;
3313
3301
  }
3314
- function da(e) {
3315
- let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => si().warn(e)), o = e.lineage ?? aa(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
3302
+ function pa(e) {
3303
+ let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => li().warn(e)), o = e.lineage ?? sa(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
3316
3304
  let e = t.getTokens(), n = e?.refresh_token;
3317
3305
  if (!n) return p = l, e;
3318
3306
  p !== void 0 && (f = Math.max(f, p, m), p = void 0);
3319
- let r = na(n) ?? "";
3307
+ let r = ia(n) ?? "";
3320
3308
  return r !== c?.fp && (c = {
3321
3309
  fp: r,
3322
3310
  seq: l
@@ -3351,7 +3339,7 @@ function da(e) {
3351
3339
  h = void 0;
3352
3340
  let e = y();
3353
3341
  e?.refresh_token || C(e) ? se() : ne(!0) === "end" && s?.("emptied");
3354
- }, yi));
3342
+ }, xi));
3355
3343
  let n = t === "keep" ? T() : void 0;
3356
3344
  return n && (m = Math.max(m, n.seq)), n && g !== n.fp && (g = n.fp, a(`[passflow] The shared token storage was emptied by the end of the session of ${n.fp}, a refresh token the ${b()?.fp ?? "(none)"} this tab holds is ahead of: keeping it. Nothing is refreshed until the storage holds a token again.`)), t;
3357
3345
  }, D = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, re = (e) => {
@@ -3364,7 +3352,7 @@ function da(e) {
3364
3352
  return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
3365
3353
  }, ie = (e, t) => o.isForward(e, t) ? !0 : !!e && !!t && e.iat !== void 0 && e.sid !== t.sid && o.isRetired(t) && !o.isRetired(e) && !o.isEnded(e), ae = (e) => {
3366
3354
  let t = b();
3367
- t && t.fp !== na(e.refresh_token) && o.retire(t), n.setTokensCache(e);
3355
+ t && t.fp !== ia(e.refresh_token) && o.retire(t), n.setTokensCache(e);
3368
3356
  }, oe = (e) => {
3369
3357
  let t = y(), n = t?.refresh_token;
3370
3358
  if (n === e.refreshToken) return null;
@@ -3375,7 +3363,7 @@ function da(e) {
3375
3363
  kind: "superseded",
3376
3364
  adopted: !1
3377
3365
  };
3378
- let r = ca(t.access_token) ?? ca(n);
3366
+ let r = ua(t.access_token) ?? ua(n);
3379
3367
  if (e.sub && r && e.sub !== r) return {
3380
3368
  kind: "identity-changed",
3381
3369
  saved: !1
@@ -3416,22 +3404,22 @@ function da(e) {
3416
3404
  let e = y();
3417
3405
  if (C(e)) return "held";
3418
3406
  if (!e?.refresh_token) {
3419
- if (ne() === "end") throw new oa("emptied");
3407
+ if (ne() === "end") throw new ca("emptied");
3420
3408
  return "held";
3421
3409
  }
3422
3410
  let t = n.getTokens();
3423
3411
  if (e.refresh_token === t?.refresh_token) return "send";
3424
3412
  let r = i() ?? Z(t), a = Z(e);
3425
- if (r && a && r !== a) throw new sa();
3413
+ if (r && a && r !== a) throw new la();
3426
3414
  let s = X(e.refresh_token);
3427
3415
  if (o.isEnded(s)) {
3428
3416
  if (s && S(s)) return "held";
3429
- throw new oa("ended");
3417
+ throw new ca("ended");
3430
3418
  }
3431
3419
  let c = X(t?.refresh_token);
3432
3420
  return ie(s, c) ? (ae(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && re(s) ? "held" : "send";
3433
3421
  }, M = (e) => {
3434
- let t = i(), r = ca(e);
3422
+ let t = i(), r = ua(e);
3435
3423
  if (t && r && t !== r) return { kind: "identity-changed" };
3436
3424
  let a = X(e) ?? { fp: e };
3437
3425
  if (o.isEnded(a)) return S(a) ? { kind: "superseded" } : { kind: "ended" };
@@ -3439,7 +3427,7 @@ function da(e) {
3439
3427
  let s = {
3440
3428
  refreshToken: e,
3441
3429
  order: a
3442
- }, c = t ?? r ?? ca(n.getTokens()?.access_token);
3430
+ }, c = t ?? r ?? ua(n.getTokens()?.access_token);
3443
3431
  return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
3444
3432
  kind: "send",
3445
3433
  sent: s
@@ -3448,7 +3436,7 @@ function da(e) {
3448
3436
  if (o.isEnded(e.order)) return k(e.order);
3449
3437
  let i = oe(e);
3450
3438
  if (i) return i;
3451
- if (!D(e) && O(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${na(r.refresh_token) ?? "(no refresh token)"}, but this tab already holds ${b()?.fp ?? "(none)"}, a later successor of ${e.order.fp}. Neither saved nor adopted.`), {
3439
+ if (!D(e) && O(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${ia(r.refresh_token) ?? "(no refresh token)"}, but this tab already holds ${b()?.fp ?? "(none)"}, a later successor of ${e.order.fp}. Neither saved nor adopted.`), {
3452
3440
  kind: "superseded",
3453
3441
  adopted: !1
3454
3442
  };
@@ -3458,7 +3446,7 @@ function da(e) {
3458
3446
  saved: !0
3459
3447
  };
3460
3448
  let c = X(r.refresh_token);
3461
- return c && (la(c, e.order) || la(c, b())) ? (a(`[passflow] Refused to save a refresh result older than the token this tab holds: ${e.order.fp} was answered with ${c.fp}. Neither saved nor adopted.`), {
3449
+ return c && (da(c, e.order) || da(c, b())) ? (a(`[passflow] Refused to save a refresh result older than the token this tab holds: ${e.order.fp} was answered with ${c.fp}. Neither saved nor adopted.`), {
3462
3450
  kind: "superseded",
3463
3451
  adopted: !1
3464
3452
  }) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
@@ -3470,7 +3458,7 @@ function da(e) {
3470
3458
  kind: "superseded",
3471
3459
  adopted: !1
3472
3460
  };
3473
- let r = Ji(t), i = r.kind === "blocked" || r.kind === "auth";
3461
+ let r = Xi(t), i = r.kind === "blocked" || r.kind === "auth";
3474
3462
  return D(e) && i ? (o.retire(e.order), _ = e.order, {
3475
3463
  kind: "own",
3476
3464
  failure: r,
@@ -3481,11 +3469,11 @@ function da(e) {
3481
3469
  heldRefused: !1
3482
3470
  });
3483
3471
  }, F = (e) => {
3484
- if (!ua(e)) return !1;
3472
+ if (!fa(e)) return !1;
3485
3473
  let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
3486
- if (typeof t != "string" || typeof c != "string" || !ua(l)) return !1;
3474
+ if (typeof t != "string" || typeof c != "string" || !fa(l)) return !1;
3487
3475
  let u = l;
3488
- if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || na(u.refresh_token) !== c) return !1;
3476
+ if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || ia(u.refresh_token) !== c) return !1;
3489
3477
  let d = y();
3490
3478
  if (!d?.refresh_token) return !1;
3491
3479
  let f = n.getTokens(), p = i() ?? Z(f), m = Z(u);
@@ -3502,7 +3490,7 @@ function da(e) {
3502
3490
  }
3503
3491
  return !0;
3504
3492
  };
3505
- return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && na(d.refresh_token) !== c ? !1 : (ae({ ...u }), _());
3493
+ return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && ia(d.refresh_token) !== c ? !1 : (ae({ ...u }), _());
3506
3494
  }, ue = (e) => {
3507
3495
  if (!e || !_) return !1;
3508
3496
  let t = _;
@@ -3568,7 +3556,7 @@ function da(e) {
3568
3556
  };
3569
3557
  }
3570
3558
  // lib/refresh/controller.ts
3571
- function fa() {
3559
+ function ma() {
3572
3560
  let e, t, n = new Promise((n, r) => {
3573
3561
  e = n, t = r;
3574
3562
  });
@@ -3578,7 +3566,7 @@ function fa() {
3578
3566
  reject: t
3579
3567
  };
3580
3568
  }
3581
- var pa = {
3569
+ var ha = {
3582
3570
  strikes: J.sessionEnded,
3583
3571
  "session-ended": J.sessionEnded,
3584
3572
  "stored-ended": J.sessionEnded,
@@ -3589,42 +3577,42 @@ var pa = {
3589
3577
  "identity-changed": J.identityChanged,
3590
3578
  disposed: J.disposed
3591
3579
  };
3592
- function ma(e) {
3580
+ function ga(e) {
3593
3581
  throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
3594
3582
  }
3595
- function ha(e) {
3583
+ function _a(e) {
3596
3584
  if (e === void 0 || !Number.isFinite(e)) return 3;
3597
3585
  let t = Math.floor(e);
3598
3586
  return t >= 1 ? t : 3;
3599
3587
  }
3600
- function ga(e, t) {
3588
+ function va(e, t) {
3601
3589
  return e instanceof Error && e.message ? e.message : t;
3602
3590
  }
3603
- function _a(e) {
3591
+ function ya(e) {
3604
3592
  if (typeof e != "object" || !e) return;
3605
3593
  let t = e.id;
3606
3594
  return typeof t == "string" || typeof t == "number" ? t : void 0;
3607
3595
  }
3608
- function va(e) {
3596
+ function ba(e) {
3609
3597
  let t = {};
3610
3598
  return e?.access_token && (t.access_token = e.access_token), e?.refresh_token && (t.refresh_token = e.refresh_token), e?.id_token && (t.id_token = e.id_token), e?.scopes && (t.scopes = [...e.scopes]), t;
3611
3599
  }
3612
- function ya(e, t) {
3600
+ function xa(e, t) {
3613
3601
  let n = {};
3614
3602
  e.access_token && (n.access_token = e.access_token), e.refresh_token && (n.refresh_token = e.refresh_token), e.id_token && (n.id_token = e.id_token);
3615
3603
  let r = t?.scopes ?? e.scopes;
3616
3604
  return r && (n.scopes = r), n;
3617
3605
  }
3618
- function ba(e) {
3619
- let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? si(), c = ha(e.strikes), l = a.transports ? Zi({
3606
+ function Sa(e) {
3607
+ let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? li(), c = _a(e.strikes), l = a.transports ? $i({
3620
3608
  locks: a.transports.locks,
3621
3609
  channel: a.transports.channel,
3622
3610
  tabId: a.transports.tabId,
3623
3611
  names: a.names,
3624
3612
  clock: o
3625
- }) : Qi(), u = { kind: "idle" }, d = 0, f = !1, p = !a.warnOnFirstCycle, m = 0, h = 0, g, _, v, y, b, x, ee, S, C = !1, w = () => o.now(), T = () => i.mode(), E = () => na(r.getTokens()?.refresh_token), te = () => ({ ...r.getTokens() ?? {} }), ne = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, D = () => (ee === void 0 && (ee = Z(r.getTokens() ?? n.getTokens())), ee), re = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set(), ie = (e) => () => {
3613
+ }) : ea(), u = { kind: "idle" }, d = 0, f = !1, p = !a.warnOnFirstCycle, m = 0, h = 0, g, _, v, y, b, x, ee, S, C = !1, w = () => o.now(), T = () => i.mode(), E = () => ia(r.getTokens()?.refresh_token), te = () => ({ ...r.getTokens() ?? {} }), ne = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, D = () => (ee === void 0 && (ee = Z(r.getTokens() ?? n.getTokens())), ee), re = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set(), ie = (e) => () => {
3626
3614
  for (let t of Array.from(e)) t();
3627
- }, ae = a.onStorageChange?.(ie(re)), oe = e.platform?.onForeground(ie(O)), k = da({
3615
+ }, ae = a.onStorageChange?.(ie(re)), oe = e.platform?.onForeground(ie(O)), k = pa({
3628
3616
  storage: n,
3629
3617
  cache: r,
3630
3618
  identity: D,
@@ -3639,13 +3627,13 @@ function ba(e) {
3639
3627
  }), se = (e) => ({
3640
3628
  trigger: e,
3641
3629
  startedAt: w(),
3642
- plain: fa(),
3630
+ plain: ma(),
3643
3631
  fresh: []
3644
3632
  }), ce = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, le = (e, t) => {
3645
3633
  if (t === void 0) return e.plain.promise;
3646
3634
  let n = {
3647
3635
  callTime: t,
3648
- deferred: fa()
3636
+ deferred: ma()
3649
3637
  };
3650
3638
  return e.fresh.push(n), n.deferred.promise;
3651
3639
  }, A = (e, t, n = !1) => {
@@ -3664,11 +3652,11 @@ function ba(e) {
3664
3652
  }
3665
3653
  }, N = (e, n, r, i) => {
3666
3654
  let a = {
3667
- message: ga(r, "Token refresh failed"),
3655
+ message: va(r, "Token refresh failed"),
3668
3656
  originalError: r,
3669
3657
  operation: e,
3670
3658
  source: n
3671
- }, o = _a(r);
3659
+ }, o = ya(r);
3672
3660
  o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
3673
3661
  }, P = (e, t) => {
3674
3662
  let n = {
@@ -3698,10 +3686,10 @@ function ba(e) {
3698
3686
  };
3699
3687
  n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
3700
3688
  }, de = (e, t) => {
3701
- let n = r.getTokens(), i = na(n?.refresh_token);
3689
+ let n = r.getTokens(), i = ia(n?.refresh_token);
3702
3690
  e.fp && i && l.post({
3703
3691
  type: "tokens-refreshed",
3704
- tokens: va(n),
3692
+ tokens: ba(n),
3705
3693
  from: e.fp,
3706
3694
  ...e.iat === void 0 ? {} : { fromIat: e.iat },
3707
3695
  fromSid: e.sid ?? "",
@@ -3709,7 +3697,7 @@ function ba(e) {
3709
3697
  ...t === void 0 ? {} : { sentAt: t }
3710
3698
  });
3711
3699
  }, fe = () => {
3712
- p || (p = !0, s.warn(Mi));
3700
+ p || (p = !0, s.warn(Pi));
3713
3701
  }, pe = (e) => {
3714
3702
  (e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
3715
3703
  }, I = (e, n) => {
@@ -3723,7 +3711,7 @@ function ba(e) {
3723
3711
  }, e !== "disposed" && k.dropSession(), (e === "strikes" || e === "successor-timeout") && T() !== "json" && i.invalidate(), u = {
3724
3712
  kind: "ended",
3725
3713
  cause: e
3726
- }, M(r, n ?? new Y(pa[e])), e) {
3714
+ }, M(r, n ?? new Y(ha[e])), e) {
3727
3715
  case "strikes":
3728
3716
  t("session:expired", {
3729
3717
  reason: "refresh_failed",
@@ -3758,7 +3746,7 @@ function ba(e) {
3758
3746
  break;
3759
3747
  case "signed-out-here":
3760
3748
  case "disposed": break;
3761
- default: ma(e);
3749
+ default: ga(e);
3762
3750
  }
3763
3751
  }, me = () => {
3764
3752
  if (u.kind !== "ended" || u.cause === "disposed" || f || T() !== "json") return;
@@ -3775,10 +3763,10 @@ function ba(e) {
3775
3763
  }, he = (e) => {
3776
3764
  u.kind === "ended" || f || T() === "json" && (I(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && me());
3777
3765
  }, ge = (e) => {
3778
- e instanceof sa ? (I("identity-changed"), me()) : e instanceof oa ? I(e.cause === "emptied" ? "emptied" : "stored-ended") : I("stored-ended", e);
3766
+ e instanceof la ? (I("identity-changed"), me()) : e instanceof ca ? I(e.cause === "emptied" ? "emptied" : "stored-ended") : I("stored-ended", e);
3779
3767
  }, L = () => {
3780
3768
  u = { kind: "idle" }, C || l.release();
3781
- }, _e = (e) => !e.from || T() !== "json" || e.from === E() || e.from === na(n.getTokens()?.refresh_token), ve = (e) => {
3769
+ }, _e = (e) => !e.from || T() !== "json" || e.from === E() || e.from === ia(n.getTokens()?.refresh_token), ve = (e) => {
3782
3770
  let t = g;
3783
3771
  if (!t) return;
3784
3772
  if (!l.holding) {
@@ -3844,14 +3832,14 @@ function ba(e) {
3844
3832
  case "ended": return k.endHeldSend(), I("stored-ended"), !1;
3845
3833
  case "identity-changed": return k.endHeldSend(), I("identity-changed"), me(), !1;
3846
3834
  case "send": return we(e, t, a.sent, r);
3847
- default: return ma(a);
3835
+ default: return ga(a);
3848
3836
  }
3849
3837
  }, we = (e, n, r, a) => {
3850
3838
  let o = {
3851
3839
  generation: d,
3852
3840
  sentAt: w(),
3853
3841
  trigger: n,
3854
- settled: fa()
3842
+ settled: ma()
3855
3843
  };
3856
3844
  r ? o.sent = r : o.marker = ne(), a && (o.stored = a), u = {
3857
3845
  kind: "refreshing",
@@ -3888,7 +3876,7 @@ function ba(e) {
3888
3876
  if (!Te(e)) return;
3889
3877
  r.setTokensCache({
3890
3878
  ...n.getTokens() ?? {},
3891
- ...ya(t, void 0)
3879
+ ...xa(t, void 0)
3892
3880
  }), F("refresh", "this-tab");
3893
3881
  let c = D();
3894
3882
  l.post(c === void 0 ? {
@@ -3901,7 +3889,7 @@ function ba(e) {
3901
3889
  }), L(), A(a, e.sentAt);
3902
3890
  return;
3903
3891
  }
3904
- let o = E(), s = k.commitSave(e.sent, ya(t, e.stored));
3892
+ let o = E(), s = k.commitSave(e.sent, xa(t, e.stored));
3905
3893
  switch (s.kind) {
3906
3894
  case "saved":
3907
3895
  F("refresh", "this-tab"), de(e.sent.order, e.sentAt), L(), A(a, e.sentAt);
@@ -3919,7 +3907,7 @@ function ba(e) {
3919
3907
  N("refresh", e.trigger, t, P("auth")), I("identity-changed", t), me();
3920
3908
  return;
3921
3909
  }
3922
- default: ma(s);
3910
+ default: ga(s);
3923
3911
  }
3924
3912
  }, De = (e, t) => {
3925
3913
  if (e.sent?.held && k.endHeldSend(), !Te(e) || u.kind !== "refreshing") return;
@@ -3939,9 +3927,9 @@ function ba(e) {
3939
3927
  case "own":
3940
3928
  r = o.failure, i = o.heldRefused;
3941
3929
  break;
3942
- default: ma(o);
3930
+ default: ga(o);
3943
3931
  }
3944
- } else r = Ji(t, w());
3932
+ } else r = Xi(t, w());
3945
3933
  if (i) N("refresh", e.trigger, t, P(r.kind)), F("adopted", "other-tab"), L(), A(n, void 0, !0);
3946
3934
  else switch (r.kind) {
3947
3935
  case "blocked":
@@ -3957,10 +3945,10 @@ function ba(e) {
3957
3945
  case "transient":
3958
3946
  m += 1, Oe(e, n, t, r);
3959
3947
  return;
3960
- default: ma(r.kind);
3948
+ default: ga(r.kind);
3961
3949
  }
3962
3950
  }, Oe = (e, t, n, r) => {
3963
- let i = w() + Yi(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
3951
+ let i = w() + Zi(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
3964
3952
  N("refresh", e.trigger, n, P(a, i)), a === "transient" && ue(w(), i, "this-tab");
3965
3953
  let s = {
3966
3954
  kind: a,
@@ -3970,7 +3958,7 @@ function ba(e) {
3970
3958
  }, c = e.sent?.order.fp;
3971
3959
  c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
3972
3960
  type: "retry-scheduled",
3973
- message: ga(n, "Token refresh failed"),
3961
+ message: va(n, "Token refresh failed"),
3974
3962
  retry: s
3975
3963
  }), ve(se("retry")), j(t, n, e.sentAt);
3976
3964
  }, ke = (e, t) => {
@@ -3983,8 +3971,8 @@ function ba(e) {
3983
3971
  fp: i.fp
3984
3972
  })), r && k.deleteIfStillDead(r), I("strikes", t);
3985
3973
  }, Ae = (e, t, n, r) => {
3986
- l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${ga(n, "blocked")}`);
3987
- let i = d, a = w() + _i, c = {
3974
+ l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${va(n, "blocked")}`);
3975
+ let i = d, a = w() + yi, c = {
3988
3976
  kind: "blocked-wait",
3989
3977
  pending: e,
3990
3978
  deadline: a,
@@ -3997,9 +3985,9 @@ function ba(e) {
3997
3985
  i === d && u === c && (je() || (f ? (e.cookieRetried = !0, u = {
3998
3986
  kind: "waiting",
3999
3987
  pending: e
4000
- }, l.request()) : w() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), I("successor-timeout")) : c.cancel = o.setTimeout(p, vi)));
3988
+ }, l.request()) : w() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), I("successor-timeout")) : c.cancel = o.setTimeout(p, bi)));
4001
3989
  };
4002
- c.cancel = o.setTimeout(p, f ? bi : vi);
3990
+ c.cancel = o.setTimeout(p, f ? Si : bi);
4003
3991
  }, je = () => {
4004
3992
  if (u.kind !== "blocked-wait") return !1;
4005
3993
  let e = u;
@@ -4043,7 +4031,7 @@ function ba(e) {
4043
4031
  case "idle":
4044
4032
  case "refreshing":
4045
4033
  case "ended": return;
4046
- default: ma(u);
4034
+ default: ga(u);
4047
4035
  }
4048
4036
  }, Ie = (e) => {
4049
4037
  let t = {};
@@ -4086,7 +4074,7 @@ function ba(e) {
4086
4074
  Pe(e.retry, !0, e.message), Re();
4087
4075
  return;
4088
4076
  case "refresh-failed":
4089
- if (u.kind === "ended" || T() !== "json" || e.from !== E() && e.from !== na(n.getTokens()?.refresh_token)) return;
4077
+ if (u.kind === "ended" || T() !== "json" || e.from !== E() && e.from !== ia(n.getTokens()?.refresh_token)) return;
4090
4078
  if (ue(w(), void 0, "other-tab"), u.kind === "waiting") {
4091
4079
  let t = u.pending;
4092
4080
  u.pending = se(t.trigger), j(t, new Y(J.unavailable, { cause: e.message }), void 0);
@@ -4107,7 +4095,7 @@ function ba(e) {
4107
4095
  return;
4108
4096
  case "takeover":
4109
4097
  case "rate-limited": return;
4110
- default: ma(e);
4098
+ default: ga(e);
4111
4099
  }
4112
4100
  }, Re = () => {
4113
4101
  S && !l.holding && l.post({
@@ -4172,7 +4160,7 @@ function ba(e) {
4172
4160
  case "refreshing":
4173
4161
  case "backoff":
4174
4162
  case "blocked-wait": return le(u.pending, t);
4175
- default: return ma(u);
4163
+ default: return ga(u);
4176
4164
  }
4177
4165
  }, Ve = (e) => {
4178
4166
  if (f) return Promise.reject(new Y(J.disposed));
@@ -4223,9 +4211,9 @@ function ba(e) {
4223
4211
  }, Ke = async (e, t) => {
4224
4212
  if (f) throw new Y(J.disposed);
4225
4213
  fe();
4226
- let n = w() + xi;
4214
+ let n = w() + Ci;
4227
4215
  if (await We(n - w()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await Ue("commit", n - w())) === "timeout") {
4228
- let e = new ta("lock-timeout");
4216
+ let e = new ra("lock-timeout");
4229
4217
  throw N("upgrade.commit", "upgrade", e), e;
4230
4218
  }
4231
4219
  C = !0;
@@ -4271,12 +4259,12 @@ function ba(e) {
4271
4259
  }
4272
4260
  if (!o) {
4273
4261
  if (u !== d) {
4274
- let e = new ta("superseded");
4262
+ let e = new ra("superseded");
4275
4263
  throw N("upgrade.commit", "upgrade", e), e;
4276
4264
  }
4277
4265
  await i.applyOpaque(f), r.setTokensCache({
4278
4266
  ...n.getTokens() ?? {},
4279
- ...ya(f, void 0)
4267
+ ...xa(f, void 0)
4280
4268
  }), Je(c);
4281
4269
  let e = D();
4282
4270
  return l.post(e === void 0 ? {
@@ -4288,9 +4276,9 @@ function ba(e) {
4288
4276
  sub: e
4289
4277
  }), te();
4290
4278
  }
4291
- let p = k.commitSave(o, ya(f, s));
4279
+ let p = k.commitSave(o, xa(f, s));
4292
4280
  if (p.kind === "saved") return Je(c), de(o.order, c), te();
4293
- let m = new ta("superseded");
4281
+ let m = new ra("superseded");
4294
4282
  throw N("upgrade.commit", "upgrade", m), p.kind === "superseded" && p.adopted && F("adopted", "other-tab"), m;
4295
4283
  }, Je = (e) => {
4296
4284
  if (F("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
@@ -4316,7 +4304,7 @@ function ba(e) {
4316
4304
  commitUpgrade: Ke,
4317
4305
  signOut: async (e) => {
4318
4306
  if (f) return e(n.getTokens()?.refresh_token);
4319
- let t = w() + Si;
4307
+ let t = w() + wi;
4320
4308
  Xe(), await We(t - w()), Xe(), l.coordinated && !l.holding && await Ue("logout", t - w());
4321
4309
  try {
4322
4310
  Ye(), await e(n.getTokens()?.refresh_token);
@@ -4362,7 +4350,7 @@ function ba(e) {
4362
4350
  };
4363
4351
  }
4364
4352
  // lib/token/verify.ts
4365
- var xa = {
4353
+ var Ca = {
4366
4354
  ES256: {
4367
4355
  kty: "EC",
4368
4356
  key: (e) => ({
@@ -4393,34 +4381,34 @@ var xa = {
4393
4381
  },
4394
4382
  signature: { name: "RSASSA-PKCS1-v1_5" }
4395
4383
  }
4396
- }, Sa = (e) => {
4384
+ }, wa = (e) => {
4397
4385
  let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = globalThis.atob(t + "=".repeat((4 - t.length % 4) % 4));
4398
4386
  return Uint8Array.from(n, (e) => e.charCodeAt(0));
4399
- }, Ca = () => {
4387
+ }, Ta = () => {
4400
4388
  let e = globalThis.crypto;
4401
4389
  if (!e?.subtle) throw Error("Verifying tokens needs the Web Crypto API, available only in a secure context (https or localhost)");
4402
4390
  return e;
4403
4391
  };
4404
- async function wa(e, t, n, r, i) {
4405
- let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(Sa(a))), l = c.alg === "ES256" || c.alg === "RS256" ? xa[c.alg] : void 0;
4392
+ async function Ea(e, t, n, r, i) {
4393
+ let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(wa(a))), l = c.alg === "ES256" || c.alg === "RS256" ? Ca[c.alg] : void 0;
4406
4394
  if (!l) throw Error(`Token signing algorithm ${String(c.alg)} is not accepted`);
4407
4395
  let u = t.find((e) => e.kid === c.kid && e.kty === l.kty && (e.kty !== "EC" || e.crv === "P-256"));
4408
4396
  if (!u) throw Error("Token signing key is not published by the server");
4409
- let d = Ca().subtle, f = await d.importKey("jwk", l.key(u), l.imported, !1, ["verify"]), p = new TextEncoder().encode(`${a}.${o}`);
4410
- if (!await d.verify(l.signature, f, Sa(s), p)) throw Error("Token signature is not valid");
4397
+ let d = Ta().subtle, f = await d.importKey("jwk", l.key(u), l.imported, !1, ["verify"]), p = new TextEncoder().encode(`${a}.${o}`);
4398
+ if (!await d.verify(l.signature, f, wa(s), p)) throw Error("Token signature is not valid");
4411
4399
  let m = M(e), h = Array.isArray(m.aud) ? m.aud : [m.aud];
4412
4400
  if (m.iss !== n) throw Error("Token issuer does not match the server");
4413
4401
  if (!h.includes(r)) throw Error("Token is not issued for this app");
4414
4402
  if (typeof m.exp != "number" || j(m, 0)) throw Error("Token has expired");
4415
4403
  if (i && m.type !== i) throw Error("Token type is not valid");
4416
4404
  }
4417
- async function Ta(t, n, r) {
4405
+ async function Da(t, n, r) {
4418
4406
  if (!n) throw Error("An app id is required to accept tokens from the URL");
4419
4407
  if (!r.access_token) throw Error("No access token received");
4420
- Ca();
4408
+ Ta();
4421
4409
  let i = t.replace(/\/+$/, ""), [a, o] = await Promise.all([e.get(`${i}/.well-known/openid-configuration`), e.get(`${i}/.well-known/jwks.json`)]), s = a.data?.issuer, c = o.data?.keys ?? [];
4422
4410
  if (!s) throw Error("The server did not publish an issuer");
4423
- await wa(r.access_token, c, s, n, N.access_token), r.refresh_token && await wa(r.refresh_token, c, s, n, N.refresh_token), r.id_token && await wa(r.id_token, c, s, n);
4411
+ await Ea(r.access_token, c, s, n, N.access_token), r.refresh_token && await Ea(r.refresh_token, c, s, n, N.refresh_token), r.id_token && await Ea(r.id_token, c, s, n);
4424
4412
  }
4425
4413
  // lib/upgrade/errors.ts
4426
4414
  var Q = {
@@ -4440,23 +4428,23 @@ var Q = {
4440
4428
  grantPredatesCredentialReset: "error.grant.predates_credential_reset",
4441
4429
  tokenAccessEnded: "error.token.access_ended",
4442
4430
  userNotFound: "error.user.not_found"
4443
- }, Ea = Object.freeze([
4431
+ }, Oa = Object.freeze([
4444
4432
  Q.twoFactorCodeInvalid,
4445
4433
  Q.twoFactorNotEnabled,
4446
4434
  Q.challengeInvalid,
4447
4435
  Q.challengeSessionMismatch,
4448
4436
  Q.challengeTooManyAttempts
4449
- ]), Da = Object.freeze([
4437
+ ]), ka = Object.freeze([
4450
4438
  Q.tokenInvalid,
4451
4439
  Q.grantPredatesCredentialReset,
4452
4440
  Q.tokenAccessEnded,
4453
4441
  Q.userNotFound
4454
- ]), Oa = Object.freeze([
4442
+ ]), Aa = Object.freeze([
4455
4443
  "wrong_code",
4456
4444
  "challenge_spent",
4457
4445
  "not_registered",
4458
4446
  "prepare_not_required"
4459
- ]), ka = (e) => Oa.includes(e), Aa = {
4447
+ ]), ja = (e) => Aa.includes(e), Ma = {
4460
4448
  wrong_code: "That code was not accepted. Try again.",
4461
4449
  challenge_spent: "That verification challenge is no longer valid. Start again.",
4462
4450
  exhausted: "Too many attempts. Try again later.",
@@ -4471,9 +4459,9 @@ var Q = {
4471
4459
  session_changed: "The session ended during verification."
4472
4460
  }, $ = class extends Error {
4473
4461
  constructor(e) {
4474
- super(e.message || Aa[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, e.retryAfter !== void 0 && (this.retryAfter = e.retryAfter), this.retryable = ka(e.kind), e.cause !== void 0 && (this.cause = e.cause);
4462
+ super(e.message || Ma[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, e.retryAfter !== void 0 && (this.retryAfter = e.retryAfter), this.retryable = ja(e.kind), e.cause !== void 0 && (this.cause = e.cause);
4475
4463
  }
4476
- }, ja = Object.freeze([
4464
+ }, Na = Object.freeze([
4477
4465
  "upgrade_transport",
4478
4466
  "upgrade_insufficient",
4479
4467
  "upgrade_unavailable",
@@ -4481,14 +4469,14 @@ var Q = {
4481
4469
  "upgrade_cancelled",
4482
4470
  "upgrade_unsatisfiable",
4483
4471
  "upgrade_sign_in_required"
4484
- ]), Ma = (e) => typeof e == "object" && !!e && typeof e.code == "string" && ja.includes(e.code), Na = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", Pa = (e) => {
4472
+ ]), Pa = (e) => typeof e == "object" && !!e && typeof e.code == "string" && Na.includes(e.code), Fa = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", Ia = (e) => {
4485
4473
  let t = e?.error, n = typeof t == "string" ? t : t?.message;
4486
4474
  if (typeof n == "string" && n && !n.startsWith("localized error:")) return n;
4487
- }, Fa = (e) => {
4475
+ }, La = (e) => {
4488
4476
  if (!e || typeof e != "object") return;
4489
4477
  let t = e["retry-after"];
4490
4478
  return typeof t == "string" && /^\d+$/.test(t.trim()) ? Number(t.trim()) : void 0;
4491
- }, Ia = (e) => {
4479
+ }, Ra = (e) => {
4492
4480
  if (typeof e != "object" || !e) return {
4493
4481
  hasResponse: !1,
4494
4482
  message: typeof e == "string" ? e : void 0
@@ -4499,10 +4487,10 @@ var Q = {
4499
4487
  errorId: typeof t.id == "string" ? t.id : i,
4500
4488
  message: typeof t.message == "string" ? t.message : void 0,
4501
4489
  hasResponse: n !== void 0 || typeof t.status == "number",
4502
- serverText: Pa(n?.data),
4503
- retryAfter: Fa(n?.headers)
4490
+ serverText: Ia(n?.data),
4491
+ retryAfter: La(n?.headers)
4504
4492
  };
4505
- }, La = (e, t) => {
4493
+ }, za = (e, t) => {
4506
4494
  switch (e) {
4507
4495
  case Q.twoFactorCodeInvalid: return "wrong_code";
4508
4496
  case Q.challengeInvalid:
@@ -4520,15 +4508,15 @@ var Q = {
4520
4508
  case "error.service.unavailable": return "network";
4521
4509
  default: return;
4522
4510
  }
4523
- }, Ra = (e, t) => e === void 0 ? "network" : e === 501 ? "unavailable" : e === 400 ? "fatal" : e === 429 ? "rate_limited" : e === 401 || e === 403 ? t === "start" ? "challenge_spent" : "session_changed" : e >= 500 ? "network" : "fatal", za = (e, t) => {
4511
+ }, Ba = (e, t) => e === void 0 ? "network" : e === 501 ? "unavailable" : e === 400 ? "fatal" : e === 429 ? "rate_limited" : e === 401 || e === 403 ? t === "start" ? "challenge_spent" : "session_changed" : e >= 500 ? "network" : "fatal", Va = (e, t) => {
4524
4512
  if (e instanceof $) return e;
4525
- let n = Ia(e);
4513
+ let n = Ra(e);
4526
4514
  if (!n.hasResponse) return new $({
4527
4515
  kind: "network",
4528
4516
  message: n.message,
4529
4517
  cause: e
4530
4518
  });
4531
- let r = La(n.errorId, t) ?? Ra(n.status, t);
4519
+ let r = za(n.errorId, t) ?? Ba(n.status, t);
4532
4520
  return r === "rate_limited" ? new $({
4533
4521
  kind: r,
4534
4522
  message: n.serverText,
@@ -4543,63 +4531,63 @@ var Q = {
4543
4531
  errorId: n.errorId,
4544
4532
  cause: e
4545
4533
  });
4546
- }, Ba = (e) => e.errorId !== void 0 && Ea.includes(e.errorId), Va = (e) => e.errorId !== void 0 && Da.includes(e.errorId), Ha = class extends Error {
4534
+ }, Ha = (e) => e.errorId !== void 0 && Oa.includes(e.errorId), Ua = (e) => e.errorId !== void 0 && ka.includes(e.errorId), Wa = class extends Error {
4547
4535
  constructor(e, t, n) {
4548
4536
  super(n ?? "The session was elevated, but this action requires a higher assurance level"), this.name = "UpgradeInsufficientError", this.code = "upgrade_insufficient", this.obtained = e, this.required = t;
4549
4537
  }
4550
- }, Ua = class extends Error {
4538
+ }, Ga = class extends Error {
4551
4539
  constructor(e = "Step-up verification is not available on this deployment") {
4552
4540
  super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
4553
4541
  }
4554
- }, Wa = class extends Error {
4542
+ }, Ka = class extends Error {
4555
4543
  constructor(e = "The session changed during verification") {
4556
4544
  super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
4557
4545
  }
4558
- }, Ga = (e) => {
4546
+ }, qa = (e) => {
4559
4547
  if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
4560
4548
  sub: e.sub,
4561
4549
  sid: e.sid
4562
4550
  } : { sub: e.sub };
4563
- }, Ka = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
4551
+ }, Ja = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
4564
4552
  // lib/utils/validation.ts
4565
- function qa(e) {
4553
+ function Ya(e) {
4566
4554
  if (!e || typeof e != "string") return !1;
4567
4555
  let t = e.split(".");
4568
4556
  if (t.length !== 3) return !1;
4569
4557
  let n = /^[A-Za-z0-9_-]+$/;
4570
4558
  return t.every((e) => n.test(e) && e.length > 0);
4571
4559
  }
4572
- function Ja(e) {
4560
+ function Xa(e) {
4573
4561
  return e.replace(/<[^>]*>/g, "").substring(0, 200);
4574
4562
  }
4575
- function Ya(e) {
4563
+ function Za(e) {
4576
4564
  if (!e || typeof e != "string") return !1;
4577
4565
  let t = e.trim();
4578
4566
  return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
4579
4567
  }
4580
- function Xa(e) {
4568
+ function Qa(e) {
4581
4569
  if (!e || typeof e != "string") return !1;
4582
4570
  let t = e.trim();
4583
4571
  return /^\+[1-9]\d{1,14}$/.test(t);
4584
4572
  }
4585
- function Za(e) {
4573
+ function $a(e) {
4586
4574
  if (!e || typeof e != "string") return !1;
4587
4575
  let t = e.trim();
4588
4576
  return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
4589
4577
  }
4590
- function Qa(e, t = 6) {
4578
+ function eo(e, t = 6) {
4591
4579
  return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
4592
4580
  }
4593
- function $a(e) {
4581
+ function to(e) {
4594
4582
  if (!e || typeof e != "string") return null;
4595
4583
  let t = e.toUpperCase().replace(/\s+/g, "");
4596
4584
  return t.length > 64 || !/^[A-Z0-9-]+$/.test(t) || t.replace(/-/g, "") === "" ? null : t;
4597
4585
  }
4598
4586
  // lib/services/auth-service.ts
4599
- var eo = (e) => e ? [e] : [], to = (e) => {
4587
+ var no = (e) => e ? [e] : [], ro = (e) => {
4600
4588
  if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted", "AbortError");
4601
- }, no = (e, t, n, r) => !(e instanceof L || t !== "complete" && r?.aborted || t === "start" && n === "passive"), ro = "passflow_2fa_pkce", io = 3e5, ao = "passflow_pwless_pending", oo = 3e3, so = "passflow_federated_pkce", co = 6e5, lo = "AppId is required for federated auth";
4602
- function uo(e) {
4589
+ }, io = (e, t, n, r) => !(e instanceof L || t !== "complete" && r?.aborted || t === "start" && n === "passive"), ao = "passflow_2fa_pkce", oo = 3e5, so = "passflow_pwless_pending", co = 3e3, lo = "passflow_federated_pkce", uo = 6e5, fo = "AppId is required for federated auth";
4590
+ function po(e) {
4603
4591
  let t;
4604
4592
  try {
4605
4593
  t = new URL(e).protocol;
@@ -4609,7 +4597,7 @@ function uo(e) {
4609
4597
  if (t !== "https:" && t !== "http:") throw Error("The federated start returned an address that is not http or https");
4610
4598
  return e;
4611
4599
  }
4612
- function fo(e) {
4600
+ function mo(e) {
4613
4601
  if (e) try {
4614
4602
  let { protocol: t } = new URL(e);
4615
4603
  return t === "https:" || t === "http:" ? e : void 0;
@@ -4617,14 +4605,14 @@ function fo(e) {
4617
4605
  return;
4618
4606
  }
4619
4607
  }
4620
- function po(e) {
4608
+ function ho(e) {
4621
4609
  return e.provider?.startsWith("conn_") ? e.login_hint : void 0;
4622
4610
  }
4623
- function mo(e) {
4611
+ function go(e) {
4624
4612
  let t = {};
4625
4613
  return e.connection_id !== void 0 && (t.connection_id = e.connection_id), e.email !== void 0 && (t.email = e.email), t;
4626
4614
  }
4627
- var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is gone", _o = (e, t) => new Promise((n, r) => {
4615
+ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is gone", yo = (e, t) => new Promise((n, r) => {
4628
4616
  if (t?.aborted) {
4629
4617
  r(t.reason);
4630
4618
  return;
@@ -4635,21 +4623,21 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4635
4623
  t?.removeEventListener("abort", i), n();
4636
4624
  }, e);
4637
4625
  t?.addEventListener("abort", i, { once: !0 });
4638
- }), vo = (e) => {
4626
+ }), bo = (e) => {
4639
4627
  if (!e) return;
4640
4628
  let t = new URLSearchParams(e.search).get("token");
4641
4629
  if (t) return t;
4642
4630
  let n = e.hash.indexOf("?");
4643
4631
  return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
4644
- }, yo = (e) => {
4632
+ }, xo = (e) => {
4645
4633
  if (e) try {
4646
4634
  return M(e).email;
4647
4635
  } catch {
4648
4636
  return;
4649
4637
  }
4650
- }, bo = class {
4651
- constructor(e, t, n, r, i, a, o, s, c, l, u, d = we, f, p = { coordination: Bi() }, m) {
4652
- this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.readAppSettings = m, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.deviceKey = p.deviceKey, this.enrolDeviceKeyRequest = p.enrolDeviceKeyRequest, this.tokenDeliveryManager = new ue(n), this.setBffModeIfConfigured(), this.refresh = ba({
4638
+ }, So = class {
4639
+ constructor(e, t, n, r, i, a, o, s, c, l, u, d = Ee, f, p = { coordination: Hi() }, m) {
4640
+ this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.readAppSettings = m, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.deviceKey = p.deviceKey, this.enrolDeviceKeyRequest = p.enrolDeviceKeyRequest, this.tokenDeliveryManager = new ue(n), this.setBffModeIfConfigured(), this.refresh = Sa({
4653
4641
  emit: this.createRefreshEmit(),
4654
4642
  storage: n,
4655
4643
  cache: i,
@@ -4657,7 +4645,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4657
4645
  coordination: p.coordination,
4658
4646
  platform: d,
4659
4647
  ...p.strikes === void 0 ? {} : { strikes: p.strikes },
4660
- logger: si()
4648
+ logger: li()
4661
4649
  }), this.initializeSession();
4662
4650
  }
4663
4651
  setAppId(e) {
@@ -4732,7 +4720,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4732
4720
  }), !0) : !1;
4733
4721
  }
4734
4722
  handleEmailVerificationStep(e, t, n, r, i) {
4735
- if (!$e(e)) return !1;
4723
+ if (!tt(e)) return !1;
4736
4724
  let a = e.challenge_id || void 0;
4737
4725
  return a && r ? this.rememberPkceSignIn(r.verifier, i) : this.forgetPkceSignIn(), a && this.rememberEmailChallenge(a, {
4738
4726
  operation: t,
@@ -4748,7 +4736,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4748
4736
  rememberEmailChallenge(e, t) {
4749
4737
  this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
4750
4738
  for (let e of this.emailChallenges.keys()) {
4751
- if (this.emailChallenges.size <= ho) break;
4739
+ if (this.emailChallenges.size <= _o) break;
4752
4740
  this.emailChallenges.delete(e);
4753
4741
  }
4754
4742
  }
@@ -4756,14 +4744,14 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4756
4744
  if (this.pendingPkce = {
4757
4745
  verifier: e,
4758
4746
  scopes: t,
4759
- expiresAt: Date.now() + io
4747
+ expiresAt: Date.now() + oo
4760
4748
  }, typeof sessionStorage < "u") try {
4761
- sessionStorage.setItem(ro, JSON.stringify(this.pendingPkce));
4749
+ sessionStorage.setItem(ao, JSON.stringify(this.pendingPkce));
4762
4750
  } catch {}
4763
4751
  }
4764
4752
  readPendingPkce() {
4765
4753
  if (!this.pendingPkce && typeof sessionStorage < "u") try {
4766
- let e = sessionStorage.getItem(ro);
4754
+ let e = sessionStorage.getItem(ao);
4767
4755
  this.pendingPkce = e ? JSON.parse(e) : void 0;
4768
4756
  } catch {
4769
4757
  this.pendingPkce = void 0;
@@ -4775,17 +4763,17 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4775
4763
  }
4776
4764
  forgetPkceSignIn() {
4777
4765
  if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
4778
- sessionStorage.removeItem(ro);
4766
+ sessionStorage.removeItem(ao);
4779
4767
  } catch {}
4780
4768
  }
4781
4769
  rememberPendingPasswordless(e) {
4782
4770
  if (this.pendingPasswordless = e, typeof sessionStorage < "u") try {
4783
- sessionStorage.setItem(ao, JSON.stringify(e));
4771
+ sessionStorage.setItem(so, JSON.stringify(e));
4784
4772
  } catch {}
4785
4773
  }
4786
4774
  readPendingPasswordless() {
4787
4775
  if (!this.pendingPasswordless && typeof sessionStorage < "u") try {
4788
- let e = sessionStorage.getItem(ao);
4776
+ let e = sessionStorage.getItem(so);
4789
4777
  this.pendingPasswordless = e ? JSON.parse(e) : void 0;
4790
4778
  } catch {
4791
4779
  this.pendingPasswordless = void 0;
@@ -4794,22 +4782,22 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4794
4782
  }
4795
4783
  forgetPendingPasswordless() {
4796
4784
  if (this.pendingPasswordless = void 0, typeof sessionStorage < "u") try {
4797
- sessionStorage.removeItem(ao);
4785
+ sessionStorage.removeItem(so);
4798
4786
  } catch {}
4799
4787
  }
4800
4788
  rememberFederatedSlot(e, t, n) {
4801
4789
  if (this.federatedSlot = {
4802
4790
  verifier: e,
4803
4791
  scopes: t,
4804
- expiresAt: Date.now() + co,
4792
+ expiresAt: Date.now() + uo,
4805
4793
  ...n ? { provider: n } : {}
4806
4794
  }, typeof sessionStorage < "u") try {
4807
- sessionStorage.setItem(so, JSON.stringify(this.federatedSlot));
4795
+ sessionStorage.setItem(lo, JSON.stringify(this.federatedSlot));
4808
4796
  } catch {}
4809
4797
  }
4810
4798
  readFederatedSlot() {
4811
4799
  if (!this.federatedSlot && typeof sessionStorage < "u") try {
4812
- let e = sessionStorage.getItem(so);
4800
+ let e = sessionStorage.getItem(lo);
4813
4801
  this.federatedSlot = e ? JSON.parse(e) : void 0;
4814
4802
  } catch {
4815
4803
  this.federatedSlot = void 0;
@@ -4818,7 +4806,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4818
4806
  }
4819
4807
  forgetFederatedSlot() {
4820
4808
  if (this.federatedSlot = void 0, typeof sessionStorage < "u") try {
4821
- sessionStorage.removeItem(so);
4809
+ sessionStorage.removeItem(lo);
4822
4810
  } catch {}
4823
4811
  }
4824
4812
  async startPkce() {
@@ -4826,17 +4814,17 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4826
4814
  try {
4827
4815
  e = await this.readPkceEnabled?.() ?? !1;
4828
4816
  } catch (e) {
4829
- si().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
4817
+ li().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
4830
4818
  return;
4831
4819
  }
4832
- return e ? wr() : void 0;
4820
+ return e ? Er() : void 0;
4833
4821
  }
4834
4822
  async exchangeCode(e, t) {
4835
4823
  return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
4836
4824
  }
4837
4825
  async completePkceSignIn(e) {
4838
4826
  let t = this.readPendingPkce();
4839
- if (!t) throw Error(go);
4827
+ if (!t) throw Error(vo);
4840
4828
  let n = await this.authApi.pkceExchange(e, t.verifier);
4841
4829
  return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
4842
4830
  }
@@ -4866,7 +4854,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4866
4854
  if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
4867
4855
  }
4868
4856
  async signIn(e, t) {
4869
- if ("email" in e && e.email && !Ya(e.email)) {
4857
+ if ("email" in e && e.email && !Za(e.email)) {
4870
4858
  let e = /* @__PURE__ */ Error("Invalid email format"), t = {
4871
4859
  operation: "sign-in",
4872
4860
  message: "Invalid email format",
@@ -4875,7 +4863,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4875
4863
  };
4876
4864
  throw W(this.subscribeStore, t), e;
4877
4865
  }
4878
- if ("username" in e && e.username && !Za(e.username)) {
4866
+ if ("username" in e && e.username && !$a(e.username)) {
4879
4867
  let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
4880
4868
  operation: "sign-in",
4881
4869
  message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
@@ -4884,7 +4872,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4884
4872
  };
4885
4873
  throw W(this.subscribeStore, t), e;
4886
4874
  }
4887
- if ("phone" in e && e.phone && !Xa(e.phone)) {
4875
+ if ("phone" in e && e.phone && !Qa(e.phone)) {
4888
4876
  let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
4889
4877
  operation: "sign-in",
4890
4878
  message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
@@ -4894,13 +4882,13 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4894
4882
  throw W(this.subscribeStore, t), e;
4895
4883
  }
4896
4884
  this.subscribeStore.notify(G.SignInStart, { email: e.email });
4897
- let n = this.deviceService.getDeviceId(), r = At(this.platform.getDeviceType());
4885
+ let n = this.deviceService.getDeviceId(), r = Mt(this.platform.getDeviceType());
4898
4886
  e.scopes = e.scopes ?? this.scopes;
4899
4887
  try {
4900
4888
  let i = await this.startPkce(), a = i ? {
4901
4889
  ...e,
4902
4890
  code_challenge: i.challenge
4903
- } : e, o = await this.signInProof(), s = o ? await this.authApi.signIn(a, n, r, t, o) : await this.authApi.signIn(a, n, r, ...eo(t));
4891
+ } : e, o = await this.signInProof(), s = o ? await this.authApi.signIn(a, n, r, t, o) : await this.authApi.signIn(a, n, r, ...no(t));
4904
4892
  if (this.handleEmailVerificationStep(s, "sign-in", e.email, i, e.scopes) || this.handlePendingSecondFactor(s, e.email, i, e.scopes)) return s;
4905
4893
  let c = await this.exchangeCode(s, i);
4906
4894
  return this.handlePendingSecondFactor(c, e.email) || (await this.processAuthResponse(c, e.scopes), this.subscribeStore.notify(G.SignIn, {
@@ -4918,7 +4906,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4918
4906
  }
4919
4907
  }
4920
4908
  async signUp(e, t) {
4921
- if (e.user.email && !Ya(e.user.email)) {
4909
+ if (e.user.email && !Za(e.user.email)) {
4922
4910
  let e = /* @__PURE__ */ Error("Invalid email format"), t = {
4923
4911
  operation: "sign-up",
4924
4912
  message: "Invalid email format",
@@ -4927,7 +4915,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4927
4915
  };
4928
4916
  throw W(this.subscribeStore, t), e;
4929
4917
  }
4930
- if (e.user.phone_number && !Xa(e.user.phone_number)) {
4918
+ if (e.user.phone_number && !Qa(e.user.phone_number)) {
4931
4919
  let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
4932
4920
  operation: "sign-up",
4933
4921
  message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
@@ -4941,7 +4929,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4941
4929
  let n = await this.startPkce(), r = await this.authApi.signUp(n ? {
4942
4930
  ...e,
4943
4931
  code_challenge: n.challenge
4944
- } : e, ...eo(t));
4932
+ } : e, ...no(t));
4945
4933
  if (this.handleEmailVerificationStep(r, "sign-up", e.user.email, n, e.scopes) || this.handlePendingSecondFactor(r, e.user.email, n, e.scopes)) return r;
4946
4934
  let i = await this.exchangeCode(r, n);
4947
4935
  return this.handlePendingSecondFactor(i, e.user.email) || (await this.processAuthResponse(i, e.scopes), this.notifyRegisteredAndSignedIn(i), await this.submitSessionCheck()), i;
@@ -4956,7 +4944,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4956
4944
  }
4957
4945
  }
4958
4946
  async passwordlessSignIn(e, t) {
4959
- if (e.email && !Ya(e.email)) {
4947
+ if (e.email && !Za(e.email)) {
4960
4948
  let e = /* @__PURE__ */ Error("Invalid email format"), t = {
4961
4949
  operation: "passwordless.start",
4962
4950
  message: "Invalid email format",
@@ -4965,7 +4953,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4965
4953
  };
4966
4954
  throw W(this.subscribeStore, t), e;
4967
4955
  }
4968
- if (e.phone && !Xa(e.phone)) {
4956
+ if (e.phone && !Qa(e.phone)) {
4969
4957
  let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
4970
4958
  operation: "passwordless.start",
4971
4959
  message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
@@ -4975,13 +4963,13 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
4975
4963
  throw W(this.subscribeStore, t), e;
4976
4964
  }
4977
4965
  this.subscribeStore.notify(G.SignInStart, { email: e.email });
4978
- let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId(), i = At(this.platform.getDeviceType());
4966
+ let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId(), i = Mt(this.platform.getDeviceType());
4979
4967
  try {
4980
4968
  let a = await this.startPkce(), o = await this.authApi.passwordlessSignIn({
4981
4969
  ...e,
4982
4970
  scopes: n,
4983
4971
  ...a ? { code_challenge: a.challenge } : {}
4984
- }, r, i, ...eo(t));
4972
+ }, r, i, ...no(t));
4985
4973
  return a && o.challenge_id ? this.rememberPendingPasswordless({
4986
4974
  challengeId: o.challenge_id,
4987
4975
  verifier: a.verifier,
@@ -5005,11 +4993,11 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5005
4993
  this.subscribeStore.notify(G.SignInStart, {}), e.scopes = e.scopes ?? this.scopes, e.device = this.deviceService.getDeviceId();
5006
4994
  let n = this.readPendingPasswordless(), r = n?.challengeId === e.challenge_id ? n : void 0, i = !1;
5007
4995
  try {
5008
- let n = await this.authApi.passwordlessSignInComplete(e, ...eo(t));
4996
+ let n = await this.authApi.passwordlessSignInComplete(e, ...no(t));
5009
4997
  if (i = !0, this.handlePendingSecondFactor(n, r?.email, r && { verifier: r.verifier }, r?.scopes)) return this.forgetPendingPasswordless(), n;
5010
4998
  let a = n;
5011
4999
  if (n.code) {
5012
- if (!r) throw Error(go);
5000
+ if (!r) throw Error(vo);
5013
5001
  if (a = await this.authApi.pkceExchange(n.code, r.verifier), this.handlePendingSecondFactor(a)) return this.forgetPendingPasswordless(), {
5014
5002
  ...a,
5015
5003
  redirect_url: n.redirect_url ?? ""
@@ -5041,11 +5029,11 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5041
5029
  let n = t?.signal;
5042
5030
  try {
5043
5031
  let t = this.readPendingPasswordless();
5044
- if (t?.challengeId !== e) throw Error(go);
5032
+ if (t?.challengeId !== e) throw Error(vo);
5045
5033
  for (;;) {
5046
5034
  if (n?.aborted) throw n.reason;
5047
5035
  if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
5048
- if (this.readPendingPasswordless()?.challengeId !== e) throw Error(go);
5036
+ if (this.readPendingPasswordless()?.challengeId !== e) throw Error(vo);
5049
5037
  let r;
5050
5038
  try {
5051
5039
  r = await this.authApi.passwordlessStatus({
@@ -5063,7 +5051,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5063
5051
  status: "signed-in",
5064
5052
  tokens: { redirect_url: r.redirect_url }
5065
5053
  };
5066
- await _o(oo, n);
5054
+ await yo(co, n);
5067
5055
  }
5068
5056
  } catch (e) {
5069
5057
  if (n?.aborted && e === n.reason) throw e;
@@ -5132,14 +5120,14 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5132
5120
  let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
5133
5121
  try {
5134
5122
  let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
5135
- if (t?.pkce && !r) throw Error(go);
5123
+ if (t?.pkce && !r) throw Error(vo);
5136
5124
  let i = await this.authApi.validateEmailCode(e);
5137
5125
  this.emailChallenges.delete(e.challenge_id);
5138
5126
  let a = r?.scopes ?? t?.scopes ?? this.scopes;
5139
5127
  if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
5140
5128
  let o = i;
5141
5129
  if (i.code) {
5142
- if (!r) throw Error(go);
5130
+ if (!r) throw Error(vo);
5143
5131
  if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
5144
5132
  }
5145
5133
  let s = i.redirect_url ? {
@@ -5197,7 +5185,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5197
5185
  try {
5198
5186
  let e = await this.authApi.logOut(r, n, !this.appId, t);
5199
5187
  if (e.status !== "ok") throw Error("Logout failed");
5200
- return fo(e.saml_logout_url);
5188
+ return mo(e.saml_logout_url);
5201
5189
  } catch {
5202
5190
  return;
5203
5191
  }
@@ -5208,13 +5196,13 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5208
5196
  readSessionPin() {
5209
5197
  try {
5210
5198
  let e = this.storageManager.getToken(N.access_token);
5211
- return e ? Ga(M(e)) : void 0;
5199
+ return e ? qa(M(e)) : void 0;
5212
5200
  } catch {
5213
5201
  return;
5214
5202
  }
5215
5203
  }
5216
5204
  assertSessionPin(e) {
5217
- if (e && !Ka(e, this.readSessionPin())) throw console.warn("[passflow] the session or user changed while a step-up upgrade was in flight; the elevated tokens were discarded and the live session was left untouched."), new Wa("The session changed during verification, so the elevated tokens were discarded");
5205
+ if (e && !Ja(e, this.readSessionPin())) throw console.warn("[passflow] the session or user changed while a step-up upgrade was in flight; the elevated tokens were discarded and the live session was left untouched."), new Ka("The session changed during verification, so the elevated tokens were discarded");
5218
5206
  }
5219
5207
  refreshMode() {
5220
5208
  return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
@@ -5262,7 +5250,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5262
5250
  case "signout":
5263
5251
  n.notify(G.SignOut, t);
5264
5252
  return;
5265
- default: si().warn(`[passflow] Unknown refresh event: ${String(e)}`);
5253
+ default: li().warn(`[passflow] Unknown refresh event: ${String(e)}`);
5266
5254
  }
5267
5255
  };
5268
5256
  }
@@ -5293,11 +5281,11 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5293
5281
  async sendDeviceKeyRefresh(e, t, n, r) {
5294
5282
  let i = t === "json" ? n?.refresh_token ?? "" : "", a = t === "json" ? n?.scopes ?? this.scopes : this.scopes, o = t === "json" ? n?.access_token : void 0, s = {};
5295
5283
  if (e.supported) try {
5296
- let n = t === "json" ? i && await Nn(i) : this.storageManager.getRefreshChallenge(), r = n ? await e.proof("refresh", n) : void 0;
5284
+ let n = t === "json" ? i && await Fn(i) : this.storageManager.getRefreshChallenge(), r = n ? await e.proof("refresh", n) : void 0;
5297
5285
  r && (s = { proof: r });
5298
5286
  } catch (t) {
5299
5287
  throw await e.clear().catch(() => void 0), new z({
5300
- id: qn.proofUnavailable,
5288
+ id: Yn.proofUnavailable,
5301
5289
  message: "The device key could not sign the refresh. Sign in again.",
5302
5290
  status: 0,
5303
5291
  location: R.refresh,
@@ -5307,7 +5295,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5307
5295
  try {
5308
5296
  return await this.authApi.refreshToken(i, a, o, r, s);
5309
5297
  } catch (t) {
5310
- throw Jn(Ki(t)) && await e.clear().catch(() => void 0), t;
5298
+ throw Xn(Ji(t)) && await e.clear().catch(() => void 0), t;
5311
5299
  }
5312
5300
  }
5313
5301
  async signInProof() {
@@ -5324,15 +5312,15 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5324
5312
  try {
5325
5313
  let e = this.deviceKey, t = this.enrolDeviceKeyRequest;
5326
5314
  if (!e || !t) throw Error("Device keys are off: set deviceKey: true in the Passflow config");
5327
- if (!e.supported) throw Error(Vn);
5315
+ if (!e.supported) throw Error(Un);
5328
5316
  let { challenge: n } = await this.authApi.deviceChallenge();
5329
5317
  await t({
5330
5318
  proof: await e.enrolProof(n),
5331
5319
  key_storage: "software"
5332
5320
  }), await e.markEnrolled();
5333
5321
  } catch (e) {
5334
- let t = Ki(e);
5335
- if (t === qn.keyReused) {
5322
+ let t = Ji(e);
5323
+ if (t === Yn.keyReused) {
5336
5324
  await this.deviceKey?.clear().catch(() => void 0);
5337
5325
  let e = this.resetSession();
5338
5326
  this.subscribeStore.notify(G.SignOut, e === void 0 ? { origin: "this-tab" } : {
@@ -5397,7 +5385,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5397
5385
  }
5398
5386
  async sendPasswordResetEmail(e, t) {
5399
5387
  try {
5400
- return await this.authApi.sendPasswordResetEmail(e, ...eo(t));
5388
+ return await this.authApi.sendPasswordResetEmail(e, ...no(t));
5401
5389
  } catch (e) {
5402
5390
  let t = {
5403
5391
  operation: "password-reset.send",
@@ -5410,10 +5398,10 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5410
5398
  }
5411
5399
  async resetPassword(e, t, n) {
5412
5400
  this.subscribeStore.notify(G.SignInStart, {});
5413
- let r = n ?? vo(this.platform.getCurrentUrl()), i = t ?? this.scopes;
5401
+ let r = n ?? bo(this.platform.getCurrentUrl()), i = t ?? this.scopes;
5414
5402
  try {
5415
5403
  let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
5416
- if (this.handleEmailVerificationStep(n, "reset-password", yo(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
5404
+ if (this.handleEmailVerificationStep(n, "reset-password", xo(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
5417
5405
  let a = await this.exchangeCode(n, t);
5418
5406
  if (this.handlePendingSecondFactor(a)) return a;
5419
5407
  let o = n.redirect_url ? {
@@ -5437,17 +5425,17 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5437
5425
  async passkeyRegister(e, t) {
5438
5426
  if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
5439
5427
  this.subscribeStore.notify(G.RegisterStart, {});
5440
- let n = this.deviceService.getDeviceId(), r = At(this.platform.getDeviceType());
5428
+ let n = this.deviceService.getDeviceId(), r = Mt(this.platform.getDeviceType());
5441
5429
  e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
5442
5430
  try {
5443
5431
  let i = await this.startPkce(), { challenge_id: a, publicKey: o } = await this.authApi.passkeyRegisterStart(i ? {
5444
5432
  ...e,
5445
5433
  code_challenge: i.challenge
5446
- } : e, n, r, !this.appId, ...eo(t));
5434
+ } : e, n, r, !this.appId, ...no(t));
5447
5435
  o.user.id = this.platform.btoa(o.user.id);
5448
5436
  let s = await this.platform.passkeys.startRegistration(o);
5449
5437
  if (!s) throw Error("Passkey registration was not completed");
5450
- let c = await this.authApi.passkeyRegisterComplete(s, n, a, !this.appId, ...eo(t));
5438
+ let c = await this.authApi.passkeyRegisterComplete(s, n, a, !this.appId, ...no(t));
5451
5439
  if (this.handlePendingSecondFactor(c, void 0, i, e.scopes)) return c;
5452
5440
  let l = await this.exchangeCode(c, i);
5453
5441
  return this.handlePendingSecondFactor(l) || (await this.processAuthResponse(l, e.scopes), this.notifyRegisteredAndSignedIn(l), await this.submitSessionCheck()), l;
@@ -5464,15 +5452,15 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5464
5452
  async passkeyAuthenticate(e, t) {
5465
5453
  if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
5466
5454
  this.subscribeStore.notify(G.SignInStart, {});
5467
- let n = this.deviceService.getDeviceId(), r = At(this.platform.getDeviceType());
5455
+ let n = this.deviceService.getDeviceId(), r = Mt(this.platform.getDeviceType());
5468
5456
  e.scopes = e.scopes ?? this.scopes;
5469
5457
  try {
5470
5458
  let i = await this.startPkce(), { challenge_id: a, publicKey: o } = await this.authApi.passkeyAuthenticateStart(i ? {
5471
5459
  ...e,
5472
5460
  code_challenge: i.challenge
5473
- } : e, n, r, !this.appId, ...eo(t)), s = await this.platform.passkeys.startAuthentication(o);
5461
+ } : e, n, r, !this.appId, ...no(t)), s = await this.platform.passkeys.startAuthentication(o);
5474
5462
  if (!s) throw Error("Passkey authentication was not completed");
5475
- let c = await this.signInProof(), l = c ? await this.authApi.passkeyAuthenticateComplete(s, n, a, !this.appId, t, c) : await this.authApi.passkeyAuthenticateComplete(s, n, a, !this.appId, ...eo(t));
5463
+ let c = await this.signInProof(), l = c ? await this.authApi.passkeyAuthenticateComplete(s, n, a, !this.appId, t, c) : await this.authApi.passkeyAuthenticateComplete(s, n, a, !this.appId, ...no(t));
5476
5464
  if (this.handlePendingSecondFactor(l, void 0, i, e.scopes)) return l;
5477
5465
  let u = await this.exchangeCode(l, i);
5478
5466
  return this.handlePendingSecondFactor(u) || "access_token" in u && (await this.processAuthResponse(u, e.scopes), this.subscribeStore.notify(G.SignIn, {
@@ -5517,9 +5505,9 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5517
5505
  try {
5518
5506
  let a = await this.googleNativeSettings(), o = this.platform.identityCredentials;
5519
5507
  if (!a || !o) throw new L("unsupported");
5520
- to(r);
5508
+ ro(r);
5521
5509
  let s = e.scopes ?? this.scopes, c = await this.startPkce();
5522
- to(r);
5510
+ ro(r);
5523
5511
  let l = {
5524
5512
  device: this.deviceService.getDeviceId(),
5525
5513
  mode: n,
@@ -5533,7 +5521,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5533
5521
  code_challenge_method: "S256"
5534
5522
  } : {}
5535
5523
  }, u = await this.authApi.federatedNativeStart("google", l, t, r);
5536
- to(r), i = "provider";
5524
+ ro(r), i = "provider";
5537
5525
  let d;
5538
5526
  try {
5539
5527
  d = await o.get({
@@ -5546,11 +5534,11 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5546
5534
  } catch (e) {
5547
5535
  throw e instanceof L ? e : new L("dismissed", e instanceof Error ? e.message : void 0);
5548
5536
  }
5549
- to(r), i = "complete", e.onToken?.(), this.subscribeStore.notify(G.SignInStart, { provider: "google" });
5537
+ ro(r), i = "complete", e.onToken?.(), this.subscribeStore.notify(G.SignInStart, { provider: "google" });
5550
5538
  let f = {
5551
5539
  challenge_id: u.challenge_id,
5552
5540
  id_token: d
5553
- }, p = await this.signInProof(), m = p ? await this.authApi.federatedNativeComplete("google", f, t, p) : await this.authApi.federatedNativeComplete("google", f, ...eo(t));
5541
+ }, p = await this.signInProof(), m = p ? await this.authApi.federatedNativeComplete("google", f, t, p) : await this.authApi.federatedNativeComplete("google", f, ...no(t));
5554
5542
  if (this.handleEmailVerificationStep(m, "sign-in", void 0, c, s) || this.handlePendingSecondFactor(m, void 0, c, s)) return m;
5555
5543
  let h = await this.exchangeCode(m, c);
5556
5544
  return this.handlePendingSecondFactor(h) || (h.access_token || h.id_token || h.token_delivery) && (await this.processAuthResponse(h, s), this.subscribeStore.notify(G.SignIn, {
@@ -5558,7 +5546,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5558
5546
  parsedTokens: this.tokenCacheService.getParsedTokens()
5559
5547
  }), await this.submitSessionCheck()), h;
5560
5548
  } catch (e) {
5561
- if (no(e, i, n, r)) {
5549
+ if (io(e, i, n, r)) {
5562
5550
  let t = {
5563
5551
  operation: "federated.native",
5564
5552
  message: e instanceof Error ? e.message : "Google sign-in failed",
@@ -5567,19 +5555,20 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5567
5555
  };
5568
5556
  W(this.subscribeStore, t);
5569
5557
  }
5570
- throw i !== "complete" && to(r), e;
5558
+ throw i !== "complete" && ro(r), e;
5571
5559
  }
5572
5560
  }
5573
5561
  async usesFederatedPost(e) {
5574
5562
  if (e?.agentTool === !0) return !0;
5575
5563
  try {
5576
- return (await this.readAppSettings?.())?.bot_mode === "human_only";
5564
+ let e = await this.readAppSettings?.();
5565
+ return e?.bot_mode === "human_only" || e?.attack_protection?.challenge === !0;
5577
5566
  } catch {
5578
5567
  return !1;
5579
5568
  }
5580
5569
  }
5581
5570
  federatedStartBody(e, t) {
5582
- let n = po(e);
5571
+ let n = ho(e);
5583
5572
  return {
5584
5573
  redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
5585
5574
  scopes: t,
@@ -5594,12 +5583,12 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5594
5583
  };
5595
5584
  }
5596
5585
  createFederatedAuthUrl(e) {
5597
- if (!this.appId) throw Error(lo);
5586
+ if (!this.appId) throw Error(fo);
5598
5587
  let t = new URL(`/auth/federated/start/${e.provider}`, this.url);
5599
5588
  return t.search = new URLSearchParams(this.federatedStartQuery(e, e.scopes ?? this.scopes, this.appId)).toString(), t.toString();
5600
5589
  }
5601
5590
  federatedStartQuery(e, t, n) {
5602
- let r = po(e);
5591
+ let r = ho(e);
5603
5592
  return {
5604
5593
  scopes: t.join(" "),
5605
5594
  redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
@@ -5615,10 +5604,10 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5615
5604
  };
5616
5605
  }
5617
5606
  createEnterpriseAuthUrl(e) {
5618
- if (!this.appId) throw Error(lo);
5607
+ if (!this.appId) throw Error(fo);
5619
5608
  let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId(), r = new URL(R.enterpriseStart, this.url);
5620
5609
  return r.search = new URLSearchParams({
5621
- ...mo(e),
5610
+ ...go(e),
5622
5611
  ...this.federatedStartQuery({
5623
5612
  ...e,
5624
5613
  device: n
@@ -5628,8 +5617,8 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5628
5617
  async enterpriseStart(e, t) {
5629
5618
  this.subscribeStore.notify(G.SignInStart, e.connection_id ? { provider: `conn_${e.connection_id}` } : { email: e.email });
5630
5619
  let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
5631
- return { auth_url: uo((await this.authApi.enterpriseStart({
5632
- ...mo(e),
5620
+ return { auth_url: po((await this.authApi.enterpriseStart({
5621
+ ...go(e),
5633
5622
  ...this.federatedStartBody({
5634
5623
  ...e,
5635
5624
  device: r
@@ -5637,7 +5626,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5637
5626
  }, t)).auth_url) };
5638
5627
  }
5639
5628
  async federatedAuthWithPopup(e, t) {
5640
- if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(lo);
5629
+ if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(fo);
5641
5630
  let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
5642
5631
  try {
5643
5632
  this.forgetFederatedSlot();
@@ -5655,7 +5644,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5655
5644
  } : {}
5656
5645
  };
5657
5646
  return {
5658
- url: await this.usesFederatedPost(t) ? uo((await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url) : this.createFederatedAuthUrl(a),
5647
+ url: await this.usesFederatedPost(t) ? po((await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url) : this.createFederatedAuthUrl(a),
5659
5648
  pkce: i
5660
5649
  };
5661
5650
  })(), o, s = (t) => {
@@ -5677,11 +5666,11 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5677
5666
  scopes: n
5678
5667
  };
5679
5668
  if (o) {
5680
- if (!f) throw kr();
5669
+ if (!f) throw jr();
5681
5670
  if (_ = await this.authApi.pkceExchange(f, o.verifier), this.handlePendingSecondFactor(_)) return;
5682
5671
  } else {
5683
- if (!await this.isSimpleModeApp()) throw kr();
5684
- await Ta(this.url, this.appId, _);
5672
+ if (!await this.isSimpleModeApp()) throw jr();
5673
+ await Da(this.url, this.appId, _);
5685
5674
  }
5686
5675
  await this.processAuthResponse(_, n), this.subscribeStore.notify(G.SignIn, {
5687
5676
  tokens: _,
@@ -5707,7 +5696,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5707
5696
  }
5708
5697
  }
5709
5698
  federatedAuthWithRedirect(e, t) {
5710
- if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(lo);
5699
+ if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(fo);
5711
5700
  let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
5712
5701
  this.startPkce().then(async (i) => {
5713
5702
  let a = {
@@ -5718,7 +5707,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5718
5707
  code_challenge: i.challenge,
5719
5708
  code_challenge_method: "S256"
5720
5709
  } : {}
5721
- }, o = await this.usesFederatedPost(t) ? uo((await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url) : this.createFederatedAuthUrl(a);
5710
+ }, o = await this.usesFederatedPost(t) ? po((await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url) : this.createFederatedAuthUrl(a);
5722
5711
  i ? this.rememberFederatedSlot(i.verifier, n, e.provider) : this.forgetFederatedSlot(), this.platform.navigateTo(o);
5723
5712
  }).catch((e) => this.reportFederatedRedirectFailure(e));
5724
5713
  }
@@ -5776,7 +5765,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5776
5765
  async authRedirect(e = {}) {
5777
5766
  try {
5778
5767
  let { url: t, appId: n, redirectUrl: r, scopes: i, state: a } = e;
5779
- if (t !== void 0 && Mr(t) !== Mr(this.url) || n !== void 0 && n !== (this.appId ?? "")) throw new U("OVERRIDE_NOT_SUPPORTED", "authRedirect() signs in to this instance's url and appId; create a Passflow instance for another server or app");
5768
+ if (t !== void 0 && Pr(t) !== Pr(this.url) || n !== void 0 && n !== (this.appId ?? "")) throw new U("OVERRIDE_NOT_SUPPORTED", "authRedirect() signs in to this instance's url and appId; create a Passflow instance for another server or app");
5780
5769
  let o = await this.readAppSettings?.();
5781
5770
  if (o?.pkce_enabled !== !0) {
5782
5771
  let e = this.authRedirectUrl({
@@ -5786,8 +5775,8 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5786
5775
  this.platform.navigateTo(a ? `${e}&${new URLSearchParams({ state: a })}` : e);
5787
5776
  return;
5788
5777
  }
5789
- if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT", Dr(o.type));
5790
- let s = this.platform.getCurrentUrl(), c = await Pr({
5778
+ if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT", kr(o.type));
5779
+ let s = this.platform.getCurrentUrl(), c = await Ir({
5791
5780
  url: this.url,
5792
5781
  clientId: this.appId ?? "",
5793
5782
  redirectUri: r ?? (s ? s.origin + s.pathname : ""),
@@ -5808,9 +5797,9 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5808
5797
  if (!this.appId) return !1;
5809
5798
  let t = new URLSearchParams(e.search), n = t.get("code"), r = t.get("state"), i = t.get("error"), a = t.get("error_description");
5810
5799
  if (t.get("user_state") || r === null || !n && !i) return !1;
5811
- let o = Ir();
5800
+ let o = Rr();
5812
5801
  if (o.status === "none") return !1;
5813
- Lr();
5802
+ zr();
5814
5803
  for (let e of [
5815
5804
  "code",
5816
5805
  "state",
@@ -5822,9 +5811,9 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5822
5811
  return this.platform.replaceUrl(e.pathname + (s ? `?${s}` : "") + e.hash), this.finishOidcLanding(async () => {
5823
5812
  if (o.status === "unusable") throw new U("VERIFIER_MISSING", "This sign-in has expired or its proof key is gone. Sign in again.");
5824
5813
  if (o.slot.state !== r) throw new U("STATE_MISMATCH", "The sign-in answer does not belong to this sign-in. Sign in again.");
5825
- if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED", Ja(a || i || "Sign in again."));
5814
+ if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED", Xa(a || i || "Sign in again."));
5826
5815
  return {
5827
- tokens: await zr(this.url, n, o.slot),
5816
+ tokens: await Vr(this.url, n, o.slot),
5828
5817
  scopes: o.slot.scopes,
5829
5818
  returnUrl: o.slot.redirectUri
5830
5819
  };
@@ -5913,7 +5902,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5913
5902
  return;
5914
5903
  }
5915
5904
  }
5916
- }, xo = class {
5905
+ }, Co = class {
5917
5906
  constructor(e) {
5918
5907
  this.invitationApi = e;
5919
5908
  }
@@ -5932,7 +5921,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5932
5921
  getInvitationLink(e) {
5933
5922
  return this.invitationApi.getInvitationLink(e);
5934
5923
  }
5935
- }, So = class {
5924
+ }, wo = class {
5936
5925
  constructor(e) {
5937
5926
  this.data = this.normalize(e);
5938
5927
  }
@@ -5989,9 +5978,9 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
5989
5978
  getData() {
5990
5979
  return this.data;
5991
5980
  }
5992
- }, Co = "[passflow] The access token has no tenant membership (no passflow_tm claim): the sign-in did not ask for the tenant scope. Add 'access:tenant:all' to your scopes (for example PassflowProvider `scopes`) and sign in again. A token refresh keeps the old scopes, so refreshing does not fix this.", wo = class {
5981
+ }, To = "[passflow] The access token has no tenant membership (no passflow_tm claim): the sign-in did not ask for the tenant scope. Add 'access:tenant:all' to your scopes (for example PassflowProvider `scopes`) and sign in again. A token refresh keeps the old scopes, so refreshing does not fix this.", Eo = class {
5993
5982
  constructor(e, t, n, r) {
5994
- this.tenantApi = e, this.scopes = t, this.readStoredAccessToken = r, this.tenantScopeWarned = !1, this.logger = n || si();
5983
+ this.tenantApi = e, this.scopes = t, this.readStoredAccessToken = r, this.tenantScopeWarned = !1, this.logger = n || li();
5995
5984
  }
5996
5985
  warnIfNoTenantMembership() {
5997
5986
  if (this.tenantScopeWarned) return;
@@ -6003,7 +5992,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6003
5992
  } catch {
6004
5993
  return;
6005
5994
  }
6006
- t.passflow_tm === void 0 && (this.tenantScopeWarned = !0, this.logger.warn(Co));
5995
+ t.passflow_tm === void 0 && (this.tenantScopeWarned = !0, this.logger.warn(To));
6007
5996
  }
6008
5997
  handlePassflowError(t, n) {
6009
5998
  if (e.isAxiosError(t) && t.response?.data) {
@@ -6042,7 +6031,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6042
6031
  async getTenantUserMembership(e) {
6043
6032
  this.warnIfNoTenantMembership();
6044
6033
  try {
6045
- return new So(await this.tenantApi.getTenantDetails(e));
6034
+ return new wo(await this.tenantApi.getTenantDetails(e));
6046
6035
  } catch (t) {
6047
6036
  this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
6048
6037
  }
@@ -6188,8 +6177,8 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6188
6177
  this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
6189
6178
  }
6190
6179
  }
6191
- }, To = class {
6192
- constructor(e, t, n, r = we) {
6180
+ }, Do = class {
6181
+ constructor(e, t, n, r = Ee) {
6193
6182
  this.storageManager = e, this.subscribeStore = n, this.platform = r, this.checkInterval = null, this.CHECK_INTERVAL = 6e4, this.unsubscribeForeground = null, this.unsubscribeUnload = null, this.tokenExpiredFlag = !1, this.storageManager = e, this.setupLifecycleListeners();
6194
6183
  }
6195
6184
  get isRefreshing() {
@@ -6268,7 +6257,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6268
6257
  isExpired() {
6269
6258
  return this.tokensCache ? this.tokensCache.access_token ? j(M(this.tokensCache.access_token)) : !1 : !0;
6270
6259
  }
6271
- }, Eo = class {
6260
+ }, Oo = class {
6272
6261
  constructor(e, t, n) {
6273
6262
  this.twoFactorApi = e, this.subscribeStore = t, this.signInCompleter = n, this.PARTIAL_AUTH_TIMEOUT_MS = 3e5, this.SESSION_STORAGE_KEY = "passflow_2fa_challenge", this.subscribeStore.subscribe({ onAuthChange: (e, t) => {
6274
6263
  if (e === G.TwoFactorRequired) {
@@ -6348,8 +6337,8 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6348
6337
  assertTotpCode(e) {
6349
6338
  let t = this.totpDigits;
6350
6339
  if (t) {
6351
- if (!Qa(e, t)) throw Error(`Invalid TOTP code format. Code must be exactly ${t} digits.`);
6352
- } else if (!Qa(e, 6) && !Qa(e, 8)) throw Error("Invalid TOTP code format. Code must be 6 or 8 digits.");
6340
+ if (!eo(e, t)) throw Error(`Invalid TOTP code format. Code must be exactly ${t} digits.`);
6341
+ } else if (!eo(e, 6) && !eo(e, 8)) throw Error("Invalid TOTP code format. Code must be 6 or 8 digits.");
6353
6342
  }
6354
6343
  requirePendingTfaToken() {
6355
6344
  let e = this.pendingTfaToken();
@@ -6387,7 +6376,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6387
6376
  }
6388
6377
  async useRecoveryCode(e, t) {
6389
6378
  try {
6390
- let n = $a(e);
6379
+ let n = to(e);
6391
6380
  if (!n) throw Error("Invalid recovery code format. Expected letters, digits and dashes, such as XXXX-XXXX-XXXX.");
6392
6381
  if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
6393
6382
  if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
@@ -6650,8 +6639,8 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6650
6639
  this.emitErrorAndThrow(e, "2fa.preferred-method.clear", "Clear preferred 2FA method");
6651
6640
  }
6652
6641
  }
6653
- }, Do = class {
6654
- constructor(e, t, n = we) {
6642
+ }, ko = class {
6643
+ constructor(e, t, n = Ee) {
6655
6644
  this.userAPI = e, this.deviceService = t, this.platform = n;
6656
6645
  }
6657
6646
  getUserPasskeys() {
@@ -6665,7 +6654,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6665
6654
  }
6666
6655
  async addUserPasskey({ relyingPartyId: e, passkeyUsername: t, passkeyDisplayName: n } = {}) {
6667
6656
  if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
6668
- let r = this.deviceService.getDeviceId(), i = At(this.platform.getDeviceType()), { challenge_id: a, publicKey: o } = await this.userAPI.addUserPasskeyStart({
6657
+ let r = this.deviceService.getDeviceId(), i = Mt(this.platform.getDeviceType()), { challenge_id: a, publicKey: o } = await this.userAPI.addUserPasskeyStart({
6669
6658
  relyingPartyId: (e || this.platform.getCurrentUrl()?.hostname) ?? "",
6670
6659
  deviceId: r,
6671
6660
  os: i,
@@ -6692,77 +6681,77 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6692
6681
  updateProfile(e, t) {
6693
6682
  return this.userAPI.updateProfile(e, t);
6694
6683
  }
6695
- }, Oo = class extends Error {
6684
+ }, Ao = class extends Error {
6696
6685
  constructor(e, t, n = !1) {
6697
6686
  super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
6698
6687
  }
6699
- }, ko = (e, t) => {
6688
+ }, jo = (e, t) => {
6700
6689
  let n = t?.trim();
6701
- if (!n) throw new Oo(e, "A verification code is required");
6690
+ if (!n) throw new Ao(e, "A verification code is required");
6702
6691
  return n;
6703
- }, Ao = {
6692
+ }, Mo = {
6704
6693
  type: "totp",
6705
6694
  requiresPrepare: !1,
6706
6695
  input: "code",
6707
- assert: async ({ code: e }) => ({ code: ko("totp", e) })
6708
- }, jo = {
6696
+ assert: async ({ code: e }) => ({ code: jo("totp", e) })
6697
+ }, No = {
6709
6698
  type: "recovery_codes",
6710
6699
  requiresPrepare: !1,
6711
6700
  input: "code",
6712
- assert: async ({ code: e }) => ({ code: ko("recovery_codes", e) })
6713
- }, Mo = {
6701
+ assert: async ({ code: e }) => ({ code: jo("recovery_codes", e) })
6702
+ }, Po = {
6714
6703
  type: "passkey",
6715
6704
  requiresPrepare: !0,
6716
6705
  input: "none",
6717
6706
  assert: async ({ prepared: e, platform: t }) => {
6718
- if (!e?.webauthn) throw new Oo("passkey", "The upgrade challenge carried no WebAuthn options");
6707
+ if (!e?.webauthn) throw new Ao("passkey", "The upgrade challenge carried no WebAuthn options");
6719
6708
  let n = t.passkeys;
6720
- if (!n) throw new Oo("passkey", "This platform does not support passkeys");
6709
+ if (!n) throw new Ao("passkey", "This platform does not support passkeys");
6721
6710
  let r;
6722
6711
  try {
6723
6712
  r = await n.startAuthentication(e.webauthn);
6724
6713
  } catch (e) {
6725
- throw new Oo("passkey", e?.message || "Passkey verification was cancelled", !0);
6714
+ throw new Ao("passkey", e?.message || "Passkey verification was cancelled", !0);
6726
6715
  }
6727
- if (!r) throw new Oo("passkey", "Passkey verification was cancelled", !0);
6716
+ if (!r) throw new Ao("passkey", "Passkey verification was cancelled", !0);
6728
6717
  return {
6729
6718
  challenge_id: e.challengeId,
6730
6719
  credential: r
6731
6720
  };
6732
6721
  }
6733
- }, No = Object.freeze([
6734
- Ao,
6722
+ }, Fo = Object.freeze([
6735
6723
  Mo,
6736
- jo
6737
- ]), Po = (e = No) => new Map(e.map((e) => [e.type, e])), Fo = 3, Io = {
6724
+ Po,
6725
+ No
6726
+ ]), Io = (e = Fo) => new Map(e.map((e) => [e.type, e])), Lo = 3, Ro = {
6738
6727
  totp: 0,
6739
6728
  passkey: 1,
6740
6729
  email_otp: 2,
6741
6730
  sms_otp: 3,
6742
6731
  recovery_codes: 9
6743
- }, Lo = (e) => e.requiredLevel ?? ke(e.acrValues), Ro = (e, t) => {
6744
- let n = Io[e.type] ?? 5, r = t !== void 0 && t >= Fo, i = e.type === "passkey";
6732
+ }, zo = (e) => e.requiredLevel ?? je(e.acrValues), Bo = (e, t) => {
6733
+ let n = Ro[e.type] ?? 5, r = t !== void 0 && t >= Lo, i = e.type === "passkey";
6745
6734
  return (r && !i ? 100 : 0) + n;
6746
- }, zo = (e, t) => {
6735
+ }, Vo = (e, t) => {
6747
6736
  if (t.availableFactors) return t.availableFactors.flatMap((t) => e.find((e) => e.type === t) ?? []);
6748
- let n = Lo(t);
6749
- return [...e].sort((e, t) => Ro(e, n) - Ro(t, n));
6750
- }, Bo = class extends Error {
6737
+ let n = zo(t);
6738
+ return [...e].sort((e, t) => Bo(e, n) - Bo(t, n));
6739
+ }, Ho = class extends Error {
6751
6740
  constructor(e) {
6752
6741
  super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
6753
6742
  }
6754
- }, Vo = class extends Error {
6743
+ }, Uo = class extends Error {
6755
6744
  constructor(e = "Only a fresh sign-in can meet this challenge") {
6756
6745
  super(e), this.code = "upgrade_sign_in_required", this.name = "UpgradeSignInRequiredError";
6757
6746
  }
6758
- }, Ho = (e) => e?.signInRequired === !0 || e?.signInRequired === void 0 && e?.availableFactors?.length === 0, Uo = (e) => e?.signInRequired === !1 && e.availableFactors?.length === 0, Wo = "This account has no factor that reaches the required level (it may need a device-bound passkey)", Go = (e) => {
6759
- if (Ho(e)) return new Vo();
6760
- if (Uo(e)) return new Ko(Wo);
6761
- }, Ko = class extends Error {
6747
+ }, Wo = (e) => e?.signInRequired === !0 || e?.signInRequired === void 0 && e?.availableFactors?.length === 0, Go = (e) => e?.signInRequired === !1 && e.availableFactors?.length === 0, Ko = "This account has no factor that reaches the required level (it may need a device-bound passkey)", qo = (e) => {
6748
+ if (Wo(e)) return new Uo();
6749
+ if (Go(e)) return new Jo(Ko);
6750
+ }, Jo = class extends Error {
6762
6751
  constructor(e = "No available authentication factor can satisfy this challenge") {
6763
6752
  super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
6764
6753
  }
6765
- }, qo = 4, Jo = 3e4, Yo = () => {
6754
+ }, Yo = 4, Xo = 3e4, Zo = () => {
6766
6755
  let e = () => void 0, t = () => void 0;
6767
6756
  return {
6768
6757
  promise: new Promise((n, r) => {
@@ -6771,12 +6760,12 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6771
6760
  resolve: e,
6772
6761
  reject: t
6773
6762
  };
6774
- }, Xo = (e) => ({
6763
+ }, Qo = (e) => ({
6775
6764
  acrValues: e.acrValues,
6776
6765
  level: e.requiredLevel,
6777
6766
  maxAge: e.maxAge
6778
- }), Zo = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, Qo = (e, t) => {
6779
- let n = e.requiredLevel === void 0 ? t.requiredLevel : t.requiredLevel === void 0 ? e.requiredLevel : Math.max(e.requiredLevel, t.requiredLevel), r = n === void 0 ? e.acrValues ?? t.acrValues : n === e.requiredLevel ? e.acrValues : t.acrValues, i = e.maxAge === void 0 ? t.maxAge : t.maxAge === void 0 ? e.maxAge : Math.min(e.maxAge, t.maxAge), a = Array.from(/* @__PURE__ */ new Set([...e.channels ?? [], ...t.channels ?? []])), { availableFactors: o, signInRequired: s } = $o(t, e) && !$o(e, t) || !t.availableFactors ? e : t;
6767
+ }), $o = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, es = (e, t) => {
6768
+ let n = e.requiredLevel === void 0 ? t.requiredLevel : t.requiredLevel === void 0 ? e.requiredLevel : Math.max(e.requiredLevel, t.requiredLevel), r = n === void 0 ? e.acrValues ?? t.acrValues : n === e.requiredLevel ? e.acrValues : t.acrValues, i = e.maxAge === void 0 ? t.maxAge : t.maxAge === void 0 ? e.maxAge : Math.min(e.maxAge, t.maxAge), a = Array.from(/* @__PURE__ */ new Set([...e.channels ?? [], ...t.channels ?? []])), { availableFactors: o, signInRequired: s } = ts(t, e) && !ts(e, t) || !t.availableFactors ? e : t;
6780
6769
  return {
6781
6770
  acrValues: r,
6782
6771
  requiredLevel: n,
@@ -6786,12 +6775,12 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6786
6775
  ...o ? { availableFactors: o } : {},
6787
6776
  ...s === void 0 ? {} : { signInRequired: s }
6788
6777
  };
6789
- }, $o = (e, t) => {
6778
+ }, ts = (e, t) => {
6790
6779
  let n = t.requiredLevel !== void 0 && (e.requiredLevel === void 0 || t.requiredLevel > e.requiredLevel), r = t.maxAge !== void 0 && (e.maxAge === void 0 || t.maxAge < e.maxAge);
6791
6780
  return n || r;
6792
- }, es = class {
6781
+ }, ns = class {
6793
6782
  constructor(e) {
6794
- this.state = "idle", this.inFlight = null, this.requirement = null, this.selected = null, this.rankedRequirement = null, this.registrations = [], this.proof = null, this.pruned = /* @__PURE__ */ new Set(), this.openPrompt = null, this.transport = e.transport, this.prompt = e.prompt, this.platform = e.platform, this.available = e.factors ?? No, this.registry = Po(this.available), this.maxAttempts = e.maxAttempts ?? qo, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? Jo;
6783
+ this.state = "idle", this.inFlight = null, this.requirement = null, this.selected = null, this.rankedRequirement = null, this.registrations = [], this.proof = null, this.pruned = /* @__PURE__ */ new Set(), this.openPrompt = null, this.transport = e.transport, this.prompt = e.prompt, this.platform = e.platform, this.available = e.factors ?? Fo, this.registry = Io(this.available), this.maxAttempts = e.maxAttempts ?? Yo, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? Xo;
6795
6784
  }
6796
6785
  get currentState() {
6797
6786
  return this.state;
@@ -6811,9 +6800,9 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6811
6800
  }
6812
6801
  register(e, t) {
6813
6802
  let n = t.kind === "imperative" && t.requested !== void 0, r = {
6814
- demanded: t.kind === "imperative" && t.requested ? t.requested : Xo(e),
6803
+ demanded: t.kind === "imperative" && t.requested ? t.requested : Qo(e),
6815
6804
  statedBar: n,
6816
- settlement: Yo(),
6805
+ settlement: Zo(),
6817
6806
  reported: !1,
6818
6807
  entry: {
6819
6808
  ...t,
@@ -6829,15 +6818,15 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6829
6818
  this.requirement = e;
6830
6819
  return;
6831
6820
  }
6832
- let n = $o(t, e);
6833
- this.requirement = Qo(t, e), Go(this.requirement) ? this.state === "collecting" && this.selected === null && (this.openPrompt?.onClosed?.(), this.closeOpenPrompt?.()) : n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
6821
+ let n = ts(t, e);
6822
+ this.requirement = es(t, e), qo(this.requirement) ? this.state === "collecting" && this.selected === null && (this.openPrompt?.onClosed?.(), this.closeOpenPrompt?.()) : n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
6834
6823
  challenge: this.requirement,
6835
6824
  factors: this.offeredFactors()
6836
6825
  });
6837
6826
  }
6838
6827
  offeredFactors() {
6839
6828
  let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
6840
- return t ? zo(e, t) : e;
6829
+ return t ? Vo(e, t) : e;
6841
6830
  }
6842
6831
  receiveReport(e, t) {
6843
6832
  e.reported || (e.reported = !0, e.entry.outcome = t.outcome, t.obtained && (e.entry.obtained = t.obtained), t.required && (e.entry.required = t.required), this.notifyReportsSettled());
@@ -6872,12 +6861,12 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6872
6861
  }
6873
6862
  release(e, t) {
6874
6863
  if (e.entry.kind === "imperative") {
6875
- if (e.statedBar && !Zo(t, e.demanded)) {
6864
+ if (e.statedBar && !$o(t, e.demanded)) {
6876
6865
  this.receiveReport(e, {
6877
6866
  outcome: "insufficient",
6878
6867
  obtained: t,
6879
6868
  required: e.demanded
6880
- }), e.settlement.reject(new Ha(t, e.demanded));
6869
+ }), e.settlement.reject(new Wa(t, e.demanded));
6881
6870
  return;
6882
6871
  }
6883
6872
  this.receiveReport(e, {
@@ -6947,7 +6936,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6947
6936
  async prove() {
6948
6937
  let e;
6949
6938
  for (let t = 0; t < this.maxAttempts; t++) {
6950
- let t = Go(this.requirement);
6939
+ let t = qo(this.requirement);
6951
6940
  if (t) return {
6952
6941
  status: "failed",
6953
6942
  reason: t
@@ -6955,7 +6944,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6955
6944
  let n = this.offeredFactors();
6956
6945
  if (n.length === 0) return {
6957
6946
  status: "failed",
6958
- reason: new Ko()
6947
+ reason: new Jo()
6959
6948
  };
6960
6949
  let r = this.requirement, i;
6961
6950
  try {
@@ -6963,29 +6952,29 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
6963
6952
  } catch (e) {
6964
6953
  return {
6965
6954
  status: "failed",
6966
- reason: new Bo(e)
6955
+ reason: new Ho(e)
6967
6956
  };
6968
6957
  }
6969
- let a = Go(this.requirement);
6958
+ let a = qo(this.requirement);
6970
6959
  if (a) return {
6971
6960
  status: "failed",
6972
6961
  reason: a
6973
6962
  };
6974
6963
  if (i.type === "cancel") return {
6975
6964
  status: "failed",
6976
- reason: new Bo()
6965
+ reason: new Ho()
6977
6966
  };
6978
6967
  let o = this.registry.get(i.factor);
6979
- if (!o) e = new Ko(`Unknown authentication factor: ${i.factor}`), this.state = "collecting", this.selected = null;
6968
+ if (!o) e = new Jo(`Unknown authentication factor: ${i.factor}`), this.state = "collecting", this.selected = null;
6980
6969
  else try {
6981
6970
  return await this.proveAndCommit(o, i.code), {
6982
6971
  status: "proven",
6983
- obtained: this.readObtainedBar?.() ?? Xo(this.rankedRequirement ?? r)
6972
+ obtained: this.readObtainedBar?.() ?? Qo(this.rankedRequirement ?? r)
6984
6973
  };
6985
6974
  } catch (t) {
6986
- if (t instanceof Oo && t.cancelled) return {
6975
+ if (t instanceof Ao && t.cancelled) return {
6987
6976
  status: "failed",
6988
- reason: new Bo()
6977
+ reason: new Ho()
6989
6978
  };
6990
6979
  let n = this.classifyProofFailure(t);
6991
6980
  if (n) return {
@@ -7021,16 +7010,16 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7021
7010
  });
7022
7011
  }
7023
7012
  classifyProofFailure(e) {
7024
- if (e instanceof Ha || e instanceof Ua || e instanceof Wa) return e;
7013
+ if (e instanceof Wa || e instanceof Ga || e instanceof Ka) return e;
7025
7014
  if (e instanceof $) switch (e.kind) {
7026
- case "unavailable": return new Ua(e.message);
7015
+ case "unavailable": return new Ga(e.message);
7027
7016
  case "exhausted":
7028
7017
  case "attempts_exhausted":
7029
7018
  case "rate_limited":
7030
7019
  case "fatal":
7031
7020
  case "protocol":
7032
7021
  case "network": return e;
7033
- case "session_changed": return new Wa(e.message);
7022
+ case "session_changed": return new Ka(e.message);
7034
7023
  default: return;
7035
7024
  }
7036
7025
  }
@@ -7042,28 +7031,28 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7042
7031
  });
7043
7032
  await this.transport.commit(e.type, r);
7044
7033
  }
7045
- }, ts = (e) => typeof e == "function" ? e() : e, ns = (e) => {
7034
+ }, rs = (e) => typeof e == "function" ? e() : e, is = (e) => {
7046
7035
  try {
7047
7036
  return new URL(e);
7048
7037
  } catch {
7049
7038
  return;
7050
7039
  }
7051
- }, rs = (e, t) => {
7040
+ }, as = (e, t) => {
7052
7041
  if (!t || t === "/") return !0;
7053
7042
  let n = t.replace(/\/+$/, "");
7054
7043
  return e === n || e.startsWith(`${n}/`);
7055
- }, is = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && rs(e.pathname, t.pathPrefix), as = (e, t) => {
7044
+ }, os = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && as(e.pathname, t.pathPrefix), ss = (e, t) => {
7056
7045
  for (let n of t) {
7057
7046
  if (n === "") continue;
7058
7047
  if (n.startsWith("/")) {
7059
- if (e.relativeToBase && rs(e.pathname, n)) return !0;
7048
+ if (e.relativeToBase && as(e.pathname, n)) return !0;
7060
7049
  continue;
7061
7050
  }
7062
- let t = ns(n) ?? ns(`https://${n}`);
7063
- if (t && e.origin !== void 0 && e.origin === t.origin && rs(e.pathname, t.pathname)) return !0;
7051
+ let t = is(n) ?? is(`https://${n}`);
7052
+ if (t && e.origin !== void 0 && e.origin === t.origin && as(e.pathname, t.pathname)) return !0;
7064
7053
  }
7065
7054
  return !1;
7066
- }, os = (e, t, n) => is(e, t.passflow) || as(e, t.backend) ? !n || n(e.href) !== !1 : !1, ss = (e) => {
7055
+ }, cs = (e, t, n) => os(e, t.passflow) || ss(e, t.backend) ? !n || n(e.href) !== !1 : !1, ls = (e) => {
7067
7056
  let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
7068
7057
  console.warn(n, {
7069
7058
  status: e.status,
@@ -7071,8 +7060,8 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7071
7060
  reason: e.reason,
7072
7061
  detail: t
7073
7062
  });
7074
- }, cs = (e, t) => {
7075
- let n = t.onUpgradeDiagnostic ?? ss;
7063
+ }, us = (e, t) => {
7064
+ let n = t.onUpgradeDiagnostic ?? ls;
7076
7065
  return (t, r) => {
7077
7066
  n({
7078
7067
  status: e.status,
@@ -7084,8 +7073,8 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7084
7073
  }
7085
7074
  });
7086
7075
  };
7087
- }, ls = (e, t, n) => {
7088
- let r = n.onUpgradeDiagnostic ?? ss;
7076
+ }, ds = (e, t, n) => {
7077
+ let r = n.onUpgradeDiagnostic ?? ls;
7089
7078
  for (let n of e) r({
7090
7079
  ...n,
7091
7080
  url: t.request.href,
@@ -7094,14 +7083,14 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7094
7083
  ...n.detail ?? {}
7095
7084
  }
7096
7085
  });
7097
- }, us = /\bjson\b/i, ds = async (e, t) => {
7098
- let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && us.test(r), a;
7086
+ }, fs = /\bjson\b/i, ps = async (e, t) => {
7087
+ let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && fs.test(r), a;
7099
7088
  if (i) try {
7100
7089
  a = await e.readBody();
7101
7090
  } catch {
7102
7091
  a = void 0;
7103
7092
  }
7104
- return Ve(i ? {
7093
+ return Ue(i ? {
7105
7094
  status: e.status,
7106
7095
  getHeader: (t) => e.getHeader(t) ?? void 0,
7107
7096
  body: a
@@ -7109,13 +7098,13 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7109
7098
  status: e.status,
7110
7099
  getHeader: (t) => e.getHeader(t) ?? void 0
7111
7100
  }, { requireChallengeChannel: t.requireChallengeChannel });
7112
- }, fs = (e) => Ve({
7101
+ }, ms = (e) => Ue({
7113
7102
  status: e.status,
7114
7103
  getHeader: (t) => e.getHeader(t) ?? void 0
7115
- }, { requireChallengeChannel: "header" }).challenge, ps = (e, t) => t.passflow === null ? `[passflow] a 401/403 from ${e} carried an upgrade challenge, but no Passflow endpoint is configured — set \`url\` on the Passflow config.` : `[passflow] a 401/403 from ${e} carried an upgrade challenge, but that URL is not covered by the provider's \`backend\` prop — add it there to enable step-up for this API.`, ms = (e, t) => e instanceof Bo ? { kind: "cancelled" } : e instanceof Vo ? { kind: "sign-in-required" } : e instanceof Ko ? {
7104
+ }, { requireChallengeChannel: "header" }).challenge, hs = (e, t) => t.passflow === null ? `[passflow] a 401/403 from ${e} carried an upgrade challenge, but no Passflow endpoint is configured — set \`url\` on the Passflow config.` : `[passflow] a 401/403 from ${e} carried an upgrade challenge, but that URL is not covered by the provider's \`backend\` prop — add it there to enable step-up for this API.`, gs = (e, t) => e instanceof Ho ? { kind: "cancelled" } : e instanceof Uo ? { kind: "sign-in-required" } : e instanceof Jo ? {
7116
7105
  kind: "unsatisfiable",
7117
7106
  error: e
7118
- } : e instanceof Ua ? { kind: "unavailable" } : e instanceof Wa ? { kind: "session-changed" } : e instanceof Ha ? {
7107
+ } : e instanceof Ga ? { kind: "unavailable" } : e instanceof Ka ? { kind: "session-changed" } : e instanceof Wa ? {
7119
7108
  kind: "insufficient",
7120
7109
  obtained: e.obtained,
7121
7110
  required: e.required
@@ -7131,26 +7120,26 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7131
7120
  kind: "transport-failure",
7132
7121
  retryable: !1,
7133
7122
  error: e instanceof Error ? e : Error(String(e))
7134
- }, hs = async (e, t, n, r) => {
7123
+ }, _s = async (e, t, n, r) => {
7135
7124
  if (e.status !== 401 && e.status !== 403) return {
7136
7125
  kind: "replayed",
7137
7126
  response: e
7138
7127
  };
7139
- let { challenge: i, diagnostics: a } = await ds(e, t);
7140
- if (ls(a, e, t), !i) return {
7128
+ let { challenge: i, diagnostics: a } = await ps(e, t);
7129
+ if (ds(a, e, t), !i) return {
7141
7130
  kind: "replayed",
7142
7131
  response: e
7143
7132
  };
7144
- if (Ho(i)) return {
7133
+ if (Wo(i)) return {
7145
7134
  kind: "sign-in-required",
7146
7135
  response: e
7147
7136
  };
7148
- if (Uo(i)) return {
7137
+ if (Go(i)) return {
7149
7138
  kind: "unsatisfiable",
7150
- error: Go(i),
7139
+ error: qo(i),
7151
7140
  response: e
7152
7141
  };
7153
- let o = Xo(i);
7142
+ let o = Qo(i);
7154
7143
  return r("elevated-insufficient", {
7155
7144
  obtained: n,
7156
7145
  required: o
@@ -7160,7 +7149,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7160
7149
  required: o,
7161
7150
  response: e
7162
7151
  };
7163
- }, gs = async (e, t) => {
7152
+ }, vs = async (e, t) => {
7164
7153
  if (!t) return {
7165
7154
  aborted: !1,
7166
7155
  value: await e
@@ -7187,14 +7176,14 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7187
7176
  } finally {
7188
7177
  n && t.removeEventListener?.("abort", n);
7189
7178
  }
7190
- }, _s = async (e, t) => {
7179
+ }, ys = async (e, t) => {
7191
7180
  if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
7192
- let n = cs(e, t);
7181
+ let n = us(e, t);
7193
7182
  if (e.markers.replayed) {
7194
- if (!os(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
7195
- let { challenge: r, diagnostics: i } = await ds(e, t);
7196
- if (ls(i, e, t), !r) return { kind: "not-a-challenge" };
7197
- let a = t.readObtainedBar?.() ?? {}, o = Xo(r);
7183
+ if (!cs(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
7184
+ let { challenge: r, diagnostics: i } = await ps(e, t);
7185
+ if (ds(i, e, t), !r) return { kind: "not-a-challenge" };
7186
+ let a = t.readObtainedBar?.() ?? {}, o = Qo(r);
7198
7187
  return n("elevated-insufficient", {
7199
7188
  obtained: a,
7200
7189
  required: o
@@ -7205,12 +7194,12 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7205
7194
  response: e
7206
7195
  };
7207
7196
  }
7208
- if (!os(e.request, t.scope, t.shouldIntercept)) return fs(e) ? (n("challenge-out-of-scope", {
7197
+ if (!cs(e.request, t.scope, t.shouldIntercept)) return ms(e) ? (n("challenge-out-of-scope", {
7209
7198
  header: e.getHeader("www-authenticate") ?? void 0,
7210
- message: ps(e.request.href, t.scope)
7199
+ message: hs(e.request.href, t.scope)
7211
7200
  }), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
7212
- let { challenge: r, diagnostics: i } = await ds(e, t);
7213
- if (ls(i, e, t), !r) {
7201
+ let { challenge: r, diagnostics: i } = await ps(e, t);
7202
+ if (ds(i, e, t), !r) {
7214
7203
  let r = e.getHeader("www-authenticate");
7215
7204
  return t.requireChallengeChannel !== "header" && n("no-channel", {
7216
7205
  ...r ? { header: r } : {},
@@ -7224,9 +7213,9 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7224
7213
  method: e.request.method
7225
7214
  }, s, c;
7226
7215
  try {
7227
- s = Promise.resolve(t.elevate(r, o)), c = await gs(s, e.signal);
7216
+ s = Promise.resolve(t.elevate(r, o)), c = await vs(s, e.signal);
7228
7217
  } catch (e) {
7229
- return ms(e, void 0);
7218
+ return gs(e, void 0);
7230
7219
  }
7231
7220
  if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
7232
7221
  kind: "aborted",
@@ -7237,7 +7226,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7237
7226
  kind: "aborted",
7238
7227
  reason: e.signal.reason
7239
7228
  };
7240
- let u = l?.obtained ?? t.readObtainedBar?.() ?? Xo(r), d = t.authorizationSwap?.(), f = d ? {
7229
+ let u = l?.obtained ?? t.readObtainedBar?.() ?? Qo(r), d = t.authorizationSwap?.(), f = d ? {
7241
7230
  from: a?.from ?? d.from,
7242
7231
  to: d.to
7243
7232
  } : void 0;
@@ -7246,7 +7235,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7246
7235
  try {
7247
7236
  p = await e.replay(f ? { authorizationSwap: f } : void 0);
7248
7237
  } catch (t) {
7249
- if (t instanceof Ha) return l?.waiter.report({
7238
+ if (t instanceof Wa) return l?.waiter.report({
7250
7239
  outcome: "insufficient",
7251
7240
  obtained: t.obtained,
7252
7241
  required: t.required
@@ -7264,7 +7253,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7264
7253
  };
7265
7254
  throw t;
7266
7255
  }
7267
- let m = await hs(p, t, u, n);
7256
+ let m = await _s(p, t, u, n);
7268
7257
  return m.kind === "insufficient" ? l?.waiter.report({
7269
7258
  outcome: "insufficient",
7270
7259
  obtained: m.obtained,
@@ -7273,19 +7262,19 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7273
7262
  outcome: "replayed",
7274
7263
  obtained: u
7275
7264
  }), m;
7276
- }, vs = (e) => {
7265
+ }, bs = (e) => {
7277
7266
  switch (e.kind) {
7278
- case "cancelled": return new Bo();
7279
- case "unsatisfiable": return e.error ?? new Ko();
7280
- case "sign-in-required": return new Vo();
7281
- case "unavailable": return new Ua();
7282
- case "session-changed": return new Wa();
7283
- case "insufficient": return new Ha(e.obtained, e.required);
7267
+ case "cancelled": return new Ho();
7268
+ case "unsatisfiable": return e.error ?? new Jo();
7269
+ case "sign-in-required": return new Uo();
7270
+ case "unavailable": return new Ga();
7271
+ case "session-changed": return new Ka();
7272
+ case "insufficient": return new Wa(e.obtained, e.required);
7284
7273
  case "exhausted": return e.error;
7285
7274
  case "transport-failure": return e.error;
7286
7275
  default: return;
7287
7276
  }
7288
- }, ys = (e, t, n) => {
7277
+ }, xs = (e, t, n) => {
7289
7278
  switch (e.kind) {
7290
7279
  case "replayed": return {
7291
7280
  settle: "resolve",
@@ -7303,26 +7292,26 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7303
7292
  };
7304
7293
  case "cancelled": return n.onCancel === "reject" ? {
7305
7294
  settle: "reject",
7306
- error: new Bo()
7295
+ error: new Ho()
7307
7296
  } : {
7308
7297
  settle: "resolve",
7309
- value: ks(t, e)
7298
+ value: js(t, e)
7310
7299
  };
7311
7300
  case "unsatisfiable":
7312
7301
  case "sign-in-required": return {
7313
7302
  settle: "resolve",
7314
- value: ks(e.response?.raw ?? t, e)
7303
+ value: js(e.response?.raw ?? t, e)
7315
7304
  };
7316
7305
  case "insufficient": return {
7317
7306
  settle: "resolve",
7318
- value: ks(e.response?.raw ?? t, e)
7307
+ value: js(e.response?.raw ?? t, e)
7319
7308
  };
7320
7309
  default: return {
7321
7310
  settle: "resolve",
7322
- value: ks(t, e)
7311
+ value: js(t, e)
7323
7312
  };
7324
7313
  }
7325
- }, bs = (e, t) => {
7314
+ }, Ss = (e, t) => {
7326
7315
  switch (e.kind) {
7327
7316
  case "replayed": return e.response.rejected ? {
7328
7317
  settle: "reject",
@@ -7337,42 +7326,42 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7337
7326
  };
7338
7327
  default: return {
7339
7328
  settle: "reject",
7340
- error: vs(e) ?? t
7329
+ error: bs(e) ?? t
7341
7330
  };
7342
7331
  }
7343
- }, xs = /* @__PURE__ */ new WeakSet(), Ss = /* @__PURE__ */ new WeakSet(), Cs = /* @__PURE__ */ new WeakSet(), ws = /* @__PURE__ */ new WeakSet(), Ts = /* @__PURE__ */ new WeakSet(), Es = /* @__PURE__ */ new WeakSet(), Ds = /* @__PURE__ */ new WeakSet(), Os = /* @__PURE__ */ new WeakSet(), ks = (e, t) => {
7332
+ }, Cs = /* @__PURE__ */ new WeakSet(), ws = /* @__PURE__ */ new WeakSet(), Ts = /* @__PURE__ */ new WeakSet(), Es = /* @__PURE__ */ new WeakSet(), Ds = /* @__PURE__ */ new WeakSet(), Os = /* @__PURE__ */ new WeakSet(), ks = /* @__PURE__ */ new WeakSet(), As = /* @__PURE__ */ new WeakSet(), js = (e, t) => {
7344
7333
  switch (t.kind) {
7345
7334
  case "cancelled":
7346
- xs.add(e);
7335
+ Cs.add(e);
7347
7336
  break;
7348
7337
  case "exhausted":
7349
- Ss.add(e);
7338
+ ws.add(e);
7350
7339
  break;
7351
7340
  case "insufficient":
7352
- Cs.add(e);
7341
+ Ts.add(e);
7353
7342
  break;
7354
7343
  case "unsatisfiable":
7355
- ws.add(e);
7344
+ Es.add(e);
7356
7345
  break;
7357
7346
  case "sign-in-required":
7358
- Ts.add(e);
7347
+ Ds.add(e);
7359
7348
  break;
7360
7349
  case "unavailable":
7361
- Es.add(e);
7350
+ Os.add(e);
7362
7351
  break;
7363
7352
  case "session-changed":
7364
- Ds.add(e);
7353
+ ks.add(e);
7365
7354
  break;
7366
- case "transport-failure": Os.add(e);
7355
+ case "transport-failure": As.add(e);
7367
7356
  }
7368
7357
  return e;
7369
- }, As = (e) => xs.has(e), js = (e) => Ss.has(e), Ms = (e) => Cs.has(e), Ns = (e) => ws.has(e), Ps = (e) => Ts.has(e), Fs = (e) => Es.has(e), Is = (e) => Ds.has(e), Ls = (e) => Os.has(e), Rs = "https://passflow-relative.invalid", zs = () => {
7358
+ }, Ms = (e) => Cs.has(e), Ns = (e) => ws.has(e), Ps = (e) => Ts.has(e), Fs = (e) => Es.has(e), Is = (e) => Ds.has(e), Ls = (e) => Os.has(e), Rs = (e) => ks.has(e), zs = (e) => As.has(e), Bs = "https://passflow-relative.invalid", Vs = () => {
7370
7359
  let e = globalThis, t = e.document?.baseURI;
7371
7360
  if (typeof t == "string" && t !== "") return t;
7372
7361
  let n = e.location?.href;
7373
- return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Rs;
7374
- }, Bs = (e, t = zs()) => {
7375
- let n = t === Rs, r;
7362
+ return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Bs;
7363
+ }, Hs = (e, t = Vs()) => {
7364
+ let n = t === Bs, r;
7376
7365
  try {
7377
7366
  r = new URL(t).origin;
7378
7367
  } catch {
@@ -7398,28 +7387,28 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7398
7387
  relativeToBase: !1,
7399
7388
  sentinelBase: n
7400
7389
  };
7401
- }, Vs = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Hs = (e) => {
7390
+ }, Us = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Ws = (e) => {
7402
7391
  let t = [];
7403
7392
  if (e == null) return Object.freeze(t);
7404
7393
  let n = e;
7405
7394
  if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
7406
- let r = Vs(n, e);
7395
+ let r = Us(n, e);
7407
7396
  r && t.push(r);
7408
7397
  }), Object.freeze(t);
7409
7398
  if (Array.isArray(e)) {
7410
7399
  for (let n of e) if (Array.isArray(n) && n.length >= 2) {
7411
- let e = Vs(String(n[0]), n[1]);
7400
+ let e = Us(String(n[0]), n[1]);
7412
7401
  e && t.push(e);
7413
7402
  }
7414
7403
  return Object.freeze(t);
7415
7404
  }
7416
7405
  if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
7417
- let e = Vs(n, Array.isArray(r) ? r.join(", ") : r);
7406
+ let e = Us(n, Array.isArray(r) ? r.join(", ") : r);
7418
7407
  e && t.push(e);
7419
7408
  }
7420
7409
  return Object.freeze(t);
7421
- }, Us = (e) => {
7422
- let t = e.base === void 0 ? Bs(e.url) : Bs(e.url, e.base), n = {
7410
+ }, Gs = (e) => {
7411
+ let t = e.base === void 0 ? Hs(e.url) : Hs(e.url, e.base), n = {
7423
7412
  raw: e.url,
7424
7413
  href: t.href,
7425
7414
  dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
@@ -7428,29 +7417,29 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7428
7417
  resolved: t.resolved,
7429
7418
  relativeToBase: t.relativeToBase,
7430
7419
  method: (e.method ?? "GET").toUpperCase(),
7431
- headers: Hs(e.headers),
7420
+ headers: Ws(e.headers),
7432
7421
  bodyKind: e.bodyKind,
7433
7422
  ..."body" in e ? { body: e.body } : {}
7434
7423
  };
7435
7424
  return Object.freeze(n);
7436
- }, Ws = (e, t) => {
7425
+ }, Ks = (e, t) => {
7437
7426
  if (!t || t.from === t.to) return e;
7438
7427
  let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
7439
7428
  return n ? Object.freeze(r) : e;
7440
- }, Gs = (e) => {
7429
+ }, qs = (e) => {
7441
7430
  let t = {};
7442
7431
  for (let [n, r] of e) t[n] = r;
7443
7432
  return t;
7444
- }, Ks = /* @__PURE__ */ new Set([
7433
+ }, Js = /* @__PURE__ */ new Set([
7445
7434
  "GET",
7446
7435
  "HEAD",
7447
7436
  "OPTIONS"
7448
- ]), qs = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, Js = (e) => typeof e == "string" ? e : qs(e) ? e.url : String(e), Ys = (e, t) => (t?.method ?? (qs(e) ? e.method : void 0) ?? "GET").toUpperCase(), Xs = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", Zs = (e) => {
7437
+ ]), Ys = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, Xs = (e) => typeof e == "string" ? e : Ys(e) ? e.url : String(e), Zs = (e, t) => (t?.method ?? (Ys(e) ? e.method : void 0) ?? "GET").toUpperCase(), Qs = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", $s = (e) => {
7449
7438
  if (typeof e == "string") return e.length;
7450
7439
  let t = e;
7451
7440
  if (typeof t?.size == "number") return t.size;
7452
7441
  if (typeof t?.byteLength == "number") return t.byteLength;
7453
- }, Qs = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? Ks.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), $s = (e, t, n, r, i) => ({
7442
+ }, ec = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? Js.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), tc = (e, t, n, r, i) => ({
7454
7443
  replayable: !1,
7455
7444
  bodyKind: e,
7456
7445
  reason: t,
@@ -7458,11 +7447,11 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7458
7447
  forwardInit: i,
7459
7448
  snapshot: r,
7460
7449
  replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
7461
- }), ec = (e, t) => Gs(Ws(e.headers, t?.authorizationSwap)), tc = (e) => {
7450
+ }), nc = (e, t) => qs(Ks(e.headers, t?.authorizationSwap)), rc = (e) => {
7462
7451
  if (!e || !("headers" in e)) return e;
7463
7452
  let { headers: t, ...n } = e;
7464
7453
  return n;
7465
- }, nc = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : qs(e) ? e.headers : void 0, rc = (e) => {
7454
+ }, ic = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : Ys(e) ? e.headers : void 0, ac = (e) => {
7466
7455
  if (e === null || typeof e == "string") return e;
7467
7456
  if (typeof FormData < "u" && e instanceof FormData) {
7468
7457
  let t = new FormData();
@@ -7470,18 +7459,18 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7470
7459
  return t;
7471
7460
  }
7472
7461
  return typeof URLSearchParams < "u" && e instanceof URLSearchParams ? new URLSearchParams(e) : e instanceof ArrayBuffer ? e.slice(0) : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength).slice() : e;
7473
- }, ic = (e, t, n) => new Request(e, { headers: ec(t, n) }), ac = (e, t, n) => {
7474
- let r = Js(e), i = Ys(e, t), a = nc(e, t), o = (e, t) => Us({
7462
+ }, oc = (e, t, n) => new Request(e, { headers: nc(t, n) }), sc = (e, t, n) => {
7463
+ let r = Xs(e), i = Zs(e, t), a = ic(e, t), o = (e, t) => Gs({
7475
7464
  url: r,
7476
7465
  method: i,
7477
7466
  headers: a,
7478
7467
  bodyKind: e,
7479
7468
  ...t === void 0 ? {} : { body: t }
7480
7469
  });
7481
- if (qs(e)) {
7470
+ if (Ys(e)) {
7482
7471
  if (e.body === null || e.body === void 0) {
7483
7472
  let a = o("none");
7484
- return Qs(n, {
7473
+ return ec(n, {
7485
7474
  url: r,
7486
7475
  method: i,
7487
7476
  bodyKind: "none"
@@ -7491,20 +7480,20 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7491
7480
  forwardInput: e,
7492
7481
  forwardInit: t,
7493
7482
  snapshot: a,
7494
- replay: (n, r) => n(ic(e, a, r), tc(t))
7495
- } : $s("none", "the replay policy refused this request", e, a, t);
7483
+ replay: (n, r) => n(oc(e, a, r), rc(t))
7484
+ } : tc("none", "the replay policy refused this request", e, a, t);
7496
7485
  }
7497
7486
  let a = o("request-clone");
7498
- if (!Qs(n, {
7487
+ if (!ec(n, {
7499
7488
  url: r,
7500
7489
  method: i,
7501
7490
  bodyKind: "request-clone"
7502
- })) return $s("request-clone", "the replay policy refused this request", e, a, t);
7491
+ })) return tc("request-clone", "the replay policy refused this request", e, a, t);
7503
7492
  let s;
7504
7493
  try {
7505
7494
  s = e.clone();
7506
7495
  } catch {
7507
- return $s("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
7496
+ return tc("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
7508
7497
  }
7509
7498
  return {
7510
7499
  replayable: !0,
@@ -7512,17 +7501,17 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7512
7501
  forwardInput: e,
7513
7502
  forwardInit: t,
7514
7503
  snapshot: a,
7515
- replay: (e, n) => e(ic(s, a, n), tc(t))
7504
+ replay: (e, n) => e(oc(s, a, n), rc(t))
7516
7505
  };
7517
7506
  }
7518
- let s = Xs(t?.body);
7519
- if (s === "one-shot") return $s("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
7520
- if (!Qs(n, {
7507
+ let s = Qs(t?.body);
7508
+ if (s === "one-shot") return tc("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
7509
+ if (!ec(n, {
7521
7510
  url: r,
7522
7511
  method: i,
7523
7512
  bodyKind: s
7524
- }, Zs(t?.body))) return $s(s, "the replay policy refused this request", e, o(s), t);
7525
- let c = t && "body" in t ? rc(t.body ?? null) : void 0, l = o(s, c);
7513
+ }, $s(t?.body))) return tc(s, "the replay policy refused this request", e, o(s), t);
7514
+ let c = t && "body" in t ? ac(t.body ?? null) : void 0, l = o(s, c);
7526
7515
  return {
7527
7516
  replayable: !0,
7528
7517
  bodyKind: s,
@@ -7530,21 +7519,21 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7530
7519
  forwardInit: t,
7531
7520
  snapshot: l,
7532
7521
  replay: (e, n) => e(l.dispatchUrl, {
7533
- ...tc(t),
7522
+ ...rc(t),
7534
7523
  ...c === void 0 ? {} : { body: c },
7535
- headers: ec(l, n),
7524
+ headers: nc(l, n),
7536
7525
  method: l.method
7537
7526
  })
7538
7527
  };
7539
- }, oc = (e) => typeof e == "object" && !!e, sc = (e) => (t) => {
7540
- if (!oc(e)) return;
7528
+ }, cc = (e) => typeof e == "object" && !!e, lc = (e) => (t) => {
7529
+ if (!cc(e)) return;
7541
7530
  let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
7542
7531
  return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
7543
- }, cc = (e) => {
7532
+ }, uc = (e) => {
7544
7533
  let t = e?.url ?? "", n = e?.baseURL;
7545
7534
  return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
7546
- }, lc = (e) => (e?.method ?? "GET").toUpperCase(), uc = (e) => e == null ? "none" : oc(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", dc = (e, t, n) => {
7547
- let r = Gs(Ws(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
7535
+ }, dc = (e) => (e?.method ?? "GET").toUpperCase(), fc = (e) => e == null ? "none" : cc(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", pc = (e, t, n) => {
7536
+ let r = qs(Ks(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
7548
7537
  return {
7549
7538
  ...e,
7550
7539
  ...i ? { baseURL: void 0 } : {},
@@ -7553,10 +7542,10 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7553
7542
  headers: r,
7554
7543
  ..."body" in t ? { data: t.body } : {}
7555
7544
  };
7556
- }, fc = (e, t, n, r, i, a) => {
7557
- let o = t ?? e?.config, s = uc(o?.data), c = a ?? Us({
7558
- url: cc(o),
7559
- method: lc(o),
7545
+ }, mc = (e, t, n, r, i, a) => {
7546
+ let o = t ?? e?.config, s = fc(o?.data), c = a ?? Gs({
7547
+ url: uc(o),
7548
+ method: dc(o),
7560
7549
  headers: o?.headers,
7561
7550
  bodyKind: s,
7562
7551
  body: o?.data
@@ -7564,59 +7553,59 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7564
7553
  url: c.href,
7565
7554
  method: c.method,
7566
7555
  bodyKind: s
7567
- }, u = s !== "one-shot" && Qs(i.replay, l);
7556
+ }, u = s !== "one-shot" && ec(i.replay, l);
7568
7557
  return {
7569
7558
  status: e?.status ?? 0,
7570
- getHeader: sc(e?.headers),
7559
+ getHeader: lc(e?.headers),
7571
7560
  readBody: async () => e?.data,
7572
7561
  request: c,
7573
7562
  replay: async (e) => {
7574
- let t = Je(dc(o ?? {}, c, e));
7563
+ let t = Xe(pc(o ?? {}, c, e));
7575
7564
  try {
7576
7565
  let e = await r(t);
7577
- return fc(e, e?.config ?? t, e, r, i, c);
7566
+ return mc(e, e?.config ?? t, e, r, i, c);
7578
7567
  } catch (e) {
7579
- let n = oc(e) ? e : {};
7580
- if (!n.response || typeof n.response.status != "number" || Ma(e)) throw e;
7568
+ let n = cc(e) ? e : {};
7569
+ if (!n.response || typeof n.response.status != "number" || Pa(e)) throw e;
7581
7570
  return {
7582
- ...fc(n.response, n.config ?? t, e, r, i, c),
7571
+ ...mc(n.response, n.config ?? t, e, r, i, c),
7583
7572
  rejected: !0
7584
7573
  };
7585
7574
  }
7586
7575
  },
7587
7576
  markers: {
7588
- ...qe(o) ? { upgradeTransaction: !0 } : {},
7589
- ...Ye(o) ? { replayed: !0 } : {}
7577
+ ...Ye(o) ? { upgradeTransaction: !0 } : {},
7578
+ ...Ze(o) ? { replayed: !0 } : {}
7590
7579
  },
7591
7580
  raw: n,
7592
7581
  replayable: u,
7593
7582
  replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
7594
7583
  signal: o?.signal
7595
7584
  };
7596
- }, pc = (e, t) => async (n) => {
7597
- let r = ts(e), i = oc(n) ? n : {}, a = bs(await _s(fc(i.response, i.config, i.response, t, r), r), n);
7585
+ }, hc = (e, t) => async (n) => {
7586
+ let r = rs(e), i = cc(n) ? n : {}, a = Ss(await ys(mc(i.response, i.config, i.response, t, r), r), n);
7598
7587
  if (a.settle === "reject") throw a.error;
7599
7588
  return a.value;
7600
- }, mc = (e, t, n) => {
7601
- let r = e.request, i = n ?? (typeof r == "function" ? (t) => r.call(e, t) : () => Promise.reject(/* @__PURE__ */ Error("Passflow: this client exposes no request() to replay through."))), a = e.interceptors.response.use(void 0, pc(t, i)), o = !1;
7589
+ }, gc = (e, t, n) => {
7590
+ let r = e.request, i = n ?? (typeof r == "function" ? (t) => r.call(e, t) : () => Promise.reject(/* @__PURE__ */ Error("Passflow: this client exposes no request() to replay through."))), a = e.interceptors.response.use(void 0, hc(t, i)), o = !1;
7602
7591
  return () => {
7603
7592
  o || (o = !0, e.interceptors.response.eject(a));
7604
7593
  };
7605
- }, hc = (t, n) => {
7594
+ }, _c = (t, n) => {
7606
7595
  let r = e.create(t);
7607
7596
  return n(r), r;
7608
- }, gc = () => {
7597
+ }, vc = () => {
7609
7598
  let e = typeof location > "u" ? void 0 : location.origin;
7610
7599
  return e && e !== "null" ? e : void 0;
7611
- }, _c = (e) => {
7600
+ }, yc = (e) => {
7612
7601
  let t = new URL(e).origin;
7613
7602
  if (t === "null") throw Error(`Passflow: "${e}" has no origin a request can be matched against; list http(s) origins only.`);
7614
7603
  return t;
7615
- }, vc = (e, t) => {
7616
- let n = (t?.origins ?? []).map(_c);
7604
+ }, bc = (e, t) => {
7605
+ let n = (t?.origins ?? []).map(yc);
7617
7606
  return (t, r) => {
7618
7607
  if (r) return Promise.resolve(void 0);
7619
- let i = gc(), a;
7608
+ let i = vc(), a;
7620
7609
  try {
7621
7610
  a = new URL(t, i).origin;
7622
7611
  } catch {
@@ -7624,22 +7613,22 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7624
7613
  }
7625
7614
  return a !== i && !n.includes(a) ? Promise.resolve(void 0) : e();
7626
7615
  };
7627
- }, yc = (e) => typeof Request < "u" && e instanceof Request, bc = (e, t) => new Headers(t?.headers === void 0 ? yc(e) ? e.headers : void 0 : t.headers), xc = (e, t, n) => {
7628
- let r = vc(t, n);
7616
+ }, xc = (e) => typeof Request < "u" && e instanceof Request, Sc = (e, t) => new Headers(t?.headers === void 0 ? xc(e) ? e.headers : void 0 : t.headers), Cc = (e, t, n) => {
7617
+ let r = bc(t, n);
7629
7618
  return async (t, n) => {
7630
- let i = yc(t) ? t.url : t instanceof URL ? t.href : String(t), a = bc(t, n), o = await r(i, a.has("authorization"));
7619
+ let i = xc(t) ? t.url : t instanceof URL ? t.href : String(t), a = Sc(t, n), o = await r(i, a.has("authorization"));
7631
7620
  return o ? (a.set("authorization", `Bearer ${o}`), e(t, {
7632
7621
  ...n,
7633
7622
  headers: a
7634
7623
  })) : e(t, n);
7635
7624
  };
7636
- }, Sc = (e) => {
7625
+ }, wc = (e) => {
7637
7626
  let t = e.url ?? "", n = /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
7638
7627
  return !e.baseURL || n && e.allowAbsoluteUrls !== !1 ? t : t ? `${e.baseURL.replace(/\/?\/$/, "")}/${t.replace(/^\/+/, "")}` : e.baseURL;
7639
- }, Cc = (e) => e ? typeof e.has == "function" ? e.has("Authorization") : Object.keys(e).some((t) => t.toLowerCase() === "authorization" && e[t] != null) : !1, wc = (e, t) => {
7640
- let n = vc(e, t);
7628
+ }, Tc = (e) => e ? typeof e.has == "function" ? e.has("Authorization") : Object.keys(e).some((t) => t.toLowerCase() === "authorization" && e[t] != null) : !1, Ec = (e, t) => {
7629
+ let n = bc(e, t);
7641
7630
  return async (e) => {
7642
- let t = e.headers, r = await n(Sc(e), Cc(t));
7631
+ let t = e.headers, r = await n(wc(e), Tc(t));
7643
7632
  if (!r) return e;
7644
7633
  let i = `Bearer ${r}`;
7645
7634
  return t && typeof t.set == "function" ? t.set("Authorization", i) : e.headers = {
@@ -7647,7 +7636,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7647
7636
  Authorization: i
7648
7637
  }, e;
7649
7638
  };
7650
- }, Tc = 0, Ec = (e, t) => {
7639
+ }, Dc = 0, Oc = (e, t) => {
7651
7640
  let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
7652
7641
  if (n) return {
7653
7642
  get aborted() {
@@ -7661,34 +7650,34 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7661
7650
  removeEventListener: (e, t) => n.removeEventListener(e, t)
7662
7651
  } : {}
7663
7652
  };
7664
- }, Dc = (e) => (t) => e.headers?.get(t), Oc = (e, t, n, r, i) => ({
7653
+ }, kc = (e) => (t) => e.headers?.get(t), Ac = (e, t, n, r, i) => ({
7665
7654
  status: e.status,
7666
- getHeader: Dc(e),
7655
+ getHeader: kc(e),
7667
7656
  readBody: () => e.clone().json(),
7668
7657
  request: t.snapshot,
7669
- replay: async (e) => Oc(await t.replay(n, e), t, n, r, i),
7658
+ replay: async (e) => Ac(await t.replay(n, e), t, n, r, i),
7670
7659
  markers: r,
7671
7660
  raw: e,
7672
7661
  replayable: t.replayable,
7673
7662
  replayUnsupportedReason: t.reason,
7674
7663
  signal: i,
7675
7664
  responseType: e.type
7676
- }), kc = (e, t) => {
7665
+ }), jc = (e, t) => {
7677
7666
  let n = (t, n) => {
7678
- Tc += 1;
7667
+ Dc += 1;
7679
7668
  try {
7680
7669
  return e(t, n);
7681
7670
  } finally {
7682
- --Tc;
7671
+ --Dc;
7683
7672
  }
7684
7673
  };
7685
7674
  return async (e, r) => {
7686
- if (Tc > 0) return n(e, r);
7687
- let i = ts(t), a = ac(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = ys(await _s(Oc(o, a, n, {}, Ec(e, r)), i), o, i);
7675
+ if (Dc > 0) return n(e, r);
7676
+ let i = rs(t), a = sc(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = xs(await ys(Ac(o, a, n, {}, Oc(e, r)), i), o, i);
7688
7677
  if (s.settle === "reject") throw s.error;
7689
7678
  return s.value;
7690
7679
  };
7691
- }, Ac = new Set(No.filter((e) => !e.requiresPrepare).map((e) => e.type)), jc = (e) => {
7680
+ }, Mc = new Set(Fo.filter((e) => !e.requiresPrepare).map((e) => e.type)), Nc = (e) => {
7692
7681
  if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
7693
7682
  kind: "protocol",
7694
7683
  message: "The upgrade start response is missing challenge_id or expires_at"
@@ -7700,17 +7689,17 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7700
7689
  webauthn: e.webauthn,
7701
7690
  codeSentTo: e.code_sent_to
7702
7691
  };
7703
- }, Mc = (e) => Ma(e) && !Na(e), Nc = (e) => ({
7692
+ }, Pc = (e) => Pa(e) && !Fa(e), Fc = (e) => ({
7704
7693
  async prepare(t) {
7705
- if (!Ac.has(t)) try {
7694
+ if (!Mc.has(t)) try {
7706
7695
  let n = e.relyingPartyId?.();
7707
- return jc(await e.startUpgrade(n ? {
7696
+ return Nc(await e.startUpgrade(n ? {
7708
7697
  method: t,
7709
7698
  relying_party_id: n
7710
7699
  } : { method: t }));
7711
7700
  } catch (e) {
7712
- if (Mc(e)) throw e;
7713
- let t = za(e, "start");
7701
+ if (Pc(e)) throw e;
7702
+ let t = Va(e, "start");
7714
7703
  if (t.kind === "prepare_not_required") return;
7715
7704
  throw t;
7716
7705
  }
@@ -7727,17 +7716,17 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7727
7716
  assertion: n
7728
7717
  });
7729
7718
  } catch (t) {
7730
- if (Mc(t)) throw t;
7731
- let n = za(t, "refresh");
7732
- throw n.status === 401 && Va(n) && e.markSessionInvalid?.(), n;
7719
+ if (Pc(t)) throw t;
7720
+ let n = Va(t, "refresh");
7721
+ throw n.status === 401 && Ua(n) && e.markSessionInvalid?.(), n;
7733
7722
  }
7734
7723
  }
7735
- }), Pc = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Fc = (e) => {
7724
+ }), Ic = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Lc = (e) => {
7736
7725
  let t, n = (e) => e !== void 0 && t === e, r = (r) => {
7737
7726
  let i = () => {
7738
7727
  if (!n(r())) throw new $({ kind: "session_changed" });
7739
7728
  };
7740
- return Nc({
7729
+ return Fc({
7741
7730
  ...e,
7742
7731
  relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
7743
7732
  startUpgrade: (t) => (i(), e.startUpgrade(t)),
@@ -7748,7 +7737,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7748
7737
  });
7749
7738
  }, i = (t, n) => {
7750
7739
  let i = {}, a = {
7751
- controller: new es({
7740
+ controller: new ns({
7752
7741
  transport: r(() => i.current),
7753
7742
  prompt: t.prompt,
7754
7743
  platform: e.platform,
@@ -7760,7 +7749,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7760
7749
  options: t,
7761
7750
  scope: {
7762
7751
  passflow: e.passflowDomain,
7763
- backend: Pc(t.backend)
7752
+ backend: Ic(t.backend)
7764
7753
  },
7765
7754
  generation: n
7766
7755
  };
@@ -7770,17 +7759,17 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7770
7759
  s = void 0;
7771
7760
  });
7772
7761
  let c = (e) => {
7773
- if (!s || $o(s.challenge, e)) return;
7762
+ if (!s || ts(s.challenge, e)) return;
7774
7763
  let t = Math.min(o, e.maxAge === void 0 ? o : e.maxAge * 1e3);
7775
7764
  if (!(Date.now() - s.at > t)) return s.challenge;
7776
7765
  }, l = async (r, i) => {
7777
7766
  let o = t;
7778
- if (!o) throw new Ua("Step-up verification is not enabled on this Passflow instance");
7767
+ if (!o) throw new Ga("Step-up verification is not enabled on this Passflow instance");
7779
7768
  let l = e.stopRepeatedElevation ? c(r) : void 0;
7780
- if (l) throw new Ha(Xo(l), Xo(r), "This requirement was already proved and the server still refused it: sign the user in again");
7769
+ if (l) throw new Wa(Qo(l), Qo(r), "This requirement was already proved and the server still refused it: sign the user in again");
7781
7770
  o.controller.active || (o.pin = e.readSessionPin?.());
7782
7771
  let u = await o.controller.elevate(r, i);
7783
- if (!n(o)) throw new Wa();
7772
+ if (!n(o)) throw new Ka();
7784
7773
  return e.stopRepeatedElevation && (s = {
7785
7774
  challenge: r,
7786
7775
  at: a ?? Date.now()
@@ -7803,7 +7792,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7803
7792
  };
7804
7793
  }, d;
7805
7794
  return Object.defineProperties(async (e) => {
7806
- let t = e?.acrValues === void 0 ? void 0 : Oe(e.acrValues).level, n = {
7795
+ let t = e?.acrValues === void 0 ? void 0 : Ae(e.acrValues).level, n = {
7807
7796
  status: 401,
7808
7797
  ...e?.acrValues === void 0 ? {} : { acrValues: e.acrValues },
7809
7798
  ...t === void 0 ? {} : { requiredLevel: t },
@@ -7827,9 +7816,9 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7827
7816
  let r = [];
7828
7817
  if (e.attachInternalSeam) {
7829
7818
  let t = e.attachInternalSeam;
7830
- t((e) => pc(u, e)), r.push(() => t(void 0));
7819
+ t((e) => hc(u, e)), r.push(() => t(void 0));
7831
7820
  }
7832
- n.interceptFetch && r.push(cr((e, t, n) => kc(e, u)(t, n), {
7821
+ n.interceptFetch && r.push(ur((e, t, n) => jc(e, u)(t, n), {
7833
7822
  priority: 20,
7834
7823
  name: "passflow-upgrade"
7835
7824
  })), e.onSessionChange && r.push(e.onSessionChange(() => {
@@ -7861,8 +7850,8 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7861
7850
  enumerable: !0,
7862
7851
  value: (t, n) => {
7863
7852
  let r = (t) => {
7864
- let r = kc(t, u);
7865
- return e.readAccessToken ? xc(r, e.readAccessToken, n) : r;
7853
+ let r = jc(t, u);
7854
+ return e.readAccessToken ? Cc(r, e.readAccessToken, n) : r;
7866
7855
  };
7867
7856
  if (t) return r(t);
7868
7857
  let i = typeof globalThis > "u" ? void 0 : globalThis;
@@ -7873,14 +7862,14 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7873
7862
  attachAuth: {
7874
7863
  enumerable: !0,
7875
7864
  value: (t, n) => {
7876
- let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(wc(e.readAccessToken, n)), a = mc(t, u);
7865
+ let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(Ec(e.readAccessToken, n)), a = gc(t, u);
7877
7866
  return () => {
7878
7867
  a(), r && i !== void 0 && r.eject(i);
7879
7868
  };
7880
7869
  }
7881
7870
  }
7882
7871
  });
7883
- }, Ic, Lc = class {
7872
+ }, Rc, zc = class {
7884
7873
  get origin() {
7885
7874
  return this.platform.getCurrentUrl()?.origin ?? "";
7886
7875
  }
@@ -7889,18 +7878,18 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7889
7878
  this.createSessionCallback = e, this.expiredSessionCallback = t, this.doRefreshTokens = n, await this.submitSessionCheck();
7890
7879
  };
7891
7880
  let { url: t, appId: n, scopes: r } = e;
7892
- this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? we, this.deferFederatedLanding = e.deferFederatedLanding ?? !1, this.storageManager = new me({
7881
+ this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? Ee, this.deferFederatedLanding = e.deferFederatedLanding ?? !1, this.storageManager = new me({
7893
7882
  prefix: e.keyStoragePrefix ?? "",
7894
7883
  storage: this.platform.storage,
7895
7884
  appId: n
7896
- }), this.deviceService = new he(this.storageManager), this.authApi = new gn(e, this.storageManager, this.deviceService), this.appApi = new ln(e, this.storageManager, this.deviceService), this.userApi = new Dn(e, this.storageManager, this.deviceService), this.settingApi = new yn(e, this.storageManager, this.deviceService), this.tenantApi = new bn(e, this.storageManager, this.deviceService), this.invitationApi = new vn(e, this.storageManager, this.deviceService), this.twoFactorApi = new Tn(e, this.storageManager, this.deviceService), this.upgradeApi = new En(e, this.storageManager, this.deviceService), this.upgradeDomain = Qe(e.url), this.subscribeStore = new Ur(), this.tokenCacheService = new To(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? x, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
7897
- let i = Vi(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
7898
- this.deviceKeyService = e.deviceKey === !0 && !e.tokenExchange?.enabled ? Kn({
7899
- dbName: Un(e.keyStoragePrefix),
7885
+ }), this.deviceService = new he(this.storageManager), this.authApi = new vn(e, this.storageManager, this.deviceService), this.appApi = new dn(e, this.storageManager, this.deviceService), this.userApi = new kn(e, this.storageManager, this.deviceService), this.settingApi = new xn(e, this.storageManager, this.deviceService), this.tenantApi = new Sn(e, this.storageManager, this.deviceService), this.invitationApi = new bn(e, this.storageManager, this.deviceService), this.twoFactorApi = new Dn(e, this.storageManager, this.deviceService), this.upgradeApi = new On(e, this.storageManager, this.deviceService), this.upgradeDomain = et(e.url), this.subscribeStore = new Gr(), this.tokenCacheService = new Do(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? x, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
7886
+ let i = Ui(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
7887
+ this.deviceKeyService = e.deviceKey === !0 && !e.tokenExchange?.enabled ? Jn({
7888
+ dbName: Gn(e.keyStoragePrefix),
7900
7889
  deviceId: () => this.deviceService.getDeviceId()
7901
7890
  }) : void 0;
7902
7891
  let a = this.deviceKeyService;
7903
- this.authService = new bo(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
7892
+ this.authService = new So(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
7904
7893
  createSession: async (e) => {
7905
7894
  await this.createSessionCallback?.(e);
7906
7895
  },
@@ -7914,7 +7903,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7914
7903
  deviceKey: a,
7915
7904
  enrolDeviceKeyRequest: (e) => this.userApi.enrolDeviceKey(e)
7916
7905
  } : {}
7917
- }, () => this.readAppSettings()), this.antiBot = ai({
7906
+ }, () => this.readAppSettings()), this.antiBot = si({
7918
7907
  readSettings: () => this.readAppSettings(),
7919
7908
  fetchChallenge: ({ identifier: e, device: t }) => t ? this.authApi.deviceAntiBotChallenge({
7920
7909
  user_code: t.userCode,
@@ -7922,9 +7911,9 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7922
7911
  }, t.csrfToken) : this.authApi.antiBotChallenge(e ? { identifier: e } : {}),
7923
7912
  store: this.subscribeStore,
7924
7913
  ...e.antiBotWorkerUrl ? { workerUrl: e.antiBotWorkerUrl } : {}
7925
- }), this.authApi.setAntiBotHandler((e) => this.antiBot.headerFor(e)), this.riskIds = li({ readSettings: () => this.readAppSettings() }), this.authApi.setRiskIdHandler((e) => this.riskIds.headersFor(e)), this.tokenCacheService.attachRefreshController(this.authService.refresh);
7914
+ }), this.authApi.setAntiBotHandler((e) => this.antiBot.headerFor(e)), this.riskIds = di({ readSettings: () => this.readAppSettings() }), this.authApi.setRiskIdHandler((e) => this.riskIds.headersFor(e)), this.tokenCacheService.attachRefreshController(this.authService.refresh);
7926
7915
  for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
7927
- this.userService = new Do(this.userApi, this.deviceService, this.platform), this.tenantService = new wo(this.tenantApi, this.scopes, void 0, () => this.storageManager.getToken(N.access_token)), this.tenant = this.tenantService, this.invitationService = new xo(this.invitationApi), this.twoFactorService = new Eo(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Fc({
7916
+ this.userService = new ko(this.userApi, this.deviceService, this.platform), this.tenantService = new Eo(this.tenantApi, this.scopes, void 0, () => this.storageManager.getToken(N.access_token)), this.tenant = this.tenantService, this.invitationService = new Co(this.invitationApi), this.twoFactorService = new Oo(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Lc({
7928
7917
  startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
7929
7918
  commitRefresh: async (e, t) => {
7930
7919
  await this.authService.refreshToken(e, t);
@@ -7953,7 +7942,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7953
7942
  let e = (await this.getTokens(!0))?.access_token;
7954
7943
  return e && !j(M(e)) ? e : void 0;
7955
7944
  }
7956
- }), this.hostedUpgrade = Fc({
7945
+ }), this.hostedUpgrade = Lc({
7957
7946
  startUpgrade: (e) => this.upgradeApi.startHostedUpgrade(e),
7958
7947
  commitRefresh: (e) => this.upgradeApi.commitHostedUpgrade(e),
7959
7948
  canCommit: () => ({ ok: !0 }),
@@ -7990,14 +7979,14 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
7990
7979
  return this.upgrade.attachAuth(e, t);
7991
7980
  }
7992
7981
  createClient(e, t) {
7993
- return hc(e, (e) => this.upgrade.attachAuth(e, t));
7982
+ return _c(e, (e) => this.upgrade.attachAuth(e, t));
7994
7983
  }
7995
7984
  readAssuranceBar() {
7996
7985
  let e = this.storageManager.getToken(N.access_token);
7997
7986
  if (e) try {
7998
7987
  let t = M(e), n = typeof t.acr == "string" ? t.acr : void 0;
7999
7988
  if (!n) return;
8000
- let r = Oe(n).level;
7989
+ let r = Ae(n).level;
8001
7990
  return r === void 0 ? { acrValues: n } : {
8002
7991
  acrValues: n,
8003
7992
  level: r
@@ -8073,7 +8062,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
8073
8062
  }
8074
8063
  let n = t.get("access_token"), r = t.get("refresh_token"), i = t.get("id_token"), a = t.get("state") ?? void 0, o = t.get("scopes")?.split(",") ?? this.scopes;
8075
8064
  if (n) {
8076
- if (!qa(n)) {
8065
+ if (!Ya(n)) {
8077
8066
  W(this.subscribeStore, {
8078
8067
  operation: "tokens.from-url",
8079
8068
  message: "Invalid access token format received",
@@ -8081,7 +8070,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
8081
8070
  }), this.cleanupUrlParams(e);
8082
8071
  return;
8083
8072
  }
8084
- if (r && !qa(r)) {
8073
+ if (r && !Ya(r)) {
8085
8074
  W(this.subscribeStore, {
8086
8075
  operation: "tokens.from-url",
8087
8076
  message: "Invalid refresh token format received",
@@ -8089,7 +8078,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
8089
8078
  }), this.cleanupUrlParams(e);
8090
8079
  return;
8091
8080
  }
8092
- if (i && !qa(i)) {
8081
+ if (i && !Ya(i)) {
8093
8082
  W(this.subscribeStore, {
8094
8083
  operation: "tokens.from-url",
8095
8084
  message: "Invalid ID token format received",
@@ -8104,8 +8093,8 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
8104
8093
  scopes: o
8105
8094
  };
8106
8095
  this.cleanupUrlParams(e), this.error = void 0, this.readAppSettings().catch(() => void 0).then((e) => {
8107
- if (e?.pkce_enabled !== !1) throw kr();
8108
- return Ta(this.url, this.appId, t);
8096
+ if (e?.pkce_enabled !== !1) throw jr();
8097
+ return Da(this.url, this.appId, t);
8109
8098
  }).then(() => {
8110
8099
  this.storageManager.clearDeliveryMode(), this.storageManager.saveTokens(t, void 0, { replace: !0 }), e && this.storageManager.setHostedSignIn(e.origin + e.pathname), this.tokenCacheService.setTokensCache(t), this.authService.refresh.sessionStarted();
8111
8100
  }).then(() => (this.subscribeStore.notify(G.SignIn, {
@@ -8142,7 +8131,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
8142
8131
  let r = t.toString(), i = new URLSearchParams(e.search);
8143
8132
  i.delete("user_state");
8144
8133
  let a = i.toString();
8145
- return this.platform.replaceUrl(e.pathname + (a ? `?${a}` : "") + (r ? `#${r}` : "")), qa(n) ? (this.authService.handleFederatedTwoFactor(n), !0) : (W(this.subscribeStore, {
8134
+ return this.platform.replaceUrl(e.pathname + (a ? `?${a}` : "") + (r ? `#${r}` : "")), Ya(n) ? (this.authService.handleFederatedTwoFactor(n), !0) : (W(this.subscribeStore, {
8146
8135
  operation: "tokens.from-url",
8147
8136
  message: "Invalid 2FA token format received",
8148
8137
  code: "INVALID_TOKEN_FORMAT"
@@ -8151,7 +8140,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
8151
8140
  checkErrorsFromURL() {
8152
8141
  let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
8153
8142
  if (e) {
8154
- let t = Ja(e);
8143
+ let t = Xa(e);
8155
8144
  return Error(t);
8156
8145
  }
8157
8146
  }
@@ -8676,7 +8665,7 @@ var ho = 10, go = "The sign-in answered with a PKCE code, but its verifier is go
8676
8665
  this.twoFactorService.clearMagicLinkSession();
8677
8666
  }
8678
8667
  };
8679
- Ic = Lc, Ic.version = y;
8680
- export { vt as ADDRESS_CHANGE_PROOF_REQUIRED_ERROR_ID, m as AGENT_TOOL_HEADER_KEY, v as ANTI_BOT_ACTION, it as ANTI_BOT_FAILED_ERROR_ID, p as ANTI_BOT_HEADER_KEY, ct as ANTI_BOT_PROVIDER_FAILED_ERROR_ID, st as ANTI_BOT_PROVIDER_MISSING_ERROR_ID, rt as ANTI_BOT_REQUIRED_ERROR_ID, lt as ANTI_BOT_SOLVE_FAILED_ERROR_ID, ot as ANTI_BOT_UNAVAILABLE_ERROR_ID, l as APP_ID_HEADER_KEY, Tt as APP_SECRET_NAMES, u as AUTHORIZATION_HEADER_KEY, ln as AppAPI, gn as AuthAPI, bo as AuthService, _n as CLIAuthAPI, S as DEFAULT_GROUP_NAME, x as DEFAULT_SCOPES, No as DEFAULT_UPGRADE_FACTORS, d as DEVICE_ID_HEADER_KEY, h as DEVICE_PROOF_HEADER_KEY, f as DEVICE_TYPE_HEADER_KEY, qn as DeviceKeyErrorId, pt as ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID, ut as ENTERPRISE_EMAIL_INVALID_ERROR_ID, ft as ENTERPRISE_NO_CONNECTION_ERROR_ID, dt as ENTERPRISE_START_INPUT_ERROR_ID, re as ERROR_MESSAGE_MAX_LENGTH, Yn as FETCH_PRIORITY_OIDC, Xn as FETCH_PRIORITY_UPGRADE, g as FINGERPRINT_EVENT_HEADER_KEY, Zn as FetchMiddlewareContractError, Ae as INSUFFICIENT_USER_AUTHENTICATION, vn as InvitationAPI, xo as InvitationService, _r as M2MClient, fr as M2MConfigError, H as M2MError, pr as M2MErrorCodes, ur as M2MNetworkError, dr as M2MTokenParseError, mr as M2M_DEFAULTS, Et as MASKED_SECRET_PREFIX, b as MINIMAL_DEFAULT_SCOPES, L as NativeSignInError, kt as OS, ee as PASSFLOW_CLOUD_URL, nt as PASSWORD_CHANGE_REQUIRED_ERROR_ID, w as POPUP_HEIGHT, T as POPUP_POLL_INTERVAL_MS, E as POPUP_TIMEOUT_MS, C as POPUP_WIDTH, Lc as Passflow, Ct as PassflowAddressChangeProofRequiredError, Ze as PassflowAdminEndpointPaths, St as PassflowAntiBotChallengeError, R as PassflowEndpointPaths, z as PassflowError, G as PassflowEvent, U as PassflowOidcError, mt as PassflowPasswordChangeRequiredError, xt as PassflowRecoveryCodesStepUpRequiredError, Y as PassflowRefreshError, bt as PassflowSendLimitError, yt as PassflowSmsQuotaExceededError, ge as PopupClosedError, wt as Providers, Ea as RECOVERABLE_COMMIT_ERROR_IDS, _t as RECOVERY_CODES_STEP_UP_REQUIRED_ERROR_ID, Hi as REFRESH_AUTH_FAILURE_IDS, J as RefreshErrorId, Xe as RequestMethod, y as SDK_VERSION, et as SERVICE_UNAVAILABLE_ERROR_ID, tt as SERVICE_UNAVAILABLE_MESSAGE, Da as SESSION_INVALIDATING_COMMIT_ERROR_IDS, Dt as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, at as SIGN_IN_REFUSED_ERROR_ID, _ as STYTCH_TELEMETRY_HEADER_KEY, F as SessionState, yn as SettingAPI, te as TOKEN_EXPIRY_BUFFER_SECONDS, gt as TWO_FACTOR_SEND_LIMIT_ERROR_ID, ht as TWO_FACTOR_SMS_QUOTA_EXCEEDED_ERROR_ID, bn as TenantAPI, wo as TenantService, So as TenantUserMembership, To as TokenCacheService, P as TokenDeliveryMode, N as TokenType, Tn as TwoFactorApiClient, Mt as TwoFactorPolicy, Eo as TwoFactorService, je as UPGRADE_REQUIRED, D as USERNAME_MAX_LENGTH, ne as USERNAME_MIN_LENGTH, En as UpgradeAPI, Bo as UpgradeCancelledError, ta as UpgradeCommitInterruptedError, es as UpgradeController, Q as UpgradeErrorIds, Oo as UpgradeFactorError, Ha as UpgradeInsufficientError, Wa as UpgradeSessionChangedError, Vo as UpgradeSignInRequiredError, $ as UpgradeTransportError, Ua as UpgradeUnavailableError, Ko as UpgradeUnsatisfiableError, Dn as UserAPI, Do as UserService, Ce as WebAdapter, za as classifyUpgradeError, Po as factorRegistry, lr as fetchRegistryState, At as getOSFromDeviceType, Va as invalidatesSessionOnCommit, $e as isEmailVerificationStep, Ot as isMaskedSecret, Ba as isRecoverableCommitFailure, ka as isRetryableUpgradeKind, j as isTokenExpired, As as isUpgradeCancelled, js as isUpgradeExhausted, Ms as isUpgradeInsufficient, Is as isUpgradeSessionChanged, Ps as isUpgradeSignInRequired, Na as isUpgradeTransportError, Ls as isUpgradeTransportFailure, Fs as isUpgradeUnavailable, Ns as isUpgradeUnsatisfiable, Ya as isValidEmail, qa as isValidJWTFormat, Xa as isValidPhoneNumber, Za as isValidUsername, Re as parseChallengeBody, Le as parseChallengeHeader, M as parseToken, He as parseUpgradeChallenge, Mo as passkeyFactor, jt as pathWithParams, Pn as pushChallengeOf, jo as recoveryCodesFactor, cr as registerFetchMiddleware, ke as requiredAcrLevel, Qe as resolveUpgradeDomain, Ja as sanitizeErrorMessage, zo as selectFactors, Ao as totpFactor, we as webAdapter };
8668
+ Rc = zc, Rc.version = y;
8669
+ export { bt as ADDRESS_CHANGE_PROOF_REQUIRED_ERROR_ID, m as AGENT_TOOL_HEADER_KEY, v as ANTI_BOT_ACTION, ot as ANTI_BOT_FAILED_ERROR_ID, p as ANTI_BOT_HEADER_KEY, ut as ANTI_BOT_PROVIDER_FAILED_ERROR_ID, lt as ANTI_BOT_PROVIDER_MISSING_ERROR_ID, at as ANTI_BOT_REQUIRED_ERROR_ID, dt as ANTI_BOT_SOLVE_FAILED_ERROR_ID, ct as ANTI_BOT_UNAVAILABLE_ERROR_ID, l as APP_ID_HEADER_KEY, Dt as APP_SECRET_NAMES, u as AUTHORIZATION_HEADER_KEY, dn as AppAPI, vn as AuthAPI, So as AuthService, yn as CLIAuthAPI, S as DEFAULT_GROUP_NAME, x as DEFAULT_SCOPES, Fo as DEFAULT_UPGRADE_FACTORS, d as DEVICE_ID_HEADER_KEY, h as DEVICE_PROOF_HEADER_KEY, f as DEVICE_TYPE_HEADER_KEY, Yn as DeviceKeyErrorId, ht as ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID, ft as ENTERPRISE_EMAIL_INVALID_ERROR_ID, mt as ENTERPRISE_NO_CONNECTION_ERROR_ID, pt as ENTERPRISE_START_INPUT_ERROR_ID, re as ERROR_MESSAGE_MAX_LENGTH, Zn as FETCH_PRIORITY_OIDC, Qn as FETCH_PRIORITY_UPGRADE, g as FINGERPRINT_EVENT_HEADER_KEY, $n as FetchMiddlewareContractError, Me as INSUFFICIENT_USER_AUTHENTICATION, bn as InvitationAPI, Co as InvitationService, yr as M2MClient, mr as M2MConfigError, H as M2MError, hr as M2MErrorCodes, fr as M2MNetworkError, pr as M2MTokenParseError, gr as M2M_DEFAULTS, Ot as MASKED_SECRET_PREFIX, b as MINIMAL_DEFAULT_SCOPES, L as NativeSignInError, jt as OS, ee as PASSFLOW_CLOUD_URL, it as PASSWORD_CHANGE_REQUIRED_ERROR_ID, w as POPUP_HEIGHT, T as POPUP_POLL_INTERVAL_MS, E as POPUP_TIMEOUT_MS, C as POPUP_WIDTH, zc as Passflow, Tt as PassflowAddressChangeProofRequiredError, $e as PassflowAdminEndpointPaths, wt as PassflowAntiBotChallengeError, R as PassflowEndpointPaths, z as PassflowError, G as PassflowEvent, U as PassflowOidcError, gt as PassflowPasswordChangeRequiredError, Ct as PassflowRecoveryCodesStepUpRequiredError, Y as PassflowRefreshError, St as PassflowSendLimitError, xt as PassflowSmsQuotaExceededError, ge as PopupClosedError, Et as Providers, Oa as RECOVERABLE_COMMIT_ERROR_IDS, yt as RECOVERY_CODES_STEP_UP_REQUIRED_ERROR_ID, Wi as REFRESH_AUTH_FAILURE_IDS, J as RefreshErrorId, Qe as RequestMethod, y as SDK_VERSION, nt as SERVICE_UNAVAILABLE_ERROR_ID, rt as SERVICE_UNAVAILABLE_MESSAGE, ka as SESSION_INVALIDATING_COMMIT_ERROR_IDS, kt as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, st as SIGN_IN_REFUSED_ERROR_ID, _ as STYTCH_TELEMETRY_HEADER_KEY, F as SessionState, xn as SettingAPI, te as TOKEN_EXPIRY_BUFFER_SECONDS, vt as TWO_FACTOR_SEND_LIMIT_ERROR_ID, _t as TWO_FACTOR_SMS_QUOTA_EXCEEDED_ERROR_ID, Sn as TenantAPI, Eo as TenantService, wo as TenantUserMembership, Do as TokenCacheService, P as TokenDeliveryMode, N as TokenType, Dn as TwoFactorApiClient, Pt as TwoFactorPolicy, Oo as TwoFactorService, Ne as UPGRADE_REQUIRED, D as USERNAME_MAX_LENGTH, ne as USERNAME_MIN_LENGTH, On as UpgradeAPI, Ho as UpgradeCancelledError, ra as UpgradeCommitInterruptedError, ns as UpgradeController, Q as UpgradeErrorIds, Ao as UpgradeFactorError, Wa as UpgradeInsufficientError, Ka as UpgradeSessionChangedError, Uo as UpgradeSignInRequiredError, $ as UpgradeTransportError, Ga as UpgradeUnavailableError, Jo as UpgradeUnsatisfiableError, kn as UserAPI, ko as UserService, Te as WebAdapter, Va as classifyUpgradeError, Io as factorRegistry, dr as fetchRegistryState, Mt as getOSFromDeviceType, Ua as invalidatesSessionOnCommit, tt as isEmailVerificationStep, At as isMaskedSecret, Ha as isRecoverableCommitFailure, ja as isRetryableUpgradeKind, j as isTokenExpired, Ms as isUpgradeCancelled, Ns as isUpgradeExhausted, Ps as isUpgradeInsufficient, Rs as isUpgradeSessionChanged, Is as isUpgradeSignInRequired, Fa as isUpgradeTransportError, zs as isUpgradeTransportFailure, Ls as isUpgradeUnavailable, Fs as isUpgradeUnsatisfiable, Za as isValidEmail, Ya as isValidJWTFormat, Qa as isValidPhoneNumber, $a as isValidUsername, Be as parseChallengeBody, ze as parseChallengeHeader, M as parseToken, We as parseUpgradeChallenge, Po as passkeyFactor, Nt as pathWithParams, In as pushChallengeOf, No as recoveryCodesFactor, ur as registerFetchMiddleware, je as requiredAcrLevel, et as resolveUpgradeDomain, Xa as sanitizeErrorMessage, Vo as selectFactors, Mo as totpFactor, Ee as webAdapter };
8681
8670
 
8682
8671
  //# sourceMappingURL=index.mjs.map