@passflow/core 0.25.0 → 0.27.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,7 +1,7 @@
1
1
  import e from "axios";
2
2
  import { startAuthentication as t, startRegistration as n } from "@simplewebauthn/browser";
3
3
  // package.json
4
- var r = "0.25.0", i = "X-Passflow-Clientid", a = "Authorization", o = "X-Passflow-DeviceId", s = "X-Passflow-DeviceType", c = r, l = [
4
+ var r = "0.27.0", i = "X-Passflow-Clientid", a = "Authorization", o = "X-Passflow-DeviceId", s = "X-Passflow-DeviceType", c = r, l = [
5
5
  "id",
6
6
  "offline",
7
7
  "openid"
@@ -567,7 +567,7 @@ var j = /* @__PURE__ */ function(e) {
567
567
  }), Ee = (e) => Se(e, xe), De = /* @__PURE__ */ function(e) {
568
568
  return e.GET = "get", e.POST = "post", e.PUT = "put", e.PATCH = "patch", e.DELETE = "delete", e;
569
569
  }({}), z = /* @__PURE__ */ function(e) {
570
- return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.signInWithProvider = "/auth/federated/start/", e.passwordless = "/auth/passwordless/start", e.passwordlessComplete = "/auth/passwordless/complete", e.passwordlessStatus = "/auth/passwordless/status", e.passwordlessApprovalInfo = "/auth/passwordless/approval/info", e.passwordlessApprovalDecide = "/auth/passwordless/approval/decide", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.twoFactorEnrollment = "/auth/2fa/enrollment", e.twoFactorEnrollmentEmailLink = "/auth/2fa/enrollment/email-link", e.twoFactorEnrollmentBegin = "/auth/2fa/setup/begin", e.twoFactorEnrollmentConfirm = "/auth/2fa/setup/confirm", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e;
570
+ return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.redirectCheck = "/auth/redirect/check", e.signInWithProvider = "/auth/federated/start/", e.passwordless = "/auth/passwordless/start", e.passwordlessComplete = "/auth/passwordless/complete", e.passwordlessStatus = "/auth/passwordless/status", e.passwordlessApprovalInfo = "/auth/passwordless/approval/info", e.passwordlessApprovalDecide = "/auth/passwordless/approval/decide", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.twoFactorEnrollment = "/auth/2fa/enrollment", e.twoFactorEnrollmentEmailLink = "/auth/2fa/enrollment/email-link", e.twoFactorEnrollmentBegin = "/auth/2fa/setup/begin", e.twoFactorEnrollmentConfirm = "/auth/2fa/setup/confirm", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e;
571
571
  }({}), Oe = /* @__PURE__ */ function(e) {
572
572
  return e.passkeyRegisterStart = "/admin/auth/passkey/register/start", e.passkeyRegisterComplete = "/admin/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/admin/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/admin/auth/passkey/authenticate/complete", e.passkeyValidate = "/admin/auth/validate", e.logout = "/admin/auth/logout", e;
573
573
  }({}), ke = (e) => {
@@ -866,6 +866,13 @@ var Re = /* @__PURE__ */ function(e) {
866
866
  throw tt(e, z.passwordlessStatus, "error.passwordless.status", $e);
867
867
  }
868
868
  }
869
+ async checkRedirectUrl(e) {
870
+ try {
871
+ return (await this.axiosClient.post(z.redirectCheck, { redirect_url: e })).redirect_url;
872
+ } catch (e) {
873
+ throw tt(e, z.redirectCheck, "error.redirect.check", et);
874
+ }
875
+ }
869
876
  async passwordlessApprovalInfo(e) {
870
877
  try {
871
878
  return await this.axiosClient.post(z.passwordlessApprovalInfo, e);
@@ -3423,7 +3430,68 @@ var Z = /* @__PURE__ */ function(e) {
3423
3430
  notifyError(e) {
3424
3431
  return U(this, e);
3425
3432
  }
3426
- }, Q = {
3433
+ }, ar = {
3434
+ ES256: {
3435
+ kty: "EC",
3436
+ key: (e) => ({
3437
+ kty: e.kty,
3438
+ crv: e.crv,
3439
+ x: e.x,
3440
+ y: e.y
3441
+ }),
3442
+ imported: {
3443
+ name: "ECDSA",
3444
+ namedCurve: "P-256"
3445
+ },
3446
+ signature: {
3447
+ name: "ECDSA",
3448
+ hash: "SHA-256"
3449
+ }
3450
+ },
3451
+ RS256: {
3452
+ kty: "RSA",
3453
+ key: (e) => ({
3454
+ kty: e.kty,
3455
+ n: e.n,
3456
+ e: e.e
3457
+ }),
3458
+ imported: {
3459
+ name: "RSASSA-PKCS1-v1_5",
3460
+ hash: "SHA-256"
3461
+ },
3462
+ signature: { name: "RSASSA-PKCS1-v1_5" }
3463
+ }
3464
+ }, or = (e) => {
3465
+ let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = globalThis.atob(t + "=".repeat((4 - t.length % 4) % 4));
3466
+ return Uint8Array.from(n, (e) => e.charCodeAt(0));
3467
+ }, sr = () => {
3468
+ let e = globalThis.crypto;
3469
+ if (!e?.subtle) throw Error("Verifying tokens needs the Web Crypto API, available only in a secure context (https or localhost)");
3470
+ return e;
3471
+ };
3472
+ async function cr(e, t, n, r, i) {
3473
+ let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(or(a))), l = c.alg === "ES256" || c.alg === "RS256" ? ar[c.alg] : void 0;
3474
+ if (!l) throw Error(`Token signing algorithm ${String(c.alg)} is not accepted`);
3475
+ let u = t.find((e) => e.kid === c.kid && e.kty === l.kty && (e.kty !== "EC" || e.crv === "P-256"));
3476
+ if (!u) throw Error("Token signing key is not published by the server");
3477
+ let d = sr().subtle, f = await d.importKey("jwk", l.key(u), l.imported, !1, ["verify"]), p = new TextEncoder().encode(`${a}.${o}`);
3478
+ if (!await d.verify(l.signature, f, or(s), p)) throw Error("Token signature is not valid");
3479
+ let m = A(e), h = Array.isArray(m.aud) ? m.aud : [m.aud];
3480
+ if (m.iss !== n) throw Error("Token issuer does not match the server");
3481
+ if (!h.includes(r)) throw Error("Token is not issued for this app");
3482
+ if (typeof m.exp != "number" || k(m, 0)) throw Error("Token has expired");
3483
+ if (i && m.type !== i) throw Error("Token type is not valid");
3484
+ }
3485
+ async function lr(t, n, r) {
3486
+ if (!n) throw Error("An app id is required to accept tokens from the URL");
3487
+ if (!r.access_token) throw Error("No access token received");
3488
+ sr();
3489
+ let i = t.replace(/\/+$/, ""), [a, o] = await Promise.all([e.get(`${i}/.well-known/openid-configuration`), e.get(`${i}/.well-known/jwks.json`)]), s = a.data?.issuer, c = o.data?.keys ?? [];
3490
+ if (!s) throw Error("The server did not publish an issuer");
3491
+ await cr(r.access_token, c, s, n, j.access_token), r.refresh_token && await cr(r.refresh_token, c, s, n, j.refresh_token), r.id_token && await cr(r.id_token, c, s, n);
3492
+ }
3493
+ // lib/upgrade/errors.ts
3494
+ var Q = {
3427
3495
  twoFactorCodeInvalid: "error.api.request.2fa_code.invalid",
3428
3496
  challengeInvalid: "error.upgrade.challenge_invalid",
3429
3497
  challengeSessionMismatch: "error.upgrade.challenge_session_mismatch",
@@ -3437,18 +3505,18 @@ var Z = /* @__PURE__ */ function(e) {
3437
3505
  twoFactorNotEnabled: "error.2fa.not_enabled",
3438
3506
  notImplemented: "error.not.implemented",
3439
3507
  tokenInvalid: "error.api.request.token.invalid"
3440
- }, ar = Object.freeze([
3508
+ }, ur = Object.freeze([
3441
3509
  Q.twoFactorCodeInvalid,
3442
3510
  Q.twoFactorNotEnabled,
3443
3511
  Q.challengeInvalid,
3444
3512
  Q.challengeSessionMismatch,
3445
3513
  Q.challengeTooManyAttempts
3446
- ]), or = Object.freeze([Q.tokenInvalid]), sr = Object.freeze([
3514
+ ]), dr = Object.freeze([Q.tokenInvalid]), fr = Object.freeze([
3447
3515
  "wrong_code",
3448
3516
  "challenge_spent",
3449
3517
  "not_registered",
3450
3518
  "prepare_not_required"
3451
- ]), cr = (e) => sr.includes(e), lr = {
3519
+ ]), pr = (e) => fr.includes(e), mr = {
3452
3520
  wrong_code: "That code was not accepted. Try again.",
3453
3521
  challenge_spent: "That verification challenge is no longer valid. Start again.",
3454
3522
  exhausted: "Too many attempts. Try again later.",
@@ -3462,16 +3530,16 @@ var Z = /* @__PURE__ */ function(e) {
3462
3530
  session_changed: "The session ended during verification."
3463
3531
  }, $ = class extends Error {
3464
3532
  constructor(e) {
3465
- super(e.message || lr[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, this.retryable = cr(e.kind), e.cause !== void 0 && (this.cause = e.cause);
3533
+ 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 = pr(e.kind), e.cause !== void 0 && (this.cause = e.cause);
3466
3534
  }
3467
- }, ur = Object.freeze([
3535
+ }, hr = Object.freeze([
3468
3536
  "upgrade_transport",
3469
3537
  "upgrade_insufficient",
3470
3538
  "upgrade_unavailable",
3471
3539
  "upgrade_session_changed",
3472
3540
  "upgrade_cancelled",
3473
3541
  "upgrade_unsatisfiable"
3474
- ]), dr = (e) => typeof e == "object" && !!e && typeof e.code == "string" && ur.includes(e.code), fr = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", pr = (e) => {
3542
+ ]), gr = (e) => typeof e == "object" && !!e && typeof e.code == "string" && hr.includes(e.code), _r = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", vr = (e) => {
3475
3543
  if (typeof e != "object" || !e) return {
3476
3544
  hasResponse: !1,
3477
3545
  message: typeof e == "string" ? e : void 0
@@ -3483,7 +3551,7 @@ var Z = /* @__PURE__ */ function(e) {
3483
3551
  message: typeof t.message == "string" ? t.message : void 0,
3484
3552
  hasResponse: n !== void 0 || typeof t.status == "number"
3485
3553
  };
3486
- }, mr = (e, t) => {
3554
+ }, yr = (e, t) => {
3487
3555
  switch (e) {
3488
3556
  case Q.twoFactorCodeInvalid: return "wrong_code";
3489
3557
  case Q.challengeInvalid:
@@ -3500,11 +3568,11 @@ var Z = /* @__PURE__ */ function(e) {
3500
3568
  case Q.tokenInvalid: return t === "refresh" ? "session_changed" : "fatal";
3501
3569
  default: return;
3502
3570
  }
3503
- }, hr = (e, t) => e === void 0 ? "network" : e === 501 ? "unavailable" : e === 400 ? "fatal" : e === 401 || e === 403 ? t === "start" ? "challenge_spent" : "session_changed" : e >= 500 ? "network" : "fatal", gr = (e, t) => {
3571
+ }, br = (e, t) => e === void 0 ? "network" : e === 501 ? "unavailable" : e === 400 ? "fatal" : e === 401 || e === 403 ? t === "start" ? "challenge_spent" : "session_changed" : e >= 500 ? "network" : "fatal", xr = (e, t) => {
3504
3572
  if (e instanceof $) return e;
3505
- let n = pr(e);
3573
+ let n = vr(e);
3506
3574
  return n.hasResponse ? new $({
3507
- kind: mr(n.errorId, t) ?? hr(n.status, t),
3575
+ kind: yr(n.errorId, t) ?? br(n.status, t),
3508
3576
  message: n.message,
3509
3577
  status: n.status,
3510
3578
  errorId: n.errorId,
@@ -3514,60 +3582,60 @@ var Z = /* @__PURE__ */ function(e) {
3514
3582
  message: n.message,
3515
3583
  cause: e
3516
3584
  });
3517
- }, _r = (e) => e.errorId !== void 0 && ar.includes(e.errorId), vr = (e) => e.errorId !== void 0 && or.includes(e.errorId), yr = class extends Error {
3585
+ }, Sr = (e) => e.errorId !== void 0 && ur.includes(e.errorId), Cr = (e) => e.errorId !== void 0 && dr.includes(e.errorId), wr = class extends Error {
3518
3586
  constructor(e, t, n) {
3519
3587
  super(n ?? "The session was elevated, but this action requires a higher assurance level"), this.name = "UpgradeInsufficientError", this.code = "upgrade_insufficient", this.obtained = e, this.required = t;
3520
3588
  }
3521
- }, br = class extends Error {
3589
+ }, Tr = class extends Error {
3522
3590
  constructor(e = "Step-up verification is not available on this deployment") {
3523
3591
  super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
3524
3592
  }
3525
- }, xr = class extends Error {
3593
+ }, Er = class extends Error {
3526
3594
  constructor(e = "The session changed during verification") {
3527
3595
  super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
3528
3596
  }
3529
- }, Sr = (e) => {
3597
+ }, Dr = (e) => {
3530
3598
  if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
3531
3599
  sub: e.sub,
3532
3600
  sid: e.sid
3533
3601
  } : { sub: e.sub };
3534
- }, Cr = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
3602
+ }, Or = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
3535
3603
  // lib/utils/validation.ts
3536
- function wr(e) {
3604
+ function kr(e) {
3537
3605
  if (!e || typeof e != "string") return !1;
3538
3606
  let t = e.split(".");
3539
3607
  if (t.length !== 3) return !1;
3540
3608
  let n = /^[A-Za-z0-9_-]+$/;
3541
3609
  return t.every((e) => n.test(e) && e.length > 0);
3542
3610
  }
3543
- function Tr(e) {
3611
+ function Ar(e) {
3544
3612
  return e.replace(/<[^>]*>/g, "").substring(0, 200);
3545
3613
  }
3546
- function Er(e) {
3614
+ function jr(e) {
3547
3615
  if (!e || typeof e != "string") return !1;
3548
3616
  let t = e.trim();
3549
3617
  return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
3550
3618
  }
3551
- function Dr(e) {
3619
+ function Mr(e) {
3552
3620
  if (!e || typeof e != "string") return !1;
3553
3621
  let t = e.trim();
3554
3622
  return /^\+[1-9]\d{1,14}$/.test(t);
3555
3623
  }
3556
- function Or(e) {
3624
+ function Nr(e) {
3557
3625
  if (!e || typeof e != "string") return !1;
3558
3626
  let t = e.trim();
3559
3627
  return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
3560
3628
  }
3561
- function kr(e, t = 6) {
3629
+ function Pr(e, t = 6) {
3562
3630
  return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
3563
3631
  }
3564
- function Ar(e) {
3632
+ function Fr(e) {
3565
3633
  if (!e || typeof e != "string") return null;
3566
3634
  let t = e.toUpperCase().replace(/\s+/g, "");
3567
3635
  return /^[A-Z0-9-]{4,16}$/.test(t) ? t : null;
3568
3636
  }
3569
3637
  // lib/services/auth-service.ts
3570
- var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3, Fr = "passflow_federated_pkce", Ir = 6e5, Lr = "AppId is required for federated auth", Rr = 10, zr = "The sign-in answered with a PKCE code, but its verifier is gone", Br = (e, t) => new Promise((n, r) => {
3638
+ var Ir = "passflow_2fa_pkce", Lr = 3e5, Rr = "passflow_pwless_pending", zr = 3e3, Br = "passflow_federated_pkce", Vr = 6e5, Hr = "AppId is required for federated auth", Ur = 10, Wr = "The sign-in answered with a PKCE code, but its verifier is gone", Gr = (e, t) => new Promise((n, r) => {
3571
3639
  if (t?.aborted) {
3572
3640
  r(t.reason);
3573
3641
  return;
@@ -3578,19 +3646,19 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3578
3646
  t?.removeEventListener("abort", i), n();
3579
3647
  }, e);
3580
3648
  t?.addEventListener("abort", i, { once: !0 });
3581
- }), Vr = (e) => {
3649
+ }), Kr = (e) => {
3582
3650
  if (!e) return;
3583
3651
  let t = new URLSearchParams(e.search).get("token");
3584
3652
  if (t) return t;
3585
3653
  let n = e.hash.indexOf("?");
3586
3654
  return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
3587
- }, Hr = (e) => {
3655
+ }, qr = (e) => {
3588
3656
  if (e) try {
3589
3657
  return A(e).email;
3590
3658
  } catch {
3591
3659
  return;
3592
3660
  }
3593
- }, Ur = class {
3661
+ }, Jr = class {
3594
3662
  constructor(e, t, n, r, i, a, o, s, c, l, u, d = P, f, p = { coordination: _n() }) {
3595
3663
  this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new ne(n), u?.enabled && this.tokenDeliveryManager.setMode(M.BFF), this.refresh = rr({
3596
3664
  emit: this.createRefreshEmit(),
@@ -3655,7 +3723,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3655
3723
  rememberEmailChallenge(e, t) {
3656
3724
  this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
3657
3725
  for (let e of this.emailChallenges.keys()) {
3658
- if (this.emailChallenges.size <= Rr) break;
3726
+ if (this.emailChallenges.size <= Ur) break;
3659
3727
  this.emailChallenges.delete(e);
3660
3728
  }
3661
3729
  }
@@ -3663,14 +3731,14 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3663
3731
  if (this.pendingPkce = {
3664
3732
  verifier: e,
3665
3733
  scopes: t,
3666
- expiresAt: Date.now() + Mr
3734
+ expiresAt: Date.now() + Lr
3667
3735
  }, typeof sessionStorage < "u") try {
3668
- sessionStorage.setItem(jr, JSON.stringify(this.pendingPkce));
3736
+ sessionStorage.setItem(Ir, JSON.stringify(this.pendingPkce));
3669
3737
  } catch {}
3670
3738
  }
3671
3739
  readPendingPkce() {
3672
3740
  if (!this.pendingPkce && typeof sessionStorage < "u") try {
3673
- let e = sessionStorage.getItem(jr);
3741
+ let e = sessionStorage.getItem(Ir);
3674
3742
  this.pendingPkce = e ? JSON.parse(e) : void 0;
3675
3743
  } catch {
3676
3744
  this.pendingPkce = void 0;
@@ -3682,17 +3750,17 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3682
3750
  }
3683
3751
  forgetPkceSignIn() {
3684
3752
  if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
3685
- sessionStorage.removeItem(jr);
3753
+ sessionStorage.removeItem(Ir);
3686
3754
  } catch {}
3687
3755
  }
3688
3756
  rememberPendingPasswordless(e) {
3689
3757
  if (this.pendingPasswordless = e, typeof sessionStorage < "u") try {
3690
- sessionStorage.setItem(Nr, JSON.stringify(e));
3758
+ sessionStorage.setItem(Rr, JSON.stringify(e));
3691
3759
  } catch {}
3692
3760
  }
3693
3761
  readPendingPasswordless() {
3694
3762
  if (!this.pendingPasswordless && typeof sessionStorage < "u") try {
3695
- let e = sessionStorage.getItem(Nr);
3763
+ let e = sessionStorage.getItem(Rr);
3696
3764
  this.pendingPasswordless = e ? JSON.parse(e) : void 0;
3697
3765
  } catch {
3698
3766
  this.pendingPasswordless = void 0;
@@ -3701,21 +3769,21 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3701
3769
  }
3702
3770
  forgetPendingPasswordless() {
3703
3771
  if (this.pendingPasswordless = void 0, typeof sessionStorage < "u") try {
3704
- sessionStorage.removeItem(Nr);
3772
+ sessionStorage.removeItem(Rr);
3705
3773
  } catch {}
3706
3774
  }
3707
3775
  rememberFederatedSlot(e, t) {
3708
3776
  if (this.federatedSlot = {
3709
3777
  verifier: e,
3710
3778
  scopes: t,
3711
- expiresAt: Date.now() + Ir
3779
+ expiresAt: Date.now() + Vr
3712
3780
  }, typeof sessionStorage < "u") try {
3713
- sessionStorage.setItem(Fr, JSON.stringify(this.federatedSlot));
3781
+ sessionStorage.setItem(Br, JSON.stringify(this.federatedSlot));
3714
3782
  } catch {}
3715
3783
  }
3716
3784
  readFederatedSlot() {
3717
3785
  if (!this.federatedSlot && typeof sessionStorage < "u") try {
3718
- let e = sessionStorage.getItem(Fr);
3786
+ let e = sessionStorage.getItem(Br);
3719
3787
  this.federatedSlot = e ? JSON.parse(e) : void 0;
3720
3788
  } catch {
3721
3789
  this.federatedSlot = void 0;
@@ -3724,7 +3792,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3724
3792
  }
3725
3793
  forgetFederatedSlot() {
3726
3794
  if (this.federatedSlot = void 0, typeof sessionStorage < "u") try {
3727
- sessionStorage.removeItem(Fr);
3795
+ sessionStorage.removeItem(Br);
3728
3796
  } catch {}
3729
3797
  }
3730
3798
  async startPkce() {
@@ -3742,7 +3810,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3742
3810
  }
3743
3811
  async completePkceSignIn(e) {
3744
3812
  let t = this.readPendingPkce();
3745
- if (!t) throw Error(zr);
3813
+ if (!t) throw Error(Wr);
3746
3814
  let n = await this.authApi.pkceExchange(e, t.verifier);
3747
3815
  return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
3748
3816
  }
@@ -3766,7 +3834,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3766
3834
  if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
3767
3835
  }
3768
3836
  async signIn(e) {
3769
- if ("email" in e && e.email && !Er(e.email)) {
3837
+ if ("email" in e && e.email && !jr(e.email)) {
3770
3838
  let e = /* @__PURE__ */ Error("Invalid email format"), t = {
3771
3839
  operation: "sign-in",
3772
3840
  message: "Invalid email format",
@@ -3775,7 +3843,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3775
3843
  };
3776
3844
  throw U(this.subscribeStore, t), e;
3777
3845
  }
3778
- if ("username" in e && e.username && !Or(e.username)) {
3846
+ if ("username" in e && e.username && !Nr(e.username)) {
3779
3847
  let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
3780
3848
  operation: "sign-in",
3781
3849
  message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
@@ -3784,7 +3852,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3784
3852
  };
3785
3853
  throw U(this.subscribeStore, t), e;
3786
3854
  }
3787
- if ("phone" in e && e.phone && !Dr(e.phone)) {
3855
+ if ("phone" in e && e.phone && !Mr(e.phone)) {
3788
3856
  let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
3789
3857
  operation: "sign-in",
3790
3858
  message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
@@ -3818,7 +3886,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3818
3886
  }
3819
3887
  }
3820
3888
  async signUp(e) {
3821
- if (e.user.email && !Er(e.user.email)) {
3889
+ if (e.user.email && !jr(e.user.email)) {
3822
3890
  let e = /* @__PURE__ */ Error("Invalid email format"), t = {
3823
3891
  operation: "sign-up",
3824
3892
  message: "Invalid email format",
@@ -3827,7 +3895,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3827
3895
  };
3828
3896
  throw U(this.subscribeStore, t), e;
3829
3897
  }
3830
- if (e.user.phone_number && !Dr(e.user.phone_number)) {
3898
+ if (e.user.phone_number && !Mr(e.user.phone_number)) {
3831
3899
  let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
3832
3900
  operation: "sign-up",
3833
3901
  message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
@@ -3859,7 +3927,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3859
3927
  }
3860
3928
  }
3861
3929
  async passwordlessSignIn(e) {
3862
- if (e.email && !Er(e.email)) {
3930
+ if (e.email && !jr(e.email)) {
3863
3931
  let e = /* @__PURE__ */ Error("Invalid email format"), t = {
3864
3932
  operation: "passwordless.start",
3865
3933
  message: "Invalid email format",
@@ -3868,7 +3936,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3868
3936
  };
3869
3937
  throw U(this.subscribeStore, t), e;
3870
3938
  }
3871
- if (e.phone && !Dr(e.phone)) {
3939
+ if (e.phone && !Mr(e.phone)) {
3872
3940
  let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
3873
3941
  operation: "passwordless.start",
3874
3942
  message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
@@ -3912,7 +3980,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3912
3980
  if (r = !0, this.handlePendingSecondFactor(t, n?.email, n && { verifier: n.verifier }, n?.scopes)) return this.forgetPendingPasswordless(), t;
3913
3981
  let i = t;
3914
3982
  if (t.code) {
3915
- if (!n) throw Error(zr);
3983
+ if (!n) throw Error(Wr);
3916
3984
  if (i = await this.authApi.pkceExchange(t.code, n.verifier), this.handlePendingSecondFactor(i)) return this.forgetPendingPasswordless(), {
3917
3985
  ...i,
3918
3986
  redirect_url: t.redirect_url ?? ""
@@ -3944,11 +4012,11 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3944
4012
  let n = t?.signal;
3945
4013
  try {
3946
4014
  let t = this.readPendingPasswordless();
3947
- if (t?.challengeId !== e) throw Error(zr);
4015
+ if (t?.challengeId !== e) throw Error(Wr);
3948
4016
  for (;;) {
3949
4017
  if (n?.aborted) throw n.reason;
3950
4018
  if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
3951
- if (this.readPendingPasswordless()?.challengeId !== e) throw Error(zr);
4019
+ if (this.readPendingPasswordless()?.challengeId !== e) throw Error(Wr);
3952
4020
  let r;
3953
4021
  try {
3954
4022
  r = await this.authApi.passwordlessStatus({
@@ -3961,7 +4029,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3961
4029
  }
3962
4030
  if (r?.status === "denied" || r?.status === "expired" || r?.status === "completed") return this.forgetPendingPasswordless(), { status: r.status };
3963
4031
  if (r?.status === "approved" && r.code) return await this.finishApprovedPasswordless(r.code, t);
3964
- await Br(Pr, n);
4032
+ await Gr(zr, n);
3965
4033
  }
3966
4034
  } catch (e) {
3967
4035
  if (n?.aborted && e === n.reason) throw e;
@@ -3995,6 +4063,9 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
3995
4063
  expiresAt: t.expiresAt
3996
4064
  };
3997
4065
  }
4066
+ checkRedirectUrl(e) {
4067
+ return this.authApi.checkRedirectUrl(e);
4068
+ }
3998
4069
  async getPasswordlessApproval(e) {
3999
4070
  try {
4000
4071
  return await this.authApi.passwordlessApprovalInfo({ challenge_id: e });
@@ -4027,14 +4098,14 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4027
4098
  let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
4028
4099
  try {
4029
4100
  let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
4030
- if (t?.pkce && !r) throw Error(zr);
4101
+ if (t?.pkce && !r) throw Error(Wr);
4031
4102
  let i = await this.authApi.validateEmailCode(e);
4032
4103
  this.emailChallenges.delete(e.challenge_id);
4033
4104
  let a = r?.scopes ?? t?.scopes ?? this.scopes;
4034
4105
  if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
4035
4106
  let o = i;
4036
4107
  if (i.code) {
4037
- if (!r) throw Error(zr);
4108
+ if (!r) throw Error(Wr);
4038
4109
  if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
4039
4110
  }
4040
4111
  let s = i.redirect_url ? {
@@ -4088,13 +4159,13 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4088
4159
  readSessionPin() {
4089
4160
  try {
4090
4161
  let e = this.storageManager.getToken(j.access_token);
4091
- return e ? Sr(A(e)) : void 0;
4162
+ return e ? Dr(A(e)) : void 0;
4092
4163
  } catch {
4093
4164
  return;
4094
4165
  }
4095
4166
  }
4096
4167
  assertSessionPin(e) {
4097
- if (e && !Cr(e, this.readSessionPin())) throw console.warn("[passflow] the session or user changed while a step-up upgrade was in flight; the elevated tokens were discarded and the live session was left untouched."), new xr("The session changed during verification, so the elevated tokens were discarded");
4168
+ if (e && !Or(e, this.readSessionPin())) throw console.warn("[passflow] the session or user changed while a step-up upgrade was in flight; the elevated tokens were discarded and the live session was left untouched."), new Er("The session changed during verification, so the elevated tokens were discarded");
4098
4169
  }
4099
4170
  refreshMode() {
4100
4171
  return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
@@ -4228,10 +4299,10 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4228
4299
  }
4229
4300
  async resetPassword(e, t, n) {
4230
4301
  this.subscribeStore.notify(Z.SignInStart, {});
4231
- let r = n ?? Vr(this.platform.getCurrentUrl()), i = t ?? this.scopes;
4302
+ let r = n ?? Kr(this.platform.getCurrentUrl()), i = t ?? this.scopes;
4232
4303
  try {
4233
4304
  let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
4234
- if (this.handleEmailVerificationStep(n, "reset-password", Hr(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
4305
+ if (this.handleEmailVerificationStep(n, "reset-password", qr(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
4235
4306
  let a = await this.exchangeCode(n, t);
4236
4307
  if (this.handlePendingSecondFactor(a)) return a;
4237
4308
  let o = n.redirect_url ? {
@@ -4312,7 +4383,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4312
4383
  }
4313
4384
  createFederatedAuthUrl(e) {
4314
4385
  let t = `/auth/federated/start/${e.provider}`;
4315
- if (!this.appId) throw Error(Lr);
4386
+ if (!this.appId) throw Error(Hr);
4316
4387
  let n = {
4317
4388
  scopes: (e.scopes ?? this.scopes).join(" "),
4318
4389
  redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
@@ -4326,7 +4397,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4326
4397
  return r.search = new URLSearchParams(n).toString(), r.toString();
4327
4398
  }
4328
4399
  async federatedAuthWithPopup(e) {
4329
- if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(Lr);
4400
+ if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(Hr);
4330
4401
  let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
4331
4402
  try {
4332
4403
  this.forgetFederatedSlot();
@@ -4353,7 +4424,9 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4353
4424
  id_token: f || void 0,
4354
4425
  scopes: t
4355
4426
  };
4356
- if (l && r && (p = await this.authApi.pkceExchange(l, r.verifier), this.handlePendingSecondFactor(p))) return;
4427
+ if (l && r) {
4428
+ if (p = await this.authApi.pkceExchange(l, r.verifier), this.handlePendingSecondFactor(p)) return;
4429
+ } else await lr(this.url, this.appId, p);
4357
4430
  await this.processAuthResponse(p, t), this.subscribeStore.notify(Z.SignIn, {
4358
4431
  tokens: p,
4359
4432
  parsedTokens: this.tokenCacheService.getParsedTokens()
@@ -4370,7 +4443,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4370
4443
  }
4371
4444
  }
4372
4445
  federatedAuthWithRedirect(e) {
4373
- if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(Lr);
4446
+ if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(Hr);
4374
4447
  let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
4375
4448
  this.startPkce().then((r) => {
4376
4449
  let i = this.createFederatedAuthUrl({
@@ -4500,7 +4573,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4500
4573
  return;
4501
4574
  }
4502
4575
  }
4503
- }, Wr = class {
4576
+ }, Yr = class {
4504
4577
  constructor(e) {
4505
4578
  this.invitationApi = e;
4506
4579
  }
@@ -4519,7 +4592,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4519
4592
  getInvitationLink(e) {
4520
4593
  return this.invitationApi.getInvitationLink(e);
4521
4594
  }
4522
- }, Gr = class {
4595
+ }, Xr = class {
4523
4596
  constructor(e) {
4524
4597
  this.data = this.normalize(e);
4525
4598
  }
@@ -4576,7 +4649,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4576
4649
  getData() {
4577
4650
  return this.data;
4578
4651
  }
4579
- }, Kr = class {
4652
+ }, Zr = class {
4580
4653
  constructor(e, t, n) {
4581
4654
  this.tenantApi = e, this.scopes = t, this.logger = n || En();
4582
4655
  }
@@ -4614,7 +4687,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4614
4687
  }
4615
4688
  async getTenantUserMembership(e) {
4616
4689
  try {
4617
- return new Gr(await this.tenantApi.getTenantDetails(e));
4690
+ return new Xr(await this.tenantApi.getTenantDetails(e));
4618
4691
  } catch (t) {
4619
4692
  this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
4620
4693
  }
@@ -4759,7 +4832,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4759
4832
  this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
4760
4833
  }
4761
4834
  }
4762
- }, qr = class {
4835
+ }, Qr = class {
4763
4836
  constructor(e, t, n, r = P) {
4764
4837
  this.storageManager = e, this.subscribeStore = n, this.platform = r, this.checkInterval = null, this.CHECK_INTERVAL = 6e4, this.unsubscribeForeground = null, this.unsubscribeUnload = null, this.tokenExpiredFlag = !1, this.storageManager = e, this.setupLifecycleListeners();
4765
4838
  }
@@ -4839,7 +4912,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4839
4912
  isExpired() {
4840
4913
  return this.tokensCache ? this.tokensCache.access_token ? k(A(this.tokensCache.access_token)) : !1 : !0;
4841
4914
  }
4842
- }, Jr = class {
4915
+ }, $r = class {
4843
4916
  constructor(e, t, n) {
4844
4917
  this.twoFactorApi = e, this.subscribeStore = t, this.signInCompleter = n, this.PARTIAL_AUTH_TIMEOUT_MS = 3e5, this.SESSION_STORAGE_KEY = "passflow_2fa_challenge", this.totpDigits = 6, this.subscribeStore.subscribe({ onAuthChange: (e, t) => {
4845
4918
  if (e === Z.TwoFactorRequired) {
@@ -4916,7 +4989,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4916
4989
  }
4917
4990
  }
4918
4991
  assertTotpCode(e) {
4919
- if (!kr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
4992
+ if (!Pr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
4920
4993
  }
4921
4994
  requirePendingTfaToken() {
4922
4995
  let e = this.pendingTfaToken();
@@ -4935,7 +5008,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4935
5008
  }), e;
4936
5009
  }
4937
5010
  async verify(e, t) {
4938
- if (!kr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
5011
+ if (!Pr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
4939
5012
  if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
4940
5013
  if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
4941
5014
  try {
@@ -4951,7 +5024,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4951
5024
  }
4952
5025
  async useRecoveryCode(e, t) {
4953
5026
  try {
4954
- let n = Ar(e);
5027
+ let n = Fr(e);
4955
5028
  if (!n) throw Error("Invalid recovery code format. Expected format: XXXX-XXXX or XXXXXXXX (alphanumeric).");
4956
5029
  if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
4957
5030
  if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
@@ -4972,7 +5045,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4972
5045
  }
4973
5046
  }
4974
5047
  async disable(e) {
4975
- if (!kr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
5048
+ if (!Pr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
4976
5049
  try {
4977
5050
  let t = await this.twoFactorApi.disable({ code: e });
4978
5051
  return this.subscribeStore.notify(Z.TwoFactorDisabled, {}), t;
@@ -4981,7 +5054,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
4981
5054
  }
4982
5055
  }
4983
5056
  async regenerateRecoveryCodes(e) {
4984
- if (!kr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
5057
+ if (!Pr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
4985
5058
  try {
4986
5059
  let t = await this.twoFactorApi.regenerateRecoveryCodes({ code: e }), n = [...t.recovery_codes];
4987
5060
  return t.recovery_codes = [], t.recovery_codes = n, t;
@@ -5165,7 +5238,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5165
5238
  this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
5166
5239
  }
5167
5240
  }
5168
- }, Yr = class {
5241
+ }, ei = class {
5169
5242
  constructor(e, t, n = P) {
5170
5243
  this.userAPI = e, this.deviceService = t, this.platform = n;
5171
5244
  }
@@ -5192,69 +5265,69 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5192
5265
  if (!s) throw Error("Passkey registration was not completed");
5193
5266
  return await this.userAPI.addUserPasskeyComplete(s, r, a);
5194
5267
  }
5195
- }, Xr = class extends Error {
5268
+ }, ti = class extends Error {
5196
5269
  constructor(e, t, n = !1) {
5197
5270
  super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
5198
5271
  }
5199
- }, Zr = (e, t) => {
5272
+ }, ni = (e, t) => {
5200
5273
  let n = t?.trim();
5201
- if (!n) throw new Xr(e, "A verification code is required");
5274
+ if (!n) throw new ti(e, "A verification code is required");
5202
5275
  return n;
5203
- }, Qr = {
5276
+ }, ri = {
5204
5277
  type: "totp",
5205
5278
  requiresPrepare: !1,
5206
5279
  input: "code",
5207
- assert: async ({ code: e }) => ({ code: Zr("totp", e) })
5208
- }, $r = {
5280
+ assert: async ({ code: e }) => ({ code: ni("totp", e) })
5281
+ }, ii = {
5209
5282
  type: "recovery_codes",
5210
5283
  requiresPrepare: !1,
5211
5284
  input: "code",
5212
- assert: async ({ code: e }) => ({ code: Zr("recovery_codes", e) })
5213
- }, ei = {
5285
+ assert: async ({ code: e }) => ({ code: ni("recovery_codes", e) })
5286
+ }, ai = {
5214
5287
  type: "passkey",
5215
5288
  requiresPrepare: !0,
5216
5289
  input: "none",
5217
5290
  assert: async ({ prepared: e, platform: t }) => {
5218
- if (!e?.webauthn) throw new Xr("passkey", "The upgrade challenge carried no WebAuthn options");
5291
+ if (!e?.webauthn) throw new ti("passkey", "The upgrade challenge carried no WebAuthn options");
5219
5292
  let n = t.passkeys;
5220
- if (!n) throw new Xr("passkey", "This platform does not support passkeys");
5293
+ if (!n) throw new ti("passkey", "This platform does not support passkeys");
5221
5294
  let r;
5222
5295
  try {
5223
5296
  r = await n.startAuthentication(e.webauthn);
5224
5297
  } catch (e) {
5225
- throw new Xr("passkey", e?.message || "Passkey verification was cancelled", !0);
5298
+ throw new ti("passkey", e?.message || "Passkey verification was cancelled", !0);
5226
5299
  }
5227
- if (!r) throw new Xr("passkey", "Passkey verification was cancelled", !0);
5300
+ if (!r) throw new ti("passkey", "Passkey verification was cancelled", !0);
5228
5301
  return {
5229
5302
  challenge_id: e.challengeId,
5230
5303
  credential: r
5231
5304
  };
5232
5305
  }
5233
- }, ti = Object.freeze([
5234
- Qr,
5235
- ei,
5236
- $r
5237
- ]), ni = (e = ti) => new Map(e.map((e) => [e.type, e])), ri = 3, ii = {
5306
+ }, oi = Object.freeze([
5307
+ ri,
5308
+ ai,
5309
+ ii
5310
+ ]), si = (e = oi) => new Map(e.map((e) => [e.type, e])), ci = 3, li = {
5238
5311
  passkey: 0,
5239
5312
  totp: 1,
5240
5313
  email_otp: 2,
5241
5314
  sms_otp: 3,
5242
5315
  recovery_codes: 9
5243
- }, ai = (e) => e.requiredLevel ?? L(e.acrValues), oi = (e, t) => {
5244
- let n = ii[e.type] ?? 5, r = t !== void 0 && t >= ri, i = e.type === "passkey";
5316
+ }, ui = (e) => e.requiredLevel ?? L(e.acrValues), di = (e, t) => {
5317
+ let n = li[e.type] ?? 5, r = t !== void 0 && t >= ci, i = e.type === "passkey";
5245
5318
  return (r && !i ? 100 : 0) + n;
5246
- }, si = (e, t) => {
5247
- let n = ai(t);
5248
- return [...e].sort((e, t) => oi(e, n) - oi(t, n));
5249
- }, ci = class extends Error {
5319
+ }, fi = (e, t) => {
5320
+ let n = ui(t);
5321
+ return [...e].sort((e, t) => di(e, n) - di(t, n));
5322
+ }, pi = class extends Error {
5250
5323
  constructor(e) {
5251
5324
  super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
5252
5325
  }
5253
- }, li = class extends Error {
5326
+ }, mi = class extends Error {
5254
5327
  constructor(e = "No available authentication factor can satisfy this challenge") {
5255
5328
  super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
5256
5329
  }
5257
- }, ui = 4, di = 3e4, fi = () => {
5330
+ }, hi = 4, gi = 3e4, _i = () => {
5258
5331
  let e = () => void 0, t = () => void 0;
5259
5332
  return {
5260
5333
  promise: new Promise((n, r) => {
@@ -5263,11 +5336,11 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5263
5336
  resolve: e,
5264
5337
  reject: t
5265
5338
  };
5266
- }, pi = (e) => ({
5339
+ }, vi = (e) => ({
5267
5340
  acrValues: e.acrValues,
5268
5341
  level: e.requiredLevel,
5269
5342
  maxAge: e.maxAge
5270
- }), mi = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, hi = (e, t) => {
5343
+ }), yi = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, bi = (e, t) => {
5271
5344
  let n = e.requiredLevel === void 0 ? t.requiredLevel : t.requiredLevel === void 0 ? e.requiredLevel : Math.max(e.requiredLevel, t.requiredLevel), r = n === void 0 ? e.acrValues ?? t.acrValues : n === e.requiredLevel ? e.acrValues : t.acrValues, i = e.maxAge === void 0 ? t.maxAge : t.maxAge === void 0 ? e.maxAge : Math.min(e.maxAge, t.maxAge), a = Array.from(/* @__PURE__ */ new Set([...e.channels ?? [], ...t.channels ?? []]));
5272
5345
  return {
5273
5346
  acrValues: r,
@@ -5276,12 +5349,12 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5276
5349
  status: e.status,
5277
5350
  ...a.length > 0 ? { channels: a } : {}
5278
5351
  };
5279
- }, gi = (e, t) => {
5352
+ }, xi = (e, t) => {
5280
5353
  let n = t.requiredLevel !== void 0 && (e.requiredLevel === void 0 || t.requiredLevel > e.requiredLevel), r = t.maxAge !== void 0 && (e.maxAge === void 0 || t.maxAge < e.maxAge);
5281
5354
  return n || r;
5282
- }, _i = class {
5355
+ }, Si = class {
5283
5356
  constructor(e) {
5284
- 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 ?? ti, this.registry = ni(this.available), this.maxAttempts = e.maxAttempts ?? ui, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? di;
5357
+ 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 ?? oi, this.registry = si(this.available), this.maxAttempts = e.maxAttempts ?? hi, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? gi;
5285
5358
  }
5286
5359
  get currentState() {
5287
5360
  return this.state;
@@ -5301,9 +5374,9 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5301
5374
  }
5302
5375
  register(e, t) {
5303
5376
  let n = t.kind === "imperative" && t.requested !== void 0, r = {
5304
- demanded: t.kind === "imperative" && t.requested ? t.requested : pi(e),
5377
+ demanded: t.kind === "imperative" && t.requested ? t.requested : vi(e),
5305
5378
  statedBar: n,
5306
- settlement: fi(),
5379
+ settlement: _i(),
5307
5380
  reported: !1,
5308
5381
  entry: {
5309
5382
  ...t,
@@ -5319,15 +5392,15 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5319
5392
  this.requirement = e;
5320
5393
  return;
5321
5394
  }
5322
- let n = gi(t, e);
5323
- this.requirement = hi(t, e), n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
5395
+ let n = xi(t, e);
5396
+ this.requirement = bi(t, e), n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
5324
5397
  challenge: this.requirement,
5325
5398
  factors: this.offeredFactors()
5326
5399
  });
5327
5400
  }
5328
5401
  offeredFactors() {
5329
5402
  let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
5330
- return t ? si(e, t) : e;
5403
+ return t ? fi(e, t) : e;
5331
5404
  }
5332
5405
  receiveReport(e, t) {
5333
5406
  e.reported || (e.reported = !0, e.entry.outcome = t.outcome, t.obtained && (e.entry.obtained = t.obtained), t.required && (e.entry.required = t.required), this.notifyReportsSettled());
@@ -5362,12 +5435,12 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5362
5435
  }
5363
5436
  release(e, t) {
5364
5437
  if (e.entry.kind === "imperative") {
5365
- if (e.statedBar && !mi(t, e.demanded)) {
5438
+ if (e.statedBar && !yi(t, e.demanded)) {
5366
5439
  this.receiveReport(e, {
5367
5440
  outcome: "insufficient",
5368
5441
  obtained: t,
5369
5442
  required: e.demanded
5370
- }), e.settlement.reject(new yr(t, e.demanded));
5443
+ }), e.settlement.reject(new wr(t, e.demanded));
5371
5444
  return;
5372
5445
  }
5373
5446
  this.receiveReport(e, {
@@ -5440,7 +5513,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5440
5513
  let t = this.offeredFactors();
5441
5514
  if (t.length === 0) return {
5442
5515
  status: "failed",
5443
- reason: new li()
5516
+ reason: new mi()
5444
5517
  };
5445
5518
  let n = this.requirement, r;
5446
5519
  try {
@@ -5448,24 +5521,24 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5448
5521
  } catch (e) {
5449
5522
  return {
5450
5523
  status: "failed",
5451
- reason: new ci(e)
5524
+ reason: new pi(e)
5452
5525
  };
5453
5526
  }
5454
5527
  if (r.type === "cancel") return {
5455
5528
  status: "failed",
5456
- reason: new ci()
5529
+ reason: new pi()
5457
5530
  };
5458
5531
  let i = this.registry.get(r.factor);
5459
- if (!i) e = new li(`Unknown authentication factor: ${r.factor}`), this.state = "collecting", this.selected = null;
5532
+ if (!i) e = new mi(`Unknown authentication factor: ${r.factor}`), this.state = "collecting", this.selected = null;
5460
5533
  else try {
5461
5534
  return await this.proveAndCommit(i, r.code), {
5462
5535
  status: "proven",
5463
- obtained: this.readObtainedBar?.() ?? pi(this.rankedRequirement ?? n)
5536
+ obtained: this.readObtainedBar?.() ?? vi(this.rankedRequirement ?? n)
5464
5537
  };
5465
5538
  } catch (t) {
5466
- if (t instanceof Xr && t.cancelled) return {
5539
+ if (t instanceof ti && t.cancelled) return {
5467
5540
  status: "failed",
5468
- reason: new ci()
5541
+ reason: new pi()
5469
5542
  };
5470
5543
  let n = this.classifyProofFailure(t);
5471
5544
  if (n) return {
@@ -5495,15 +5568,15 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5495
5568
  return this.openPrompt = r, this.prompt(r);
5496
5569
  }
5497
5570
  classifyProofFailure(e) {
5498
- if (e instanceof yr || e instanceof br || e instanceof xr) return e;
5571
+ if (e instanceof wr || e instanceof Tr || e instanceof Er) return e;
5499
5572
  if (e instanceof $) switch (e.kind) {
5500
- case "unavailable": return new br(e.message);
5573
+ case "unavailable": return new Tr(e.message);
5501
5574
  case "exhausted":
5502
5575
  case "attempts_exhausted":
5503
5576
  case "fatal":
5504
5577
  case "protocol":
5505
5578
  case "network": return e;
5506
- case "session_changed": return new xr(e.message);
5579
+ case "session_changed": return new Er(e.message);
5507
5580
  default: return;
5508
5581
  }
5509
5582
  }
@@ -5515,28 +5588,28 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5515
5588
  });
5516
5589
  await this.transport.commit(e.type, r);
5517
5590
  }
5518
- }, vi = (e) => typeof e == "function" ? e() : e, yi = (e) => {
5591
+ }, Ci = (e) => typeof e == "function" ? e() : e, wi = (e) => {
5519
5592
  try {
5520
5593
  return new URL(e);
5521
5594
  } catch {
5522
5595
  return;
5523
5596
  }
5524
- }, bi = (e, t) => {
5597
+ }, Ti = (e, t) => {
5525
5598
  if (!t || t === "/") return !0;
5526
5599
  let n = t.replace(/\/+$/, "");
5527
5600
  return e === n || e.startsWith(`${n}/`);
5528
- }, xi = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && bi(e.pathname, t.pathPrefix), Si = (e, t) => {
5601
+ }, Ei = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && Ti(e.pathname, t.pathPrefix), Di = (e, t) => {
5529
5602
  for (let n of t) {
5530
5603
  if (n === "") continue;
5531
5604
  if (n.startsWith("/")) {
5532
- if (e.relativeToBase && bi(e.pathname, n)) return !0;
5605
+ if (e.relativeToBase && Ti(e.pathname, n)) return !0;
5533
5606
  continue;
5534
5607
  }
5535
- let t = yi(n) ?? yi(`https://${n}`);
5536
- if (t && e.origin !== void 0 && e.origin === t.origin && bi(e.pathname, t.pathname)) return !0;
5608
+ let t = wi(n) ?? wi(`https://${n}`);
5609
+ if (t && e.origin !== void 0 && e.origin === t.origin && Ti(e.pathname, t.pathname)) return !0;
5537
5610
  }
5538
5611
  return !1;
5539
- }, Ci = (e, t, n) => xi(e, t.passflow) || Si(e, t.backend) ? !n || n(e.href) !== !1 : !1, wi = (e) => {
5612
+ }, Oi = (e, t, n) => Ei(e, t.passflow) || Di(e, t.backend) ? !n || n(e.href) !== !1 : !1, ki = (e) => {
5540
5613
  let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
5541
5614
  console.warn(n, {
5542
5615
  status: e.status,
@@ -5544,8 +5617,8 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5544
5617
  reason: e.reason,
5545
5618
  detail: t
5546
5619
  });
5547
- }, Ti = (e, t) => {
5548
- let n = t.onUpgradeDiagnostic ?? wi;
5620
+ }, Ai = (e, t) => {
5621
+ let n = t.onUpgradeDiagnostic ?? ki;
5549
5622
  return (t, r) => {
5550
5623
  n({
5551
5624
  status: e.status,
@@ -5557,8 +5630,8 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5557
5630
  }
5558
5631
  });
5559
5632
  };
5560
- }, Ei = (e, t, n) => {
5561
- let r = n.onUpgradeDiagnostic ?? wi;
5633
+ }, ji = (e, t, n) => {
5634
+ let r = n.onUpgradeDiagnostic ?? ki;
5562
5635
  for (let n of e) r({
5563
5636
  ...n,
5564
5637
  url: t.request.href,
@@ -5567,8 +5640,8 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5567
5640
  ...n.detail ?? {}
5568
5641
  }
5569
5642
  });
5570
- }, Di = /\bjson\b/i, Oi = async (e, t) => {
5571
- let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && Di.test(r), a;
5643
+ }, Mi = /\bjson\b/i, Ni = async (e, t) => {
5644
+ let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && Mi.test(r), a;
5572
5645
  if (i) try {
5573
5646
  a = await e.readBody();
5574
5647
  } catch {
@@ -5582,10 +5655,10 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5582
5655
  status: e.status,
5583
5656
  getHeader: (t) => e.getHeader(t) ?? void 0
5584
5657
  }, { requireChallengeChannel: t.requireChallengeChannel });
5585
- }, ki = (e) => ve({
5658
+ }, Pi = (e) => ve({
5586
5659
  status: e.status,
5587
5660
  getHeader: (t) => e.getHeader(t) ?? void 0
5588
- }, { requireChallengeChannel: "header" }).challenge, Ai = (e, t) => t.passflow === null ? `[passflow] a 401/403 from ${e} carried an upgrade challenge, but no Passflow endpoint is configured — set \`url\` on the Passflow config.` : `[passflow] a 401/403 from ${e} carried an upgrade challenge, but that URL is not covered by the provider's \`backend\` prop — add it there to enable step-up for this API.`, ji = (e, t) => e instanceof ci ? { kind: "cancelled" } : e instanceof li ? { kind: "unsatisfiable" } : e instanceof br ? { kind: "unavailable" } : e instanceof xr ? { kind: "session-changed" } : e instanceof yr ? {
5661
+ }, { requireChallengeChannel: "header" }).challenge, Fi = (e, t) => t.passflow === null ? `[passflow] a 401/403 from ${e} carried an upgrade challenge, but no Passflow endpoint is configured — set \`url\` on the Passflow config.` : `[passflow] a 401/403 from ${e} carried an upgrade challenge, but that URL is not covered by the provider's \`backend\` prop — add it there to enable step-up for this API.`, Ii = (e, t) => e instanceof pi ? { kind: "cancelled" } : e instanceof mi ? { kind: "unsatisfiable" } : e instanceof Tr ? { kind: "unavailable" } : e instanceof Er ? { kind: "session-changed" } : e instanceof wr ? {
5589
5662
  kind: "insufficient",
5590
5663
  obtained: e.obtained,
5591
5664
  required: e.required
@@ -5601,17 +5674,17 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5601
5674
  kind: "transport-failure",
5602
5675
  retryable: !1,
5603
5676
  error: e instanceof Error ? e : Error(String(e))
5604
- }, Mi = async (e, t, n, r) => {
5677
+ }, Li = async (e, t, n, r) => {
5605
5678
  if (e.status !== 401 && e.status !== 403) return {
5606
5679
  kind: "replayed",
5607
5680
  response: e
5608
5681
  };
5609
- let { challenge: i, diagnostics: a } = await Oi(e, t);
5610
- if (Ei(a, e, t), !i) return {
5682
+ let { challenge: i, diagnostics: a } = await Ni(e, t);
5683
+ if (ji(a, e, t), !i) return {
5611
5684
  kind: "replayed",
5612
5685
  response: e
5613
5686
  };
5614
- let o = pi(i);
5687
+ let o = vi(i);
5615
5688
  return r("elevated-insufficient", {
5616
5689
  obtained: n,
5617
5690
  required: o
@@ -5621,7 +5694,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5621
5694
  required: o,
5622
5695
  response: e
5623
5696
  };
5624
- }, Ni = async (e, t) => {
5697
+ }, Ri = async (e, t) => {
5625
5698
  if (!t) return {
5626
5699
  aborted: !1,
5627
5700
  value: await e
@@ -5648,14 +5721,14 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5648
5721
  } finally {
5649
5722
  n && t.removeEventListener?.("abort", n);
5650
5723
  }
5651
- }, Pi = async (e, t) => {
5724
+ }, zi = async (e, t) => {
5652
5725
  if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
5653
- let n = Ti(e, t);
5726
+ let n = Ai(e, t);
5654
5727
  if (e.markers.replayed) {
5655
- if (!Ci(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
5656
- let { challenge: r, diagnostics: i } = await Oi(e, t);
5657
- if (Ei(i, e, t), !r) return { kind: "not-a-challenge" };
5658
- let a = t.readObtainedBar?.() ?? {}, o = pi(r);
5728
+ if (!Oi(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
5729
+ let { challenge: r, diagnostics: i } = await Ni(e, t);
5730
+ if (ji(i, e, t), !r) return { kind: "not-a-challenge" };
5731
+ let a = t.readObtainedBar?.() ?? {}, o = vi(r);
5659
5732
  return n("elevated-insufficient", {
5660
5733
  obtained: a,
5661
5734
  required: o
@@ -5666,12 +5739,12 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5666
5739
  response: e
5667
5740
  };
5668
5741
  }
5669
- if (!Ci(e.request, t.scope, t.shouldIntercept)) return ki(e) ? (n("challenge-out-of-scope", {
5742
+ if (!Oi(e.request, t.scope, t.shouldIntercept)) return Pi(e) ? (n("challenge-out-of-scope", {
5670
5743
  header: e.getHeader("www-authenticate") ?? void 0,
5671
- message: Ai(e.request.href, t.scope)
5744
+ message: Fi(e.request.href, t.scope)
5672
5745
  }), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
5673
- let { challenge: r, diagnostics: i } = await Oi(e, t);
5674
- if (Ei(i, e, t), !r) {
5746
+ let { challenge: r, diagnostics: i } = await Ni(e, t);
5747
+ if (ji(i, e, t), !r) {
5675
5748
  let r = e.getHeader("www-authenticate");
5676
5749
  return t.requireChallengeChannel !== "header" && n("no-channel", {
5677
5750
  ...r ? { header: r } : {},
@@ -5685,9 +5758,9 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5685
5758
  method: e.request.method
5686
5759
  }, s, c;
5687
5760
  try {
5688
- s = Promise.resolve(t.elevate(r, o)), c = await Ni(s, e.signal);
5761
+ s = Promise.resolve(t.elevate(r, o)), c = await Ri(s, e.signal);
5689
5762
  } catch (e) {
5690
- return ji(e, void 0);
5763
+ return Ii(e, void 0);
5691
5764
  }
5692
5765
  if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
5693
5766
  kind: "aborted",
@@ -5698,7 +5771,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5698
5771
  kind: "aborted",
5699
5772
  reason: e.signal.reason
5700
5773
  };
5701
- let u = l?.obtained ?? t.readObtainedBar?.() ?? pi(r), d = t.authorizationSwap?.(), f = d ? {
5774
+ let u = l?.obtained ?? t.readObtainedBar?.() ?? vi(r), d = t.authorizationSwap?.(), f = d ? {
5702
5775
  from: a?.from ?? d.from,
5703
5776
  to: d.to
5704
5777
  } : void 0;
@@ -5707,7 +5780,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5707
5780
  try {
5708
5781
  p = await e.replay(f ? { authorizationSwap: f } : void 0);
5709
5782
  } catch (t) {
5710
- if (t instanceof yr) return l?.waiter.report({
5783
+ if (t instanceof wr) return l?.waiter.report({
5711
5784
  outcome: "insufficient",
5712
5785
  obtained: t.obtained,
5713
5786
  required: t.required
@@ -5725,7 +5798,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5725
5798
  };
5726
5799
  throw t;
5727
5800
  }
5728
- let m = await Mi(p, t, u, n);
5801
+ let m = await Li(p, t, u, n);
5729
5802
  return m.kind === "insufficient" ? l?.waiter.report({
5730
5803
  outcome: "insufficient",
5731
5804
  obtained: m.obtained,
@@ -5734,18 +5807,18 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5734
5807
  outcome: "replayed",
5735
5808
  obtained: u
5736
5809
  }), m;
5737
- }, Fi = (e) => {
5810
+ }, Bi = (e) => {
5738
5811
  switch (e.kind) {
5739
- case "cancelled": return new ci();
5740
- case "unsatisfiable": return new li();
5741
- case "unavailable": return new br();
5742
- case "session-changed": return new xr();
5743
- case "insufficient": return new yr(e.obtained, e.required);
5812
+ case "cancelled": return new pi();
5813
+ case "unsatisfiable": return new mi();
5814
+ case "unavailable": return new Tr();
5815
+ case "session-changed": return new Er();
5816
+ case "insufficient": return new wr(e.obtained, e.required);
5744
5817
  case "exhausted": return e.error;
5745
5818
  case "transport-failure": return e.error;
5746
5819
  default: return;
5747
5820
  }
5748
- }, Ii = (e, t, n) => {
5821
+ }, Vi = (e, t, n) => {
5749
5822
  switch (e.kind) {
5750
5823
  case "replayed": return {
5751
5824
  settle: "resolve",
@@ -5763,21 +5836,21 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5763
5836
  };
5764
5837
  case "cancelled": return n.onCancel === "reject" ? {
5765
5838
  settle: "reject",
5766
- error: new ci()
5839
+ error: new pi()
5767
5840
  } : {
5768
5841
  settle: "resolve",
5769
- value: Gi(t, e)
5842
+ value: Xi(t, e)
5770
5843
  };
5771
5844
  case "insufficient": return {
5772
5845
  settle: "resolve",
5773
- value: Gi(e.response?.raw ?? t, e)
5846
+ value: Xi(e.response?.raw ?? t, e)
5774
5847
  };
5775
5848
  default: return {
5776
5849
  settle: "resolve",
5777
- value: Gi(t, e)
5850
+ value: Xi(t, e)
5778
5851
  };
5779
5852
  }
5780
- }, Li = (e, t) => {
5853
+ }, Hi = (e, t) => {
5781
5854
  switch (e.kind) {
5782
5855
  case "replayed": return e.response.rejected ? {
5783
5856
  settle: "reject",
@@ -5792,39 +5865,39 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5792
5865
  };
5793
5866
  default: return {
5794
5867
  settle: "reject",
5795
- error: Fi(e) ?? t
5868
+ error: Bi(e) ?? t
5796
5869
  };
5797
5870
  }
5798
- }, Ri = /* @__PURE__ */ new WeakSet(), zi = /* @__PURE__ */ new WeakSet(), Bi = /* @__PURE__ */ new WeakSet(), Vi = /* @__PURE__ */ new WeakSet(), Hi = /* @__PURE__ */ new WeakSet(), Ui = /* @__PURE__ */ new WeakSet(), Wi = /* @__PURE__ */ new WeakSet(), Gi = (e, t) => {
5871
+ }, Ui = /* @__PURE__ */ new WeakSet(), Wi = /* @__PURE__ */ new WeakSet(), Gi = /* @__PURE__ */ new WeakSet(), Ki = /* @__PURE__ */ new WeakSet(), qi = /* @__PURE__ */ new WeakSet(), Ji = /* @__PURE__ */ new WeakSet(), Yi = /* @__PURE__ */ new WeakSet(), Xi = (e, t) => {
5799
5872
  switch (t.kind) {
5800
5873
  case "cancelled":
5801
- Ri.add(e);
5874
+ Ui.add(e);
5802
5875
  break;
5803
5876
  case "exhausted":
5804
- zi.add(e);
5877
+ Wi.add(e);
5805
5878
  break;
5806
5879
  case "insufficient":
5807
- Bi.add(e);
5880
+ Gi.add(e);
5808
5881
  break;
5809
5882
  case "unsatisfiable":
5810
- Vi.add(e);
5883
+ Ki.add(e);
5811
5884
  break;
5812
5885
  case "unavailable":
5813
- Hi.add(e);
5886
+ qi.add(e);
5814
5887
  break;
5815
5888
  case "session-changed":
5816
- Ui.add(e);
5889
+ Ji.add(e);
5817
5890
  break;
5818
- case "transport-failure": Wi.add(e);
5891
+ case "transport-failure": Yi.add(e);
5819
5892
  }
5820
5893
  return e;
5821
- }, Ki = (e) => Ri.has(e), qi = (e) => zi.has(e), Ji = (e) => Bi.has(e), Yi = (e) => Vi.has(e), Xi = (e) => Hi.has(e), Zi = (e) => Ui.has(e), Qi = (e) => Wi.has(e), $i = "https://passflow-relative.invalid", ea = () => {
5894
+ }, Zi = (e) => Ui.has(e), Qi = (e) => Wi.has(e), $i = (e) => Gi.has(e), ea = (e) => Ki.has(e), ta = (e) => qi.has(e), na = (e) => Ji.has(e), ra = (e) => Yi.has(e), ia = "https://passflow-relative.invalid", aa = () => {
5822
5895
  let e = globalThis, t = e.document?.baseURI;
5823
5896
  if (typeof t == "string" && t !== "") return t;
5824
5897
  let n = e.location?.href;
5825
- return typeof n == "string" && n !== "" && n !== "about:blank" ? n : $i;
5826
- }, ta = (e, t = ea()) => {
5827
- let n = t === $i, r;
5898
+ return typeof n == "string" && n !== "" && n !== "about:blank" ? n : ia;
5899
+ }, oa = (e, t = aa()) => {
5900
+ let n = t === ia, r;
5828
5901
  try {
5829
5902
  r = new URL(t).origin;
5830
5903
  } catch {
@@ -5850,28 +5923,28 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5850
5923
  relativeToBase: !1,
5851
5924
  sentinelBase: n
5852
5925
  };
5853
- }, na = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, ra = (e) => {
5926
+ }, sa = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, ca = (e) => {
5854
5927
  let t = [];
5855
5928
  if (e == null) return Object.freeze(t);
5856
5929
  let n = e;
5857
5930
  if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
5858
- let r = na(n, e);
5931
+ let r = sa(n, e);
5859
5932
  r && t.push(r);
5860
5933
  }), Object.freeze(t);
5861
5934
  if (Array.isArray(e)) {
5862
5935
  for (let n of e) if (Array.isArray(n) && n.length >= 2) {
5863
- let e = na(String(n[0]), n[1]);
5936
+ let e = sa(String(n[0]), n[1]);
5864
5937
  e && t.push(e);
5865
5938
  }
5866
5939
  return Object.freeze(t);
5867
5940
  }
5868
5941
  if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
5869
- let e = na(n, Array.isArray(r) ? r.join(", ") : r);
5942
+ let e = sa(n, Array.isArray(r) ? r.join(", ") : r);
5870
5943
  e && t.push(e);
5871
5944
  }
5872
5945
  return Object.freeze(t);
5873
- }, ia = (e) => {
5874
- let t = e.base === void 0 ? ta(e.url) : ta(e.url, e.base), n = {
5946
+ }, la = (e) => {
5947
+ let t = e.base === void 0 ? oa(e.url) : oa(e.url, e.base), n = {
5875
5948
  raw: e.url,
5876
5949
  href: t.href,
5877
5950
  dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
@@ -5880,29 +5953,29 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5880
5953
  resolved: t.resolved,
5881
5954
  relativeToBase: t.relativeToBase,
5882
5955
  method: (e.method ?? "GET").toUpperCase(),
5883
- headers: ra(e.headers),
5956
+ headers: ca(e.headers),
5884
5957
  bodyKind: e.bodyKind,
5885
5958
  ..."body" in e ? { body: e.body } : {}
5886
5959
  };
5887
5960
  return Object.freeze(n);
5888
- }, aa = (e, t) => {
5961
+ }, ua = (e, t) => {
5889
5962
  if (!t || t.from === t.to) return e;
5890
5963
  let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
5891
5964
  return n ? Object.freeze(r) : e;
5892
- }, oa = (e) => {
5965
+ }, da = (e) => {
5893
5966
  let t = {};
5894
5967
  for (let [n, r] of e) t[n] = r;
5895
5968
  return t;
5896
- }, sa = /* @__PURE__ */ new Set([
5969
+ }, fa = /* @__PURE__ */ new Set([
5897
5970
  "GET",
5898
5971
  "HEAD",
5899
5972
  "OPTIONS"
5900
- ]), ca = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, la = (e) => typeof e == "string" ? e : ca(e) ? e.url : String(e), ua = (e, t) => (t?.method ?? (ca(e) ? e.method : void 0) ?? "GET").toUpperCase(), da = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", fa = (e) => {
5973
+ ]), pa = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, ma = (e) => typeof e == "string" ? e : pa(e) ? e.url : String(e), ha = (e, t) => (t?.method ?? (pa(e) ? e.method : void 0) ?? "GET").toUpperCase(), ga = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", _a = (e) => {
5901
5974
  if (typeof e == "string") return e.length;
5902
5975
  let t = e;
5903
5976
  if (typeof t?.size == "number") return t.size;
5904
5977
  if (typeof t?.byteLength == "number") return t.byteLength;
5905
- }, pa = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? sa.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), ma = (e, t, n, r, i) => ({
5978
+ }, va = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? fa.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), ya = (e, t, n, r, i) => ({
5906
5979
  replayable: !1,
5907
5980
  bodyKind: e,
5908
5981
  reason: t,
@@ -5910,11 +5983,11 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5910
5983
  forwardInit: i,
5911
5984
  snapshot: r,
5912
5985
  replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
5913
- }), ha = (e, t) => oa(aa(e.headers, t?.authorizationSwap)), ga = (e) => {
5986
+ }), ba = (e, t) => da(ua(e.headers, t?.authorizationSwap)), xa = (e) => {
5914
5987
  if (!e || !("headers" in e)) return e;
5915
5988
  let { headers: t, ...n } = e;
5916
5989
  return n;
5917
- }, _a = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : ca(e) ? e.headers : void 0, va = (e) => {
5990
+ }, Sa = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : pa(e) ? e.headers : void 0, Ca = (e) => {
5918
5991
  if (e === null || typeof e == "string") return e;
5919
5992
  if (typeof FormData < "u" && e instanceof FormData) {
5920
5993
  let t = new FormData();
@@ -5922,18 +5995,18 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5922
5995
  return t;
5923
5996
  }
5924
5997
  return typeof URLSearchParams < "u" && e instanceof URLSearchParams ? new URLSearchParams(e) : e instanceof ArrayBuffer ? e.slice(0) : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength).slice() : e;
5925
- }, ya = (e, t, n) => new Request(e, { headers: ha(t, n) }), ba = (e, t, n) => {
5926
- let r = la(e), i = ua(e, t), a = _a(e, t), o = (e, t) => ia({
5998
+ }, wa = (e, t, n) => new Request(e, { headers: ba(t, n) }), Ta = (e, t, n) => {
5999
+ let r = ma(e), i = ha(e, t), a = Sa(e, t), o = (e, t) => la({
5927
6000
  url: r,
5928
6001
  method: i,
5929
6002
  headers: a,
5930
6003
  bodyKind: e,
5931
6004
  ...t === void 0 ? {} : { body: t }
5932
6005
  });
5933
- if (ca(e)) {
6006
+ if (pa(e)) {
5934
6007
  if (e.body === null || e.body === void 0) {
5935
6008
  let a = o("none");
5936
- return pa(n, {
6009
+ return va(n, {
5937
6010
  url: r,
5938
6011
  method: i,
5939
6012
  bodyKind: "none"
@@ -5943,20 +6016,20 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5943
6016
  forwardInput: e,
5944
6017
  forwardInit: t,
5945
6018
  snapshot: a,
5946
- replay: (n, r) => n(ya(e, a, r), ga(t))
5947
- } : ma("none", "the replay policy refused this request", e, a, t);
6019
+ replay: (n, r) => n(wa(e, a, r), xa(t))
6020
+ } : ya("none", "the replay policy refused this request", e, a, t);
5948
6021
  }
5949
6022
  let a = o("request-clone");
5950
- if (!pa(n, {
6023
+ if (!va(n, {
5951
6024
  url: r,
5952
6025
  method: i,
5953
6026
  bodyKind: "request-clone"
5954
- })) return ma("request-clone", "the replay policy refused this request", e, a, t);
6027
+ })) return ya("request-clone", "the replay policy refused this request", e, a, t);
5955
6028
  let s;
5956
6029
  try {
5957
6030
  s = e.clone();
5958
6031
  } catch {
5959
- return ma("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
6032
+ return ya("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
5960
6033
  }
5961
6034
  return {
5962
6035
  replayable: !0,
@@ -5964,17 +6037,17 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5964
6037
  forwardInput: e,
5965
6038
  forwardInit: t,
5966
6039
  snapshot: a,
5967
- replay: (e, n) => e(ya(s, a, n), ga(t))
6040
+ replay: (e, n) => e(wa(s, a, n), xa(t))
5968
6041
  };
5969
6042
  }
5970
- let s = da(t?.body);
5971
- if (s === "one-shot") return ma("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
5972
- if (!pa(n, {
6043
+ let s = ga(t?.body);
6044
+ if (s === "one-shot") return ya("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
6045
+ if (!va(n, {
5973
6046
  url: r,
5974
6047
  method: i,
5975
6048
  bodyKind: s
5976
- }, fa(t?.body))) return ma(s, "the replay policy refused this request", e, o(s), t);
5977
- let c = t && "body" in t ? va(t.body ?? null) : void 0, l = o(s, c);
6049
+ }, _a(t?.body))) return ya(s, "the replay policy refused this request", e, o(s), t);
6050
+ let c = t && "body" in t ? Ca(t.body ?? null) : void 0, l = o(s, c);
5978
6051
  return {
5979
6052
  replayable: !0,
5980
6053
  bodyKind: s,
@@ -5982,21 +6055,21 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
5982
6055
  forwardInit: t,
5983
6056
  snapshot: l,
5984
6057
  replay: (e, n) => e(l.dispatchUrl, {
5985
- ...ga(t),
6058
+ ...xa(t),
5986
6059
  ...c === void 0 ? {} : { body: c },
5987
- headers: ha(l, n),
6060
+ headers: ba(l, n),
5988
6061
  method: l.method
5989
6062
  })
5990
6063
  };
5991
- }, xa = (e) => typeof e == "object" && !!e, Sa = (e) => (t) => {
5992
- if (!xa(e)) return;
6064
+ }, Ea = (e) => typeof e == "object" && !!e, Da = (e) => (t) => {
6065
+ if (!Ea(e)) return;
5993
6066
  let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
5994
6067
  return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
5995
- }, Ca = (e) => {
6068
+ }, Oa = (e) => {
5996
6069
  let t = e?.url ?? "", n = e?.baseURL;
5997
6070
  return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
5998
- }, wa = (e) => (e?.method ?? "GET").toUpperCase(), Ta = (e) => e == null ? "none" : xa(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", Ea = (e, t, n) => {
5999
- let r = oa(aa(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
6071
+ }, ka = (e) => (e?.method ?? "GET").toUpperCase(), Aa = (e) => e == null ? "none" : Ea(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", ja = (e, t, n) => {
6072
+ let r = da(ua(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
6000
6073
  return {
6001
6074
  ...e,
6002
6075
  ...i ? { baseURL: void 0 } : {},
@@ -6005,10 +6078,10 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6005
6078
  headers: r,
6006
6079
  ..."body" in t ? { data: t.body } : {}
6007
6080
  };
6008
- }, Da = (e, t, n, r, i, a) => {
6009
- let o = t ?? e?.config, s = Ta(o?.data), c = a ?? ia({
6010
- url: Ca(o),
6011
- method: wa(o),
6081
+ }, Ma = (e, t, n, r, i, a) => {
6082
+ let o = t ?? e?.config, s = Aa(o?.data), c = a ?? la({
6083
+ url: Oa(o),
6084
+ method: ka(o),
6012
6085
  headers: o?.headers,
6013
6086
  bodyKind: s,
6014
6087
  body: o?.data
@@ -6016,22 +6089,22 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6016
6089
  url: c.href,
6017
6090
  method: c.method,
6018
6091
  bodyKind: s
6019
- }, u = s !== "one-shot" && pa(i.replay, l);
6092
+ }, u = s !== "one-shot" && va(i.replay, l);
6020
6093
  return {
6021
6094
  status: e?.status ?? 0,
6022
- getHeader: Sa(e?.headers),
6095
+ getHeader: Da(e?.headers),
6023
6096
  readBody: async () => e?.data,
6024
6097
  request: c,
6025
6098
  replay: async (e) => {
6026
- let t = Te(Ea(o ?? {}, c, e));
6099
+ let t = Te(ja(o ?? {}, c, e));
6027
6100
  try {
6028
6101
  let e = await r(t);
6029
- return Da(e, e?.config ?? t, e, r, i, c);
6102
+ return Ma(e, e?.config ?? t, e, r, i, c);
6030
6103
  } catch (e) {
6031
- let n = xa(e) ? e : {};
6032
- if (!n.response || typeof n.response.status != "number" || dr(e)) throw e;
6104
+ let n = Ea(e) ? e : {};
6105
+ if (!n.response || typeof n.response.status != "number" || gr(e)) throw e;
6033
6106
  return {
6034
- ...Da(n.response, n.config ?? t, e, r, i, c),
6107
+ ...Ma(n.response, n.config ?? t, e, r, i, c),
6035
6108
  rejected: !0
6036
6109
  };
6037
6110
  }
@@ -6045,19 +6118,19 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6045
6118
  replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
6046
6119
  signal: o?.signal
6047
6120
  };
6048
- }, Oa = (e, t) => async (n) => {
6049
- let r = vi(e), i = xa(n) ? n : {}, a = Li(await Pi(Da(i.response, i.config, i.response, t, r), r), n);
6121
+ }, Na = (e, t) => async (n) => {
6122
+ let r = Ci(e), i = Ea(n) ? n : {}, a = Hi(await zi(Ma(i.response, i.config, i.response, t, r), r), n);
6050
6123
  if (a.settle === "reject") throw a.error;
6051
6124
  return a.value;
6052
- }, ka = (e, t, n) => {
6053
- let r = e.request, i = n ?? (typeof r == "function" ? (t) => r.call(e, t) : () => Promise.reject(/* @__PURE__ */ Error("Passflow: this client exposes no request() to replay through."))), a = e.interceptors.response.use(void 0, Oa(t, i)), o = !1;
6125
+ }, Pa = (e, t, n) => {
6126
+ let r = e.request, i = n ?? (typeof r == "function" ? (t) => r.call(e, t) : () => Promise.reject(/* @__PURE__ */ Error("Passflow: this client exposes no request() to replay through."))), a = e.interceptors.response.use(void 0, Na(t, i)), o = !1;
6054
6127
  return () => {
6055
6128
  o || (o = !0, e.interceptors.response.eject(a));
6056
6129
  };
6057
- }, Aa = (t, n) => {
6130
+ }, Fa = (t, n) => {
6058
6131
  let r = e.create(t);
6059
6132
  return n(r), r;
6060
- }, ja = 0, Ma = (e, t) => {
6133
+ }, Ia = 0, La = (e, t) => {
6061
6134
  let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
6062
6135
  if (n) return {
6063
6136
  get aborted() {
@@ -6071,34 +6144,34 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6071
6144
  removeEventListener: (e, t) => n.removeEventListener(e, t)
6072
6145
  } : {}
6073
6146
  };
6074
- }, Na = (e) => (t) => e.headers?.get(t), Pa = (e, t, n, r, i) => ({
6147
+ }, Ra = (e) => (t) => e.headers?.get(t), za = (e, t, n, r, i) => ({
6075
6148
  status: e.status,
6076
- getHeader: Na(e),
6149
+ getHeader: Ra(e),
6077
6150
  readBody: () => e.clone().json(),
6078
6151
  request: t.snapshot,
6079
- replay: async (e) => Pa(await t.replay(n, e), t, n, r, i),
6152
+ replay: async (e) => za(await t.replay(n, e), t, n, r, i),
6080
6153
  markers: r,
6081
6154
  raw: e,
6082
6155
  replayable: t.replayable,
6083
6156
  replayUnsupportedReason: t.reason,
6084
6157
  signal: i,
6085
6158
  responseType: e.type
6086
- }), Fa = (e, t) => {
6159
+ }), Ba = (e, t) => {
6087
6160
  let n = (t, n) => {
6088
- ja += 1;
6161
+ Ia += 1;
6089
6162
  try {
6090
6163
  return e(t, n);
6091
6164
  } finally {
6092
- --ja;
6165
+ --Ia;
6093
6166
  }
6094
6167
  };
6095
6168
  return async (e, r) => {
6096
- if (ja > 0) return n(e, r);
6097
- let i = vi(t), a = ba(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = Ii(await Pi(Pa(o, a, n, {}, Ma(e, r)), i), o, i);
6169
+ if (Ia > 0) return n(e, r);
6170
+ let i = Ci(t), a = Ta(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = Vi(await zi(za(o, a, n, {}, La(e, r)), i), o, i);
6098
6171
  if (s.settle === "reject") throw s.error;
6099
6172
  return s.value;
6100
6173
  };
6101
- }, Ia = new Set(ti.filter((e) => !e.requiresPrepare).map((e) => e.type)), La = (e) => {
6174
+ }, Va = new Set(oi.filter((e) => !e.requiresPrepare).map((e) => e.type)), Ha = (e) => {
6102
6175
  if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
6103
6176
  kind: "protocol",
6104
6177
  message: "The upgrade start response is missing challenge_id or expires_at"
@@ -6110,17 +6183,17 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6110
6183
  webauthn: e.webauthn,
6111
6184
  codeSentTo: e.code_sent_to
6112
6185
  };
6113
- }, Ra = (e) => dr(e) && !fr(e), za = (e) => ({
6186
+ }, Ua = (e) => gr(e) && !_r(e), Wa = (e) => ({
6114
6187
  async prepare(t) {
6115
- if (!Ia.has(t)) try {
6188
+ if (!Va.has(t)) try {
6116
6189
  let n = e.relyingPartyId?.();
6117
- return La(await e.startUpgrade(n ? {
6190
+ return Ha(await e.startUpgrade(n ? {
6118
6191
  method: t,
6119
6192
  relying_party_id: n
6120
6193
  } : { method: t }));
6121
6194
  } catch (e) {
6122
- if (Ra(e)) throw e;
6123
- let t = gr(e, "start");
6195
+ if (Ua(e)) throw e;
6196
+ let t = xr(e, "start");
6124
6197
  if (t.kind === "prepare_not_required") return;
6125
6198
  throw t;
6126
6199
  }
@@ -6137,17 +6210,17 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6137
6210
  assertion: n
6138
6211
  });
6139
6212
  } catch (t) {
6140
- if (Ra(t)) throw t;
6141
- let n = gr(t, "refresh");
6142
- throw n.status === 401 && vr(n) && e.markSessionInvalid?.(), n;
6213
+ if (Ua(t)) throw t;
6214
+ let n = xr(t, "refresh");
6215
+ throw n.status === 401 && Cr(n) && e.markSessionInvalid?.(), n;
6143
6216
  }
6144
6217
  }
6145
- }), Ba = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Va = (e) => {
6218
+ }), Ga = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Ka = (e) => {
6146
6219
  let t, n = (e) => e !== void 0 && t === e, r = (r) => {
6147
6220
  let i = () => {
6148
6221
  if (!n(r())) throw new $({ kind: "session_changed" });
6149
6222
  };
6150
- return za({
6223
+ return Wa({
6151
6224
  ...e,
6152
6225
  relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
6153
6226
  startUpgrade: (t) => (i(), e.startUpgrade(t)),
@@ -6158,7 +6231,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6158
6231
  });
6159
6232
  }, i = (t, n) => {
6160
6233
  let i = {}, a = {
6161
- controller: new _i({
6234
+ controller: new Si({
6162
6235
  transport: r(() => i.current),
6163
6236
  prompt: t.prompt,
6164
6237
  platform: e.platform,
@@ -6170,17 +6243,17 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6170
6243
  options: t,
6171
6244
  scope: {
6172
6245
  passflow: e.passflowDomain,
6173
- backend: Ba(t.backend)
6246
+ backend: Ga(t.backend)
6174
6247
  },
6175
6248
  generation: n
6176
6249
  };
6177
6250
  return i.current = a, a;
6178
6251
  }, a = async (r, i) => {
6179
6252
  let a = t;
6180
- if (!a) throw new br("Step-up verification is not enabled on this Passflow instance");
6253
+ if (!a) throw new Tr("Step-up verification is not enabled on this Passflow instance");
6181
6254
  a.controller.active || (a.pin = e.readSessionPin?.());
6182
6255
  let o = await a.controller.elevate(r, i);
6183
- if (!n(a)) throw new xr();
6256
+ if (!n(a)) throw new Er();
6184
6257
  return o;
6185
6258
  }, o = () => {
6186
6259
  let n = t, r = n?.scope ?? {
@@ -6224,9 +6297,9 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6224
6297
  let r = [];
6225
6298
  if (e.attachInternalSeam) {
6226
6299
  let t = e.attachInternalSeam;
6227
- t((e) => Oa(o, e)), r.push(() => t(void 0));
6300
+ t((e) => Na(o, e)), r.push(() => t(void 0));
6228
6301
  }
6229
- n.interceptFetch && r.push(Dt((e, t, n) => Fa(e, o)(t, n), {
6302
+ n.interceptFetch && r.push(Dt((e, t, n) => Ba(e, o)(t, n), {
6230
6303
  priority: 20,
6231
6304
  name: "passflow-upgrade"
6232
6305
  })), e.onSessionChange && r.push(e.onSessionChange(() => {
@@ -6257,18 +6330,18 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6257
6330
  withAuth: {
6258
6331
  enumerable: !0,
6259
6332
  value: (e) => {
6260
- if (e) return Fa(e, o);
6333
+ if (e) return Ba(e, o);
6261
6334
  let t = typeof globalThis > "u" ? void 0 : globalThis;
6262
6335
  if (!t || typeof t.fetch != "function") throw Error("Passflow: withAuth() needs a fetch to wrap — this runtime has none.");
6263
- return Fa(t.fetch.bind(t), o);
6336
+ return Ba(t.fetch.bind(t), o);
6264
6337
  }
6265
6338
  },
6266
6339
  attachAuth: {
6267
6340
  enumerable: !0,
6268
- value: (e) => ka(e, o)
6341
+ value: (e) => Pa(e, o)
6269
6342
  }
6270
6343
  });
6271
- }, Ha, Ua = class {
6344
+ }, qa, Ja = class {
6272
6345
  get origin() {
6273
6346
  return this.platform.getCurrentUrl()?.origin ?? "";
6274
6347
  }
@@ -6280,9 +6353,9 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6280
6353
  this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? P, this.deferFederatedLanding = e.deferFederatedLanding ?? !1, this.storageManager = new N({
6281
6354
  prefix: e.keyStoragePrefix ?? "",
6282
6355
  storage: this.platform.storage
6283
- }), this.deviceService = new re(this.storageManager), this.authApi = new nt(e, this.storageManager, this.deviceService), this.appApi = new Xe(e, this.storageManager, this.deviceService), this.userApi = new pt(e, this.storageManager, this.deviceService), this.settingApi = new at(e, this.storageManager, this.deviceService), this.tenantApi = new ot(e, this.storageManager, this.deviceService), this.invitationApi = new it(e, this.storageManager, this.deviceService), this.twoFactorApi = new dt(e, this.storageManager, this.deviceService), this.upgradeApi = new ft(e, this.storageManager, this.deviceService), this.upgradeDomain = ke(e.url), this.subscribeStore = new ir(), this.tokenCacheService = new qr(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? u, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
6356
+ }), this.deviceService = new re(this.storageManager), this.authApi = new nt(e, this.storageManager, this.deviceService), this.appApi = new Xe(e, this.storageManager, this.deviceService), this.userApi = new pt(e, this.storageManager, this.deviceService), this.settingApi = new at(e, this.storageManager, this.deviceService), this.tenantApi = new ot(e, this.storageManager, this.deviceService), this.invitationApi = new it(e, this.storageManager, this.deviceService), this.twoFactorApi = new dt(e, this.storageManager, this.deviceService), this.upgradeApi = new ft(e, this.storageManager, this.deviceService), this.upgradeDomain = ke(e.url), this.subscribeStore = new ir(), this.tokenCacheService = new Qr(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? u, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
6284
6357
  let i = vn(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
6285
- this.authService = new Ur(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
6358
+ this.authService = new Jr(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
6286
6359
  createSession: this.createSessionCallback,
6287
6360
  expiredSession: this.expiredSessionCallback
6288
6361
  }, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
@@ -6290,7 +6363,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6290
6363
  ...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
6291
6364
  }), this.tokenCacheService.attachRefreshController(this.authService.refresh);
6292
6365
  for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
6293
- this.userService = new Yr(this.userApi, this.deviceService, this.platform), this.tenantService = new Kr(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new Wr(this.invitationApi), this.twoFactorService = new Jr(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Va({
6366
+ this.userService = new ei(this.userApi, this.deviceService, this.platform), this.tenantService = new Zr(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new Yr(this.invitationApi), this.twoFactorService = new $r(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Ka({
6294
6367
  startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
6295
6368
  commitRefresh: async (e, t) => {
6296
6369
  await this.authService.refreshToken(e, t);
@@ -6337,7 +6410,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6337
6410
  return this.upgrade.attachAuth(e);
6338
6411
  }
6339
6412
  createClient(e) {
6340
- return Aa(e, (e) => this.upgrade.attachAuth(e));
6413
+ return Fa(e, (e) => this.upgrade.attachAuth(e));
6341
6414
  }
6342
6415
  readAssuranceBar() {
6343
6416
  let e = this.storageManager.getToken(j.access_token);
@@ -6403,58 +6476,66 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6403
6476
  this.subscribeStore.unsubscribe(e, t);
6404
6477
  }
6405
6478
  handleTokensRedirect() {
6406
- return this.checkAndSetTokens();
6479
+ this.checkAndSetTokens();
6407
6480
  }
6408
6481
  completeFederatedLanding() {
6409
6482
  return this.takeFederatedLanding();
6410
6483
  }
6411
6484
  checkAndSetTokens() {
6412
- let e = this.platform.getCurrentUrl(), t = new URLSearchParams(e?.search ?? ""), n = !1;
6485
+ let e = this.platform.getCurrentUrl(), t = new URLSearchParams(e?.search ?? "");
6413
6486
  if (!t.get("access_token") && e?.hash) {
6414
- let r = new URLSearchParams(e.hash.substring(1));
6415
- r.get("access_token") && (t = r, n = !0);
6487
+ let n = new URLSearchParams(e.hash.substring(1));
6488
+ n.get("access_token") && (t = n);
6416
6489
  }
6417
6490
  if (!t.get("access_token") && this.adoptTwoFactorTokenFromUrl(e)) {
6418
6491
  this.error = void 0;
6419
6492
  return;
6420
6493
  }
6421
- let r = t.get("access_token"), i = t.get("refresh_token"), a = t.get("id_token"), o = t.get("scopes")?.split(",") ?? this.scopes, s;
6422
- if (r) {
6423
- if (!wr(r)) {
6494
+ let n = t.get("access_token"), r = t.get("refresh_token"), i = t.get("id_token"), a = t.get("scopes")?.split(",") ?? this.scopes;
6495
+ if (n) {
6496
+ if (!kr(n)) {
6424
6497
  U(this.subscribeStore, {
6425
6498
  operation: "tokens.from-url",
6426
6499
  message: "Invalid access token format received",
6427
6500
  code: "INVALID_TOKEN_FORMAT"
6428
- }), this.cleanupUrlParams(n, e);
6501
+ }), this.cleanupUrlParams(e);
6429
6502
  return;
6430
6503
  }
6431
- if (i && !wr(i)) {
6504
+ if (r && !kr(r)) {
6432
6505
  U(this.subscribeStore, {
6433
6506
  operation: "tokens.from-url",
6434
6507
  message: "Invalid refresh token format received",
6435
6508
  code: "INVALID_TOKEN_FORMAT"
6436
- }), this.cleanupUrlParams(n, e);
6509
+ }), this.cleanupUrlParams(e);
6437
6510
  return;
6438
6511
  }
6439
- if (a && !wr(a)) {
6512
+ if (i && !kr(i)) {
6440
6513
  U(this.subscribeStore, {
6441
6514
  operation: "tokens.from-url",
6442
6515
  message: "Invalid ID token format received",
6443
6516
  code: "INVALID_TOKEN_FORMAT"
6444
- }), this.cleanupUrlParams(n, e);
6517
+ }), this.cleanupUrlParams(e);
6445
6518
  return;
6446
6519
  }
6447
- return s = {
6448
- access_token: r,
6449
- refresh_token: i ?? void 0,
6450
- id_token: a ?? void 0,
6451
- scopes: o
6452
- }, this.storageManager.clearDeliveryMode(), this.storageManager.saveTokens(s), this.tokenCacheService.setTokensCache(s), this.authService.refresh.sessionStarted(), this.subscribeStore.notify(Z.SignIn, {
6453
- tokens: s,
6454
- parsedTokens: this.getParsedTokens()
6455
- }), this.submitSessionCheck(), this.cleanupUrlParams(n, e), this.error = void 0, s;
6456
- }
6457
- this.deferFederatedLanding || this.takeFederatedLanding(), this.error = this.checkErrorsFromURL();
6520
+ let t = {
6521
+ access_token: n,
6522
+ refresh_token: r ?? void 0,
6523
+ id_token: i ?? void 0,
6524
+ scopes: a
6525
+ };
6526
+ this.cleanupUrlParams(e), this.error = void 0, lr(this.url, this.appId, t).then(() => {
6527
+ this.storageManager.clearDeliveryMode(), this.storageManager.saveTokens(t), this.tokenCacheService.setTokensCache(t), this.authService.refresh.sessionStarted();
6528
+ }).then(() => (this.subscribeStore.notify(Z.SignIn, {
6529
+ tokens: t,
6530
+ parsedTokens: this.getParsedTokens(),
6531
+ source: "tokens-in-url"
6532
+ }), this.submitSessionCheck()), (e) => U(this.subscribeStore, {
6533
+ operation: "tokens.from-url",
6534
+ message: e instanceof Error ? e.message : "Tokens in the URL could not be verified",
6535
+ code: "TOKEN_NOT_VERIFIED",
6536
+ originalError: e
6537
+ }));
6538
+ } else this.cleanupUrlParams(e), this.deferFederatedLanding || this.takeFederatedLanding(), this.error = this.checkErrorsFromURL();
6458
6539
  }
6459
6540
  takeFederatedLanding() {
6460
6541
  let e = this.platform.getCurrentUrl();
@@ -6471,7 +6552,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6471
6552
  if (!n) return !1;
6472
6553
  t.delete("tfa_token");
6473
6554
  let r = t.toString();
6474
- return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), wr(n) ? (this.subscribeStore.notify(Z.TwoFactorRequired, {
6555
+ return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), kr(n) ? (this.subscribeStore.notify(Z.TwoFactorRequired, {
6475
6556
  email: "",
6476
6557
  challengeId: "",
6477
6558
  tfaToken: n
@@ -6484,19 +6565,21 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6484
6565
  checkErrorsFromURL() {
6485
6566
  let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
6486
6567
  if (e) {
6487
- let t = Tr(e);
6568
+ let t = Ar(e);
6488
6569
  return Error(t);
6489
6570
  }
6490
6571
  }
6491
- cleanupUrlParams(e = !1, t = null) {
6492
- let n = t ?? this.platform.getCurrentUrl();
6493
- if (n) {
6494
- if (e) this.platform.replaceUrl(n.pathname + n.search);
6495
- else {
6496
- let e = new URLSearchParams(n.search);
6497
- e.delete("access_token"), e.delete("refresh_token"), e.delete("id_token"), e.delete("client_challenge"), e.size > 0 ? this.platform.replaceUrl(`${n.pathname}?${e.toString()}`) : this.platform.replaceUrl(n.pathname);
6498
- }
6499
- }
6572
+ cleanupUrlParams(e) {
6573
+ if (!e) return;
6574
+ let t = [
6575
+ "access_token",
6576
+ "refresh_token",
6577
+ "id_token"
6578
+ ], n = new URLSearchParams(e.search), r = new URLSearchParams(e.hash?.substring(1)), i = t.some((e) => r.get(e));
6579
+ if (!i && !t.some((e) => n.get(e))) return;
6580
+ for (let e of [...t, "client_challenge"]) n.delete(e);
6581
+ let a = n.toString();
6582
+ this.platform.replaceUrl(e.pathname + (a ? `?${a}` : "") + (i ? "" : e.hash ?? ""));
6500
6583
  }
6501
6584
  setTokensToCacheFromLocalStorage() {
6502
6585
  let e = this.storageManager.getTokens();
@@ -6560,6 +6643,13 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6560
6643
  async verifyEmailCode(e) {
6561
6644
  return await this.authService.verifyEmailCode(e);
6562
6645
  }
6646
+ async checkRedirectUrl(e) {
6647
+ try {
6648
+ return await this.authService.checkRedirectUrl(e);
6649
+ } catch (e) {
6650
+ this.handleError(e, "redirect.check", "Redirect check");
6651
+ }
6652
+ }
6563
6653
  handleError(e, t, n) {
6564
6654
  let r = {
6565
6655
  operation: t,
@@ -6868,7 +6958,7 @@ var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3
6868
6958
  this.twoFactorService.clearMagicLinkSession();
6869
6959
  }
6870
6960
  };
6871
- Ha = Ua, Ha.version = c;
6872
- export { i as APP_ID_HEADER_KEY, Me as APP_SECRET_NAMES, a as AUTHORIZATION_HEADER_KEY, Xe as AppAPI, nt as AuthAPI, Ur as AuthService, rt as CLIAuthAPI, f as DEFAULT_GROUP_NAME, u as DEFAULT_SCOPES, ti as DEFAULT_UPGRADE_FACTORS, o as DEVICE_ID_HEADER_KEY, s as DEVICE_TYPE_HEADER_KEY, b as ERROR_MESSAGE_MAX_LENGTH, mt as FETCH_PRIORITY_OIDC, ht as FETCH_PRIORITY_UPGRADE, gt as FetchMiddlewareContractError, ce as INSUFFICIENT_USER_AUTHENTICATION, it as InvitationAPI, Wr as InvitationService, It as M2MClient, jt as M2MConfigError, H as M2MError, Mt as M2MErrorCodes, kt as M2MNetworkError, At as M2MTokenParseError, Nt as M2M_DEFAULTS, Ne as MASKED_SECRET_PREFIX, l as MINIMAL_DEFAULT_SCOPES, Ie as OS, d as PASSFLOW_CLOUD_URL, m as POPUP_HEIGHT, h as POPUP_POLL_INTERVAL_MS, g as POPUP_TIMEOUT_MS, p as POPUP_WIDTH, Ua as Passflow, Oe as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, B as PassflowError, Z as PassflowEvent, q as PassflowRefreshError, ie as PopupClosedError, je as Providers, ar as RECOVERABLE_COMMIT_ERROR_IDS, Dn as REFRESH_AUTH_FAILURE_IDS, K as RefreshErrorId, De as RequestMethod, c as SDK_VERSION, or as SESSION_INVALIDATING_COMMIT_ERROR_IDS, Pe as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, te as SessionState, at as SettingAPI, _ as TOKEN_EXPIRY_BUFFER_SECONDS, ot as TenantAPI, Kr as TenantService, Gr as TenantUserMembership, qr as TokenCacheService, M as TokenDeliveryMode, j as TokenType, dt as TwoFactorApiClient, Re as TwoFactorPolicy, Jr as TwoFactorService, le as UPGRADE_REQUIRED, y as USERNAME_MAX_LENGTH, v as USERNAME_MIN_LENGTH, ft as UpgradeAPI, ci as UpgradeCancelledError, zn as UpgradeCommitInterruptedError, _i as UpgradeController, Q as UpgradeErrorIds, Xr as UpgradeFactorError, yr as UpgradeInsufficientError, xr as UpgradeSessionChangedError, $ as UpgradeTransportError, br as UpgradeUnavailableError, li as UpgradeUnsatisfiableError, pt as UserAPI, Yr as UserService, ae as WebAdapter, gr as classifyUpgradeError, ni as factorRegistry, Ot as fetchRegistryState, Le as getOSFromDeviceType, vr as invalidatesSessionOnCommit, Ae as isEmailVerificationStep, Fe as isMaskedSecret, _r as isRecoverableCommitFailure, cr as isRetryableUpgradeKind, k as isTokenExpired, Ki as isUpgradeCancelled, qi as isUpgradeExhausted, Ji as isUpgradeInsufficient, Zi as isUpgradeSessionChanged, fr as isUpgradeTransportError, Qi as isUpgradeTransportFailure, Xi as isUpgradeUnavailable, Yi as isUpgradeUnsatisfiable, Er as isValidEmail, wr as isValidJWTFormat, Dr as isValidPhoneNumber, Or as isValidUsername, he as parseChallengeBody, me as parseChallengeHeader, A as parseToken, ye as parseUpgradeChallenge, ei as passkeyFactor, V as pathWithParams, $r as recoveryCodesFactor, Dt as registerFetchMiddleware, L as requiredAcrLevel, ke as resolveUpgradeDomain, Tr as sanitizeErrorMessage, si as selectFactors, Qr as totpFactor, P as webAdapter };
6961
+ qa = Ja, qa.version = c;
6962
+ export { i as APP_ID_HEADER_KEY, Me as APP_SECRET_NAMES, a as AUTHORIZATION_HEADER_KEY, Xe as AppAPI, nt as AuthAPI, Jr as AuthService, rt as CLIAuthAPI, f as DEFAULT_GROUP_NAME, u as DEFAULT_SCOPES, oi as DEFAULT_UPGRADE_FACTORS, o as DEVICE_ID_HEADER_KEY, s as DEVICE_TYPE_HEADER_KEY, b as ERROR_MESSAGE_MAX_LENGTH, mt as FETCH_PRIORITY_OIDC, ht as FETCH_PRIORITY_UPGRADE, gt as FetchMiddlewareContractError, ce as INSUFFICIENT_USER_AUTHENTICATION, it as InvitationAPI, Yr as InvitationService, It as M2MClient, jt as M2MConfigError, H as M2MError, Mt as M2MErrorCodes, kt as M2MNetworkError, At as M2MTokenParseError, Nt as M2M_DEFAULTS, Ne as MASKED_SECRET_PREFIX, l as MINIMAL_DEFAULT_SCOPES, Ie as OS, d as PASSFLOW_CLOUD_URL, m as POPUP_HEIGHT, h as POPUP_POLL_INTERVAL_MS, g as POPUP_TIMEOUT_MS, p as POPUP_WIDTH, Ja as Passflow, Oe as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, B as PassflowError, Z as PassflowEvent, q as PassflowRefreshError, ie as PopupClosedError, je as Providers, ur as RECOVERABLE_COMMIT_ERROR_IDS, Dn as REFRESH_AUTH_FAILURE_IDS, K as RefreshErrorId, De as RequestMethod, c as SDK_VERSION, dr as SESSION_INVALIDATING_COMMIT_ERROR_IDS, Pe as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, te as SessionState, at as SettingAPI, _ as TOKEN_EXPIRY_BUFFER_SECONDS, ot as TenantAPI, Zr as TenantService, Xr as TenantUserMembership, Qr as TokenCacheService, M as TokenDeliveryMode, j as TokenType, dt as TwoFactorApiClient, Re as TwoFactorPolicy, $r as TwoFactorService, le as UPGRADE_REQUIRED, y as USERNAME_MAX_LENGTH, v as USERNAME_MIN_LENGTH, ft as UpgradeAPI, pi as UpgradeCancelledError, zn as UpgradeCommitInterruptedError, Si as UpgradeController, Q as UpgradeErrorIds, ti as UpgradeFactorError, wr as UpgradeInsufficientError, Er as UpgradeSessionChangedError, $ as UpgradeTransportError, Tr as UpgradeUnavailableError, mi as UpgradeUnsatisfiableError, pt as UserAPI, ei as UserService, ae as WebAdapter, xr as classifyUpgradeError, si as factorRegistry, Ot as fetchRegistryState, Le as getOSFromDeviceType, Cr as invalidatesSessionOnCommit, Ae as isEmailVerificationStep, Fe as isMaskedSecret, Sr as isRecoverableCommitFailure, pr as isRetryableUpgradeKind, k as isTokenExpired, Zi as isUpgradeCancelled, Qi as isUpgradeExhausted, $i as isUpgradeInsufficient, na as isUpgradeSessionChanged, _r as isUpgradeTransportError, ra as isUpgradeTransportFailure, ta as isUpgradeUnavailable, ea as isUpgradeUnsatisfiable, jr as isValidEmail, kr as isValidJWTFormat, Mr as isValidPhoneNumber, Nr as isValidUsername, he as parseChallengeBody, me as parseChallengeHeader, A as parseToken, ye as parseUpgradeChallenge, ai as passkeyFactor, V as pathWithParams, ii as recoveryCodesFactor, Dt as registerFetchMiddleware, L as requiredAcrLevel, ke as resolveUpgradeDomain, Ar as sanitizeErrorMessage, fi as selectFactors, ri as totpFactor, P as webAdapter };
6873
6963
 
6874
6964
  //# sourceMappingURL=index.mjs.map