@passflow/core 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import B from "axios";
2
- import { v4 as mt } from "uuid";
3
- import { startAuthentication as vt, startRegistration as yt } from "@simplewebauthn/browser";
4
- const kt = "0.16.0", wt = {
5
- version: kt
6
- }, N = "X-Passflow-Clientid", U = "Authorization", St = "X-Passflow-DeviceId", bt = "X-Passflow-DeviceType", Tt = wt.version, Ks = ["id", "offline", "openid"], _t = ["id", "offline", "tenant", "email", "oidc", "openid", "access:tenant:all"], De = "https://auth.passflow.cloud", js = "default", Et = 500, It = 600, At = 100, Ct = 6e4, xe = 30, Rt = 3, Ft = 30, Mt = 200, Pt = (r) => {
1
+ import K from "axios";
2
+ import { v4 as kt } from "uuid";
3
+ import { startAuthentication as wt, startRegistration as St } from "@simplewebauthn/browser";
4
+ const bt = "0.18.0", Tt = {
5
+ version: bt
6
+ }, V = "X-Passflow-Clientid", D = "Authorization", _t = "X-Passflow-DeviceId", Et = "X-Passflow-DeviceType", It = Tt.version, Hs = ["id", "offline", "openid"], At = ["id", "offline", "tenant", "email", "oidc", "openid", "access:tenant:all"], Le = "https://auth.passflow.cloud", zs = "default", Ct = 500, Rt = 600, Ft = 100, Pt = 6e4, $e = 30, Mt = 3, Dt = 30, Ut = 200, xt = (r) => {
7
7
  const e = [];
8
8
  let t;
9
9
  for (t in r) {
@@ -18,14 +18,14 @@ const kt = "0.16.0", wt = {
18
18
  }
19
19
  return { raw: r, tenants: e };
20
20
  };
21
- function Ut(r) {
21
+ function Ot(r) {
22
22
  if (typeof window < "u" && typeof window.atob == "function")
23
23
  return window.atob(r);
24
24
  if (typeof Buffer < "u")
25
25
  return Buffer.from(r, "base64").toString("utf-8");
26
26
  throw new Error("No Base64 decoding method available in this environment");
27
27
  }
28
- class Dt {
28
+ class Lt {
29
29
  constructor(e) {
30
30
  this.storageManager = e;
31
31
  }
@@ -54,19 +54,19 @@ class Dt {
54
54
  return T(t);
55
55
  }
56
56
  }
57
- function C(r, e = xe) {
57
+ function C(r, e = $e) {
58
58
  return Math.floor(Date.now() / 1e3) + e > r.exp;
59
59
  }
60
60
  function T(r) {
61
61
  const e = r.split(".")[1];
62
62
  if (!e) throw new Error("Invalid token string");
63
- const t = e.replace(/-/g, "+").replace(/_/g, "/"), s = t + "=".repeat((4 - t.length % 4) % 4), i = Ut(s), n = decodeURIComponent(
63
+ const t = e.replace(/-/g, "+").replace(/_/g, "/"), s = t + "=".repeat((4 - t.length % 4) % 4), i = Ot(s), n = decodeURIComponent(
64
64
  i.split("").map((a) => "%" + ("00" + a.charCodeAt(0).toString(16)).slice(-2)).join("")
65
65
  ), o = JSON.parse(n);
66
- return o.membership = o.passflow_tm && o.type !== "invite" ? Pt(o.passflow_tm) : void 0, o;
66
+ return o.membership = o.passflow_tm && o.type !== "invite" ? xt(o.passflow_tm) : void 0, o;
67
67
  }
68
- var b = /* @__PURE__ */ ((r) => (r.id_token = "id_token", r.access_token = "access", r.refresh_token = "refresh", r.invite_token = "invite", r.reset_token = "reset", r.web_cookie = "web-cookie", r.management = "management", r.signin = "signin", r.actor = "actor", r.two_factor = "2fa", r))(b || {}), A = /* @__PURE__ */ ((r) => (r.JsonBody = "json_body", r.Cookie = "cookie", r.Mobile = "mobile", r.BFF = "bff", r))(A || {}), Oe = /* @__PURE__ */ ((r) => (r.Unknown = "unknown", r.Valid = "valid", r.Invalid = "invalid", r))(Oe || {});
69
- class Le {
68
+ var b = /* @__PURE__ */ ((r) => (r.id_token = "id_token", r.access_token = "access", r.refresh_token = "refresh", r.invite_token = "invite", r.reset_token = "reset", r.web_cookie = "web-cookie", r.management = "management", r.signin = "signin", r.actor = "actor", r.two_factor = "2fa", r))(b || {}), A = /* @__PURE__ */ ((r) => (r.JsonBody = "json_body", r.Cookie = "cookie", r.Mobile = "mobile", r.BFF = "bff", r))(A || {}), qe = /* @__PURE__ */ ((r) => (r.Unknown = "unknown", r.Valid = "valid", r.Invalid = "invalid", r))(qe || {});
69
+ class Ne {
70
70
  constructor(e) {
71
71
  this.storageManager = e, this.mode = "json_body", this.sessionState = "unknown", this.isInitializedFlag = !1, this.STORAGE_PREFIX = "passflow_", this.DELIVERY_MODE_KEY = `${this.STORAGE_PREFIX}delivery_mode`, this.SESSION_STATE_KEY = `${this.STORAGE_PREFIX}session_state`, this.loadPersistedMode(), this.loadPersistedSessionState();
72
72
  }
@@ -176,7 +176,7 @@ class Le {
176
176
  loadPersistedSessionState() {
177
177
  try {
178
178
  const e = this.storageManager.storage.getItem(this.SESSION_STATE_KEY);
179
- e && Object.values(Oe).includes(e) && (this.sessionState = e);
179
+ e && Object.values(qe).includes(e) && (this.sessionState = e);
180
180
  } catch {
181
181
  }
182
182
  }
@@ -217,7 +217,7 @@ class Le {
217
217
  }
218
218
  }
219
219
  }
220
- class me {
220
+ class ke {
221
221
  constructor({ storage: e, prefix: t } = {}) {
222
222
  this.keyStoragePrefix = "", this.scopes = `${this.keyStoragePrefix}tokens_scopes`, this.deviceId = `${this.keyStoragePrefix}passflowDeviceId`, this.invitationToken = `${this.keyStoragePrefix}passflowInvitationToken`, this.previousRedirectUrl = `${this.keyStoragePrefix}passflowPreviousRedirectUrl`, this.STORAGE_PREFIX = "passflow_", this.ID_TOKEN_KEY = `${this.STORAGE_PREFIX}id_token`, this.CSRF_TOKEN_KEY = `${this.STORAGE_PREFIX}csrf_token`, this.DELIVERY_MODE_KEY = `${this.STORAGE_PREFIX}delivery_mode`, this.storage = e ?? localStorage, this.keyStoragePrefix = t ? `${t}_` : "";
223
223
  }
@@ -400,9 +400,9 @@ class me {
400
400
  return `${this.keyStoragePrefix}${e}`;
401
401
  }
402
402
  }
403
- class $e {
403
+ class Ve {
404
404
  constructor(e) {
405
- this.storageManager = e ?? new me();
405
+ this.storageManager = e ?? new ke();
406
406
  }
407
407
  getDeviceId() {
408
408
  const e = this.storageManager.getDeviceId();
@@ -413,19 +413,19 @@ class $e {
413
413
  return e;
414
414
  }
415
415
  generateUniqueDeviceId() {
416
- return mt();
416
+ return kt();
417
417
  }
418
418
  }
419
- class qe extends Error {
419
+ class Be extends Error {
420
420
  constructor(e = "Authentication popup was closed") {
421
421
  super(e), this.name = "PopupClosedError";
422
422
  }
423
423
  }
424
- class xt {
424
+ class $t {
425
425
  constructor() {
426
426
  this.passkeys = {
427
- startRegistration: (e) => yt({ optionsJSON: e }),
428
- startAuthentication: (e) => vt({ optionsJSON: e })
427
+ startRegistration: (e) => St({ optionsJSON: e }),
428
+ startAuthentication: (e) => wt({ optionsJSON: e })
429
429
  };
430
430
  }
431
431
  // ----------------------------------------------------------------
@@ -557,14 +557,14 @@ class xt {
557
557
  'openAuthUrl: "deeplink" mode is not supported on web. Use "popup" or "redirect" instead, or provide a native platform adapter.'
558
558
  )
559
559
  );
560
- const i = t.width ?? Et, n = t.height ?? It, o = t.expectedReturnOrigin ?? window.location.origin, a = window.open(e, "_blank", `width=${i},height=${n}`);
560
+ const i = t.width ?? Ct, n = t.height ?? Rt, o = t.expectedReturnOrigin ?? window.location.origin, a = window.open(e, "_blank", `width=${i},height=${n}`);
561
561
  return a ? new Promise((h, p) => {
562
562
  const m = Date.now(), d = setInterval(() => {
563
563
  if (a.closed) {
564
- clearInterval(d), p(new qe());
564
+ clearInterval(d), p(new Be());
565
565
  return;
566
566
  }
567
- if (Date.now() - m > Ct) {
567
+ if (Date.now() - m > Pt) {
568
568
  clearInterval(d), a.close(), p(new Error("Authentication popup timed out"));
569
569
  return;
570
570
  }
@@ -575,7 +575,7 @@ class xt {
575
575
  }
576
576
  } catch {
577
577
  }
578
- }, At);
578
+ }, Ft);
579
579
  }) : (window.location.href = e, new Promise(() => {
580
580
  }));
581
581
  }
@@ -633,78 +633,78 @@ class xt {
633
633
  return "web";
634
634
  }
635
635
  }
636
- const z = new xt(), Ot = /^[0-9]+$/, be = Object.freeze({ unorderable: !1, zero: !1 }), Lt = (r) => Ot.test(r) ? Number.parseInt(r, 10) : void 0, Q = (r) => {
636
+ const Y = new $t(), qt = /^[0-9]+$/, Ee = Object.freeze({ unorderable: !1, zero: !1 }), Nt = (r) => qt.test(r) ? Number.parseInt(r, 10) : void 0, te = (r) => {
637
637
  if (!r)
638
- return be;
638
+ return Ee;
639
639
  const e = r.split(/\s+/).filter((i) => i !== "");
640
640
  if (e.length === 0)
641
- return be;
641
+ return Ee;
642
642
  const t = [];
643
643
  for (const i of e) {
644
- const n = Lt(i);
644
+ const n = Nt(i);
645
645
  n !== void 0 && t.push(n);
646
646
  }
647
647
  if (t.length === 0)
648
648
  return { raw: r, unorderable: !0, zero: !1 };
649
649
  const s = Math.min(...t);
650
650
  return s === 0 ? { raw: r, unorderable: !1, zero: !0 } : { level: s, raw: r, unorderable: !1, zero: !1 };
651
- }, $t = (r) => Q(r).level, qt = "insufficient_user_authentication", Nt = "upgrade_required", Te = /([A-Za-z0-9!#$%&'*+\-.^_`|~]+)\s*=\s*(?:"((?:[^"\\]|\\.)*)"|([^\s,]*))/g, Vt = (r) => r.replace(/\\(.)/g, "$1"), Ne = (r) => {
651
+ }, Vt = (r) => te(r).level, Bt = "insufficient_user_authentication", Kt = "upgrade_required", Ie = /([A-Za-z0-9!#$%&'*+\-.^_`|~]+)\s*=\s*(?:"((?:[^"\\]|\\.)*)"|([^\s,]*))/g, jt = (r) => r.replace(/\\(.)/g, "$1"), Ke = (r) => {
652
652
  const e = {};
653
- Te.lastIndex = 0;
654
- for (const t of r.matchAll(Te)) {
653
+ Ie.lastIndex = 0;
654
+ for (const t of r.matchAll(Ie)) {
655
655
  const s = t[1];
656
656
  if (!s)
657
657
  continue;
658
658
  const i = t[2], n = t[3];
659
- e[s.toLowerCase()] = i !== void 0 ? Vt(i) : n ?? "";
659
+ e[s.toLowerCase()] = i !== void 0 ? jt(i) : n ?? "";
660
660
  }
661
661
  return e;
662
- }, Ve = (r) => {
662
+ }, je = (r) => {
663
663
  if (r == null || r === "")
664
664
  return { kind: "absent" };
665
665
  const e = typeof r == "number" ? r : Number.parseInt(String(r), 10);
666
666
  return Number.isFinite(e) && e > 0 ? { kind: "valid", value: e } : { kind: "invalid", raw: r };
667
- }, Be = (r) => {
668
- const e = Ve(r);
667
+ }, Ge = (r) => {
668
+ const e = je(r);
669
669
  return e.kind === "valid" ? e.value : void 0;
670
- }, Bt = (r, e) => {
670
+ }, Gt = (r, e) => {
671
671
  if (!r || !/(^|[\s,])Bearer\b/i.test(r))
672
672
  return;
673
- const t = Ne(r);
674
- if (t.error === qt)
673
+ const t = Ke(r);
674
+ if (t.error === Bt)
675
675
  return {
676
676
  acrValues: t.acr_values || void 0,
677
- maxAge: Be(t.max_age),
677
+ maxAge: Ge(t.max_age),
678
678
  status: e
679
679
  };
680
- }, Kt = (r, e) => {
680
+ }, Ht = (r, e) => {
681
681
  if (!r || typeof r != "object")
682
682
  return;
683
683
  const t = r;
684
- if (t.error === Nt)
684
+ if (t.error === Kt)
685
685
  return {
686
686
  acrValues: typeof t.acr_values == "string" && t.acr_values ? t.acr_values : void 0,
687
- maxAge: Be(t.max_age),
687
+ maxAge: Ge(t.max_age),
688
688
  status: e
689
689
  };
690
- }, _e = (r, e, t) => ({
690
+ }, Ae = (r, e, t) => ({
691
691
  channel: r,
692
- acr: Q(e.acrValues),
693
- maxAge: Ve(t),
692
+ acr: te(e.acrValues),
693
+ maxAge: je(t),
694
694
  raw: e.acrValues
695
- }), jt = (r) => r ? Ne(r) : {}, ve = (r, e) => {
695
+ }), zt = (r) => r ? Ke(r) : {}, we = (r, e) => {
696
696
  const { status: t } = r;
697
697
  if (t !== 401 && t !== 403)
698
698
  return { diagnostics: [] };
699
- const s = e?.requireChallengeChannel === "header", i = r.getHeader("www-authenticate"), n = Bt(i, t), o = s ? void 0 : Kt(r.body, t), a = [], h = (u, y) => {
699
+ const s = e?.requireChallengeChannel === "header", i = r.getHeader("www-authenticate"), n = Gt(i, t), o = s ? void 0 : Ht(r.body, t), a = [], h = (u, y) => {
700
700
  a.push({ status: t, url: "", reason: u, ...y ? { detail: y } : {} });
701
701
  };
702
702
  if (!n && !o)
703
703
  return s && h("header-required-but-absent", i ? { header: i } : void 0), { diagnostics: a };
704
704
  const p = [];
705
- if (n && p.push(_e("header", n, jt(i).max_age)), o) {
705
+ if (n && p.push(Ae("header", n, zt(i).max_age)), o) {
706
706
  const u = r.body;
707
- p.push(_e("body", o, u?.max_age));
707
+ p.push(Ae("body", o, u?.max_age));
708
708
  }
709
709
  const m = (u) => u;
710
710
  for (const u of p)
@@ -719,8 +719,8 @@ const z = new xt(), Ot = /^[0-9]+$/, be = Object.freeze({ unorderable: !1, zero:
719
719
  for (const u of p)
720
720
  u.maxAge.kind === "valid" && (v === void 0 || u.maxAge.value < v) && (v = u.maxAge.value);
721
721
  if (p.length === 2) {
722
- const [u, y] = p, I = u.acr.level !== void 0 && y.acr.level !== void 0 && u.acr.level !== y.acr.level, Y = u.maxAge.kind === "valid" && y.maxAge.kind === "valid" && u.maxAge.value !== y.maxAge.value;
723
- (I || Y) && h("channels-disagree", { header: u.raw ?? y.raw, body: y.raw ?? u.raw });
722
+ const [u, y] = p, I = u.acr.level !== void 0 && y.acr.level !== void 0 && u.acr.level !== y.acr.level, W = u.maxAge.kind === "valid" && y.maxAge.kind === "valid" && u.maxAge.value !== y.maxAge.value;
723
+ (I || W) && h("channels-disagree", { header: u.raw ?? y.raw, body: y.raw ?? u.raw });
724
724
  }
725
725
  return {
726
726
  challenge: {
@@ -732,15 +732,15 @@ const z = new xt(), Ot = /^[0-9]+$/, be = Object.freeze({ unorderable: !1, zero:
732
732
  },
733
733
  diagnostics: a
734
734
  };
735
- }, Gt = (r, e, t) => ve({ status: r, getHeader: e, body: t }).challenge, Ke = "__passflowUpgradeTransaction", je = "__passflowUpgradeReplayed", Ge = (r, e) => typeof r == "object" && r !== null && r[e] === !0, He = (r) => ({
735
+ }, Yt = (r, e, t) => we({ status: r, getHeader: e, body: t }).challenge, He = "__passflowUpgradeTransaction", ze = "__passflowUpgradeReplayed", Ye = (r, e) => typeof r == "object" && r !== null && r[e] === !0, We = (r) => ({
736
736
  ...r ?? {},
737
- [Ke]: !0
738
- }), ze = (r) => Ge(r, Ke), Ht = (r) => ({
737
+ [He]: !0
738
+ }), Xe = (r) => Ye(r, He), Wt = (r) => ({
739
739
  ...r,
740
- [je]: !0
741
- }), zt = (r) => Ge(r, je);
742
- var P = /* @__PURE__ */ ((r) => (r.GET = "get", r.POST = "post", r.PUT = "put", r.PATCH = "patch", r.DELETE = "delete", r))(P || {}), l = /* @__PURE__ */ ((r) => (r.signin = "/auth/login", r.signup = "/auth/register", r.signInWithProvider = "/auth/federated/start/", r.passwordless = "/auth/passwordless/start", r.passwordlessComplete = "/auth/passwordless/complete", r.logout = "/user/logout", r.refresh = "/auth/refresh", r.validateSession = "/user/me", r.sendPasswordResetEmail = "/auth/password/reset", r.resetPassword = "/auth/password/change", r.appSettings = "/app/settings", r.passkeyRegisterStart = "/auth/passkey/register/start", r.passkeyRegisterComplete = "/auth/passkey/register/complete", r.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", r.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", r.passkeyValidate = "/auth/validate", r.settingsAll = "/settings", r.settingsPasswordPolicy = "/settings/password", r.settingsPasskey = "/settings/passkey", r.userPasskey = "/user/passkey", r.addUserPasskey = "/user/passkey/add/start", r.completeAddUserPasskey = "/user/passkey/add/complete", r.joinInvitation = "/user/tenant/join", r.tenantPath = "/user/tenant", r.invitationsPath = "/user/tenant/:tenantID/invitations", r.requestInvitation = "/user/invite", r.invitationDelete = "/user/invite/:invitationID", r.invitationResend = "/user/invite/:invitationID/resend", r.invitationGetLink = "/user/invite/:invitationID/link", r.twoFactor = "/user/2fa", r.twoFactorStatus = "/user/2fa/status", r.twoFactorSetupBegin = "/user/2fa/setup/begin", r.twoFactorSetupConfirm = "/user/2fa/setup/confirm", r.twoFactorVerify = "/auth/2fa/verify", r.twoFactorRecovery = "/auth/2fa/recovery", r.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", r.twoFactorSetupMagicLink = "/auth/2fa-setup", r.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", r.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", r.TwoFactorSetupStart = "/v2/user/2fa/setup/start", r.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", r.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", r.TwoFactorChallenge = "/v2/auth/2fa/challenge", r.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", r.TwoFactorAlternative = "/v2/auth/2fa/alternative", r.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", r.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", r.cliAuthStatus = "/cli/auth/status/:sessionId", r.cliAuthComplete = "/cli/auth/complete", r.upgradeStart = "/auth/upgrade/start", r))(l || {}), F = /* @__PURE__ */ ((r) => (r.passkeyRegisterStart = "/admin/auth/passkey/register/start", r.passkeyRegisterComplete = "/admin/auth/passkey/register/complete", r.passkeyAuthenticateStart = "/admin/auth/passkey/authenticate/start", r.passkeyAuthenticateComplete = "/admin/auth/passkey/authenticate/complete", r.passkeyValidate = "/admin/auth/validate", r.logout = "/admin/auth/logout", r))(F || {});
743
- const Ye = (r) => {
740
+ [ze]: !0
741
+ }), Xt = (r) => Ye(r, ze);
742
+ var M = /* @__PURE__ */ ((r) => (r.GET = "get", r.POST = "post", r.PUT = "put", r.PATCH = "patch", r.DELETE = "delete", r))(M || {}), l = /* @__PURE__ */ ((r) => (r.signin = "/auth/login", r.signup = "/auth/register", r.signInWithProvider = "/auth/federated/start/", r.passwordless = "/auth/passwordless/start", r.passwordlessComplete = "/auth/passwordless/complete", r.logout = "/user/logout", r.refresh = "/auth/refresh", r.validateSession = "/user/me", r.sendPasswordResetEmail = "/auth/password/reset", r.resetPassword = "/auth/password/change", r.appSettings = "/app/settings", r.passkeyRegisterStart = "/auth/passkey/register/start", r.passkeyRegisterComplete = "/auth/passkey/register/complete", r.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", r.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", r.passkeyValidate = "/auth/validate", r.settingsAll = "/settings", r.settingsPasswordPolicy = "/settings/password", r.settingsPasskey = "/settings/passkey", r.userPasskey = "/user/passkey", r.addUserPasskey = "/user/passkey/add/start", r.completeAddUserPasskey = "/user/passkey/add/complete", r.joinInvitation = "/user/tenant/join", r.tenantPath = "/user/tenant", r.invitationsPath = "/user/tenant/:tenantID/invitations", r.requestInvitation = "/user/invite", r.invitationDelete = "/user/invite/:invitationID", r.invitationResend = "/user/invite/:invitationID/resend", r.invitationGetLink = "/user/invite/:invitationID/link", r.twoFactor = "/user/2fa", r.twoFactorStatus = "/user/2fa/status", r.twoFactorSetupBegin = "/user/2fa/setup/begin", r.twoFactorSetupConfirm = "/user/2fa/setup/confirm", r.twoFactorVerify = "/auth/2fa/verify", r.twoFactorRecovery = "/auth/2fa/recovery", r.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", r.twoFactorSetupMagicLink = "/auth/2fa-setup", r.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", r.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", r.TwoFactorSetupStart = "/v2/user/2fa/setup/start", r.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", r.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", r.TwoFactorChallenge = "/v2/auth/2fa/challenge", r.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", r.TwoFactorAlternative = "/v2/auth/2fa/alternative", r.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", r.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", r.cliAuthStatus = "/cli/auth/status/:sessionId", r.cliAuthComplete = "/cli/auth/complete", r.upgradeStart = "/auth/upgrade/start", r))(l || {}), F = /* @__PURE__ */ ((r) => (r.passkeyRegisterStart = "/admin/auth/passkey/register/start", r.passkeyRegisterComplete = "/admin/auth/passkey/register/complete", r.passkeyAuthenticateStart = "/admin/auth/passkey/authenticate/start", r.passkeyAuthenticateComplete = "/admin/auth/passkey/authenticate/complete", r.passkeyValidate = "/admin/auth/validate", r.logout = "/admin/auth/logout", r))(F || {});
743
+ const Je = (r) => {
744
744
  if (!r)
745
745
  return null;
746
746
  try {
@@ -755,21 +755,21 @@ class w extends Error {
755
755
  super(), 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();
756
756
  }
757
757
  }
758
- var Yt = /* @__PURE__ */ ((r) => (r.google = "google", r.facebook = "facebook", r))(Yt || {}), Wt = /* @__PURE__ */ ((r) => (r.web = "web", r.ios = "ios", r.android = "android", r))(Wt || {});
759
- function Gs(r) {
758
+ var Jt = /* @__PURE__ */ ((r) => (r.google = "google", r.facebook = "facebook", r))(Jt || {}), Zt = /* @__PURE__ */ ((r) => (r.web = "web", r.ios = "ios", r.android = "android", r))(Zt || {});
759
+ function Ys(r) {
760
760
  return r;
761
761
  }
762
- function M(r, e) {
762
+ function P(r, e) {
763
763
  let t = r;
764
764
  return Object.entries(e).forEach(([s, i]) => {
765
765
  t = t.replace(`:${s}`, i);
766
766
  }), t;
767
767
  }
768
- var Xt = /* @__PURE__ */ ((r) => (r.Disabled = "disabled", r.Optional = "optional", r.Required = "required", r))(Xt || {});
769
- const Jt = 3, Zt = 1e3, Qt = (r) => (e) => {
768
+ var Qt = /* @__PURE__ */ ((r) => (r.Disabled = "disabled", r.Optional = "optional", r.Required = "required", r))(Qt || {});
769
+ const er = 3, tr = 1e3, rr = (r) => (e) => {
770
770
  const t = r.headers?.[e] ?? r.headers?.[e.toLowerCase()];
771
771
  return Array.isArray(t) ? t.join(", ") : t;
772
- }, We = (r) => Gt(r.status, Qt(r), r.data), er = (r) => We(r) !== void 0;
772
+ }, Ze = (r) => Yt(r.status, rr(r), r.data), sr = (r) => Ze(r) !== void 0;
773
773
  class E {
774
774
  constructor(e, t, s) {
775
775
  this.refreshPromise = null, this.isRefreshing = !1, this.defaultHeaders = {
@@ -777,18 +777,18 @@ class E {
777
777
  "Content-Type": "application/json"
778
778
  }, this.nonAccessTokenEndpoints = ["/auth/", "/settings", "/settings/"], this.protectedEndpoints = ["logout", "refresh", "upgrade"];
779
779
  const { url: i, appId: n, keyStoragePrefix: o } = e;
780
- this._platform = e.platform ?? z, this.url = i || De, this.upgradeDomain = Ye(i), this.storageManager = t ?? new me({
780
+ this._platform = e.platform ?? Y, this.url = i || Le, this.upgradeDomain = Je(i), this.storageManager = t ?? new ke({
781
781
  prefix: o ?? ""
782
- }), this.deviceService = s ?? new $e(this.storageManager), this.tokenService = new Dt(this.storageManager), this.tokenDeliveryManager = new Le(this.storageManager), n && (this.appId = n, this.defaultHeaders = {
782
+ }), this.deviceService = s ?? new Ve(this.storageManager), this.tokenService = new Lt(this.storageManager), this.tokenDeliveryManager = new Ne(this.storageManager), n && (this.appId = n, this.defaultHeaders = {
783
783
  ...this.defaultHeaders,
784
- [N]: n
784
+ [V]: n
785
785
  });
786
786
  const a = this.deviceService.getDeviceId();
787
787
  this.defaultHeaders = {
788
788
  ...this.defaultHeaders,
789
- [St]: a,
790
- [bt]: this._platform.getDeviceType()
791
- }, this.detectCookieSupport(), this.instance = B.create({
789
+ [_t]: a,
790
+ [Et]: this._platform.getDeviceType()
791
+ }, this.detectCookieSupport(), this.instance = K.create({
792
792
  baseURL: this.url,
793
793
  headers: { ...this.defaultHeaders }
794
794
  }), this.instance.interceptors.request.use(async (h) => {
@@ -809,30 +809,30 @@ class E {
809
809
  const p = this.storageManager.getTokens();
810
810
  if (p?.access_token) {
811
811
  const m = T(p.access_token);
812
- if (C(m, xe) && p.refresh_token)
812
+ if (C(m, $e) && p.refresh_token)
813
813
  try {
814
814
  if (this.refreshPromise) {
815
815
  const d = await this.refreshPromise;
816
- return d?.data?.access_token && (h.headers[U] = `Bearer ${d.data.access_token}`), h;
816
+ return d?.data?.access_token && (h.headers[D] = `Bearer ${d.data.access_token}`), h;
817
817
  }
818
818
  this.refreshPromise = this.refreshTokens();
819
819
  try {
820
820
  const d = await this.refreshPromise;
821
- return d?.data?.access_token && (h.headers[U] = `Bearer ${d.data.access_token}`), h;
821
+ return d?.data?.access_token && (h.headers[D] = `Bearer ${d.data.access_token}`), h;
822
822
  } finally {
823
823
  this.refreshPromise = null;
824
824
  }
825
825
  } catch (d) {
826
826
  return this.refreshPromise = null, this.isRefreshing = !1, this.storageManager.deleteTokens(), Promise.reject(d);
827
827
  }
828
- return h.headers[U] = `Bearer ${p.access_token}`, h;
828
+ return h.headers[D] = `Bearer ${p.access_token}`, h;
829
829
  }
830
830
  return h;
831
831
  }), this.instance.interceptors.response.use(
832
832
  (h) => h,
833
833
  async (h) => {
834
834
  if (h.response?.status === 401 && !this.isUpgradeTransactionError(h) && this.tokenDeliveryManager.setSessionInvalid(), h.response && this.upgradeHandler) {
835
- const p = We(h.response);
835
+ const p = Ze(h.response);
836
836
  if (p)
837
837
  try {
838
838
  return await this.upgradeHandler(h, p);
@@ -854,7 +854,7 @@ class E {
854
854
  * speak upgrade vocabulary", which is unsound in both directions.
855
855
  */
856
856
  isUpgradeTransactionError(e) {
857
- return ze(e.config) || e.response !== void 0 && er(e.response);
857
+ return Xe(e.config) || e.response !== void 0 && sr(e.response);
858
858
  }
859
859
  /**
860
860
  * Installs (or clears) the handler consulted when a response carries an
@@ -915,7 +915,7 @@ class E {
915
915
  scopes: t
916
916
  }, i = await this.instance.post(l.refresh, s, {
917
917
  headers: {
918
- [U]: `Bearer ${e.refresh_token}`
918
+ [D]: `Bearer ${e.refresh_token}`
919
919
  }
920
920
  });
921
921
  return i.data && this.storageManager.saveTokens(i.data), this.isRefreshing = !1, i;
@@ -929,9 +929,9 @@ class E {
929
929
  if (!["GET", "HEAD", "OPTIONS"].includes(s || ""))
930
930
  return Promise.reject(e);
931
931
  const n = t._retryCount || 0;
932
- if (n >= Jt)
932
+ if (n >= er)
933
933
  return Promise.reject(e);
934
- let o = Zt * Math.pow(2, n);
934
+ let o = tr * Math.pow(2, n);
935
935
  const a = e.response?.headers?.["retry-after"];
936
936
  if (a) {
937
937
  const h = Number.parseInt(a, 10);
@@ -972,19 +972,19 @@ class E {
972
972
  })).data;
973
973
  }
974
974
  get(e, t) {
975
- return this.send(P.GET, e, t);
975
+ return this.send(M.GET, e, t);
976
976
  }
977
977
  post(e, t, s) {
978
- return this.send(P.POST, e, { data: t, ...s });
978
+ return this.send(M.POST, e, { data: t, ...s });
979
979
  }
980
980
  put(e, t, s) {
981
- return this.send(P.PUT, e, { data: t, ...s });
981
+ return this.send(M.PUT, e, { data: t, ...s });
982
982
  }
983
983
  patch(e, t, s) {
984
- return this.send(P.PATCH, e, { data: t, ...s });
984
+ return this.send(M.PATCH, e, { data: t, ...s });
985
985
  }
986
986
  delete(e, t) {
987
- return this.send(P.DELETE, e, t);
987
+ return this.send(M.DELETE, e, t);
988
988
  }
989
989
  /**
990
990
  * Update the appId and propagate it to axios headers.
@@ -995,11 +995,11 @@ class E {
995
995
  setAppId(e) {
996
996
  this.appId = e, this.defaultHeaders = {
997
997
  ...this.defaultHeaders,
998
- [N]: e
999
- }, this.instance.defaults.headers.common[N] = e;
998
+ [V]: e
999
+ }, this.instance.defaults.headers.common[V] = e;
1000
1000
  }
1001
1001
  }
1002
- class tr {
1002
+ class ir {
1003
1003
  constructor(e, t, s) {
1004
1004
  this.axiosClient = new E(e, t, s);
1005
1005
  }
@@ -1010,7 +1010,8 @@ class tr {
1010
1010
  return this.axiosClient.get(l.appSettings);
1011
1011
  }
1012
1012
  }
1013
- class rr {
1013
+ const q = { withCredentials: !0 };
1014
+ class nr {
1014
1015
  constructor(e, t, s) {
1015
1016
  this.axiosClient = new E(e, t, s);
1016
1017
  }
@@ -1041,13 +1042,13 @@ class rr {
1041
1042
  ...i ? { upgrade: i } : {}
1042
1043
  }, o = {
1043
1044
  headers: {
1044
- [U]: `Bearer ${e}`
1045
+ [D]: `Bearer ${e}`
1045
1046
  }
1046
1047
  };
1047
1048
  return this.axiosClient.post(
1048
1049
  l.refresh,
1049
1050
  n,
1050
- i ? He(o) : o
1051
+ i ? We(o) : o
1051
1052
  );
1052
1053
  }
1053
1054
  signIn(e, t, s) {
@@ -1058,7 +1059,8 @@ class rr {
1058
1059
  };
1059
1060
  return this.axiosClient.post(
1060
1061
  l.signin,
1061
- i
1062
+ i,
1063
+ q
1062
1064
  );
1063
1065
  }
1064
1066
  signUp(e) {
@@ -1069,7 +1071,8 @@ class rr {
1069
1071
  };
1070
1072
  return this.axiosClient.post(
1071
1073
  l.signup,
1072
- i
1074
+ i,
1075
+ q
1073
1076
  );
1074
1077
  }
1075
1078
  passwordlessSignIn(e, t, s) {
@@ -1087,7 +1090,8 @@ class rr {
1087
1090
  passwordlessSignInComplete(e) {
1088
1091
  return this.axiosClient.post(
1089
1092
  l.passwordlessComplete,
1090
- e
1093
+ e,
1094
+ q
1091
1095
  );
1092
1096
  }
1093
1097
  logOut(e, t, s = !1) {
@@ -1110,8 +1114,8 @@ class rr {
1110
1114
  };
1111
1115
  return this.axiosClient.post(l.resetPassword, i, {
1112
1116
  headers: {
1113
- [U]: `Bearer ${s}`,
1114
- [N]: void 0
1117
+ [D]: `Bearer ${s}`,
1118
+ [V]: void 0
1115
1119
  }
1116
1120
  });
1117
1121
  }
@@ -1130,7 +1134,11 @@ class rr {
1130
1134
  device: t,
1131
1135
  passkey_data: e
1132
1136
  }, o = i ? F.passkeyRegisterComplete : l.passkeyRegisterComplete;
1133
- return this.axiosClient.post(o, n);
1137
+ return this.axiosClient.post(
1138
+ o,
1139
+ n,
1140
+ q
1141
+ );
1134
1142
  }
1135
1143
  passkeyAuthenticateStart(e, t, s, i = !1) {
1136
1144
  const n = {
@@ -1150,7 +1158,11 @@ class rr {
1150
1158
  device: t,
1151
1159
  passkey_data: e
1152
1160
  }, o = i ? F.passkeyAuthenticateComplete : l.passkeyAuthenticateComplete;
1153
- return this.axiosClient.post(o, n);
1161
+ return this.axiosClient.post(
1162
+ o,
1163
+ n,
1164
+ q
1165
+ );
1154
1166
  }
1155
1167
  passkeyValidate(e, t, s, i = !1, n) {
1156
1168
  const o = {
@@ -1160,11 +1172,11 @@ class rr {
1160
1172
  };
1161
1173
  let a = l.passkeyValidate;
1162
1174
  !n && i && (a = F.passkeyValidate);
1163
- const h = n ? { [N]: n } : {};
1175
+ const h = n ? { [V]: n } : {};
1164
1176
  return this.axiosClient.post(a, o, { headers: h });
1165
1177
  }
1166
1178
  }
1167
- class Hs {
1179
+ class Ws {
1168
1180
  constructor(e, t, s) {
1169
1181
  this.axiosClient = new E(e, t, s);
1170
1182
  }
@@ -1172,14 +1184,14 @@ class Hs {
1172
1184
  this.axiosClient.setAppId(e);
1173
1185
  }
1174
1186
  getCLIAuthStatus(e) {
1175
- const t = M(l.cliAuthStatus, { sessionId: e });
1187
+ const t = P(l.cliAuthStatus, { sessionId: e });
1176
1188
  return this.axiosClient.get(t);
1177
1189
  }
1178
1190
  completeCLIAuth(e) {
1179
1191
  return this.axiosClient.post(l.cliAuthComplete, e);
1180
1192
  }
1181
1193
  }
1182
- class sr {
1194
+ class or {
1183
1195
  constructor(e, t, s) {
1184
1196
  this.axiosClient = new E(e, t, s);
1185
1197
  }
@@ -1205,7 +1217,7 @@ class sr {
1205
1217
  getInvitations(e) {
1206
1218
  const t = {};
1207
1219
  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());
1208
- const s = M(l.invitationsPath, {
1220
+ const s = P(l.invitationsPath, {
1209
1221
  tenantID: e.tenantID
1210
1222
  });
1211
1223
  return this.axiosClient.get(s, { params: t }).then((i) => ({
@@ -1219,7 +1231,7 @@ class sr {
1219
1231
  * @returns Promise with success response
1220
1232
  */
1221
1233
  deleteInvitation(e) {
1222
- const t = M(l.invitationDelete, {
1234
+ const t = P(l.invitationDelete, {
1223
1235
  invitationID: e
1224
1236
  });
1225
1237
  return this.axiosClient.delete(t);
@@ -1230,7 +1242,7 @@ class sr {
1230
1242
  * @returns Promise with success response
1231
1243
  */
1232
1244
  resendInvitation(e) {
1233
- const t = M(l.invitationResend, {
1245
+ const t = P(l.invitationResend, {
1234
1246
  invitationID: e
1235
1247
  });
1236
1248
  return this.axiosClient.post(t, {});
@@ -1241,13 +1253,13 @@ class sr {
1241
1253
  * @returns Promise with the link
1242
1254
  */
1243
1255
  getInvitationLink(e) {
1244
- const t = M(l.invitationGetLink, {
1256
+ const t = P(l.invitationGetLink, {
1245
1257
  invitationID: e
1246
1258
  });
1247
1259
  return this.axiosClient.get(t);
1248
1260
  }
1249
1261
  }
1250
- class ir {
1262
+ class ar {
1251
1263
  constructor(e, t, s) {
1252
1264
  this.axiosClient = new E(e, t, s);
1253
1265
  }
@@ -1264,7 +1276,7 @@ class ir {
1264
1276
  return this.axiosClient.get(l.settingsPasskey);
1265
1277
  }
1266
1278
  }
1267
- class nr {
1279
+ class cr {
1268
1280
  constructor(e, t, s) {
1269
1281
  this.axiosClient = new E(e, t, s);
1270
1282
  }
@@ -1497,7 +1509,11 @@ class nr {
1497
1509
  return this.axiosClient.delete(i);
1498
1510
  }
1499
1511
  }
1500
- class or {
1512
+ const pe = (r) => r ? { headers: { Authorization: `Bearer ${r}` } } : {}, ie = (r) => ({
1513
+ withCredentials: !0,
1514
+ ...pe(r)
1515
+ });
1516
+ class hr {
1501
1517
  constructor(e, t, s) {
1502
1518
  this.axiosClient = new E(e, t, s);
1503
1519
  }
@@ -1536,15 +1552,11 @@ class or {
1536
1552
  * Uses tfa_token as Bearer token for authentication
1537
1553
  */
1538
1554
  verify(e) {
1539
- const { tfa_token: t, code: s } = e;
1555
+ const { tfa_token: t, code: s, trust_device: i } = e;
1540
1556
  return this.axiosClient.post(
1541
1557
  l.twoFactorVerify,
1542
- { code: s },
1543
- {
1544
- headers: {
1545
- Authorization: `Bearer ${t}`
1546
- }
1547
- }
1558
+ { code: s, ...i ? { trust_device: !0 } : {} },
1559
+ ie(t)
1548
1560
  );
1549
1561
  }
1550
1562
  /**
@@ -1553,15 +1565,11 @@ class or {
1553
1565
  * Uses tfa_token as Bearer token for authentication
1554
1566
  */
1555
1567
  useRecoveryCode(e) {
1556
- const { tfa_token: t, recovery_code: s } = e;
1568
+ const { tfa_token: t, recovery_code: s, trust_device: i } = e;
1557
1569
  return this.axiosClient.post(
1558
1570
  l.twoFactorRecovery,
1559
- { recovery_code: s },
1560
- {
1561
- headers: {
1562
- Authorization: `Bearer ${t}`
1563
- }
1564
- }
1571
+ { recovery_code: s, ...i ? { trust_device: !0 } : {} },
1572
+ ie(t)
1565
1573
  );
1566
1574
  }
1567
1575
  /**
@@ -1711,56 +1719,72 @@ class or {
1711
1719
  * DELETE /v2/user/2fa/methods/:id
1712
1720
  */
1713
1721
  removeMethod(e) {
1714
- const t = M(l.TwoFactorMethodRemove, { id: e });
1722
+ const t = P(l.TwoFactorMethodRemove, { id: e });
1715
1723
  return this.axiosClient.delete(t);
1716
1724
  }
1717
1725
  /**
1718
1726
  * Request 2FA challenge during login
1719
1727
  * POST /v2/auth/2fa/challenge
1728
+ * `tfaToken`, when given, goes as the Bearer token the route is gated on.
1720
1729
  */
1721
- requestChallenge(e) {
1730
+ requestChallenge(e, t) {
1722
1731
  return this.axiosClient.post(
1723
1732
  l.TwoFactorChallenge,
1724
- e
1733
+ e,
1734
+ pe(t)
1725
1735
  );
1726
1736
  }
1727
1737
  /**
1728
1738
  * Verify 2FA challenge (v2)
1729
- * POST /v2/auth/2fa/verify
1739
+ * POST /v2/auth/2fa/verify (the server's verify-challenge)
1740
+ *
1741
+ * `tfaToken` is the 2FA token the first factor returned; the route is gated
1742
+ * on it, so it goes as the Bearer token when given.
1730
1743
  */
1731
- verifyV2(e) {
1744
+ verifyV2(e, t) {
1745
+ const { trust_device: s, ...i } = e;
1732
1746
  return this.axiosClient.post(
1733
1747
  l.TwoFactorVerifyV2,
1734
- e
1748
+ { ...i, ...s ? { trust_device: !0 } : {} },
1749
+ ie(t)
1735
1750
  );
1736
1751
  }
1737
1752
  /**
1738
1753
  * Switch to alternative 2FA method during challenge
1739
1754
  * POST /v2/auth/2fa/alternative
1755
+ * `tfaToken`, when given, goes as the Bearer token the route is gated on.
1740
1756
  */
1741
- switchToAlternative(e) {
1757
+ switchToAlternative(e, t) {
1742
1758
  return this.axiosClient.post(
1743
1759
  l.TwoFactorAlternative,
1744
- e
1760
+ e,
1761
+ pe(t)
1745
1762
  );
1746
1763
  }
1747
1764
  /**
1748
- * Get trusted devices
1765
+ * List the devices the user trusted on this app
1749
1766
  * GET /v2/user/2fa/trusted-devices
1767
+ *
1768
+ * Sent with credentials so the server sees this device's trust cookie and
1769
+ * can mark it `current`.
1750
1770
  */
1751
- getTrustedDevices() {
1752
- return this.axiosClient.get(l.TwoFactorTrustedDevices);
1771
+ async getTrustedDevices() {
1772
+ return (await this.axiosClient.get(
1773
+ l.TwoFactorTrustedDevices,
1774
+ { withCredentials: !0 }
1775
+ ))?.devices ?? [];
1753
1776
  }
1754
1777
  /**
1755
1778
  * Revoke trusted device
1756
1779
  * DELETE /v2/user/2fa/trusted-devices/:id
1780
+ * The server answers 404 when the user has no such device.
1757
1781
  */
1758
1782
  revokeTrustedDevice(e) {
1759
- const t = M(l.TwoFactorTrustedDeviceRevoke, { id: e });
1783
+ const t = P(l.TwoFactorTrustedDeviceRevoke, { id: e });
1760
1784
  return this.axiosClient.delete(t);
1761
1785
  }
1762
1786
  }
1763
- class ar {
1787
+ class dr {
1764
1788
  constructor(e, t, s) {
1765
1789
  this.axiosClient = new E(e, t, s);
1766
1790
  }
@@ -1782,11 +1806,11 @@ class ar {
1782
1806
  return this.axiosClient.post(
1783
1807
  l.upgradeStart,
1784
1808
  e,
1785
- He({})
1809
+ We({})
1786
1810
  );
1787
1811
  }
1788
1812
  }
1789
- class cr {
1813
+ class lr {
1790
1814
  constructor(e, t, s) {
1791
1815
  this.axiosClient = new E(e, t, s);
1792
1816
  }
@@ -1832,7 +1856,7 @@ class cr {
1832
1856
  }
1833
1857
  }
1834
1858
  var c = /* @__PURE__ */ ((r) => (r.SignIn = "signin", r.SignInStart = "signin:start", r.Register = "register", r.RegisterStart = "register:start", r.SignOut = "signout", r.SessionRestored = "session:restored", r.SessionExpired = "session:expired", r.Error = "error", r.Refresh = "refresh", r.RefreshStart = "refresh:start", r.TokenCacheExpired = "token-cache-expired", r.TwoFactorRequired = "2fa:required", r.TwoFactorSetupStarted = "2fa:setup_started", r.TwoFactorEnabled = "2fa:enabled", r.TwoFactorDisabled = "2fa:disabled", r.TwoFactorVerified = "2fa:verified", r.TwoFactorRecoveryUsed = "2fa:recovery_used", r.TwoFactorRecoveryCodesLow = "2fa:recovery_low", r.TwoFactorRecoveryCodesExhausted = "2fa:recovery_exhausted", r.TwoFactorSetupMagicLinkValidated = "2fa:magic_link_validated", r.TwoFactorSetupMagicLinkFailed = "2fa:magic_link_failed", r.TwoFactorChallengeReceived = "two_factor_challenge_received", r.TwoFactorMethodSwitched = "two_factor_method_switched", r.TwoFactorDeviceTrusted = "two_factor_device_trusted", r))(c || {});
1835
- class hr {
1859
+ class ur {
1836
1860
  constructor() {
1837
1861
  this.subscribers = /* @__PURE__ */ new Map();
1838
1862
  }
@@ -1886,18 +1910,18 @@ const k = {
1886
1910
  twoFactorNotEnabled: "error.2fa.not_enabled",
1887
1911
  notImplemented: "error.not.implemented",
1888
1912
  tokenInvalid: "error.api.request.token.invalid"
1889
- }, dr = Object.freeze([
1913
+ }, pr = Object.freeze([
1890
1914
  k.twoFactorCodeInvalid,
1891
1915
  k.twoFactorNotEnabled,
1892
1916
  k.challengeInvalid,
1893
1917
  k.challengeSessionMismatch,
1894
1918
  k.challengeTooManyAttempts
1895
- ]), lr = Object.freeze([k.tokenInvalid]), ur = Object.freeze([
1919
+ ]), fr = Object.freeze([k.tokenInvalid]), gr = Object.freeze([
1896
1920
  "wrong_code",
1897
1921
  "challenge_spent",
1898
1922
  "not_registered",
1899
1923
  "prepare_not_required"
1900
- ]), pr = (r) => ur.includes(r), fr = {
1924
+ ]), vr = (r) => gr.includes(r), mr = {
1901
1925
  wrong_code: "That code was not accepted. Try again.",
1902
1926
  challenge_spent: "That verification challenge is no longer valid. Start again.",
1903
1927
  exhausted: "Too many attempts. Try again later.",
@@ -1912,17 +1936,17 @@ const k = {
1912
1936
  };
1913
1937
  class _ extends Error {
1914
1938
  constructor(e) {
1915
- super(e.message || fr[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, this.retryable = pr(e.kind), e.cause !== void 0 && (this.cause = e.cause);
1939
+ super(e.message || mr[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, this.retryable = vr(e.kind), e.cause !== void 0 && (this.cause = e.cause);
1916
1940
  }
1917
1941
  }
1918
- const gr = Object.freeze([
1942
+ const yr = Object.freeze([
1919
1943
  "upgrade_transport",
1920
1944
  "upgrade_insufficient",
1921
1945
  "upgrade_unavailable",
1922
1946
  "upgrade_session_changed",
1923
1947
  "upgrade_cancelled",
1924
1948
  "upgrade_unsatisfiable"
1925
- ]), Xe = (r) => typeof r == "object" && r !== null && typeof r.code == "string" && gr.includes(r.code), mr = (r) => r instanceof _ || typeof r == "object" && r !== null && r.code === "upgrade_transport", vr = (r) => {
1949
+ ]), Qe = (r) => typeof r == "object" && r !== null && typeof r.code == "string" && yr.includes(r.code), kr = (r) => r instanceof _ || typeof r == "object" && r !== null && r.code === "upgrade_transport", wr = (r) => {
1926
1950
  if (typeof r != "object" || r === null)
1927
1951
  return { hasResponse: !1, message: typeof r == "string" ? r : void 0 };
1928
1952
  const e = r, t = e.response, s = t?.data, i = typeof s?.error?.id == "string" ? s.error.id : void 0;
@@ -1932,7 +1956,7 @@ const gr = Object.freeze([
1932
1956
  message: typeof e.message == "string" ? e.message : void 0,
1933
1957
  hasResponse: t !== void 0 || typeof e.status == "number"
1934
1958
  };
1935
- }, yr = (r, e) => {
1959
+ }, Sr = (r, e) => {
1936
1960
  switch (r) {
1937
1961
  case k.twoFactorCodeInvalid:
1938
1962
  return "wrong_code";
@@ -1981,13 +2005,13 @@ const gr = Object.freeze([
1981
2005
  default:
1982
2006
  return;
1983
2007
  }
1984
- }, kr = (r, e) => r === void 0 ? "network" : r === 501 ? "unavailable" : r === 400 ? "fatal" : r === 401 || r === 403 ? e === "start" ? "challenge_spent" : "session_changed" : r >= 500 ? "network" : "fatal", Ee = (r, e) => {
2008
+ }, br = (r, e) => r === void 0 ? "network" : r === 501 ? "unavailable" : r === 400 ? "fatal" : r === 401 || r === 403 ? e === "start" ? "challenge_spent" : "session_changed" : r >= 500 ? "network" : "fatal", Ce = (r, e) => {
1985
2009
  if (r instanceof _)
1986
2010
  return r;
1987
- const t = vr(r);
2011
+ const t = wr(r);
1988
2012
  if (!t.hasResponse)
1989
2013
  return new _({ kind: "network", message: t.message, cause: r });
1990
- const s = yr(t.errorId, e) ?? kr(t.status, e);
2014
+ const s = Sr(t.errorId, e) ?? br(t.status, e);
1991
2015
  return new _({
1992
2016
  kind: s,
1993
2017
  message: t.message,
@@ -1995,13 +2019,13 @@ const gr = Object.freeze([
1995
2019
  errorId: t.errorId,
1996
2020
  cause: r
1997
2021
  });
1998
- }, zs = (r) => r.errorId !== void 0 && dr.includes(r.errorId), wr = (r) => r.errorId !== void 0 && lr.includes(r.errorId);
1999
- class K extends Error {
2022
+ }, Xs = (r) => r.errorId !== void 0 && pr.includes(r.errorId), Tr = (r) => r.errorId !== void 0 && fr.includes(r.errorId);
2023
+ class j extends Error {
2000
2024
  constructor(e, t, s) {
2001
2025
  super(s ?? "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;
2002
2026
  }
2003
2027
  }
2004
- class j extends Error {
2028
+ class G extends Error {
2005
2029
  constructor(e = "Step-up verification is not available on this deployment") {
2006
2030
  super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
2007
2031
  }
@@ -2011,46 +2035,46 @@ class $ extends Error {
2011
2035
  super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
2012
2036
  }
2013
2037
  }
2014
- const Sr = (r) => {
2038
+ const _r = (r) => {
2015
2039
  if (!(!r || typeof r.sub != "string" || r.sub === ""))
2016
2040
  return typeof r.sid == "string" && r.sid !== "" ? { sub: r.sub, sid: r.sid } : { sub: r.sub };
2017
- }, br = (r, e) => !e || e.sub !== r.sub ? !1 : r.sid !== void 0 && e.sid !== void 0 ? r.sid === e.sid : !0;
2018
- function re(r) {
2041
+ }, Er = (r, e) => !e || e.sub !== r.sub ? !1 : r.sid !== void 0 && e.sid !== void 0 ? r.sid === e.sid : !0;
2042
+ function X(r) {
2019
2043
  if (!r || typeof r != "string") return !1;
2020
2044
  const e = r.split(".");
2021
2045
  if (e.length !== 3) return !1;
2022
2046
  const t = /^[A-Za-z0-9_-]+$/;
2023
2047
  return e.every((s) => t.test(s) && s.length > 0);
2024
2048
  }
2025
- function Tr(r) {
2026
- return r.replace(/<[^>]*>/g, "").substring(0, Mt);
2049
+ function Ir(r) {
2050
+ return r.replace(/<[^>]*>/g, "").substring(0, Ut);
2027
2051
  }
2028
- function se(r) {
2052
+ function ne(r) {
2029
2053
  if (!r || typeof r != "string") return !1;
2030
2054
  const e = r.trim();
2031
2055
  return e.length === 0 ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
2032
2056
  }
2033
- function ie(r) {
2057
+ function oe(r) {
2034
2058
  if (!r || typeof r != "string") return !1;
2035
2059
  const e = r.trim();
2036
2060
  return /^\+[1-9]\d{1,14}$/.test(e);
2037
2061
  }
2038
- function _r(r) {
2062
+ function Ar(r) {
2039
2063
  if (!r || typeof r != "string") return !1;
2040
2064
  const e = r.trim();
2041
- return e.length < Rt || e.length > Ft ? !1 : /^[a-zA-Z0-9_-]+$/.test(e);
2065
+ return e.length < Mt || e.length > Dt ? !1 : /^[a-zA-Z0-9_-]+$/.test(e);
2042
2066
  }
2043
- function W(r, e = 6) {
2067
+ function J(r, e = 6) {
2044
2068
  return !r || typeof r != "string" ? !1 : (e === 8 ? /^\d{8}$/ : /^\d{6}$/).test(r);
2045
2069
  }
2046
- function Er(r) {
2070
+ function Cr(r) {
2047
2071
  if (!r || typeof r != "string") return null;
2048
2072
  const e = r.toUpperCase().replace(/\s+/g, "");
2049
2073
  return /^[A-Z0-9-]{4,16}$/.test(e) ? e : null;
2050
2074
  }
2051
- class Ir {
2052
- constructor(e, t, s, i, n, o, a, h, p, m, d, g = z) {
2053
- this.authApi = e, this.deviceService = t, this.storageManager = s, this.subscribeStore = i, this.tokenCacheService = n, this.scopes = o, this.createTenantForNewUser = a, this.url = h, this.sessionCallbacks = p, this.appId = m, this.platform = g, this.tokenExchangeConfig = d, this.tokenDeliveryManager = new Le(s), d?.enabled && this.tokenDeliveryManager.setMode(A.BFF), this.initializeSession();
2075
+ class Rr {
2076
+ constructor(e, t, s, i, n, o, a, h, p, m, d, g = Y) {
2077
+ this.authApi = e, this.deviceService = t, this.storageManager = s, this.subscribeStore = i, this.tokenCacheService = n, this.scopes = o, this.createTenantForNewUser = a, this.url = h, this.sessionCallbacks = p, this.appId = m, this.platform = g, this.tokenExchangeConfig = d, this.tokenDeliveryManager = new Ne(s), d?.enabled && this.tokenDeliveryManager.setMode(A.BFF), this.initializeSession();
2054
2078
  }
2055
2079
  /**
2056
2080
  * Initialize session state on page load for cookie/BFF mode
@@ -2092,6 +2116,24 @@ class Ir {
2092
2116
  async processAuthResponse(e, t) {
2093
2117
  this.tokenExchangeConfig?.enabled || "token_delivery" in e && e.token_delivery && this.tokenDeliveryManager.setMode(e.token_delivery), this.tokenDeliveryManager.setSessionValid(), this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.callbackUrl && await this.forwardTokensToBFF(e), e.scopes = t, this.storageManager.saveTokens(e, this.tokenDeliveryManager.getMode()), this.tokenCacheService.setTokensCache(e), e.csrf_token && this.storageManager.setCsrfToken(e.csrf_token);
2094
2118
  }
2119
+ /**
2120
+ * Reports whether a sign-in response is still waiting on its second factor,
2121
+ * and when it is, hands the 2FA token on.
2122
+ *
2123
+ * Every sign-in path can end this way: the server answers with a
2124
+ * `tfa_token` (or `requires_2fa`) in place of tokens. That response is not
2125
+ * a session, so on `true` the caller returns it as it is — without
2126
+ * `processAuthResponse`, a `SignIn`/`Register` event or a session check.
2127
+ * The `TwoFactorRequired` event is what the TwoFactorService listens to, so
2128
+ * its verify and recovery calls can carry the token.
2129
+ */
2130
+ handlePendingSecondFactor(e, t) {
2131
+ return e.requires_2fa !== !0 && !e.tfa_token ? !1 : (this.subscribeStore.notify(c.TwoFactorRequired, {
2132
+ email: t || "",
2133
+ challengeId: e.challenge_id || "",
2134
+ tfaToken: e.tfa_token || ""
2135
+ }), !0);
2136
+ }
2095
2137
  /**
2096
2138
  * Forward tokens to BFF server for httpOnly cookie storage
2097
2139
  */
@@ -2117,7 +2159,7 @@ class Ir {
2117
2159
  throw new Error(`BFF token storage failed: ${t.status}`);
2118
2160
  }
2119
2161
  async signIn(e) {
2120
- if ("email" in e && e.email && !se(e.email)) {
2162
+ if ("email" in e && e.email && !ne(e.email)) {
2121
2163
  const i = new Error("Invalid email format"), n = {
2122
2164
  message: "Invalid email format",
2123
2165
  originalError: i,
@@ -2125,7 +2167,7 @@ class Ir {
2125
2167
  };
2126
2168
  throw this.subscribeStore.notify(c.Error, n), i;
2127
2169
  }
2128
- if ("username" in e && e.username && !_r(e.username)) {
2170
+ if ("username" in e && e.username && !Ar(e.username)) {
2129
2171
  const i = new Error(
2130
2172
  "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"
2131
2173
  ), n = {
@@ -2135,7 +2177,7 @@ class Ir {
2135
2177
  };
2136
2178
  throw this.subscribeStore.notify(c.Error, n), i;
2137
2179
  }
2138
- if ("phone" in e && e.phone && !ie(e.phone)) {
2180
+ if ("phone" in e && e.phone && !oe(e.phone)) {
2139
2181
  const i = new Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), n = {
2140
2182
  message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
2141
2183
  originalError: i,
@@ -2148,14 +2190,10 @@ class Ir {
2148
2190
  e.scopes = e.scopes ?? this.scopes;
2149
2191
  try {
2150
2192
  const i = await this.authApi.signIn(e, t, s);
2151
- return "requires_2fa" in i && i.requires_2fa === !0 || "tfa_token" in i && i.tfa_token ? (this.subscribeStore.notify(c.TwoFactorRequired, {
2152
- email: e.email || "",
2153
- challengeId: i.challenge_id || "",
2154
- tfaToken: i.tfa_token || ""
2155
- }), i) : (await this.processAuthResponse(i, e.scopes), this.subscribeStore.notify(c.SignIn, {
2193
+ return this.handlePendingSecondFactor(i, e.email) || (await this.processAuthResponse(i, e.scopes), this.subscribeStore.notify(c.SignIn, {
2156
2194
  tokens: i,
2157
2195
  parsedTokens: this.tokenCacheService.getParsedTokens()
2158
- }), await this.submitSessionCheck(), i);
2196
+ }), await this.submitSessionCheck()), i;
2159
2197
  } catch (i) {
2160
2198
  const n = {
2161
2199
  message: i instanceof Error ? i.message : "Sign in failed",
@@ -2166,7 +2204,7 @@ class Ir {
2166
2204
  }
2167
2205
  }
2168
2206
  async signUp(e) {
2169
- if (e.user.email && !se(e.user.email)) {
2207
+ if (e.user.email && !ne(e.user.email)) {
2170
2208
  const t = new Error("Invalid email format"), s = {
2171
2209
  message: "Invalid email format",
2172
2210
  originalError: t,
@@ -2174,7 +2212,7 @@ class Ir {
2174
2212
  };
2175
2213
  throw this.subscribeStore.notify(c.Error, s), t;
2176
2214
  }
2177
- if (e.user.phone_number && !ie(e.user.phone_number)) {
2215
+ if (e.user.phone_number && !oe(e.user.phone_number)) {
2178
2216
  const t = new Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), s = {
2179
2217
  message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
2180
2218
  originalError: t,
@@ -2185,10 +2223,10 @@ class Ir {
2185
2223
  this.subscribeStore.notify(c.RegisterStart, { email: e.user.email }), e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
2186
2224
  try {
2187
2225
  const t = await this.authApi.signUp(e);
2188
- return await this.processAuthResponse(t, e.scopes), this.subscribeStore.notify(c.Register, {
2226
+ return this.handlePendingSecondFactor(t, e.user.email) || (await this.processAuthResponse(t, e.scopes), this.subscribeStore.notify(c.Register, {
2189
2227
  tokens: t,
2190
2228
  parsedTokens: this.tokenCacheService.getParsedTokens()
2191
- }), await this.submitSessionCheck(), t;
2229
+ }), await this.submitSessionCheck()), t;
2192
2230
  } catch (t) {
2193
2231
  const s = {
2194
2232
  message: t instanceof Error ? t.message : "Sign up failed",
@@ -2199,7 +2237,7 @@ class Ir {
2199
2237
  }
2200
2238
  }
2201
2239
  async passwordlessSignIn(e) {
2202
- if (e.email && !se(e.email)) {
2240
+ if (e.email && !ne(e.email)) {
2203
2241
  const i = new Error("Invalid email format"), n = {
2204
2242
  message: "Invalid email format",
2205
2243
  originalError: i,
@@ -2207,7 +2245,7 @@ class Ir {
2207
2245
  };
2208
2246
  throw this.subscribeStore.notify(c.Error, n), i;
2209
2247
  }
2210
- if (e.phone && !ie(e.phone)) {
2248
+ if (e.phone && !oe(e.phone)) {
2211
2249
  const i = new Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), n = {
2212
2250
  message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
2213
2251
  originalError: i,
@@ -2232,10 +2270,10 @@ class Ir {
2232
2270
  this.subscribeStore.notify(c.SignInStart, {}), e.scopes = e.scopes ?? this.scopes, e.device = this.deviceService.getDeviceId();
2233
2271
  try {
2234
2272
  const t = await this.authApi.passwordlessSignInComplete(e);
2235
- return await this.processAuthResponse(t, e.scopes), this.subscribeStore.notify(c.SignIn, {
2273
+ return this.handlePendingSecondFactor(t) || (await this.processAuthResponse(t, e.scopes), this.subscribeStore.notify(c.SignIn, {
2236
2274
  tokens: t,
2237
2275
  parsedTokens: this.tokenCacheService.getParsedTokens()
2238
- }), await this.submitSessionCheck(), t;
2276
+ }), await this.submitSessionCheck()), t;
2239
2277
  } catch (t) {
2240
2278
  const s = {
2241
2279
  message: t instanceof Error ? t.message : "Passwordless sign in failed",
@@ -2278,7 +2316,7 @@ class Ir {
2278
2316
  const e = this.storageManager.getToken(b.access_token);
2279
2317
  if (e)
2280
2318
  try {
2281
- return Sr(T(e));
2319
+ return _r(T(e));
2282
2320
  } catch {
2283
2321
  return;
2284
2322
  }
@@ -2305,7 +2343,7 @@ class Ir {
2305
2343
  * state — two different axes.
2306
2344
  */
2307
2345
  assertSessionPin(e) {
2308
- if (e && !br(e, this.readSessionPin()))
2346
+ if (e && !Er(e, this.readSessionPin()))
2309
2347
  throw console.warn(
2310
2348
  "[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."
2311
2349
  ), new $("The session changed during verification, so the elevated tokens were discarded");
@@ -2398,13 +2436,13 @@ class Ir {
2398
2436
  message: n instanceof Error ? n.message : "Token refresh failed",
2399
2437
  originalError: n,
2400
2438
  code: n instanceof w ? n.id : void 0,
2401
- details: B.isAxiosError(n) && n.response ? {
2439
+ details: K.isAxiosError(n) && n.response ? {
2402
2440
  status: n.response.status,
2403
2441
  data: n.response.data
2404
2442
  } : void 0
2405
2443
  };
2406
2444
  this.subscribeStore.notify(c.Error, o);
2407
- const a = B.isAxiosError(n) && n.response?.status && n.response.status >= 400 && n.response.status < 500;
2445
+ const a = K.isAxiosError(n) && n.response?.status && n.response.status >= 400 && n.response.status < 500;
2408
2446
  throw a && !e && (this.tokenCacheService.tokenExpiredFlag = !0, this.tokenCacheService.setTokensCache(void 0), this.storageManager.deleteTokens(), this.subscribeStore.notify(c.SessionExpired, { reason: "refresh_failed" })), n instanceof w ? n : a && !e ? new Error(`Getting unknown error message from server with code:${n.response?.status}`) : n;
2409
2447
  }
2410
2448
  }
@@ -2425,10 +2463,10 @@ class Ir {
2425
2463
  const i = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("token") ?? void 0, n = t ?? this.scopes;
2426
2464
  try {
2427
2465
  const o = await this.authApi.resetPassword(e, n, i);
2428
- return await this.processAuthResponse(o, n), this.subscribeStore.notify(c.SignIn, {
2466
+ return this.handlePendingSecondFactor(o) || (await this.processAuthResponse(o, n), this.subscribeStore.notify(c.SignIn, {
2429
2467
  tokens: o,
2430
2468
  parsedTokens: this.tokenCacheService.getParsedTokens()
2431
- }), await this.submitSessionCheck(), o;
2469
+ }), await this.submitSessionCheck()), o;
2432
2470
  } catch (o) {
2433
2471
  const a = {
2434
2472
  message: o instanceof Error ? o.message : "Password reset failed",
@@ -2454,10 +2492,10 @@ class Ir {
2454
2492
  i,
2455
2493
  !this.appId
2456
2494
  );
2457
- return await this.processAuthResponse(a, e.scopes), this.subscribeStore.notify(c.Register, {
2495
+ return this.handlePendingSecondFactor(a) || (await this.processAuthResponse(a, e.scopes), this.subscribeStore.notify(c.Register, {
2458
2496
  tokens: a,
2459
2497
  parsedTokens: this.tokenCacheService.getParsedTokens()
2460
- }), await this.submitSessionCheck(), a;
2498
+ }), await this.submitSessionCheck()), a;
2461
2499
  } catch (i) {
2462
2500
  const n = {
2463
2501
  message: i instanceof Error ? i.message : "Passkey registration failed",
@@ -2481,7 +2519,7 @@ class Ir {
2481
2519
  i,
2482
2520
  !this.appId
2483
2521
  );
2484
- return "access_token" in a && (await this.processAuthResponse(a, e.scopes), this.subscribeStore.notify(c.SignIn, {
2522
+ return this.handlePendingSecondFactor(a) || "access_token" in a && (await this.processAuthResponse(a, e.scopes), this.subscribeStore.notify(c.SignIn, {
2485
2523
  tokens: a,
2486
2524
  parsedTokens: this.tokenCacheService.getParsedTokens()
2487
2525
  }), await this.submitSessionCheck()), a;
@@ -2514,20 +2552,23 @@ class Ir {
2514
2552
  const n = await this.platform.openAuthUrl(i, {
2515
2553
  mode: "popup",
2516
2554
  expectedReturnOrigin: this.platform.getCurrentUrl()?.origin ?? ""
2517
- }), o = new URLSearchParams(n.callbackSearch), a = o.get("access_token") || "", h = o.get("refresh_token") || "", p = o.get("id_token") || "", m = {
2518
- access_token: a,
2519
- refresh_token: h || void 0,
2520
- id_token: p || void 0,
2555
+ }), o = new URLSearchParams(n.callbackHash.replace(/^#/, ""));
2556
+ if (this.handlePendingSecondFactor({ tfa_token: o.get("tfa_token") ?? void 0 }))
2557
+ return;
2558
+ const a = new URLSearchParams(n.callbackSearch), h = a.get("access_token") || "", p = a.get("refresh_token") || "", m = a.get("id_token") || "", d = {
2559
+ access_token: h,
2560
+ refresh_token: p || void 0,
2561
+ id_token: m || void 0,
2521
2562
  scopes: t
2522
2563
  };
2523
- await this.processAuthResponse(m, t), this.subscribeStore.notify(c.SignIn, {
2524
- tokens: m,
2564
+ await this.processAuthResponse(d, t), this.subscribeStore.notify(c.SignIn, {
2565
+ tokens: d,
2525
2566
  parsedTokens: this.tokenCacheService.getParsedTokens()
2526
2567
  }), this.platform.navigateTo(this.platform.getCurrentUrl()?.origin ?? "");
2527
2568
  } catch (n) {
2528
2569
  const o = {
2529
2570
  message: n instanceof Error ? n.message : "Authentication failed",
2530
- code: n instanceof qe ? "POPUP_CLOSED" : "AUTH_FAILED",
2571
+ code: n instanceof Be ? "POPUP_CLOSED" : "AUTH_FAILED",
2531
2572
  originalError: n
2532
2573
  };
2533
2574
  this.subscribeStore.notify(c.Error, o);
@@ -2628,7 +2669,7 @@ class Ir {
2628
2669
  }
2629
2670
  }
2630
2671
  }
2631
- class Ar {
2672
+ class Fr {
2632
2673
  constructor(e) {
2633
2674
  this.invitationApi = e;
2634
2675
  }
@@ -2673,7 +2714,7 @@ class Ar {
2673
2714
  return this.invitationApi.getInvitationLink(e);
2674
2715
  }
2675
2716
  }
2676
- class Cr {
2717
+ class Pr {
2677
2718
  error(e, ...t) {
2678
2719
  console.error(e, ...t);
2679
2720
  }
@@ -2687,10 +2728,10 @@ class Cr {
2687
2728
  console.debug(e, ...t);
2688
2729
  }
2689
2730
  }
2690
- function Rr() {
2691
- return new Cr();
2731
+ function Mr() {
2732
+ return new Pr();
2692
2733
  }
2693
- class Fr {
2734
+ class Dr {
2694
2735
  constructor(e) {
2695
2736
  this.data = this.normalize(e);
2696
2737
  }
@@ -2760,9 +2801,9 @@ class Fr {
2760
2801
  return this.data;
2761
2802
  }
2762
2803
  }
2763
- class Mr {
2804
+ class Ur {
2764
2805
  constructor(e, t, s) {
2765
- this.tenantApi = e, this.scopes = t, this.logger = s || Rr();
2806
+ this.tenantApi = e, this.scopes = t, this.logger = s || Mr();
2766
2807
  }
2767
2808
  /**
2768
2809
  * Handle Passflow API errors
@@ -2771,7 +2812,7 @@ class Mr {
2771
2812
  * @throws Formatted error with Passflow API error details
2772
2813
  */
2773
2814
  handlePassflowError(e, t) {
2774
- if (B.isAxiosError(e) && e.response?.data) {
2815
+ if (K.isAxiosError(e) && e.response?.data) {
2775
2816
  const s = e.response.data;
2776
2817
  if (typeof s == "object" && s !== null && "error" in s && typeof s.error == "object" && s.error !== null) {
2777
2818
  const i = s.error;
@@ -2832,7 +2873,7 @@ class Mr {
2832
2873
  async getTenantUserMembership(e) {
2833
2874
  try {
2834
2875
  const t = await this.tenantApi.getTenantDetails(e);
2835
- return new Fr(t);
2876
+ return new Dr(t);
2836
2877
  } catch (t) {
2837
2878
  this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
2838
2879
  }
@@ -3130,8 +3171,8 @@ class Mr {
3130
3171
  }
3131
3172
  }
3132
3173
  }
3133
- class Pr {
3134
- constructor(e, t, s, i = z) {
3174
+ class xr {
3175
+ constructor(e, t, s, i = Y) {
3135
3176
  this.storageManager = e, this.authApi = t, this.subscribeStore = s, this.platform = i, this.checkInterval = null, this.CHECK_INTERVAL = 6e4, this.unsubscribeForeground = null, this.unsubscribeUnload = null, this.isRefreshing = !1, this.tokenExpiredFlag = !1, this.storageManager = e, this.authApi = t, this.setupLifecycleListeners();
3136
3177
  }
3137
3178
  initialize() {
@@ -3229,7 +3270,7 @@ class Pr {
3229
3270
  return C(e);
3230
3271
  }
3231
3272
  }
3232
- class Ur {
3273
+ class Or {
3233
3274
  constructor(e, t) {
3234
3275
  this.twoFactorApi = e, this.subscribeStore = t, this.PARTIAL_AUTH_TIMEOUT_MS = 300 * 1e3, this.SESSION_STORAGE_KEY = "passflow_2fa_challenge", this.totpDigits = 6;
3235
3276
  const s = {
@@ -3238,9 +3279,14 @@ class Ur {
3238
3279
  const o = n;
3239
3280
  this.setPartialAuthState(o.email, o.challengeId, o.tfaToken);
3240
3281
  }
3282
+ (i === c.SignIn || i === c.Register) && this.clearPartialAuthState();
3241
3283
  }
3242
3284
  };
3243
- this.subscribeStore.subscribe(s, [c.TwoFactorRequired]);
3285
+ this.subscribeStore.subscribe(s, [
3286
+ c.TwoFactorRequired,
3287
+ c.SignIn,
3288
+ c.Register
3289
+ ]);
3244
3290
  }
3245
3291
  /**
3246
3292
  * Emit error event and throw the error
@@ -3282,7 +3328,7 @@ class Ur {
3282
3328
  * Returns recovery codes that MUST be displayed to user
3283
3329
  */
3284
3330
  async confirmSetup(e) {
3285
- if (!W(e, this.totpDigits))
3331
+ if (!J(e, this.totpDigits))
3286
3332
  throw new Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
3287
3333
  try {
3288
3334
  const t = await this.twoFactorApi.confirmSetup({ code: e });
@@ -3299,57 +3345,63 @@ class Ur {
3299
3345
  /**
3300
3346
  * Verify TOTP code during login
3301
3347
  * Completes authentication if successful
3348
+ *
3349
+ * @param options.trustDevice - ask the server to trust this device for later sign-ins
3302
3350
  */
3303
- async verify(e) {
3304
- if (!W(e, this.totpDigits))
3351
+ async verify(e, t) {
3352
+ if (!J(e, this.totpDigits))
3305
3353
  throw new Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
3306
3354
  if (this.recoverPartialAuthState(), !this.isVerificationRequired())
3307
3355
  throw new Error("2FA verification expired or not required. User must sign in first.");
3308
3356
  if (!this.partialAuthState?.tfaToken)
3309
3357
  throw new Error("No TFA token found. User must sign in first.");
3310
3358
  try {
3311
- const t = await this.twoFactorApi.verify({
3359
+ const s = await this.twoFactorApi.verify({
3312
3360
  code: e,
3313
- tfa_token: this.partialAuthState.tfaToken
3361
+ tfa_token: this.partialAuthState.tfaToken,
3362
+ ...t?.trustDevice ? { trust_device: !0 } : {}
3314
3363
  });
3315
- return this.clearPartialAuthState(), this.subscribeStore.notify(c.TwoFactorVerified, { tokens: t }), t;
3316
- } catch (t) {
3317
- this.emitErrorAndThrow(t, "Verify 2FA code");
3364
+ return this.clearPartialAuthState(), this.subscribeStore.notify(c.TwoFactorVerified, { tokens: s }), s;
3365
+ } catch (s) {
3366
+ this.emitErrorAndThrow(s, "Verify 2FA code");
3318
3367
  }
3319
3368
  }
3320
3369
  /**
3321
3370
  * Use recovery code for authentication
3322
3371
  * Completes authentication if successful
3372
+ *
3373
+ * @param options.trustDevice - ask the server to trust this device for later sign-ins
3323
3374
  */
3324
- async useRecoveryCode(e) {
3375
+ async useRecoveryCode(e, t) {
3325
3376
  try {
3326
- const t = Er(e);
3327
- if (!t)
3377
+ const s = Cr(e);
3378
+ if (!s)
3328
3379
  throw new Error("Invalid recovery code format. Expected format: XXXX-XXXX or XXXXXXXX (alphanumeric).");
3329
3380
  if (this.recoverPartialAuthState(), !this.isVerificationRequired())
3330
3381
  throw new Error("2FA verification expired or not required. User must sign in first.");
3331
3382
  if (!this.partialAuthState?.tfaToken)
3332
3383
  throw new Error("No TFA token found. User must sign in first.");
3333
- const s = await this.twoFactorApi.useRecoveryCode({
3334
- recovery_code: t,
3335
- tfa_token: this.partialAuthState.tfaToken
3384
+ const i = await this.twoFactorApi.useRecoveryCode({
3385
+ recovery_code: s,
3386
+ tfa_token: this.partialAuthState.tfaToken,
3387
+ ...t?.trustDevice ? { trust_device: !0 } : {}
3336
3388
  });
3337
- return this.clearPartialAuthState(), s.remaining_recovery_codes === 0 ? this.subscribeStore.notify(c.TwoFactorRecoveryCodesExhausted, { tokens: s }) : s.remaining_recovery_codes <= 2 && this.subscribeStore.notify(c.TwoFactorRecoveryCodesLow, {
3338
- tokens: s,
3339
- remainingCodes: s.remaining_recovery_codes
3389
+ return this.clearPartialAuthState(), i.remaining_recovery_codes === 0 ? this.subscribeStore.notify(c.TwoFactorRecoveryCodesExhausted, { tokens: i }) : i.remaining_recovery_codes <= 2 && this.subscribeStore.notify(c.TwoFactorRecoveryCodesLow, {
3390
+ tokens: i,
3391
+ remainingCodes: i.remaining_recovery_codes
3340
3392
  }), this.subscribeStore.notify(c.TwoFactorRecoveryUsed, {
3341
- tokens: s,
3342
- remainingCodes: s.remaining_recovery_codes
3343
- }), this.subscribeStore.notify(c.TwoFactorVerified, { tokens: s }), s;
3344
- } catch (t) {
3345
- this.emitErrorAndThrow(t, "Use recovery code");
3393
+ tokens: i,
3394
+ remainingCodes: i.remaining_recovery_codes
3395
+ }), this.subscribeStore.notify(c.TwoFactorVerified, { tokens: i }), i;
3396
+ } catch (s) {
3397
+ this.emitErrorAndThrow(s, "Use recovery code");
3346
3398
  }
3347
3399
  }
3348
3400
  /**
3349
3401
  * Disable 2FA (requires TOTP verification)
3350
3402
  */
3351
3403
  async disable(e) {
3352
- if (!W(e, this.totpDigits))
3404
+ if (!J(e, this.totpDigits))
3353
3405
  throw new Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
3354
3406
  try {
3355
3407
  const t = await this.twoFactorApi.disable({ code: e });
@@ -3362,7 +3414,7 @@ class Ur {
3362
3414
  * Regenerate recovery codes
3363
3415
  */
3364
3416
  async regenerateRecoveryCodes(e) {
3365
- if (!W(e, this.totpDigits))
3417
+ if (!J(e, this.totpDigits))
3366
3418
  throw new Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
3367
3419
  try {
3368
3420
  const t = await this.twoFactorApi.regenerateRecoveryCodes({ code: e }), s = [...t.recovery_codes];
@@ -3406,6 +3458,12 @@ class Ur {
3406
3458
  } catch {
3407
3459
  }
3408
3460
  }
3461
+ /**
3462
+ * The 2FA token of the sign-in waiting on its second factor, if any.
3463
+ */
3464
+ pendingTfaToken() {
3465
+ return this.isVerificationRequired() && this.partialAuthState?.tfaToken || void 0;
3466
+ }
3409
3467
  /**
3410
3468
  * Attempt to recover partial auth state from sessionStorage
3411
3469
  * Called before verification operations to handle page refresh
@@ -3564,7 +3622,7 @@ class Ur {
3564
3622
  */
3565
3623
  async requestChallenge(e) {
3566
3624
  try {
3567
- const t = await this.twoFactorApi.requestChallenge(e);
3625
+ const t = await this.twoFactorApi.requestChallenge(e, this.pendingTfaToken());
3568
3626
  return this.subscribeStore.notify(c.TwoFactorChallengeReceived, {
3569
3627
  challengeId: t.challenge_id,
3570
3628
  method: t.method,
@@ -3576,11 +3634,12 @@ class Ur {
3576
3634
  }
3577
3635
  /**
3578
3636
  * Verify 2FA challenge (v2)
3637
+ * Set `trust_device` on the payload to ask the server to trust this device.
3579
3638
  */
3580
3639
  async verifyV2(e) {
3581
3640
  try {
3582
- const t = await this.twoFactorApi.verifyV2(e);
3583
- return t.success && (this.subscribeStore.notify(c.TwoFactorVerified, {
3641
+ const t = await this.twoFactorApi.verifyV2(e, this.pendingTfaToken());
3642
+ return t.success && (this.clearPartialAuthState(), this.subscribeStore.notify(c.TwoFactorVerified, {
3584
3643
  tokens: {
3585
3644
  access_token: t.access_token,
3586
3645
  refresh_token: t.refresh_token
@@ -3595,7 +3654,7 @@ class Ur {
3595
3654
  */
3596
3655
  async switchToAlternative(e) {
3597
3656
  try {
3598
- const t = await this.twoFactorApi.switchToAlternative(e);
3657
+ const t = await this.twoFactorApi.switchToAlternative(e, this.pendingTfaToken());
3599
3658
  return this.subscribeStore.notify(c.TwoFactorMethodSwitched, {
3600
3659
  challengeId: t.challenge_id,
3601
3660
  method: t.method,
@@ -3606,7 +3665,8 @@ class Ur {
3606
3665
  }
3607
3666
  }
3608
3667
  /**
3609
- * Get trusted devices
3668
+ * List the devices the user trusted to skip the second factor on this app.
3669
+ * The one this request came from has `current: true`.
3610
3670
  */
3611
3671
  async getTrustedDevices() {
3612
3672
  try {
@@ -3616,7 +3676,8 @@ class Ur {
3616
3676
  }
3617
3677
  }
3618
3678
  /**
3619
- * Revoke trusted device
3679
+ * Revoke a trusted device; its next sign-in asks for the second factor again.
3680
+ * Rejects with the server's 404 when the user has no such device.
3620
3681
  */
3621
3682
  async revokeTrustedDevice(e) {
3622
3683
  try {
@@ -3626,8 +3687,8 @@ class Ur {
3626
3687
  }
3627
3688
  }
3628
3689
  }
3629
- class Dr {
3630
- constructor(e, t, s = z) {
3690
+ class Lr {
3691
+ constructor(e, t, s = Y) {
3631
3692
  this.userAPI = e, this.deviceService = t, this.platform = s;
3632
3693
  }
3633
3694
  /**
@@ -3678,85 +3739,85 @@ class Dr {
3678
3739
  return await this.userAPI.addUserPasskeyComplete(h, i, o);
3679
3740
  }
3680
3741
  }
3681
- class D extends Error {
3742
+ class U extends Error {
3682
3743
  constructor(e, t, s = !1) {
3683
3744
  super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = s;
3684
3745
  }
3685
3746
  }
3686
- const Je = (r, e) => {
3747
+ const et = (r, e) => {
3687
3748
  const t = e?.trim();
3688
3749
  if (!t)
3689
- throw new D(r, "A verification code is required");
3750
+ throw new U(r, "A verification code is required");
3690
3751
  return t;
3691
- }, xr = {
3752
+ }, $r = {
3692
3753
  type: "totp",
3693
3754
  requiresPrepare: !1,
3694
3755
  input: "code",
3695
- assert: async ({ code: r }) => ({ code: Je("totp", r) })
3696
- }, Or = {
3756
+ assert: async ({ code: r }) => ({ code: et("totp", r) })
3757
+ }, qr = {
3697
3758
  type: "recovery_codes",
3698
3759
  requiresPrepare: !1,
3699
3760
  input: "code",
3700
- assert: async ({ code: r }) => ({ code: Je("recovery_codes", r) })
3701
- }, Lr = {
3761
+ assert: async ({ code: r }) => ({ code: et("recovery_codes", r) })
3762
+ }, Nr = {
3702
3763
  type: "passkey",
3703
3764
  requiresPrepare: !0,
3704
3765
  input: "none",
3705
3766
  assert: async ({ prepared: r, platform: e }) => {
3706
3767
  if (!r?.webauthn)
3707
- throw new D("passkey", "The upgrade challenge carried no WebAuthn options");
3768
+ throw new U("passkey", "The upgrade challenge carried no WebAuthn options");
3708
3769
  const t = e.passkeys;
3709
3770
  if (!t)
3710
- throw new D("passkey", "This platform does not support passkeys");
3771
+ throw new U("passkey", "This platform does not support passkeys");
3711
3772
  let s;
3712
3773
  try {
3713
3774
  s = await t.startAuthentication(r.webauthn);
3714
3775
  } catch (i) {
3715
- throw new D("passkey", i?.message || "Passkey verification was cancelled", !0);
3776
+ throw new U("passkey", i?.message || "Passkey verification was cancelled", !0);
3716
3777
  }
3717
3778
  if (!s)
3718
- throw new D("passkey", "Passkey verification was cancelled", !0);
3779
+ throw new U("passkey", "Passkey verification was cancelled", !0);
3719
3780
  return { challenge_id: r.challengeId, credential: s };
3720
3781
  }
3721
- }, ye = Object.freeze([
3722
- xr,
3723
- Lr,
3724
- Or
3725
- ]), $r = (r = ye) => new Map(r.map((e) => [e.type, e])), qr = 3, Nr = {
3782
+ }, Se = Object.freeze([
3783
+ $r,
3784
+ Nr,
3785
+ qr
3786
+ ]), Vr = (r = Se) => new Map(r.map((e) => [e.type, e])), Br = 3, Kr = {
3726
3787
  passkey: 0,
3727
3788
  totp: 1,
3728
3789
  email_otp: 2,
3729
3790
  sms_otp: 3,
3730
3791
  recovery_codes: 9
3731
- }, Vr = (r) => r.requiredLevel ?? $t(r.acrValues), Ie = (r, e) => {
3732
- const t = Nr[r.type] ?? 5, s = e !== void 0 && e >= qr, i = r.type === "passkey";
3792
+ }, jr = (r) => r.requiredLevel ?? Vt(r.acrValues), Re = (r, e) => {
3793
+ const t = Kr[r.type] ?? 5, s = e !== void 0 && e >= Br, i = r.type === "passkey";
3733
3794
  return (s && !i ? 100 : 0) + t;
3734
- }, Br = (r, e) => {
3735
- const t = Vr(e);
3736
- return [...r].sort((s, i) => Ie(s, t) - Ie(i, t));
3795
+ }, Gr = (r, e) => {
3796
+ const t = jr(e);
3797
+ return [...r].sort((s, i) => Re(s, t) - Re(i, t));
3737
3798
  };
3738
3799
  class O extends Error {
3739
3800
  constructor(e) {
3740
3801
  super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
3741
3802
  }
3742
3803
  }
3743
- class Z extends Error {
3804
+ class ee extends Error {
3744
3805
  constructor(e = "No available authentication factor can satisfy this challenge") {
3745
3806
  super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
3746
3807
  }
3747
3808
  }
3748
- const Kr = 4, jr = 3e4, Gr = () => {
3809
+ const Hr = 4, zr = 3e4, Yr = () => {
3749
3810
  let r = () => {
3750
3811
  }, e = () => {
3751
3812
  };
3752
3813
  return { promise: new Promise((s, i) => {
3753
3814
  r = s, e = i;
3754
3815
  }), resolve: r, reject: e };
3755
- }, G = (r) => ({
3816
+ }, H = (r) => ({
3756
3817
  acrValues: r.acrValues,
3757
3818
  level: r.requiredLevel,
3758
3819
  maxAge: r.maxAge
3759
- }), Hr = (r, e) => e.level === void 0 ? !0 : r.level === void 0 ? !1 : r.level >= e.level, zr = (r, e) => {
3820
+ }), Wr = (r, e) => e.level === void 0 ? !0 : r.level === void 0 ? !1 : r.level >= e.level, Xr = (r, e) => {
3760
3821
  const t = r.requiredLevel === void 0 ? e.requiredLevel : e.requiredLevel === void 0 ? r.requiredLevel : Math.max(r.requiredLevel, e.requiredLevel), s = t === void 0 ? r.acrValues ?? e.acrValues : t === r.requiredLevel ? r.acrValues : e.acrValues, i = r.maxAge === void 0 ? e.maxAge : e.maxAge === void 0 ? r.maxAge : Math.min(r.maxAge, e.maxAge), n = Array.from(/* @__PURE__ */ new Set([...r.channels ?? [], ...e.channels ?? []]));
3761
3822
  return {
3762
3823
  acrValues: s,
@@ -3765,13 +3826,13 @@ const Kr = 4, jr = 3e4, Gr = () => {
3765
3826
  status: r.status,
3766
3827
  ...n.length > 0 ? { channels: n } : {}
3767
3828
  };
3768
- }, Yr = (r, e) => {
3829
+ }, Jr = (r, e) => {
3769
3830
  const t = e.requiredLevel !== void 0 && (r.requiredLevel === void 0 || e.requiredLevel > r.requiredLevel), s = e.maxAge !== void 0 && (r.maxAge === void 0 || e.maxAge < r.maxAge);
3770
3831
  return t || s;
3771
3832
  };
3772
- class Wr {
3833
+ class Zr {
3773
3834
  constructor(e) {
3774
- 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 ?? ye, this.registry = $r(this.available), this.maxAttempts = e.maxAttempts ?? Kr, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? jr;
3835
+ 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 ?? Se, this.registry = Vr(this.available), this.maxAttempts = e.maxAttempts ?? Hr, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? zr;
3775
3836
  }
3776
3837
  /** The current lifecycle state. Read-only. */
3777
3838
  get currentState() {
@@ -3808,9 +3869,9 @@ class Wr {
3808
3869
  /** Registers a waiter and the bar it arrived demanding. */
3809
3870
  register(e, t) {
3810
3871
  const s = t.kind === "imperative" && t.requested !== void 0, n = {
3811
- demanded: t.kind === "imperative" && t.requested ? t.requested : G(e),
3872
+ demanded: t.kind === "imperative" && t.requested ? t.requested : H(e),
3812
3873
  statedBar: s,
3813
- settlement: Gr(),
3874
+ settlement: Yr(),
3814
3875
  reported: !1,
3815
3876
  entry: {
3816
3877
  ...t,
@@ -3838,13 +3899,13 @@ class Wr {
3838
3899
  this.requirement = e;
3839
3900
  return;
3840
3901
  }
3841
- const s = Yr(t, e);
3842
- this.requirement = zr(t, e), s && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({ challenge: this.requirement, factors: this.offeredFactors() });
3902
+ const s = Jr(t, e);
3903
+ this.requirement = Xr(t, e), s && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({ challenge: this.requirement, factors: this.offeredFactors() });
3843
3904
  }
3844
3905
  /** The factors to offer right now: ranked for the merged bar, minus what the server refused. */
3845
3906
  offeredFactors() {
3846
3907
  const e = this.available.filter((s) => !this.pruned.has(s.type)), t = this.requirement;
3847
- return t ? Br(e, t) : e;
3908
+ return t ? Gr(e, t) : e;
3848
3909
  }
3849
3910
  /** The waiter's inbound edge. Idempotent — a second call is ignored. */
3850
3911
  receiveReport(e, t) {
@@ -3912,8 +3973,8 @@ class Wr {
3912
3973
  */
3913
3974
  release(e, t) {
3914
3975
  if (e.entry.kind === "imperative") {
3915
- if (e.statedBar && !Hr(t, e.demanded)) {
3916
- this.receiveReport(e, { outcome: "insufficient", obtained: t, required: e.demanded }), e.settlement.reject(new K(t, e.demanded));
3976
+ if (e.statedBar && !Wr(t, e.demanded)) {
3977
+ this.receiveReport(e, { outcome: "insufficient", obtained: t, required: e.demanded }), e.settlement.reject(new j(t, e.demanded));
3917
3978
  return;
3918
3979
  }
3919
3980
  this.receiveReport(e, { outcome: "replayed", obtained: t }), e.settlement.resolve({ waiter: e.entry, obtained: t });
@@ -3988,7 +4049,7 @@ class Wr {
3988
4049
  for (let t = 0; t < this.maxAttempts; t++) {
3989
4050
  const s = this.offeredFactors();
3990
4051
  if (s.length === 0)
3991
- return { status: "failed", reason: new Z() };
4052
+ return { status: "failed", reason: new ee() };
3992
4053
  const i = this.requirement;
3993
4054
  let n;
3994
4055
  try {
@@ -4000,13 +4061,13 @@ class Wr {
4000
4061
  return { status: "failed", reason: new O() };
4001
4062
  const o = this.registry.get(n.factor);
4002
4063
  if (!o) {
4003
- e = new Z(`Unknown authentication factor: ${n.factor}`), this.state = "collecting", this.selected = null;
4064
+ e = new ee(`Unknown authentication factor: ${n.factor}`), this.state = "collecting", this.selected = null;
4004
4065
  continue;
4005
4066
  }
4006
4067
  try {
4007
- return await this.proveAndCommit(o, n.code), { status: "proven", obtained: this.readObtainedBar?.() ?? G(this.rankedRequirement ?? i) };
4068
+ return await this.proveAndCommit(o, n.code), { status: "proven", obtained: this.readObtainedBar?.() ?? H(this.rankedRequirement ?? i) };
4008
4069
  } catch (a) {
4009
- if (a instanceof D && a.cancelled)
4070
+ if (a instanceof U && a.cancelled)
4010
4071
  return { status: "failed", reason: new O() };
4011
4072
  const h = this.classifyProofFailure(a);
4012
4073
  if (h)
@@ -4036,12 +4097,12 @@ class Wr {
4036
4097
  }
4037
4098
  /** Maps a proof failure to a terminal reason, or `undefined` when the user may retry. */
4038
4099
  classifyProofFailure(e) {
4039
- if (e instanceof K || e instanceof j || e instanceof $)
4100
+ if (e instanceof j || e instanceof G || e instanceof $)
4040
4101
  return e;
4041
4102
  if (e instanceof _)
4042
4103
  switch (e.kind) {
4043
4104
  case "unavailable":
4044
- return new j(e.message);
4105
+ return new G(e.message);
4045
4106
  case "exhausted":
4046
4107
  case "attempts_exhausted":
4047
4108
  case "fatal":
@@ -4060,14 +4121,14 @@ class Wr {
4060
4121
  await this.transport.commit(e.type, i);
4061
4122
  }
4062
4123
  }
4063
- const Ze = "https://passflow-relative.invalid", Xr = () => {
4124
+ const tt = "https://passflow-relative.invalid", Qr = () => {
4064
4125
  const r = globalThis, e = r.document?.baseURI;
4065
4126
  if (typeof e == "string" && e !== "")
4066
4127
  return e;
4067
4128
  const t = r.location?.href;
4068
- return typeof t == "string" && t !== "" && t !== "about:blank" ? t : Ze;
4069
- }, Ae = (r, e = Xr()) => {
4070
- const t = e === Ze;
4129
+ return typeof t == "string" && t !== "" && t !== "about:blank" ? t : tt;
4130
+ }, Fe = (r, e = Qr()) => {
4131
+ const t = e === tt;
4071
4132
  let s;
4072
4133
  try {
4073
4134
  s = new URL(e).origin;
@@ -4092,32 +4153,32 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4092
4153
  relativeToBase: s !== void 0 && i.origin === s,
4093
4154
  sentinelBase: t
4094
4155
  };
4095
- }, ne = (r, e) => typeof e == "string" ? [r.toLowerCase(), e] : void 0, Jr = (r) => {
4156
+ }, ae = (r, e) => typeof e == "string" ? [r.toLowerCase(), e] : void 0, es = (r) => {
4096
4157
  const e = [];
4097
4158
  if (r == null)
4098
4159
  return Object.freeze(e);
4099
4160
  const t = r;
4100
4161
  if (typeof t.forEach == "function" && typeof t.entries == "function")
4101
4162
  return r.forEach((s, i) => {
4102
- const n = ne(i, s);
4163
+ const n = ae(i, s);
4103
4164
  n && e.push(n);
4104
4165
  }), Object.freeze(e);
4105
4166
  if (Array.isArray(r)) {
4106
4167
  for (const s of r)
4107
4168
  if (Array.isArray(s) && s.length >= 2) {
4108
- const i = ne(String(s[0]), s[1]);
4169
+ const i = ae(String(s[0]), s[1]);
4109
4170
  i && e.push(i);
4110
4171
  }
4111
4172
  return Object.freeze(e);
4112
4173
  }
4113
4174
  if (typeof r == "object")
4114
4175
  for (const [s, i] of Object.entries(r)) {
4115
- const n = Array.isArray(i) ? i.join(", ") : i, o = ne(s, n);
4176
+ const n = Array.isArray(i) ? i.join(", ") : i, o = ae(s, n);
4116
4177
  o && e.push(o);
4117
4178
  }
4118
4179
  return Object.freeze(e);
4119
- }, Qe = (r) => {
4120
- const e = r.base === void 0 ? Ae(r.url) : Ae(r.url, r.base), t = {
4180
+ }, rt = (r) => {
4181
+ const e = r.base === void 0 ? Fe(r.url) : Fe(r.url, r.base), t = {
4121
4182
  raw: r.url,
4122
4183
  href: e.href,
4123
4184
  dispatchUrl: e.sentinelBase || !e.resolved ? r.url : e.href,
@@ -4126,25 +4187,25 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4126
4187
  resolved: e.resolved,
4127
4188
  relativeToBase: e.relativeToBase,
4128
4189
  method: (r.method ?? "GET").toUpperCase(),
4129
- headers: Jr(r.headers),
4190
+ headers: es(r.headers),
4130
4191
  bodyKind: r.bodyKind,
4131
4192
  ..."body" in r ? { body: r.body } : {}
4132
4193
  };
4133
4194
  return Object.freeze(t);
4134
- }, et = (r, e) => {
4195
+ }, st = (r, e) => {
4135
4196
  if (!e || e.from === e.to)
4136
4197
  return r;
4137
4198
  let t = !1;
4138
4199
  const s = r.map(([i, n]) => i === "authorization" && n === e.from ? (t = !0, [i, e.to]) : [i, n]);
4139
4200
  return t ? Object.freeze(s) : r;
4140
- }, tt = (r) => {
4201
+ }, it = (r) => {
4141
4202
  const e = {};
4142
4203
  for (const [t, s] of r)
4143
4204
  e[t] = s;
4144
4205
  return e;
4145
- }, Zr = new Set(
4146
- ye.filter((r) => !r.requiresPrepare).map((r) => r.type)
4147
- ), Qr = (r) => {
4206
+ }, ts = new Set(
4207
+ Se.filter((r) => !r.requiresPrepare).map((r) => r.type)
4208
+ ), rs = (r) => {
4148
4209
  if (!r || typeof r != "object" || !r.challenge_id || !r.expires_at)
4149
4210
  throw new _({
4150
4211
  kind: "protocol",
@@ -4157,16 +4218,16 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4157
4218
  webauthn: r.webauthn,
4158
4219
  codeSentTo: r.code_sent_to
4159
4220
  };
4160
- }, Ce = (r) => Xe(r) && !mr(r), es = (r) => ({
4221
+ }, Pe = (r) => Qe(r) && !kr(r), ss = (r) => ({
4161
4222
  async prepare(e) {
4162
- if (!Zr.has(e))
4223
+ if (!ts.has(e))
4163
4224
  try {
4164
4225
  const t = r.relyingPartyId?.(), s = await r.startUpgrade(t ? { method: e, relying_party_id: t } : { method: e });
4165
- return Qr(s);
4226
+ return rs(s);
4166
4227
  } catch (t) {
4167
- if (Ce(t))
4228
+ if (Pe(t))
4168
4229
  throw t;
4169
- const s = Ee(t, "start");
4230
+ const s = Ce(t, "start");
4170
4231
  if (s.kind === "prepare_not_required")
4171
4232
  return;
4172
4233
  throw s;
@@ -4179,42 +4240,42 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4179
4240
  try {
4180
4241
  await r.commitRefresh({ type: e, assertion: t });
4181
4242
  } catch (i) {
4182
- if (Ce(i))
4243
+ if (Pe(i))
4183
4244
  throw i;
4184
- const n = Ee(i, "refresh");
4185
- throw n.status === 401 && wr(n) && r.markSessionInvalid?.(), n;
4245
+ const n = Ce(i, "refresh");
4246
+ throw n.status === 401 && Tr(n) && r.markSessionInvalid?.(), n;
4186
4247
  }
4187
4248
  }
4188
- }), rt = (r) => typeof r == "function" ? r() : r, Re = (r) => {
4249
+ }), nt = (r) => typeof r == "function" ? r() : r, Me = (r) => {
4189
4250
  try {
4190
4251
  return new URL(r);
4191
4252
  } catch {
4192
4253
  return;
4193
4254
  }
4194
- }, le = (r, e) => {
4255
+ }, fe = (r, e) => {
4195
4256
  if (!e || e === "/")
4196
4257
  return !0;
4197
4258
  const t = e.replace(/\/+$/, "");
4198
4259
  return r === t || r.startsWith(`${t}/`);
4199
- }, ts = (r, e) => !e || r.origin === void 0 ? !1 : r.origin === e.origin && le(r.pathname, e.pathPrefix), rs = (r, e) => {
4260
+ }, is = (r, e) => !e || r.origin === void 0 ? !1 : r.origin === e.origin && fe(r.pathname, e.pathPrefix), ns = (r, e) => {
4200
4261
  for (const t of e) {
4201
4262
  if (t === "")
4202
4263
  continue;
4203
4264
  if (t.startsWith("/")) {
4204
- if (r.relativeToBase && le(r.pathname, t))
4265
+ if (r.relativeToBase && fe(r.pathname, t))
4205
4266
  return !0;
4206
4267
  continue;
4207
4268
  }
4208
- const s = Re(t) ?? Re(`https://${t}`);
4209
- if (!(!s || r.origin === void 0) && r.origin === s.origin && le(r.pathname, s.pathname))
4269
+ const s = Me(t) ?? Me(`https://${t}`);
4270
+ if (!(!s || r.origin === void 0) && r.origin === s.origin && fe(r.pathname, s.pathname))
4210
4271
  return !0;
4211
4272
  }
4212
4273
  return !1;
4213
- }, Fe = (r, e, t) => ts(r, e.passflow) || rs(r, e.backend) ? t ? t(r.href) !== !1 : !0 : !1, st = (r) => {
4274
+ }, De = (r, e, t) => is(r, e.passflow) || ns(r, e.backend) ? t ? t(r.href) !== !1 : !0 : !1, ot = (r) => {
4214
4275
  const e = r.detail, t = e?.message ?? `[passflow] upgrade challenge not actioned: ${r.reason}`;
4215
4276
  console.warn(t, { status: r.status, url: r.url, reason: r.reason, detail: e });
4216
- }, ss = (r, e) => {
4217
- const t = e.onUpgradeDiagnostic ?? st;
4277
+ }, os = (r, e) => {
4278
+ const t = e.onUpgradeDiagnostic ?? ot;
4218
4279
  return (s, i) => {
4219
4280
  t({
4220
4281
  status: r.status,
@@ -4223,12 +4284,12 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4223
4284
  detail: { method: r.request.method, ...i ?? {} }
4224
4285
  });
4225
4286
  };
4226
- }, ue = (r, e, t) => {
4227
- const s = t.onUpgradeDiagnostic ?? st;
4287
+ }, ge = (r, e, t) => {
4288
+ const s = t.onUpgradeDiagnostic ?? ot;
4228
4289
  for (const i of r)
4229
4290
  s({ ...i, url: e.request.href, detail: { method: e.request.method, ...i.detail ?? {} } });
4230
- }, is = /\bjson\b/i, pe = async (r, e) => {
4231
- const t = e.requireChallengeChannel === "header", s = r.getHeader("content-type") ?? "", i = !t && is.test(s);
4291
+ }, as = /\bjson\b/i, ve = async (r, e) => {
4292
+ const t = e.requireChallengeChannel === "header", s = r.getHeader("content-type") ?? "", i = !t && as.test(s);
4232
4293
  let n;
4233
4294
  if (i)
4234
4295
  try {
@@ -4237,23 +4298,23 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4237
4298
  n = void 0;
4238
4299
  }
4239
4300
  const o = i ? { status: r.status, getHeader: (a) => r.getHeader(a) ?? void 0, body: n } : { status: r.status, getHeader: (a) => r.getHeader(a) ?? void 0 };
4240
- return ve(o, { requireChallengeChannel: e.requireChallengeChannel });
4241
- }, ns = (r) => ve(
4301
+ return we(o, { requireChallengeChannel: e.requireChallengeChannel });
4302
+ }, cs = (r) => we(
4242
4303
  { status: r.status, getHeader: (e) => r.getHeader(e) ?? void 0 },
4243
4304
  { requireChallengeChannel: "header" }
4244
- ).challenge, os = (r, e) => e.passflow === null ? `[passflow] a 401/403 from ${r} carried an upgrade challenge, but no Passflow endpoint is configured — set \`url\` on the Passflow config.` : `[passflow] a 401/403 from ${r} 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.`, as = (r, e) => r instanceof O ? { kind: "cancelled" } : r instanceof Z ? { kind: "unsatisfiable" } : r instanceof j ? { kind: "unavailable" } : r instanceof $ ? { kind: "session-changed" } : r instanceof K ? { kind: "insufficient", obtained: r.obtained, required: r.required } : r instanceof _ ? r.kind === "exhausted" || r.kind === "attempts_exhausted" ? { kind: "exhausted", error: r } : r.kind === "unavailable" ? { kind: "unavailable" } : r.kind === "session_changed" ? { kind: "session-changed" } : { kind: "transport-failure", status: r.status, retryable: r.retryable, error: r } : {
4305
+ ).challenge, hs = (r, e) => e.passflow === null ? `[passflow] a 401/403 from ${r} carried an upgrade challenge, but no Passflow endpoint is configured — set \`url\` on the Passflow config.` : `[passflow] a 401/403 from ${r} 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.`, ds = (r, e) => r instanceof O ? { kind: "cancelled" } : r instanceof ee ? { kind: "unsatisfiable" } : r instanceof G ? { kind: "unavailable" } : r instanceof $ ? { kind: "session-changed" } : r instanceof j ? { kind: "insufficient", obtained: r.obtained, required: r.required } : r instanceof _ ? r.kind === "exhausted" || r.kind === "attempts_exhausted" ? { kind: "exhausted", error: r } : r.kind === "unavailable" ? { kind: "unavailable" } : r.kind === "session_changed" ? { kind: "session-changed" } : { kind: "transport-failure", status: r.status, retryable: r.retryable, error: r } : {
4245
4306
  kind: "transport-failure",
4246
4307
  retryable: !1,
4247
4308
  error: r instanceof Error ? r : new Error(String(r))
4248
- }, cs = async (r, e, t, s) => {
4309
+ }, ls = async (r, e, t, s) => {
4249
4310
  if (r.status !== 401 && r.status !== 403)
4250
4311
  return { kind: "replayed", response: r };
4251
- const { challenge: i, diagnostics: n } = await pe(r, e);
4252
- if (ue(n, r, e), !i)
4312
+ const { challenge: i, diagnostics: n } = await ve(r, e);
4313
+ if (ge(n, r, e), !i)
4253
4314
  return { kind: "replayed", response: r };
4254
- const o = G(i);
4315
+ const o = H(i);
4255
4316
  return s("elevated-insufficient", { obtained: t, required: o }), { kind: "insufficient", obtained: t, required: o, response: r };
4256
- }, hs = async (r, e) => {
4317
+ }, us = async (r, e) => {
4257
4318
  if (!e)
4258
4319
  return { aborted: !1, value: await r };
4259
4320
  if (e.aborted)
@@ -4269,28 +4330,28 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4269
4330
  } finally {
4270
4331
  t && e.removeEventListener?.("abort", t);
4271
4332
  }
4272
- }, it = async (r, e) => {
4333
+ }, at = async (r, e) => {
4273
4334
  if (r.status !== 401 && r.status !== 403)
4274
4335
  return { kind: "not-a-challenge" };
4275
4336
  if (r.markers.upgradeTransaction)
4276
4337
  return { kind: "not-a-challenge" };
4277
- const t = ss(r, e);
4338
+ const t = os(r, e);
4278
4339
  if (r.markers.replayed) {
4279
- if (!Fe(r.request, e.scope, e.shouldIntercept))
4340
+ if (!De(r.request, e.scope, e.shouldIntercept))
4280
4341
  return { kind: "not-a-challenge" };
4281
- const { challenge: y, diagnostics: I } = await pe(r, e);
4282
- if (ue(I, r, e), !y)
4342
+ const { challenge: y, diagnostics: I } = await ve(r, e);
4343
+ if (ge(I, r, e), !y)
4283
4344
  return { kind: "not-a-challenge" };
4284
- const Y = e.readObtainedBar?.() ?? {}, Se = G(y);
4285
- return t("elevated-insufficient", { obtained: Y, required: Se }), { kind: "insufficient", obtained: Y, required: Se, response: r };
4345
+ const W = e.readObtainedBar?.() ?? {}, _e = H(y);
4346
+ return t("elevated-insufficient", { obtained: W, required: _e }), { kind: "insufficient", obtained: W, required: _e, response: r };
4286
4347
  }
4287
- if (!Fe(r.request, e.scope, e.shouldIntercept))
4288
- return ns(r) ? (t("challenge-out-of-scope", {
4348
+ if (!De(r.request, e.scope, e.shouldIntercept))
4349
+ return cs(r) ? (t("challenge-out-of-scope", {
4289
4350
  header: r.getHeader("www-authenticate") ?? void 0,
4290
- message: os(r.request.href, e.scope)
4351
+ message: hs(r.request.href, e.scope)
4291
4352
  }), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
4292
- const { challenge: s, diagnostics: i } = await pe(r, e);
4293
- if (ue(i, r, e), !s) {
4353
+ const { challenge: s, diagnostics: i } = await ve(r, e);
4354
+ if (ge(i, r, e), !s) {
4294
4355
  const u = r.getHeader("www-authenticate");
4295
4356
  return e.requireChallengeChannel !== "header" && t("no-channel", {
4296
4357
  ...u ? { header: u } : {},
@@ -4304,9 +4365,9 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4304
4365
  const n = e.authorizationSwap?.(), o = { kind: "request", url: r.request.href, method: r.request.method };
4305
4366
  let a, h;
4306
4367
  try {
4307
- a = Promise.resolve(e.elevate(s, o)), h = await hs(a, r.signal);
4368
+ a = Promise.resolve(e.elevate(s, o)), h = await us(a, r.signal);
4308
4369
  } catch (u) {
4309
- return as(u);
4370
+ return ds(u);
4310
4371
  }
4311
4372
  if (h.aborted)
4312
4373
  return a?.then(
@@ -4317,32 +4378,32 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4317
4378
  const p = h.value;
4318
4379
  if (r.signal?.aborted)
4319
4380
  return p?.waiter.report({ outcome: "failed" }), { kind: "aborted", reason: r.signal.reason };
4320
- const m = p?.obtained ?? e.readObtainedBar?.() ?? G(s), d = e.authorizationSwap?.(), g = d ? { from: n?.from ?? d.from, to: d.to } : void 0;
4381
+ const m = p?.obtained ?? e.readObtainedBar?.() ?? H(s), d = e.authorizationSwap?.(), g = d ? { from: n?.from ?? d.from, to: d.to } : void 0;
4321
4382
  r.markers.replayed = !0;
4322
4383
  let f;
4323
4384
  try {
4324
4385
  f = await r.replay(g ? { authorizationSwap: g } : void 0);
4325
4386
  } catch (u) {
4326
- if (u instanceof K)
4387
+ if (u instanceof j)
4327
4388
  return p?.waiter.report({ outcome: "insufficient", obtained: u.obtained, required: u.required }), r.signal?.aborted ? { kind: "aborted", reason: r.signal.reason } : { kind: "insufficient", obtained: u.obtained, required: u.required };
4328
4389
  if (p?.waiter.report({ outcome: "failed" }), r.signal?.aborted)
4329
4390
  return { kind: "aborted", reason: r.signal.reason };
4330
4391
  throw u;
4331
4392
  }
4332
- const v = await cs(f, e, m, t);
4393
+ const v = await ls(f, e, m, t);
4333
4394
  return v.kind === "insufficient" ? p?.waiter.report({ outcome: "insufficient", obtained: v.obtained, required: v.required }) : p?.waiter.report({ outcome: "replayed", obtained: m }), v;
4334
- }, ds = (r) => {
4395
+ }, ps = (r) => {
4335
4396
  switch (r.kind) {
4336
4397
  case "cancelled":
4337
4398
  return new O();
4338
4399
  case "unsatisfiable":
4339
- return new Z();
4400
+ return new ee();
4340
4401
  case "unavailable":
4341
- return new j();
4402
+ return new G();
4342
4403
  case "session-changed":
4343
4404
  return new $();
4344
4405
  case "insufficient":
4345
- return new K(r.obtained, r.required);
4406
+ return new j(r.obtained, r.required);
4346
4407
  case "exhausted":
4347
4408
  return r.error;
4348
4409
  case "transport-failure":
@@ -4350,7 +4411,7 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4350
4411
  default:
4351
4412
  return;
4352
4413
  }
4353
- }, ls = (r, e, t) => {
4414
+ }, fs = (r, e, t) => {
4354
4415
  switch (r.kind) {
4355
4416
  case "replayed":
4356
4417
  return { settle: "resolve", value: r.response.raw };
@@ -4361,47 +4422,47 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4361
4422
  case "aborted":
4362
4423
  return { settle: "reject", error: r.reason };
4363
4424
  case "cancelled":
4364
- return t.onCancel === "reject" ? { settle: "reject", error: new O() } : { settle: "resolve", value: oe(e, r) };
4425
+ return t.onCancel === "reject" ? { settle: "reject", error: new O() } : { settle: "resolve", value: ce(e, r) };
4365
4426
  case "insufficient":
4366
- return { settle: "resolve", value: oe(r.response?.raw ?? e, r) };
4427
+ return { settle: "resolve", value: ce(r.response?.raw ?? e, r) };
4367
4428
  default:
4368
- return { settle: "resolve", value: oe(e, r) };
4429
+ return { settle: "resolve", value: ce(e, r) };
4369
4430
  }
4370
- }, us = (r, e) => {
4431
+ }, gs = (r, e) => {
4371
4432
  switch (r.kind) {
4372
4433
  case "replayed":
4373
4434
  return r.response.rejected ? { settle: "reject", error: r.response.raw ?? e } : { settle: "resolve", value: r.response.raw };
4374
4435
  case "aborted":
4375
4436
  return { settle: "reject", error: r.reason };
4376
4437
  default:
4377
- return { settle: "reject", error: ds(r) ?? e };
4438
+ return { settle: "reject", error: ps(r) ?? e };
4378
4439
  }
4379
- }, nt = /* @__PURE__ */ new WeakSet(), ot = /* @__PURE__ */ new WeakSet(), at = /* @__PURE__ */ new WeakSet(), ct = /* @__PURE__ */ new WeakSet(), ht = /* @__PURE__ */ new WeakSet(), dt = /* @__PURE__ */ new WeakSet(), lt = /* @__PURE__ */ new WeakSet(), oe = (r, e) => {
4440
+ }, ct = /* @__PURE__ */ new WeakSet(), ht = /* @__PURE__ */ new WeakSet(), dt = /* @__PURE__ */ new WeakSet(), lt = /* @__PURE__ */ new WeakSet(), ut = /* @__PURE__ */ new WeakSet(), pt = /* @__PURE__ */ new WeakSet(), ft = /* @__PURE__ */ new WeakSet(), ce = (r, e) => {
4380
4441
  switch (e.kind) {
4381
4442
  case "cancelled":
4382
- nt.add(r);
4443
+ ct.add(r);
4383
4444
  break;
4384
4445
  case "exhausted":
4385
- ot.add(r);
4446
+ ht.add(r);
4386
4447
  break;
4387
4448
  case "insufficient":
4388
- at.add(r);
4449
+ dt.add(r);
4389
4450
  break;
4390
4451
  case "unsatisfiable":
4391
- ct.add(r);
4452
+ lt.add(r);
4392
4453
  break;
4393
4454
  case "unavailable":
4394
- ht.add(r);
4455
+ ut.add(r);
4395
4456
  break;
4396
4457
  case "session-changed":
4397
- dt.add(r);
4458
+ pt.add(r);
4398
4459
  break;
4399
4460
  case "transport-failure":
4400
- lt.add(r);
4461
+ ft.add(r);
4401
4462
  break;
4402
4463
  }
4403
4464
  return r;
4404
- }, Ys = (r) => nt.has(r), Ws = (r) => ot.has(r), Xs = (r) => at.has(r), Js = (r) => ct.has(r), Zs = (r) => ht.has(r), Qs = (r) => dt.has(r), ei = (r) => lt.has(r), ps = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]), ee = (r) => typeof r == "object" && r !== null && typeof r.url == "string" && typeof r.clone == "function" && "method" in r, fs = (r) => typeof r == "string" ? r : ee(r) ? r.url : String(r), gs = (r, e) => (e?.method ?? (ee(r) ? r.method : void 0) ?? "GET").toUpperCase(), ms = (r) => r == null ? "none" : typeof r == "string" ? "reusable" : typeof r.getReader == "function" ? "one-shot" : "reusable", vs = (r) => {
4465
+ }, Js = (r) => ct.has(r), Zs = (r) => ht.has(r), Qs = (r) => dt.has(r), ei = (r) => lt.has(r), ti = (r) => ut.has(r), ri = (r) => pt.has(r), si = (r) => ft.has(r), vs = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]), re = (r) => typeof r == "object" && r !== null && typeof r.url == "string" && typeof r.clone == "function" && "method" in r, ms = (r) => typeof r == "string" ? r : re(r) ? r.url : String(r), ys = (r, e) => (e?.method ?? (re(r) ? r.method : void 0) ?? "GET").toUpperCase(), ks = (r) => r == null ? "none" : typeof r == "string" ? "reusable" : typeof r.getReader == "function" ? "one-shot" : "reusable", ws = (r) => {
4405
4466
  if (typeof r == "string")
4406
4467
  return r.length;
4407
4468
  const e = r;
@@ -4409,7 +4470,7 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4409
4470
  return e.size;
4410
4471
  if (typeof e?.byteLength == "number")
4411
4472
  return e.byteLength;
4412
- }, J = (r, e, t) => r === void 0 || r === "always" ? !0 : r === "idempotent-only" ? ps.has(e.method) : typeof r == "function" ? r(e) : !(r.maxBodyBytes !== void 0 && t !== void 0 && t > r.maxBodyBytes), q = (r, e, t, s, i) => ({
4473
+ }, Q = (r, e, t) => r === void 0 || r === "always" ? !0 : r === "idempotent-only" ? vs.has(e.method) : typeof r == "function" ? r(e) : !(r.maxBodyBytes !== void 0 && t !== void 0 && t > r.maxBodyBytes), N = (r, e, t, s, i) => ({
4413
4474
  replayable: !1,
4414
4475
  bodyKind: r,
4415
4476
  reason: e,
@@ -4417,12 +4478,12 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4417
4478
  forwardInit: i,
4418
4479
  snapshot: s,
4419
4480
  replay: () => Promise.reject(new Error(`This request cannot be replayed: ${e}`))
4420
- }), ut = (r, e) => tt(et(r.headers, e?.authorizationSwap)), ae = (r) => {
4481
+ }), gt = (r, e) => it(st(r.headers, e?.authorizationSwap)), he = (r) => {
4421
4482
  if (!r || !("headers" in r))
4422
4483
  return r;
4423
4484
  const { headers: e, ...t } = r;
4424
4485
  return t;
4425
- }, ys = (r, e) => e && "headers" in e && e.headers !== void 0 ? e.headers : ee(r) ? r.headers : void 0, ks = (r) => {
4486
+ }, Ss = (r, e) => e && "headers" in e && e.headers !== void 0 ? e.headers : re(r) ? r.headers : void 0, bs = (r) => {
4426
4487
  if (r === null || typeof r == "string")
4427
4488
  return r;
4428
4489
  if (typeof FormData < "u" && r instanceof FormData) {
@@ -4432,12 +4493,12 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4432
4493
  return e;
4433
4494
  }
4434
4495
  return typeof URLSearchParams < "u" && r instanceof URLSearchParams ? new URLSearchParams(r) : r instanceof ArrayBuffer ? r.slice(0) : ArrayBuffer.isView(r) ? new Uint8Array(r.buffer, r.byteOffset, r.byteLength).slice() : r;
4435
- }, Me = (r, e, t) => new Request(r, { headers: ut(e, t) }), ws = (r, e, t) => {
4436
- const s = fs(r), i = gs(r, e), n = ys(r, e), o = (d, g) => Qe({ url: s, method: i, headers: n, bodyKind: d, ...g === void 0 ? {} : { body: g } });
4437
- if (ee(r)) {
4496
+ }, Ue = (r, e, t) => new Request(r, { headers: gt(e, t) }), Ts = (r, e, t) => {
4497
+ const s = ms(r), i = ys(r, e), n = Ss(r, e), o = (d, g) => rt({ url: s, method: i, headers: n, bodyKind: d, ...g === void 0 ? {} : { body: g } });
4498
+ if (re(r)) {
4438
4499
  if (r.body === null || r.body === void 0) {
4439
4500
  const v = o("none");
4440
- return J(t, { url: s, method: i, bodyKind: "none" }) ? {
4501
+ return Q(t, { url: s, method: i, bodyKind: "none" }) ? {
4441
4502
  replayable: !0,
4442
4503
  bodyKind: "none",
4443
4504
  forwardInput: r,
@@ -4446,17 +4507,17 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4446
4507
  // The snapshot's effective header set is applied to the `Request` and
4447
4508
  // `init.headers` is dropped, so `fetch` has only one set to choose
4448
4509
  // from. See `replayHeaders` for why that matters.
4449
- replay: (y, I) => y(Me(r, v, I), ae(e))
4450
- } : q("none", "the replay policy refused this request", r, v, e);
4510
+ replay: (y, I) => y(Ue(r, v, I), he(e))
4511
+ } : N("none", "the replay policy refused this request", r, v, e);
4451
4512
  }
4452
4513
  const d = o("request-clone");
4453
- if (!J(t, { url: s, method: i, bodyKind: "request-clone" }))
4454
- return q("request-clone", "the replay policy refused this request", r, d, e);
4514
+ if (!Q(t, { url: s, method: i, bodyKind: "request-clone" }))
4515
+ return N("request-clone", "the replay policy refused this request", r, d, e);
4455
4516
  let f;
4456
4517
  try {
4457
4518
  f = r.clone();
4458
4519
  } catch {
4459
- return q("one-shot", "the Request body was already consumed and cannot be cloned", r, d, e);
4520
+ return N("one-shot", "the Request body was already consumed and cannot be cloned", r, d, e);
4460
4521
  }
4461
4522
  return {
4462
4523
  replayable: !0,
@@ -4464,15 +4525,15 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4464
4525
  forwardInput: r,
4465
4526
  forwardInit: e,
4466
4527
  snapshot: d,
4467
- replay: (v, u) => v(Me(f, d, u), ae(e))
4528
+ replay: (v, u) => v(Ue(f, d, u), he(e))
4468
4529
  };
4469
4530
  }
4470
- const a = ms(e?.body);
4531
+ const a = ks(e?.body);
4471
4532
  if (a === "one-shot")
4472
- return q("one-shot", "a streaming request body is consumed by the first send", r, o("one-shot"), e);
4473
- if (!J(t, { url: s, method: i, bodyKind: a }, vs(e?.body)))
4474
- return q(a, "the replay policy refused this request", r, o(a), e);
4475
- const p = e && "body" in e ? ks(e.body ?? null) : void 0, m = o(a, p);
4533
+ return N("one-shot", "a streaming request body is consumed by the first send", r, o("one-shot"), e);
4534
+ if (!Q(t, { url: s, method: i, bodyKind: a }, ws(e?.body)))
4535
+ return N(a, "the replay policy refused this request", r, o(a), e);
4536
+ const p = e && "body" in e ? bs(e.body ?? null) : void 0, m = o(a, p);
4476
4537
  return {
4477
4538
  replayable: !0,
4478
4539
  bodyKind: a,
@@ -4497,22 +4558,22 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4497
4558
  // unchanged, so an abort during the replay behaves identically to an abort
4498
4559
  // during the original.
4499
4560
  replay: (d, g) => d(m.dispatchUrl, {
4500
- ...ae(e),
4561
+ ...he(e),
4501
4562
  ...p === void 0 ? {} : { body: p },
4502
- headers: ut(m, g),
4563
+ headers: gt(m, g),
4503
4564
  method: m.method
4504
4565
  })
4505
4566
  };
4506
- }, te = (r) => typeof r == "object" && r !== null, Ss = (r) => (e) => {
4507
- if (!te(r))
4567
+ }, se = (r) => typeof r == "object" && r !== null, _s = (r) => (e) => {
4568
+ if (!se(r))
4508
4569
  return;
4509
4570
  const s = r[e] ?? r[e.toLowerCase()] ?? (typeof r.get == "function" ? r.get(e) : void 0);
4510
4571
  return Array.isArray(s) ? s.join(", ") : typeof s == "string" ? s : void 0;
4511
- }, bs = (r) => {
4572
+ }, Es = (r) => {
4512
4573
  const e = r?.url ?? "", t = r?.baseURL;
4513
4574
  return !t || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(e) ? e : `${t.replace(/\/+$/, "")}/${e.replace(/^\/+/, "")}`;
4514
- }, Ts = (r) => (r?.method ?? "GET").toUpperCase(), _s = (r) => r == null ? "none" : te(r) && (typeof r.pipe == "function" || typeof r.getReader == "function") ? "one-shot" : "reusable", Es = (r, e, t) => {
4515
- const s = tt(et(e.headers, t?.authorizationSwap)), i = e.dispatchUrl === e.href && e.resolved;
4575
+ }, Is = (r) => (r?.method ?? "GET").toUpperCase(), As = (r) => r == null ? "none" : se(r) && (typeof r.pipe == "function" || typeof r.getReader == "function") ? "one-shot" : "reusable", Cs = (r, e, t) => {
4576
+ const s = it(st(e.headers, t?.authorizationSwap)), i = e.dispatchUrl === e.href && e.resolved;
4516
4577
  return {
4517
4578
  ...r,
4518
4579
  ...i ? { baseURL: void 0 } : {},
@@ -4521,56 +4582,56 @@ const Ze = "https://passflow-relative.invalid", Xr = () => {
4521
4582
  headers: s,
4522
4583
  ..."body" in e ? { data: e.body } : {}
4523
4584
  };
4524
- }, fe = (r, e, t, s, i, n) => {
4525
- const o = e ?? r?.config, a = _s(o?.data), h = n ?? Qe({
4526
- url: bs(o),
4527
- method: Ts(o),
4585
+ }, me = (r, e, t, s, i, n) => {
4586
+ const o = e ?? r?.config, a = As(o?.data), h = n ?? rt({
4587
+ url: Es(o),
4588
+ method: Is(o),
4528
4589
  headers: o?.headers,
4529
4590
  bodyKind: a,
4530
4591
  body: o?.data
4531
- }), p = { url: h.href, method: h.method, bodyKind: a }, m = a !== "one-shot" && J(i.replay, p);
4592
+ }), p = { url: h.href, method: h.method, bodyKind: a }, m = a !== "one-shot" && Q(i.replay, p);
4532
4593
  return {
4533
4594
  status: r?.status ?? 0,
4534
- getHeader: Ss(r?.headers),
4595
+ getHeader: _s(r?.headers),
4535
4596
  // Pre-read by axios into `data`; nothing is consumed by reading it again,
4536
4597
  // and the core still decides whether reading it is in scope.
4537
4598
  readBody: async () => r?.data,
4538
4599
  request: h,
4539
4600
  replay: async (d) => {
4540
- const g = Ht(Es(o ?? {}, h, d));
4601
+ const g = Wt(Cs(o ?? {}, h, d));
4541
4602
  try {
4542
4603
  const f = await s(g);
4543
- return fe(f, f?.config ?? g, f, s, i, h);
4604
+ return me(f, f?.config ?? g, f, s, i, h);
4544
4605
  } catch (f) {
4545
- const v = te(f) ? f : {};
4546
- if (!v.response || typeof v.response.status != "number" || Xe(f))
4606
+ const v = se(f) ? f : {};
4607
+ if (!v.response || typeof v.response.status != "number" || Qe(f))
4547
4608
  throw f;
4548
- return { ...fe(v.response, v.config ?? g, f, s, i, h), rejected: !0 };
4609
+ return { ...me(v.response, v.config ?? g, f, s, i, h), rejected: !0 };
4549
4610
  }
4550
4611
  },
4551
4612
  markers: {
4552
- ...ze(o) ? { upgradeTransaction: !0 } : {},
4553
- ...zt(o) ? { replayed: !0 } : {}
4613
+ ...Xe(o) ? { upgradeTransaction: !0 } : {},
4614
+ ...Xt(o) ? { replayed: !0 } : {}
4554
4615
  },
4555
4616
  raw: t,
4556
4617
  replayable: m,
4557
4618
  replayUnsupportedReason: a === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
4558
4619
  signal: o?.signal
4559
4620
  };
4560
- }, pt = (r, e) => async (t) => {
4561
- const s = rt(r), i = te(t) ? t : {}, n = fe(i.response, i.config, i.response, e, s), o = await it(n, s), a = us(o, t);
4621
+ }, vt = (r, e) => async (t) => {
4622
+ const s = nt(r), i = se(t) ? t : {}, n = me(i.response, i.config, i.response, e, s), o = await at(n, s), a = gs(o, t);
4562
4623
  if (a.settle === "reject")
4563
4624
  throw a.error;
4564
4625
  return a.value;
4565
- }, Is = (r, e, t) => {
4566
- const s = r.request, i = typeof s == "function" ? (a) => s.call(r, a) : () => Promise.reject(new Error("Passflow: this client exposes no request() to replay through.")), n = r.interceptors.response.use(void 0, pt(e, i));
4626
+ }, Rs = (r, e, t) => {
4627
+ const s = r.request, i = typeof s == "function" ? (a) => s.call(r, a) : () => Promise.reject(new Error("Passflow: this client exposes no request() to replay through.")), n = r.interceptors.response.use(void 0, vt(e, i));
4567
4628
  let o = !1;
4568
4629
  return () => {
4569
4630
  o || (o = !0, r.interceptors.response.eject(n));
4570
4631
  };
4571
4632
  };
4572
- let ce = 0;
4573
- const As = (r, e) => {
4633
+ let de = 0;
4634
+ const Fs = (r, e) => {
4574
4635
  const t = e?.signal ?? (typeof r == "object" && r !== null ? r.signal : void 0) ?? void 0;
4575
4636
  if (t)
4576
4637
  return {
@@ -4585,9 +4646,9 @@ const As = (r, e) => {
4585
4646
  removeEventListener: (s, i) => t.removeEventListener(s, i)
4586
4647
  } : {}
4587
4648
  };
4588
- }, Cs = (r) => (e) => r.headers?.get(e), ft = (r, e, t, s, i) => ({
4649
+ }, Ps = (r) => (e) => r.headers?.get(e), mt = (r, e, t, s, i) => ({
4589
4650
  status: r.status,
4590
- getHeader: Cs(r),
4651
+ getHeader: Ps(r),
4591
4652
  // A CLONE, always. The response the caller receives must still have an unread
4592
4653
  // body, and the core calls this only when the scope and the channel policy
4593
4654
  // both permit a body read.
@@ -4600,7 +4661,7 @@ const As = (r, e) => {
4600
4661
  request: e.snapshot,
4601
4662
  replay: async (n) => {
4602
4663
  const o = await e.replay(t, n);
4603
- return ft(o, e, t, s, i);
4664
+ return mt(o, e, t, s, i);
4604
4665
  },
4605
4666
  markers: s,
4606
4667
  raw: r,
@@ -4608,89 +4669,89 @@ const As = (r, e) => {
4608
4669
  replayUnsupportedReason: e.reason,
4609
4670
  signal: i,
4610
4671
  responseType: r.type
4611
- }), he = (r, e) => {
4672
+ }), le = (r, e) => {
4612
4673
  const t = (s, i) => {
4613
- ce += 1;
4674
+ de += 1;
4614
4675
  try {
4615
4676
  return r(s, i);
4616
4677
  } finally {
4617
- ce -= 1;
4678
+ de -= 1;
4618
4679
  }
4619
4680
  };
4620
4681
  return async (s, i) => {
4621
- if (ce > 0)
4682
+ if (de > 0)
4622
4683
  return t(s, i);
4623
- const n = rt(e), o = ws(s, i, n.replay), a = await t(o.forwardInput, o.forwardInit), h = ft(a, o, t, {}, As(s, i)), p = await it(h, n), m = ls(p, a, n);
4684
+ const n = nt(e), o = Ts(s, i, n.replay), a = await t(o.forwardInput, o.forwardInit), h = mt(a, o, t, {}, Fs(s, i)), p = await at(h, n), m = fs(p, a, n);
4624
4685
  if (m.settle === "reject")
4625
4686
  throw m.error;
4626
4687
  return m.value;
4627
4688
  };
4628
- }, Rs = (r, e) => {
4629
- const t = B.create(r);
4689
+ }, Ms = (r, e) => {
4690
+ const t = K.create(r);
4630
4691
  return e(t), t;
4631
- }, ti = 10, Fs = 20;
4632
- class Ms extends Error {
4692
+ }, ii = 10, Ds = 20;
4693
+ class Us extends Error {
4633
4694
  constructor(e) {
4634
4695
  super(
4635
4696
  `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.`
4636
4697
  ), this.name = "FetchMiddlewareContractError", this.middlewareName = e;
4637
4698
  }
4638
4699
  }
4639
- let x = [], Ps = 0, H = !1, V, L;
4640
- const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof globalThis > "u" ? void 0 : globalThis, ge = async (r, e, t, s) => {
4700
+ let x = [], xs = 0, z = !1, B, L;
4701
+ const yt = (r, e) => r.priority - e.priority || r.seq - e.seq, be = () => typeof globalThis > "u" ? void 0 : globalThis, ye = async (r, e, t, s) => {
4641
4702
  if (e >= r.length) {
4642
- const h = V;
4703
+ const h = B;
4643
4704
  if (!h)
4644
4705
  throw new Error("Passflow fetch registry: no captured fetch to delegate to.");
4645
4706
  return h(t, s);
4646
4707
  }
4647
4708
  const i = r[e];
4648
4709
  if (!i)
4649
- return ge(r, r.length, t, s);
4710
+ return ye(r, r.length, t, s);
4650
4711
  let n = !1;
4651
- const o = (h, p) => (n = !0, ge(r, e + 1, h, p)), a = await i.middleware(o, t, s);
4712
+ const o = (h, p) => (n = !0, ye(r, e + 1, h, p)), a = await i.middleware(o, t, s);
4652
4713
  if (!n)
4653
- throw new Ms(i.name);
4714
+ throw new Us(i.name);
4654
4715
  return a;
4655
- }, Us = () => {
4656
- const r = ke();
4716
+ }, Os = () => {
4717
+ const r = be();
4657
4718
  if (!r || typeof r.fetch != "function")
4658
4719
  return !1;
4659
- const e = r.fetch.bind(r), t = (s, i) => ge([...x].sort(gt), 0, s, i);
4660
- return V = e, L = t, r.fetch = t, H = !0, !0;
4661
- }, Ds = () => {
4662
- const r = ke();
4663
- !r || !L || r.fetch === L && (V && (r.fetch = V), H = !1, L = void 0, V = void 0);
4664
- }, xs = (r, e) => {
4665
- if (!H && !Us())
4720
+ const e = r.fetch.bind(r), t = (s, i) => ye([...x].sort(yt), 0, s, i);
4721
+ return B = e, L = t, r.fetch = t, z = !0, !0;
4722
+ }, Ls = () => {
4723
+ const r = be();
4724
+ !r || !L || r.fetch === L && (B && (r.fetch = B), z = !1, L = void 0, B = void 0);
4725
+ }, $s = (r, e) => {
4726
+ if (!z && !Os())
4666
4727
  return () => {
4667
4728
  };
4668
4729
  const t = {
4669
4730
  middleware: r,
4670
4731
  name: e.name,
4671
4732
  priority: e.priority,
4672
- seq: Ps++
4733
+ seq: xs++
4673
4734
  };
4674
4735
  x.push(t);
4675
4736
  let s = !1;
4676
4737
  return () => {
4677
- s || (s = !0, x = x.filter((i) => i !== t), x.length === 0 && Ds());
4738
+ s || (s = !0, x = x.filter((i) => i !== t), x.length === 0 && Ls());
4678
4739
  };
4679
- }, ri = () => {
4680
- const r = ke();
4740
+ }, ni = () => {
4741
+ const r = be();
4681
4742
  return {
4682
- installed: H,
4683
- names: [...x].sort(gt).map((e) => e.name),
4684
- foreignPatch: H && !!r && !!L && r.fetch !== L
4743
+ installed: z,
4744
+ names: [...x].sort(yt).map((e) => e.name),
4745
+ foreignPatch: z && !!r && !!L && r.fetch !== L
4685
4746
  };
4686
- }, Os = (r) => r === void 0 ? [] : (Array.isArray(r) ? r : [r]).filter((e) => e !== ""), Ls = (r) => {
4747
+ }, qs = (r) => r === void 0 ? [] : (Array.isArray(r) ? r : [r]).filter((e) => e !== ""), Ns = (r) => {
4687
4748
  let e;
4688
4749
  const t = (d) => d !== void 0 && e === d, s = (d) => {
4689
4750
  const g = () => {
4690
4751
  if (!t(d()))
4691
4752
  throw new _({ kind: "session_changed" });
4692
4753
  };
4693
- return es({
4754
+ return ss({
4694
4755
  ...r,
4695
4756
  relyingPartyId: () => e?.options.relyingPartyId ?? r.relyingPartyId?.(),
4696
4757
  startUpgrade: (f) => (g(), r.startUpgrade(f)),
@@ -4703,7 +4764,7 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
4703
4764
  });
4704
4765
  }, i = (d, g) => {
4705
4766
  const f = {}, u = {
4706
- controller: new Wr({
4767
+ controller: new Zr({
4707
4768
  transport: s(() => f.current),
4708
4769
  prompt: d.prompt,
4709
4770
  platform: r.platform,
@@ -4713,14 +4774,14 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
4713
4774
  ...d.onFlightSettled ? { onFlightSettled: d.onFlightSettled } : {}
4714
4775
  }),
4715
4776
  options: d,
4716
- scope: { passflow: r.passflowDomain, backend: Os(d.backend) },
4777
+ scope: { passflow: r.passflowDomain, backend: qs(d.backend) },
4717
4778
  generation: g
4718
4779
  };
4719
4780
  return f.current = u, u;
4720
4781
  }, n = async (d, g) => {
4721
4782
  const f = e;
4722
4783
  if (!f)
4723
- throw new j("Step-up verification is not enabled on this Passflow instance");
4784
+ throw new G("Step-up verification is not enabled on this Passflow instance");
4724
4785
  f.controller.active || (f.pin = r.readSessionPin?.());
4725
4786
  const v = await f.controller.elevate(d, g);
4726
4787
  if (!t(f))
@@ -4742,7 +4803,7 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
4742
4803
  };
4743
4804
  let a;
4744
4805
  return Object.defineProperties(async (d) => {
4745
- const g = d?.acrValues === void 0 ? void 0 : Q(d.acrValues).level, f = {
4806
+ const g = d?.acrValues === void 0 ? void 0 : te(d.acrValues).level, f = {
4746
4807
  status: 401,
4747
4808
  ...d?.acrValues === void 0 ? {} : { acrValues: d.acrValues },
4748
4809
  ...g === void 0 ? {} : { requiredLevel: g },
@@ -4759,11 +4820,11 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
4759
4820
  const g = [];
4760
4821
  if (r.attachInternalSeam) {
4761
4822
  const v = r.attachInternalSeam;
4762
- v((u) => pt(o, u)), g.push(() => v(void 0));
4823
+ v((u) => vt(o, u)), g.push(() => v(void 0));
4763
4824
  }
4764
4825
  d.interceptFetch && g.push(
4765
- xs((v, u, y) => he(v, o)(u, y), {
4766
- priority: Fs,
4826
+ $s((v, u, y) => le(v, o)(u, y), {
4827
+ priority: Ds,
4767
4828
  name: "passflow-upgrade"
4768
4829
  })
4769
4830
  ), r.onSessionChange && g.push(
@@ -4796,19 +4857,19 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
4796
4857
  enumerable: !0,
4797
4858
  value: (d) => {
4798
4859
  if (d)
4799
- return he(d, o);
4860
+ return le(d, o);
4800
4861
  const g = typeof globalThis > "u" ? void 0 : globalThis;
4801
4862
  if (!g || typeof g.fetch != "function")
4802
4863
  throw new Error("Passflow: withAuth() needs a fetch to wrap — this runtime has none.");
4803
- return he(g.fetch.bind(g), o);
4864
+ return le(g.fetch.bind(g), o);
4804
4865
  }
4805
4866
  },
4806
4867
  attachAuth: {
4807
4868
  enumerable: !0,
4808
- value: (d) => Is(d, o)
4869
+ value: (d) => Rs(d, o)
4809
4870
  }
4810
4871
  });
4811
- }, we = class we {
4872
+ }, Te = class Te {
4812
4873
  constructor(e) {
4813
4874
  this.doRefreshTokens = !1, this.session = async ({
4814
4875
  createSession: n,
@@ -4818,10 +4879,10 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
4818
4879
  this.createSessionCallback = n, this.expiredSessionCallback = o, this.doRefreshTokens = a, await this.submitSessionCheck();
4819
4880
  };
4820
4881
  const { url: t, appId: s, scopes: i } = e;
4821
- this.url = t || De, this.appId = s, this.platform = e.platform ?? z, this.storageManager = new me({
4882
+ this.url = t || Le, this.appId = s, this.platform = e.platform ?? Y, this.storageManager = new ke({
4822
4883
  prefix: e.keyStoragePrefix ?? "",
4823
4884
  storage: this.platform.storage
4824
- }), this.deviceService = new $e(this.storageManager), this.authApi = new rr(e, this.storageManager, this.deviceService), this.appApi = new tr(e, this.storageManager, this.deviceService), this.userApi = new cr(e, this.storageManager, this.deviceService), this.settingApi = new ir(e, this.storageManager, this.deviceService), this.tenantApi = new nr(e, this.storageManager, this.deviceService), this.invitationApi = new sr(e, this.storageManager, this.deviceService), this.twoFactorApi = new or(e, this.storageManager, this.deviceService), this.upgradeApi = new ar(e, this.storageManager, this.deviceService), this.upgradeDomain = Ye(e.url), this.subscribeStore = new hr(), this.tokenCacheService = new Pr(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = i ?? _t, this.createTenantForNewUser = e.createTenantForNewUser ?? !1, this.authService = new Ir(
4885
+ }), this.deviceService = new Ve(this.storageManager), this.authApi = new nr(e, this.storageManager, this.deviceService), this.appApi = new ir(e, this.storageManager, this.deviceService), this.userApi = new lr(e, this.storageManager, this.deviceService), this.settingApi = new ar(e, this.storageManager, this.deviceService), this.tenantApi = new cr(e, this.storageManager, this.deviceService), this.invitationApi = new or(e, this.storageManager, this.deviceService), this.twoFactorApi = new hr(e, this.storageManager, this.deviceService), this.upgradeApi = new dr(e, this.storageManager, this.deviceService), this.upgradeDomain = Je(e.url), this.subscribeStore = new ur(), this.tokenCacheService = new xr(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = i ?? At, this.createTenantForNewUser = e.createTenantForNewUser ?? !1, this.authService = new Rr(
4825
4886
  this.authApi,
4826
4887
  this.deviceService,
4827
4888
  this.storageManager,
@@ -4837,7 +4898,7 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
4837
4898
  this.appId ?? "",
4838
4899
  e.tokenExchange,
4839
4900
  this.platform
4840
- ), this.userService = new Dr(this.userApi, this.deviceService, this.platform), this.tenantService = new Mr(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new Ar(this.invitationApi), this.twoFactorService = new Ur(this.twoFactorApi, this.subscribeStore), this.twoFactor = this.twoFactorService, this.upgrade = Ls({
4901
+ ), this.userService = new Lr(this.userApi, this.deviceService, this.platform), this.tenantService = new Ur(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new Fr(this.invitationApi), this.twoFactorService = new Or(this.twoFactorApi, this.subscribeStore), this.twoFactor = this.twoFactorService, this.upgrade = Ns({
4841
4902
  // The prepare round. The commit round is `/auth/refresh`, which must go
4842
4903
  // through AuthService: it is the only path that STORES the rotated tokens,
4843
4904
  // so posting directly would elevate the session on the server and leave
@@ -4945,7 +5006,7 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
4945
5006
  * ```
4946
5007
  */
4947
5008
  createClient(e) {
4948
- return Rs(e, (t) => this.upgrade.attachAuth(t));
5009
+ return Ms(e, (t) => this.upgrade.attachAuth(t));
4949
5010
  }
4950
5011
  /**
4951
5012
  * The assurance bar the session currently holds, read from the `acr` claim of
@@ -4962,7 +5023,7 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
4962
5023
  const t = T(e), s = typeof t.acr == "string" ? t.acr : void 0;
4963
5024
  if (!s)
4964
5025
  return;
4965
- const i = Q(s).level;
5026
+ const i = te(s).level;
4966
5027
  return i === void 0 ? { acrValues: s } : { acrValues: s, level: i };
4967
5028
  } catch {
4968
5029
  return;
@@ -5104,10 +5165,14 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
5104
5165
  const p = new URLSearchParams(e.hash.substring(1));
5105
5166
  p.get("access_token") && (t = p, s = !0);
5106
5167
  }
5168
+ if (!t.get("access_token") && this.adoptTwoFactorTokenFromUrl(e)) {
5169
+ this.error = void 0;
5170
+ return;
5171
+ }
5107
5172
  const i = t.get("access_token"), n = t.get("refresh_token"), o = t.get("id_token"), a = t.get("scopes")?.split(",") ?? this.scopes;
5108
5173
  let h;
5109
5174
  if (i) {
5110
- if (!re(i)) {
5175
+ if (!X(i)) {
5111
5176
  const p = {
5112
5177
  message: "Invalid access token format received",
5113
5178
  code: "INVALID_TOKEN_FORMAT"
@@ -5115,7 +5180,7 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
5115
5180
  this.subscribeStore.notify(c.Error, p), this.cleanupUrlParams(s, e);
5116
5181
  return;
5117
5182
  }
5118
- if (n && !re(n)) {
5183
+ if (n && !X(n)) {
5119
5184
  const p = {
5120
5185
  message: "Invalid refresh token format received",
5121
5186
  code: "INVALID_TOKEN_FORMAT"
@@ -5123,7 +5188,7 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
5123
5188
  this.subscribeStore.notify(c.Error, p), this.cleanupUrlParams(s, e);
5124
5189
  return;
5125
5190
  }
5126
- if (o && !re(o)) {
5191
+ if (o && !X(o)) {
5127
5192
  const p = {
5128
5193
  message: "Invalid ID token format received",
5129
5194
  code: "INVALID_TOKEN_FORMAT"
@@ -5140,10 +5205,32 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
5140
5205
  } else
5141
5206
  this.error = this.checkErrorsFromURL();
5142
5207
  }
5208
+ /**
5209
+ * Adopts a `#tfa_token=` fragment: the 2FA token goes to the TwoFactorService
5210
+ * through `TwoFactorRequired`, exactly as a password sign-in's does, and the
5211
+ * fragment is stripped from the URL. Nothing is saved as a session.
5212
+ *
5213
+ * @returns true when the URL carried a 2FA token
5214
+ */
5215
+ adoptTwoFactorTokenFromUrl(e) {
5216
+ if (!e?.hash) return !1;
5217
+ const t = new URLSearchParams(e.hash.substring(1)), s = t.get("tfa_token");
5218
+ if (!s) return !1;
5219
+ t.delete("tfa_token");
5220
+ const i = t.toString();
5221
+ if (this.platform.replaceUrl(e.pathname + e.search + (i ? `#${i}` : "")), !X(s)) {
5222
+ const n = {
5223
+ message: "Invalid 2FA token format received",
5224
+ code: "INVALID_TOKEN_FORMAT"
5225
+ };
5226
+ return this.subscribeStore.notify(c.Error, n), !0;
5227
+ }
5228
+ return this.subscribeStore.notify(c.TwoFactorRequired, { email: "", challengeId: "", tfaToken: s }), !0;
5229
+ }
5143
5230
  checkErrorsFromURL() {
5144
5231
  const t = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
5145
5232
  if (t) {
5146
- const s = Tr(t);
5233
+ const s = Ir(t);
5147
5234
  return new Error(s);
5148
5235
  }
5149
5236
  }
@@ -6123,6 +6210,8 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
6123
6210
  * Completes the authentication process and saves tokens.
6124
6211
  *
6125
6212
  * @param code - 6-digit TOTP code from authenticator app
6213
+ * @param options - `trustDevice: true` asks the server to trust this device,
6214
+ * so later sign-ins from it skip the second factor where the app allows it
6126
6215
  * @returns Promise with verification response containing tokens
6127
6216
  * @throws {PassflowError} If verification fails
6128
6217
  *
@@ -6130,20 +6219,20 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
6130
6219
  * ```typescript
6131
6220
  * // After signIn returns requires_2fa: true
6132
6221
  * if (passflow.isTwoFactorVerificationRequired()) {
6133
- * const response = await passflow.verifyTwoFactor('123456');
6222
+ * const response = await passflow.verifyTwoFactor('123456', { trustDevice: true });
6134
6223
  * console.log('Authentication complete', response.access_token);
6135
6224
  * }
6136
6225
  * ```
6137
6226
  */
6138
- async verifyTwoFactor(e) {
6227
+ async verifyTwoFactor(e, t) {
6139
6228
  try {
6140
- const t = await this.twoFactorService.verify(e);
6141
- return this.storageManager.saveTokens(t), this.tokenCacheService.setTokensCache(t), this.subscribeStore.notify(c.SignIn, {
6142
- tokens: t,
6229
+ const s = await this.twoFactorService.verify(e, t);
6230
+ return this.storageManager.saveTokens(s), this.tokenCacheService.setTokensCache(s), this.subscribeStore.notify(c.SignIn, {
6231
+ tokens: s,
6143
6232
  parsedTokens: this.tokenCacheService.getParsedTokens()
6144
- }), await this.submitSessionCheck(), t;
6145
- } catch (t) {
6146
- this.handleError(t, "Verify 2FA");
6233
+ }), await this.submitSessionCheck(), s;
6234
+ } catch (s) {
6235
+ this.handleError(s, "Verify 2FA");
6147
6236
  }
6148
6237
  }
6149
6238
  /**
@@ -6151,6 +6240,7 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
6151
6240
  * Completes the authentication process and saves tokens.
6152
6241
  *
6153
6242
  * @param code - Recovery code from the list provided during setup
6243
+ * @param options - `trustDevice: true` asks the server to trust this device
6154
6244
  * @returns Promise with recovery response containing tokens and remaining codes count
6155
6245
  * @throws {PassflowError} If recovery code is invalid
6156
6246
  *
@@ -6162,15 +6252,15 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
6162
6252
  * console.log(`${result.remaining_recovery_codes} recovery codes remaining`);
6163
6253
  * ```
6164
6254
  */
6165
- async useTwoFactorRecoveryCode(e) {
6255
+ async useTwoFactorRecoveryCode(e, t) {
6166
6256
  try {
6167
- const t = await this.twoFactorService.useRecoveryCode(e);
6168
- return this.storageManager.saveTokens(t), this.tokenCacheService.setTokensCache(t), this.subscribeStore.notify(c.SignIn, {
6169
- tokens: t,
6257
+ const s = await this.twoFactorService.useRecoveryCode(e, t);
6258
+ return this.storageManager.saveTokens(s), this.tokenCacheService.setTokensCache(s), this.subscribeStore.notify(c.SignIn, {
6259
+ tokens: s,
6170
6260
  parsedTokens: this.tokenCacheService.getParsedTokens()
6171
- }), await this.submitSessionCheck(), t;
6172
- } catch (t) {
6173
- this.handleError(t, "Use 2FA recovery code");
6261
+ }), await this.submitSessionCheck(), s;
6262
+ } catch (s) {
6263
+ this.handleError(s, "Use 2FA recovery code");
6174
6264
  }
6175
6265
  }
6176
6266
  /**
@@ -6216,6 +6306,45 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
6216
6306
  this.handleError(t, "Regenerate 2FA recovery codes");
6217
6307
  }
6218
6308
  }
6309
+ /**
6310
+ * List the devices the signed-in user trusted to skip the second factor on
6311
+ * this app. The device making the request has `current: true`.
6312
+ *
6313
+ * @returns Promise with the trusted devices
6314
+ * @throws {PassflowError} If the request fails
6315
+ *
6316
+ * @example
6317
+ * ```typescript
6318
+ * const devices = await passflow.getTrustedDevices();
6319
+ * devices.forEach((d) => console.log(d.user_agent, d.current ? '(this device)' : ''));
6320
+ * ```
6321
+ */
6322
+ async getTrustedDevices() {
6323
+ try {
6324
+ return await this.twoFactorService.getTrustedDevices();
6325
+ } catch (e) {
6326
+ this.handleError(e, "Get trusted devices");
6327
+ }
6328
+ }
6329
+ /**
6330
+ * Revoke one of the signed-in user's trusted devices. Its next sign-in
6331
+ * asks for the second factor again.
6332
+ *
6333
+ * @param id - The trusted device's `id` from `getTrustedDevices()`
6334
+ * @throws {PassflowError} If the request fails, including a 404 for an unknown id
6335
+ *
6336
+ * @example
6337
+ * ```typescript
6338
+ * await passflow.revokeTrustedDevice(device.id);
6339
+ * ```
6340
+ */
6341
+ async revokeTrustedDevice(e) {
6342
+ try {
6343
+ await this.twoFactorService.revokeTrustedDevice(e);
6344
+ } catch (t) {
6345
+ this.handleError(t, "Revoke trusted device");
6346
+ }
6347
+ }
6219
6348
  /**
6220
6349
  * Check if 2FA verification is currently required (local state check).
6221
6350
  * Returns true if user has signed in but needs to complete 2FA verification.
@@ -6327,8 +6456,8 @@ const gt = (r, e) => r.priority - e.priority || r.seq - e.seq, ke = () => typeof
6327
6456
  this.twoFactorService.clearMagicLinkSession();
6328
6457
  }
6329
6458
  };
6330
- we.version = Tt;
6331
- let Pe = we;
6459
+ Te.version = It;
6460
+ let xe = Te;
6332
6461
  class S extends Error {
6333
6462
  constructor(e) {
6334
6463
  super(e.message), this.name = "M2MError", this.code = e.code, this.status = e.status ?? 400, this.errorUri = e.errorUri, this.rateLimitInfo = e.rateLimitInfo, this.headers = e.headers, this.cause = e.cause, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this, S);
@@ -6424,7 +6553,7 @@ class S extends Error {
6424
6553
  return this.status && (e += ` (HTTP ${this.status})`), e;
6425
6554
  }
6426
6555
  }
6427
- class Ue extends S {
6556
+ class Oe extends S {
6428
6557
  constructor(e, t) {
6429
6558
  super({
6430
6559
  code: "temporarily_unavailable",
@@ -6434,7 +6563,7 @@ class Ue extends S {
6434
6563
  }), this.name = "M2MNetworkError";
6435
6564
  }
6436
6565
  }
6437
- class X extends S {
6566
+ class Z extends S {
6438
6567
  constructor(e, t) {
6439
6568
  super({
6440
6569
  code: "invalid_request",
@@ -6444,7 +6573,7 @@ class X extends S {
6444
6573
  }), this.name = "M2MTokenParseError";
6445
6574
  }
6446
6575
  }
6447
- class de extends S {
6576
+ class ue extends S {
6448
6577
  constructor(e) {
6449
6578
  super({
6450
6579
  code: "invalid_request",
@@ -6453,7 +6582,7 @@ class de extends S {
6453
6582
  }), this.name = "M2MConfigError";
6454
6583
  }
6455
6584
  }
6456
- const si = {
6585
+ const oi = {
6457
6586
  InvalidRequest: "invalid_request",
6458
6587
  InvalidClient: "invalid_client",
6459
6588
  InvalidGrant: "invalid_grant",
@@ -6477,7 +6606,7 @@ const si = {
6477
6606
  /** Content-Type for token requests */
6478
6607
  CONTENT_TYPE: "application/x-www-form-urlencoded"
6479
6608
  };
6480
- class $s {
6609
+ class Vs {
6481
6610
  constructor() {
6482
6611
  this.cache = /* @__PURE__ */ new Map();
6483
6612
  }
@@ -6495,7 +6624,7 @@ class $s {
6495
6624
  return this.cache.delete(e), Promise.resolve();
6496
6625
  }
6497
6626
  }
6498
- const qs = {
6627
+ const Bs = {
6499
6628
  shouldRetry(r, e) {
6500
6629
  return e >= 3 ? !1 : r.code === "server_error" || r.code === "temporarily_unavailable" || r.code === "rate_limit_exceeded" || r.status !== void 0 && r.status >= 500;
6501
6630
  },
@@ -6503,7 +6632,7 @@ const qs = {
6503
6632
  return Math.pow(2, r - 1) * 1e3;
6504
6633
  }
6505
6634
  };
6506
- class ii {
6635
+ class ai {
6507
6636
  /**
6508
6637
  * Create a new M2M client
6509
6638
  *
@@ -6521,11 +6650,11 @@ class ii {
6521
6650
  */
6522
6651
  constructor(e) {
6523
6652
  if (!e.url)
6524
- throw new de("M2M client requires a URL");
6653
+ throw new ue("M2M client requires a URL");
6525
6654
  if (!e.clientId)
6526
- throw new de("M2M client requires a clientId");
6655
+ throw new ue("M2M client requires a clientId");
6527
6656
  if (!e.clientSecret)
6528
- throw new de("M2M client requires a clientSecret");
6657
+ throw new ue("M2M client requires a clientSecret");
6529
6658
  const t = e.url.replace(/\/$/, "");
6530
6659
  this.config = {
6531
6660
  url: t,
@@ -6543,7 +6672,7 @@ class ii {
6543
6672
  onTokenRequest: e.onTokenRequest,
6544
6673
  onTokenResponse: e.onTokenResponse,
6545
6674
  onError: e.onError
6546
- }, this.cache = e.cache ?? new $s(), this.retryStrategy = e.retryStrategy ?? qs, this.tokenEndpoint = `${t}${R.TOKEN_ENDPOINT}`;
6675
+ }, this.cache = e.cache ?? new Vs(), this.retryStrategy = e.retryStrategy ?? Bs, this.tokenEndpoint = `${t}${R.TOKEN_ENDPOINT}`;
6547
6676
  }
6548
6677
  /**
6549
6678
  * Get the cache key for this client
@@ -6663,7 +6792,7 @@ class ii {
6663
6792
  }
6664
6793
  return a;
6665
6794
  } catch (n) {
6666
- throw clearTimeout(i), n instanceof Error && n.name === "AbortError" ? new Ue(`Request timed out after ${this.config.timeout}ms`) : n instanceof TypeError && n.message.includes("fetch") ? new Ue(`Network error: ${n.message}`, n) : n instanceof S ? n : S.fromError(n instanceof Error ? n : new Error(String(n)));
6795
+ throw clearTimeout(i), n instanceof Error && n.name === "AbortError" ? new Oe(`Request timed out after ${this.config.timeout}ms`) : n instanceof TypeError && n.message.includes("fetch") ? new Oe(`Network error: ${n.message}`, n) : n instanceof S ? n : S.fromError(n instanceof Error ? n : new Error(String(n)));
6667
6796
  }
6668
6797
  }
6669
6798
  /**
@@ -6758,14 +6887,14 @@ class ii {
6758
6887
  try {
6759
6888
  const t = e.split(".");
6760
6889
  if (t.length !== 3)
6761
- throw new X("Invalid JWT format: expected 3 parts");
6890
+ throw new Z("Invalid JWT format: expected 3 parts");
6762
6891
  const s = t[1];
6763
6892
  if (!s)
6764
- throw new X("Invalid JWT format: missing payload");
6893
+ throw new Z("Invalid JWT format: missing payload");
6765
6894
  const i = atob(s.replace(/-/g, "+").replace(/_/g, "/")), n = JSON.parse(i);
6766
6895
  return n.scopes && typeof n.scopes == "string" ? n.scopes = n.scopes.split(" ") : n.scopes || (n.scopes = []), n;
6767
6896
  } catch (t) {
6768
- throw t instanceof X ? t : new X(`Failed to parse token: ${t instanceof Error ? t.message : "Unknown error"}`);
6897
+ throw t instanceof Z ? t : new Z(`Failed to parse token: ${t instanceof Error ? t.message : "Unknown error"}`);
6769
6898
  }
6770
6899
  }
6771
6900
  /**
@@ -6851,110 +6980,110 @@ class ii {
6851
6980
  }
6852
6981
  }
6853
6982
  export {
6854
- N as APP_ID_HEADER_KEY,
6855
- U as AUTHORIZATION_HEADER_KEY,
6856
- tr as AppAPI,
6857
- rr as AuthAPI,
6858
- Ir as AuthService,
6859
- Hs as CLIAuthAPI,
6860
- js as DEFAULT_GROUP_NAME,
6861
- _t as DEFAULT_SCOPES,
6862
- ye as DEFAULT_UPGRADE_FACTORS,
6863
- St as DEVICE_ID_HEADER_KEY,
6864
- bt as DEVICE_TYPE_HEADER_KEY,
6865
- Mt as ERROR_MESSAGE_MAX_LENGTH,
6866
- ti as FETCH_PRIORITY_OIDC,
6867
- Fs as FETCH_PRIORITY_UPGRADE,
6868
- Ms as FetchMiddlewareContractError,
6869
- qt as INSUFFICIENT_USER_AUTHENTICATION,
6870
- sr as InvitationAPI,
6871
- Ar as InvitationService,
6872
- ii as M2MClient,
6873
- de as M2MConfigError,
6983
+ V as APP_ID_HEADER_KEY,
6984
+ D as AUTHORIZATION_HEADER_KEY,
6985
+ ir as AppAPI,
6986
+ nr as AuthAPI,
6987
+ Rr as AuthService,
6988
+ Ws as CLIAuthAPI,
6989
+ zs as DEFAULT_GROUP_NAME,
6990
+ At as DEFAULT_SCOPES,
6991
+ Se as DEFAULT_UPGRADE_FACTORS,
6992
+ _t as DEVICE_ID_HEADER_KEY,
6993
+ Et as DEVICE_TYPE_HEADER_KEY,
6994
+ Ut as ERROR_MESSAGE_MAX_LENGTH,
6995
+ ii as FETCH_PRIORITY_OIDC,
6996
+ Ds as FETCH_PRIORITY_UPGRADE,
6997
+ Us as FetchMiddlewareContractError,
6998
+ Bt as INSUFFICIENT_USER_AUTHENTICATION,
6999
+ or as InvitationAPI,
7000
+ Fr as InvitationService,
7001
+ ai as M2MClient,
7002
+ ue as M2MConfigError,
6874
7003
  S as M2MError,
6875
- si as M2MErrorCodes,
6876
- Ue as M2MNetworkError,
6877
- X as M2MTokenParseError,
7004
+ oi as M2MErrorCodes,
7005
+ Oe as M2MNetworkError,
7006
+ Z as M2MTokenParseError,
6878
7007
  R as M2M_DEFAULTS,
6879
- Ks as MINIMAL_DEFAULT_SCOPES,
6880
- Wt as OS,
6881
- De as PASSFLOW_CLOUD_URL,
6882
- It as POPUP_HEIGHT,
6883
- At as POPUP_POLL_INTERVAL_MS,
6884
- Ct as POPUP_TIMEOUT_MS,
6885
- Et as POPUP_WIDTH,
6886
- Pe as Passflow,
7008
+ Hs as MINIMAL_DEFAULT_SCOPES,
7009
+ Zt as OS,
7010
+ Le as PASSFLOW_CLOUD_URL,
7011
+ Rt as POPUP_HEIGHT,
7012
+ Ft as POPUP_POLL_INTERVAL_MS,
7013
+ Pt as POPUP_TIMEOUT_MS,
7014
+ Ct as POPUP_WIDTH,
7015
+ xe as Passflow,
6887
7016
  F as PassflowAdminEndpointPaths,
6888
7017
  l as PassflowEndpointPaths,
6889
7018
  w as PassflowError,
6890
7019
  c as PassflowEvent,
6891
- qe as PopupClosedError,
6892
- Yt as Providers,
6893
- dr as RECOVERABLE_COMMIT_ERROR_IDS,
6894
- P as RequestMethod,
6895
- Tt as SDK_VERSION,
6896
- lr as SESSION_INVALIDATING_COMMIT_ERROR_IDS,
6897
- Oe as SessionState,
6898
- ir as SettingAPI,
6899
- xe as TOKEN_EXPIRY_BUFFER_SECONDS,
6900
- nr as TenantAPI,
6901
- Mr as TenantService,
6902
- Fr as TenantUserMembership,
6903
- Pr as TokenCacheService,
7020
+ Be as PopupClosedError,
7021
+ Jt as Providers,
7022
+ pr as RECOVERABLE_COMMIT_ERROR_IDS,
7023
+ M as RequestMethod,
7024
+ It as SDK_VERSION,
7025
+ fr as SESSION_INVALIDATING_COMMIT_ERROR_IDS,
7026
+ qe as SessionState,
7027
+ ar as SettingAPI,
7028
+ $e as TOKEN_EXPIRY_BUFFER_SECONDS,
7029
+ cr as TenantAPI,
7030
+ Ur as TenantService,
7031
+ Dr as TenantUserMembership,
7032
+ xr as TokenCacheService,
6904
7033
  A as TokenDeliveryMode,
6905
7034
  b as TokenType,
6906
- or as TwoFactorApiClient,
6907
- Xt as TwoFactorPolicy,
6908
- Ur as TwoFactorService,
6909
- Nt as UPGRADE_REQUIRED,
6910
- Ft as USERNAME_MAX_LENGTH,
6911
- Rt as USERNAME_MIN_LENGTH,
6912
- ar as UpgradeAPI,
7035
+ hr as TwoFactorApiClient,
7036
+ Qt as TwoFactorPolicy,
7037
+ Or as TwoFactorService,
7038
+ Kt as UPGRADE_REQUIRED,
7039
+ Dt as USERNAME_MAX_LENGTH,
7040
+ Mt as USERNAME_MIN_LENGTH,
7041
+ dr as UpgradeAPI,
6913
7042
  O as UpgradeCancelledError,
6914
- Wr as UpgradeController,
7043
+ Zr as UpgradeController,
6915
7044
  k as UpgradeErrorIds,
6916
- D as UpgradeFactorError,
6917
- K as UpgradeInsufficientError,
7045
+ U as UpgradeFactorError,
7046
+ j as UpgradeInsufficientError,
6918
7047
  $ as UpgradeSessionChangedError,
6919
7048
  _ as UpgradeTransportError,
6920
- j as UpgradeUnavailableError,
6921
- Z as UpgradeUnsatisfiableError,
6922
- cr as UserAPI,
6923
- Dr as UserService,
6924
- xt as WebAdapter,
6925
- Ee as classifyUpgradeError,
6926
- $r as factorRegistry,
6927
- ri as fetchRegistryState,
6928
- Gs as getOSFromDeviceType,
6929
- wr as invalidatesSessionOnCommit,
6930
- zs as isRecoverableCommitFailure,
6931
- pr as isRetryableUpgradeKind,
7049
+ G as UpgradeUnavailableError,
7050
+ ee as UpgradeUnsatisfiableError,
7051
+ lr as UserAPI,
7052
+ Lr as UserService,
7053
+ $t as WebAdapter,
7054
+ Ce as classifyUpgradeError,
7055
+ Vr as factorRegistry,
7056
+ ni as fetchRegistryState,
7057
+ Ys as getOSFromDeviceType,
7058
+ Tr as invalidatesSessionOnCommit,
7059
+ Xs as isRecoverableCommitFailure,
7060
+ vr as isRetryableUpgradeKind,
6932
7061
  C as isTokenExpired,
6933
- Ys as isUpgradeCancelled,
6934
- Ws as isUpgradeExhausted,
6935
- Xs as isUpgradeInsufficient,
6936
- Qs as isUpgradeSessionChanged,
6937
- mr as isUpgradeTransportError,
6938
- ei as isUpgradeTransportFailure,
6939
- Zs as isUpgradeUnavailable,
6940
- Js as isUpgradeUnsatisfiable,
6941
- se as isValidEmail,
6942
- re as isValidJWTFormat,
6943
- ie as isValidPhoneNumber,
6944
- _r as isValidUsername,
6945
- Kt as parseChallengeBody,
6946
- Bt as parseChallengeHeader,
7062
+ Js as isUpgradeCancelled,
7063
+ Zs as isUpgradeExhausted,
7064
+ Qs as isUpgradeInsufficient,
7065
+ ri as isUpgradeSessionChanged,
7066
+ kr as isUpgradeTransportError,
7067
+ si as isUpgradeTransportFailure,
7068
+ ti as isUpgradeUnavailable,
7069
+ ei as isUpgradeUnsatisfiable,
7070
+ ne as isValidEmail,
7071
+ X as isValidJWTFormat,
7072
+ oe as isValidPhoneNumber,
7073
+ Ar as isValidUsername,
7074
+ Ht as parseChallengeBody,
7075
+ Gt as parseChallengeHeader,
6947
7076
  T as parseToken,
6948
- Gt as parseUpgradeChallenge,
6949
- Lr as passkeyFactor,
6950
- M as pathWithParams,
6951
- Or as recoveryCodesFactor,
6952
- xs as registerFetchMiddleware,
6953
- $t as requiredAcrLevel,
6954
- Ye as resolveUpgradeDomain,
6955
- Tr as sanitizeErrorMessage,
6956
- Br as selectFactors,
6957
- xr as totpFactor,
6958
- z as webAdapter
7077
+ Yt as parseUpgradeChallenge,
7078
+ Nr as passkeyFactor,
7079
+ P as pathWithParams,
7080
+ qr as recoveryCodesFactor,
7081
+ $s as registerFetchMiddleware,
7082
+ Vt as requiredAcrLevel,
7083
+ Je as resolveUpgradeDomain,
7084
+ Ir as sanitizeErrorMessage,
7085
+ Gr as selectFactors,
7086
+ $r as totpFactor,
7087
+ Y as webAdapter
6959
7088
  };
6960
7089
  //# sourceMappingURL=index.mjs.map