@passflow/core 0.29.0 → 0.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import e, { AxiosError as t } from "axios";
2
2
  import { startAuthentication as n, startRegistration as r } from "@simplewebauthn/browser";
3
3
  // package.json
4
- var i = "0.29.0", a = "X-Passflow-Clientid", o = "Authorization", s = "X-Passflow-DeviceId", c = "X-Passflow-DeviceType", l = i, u = [
4
+ var i = "0.30.1", a = "X-Passflow-Clientid", o = "Authorization", s = "X-Passflow-DeviceId", c = "X-Passflow-DeviceType", l = i, u = [
5
5
  "id",
6
6
  "offline",
7
7
  "openid"
@@ -567,7 +567,7 @@ var M = /* @__PURE__ */ function(e) {
567
567
  }), De = (e) => Ce(e, Se), Oe = /* @__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.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;
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.hostedUpgradeStart = "/auth/session/upgrade/start", e.hostedUpgrade = "/auth/session/upgrade", e;
571
571
  }({}), B = /* @__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) => {
@@ -621,10 +621,10 @@ var Ve = /* @__PURE__ */ function(e) {
621
621
  location: e.config?.url ?? "unknown",
622
622
  time: (/* @__PURE__ */ new Date()).toISOString()
623
623
  }, { cause: r });
624
- }, Ze = (e) => e?.includes(z.refresh) ?? !1, Qe = (e) => e?.includes("logout") ?? !1, $e = "__passflowOwnBearer", et = (e) => typeof e == "object" && !!e && e[$e] === !0, tt = (e) => e ? {
624
+ }, Ze = (e) => e?.includes(z.refresh) ?? !1, Qe = (e) => e?.includes("/auth/session/") ?? !1, $e = (e) => e?.includes("logout") ?? !1, et = "__passflowOwnBearer", tt = (e) => typeof e == "object" && !!e && e[et] === !0, nt = (e) => e ? {
625
625
  headers: { [o]: `Bearer ${e}` },
626
- [$e]: !0
627
- } : {}, nt = class {
626
+ [et]: !0
627
+ } : {}, rt = class {
628
628
  get origin() {
629
629
  return this._platform.getCurrentUrl()?.origin ?? "";
630
630
  }
@@ -655,7 +655,7 @@ var Ve = /* @__PURE__ */ function(e) {
655
655
  baseURL: this.url,
656
656
  headers: { ...this.defaultHeaders }
657
657
  }), this.instance.interceptors.request.use(async (e) => {
658
- if (this.isNonAuthEndpoint(e.url) || et(e)) return e;
658
+ if (this.isNonAuthEndpoint(e.url) || tt(e) || Qe(e.url)) return e;
659
659
  if (this.tokenDeliveryManager.isCookieMode()) {
660
660
  e.withCredentials = !0;
661
661
  let t = this.storageManager.getCsrfToken();
@@ -665,7 +665,7 @@ var Ve = /* @__PURE__ */ function(e) {
665
665
  let t = this.storageManager.getTokens();
666
666
  if (!t?.access_token) return e;
667
667
  let n = t.access_token;
668
- if (this.refreshHandler && t.refresh_token && !Qe(e.url)) {
668
+ if (this.refreshHandler && t.refresh_token && !$e(e.url)) {
669
669
  let e = j(t.access_token);
670
670
  if (A(e, 30)) {
671
671
  let t = !A(e, 0);
@@ -681,7 +681,7 @@ var Ve = /* @__PURE__ */ function(e) {
681
681
  }
682
682
  return e.headers[o] = `Bearer ${n}`, e;
683
683
  }), this.instance.interceptors.response.use((e) => e, async (e) => {
684
- if (e.response?.status !== 401 || Ze(e.config?.url) || et(e.config) || this.isUpgradeTransactionError(e) || this.tokenDeliveryManager.setSessionInvalid(), e.response && this.upgradeHandler) {
684
+ if (e.response?.status !== 401 || Ze(e.config?.url) || Qe(e.config?.url) || tt(e.config) || this.isUpgradeTransactionError(e) || this.tokenDeliveryManager.setSessionInvalid(), e.response && this.upgradeHandler && !Qe(e.config?.url)) {
685
685
  let t = Ge(e.response);
686
686
  if (t) try {
687
687
  return await this.upgradeHandler(e, t);
@@ -788,11 +788,11 @@ var Ve = /* @__PURE__ */ function(e) {
788
788
  this.appId = e, this.defaultHeaders = {
789
789
  ...this.defaultHeaders,
790
790
  [a]: e
791
- }, this.instance.defaults.headers.common[a] = e;
791
+ }, this.instance.defaults.headers[a] = e;
792
792
  }
793
- }, rt = class {
793
+ }, it = class {
794
794
  constructor(e, t, n) {
795
- this.axiosClient = new nt(e, t, n);
795
+ this.axiosClient = new rt(e, t, n);
796
796
  }
797
797
  setAppId(e) {
798
798
  this.axiosClient.setAppId(e);
@@ -800,7 +800,7 @@ var Ve = /* @__PURE__ */ function(e) {
800
800
  getAppSettings() {
801
801
  return this.axiosClient.get(z.appSettings);
802
802
  }
803
- }, it = { withCredentials: !0 }, at = 15e3, ot = "Sign-in failed. Start again.", st = "Something went wrong. Try again later.", ct = (e, t, n, r) => {
803
+ }, at = { withCredentials: !0 }, ot = 15e3, st = "Sign-in failed. Start again.", ct = "Something went wrong. Try again later.", lt = (e, t, n, r) => {
804
804
  if (e instanceof V) return e;
805
805
  let i = e?.response?.data?.error;
806
806
  return new V({
@@ -810,9 +810,9 @@ var Ve = /* @__PURE__ */ function(e) {
810
810
  location: t,
811
811
  time: (/* @__PURE__ */ new Date()).toISOString()
812
812
  });
813
- }, lt = class {
813
+ }, ut = class {
814
814
  constructor(e, t, n) {
815
- this.axiosClient = new nt(e, t, n);
815
+ this.axiosClient = new rt(e, t, n);
816
816
  }
817
817
  setAppId(e) {
818
818
  this.axiosClient.setAppId(e);
@@ -831,7 +831,7 @@ var Ve = /* @__PURE__ */ function(e) {
831
831
  device: t,
832
832
  os: n
833
833
  };
834
- return this.axiosClient.post(z.signin, r, it);
834
+ return this.axiosClient.post(z.signin, r, at);
835
835
  }
836
836
  signUp(e) {
837
837
  let { create_tenant: t, anonymous: n } = e, r = {
@@ -839,16 +839,16 @@ var Ve = /* @__PURE__ */ function(e) {
839
839
  create_tenant: t ?? !1,
840
840
  anonymous: n ?? !1
841
841
  };
842
- return this.axiosClient.post(z.signup, r, it);
842
+ return this.axiosClient.post(z.signup, r, at);
843
843
  }
844
844
  async pkceExchange(e, t) {
845
845
  try {
846
846
  return await this.axiosClient.post(z.pkceExchange, {
847
847
  authz_code: e,
848
848
  verifier: t
849
- }, it);
849
+ }, at);
850
850
  } catch (e) {
851
- throw ct(e, z.pkceExchange, "error.pkce.exchange", ot);
851
+ throw lt(e, z.pkceExchange, "error.pkce.exchange", st);
852
852
  }
853
853
  }
854
854
  async passwordlessSignIn(e, t, n) {
@@ -861,53 +861,53 @@ var Ve = /* @__PURE__ */ function(e) {
861
861
  try {
862
862
  return await this.axiosClient.post(z.passwordless, i);
863
863
  } catch (e) {
864
- throw ct(e, z.passwordless, "error.passwordless.start", st);
864
+ throw lt(e, z.passwordless, "error.passwordless.start", ct);
865
865
  }
866
866
  }
867
867
  async passwordlessSignInComplete(e) {
868
868
  try {
869
- return await this.axiosClient.post(z.passwordlessComplete, e, it);
869
+ return await this.axiosClient.post(z.passwordlessComplete, e, at);
870
870
  } catch (e) {
871
- throw ct(e, z.passwordlessComplete, "error.passwordless.complete", st);
871
+ throw lt(e, z.passwordlessComplete, "error.passwordless.complete", ct);
872
872
  }
873
873
  }
874
874
  async passwordlessStatus(e, t) {
875
875
  try {
876
876
  return await this.axiosClient.post(z.passwordlessStatus, e, {
877
- ...it,
878
- timeout: at,
877
+ ...at,
878
+ timeout: ot,
879
879
  signal: t?.signal
880
880
  });
881
881
  } catch (e) {
882
- throw ct(e, z.passwordlessStatus, "error.passwordless.status", ot);
882
+ throw lt(e, z.passwordlessStatus, "error.passwordless.status", st);
883
883
  }
884
884
  }
885
885
  async checkRedirectUrl(e) {
886
886
  try {
887
887
  return (await this.axiosClient.post(z.redirectCheck, { redirect_url: e })).redirect_url;
888
888
  } catch (e) {
889
- throw ct(e, z.redirectCheck, "error.redirect.check", st);
889
+ throw lt(e, z.redirectCheck, "error.redirect.check", ct);
890
890
  }
891
891
  }
892
892
  async passwordlessApprovalInfo(e) {
893
893
  try {
894
894
  return await this.axiosClient.post(z.passwordlessApprovalInfo, e);
895
895
  } catch (e) {
896
- throw ct(e, z.passwordlessApprovalInfo, "error.passwordless.approval", st);
896
+ throw lt(e, z.passwordlessApprovalInfo, "error.passwordless.approval", ct);
897
897
  }
898
898
  }
899
899
  async passwordlessApprovalDecide(e) {
900
900
  try {
901
901
  return await this.axiosClient.post(z.passwordlessApprovalDecide, e);
902
902
  } catch (e) {
903
- throw ct(e, z.passwordlessApprovalDecide, "error.passwordless.approval", st);
903
+ throw lt(e, z.passwordlessApprovalDecide, "error.passwordless.approval", ct);
904
904
  }
905
905
  }
906
906
  validateEmailCode(e) {
907
907
  return this.axiosClient.post(z.passkeyValidate, {
908
908
  challenge_id: e.challenge_id,
909
909
  otp: e.otp
910
- }, it);
910
+ }, at);
911
911
  }
912
912
  logOut(e, t, n = !1) {
913
913
  let r = n ? void 0 : {
@@ -948,7 +948,7 @@ var Ve = /* @__PURE__ */ function(e) {
948
948
  device: t,
949
949
  passkey_data: e
950
950
  }, a = r ? B.passkeyRegisterComplete : z.passkeyRegisterComplete;
951
- return this.axiosClient.post(a, i, it);
951
+ return this.axiosClient.post(a, i, at);
952
952
  }
953
953
  passkeyAuthenticateStart(e, t, n, r = !1) {
954
954
  let i = {
@@ -965,7 +965,7 @@ var Ve = /* @__PURE__ */ function(e) {
965
965
  device: t,
966
966
  passkey_data: e
967
967
  }, a = r ? B.passkeyAuthenticateComplete : z.passkeyAuthenticateComplete;
968
- return this.axiosClient.post(a, i, it);
968
+ return this.axiosClient.post(a, i, at);
969
969
  }
970
970
  passkeyValidate(e, t, n, r = !1, i) {
971
971
  let o = {
@@ -977,9 +977,9 @@ var Ve = /* @__PURE__ */ function(e) {
977
977
  let c = i ? { [a]: i } : {};
978
978
  return this.axiosClient.post(s, o, { headers: c });
979
979
  }
980
- }, ut = class {
980
+ }, dt = class {
981
981
  constructor(e, t, n) {
982
- this.axiosClient = new nt(e, t, n);
982
+ this.axiosClient = new rt(e, t, n);
983
983
  }
984
984
  setAppId(e) {
985
985
  this.axiosClient.setAppId(e);
@@ -991,9 +991,9 @@ var Ve = /* @__PURE__ */ function(e) {
991
991
  completeCLIAuth(e) {
992
992
  return this.axiosClient.post(z.cliAuthComplete, e);
993
993
  }
994
- }, dt = class {
994
+ }, ft = class {
995
995
  constructor(e, t, n) {
996
- this.axiosClient = new nt(e, t, n);
996
+ this.axiosClient = new rt(e, t, n);
997
997
  }
998
998
  setAppId(e) {
999
999
  this.axiosClient.setAppId(e);
@@ -1022,9 +1022,9 @@ var Ve = /* @__PURE__ */ function(e) {
1022
1022
  let t = Be(z.invitationGetLink, { invitationID: e });
1023
1023
  return this.axiosClient.get(t);
1024
1024
  }
1025
- }, ft = class {
1025
+ }, pt = class {
1026
1026
  constructor(e, t, n) {
1027
- this.axiosClient = new nt(e, t, n);
1027
+ this.axiosClient = new rt(e, t, n);
1028
1028
  }
1029
1029
  setAppId(e) {
1030
1030
  this.axiosClient.setAppId(e);
@@ -1038,9 +1038,9 @@ var Ve = /* @__PURE__ */ function(e) {
1038
1038
  getPasskeySettings() {
1039
1039
  return this.axiosClient.get(z.settingsPasskey);
1040
1040
  }
1041
- }, pt = class {
1041
+ }, mt = class {
1042
1042
  constructor(e, t, n) {
1043
- this.axiosClient = new nt(e, t, n);
1043
+ this.axiosClient = new rt(e, t, n);
1044
1044
  }
1045
1045
  setAppId(e) {
1046
1046
  this.axiosClient.setAppId(e);
@@ -1154,58 +1154,58 @@ var Ve = /* @__PURE__ */ function(e) {
1154
1154
  let r = `${z.tenantPath}/${e}/group/${t}/invite/email/${n}`;
1155
1155
  return this.axiosClient.delete(r);
1156
1156
  }
1157
- }, mt = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, ht = (e) => ({
1157
+ }, ht = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, gt = (e) => ({
1158
1158
  withCredentials: !0,
1159
- ...mt(e)
1160
- }), gt = ({ qr_code_image: e, qr_code: t, ...n }) => ({
1159
+ ...ht(e)
1160
+ }), _t = ({ qr_code_image: e, qr_code: t, ...n }) => ({
1161
1161
  ...n,
1162
1162
  qr_code: (t ?? e ?? "").replace(/^data:image\/png;base64,/, "")
1163
- }), _t = {
1163
+ }), vt = {
1164
1164
  "error.2fa.setup.token.expired": "EXPIRED_TOKEN",
1165
1165
  "error.2fa.setup.token.revoked": "REVOKED_TOKEN",
1166
1166
  "error.2fa.setup.token.already_used": "ALREADY_USED",
1167
1167
  "error.2fa.setup.token.rate.limit.exceeded": "RATE_LIMITED"
1168
- }, vt = class {
1168
+ }, yt = class {
1169
1169
  constructor(e, t, n) {
1170
- this.axiosClient = new nt(e, t, n);
1170
+ this.axiosClient = new rt(e, t, n);
1171
1171
  }
1172
1172
  setAppId(e) {
1173
1173
  this.axiosClient.setAppId(e);
1174
1174
  }
1175
1175
  getStatus(e) {
1176
- return this.axiosClient.get(z.twoFactorStatus, tt(e));
1176
+ return this.axiosClient.get(z.twoFactorStatus, nt(e));
1177
1177
  }
1178
1178
  async beginSetup(e) {
1179
- return gt(await this.axiosClient.post(z.twoFactorSetupBegin, {}, tt(e)));
1179
+ return _t(await this.axiosClient.post(z.twoFactorSetupBegin, {}, nt(e)));
1180
1180
  }
1181
1181
  confirmSetup(e, t) {
1182
- return this.axiosClient.post(z.twoFactorSetupConfirm, e, tt(t));
1182
+ return this.axiosClient.post(z.twoFactorSetupConfirm, e, nt(t));
1183
1183
  }
1184
1184
  async getEnrollment(e) {
1185
- return (await this.axiosClient.get(z.twoFactorEnrollment, tt(e))).enrollment;
1185
+ return (await this.axiosClient.get(z.twoFactorEnrollment, nt(e))).enrollment;
1186
1186
  }
1187
1187
  sendSetupLink(e) {
1188
- return this.axiosClient.post(z.twoFactorEnrollmentEmailLink, void 0, tt(e));
1188
+ return this.axiosClient.post(z.twoFactorEnrollmentEmailLink, void 0, nt(e));
1189
1189
  }
1190
1190
  async beginEnrollment(e) {
1191
- return gt(await this.axiosClient.post(z.twoFactorEnrollmentBegin, void 0, tt(e)));
1191
+ return _t(await this.axiosClient.post(z.twoFactorEnrollmentBegin, void 0, nt(e)));
1192
1192
  }
1193
1193
  confirmEnrollment(e, t) {
1194
- return this.axiosClient.post(z.twoFactorEnrollmentConfirm, t, tt(e));
1194
+ return this.axiosClient.post(z.twoFactorEnrollmentConfirm, t, nt(e));
1195
1195
  }
1196
1196
  verify(e) {
1197
1197
  let { tfa_token: t, code: n, trust_device: r } = e;
1198
1198
  return this.axiosClient.post(z.twoFactorVerify, {
1199
1199
  code: n,
1200
1200
  ...r ? { trust_device: !0 } : {}
1201
- }, ht(t));
1201
+ }, gt(t));
1202
1202
  }
1203
1203
  useRecoveryCode(e) {
1204
1204
  let { tfa_token: t, recovery_code: n, trust_device: r } = e;
1205
1205
  return this.axiosClient.post(z.twoFactorRecovery, {
1206
1206
  recovery_code: n,
1207
1207
  ...r ? { trust_device: !0 } : {}
1208
- }, ht(t));
1208
+ }, gt(t));
1209
1209
  }
1210
1210
  disable(e) {
1211
1211
  return this.axiosClient.delete(z.twoFactor, { data: e });
@@ -1234,7 +1234,7 @@ var Ve = /* @__PURE__ */ function(e) {
1234
1234
  if (e instanceof V) return {
1235
1235
  success: !1,
1236
1236
  error: {
1237
- code: _t[e.id] ?? this.mapStatusToErrorCode(e.status),
1237
+ code: vt[e.id] ?? this.mapStatusToErrorCode(e.status),
1238
1238
  message: e.message || this.getDefaultErrorMessage(e.status)
1239
1239
  }
1240
1240
  };
@@ -1299,17 +1299,17 @@ var Ve = /* @__PURE__ */ function(e) {
1299
1299
  return this.axiosClient.delete(t);
1300
1300
  }
1301
1301
  requestChallenge(e, t) {
1302
- return this.axiosClient.post(z.TwoFactorChallenge, e, mt(t));
1302
+ return this.axiosClient.post(z.TwoFactorChallenge, e, ht(t));
1303
1303
  }
1304
1304
  verifyV2(e, t) {
1305
1305
  let { trust_device: n, ...r } = e;
1306
1306
  return this.axiosClient.post(z.TwoFactorVerifyV2, {
1307
1307
  ...r,
1308
1308
  ...n ? { trust_device: !0 } : {}
1309
- }, ht(t));
1309
+ }, gt(t));
1310
1310
  }
1311
1311
  switchToAlternative(e, t) {
1312
- return this.axiosClient.post(z.TwoFactorAlternative, e, mt(t));
1312
+ return this.axiosClient.post(z.TwoFactorAlternative, e, ht(t));
1313
1313
  }
1314
1314
  async getTrustedDevices() {
1315
1315
  return (await this.axiosClient.get(z.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
@@ -1318,9 +1318,9 @@ var Ve = /* @__PURE__ */ function(e) {
1318
1318
  let t = Be(z.TwoFactorTrustedDeviceRevoke, { id: e });
1319
1319
  return this.axiosClient.delete(t);
1320
1320
  }
1321
- }, yt = class {
1321
+ }, bt = class {
1322
1322
  constructor(e, t, n) {
1323
- this.axiosClient = new nt(e, t, n);
1323
+ this.axiosClient = new rt(e, t, n);
1324
1324
  }
1325
1325
  setAppId(e) {
1326
1326
  this.axiosClient.setAppId(e);
@@ -1328,9 +1328,15 @@ var Ve = /* @__PURE__ */ function(e) {
1328
1328
  startUpgrade(e) {
1329
1329
  return this.axiosClient.post(z.upgradeStart, e, we({}));
1330
1330
  }
1331
- }, bt = class {
1331
+ startHostedUpgrade(e) {
1332
+ return this.axiosClient.post(z.hostedUpgradeStart, e, { withCredentials: !0 });
1333
+ }
1334
+ async commitHostedUpgrade(e) {
1335
+ await this.axiosClient.post(z.hostedUpgrade, e, { withCredentials: !0 });
1336
+ }
1337
+ }, xt = class {
1332
1338
  constructor(e, t, n) {
1333
- this.axiosClient = new nt(e, t, n);
1339
+ this.axiosClient = new rt(e, t, n);
1334
1340
  }
1335
1341
  setAppId(e) {
1336
1342
  this.axiosClient.setAppId(e);
@@ -1361,48 +1367,48 @@ var Ve = /* @__PURE__ */ function(e) {
1361
1367
  passkey_data: e
1362
1368
  });
1363
1369
  }
1364
- }, xt = 10, St = 20, Ct = class extends Error {
1370
+ }, St = 10, Ct = 20, wt = class extends Error {
1365
1371
  constructor(e) {
1366
1372
  super(`Passflow fetch middleware '${e}' resolved without calling next(). Every registered middleware must delegate exactly once; swallowing a request would drop a caller's fetch inside the Passflow wrapper.`), this.name = "FetchMiddlewareContractError", this.middlewareName = e;
1367
1373
  }
1368
- }, wt = [], Tt = 0, Et = !1, Dt, Ot, kt = (e, t) => e.priority - t.priority || e.seq - t.seq, At = () => typeof globalThis > "u" ? void 0 : globalThis, jt = async (e, t, n, r) => {
1374
+ }, Tt = [], Et = 0, Dt = !1, Ot, kt, At = (e, t) => e.priority - t.priority || e.seq - t.seq, jt = () => typeof globalThis > "u" ? void 0 : globalThis, Mt = async (e, t, n, r) => {
1369
1375
  if (t >= e.length) {
1370
- let e = Dt;
1376
+ let e = Ot;
1371
1377
  if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
1372
1378
  return e(n, r);
1373
1379
  }
1374
1380
  let i = e[t];
1375
- if (!i) return jt(e, e.length, n, r);
1376
- let a = !1, o = await i.middleware((n, r) => (a = !0, jt(e, t + 1, n, r)), n, r);
1377
- if (!a) throw new Ct(i.name);
1381
+ if (!i) return Mt(e, e.length, n, r);
1382
+ let a = !1, o = await i.middleware((n, r) => (a = !0, Mt(e, t + 1, n, r)), n, r);
1383
+ if (!a) throw new wt(i.name);
1378
1384
  return o;
1379
- }, Mt = () => {
1380
- let e = At();
1381
- if (!e || typeof e.fetch != "function") return !1;
1382
- let t = e.fetch.bind(e), n = (e, t) => jt([...wt].sort(kt), 0, e, t);
1383
- return Dt = t, Ot = n, e.fetch = n, Et = !0, !0;
1384
1385
  }, Nt = () => {
1385
- let e = At();
1386
- e && Ot && e.fetch === Ot && (Dt && (e.fetch = Dt), Et = !1, Ot = void 0, Dt = void 0);
1387
- }, Pt = (e, t) => {
1388
- if (!Et && !Mt()) return () => {};
1386
+ let e = jt();
1387
+ if (!e || typeof e.fetch != "function") return !1;
1388
+ let t = e.fetch.bind(e), n = (e, t) => Mt([...Tt].sort(At), 0, e, t);
1389
+ return Ot = t, kt = n, e.fetch = n, Dt = !0, !0;
1390
+ }, Pt = () => {
1391
+ let e = jt();
1392
+ e && kt && e.fetch === kt && (Ot && (e.fetch = Ot), Dt = !1, kt = void 0, Ot = void 0);
1393
+ }, Ft = (e, t) => {
1394
+ if (!Dt && !Nt()) return () => {};
1389
1395
  let n = {
1390
1396
  middleware: e,
1391
1397
  name: t.name,
1392
1398
  priority: t.priority,
1393
- seq: Tt++
1399
+ seq: Et++
1394
1400
  };
1395
- wt.push(n);
1401
+ Tt.push(n);
1396
1402
  let r = !1;
1397
1403
  return () => {
1398
- r || (r = !0, wt = wt.filter((e) => e !== n), wt.length === 0 && Nt());
1404
+ r || (r = !0, Tt = Tt.filter((e) => e !== n), Tt.length === 0 && Pt());
1399
1405
  };
1400
- }, Ft = () => {
1401
- let e = At();
1406
+ }, It = () => {
1407
+ let e = jt();
1402
1408
  return {
1403
- installed: Et,
1404
- names: [...wt].sort(kt).map((e) => e.name),
1405
- foreignPatch: Et && !!e && !!Ot && e.fetch !== Ot
1409
+ installed: Dt,
1410
+ names: [...Tt].sort(At).map((e) => e.name),
1411
+ foreignPatch: Dt && !!e && !!kt && e.fetch !== kt
1406
1412
  };
1407
1413
  }, H = class e extends Error {
1408
1414
  constructor(t) {
@@ -1473,7 +1479,7 @@ var Ve = /* @__PURE__ */ function(e) {
1473
1479
  let e = `M2MError [${this.code}]: ${this.message}`;
1474
1480
  return this.status && (e += ` (HTTP ${this.status})`), e;
1475
1481
  }
1476
- }, It = class extends H {
1482
+ }, Lt = class extends H {
1477
1483
  constructor(e, t) {
1478
1484
  super({
1479
1485
  code: "temporarily_unavailable",
@@ -1482,7 +1488,7 @@ var Ve = /* @__PURE__ */ function(e) {
1482
1488
  cause: t
1483
1489
  }), this.name = "M2MNetworkError";
1484
1490
  }
1485
- }, Lt = class extends H {
1491
+ }, Rt = class extends H {
1486
1492
  constructor(e, t) {
1487
1493
  super({
1488
1494
  code: "invalid_request",
@@ -1491,7 +1497,7 @@ var Ve = /* @__PURE__ */ function(e) {
1491
1497
  cause: t
1492
1498
  }), this.name = "M2MTokenParseError";
1493
1499
  }
1494
- }, Rt = class extends H {
1500
+ }, zt = class extends H {
1495
1501
  constructor(e) {
1496
1502
  super({
1497
1503
  code: "invalid_request",
@@ -1499,7 +1505,7 @@ var Ve = /* @__PURE__ */ function(e) {
1499
1505
  status: 400
1500
1506
  }), this.name = "M2MConfigError";
1501
1507
  }
1502
- }, zt = {
1508
+ }, Bt = {
1503
1509
  InvalidRequest: "invalid_request",
1504
1510
  InvalidClient: "invalid_client",
1505
1511
  InvalidGrant: "invalid_grant",
@@ -1509,14 +1515,14 @@ var Ve = /* @__PURE__ */ function(e) {
1509
1515
  RateLimitExceeded: "rate_limit_exceeded",
1510
1516
  ServerError: "server_error",
1511
1517
  TemporarilyUnavailable: "temporarily_unavailable"
1512
- }, Bt = {
1518
+ }, Vt = {
1513
1519
  TOKEN_ENDPOINT: "/oauth2/token",
1514
1520
  TIMEOUT: 1e4,
1515
1521
  RETRIES: 3,
1516
1522
  RETRY_DELAY: 1e3,
1517
1523
  REFRESH_THRESHOLD: 30,
1518
1524
  CONTENT_TYPE: "application/x-www-form-urlencoded"
1519
- }, Vt = class {
1525
+ }, Ht = class {
1520
1526
  constructor() {
1521
1527
  this.cache = /* @__PURE__ */ new Map();
1522
1528
  }
@@ -1533,18 +1539,18 @@ var Ve = /* @__PURE__ */ function(e) {
1533
1539
  delete(e) {
1534
1540
  return this.cache.delete(e), Promise.resolve();
1535
1541
  }
1536
- }, Ht = {
1542
+ }, Ut = {
1537
1543
  shouldRetry(e, t) {
1538
1544
  return t >= 3 ? !1 : e.code === "server_error" || e.code === "temporarily_unavailable" || e.code === "rate_limit_exceeded" || e.status !== void 0 && e.status >= 500;
1539
1545
  },
1540
1546
  getDelay(e) {
1541
1547
  return 2 ** (e - 1) * 1e3;
1542
1548
  }
1543
- }, Ut = class {
1549
+ }, Wt = class {
1544
1550
  constructor(e) {
1545
- if (!e.url) throw new Rt("M2M client requires a URL");
1546
- if (!e.clientId) throw new Rt("M2M client requires a clientId");
1547
- if (!e.clientSecret) throw new Rt("M2M client requires a clientSecret");
1551
+ if (!e.url) throw new zt("M2M client requires a URL");
1552
+ if (!e.clientId) throw new zt("M2M client requires a clientId");
1553
+ if (!e.clientSecret) throw new zt("M2M client requires a clientSecret");
1548
1554
  let t = e.url.replace(/\/$/, "");
1549
1555
  this.config = {
1550
1556
  url: t,
@@ -1553,16 +1559,16 @@ var Ve = /* @__PURE__ */ function(e) {
1553
1559
  scopes: e.scopes,
1554
1560
  audience: e.audience,
1555
1561
  autoRefresh: e.autoRefresh ?? !1,
1556
- refreshThreshold: e.refreshThreshold ?? Bt.REFRESH_THRESHOLD,
1557
- timeout: e.timeout ?? Bt.TIMEOUT,
1558
- retries: e.retries ?? Bt.RETRIES,
1559
- retryDelay: e.retryDelay ?? Bt.RETRY_DELAY,
1562
+ refreshThreshold: e.refreshThreshold ?? Vt.REFRESH_THRESHOLD,
1563
+ timeout: e.timeout ?? Vt.TIMEOUT,
1564
+ retries: e.retries ?? Vt.RETRIES,
1565
+ retryDelay: e.retryDelay ?? Vt.RETRY_DELAY,
1560
1566
  retryStrategy: e.retryStrategy,
1561
1567
  cache: e.cache,
1562
1568
  onTokenRequest: e.onTokenRequest,
1563
1569
  onTokenResponse: e.onTokenResponse,
1564
1570
  onError: e.onError
1565
- }, this.cache = e.cache ?? new Vt(), this.retryStrategy = e.retryStrategy ?? Ht, this.tokenEndpoint = `${t}${Bt.TOKEN_ENDPOINT}`;
1571
+ }, this.cache = e.cache ?? new Ht(), this.retryStrategy = e.retryStrategy ?? Ut, this.tokenEndpoint = `${t}${Vt.TOKEN_ENDPOINT}`;
1566
1572
  }
1567
1573
  getCacheKey(e, t) {
1568
1574
  let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
@@ -1607,7 +1613,7 @@ var Ve = /* @__PURE__ */ function(e) {
1607
1613
  let e = await fetch(this.tokenEndpoint, {
1608
1614
  method: "POST",
1609
1615
  headers: {
1610
- "Content-Type": Bt.CONTENT_TYPE,
1616
+ "Content-Type": Vt.CONTENT_TYPE,
1611
1617
  Accept: "application/json"
1612
1618
  },
1613
1619
  body: t.toString(),
@@ -1632,7 +1638,7 @@ var Ve = /* @__PURE__ */ function(e) {
1632
1638
  }
1633
1639
  return a;
1634
1640
  } catch (e) {
1635
- throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new It(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new It(`Network error: ${e.message}`, e) : e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
1641
+ throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new Lt(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new Lt(`Network error: ${e.message}`, e) : e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
1636
1642
  }
1637
1643
  }
1638
1644
  async executeWithRetry(e) {
@@ -1675,13 +1681,13 @@ var Ve = /* @__PURE__ */ function(e) {
1675
1681
  parseToken(e) {
1676
1682
  try {
1677
1683
  let t = e.split(".");
1678
- if (t.length !== 3) throw new Lt("Invalid JWT format: expected 3 parts");
1684
+ if (t.length !== 3) throw new Rt("Invalid JWT format: expected 3 parts");
1679
1685
  let n = t[1];
1680
- if (!n) throw new Lt("Invalid JWT format: missing payload");
1686
+ if (!n) throw new Rt("Invalid JWT format: missing payload");
1681
1687
  let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
1682
1688
  return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
1683
1689
  } catch (e) {
1684
- throw e instanceof Lt ? e : new Lt(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
1690
+ throw e instanceof Rt ? e : new Rt(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
1685
1691
  }
1686
1692
  }
1687
1693
  clearCache() {
@@ -1696,7 +1702,7 @@ var Ve = /* @__PURE__ */ function(e) {
1696
1702
  try {
1697
1703
  let e = await fetch(t, {
1698
1704
  method: "POST",
1699
- headers: { "Content-Type": Bt.CONTENT_TYPE },
1705
+ headers: { "Content-Type": Vt.CONTENT_TYPE },
1700
1706
  body: n.toString()
1701
1707
  });
1702
1708
  if (!e.ok && e.status !== 200) {
@@ -1723,50 +1729,50 @@ var Ve = /* @__PURE__ */ function(e) {
1723
1729
  get audience() {
1724
1730
  return this.config.audience;
1725
1731
  }
1726
- }, Wt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", Gt = 32, Kt = (e) => {
1732
+ }, Gt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", Kt = 32, qt = (e) => {
1727
1733
  let t = "";
1728
1734
  for (let n = 0; n < e.length; n += 3) {
1729
1735
  let r = e[n], i = e[n + 1], a = e[n + 2];
1730
- t += Wt.charAt(r >> 2), t += Wt.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += Wt.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += Wt.charAt(a & 63));
1736
+ t += Gt.charAt(r >> 2), t += Gt.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += Gt.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += Gt.charAt(a & 63));
1731
1737
  }
1732
1738
  return t;
1733
- }, qt = () => {
1739
+ }, Jt = () => {
1734
1740
  let e = globalThis.crypto;
1735
1741
  if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
1736
1742
  return e;
1737
- }, Jt = async (e) => {
1738
- let t = await qt().subtle.digest("SHA-256", new TextEncoder().encode(e));
1739
- return Kt(new Uint8Array(t));
1740
- }, Yt = (e = Gt) => Kt(qt().getRandomValues(new Uint8Array(e))), Xt = async () => {
1741
- let e = Yt(Gt);
1743
+ }, Yt = async (e) => {
1744
+ let t = await Jt().subtle.digest("SHA-256", new TextEncoder().encode(e));
1745
+ return qt(new Uint8Array(t));
1746
+ }, Xt = (e = Kt) => qt(Jt().getRandomValues(new Uint8Array(e))), Zt = async () => {
1747
+ let e = Xt(Kt);
1742
1748
  return {
1743
1749
  verifier: e,
1744
- challenge: await Jt(e)
1750
+ challenge: await Yt(e)
1745
1751
  };
1746
- }, Zt = () => !!globalThis.crypto?.subtle, U = class extends Error {
1752
+ }, Qt = () => !!globalThis.crypto?.subtle, U = class extends Error {
1747
1753
  constructor(e, t) {
1748
1754
  super(t), this.code = e, this.name = "PassflowOidcError";
1749
1755
  }
1750
- }, Qt = "Sign in again.", $t = (e) => `This app is type ${e} and is a confidential client (it has a secret). For a browser app set its type to SPA; a server-side app redeems the code on its server with the secret.`, en = "This app is a confidential client. For a browser app set its type to SPA (or token_endpoint_auth_method to none); a server-side app must redeem the code on its server with the client secret.", tn = () => new U("TOKENS_IN_URL_NOT_ALLOWED", "Tokens in the URL are accepted only for apps in Simple mode"), nn = "passflow_oidc_pkce", rn = 6e5, an = (e) => {
1756
+ }, $t = "Sign in again.", en = (e) => `This app is type ${e} and is a confidential client (it has a secret). For a browser app set its type to SPA; a server-side app redeems the code on its server with the secret.`, tn = "This app is a confidential client. For a browser app set its type to SPA (or token_endpoint_auth_method to none); a server-side app must redeem the code on its server with the client secret.", nn = () => new U("TOKENS_IN_URL_NOT_ALLOWED", "Tokens in the URL are accepted only for apps in Simple mode"), rn = "passflow_oidc_pkce", an = 6e5, on = (e) => {
1751
1757
  try {
1752
1758
  let t = new URL(e);
1753
1759
  return `${t.protocol}//${t.host}${t.pathname.replace(/\/+$/, "")}`;
1754
1760
  } catch {
1755
1761
  return e;
1756
1762
  }
1757
- }, on = (e) => !e.includes("openid") && (e.includes("id") || e.includes("oidc")) ? [...e, "openid"] : [...e], sn = async (e) => {
1758
- if (!Zt()) throw new U("SECURE_CONTEXT_REQUIRED", "Sign-in needs the Web Crypto API, which is available only in a secure context (https or localhost)");
1759
- let t = on(e.scopes), n = await Xt(), r = {
1763
+ }, sn = (e) => !e.includes("openid") && (e.includes("id") || e.includes("oidc")) ? [...e, "openid"] : [...e], cn = async (e) => {
1764
+ if (!Qt()) throw new U("SECURE_CONTEXT_REQUIRED", "Sign-in needs the Web Crypto API, which is available only in a secure context (https or localhost)");
1765
+ let t = sn(e.scopes), n = await Zt(), r = {
1760
1766
  verifier: n.verifier,
1761
- state: Yt(),
1762
- ...t.includes("openid") ? { nonce: Yt() } : {},
1767
+ state: Xt(),
1768
+ ...t.includes("openid") ? { nonce: Xt() } : {},
1763
1769
  clientId: e.clientId,
1764
1770
  redirectUri: e.redirectUri,
1765
1771
  scopes: t,
1766
- expiresAt: Date.now() + rn
1772
+ expiresAt: Date.now() + an
1767
1773
  };
1768
1774
  try {
1769
- sessionStorage.setItem(nn, JSON.stringify(r));
1775
+ sessionStorage.setItem(rn, JSON.stringify(r));
1770
1776
  } catch {
1771
1777
  throw new U("STORAGE_UNAVAILABLE", "Sign-in needs sessionStorage, which cannot be written here");
1772
1778
  }
@@ -1781,37 +1787,37 @@ var Ve = /* @__PURE__ */ function(e) {
1781
1787
  code_challenge_method: "S256",
1782
1788
  ...r.nonce ? { nonce: r.nonce } : {}
1783
1789
  }).toString(), i.toString();
1784
- }, cn = (e) => {
1790
+ }, ln = (e) => {
1785
1791
  let t = e;
1786
1792
  return typeof t == "object" && !!t && typeof t.verifier == "string" && typeof t.state == "string" && typeof t.clientId == "string" && typeof t.redirectUri == "string" && Array.isArray(t.scopes) && typeof t.expiresAt == "number";
1787
- }, ln = () => {
1793
+ }, un = () => {
1788
1794
  let e;
1789
1795
  try {
1790
- e = sessionStorage.getItem(nn);
1796
+ e = sessionStorage.getItem(rn);
1791
1797
  } catch {
1792
1798
  return { status: "none" };
1793
1799
  }
1794
1800
  if (!e) return { status: "none" };
1795
1801
  try {
1796
1802
  let t = JSON.parse(e);
1797
- if (cn(t) && Date.now() < t.expiresAt) return {
1803
+ if (ln(t) && Date.now() < t.expiresAt) return {
1798
1804
  status: "live",
1799
1805
  slot: t
1800
1806
  };
1801
1807
  } catch {}
1802
1808
  return { status: "unusable" };
1803
- }, un = () => {
1809
+ }, dn = () => {
1804
1810
  try {
1805
- sessionStorage.removeItem(nn);
1811
+ sessionStorage.removeItem(rn);
1806
1812
  } catch {}
1807
- }, dn = async (e) => {
1813
+ }, fn = async (e) => {
1808
1814
  try {
1809
1815
  let t = await e.json();
1810
1816
  return typeof t == "object" && t ? t : void 0;
1811
1817
  } catch {
1812
1818
  return;
1813
1819
  }
1814
- }, fn = async (e, t, n) => {
1820
+ }, pn = async (e, t, n) => {
1815
1821
  let r;
1816
1822
  try {
1817
1823
  r = await fetch(`${e.replace(/\/+$/, "")}/oidc/token`, {
@@ -1826,11 +1832,11 @@ var Ve = /* @__PURE__ */ function(e) {
1826
1832
  }).toString()
1827
1833
  });
1828
1834
  } catch {
1829
- throw new U("TOKEN_EXCHANGE_FAILED", Qt);
1835
+ throw new U("TOKEN_EXCHANGE_FAILED", $t);
1830
1836
  }
1831
- let i = await dn(r);
1832
- if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client", en) : i?.error === "invalid_grant" ? new U("invalid_grant", Qt) : new U("TOKEN_EXCHANGE_FAILED", Qt);
1833
- if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED", Qt);
1837
+ let i = await fn(r);
1838
+ if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client", tn) : i?.error === "invalid_grant" ? new U("invalid_grant", $t) : new U("TOKEN_EXCHANGE_FAILED", $t);
1839
+ if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED", $t);
1834
1840
  let a = typeof i.id_token == "string" ? i.id_token : void 0;
1835
1841
  if (n.scopes.includes("openid")) {
1836
1842
  let e;
@@ -1839,7 +1845,7 @@ var Ve = /* @__PURE__ */ function(e) {
1839
1845
  } catch {
1840
1846
  e = void 0;
1841
1847
  }
1842
- if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${Qt}`);
1848
+ if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${$t}`);
1843
1849
  }
1844
1850
  return {
1845
1851
  access_token: i.access_token,
@@ -1847,101 +1853,101 @@ var Ve = /* @__PURE__ */ function(e) {
1847
1853
  ...a ? { id_token: a } : {},
1848
1854
  scopes: n.scopes
1849
1855
  };
1850
- }, pn = "error", mn = /* @__PURE__ */ new WeakMap(), hn = (e, t) => {
1856
+ }, mn = "error", hn = /* @__PURE__ */ new WeakMap(), gn = (e, t) => {
1851
1857
  if (typeof t != "object" && typeof t != "function" || t === null) return !0;
1852
- let n = mn.get(e);
1853
- return n || (n = /* @__PURE__ */ new WeakSet(), mn.set(e, n)), !n.has(t) && (n.add(t), !0);
1854
- }, W = (e, t) => hn(e, t.originalError) ? (e.notify(pn, t), !0) : !1, gn = "passflow-refresh", _n = "passflow-refresh-takeover", vn = "passflow-auth", yn = Object.freeze([
1858
+ let n = hn.get(e);
1859
+ return n || (n = /* @__PURE__ */ new WeakSet(), hn.set(e, n)), !n.has(t) && (n.add(t), !0);
1860
+ }, W = (e, t) => gn(e, t.originalError) ? (e.notify(mn, t), !0) : !1, _n = "passflow-refresh", vn = "passflow-refresh-takeover", yn = "passflow-auth", bn = Object.freeze([
1855
1861
  1e3,
1856
1862
  3e3,
1857
1863
  1e4,
1858
1864
  3e4,
1859
1865
  6e4
1860
- ]), bn = .2, xn = 6e5, Sn = 5e3, G = 2e4, Cn = 2e4, wn = 1e3, Tn = 2e3, En = 1e3, Dn = 1e4, On = 5e3;
1866
+ ]), xn = .2, Sn = 6e5, Cn = 5e3, G = 2e4, wn = 2e4, Tn = 1e3, En = 2e3, Dn = 1e3, On = 1e4, kn = 5e3;
1861
1867
  // lib/refresh/protocol.ts
1862
- function kn(e) {
1868
+ function An(e) {
1863
1869
  let t = e ? `:${e}` : "";
1864
1870
  return {
1865
- lock: `${gn}${t}`,
1866
- takeoverLock: `${_n}${t}`,
1867
- channel: `${vn}${t}`
1871
+ lock: `${_n}${t}`,
1872
+ takeoverLock: `${vn}${t}`,
1873
+ channel: `${yn}${t}`
1868
1874
  };
1869
1875
  }
1870
1876
  function K(e) {
1871
1877
  return typeof e == "string" && e !== "" ? e : void 0;
1872
1878
  }
1873
- function An(e) {
1879
+ function jn(e) {
1874
1880
  return typeof e == "number" && Number.isFinite(e) ? e : void 0;
1875
1881
  }
1876
- function jn(e) {
1882
+ function Mn(e) {
1877
1883
  return typeof e == "object" && !!e;
1878
1884
  }
1879
- function Mn(e, t) {
1885
+ function Nn(e, t) {
1880
1886
  for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
1881
1887
  return e;
1882
1888
  }
1883
- function Nn(e) {
1884
- if (!jn(e)) return null;
1889
+ function Pn(e) {
1890
+ if (!Mn(e)) return null;
1885
1891
  let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
1886
- return Mn({}, {
1892
+ return Nn({}, {
1887
1893
  access_token: K(e.access_token),
1888
1894
  refresh_token: K(e.refresh_token),
1889
1895
  id_token: K(e.id_token),
1890
1896
  scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
1891
1897
  });
1892
1898
  }
1893
- function Pn(e) {
1894
- if (!jn(e)) return null;
1899
+ function Fn(e) {
1900
+ if (!Mn(e)) return null;
1895
1901
  let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
1896
- return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || An(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Mn({
1902
+ return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || jn(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Nn({
1897
1903
  kind: t,
1898
1904
  attempt: n,
1899
1905
  nextAt: r,
1900
1906
  strikes: i
1901
1907
  }, {
1902
1908
  from: K(e.from),
1903
- failingSince: An(e.failingSince)
1909
+ failingSince: jn(e.failingSince)
1904
1910
  });
1905
1911
  }
1906
- function Fn(e) {
1907
- return Mn({}, {
1912
+ function In(e) {
1913
+ return Nn({}, {
1908
1914
  fp: K(e.fp),
1909
1915
  sub: K(e.sub),
1910
1916
  sid: K(e.sid),
1911
- iat: An(e.iat)
1917
+ iat: jn(e.iat)
1912
1918
  });
1913
1919
  }
1914
- function In(e) {
1915
- if (!jn(e)) return null;
1920
+ function Ln(e) {
1921
+ if (!Mn(e)) return null;
1916
1922
  let t = e;
1917
1923
  if (t.v !== void 0 && t.v !== 1) return null;
1918
1924
  let n = K(t.tabId);
1919
1925
  if (!n) return null;
1920
1926
  switch (t.type) {
1921
1927
  case "tokens-refreshed": {
1922
- let e = Nn(t.tokens), r = K(t.from), i = K(t.to);
1923
- return !e || !r || !i ? null : Mn({
1928
+ let e = Pn(t.tokens), r = K(t.from), i = K(t.to);
1929
+ return !e || !r || !i ? null : Nn({
1924
1930
  type: t.type,
1925
1931
  tabId: n,
1926
1932
  tokens: e,
1927
1933
  from: r,
1928
1934
  to: i
1929
1935
  }, {
1930
- fromIat: An(t.fromIat),
1936
+ fromIat: jn(t.fromIat),
1931
1937
  fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
1932
- sentAt: An(t.sentAt)
1938
+ sentAt: jn(t.sentAt)
1933
1939
  });
1934
1940
  }
1935
1941
  case "session-refreshed": {
1936
- let e = An(t.at);
1937
- return e === void 0 ? null : Mn({
1942
+ let e = jn(t.at);
1943
+ return e === void 0 ? null : Nn({
1938
1944
  type: t.type,
1939
1945
  tabId: n,
1940
1946
  at: e
1941
1947
  }, { sub: K(t.sub) });
1942
1948
  }
1943
1949
  case "still-refreshing": {
1944
- let e = t.retry === void 0 ? null : Pn(t.retry);
1950
+ let e = t.retry === void 0 ? null : Fn(t.retry);
1945
1951
  return e ? {
1946
1952
  type: t.type,
1947
1953
  tabId: n,
@@ -1952,7 +1958,7 @@ function In(e) {
1952
1958
  };
1953
1959
  }
1954
1960
  case "retry-scheduled": {
1955
- let e = Pn(t);
1961
+ let e = Fn(t);
1956
1962
  return e ? {
1957
1963
  type: t.type,
1958
1964
  tabId: n,
@@ -1973,10 +1979,10 @@ function In(e) {
1973
1979
  case "signed-out": return {
1974
1980
  type: t.type,
1975
1981
  tabId: n,
1976
- ...Fn(t)
1982
+ ...In(t)
1977
1983
  };
1978
1984
  case "rate-limited": {
1979
- let e = An(t.until);
1985
+ let e = jn(t.until);
1980
1986
  return e === void 0 ? null : {
1981
1987
  type: t.type,
1982
1988
  tabId: n,
@@ -1995,22 +2001,22 @@ function In(e) {
1995
2001
  default: return null;
1996
2002
  }
1997
2003
  }
1998
- function Ln(e, t) {
2004
+ function Rn(e, t) {
1999
2005
  let n = {
2000
2006
  v: 1,
2001
2007
  tabId: e
2002
2008
  };
2003
2009
  if (t.type === "retry-scheduled") {
2004
2010
  let { retry: e, ...r } = t;
2005
- return Mn(n, {
2011
+ return Nn(n, {
2006
2012
  ...r,
2007
2013
  ...e
2008
2014
  });
2009
2015
  }
2010
- return Mn(n, { ...t });
2016
+ return Nn(n, { ...t });
2011
2017
  }
2012
2018
  // lib/refresh/resolve.ts
2013
- var Rn = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", zn = {
2019
+ var zn = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", Bn = {
2014
2020
  now: () => Date.now(),
2015
2021
  random: () => Math.random(),
2016
2022
  setTimeout: (e, t) => {
@@ -2018,28 +2024,28 @@ var Rn = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
2018
2024
  return n.unref?.(), () => clearTimeout(n);
2019
2025
  }
2020
2026
  };
2021
- function Bn() {
2027
+ function Vn() {
2022
2028
  let e = globalThis.crypto;
2023
2029
  return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
2024
2030
  }
2025
- function Vn(e) {
2031
+ function Hn(e) {
2026
2032
  return e ? {
2027
2033
  now: () => e.now(),
2028
2034
  setTimeout: (t, n) => e.setTimeout(t, n),
2029
- random: e.random ? () => e.random?.() ?? Math.random() : zn.random
2030
- } : zn;
2035
+ random: e.random ? () => e.random?.() ?? Math.random() : Bn.random
2036
+ } : Bn;
2031
2037
  }
2032
- function Hn(e) {
2038
+ function Un(e) {
2033
2039
  return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
2034
2040
  }
2035
- function Un(e) {
2041
+ function Wn(e) {
2036
2042
  try {
2037
2043
  return e.storageSharedAcrossTabs === !0;
2038
2044
  } catch {
2039
2045
  return !1;
2040
2046
  }
2041
2047
  }
2042
- function Wn() {
2048
+ function Gn() {
2043
2049
  try {
2044
2050
  let e = globalThis.navigator?.locks;
2045
2051
  return e && typeof e.request == "function" ? e : void 0;
@@ -2047,7 +2053,7 @@ function Wn() {
2047
2053
  return;
2048
2054
  }
2049
2055
  }
2050
- function Gn(e) {
2056
+ function Kn(e) {
2051
2057
  return (t) => {
2052
2058
  let n = (n) => {
2053
2059
  let r = n.key;
@@ -2056,20 +2062,20 @@ function Gn(e) {
2056
2062
  return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
2057
2063
  };
2058
2064
  }
2059
- function Kn(e) {
2065
+ function qn(e) {
2060
2066
  return {
2061
2067
  transports: null,
2062
- names: kn(e),
2063
- clock: zn,
2068
+ names: An(e),
2069
+ clock: Bn,
2064
2070
  warnOnFirstCycle: !1
2065
2071
  };
2066
2072
  }
2067
- function qn(e, t, n, r) {
2068
- let i = kn(n), a = Hn(t), o = a ? Gn(r.tokenKeys) : void 0, s = (e) => {
2073
+ function Jn(e, t, n, r) {
2074
+ let i = An(n), a = Un(t), o = a ? Kn(r.tokenKeys) : void 0, s = (e) => {
2069
2075
  let t = {
2070
2076
  transports: null,
2071
2077
  names: i,
2072
- clock: zn,
2078
+ clock: Bn,
2073
2079
  warnOnFirstCycle: e
2074
2080
  };
2075
2081
  return o && (t.onStorageChange = o), t;
@@ -2079,16 +2085,16 @@ function qn(e, t, n, r) {
2079
2085
  transports: {
2080
2086
  locks: e.locks,
2081
2087
  channel: e.channel,
2082
- tabId: e.tabId ?? Bn()
2088
+ tabId: e.tabId ?? Vn()
2083
2089
  },
2084
2090
  names: i,
2085
- clock: Vn(e.clock),
2091
+ clock: Hn(e.clock),
2086
2092
  warnOnFirstCycle: !1
2087
2093
  };
2088
2094
  return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
2089
2095
  }
2090
- if (e === "none" || !a || !Un(t)) return s(!1);
2091
- let c = Wn();
2096
+ if (e === "none" || !a || !Wn(t)) return s(!1);
2097
+ let c = Gn();
2092
2098
  if (!c || typeof BroadcastChannel != "function") return s(!0);
2093
2099
  let l;
2094
2100
  try {
@@ -2100,16 +2106,16 @@ function qn(e, t, n, r) {
2100
2106
  transports: {
2101
2107
  locks: c,
2102
2108
  channel: l,
2103
- tabId: Bn()
2109
+ tabId: Vn()
2104
2110
  },
2105
2111
  names: i,
2106
- clock: zn,
2112
+ clock: Bn,
2107
2113
  warnOnFirstCycle: !1
2108
2114
  };
2109
2115
  return o && (u.onStorageChange = o), u;
2110
2116
  }
2111
2117
  // lib/services/logger.ts
2112
- var Jn = class {
2118
+ var Yn = class {
2113
2119
  error(e, ...t) {
2114
2120
  console.error(e, ...t);
2115
2121
  }
@@ -2123,10 +2129,10 @@ var Jn = class {
2123
2129
  console.debug(e, ...t);
2124
2130
  }
2125
2131
  };
2126
- function Yn() {
2127
- return new Jn();
2132
+ function Xn() {
2133
+ return new Yn();
2128
2134
  }
2129
- var Xn = Object.freeze([
2135
+ var Zn = Object.freeze([
2130
2136
  "error.token.invalid.error",
2131
2137
  "error.api.token.parse.error",
2132
2138
  "error.api.user.blocked",
@@ -2134,25 +2140,25 @@ var Xn = Object.freeze([
2134
2140
  "error.validation.token.invalid.subject",
2135
2141
  "error.not.found"
2136
2142
  ]);
2137
- function Zn(e) {
2143
+ function Qn(e) {
2138
2144
  if (typeof e != "object" || !e) return;
2139
2145
  let t = e;
2140
2146
  return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
2141
2147
  }
2142
- function Qn(e, t) {
2143
- if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(xn, Math.floor(e) * 1e3);
2148
+ function $n(e, t) {
2149
+ if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(Sn, Math.floor(e) * 1e3);
2144
2150
  if (typeof e != "string") return;
2145
2151
  let n = e.trim();
2146
2152
  if (n === "") return;
2147
- if (/^\d+$/.test(n)) return Math.min(xn, Number.parseInt(n, 10) * 1e3);
2153
+ if (/^\d+$/.test(n)) return Math.min(Sn, Number.parseInt(n, 10) * 1e3);
2148
2154
  if (!/[a-z]/i.test(n)) return;
2149
2155
  let r = Date.parse(n);
2150
- if (!Number.isNaN(r)) return Math.min(xn, Math.max(0, r - t));
2156
+ if (!Number.isNaN(r)) return Math.min(Sn, Math.max(0, r - t));
2151
2157
  }
2152
- function $n(e) {
2158
+ function er(e) {
2153
2159
  return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
2154
2160
  }
2155
- function er(e) {
2161
+ function tr(e) {
2156
2162
  if (typeof e.id == "string" && e.id !== "") return e.id;
2157
2163
  let t = e.response?.data;
2158
2164
  if (typeof t != "object" || !t) return;
@@ -2161,14 +2167,14 @@ function er(e) {
2161
2167
  let r = n.id;
2162
2168
  return typeof r == "string" && r !== "" ? r : void 0;
2163
2169
  }
2164
- function tr(e, t = Date.now()) {
2170
+ function nr(e, t = Date.now()) {
2165
2171
  if (typeof e != "object" || !e) return { kind: "transient" };
2166
- let n = e, r = er(n), i = $n(n.response?.status) ?? $n(n.status), a = {};
2172
+ let n = e, r = tr(n), i = er(n.response?.status) ?? er(n.status), a = {};
2167
2173
  if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
2168
2174
  kind: "blocked",
2169
2175
  ...a
2170
2176
  };
2171
- if (r !== void 0 && Xn.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
2177
+ if (r !== void 0 && Zn.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
2172
2178
  kind: "auth",
2173
2179
  ...a
2174
2180
  };
@@ -2176,7 +2182,7 @@ function tr(e, t = Date.now()) {
2176
2182
  kind: "transient",
2177
2183
  ...a
2178
2184
  };
2179
- let o = Qn(n.retryAfter ?? Zn(n.response?.headers), t);
2185
+ let o = $n(n.retryAfter ?? Qn(n.response?.headers), t);
2180
2186
  return o === void 0 ? {
2181
2187
  kind: "transient",
2182
2188
  ...a
@@ -2186,19 +2192,19 @@ function tr(e, t = Date.now()) {
2186
2192
  retryAfterMs: o
2187
2193
  };
2188
2194
  }
2189
- function nr(e, t, n) {
2190
- let r = yn.length, i = yn[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? yn[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * bn * a);
2191
- return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), xn) : 0);
2195
+ function rr(e, t, n) {
2196
+ let r = bn.length, i = bn[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? bn[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * xn * a);
2197
+ return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), Sn) : 0);
2192
2198
  }
2193
2199
  // lib/refresh/coordinator.ts
2194
- var rr = {
2200
+ var ir = {
2195
2201
  onGranted: () => !1,
2196
2202
  onLockLost: () => void 0,
2197
2203
  onMessage: () => void 0
2198
2204
  };
2199
- function ir(e) {
2200
- let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = rr, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
2201
- g || n.postMessage(Ln(r, e));
2205
+ function ar(e) {
2206
+ let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = ir, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
2207
+ g || n.postMessage(Rn(r, e));
2202
2208
  }, v = () => s !== null && c === null, y = () => {
2203
2209
  f?.(), f = null;
2204
2210
  }, b = (e) => {
@@ -2213,7 +2219,7 @@ function ir(e) {
2213
2219
  type: "still-refreshing",
2214
2220
  retry: m
2215
2221
  } : { type: "still-refreshing" }), S());
2216
- }, Sn);
2222
+ }, Cn);
2217
2223
  }, C = () => {
2218
2224
  y(), x(), u?.(), u = null;
2219
2225
  let e = s;
@@ -2264,7 +2270,7 @@ function ir(e) {
2264
2270
  });
2265
2271
  }, ee = (e) => {
2266
2272
  if (g) return;
2267
- let t = In(e.data);
2273
+ let t = Ln(e.data);
2268
2274
  if (t && t.tabId !== r) {
2269
2275
  switch (t.type) {
2270
2276
  case "still-refreshing":
@@ -2307,8 +2313,8 @@ function ir(e) {
2307
2313
  }
2308
2314
  };
2309
2315
  }
2310
- function ar(e = "local") {
2311
- let t = rr, n = !1, r = !1, i = 0, a = !1, o = () => {
2316
+ function or(e = "local") {
2317
+ let t = ir, n = !1, r = !1, i = 0, a = !1, o = () => {
2312
2318
  n = !1, r = !1, i += 1;
2313
2319
  };
2314
2320
  return {
@@ -2356,7 +2362,7 @@ var q = {
2356
2362
  successorTimeout: "error.refresh.successor_timeout",
2357
2363
  identityChanged: "error.refresh.identity_changed",
2358
2364
  disposed: "error.refresh.disposed"
2359
- }, or = {
2365
+ }, sr = {
2360
2366
  "error.refresh.unavailable": 503,
2361
2367
  "error.refresh.auth_retry": 401,
2362
2368
  "error.refresh.session_ended": 401,
@@ -2364,7 +2370,7 @@ var q = {
2364
2370
  "error.refresh.successor_timeout": 401,
2365
2371
  "error.refresh.identity_changed": 401,
2366
2372
  "error.refresh.disposed": 499
2367
- }, sr = {
2373
+ }, cr = {
2368
2374
  "error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
2369
2375
  "error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
2370
2376
  "error.refresh.session_ended": "The session has ended",
@@ -2376,19 +2382,19 @@ var q = {
2376
2382
  constructor(e, t = {}) {
2377
2383
  super({
2378
2384
  id: e,
2379
- message: t.message ?? sr[e],
2380
- status: or[e],
2385
+ message: t.message ?? cr[e],
2386
+ status: sr[e],
2381
2387
  location: "/auth/refresh",
2382
2388
  time: (/* @__PURE__ */ new Date()).toISOString()
2383
2389
  }), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
2384
2390
  }
2385
- }, cr = class extends Error {
2391
+ }, lr = class extends Error {
2386
2392
  constructor(e, t) {
2387
2393
  super(t ?? (e === "lock-timeout" ? "Step-up commit could not take the refresh lock in time" : "Step-up commit answer arrived after the stored session moved on")), this.name = "UpgradeCommitInterruptedError", this.reason = e;
2388
2394
  }
2389
2395
  };
2390
2396
  // lib/refresh/lineage.ts
2391
- function lr(e) {
2397
+ function ur(e) {
2392
2398
  if (!e) return;
2393
2399
  let t = 3735928559, n = 1103547991;
2394
2400
  for (let r = 0; r < e.length; r++) {
@@ -2397,24 +2403,24 @@ function lr(e) {
2397
2403
  }
2398
2404
  return t = Math.imul(t ^ t >>> 16, 2246822507), t ^= Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507), n ^= Math.imul(t ^ t >>> 13, 3266489909), (4294967296 * (2097151 & n) + (t >>> 0)).toString(16);
2399
2405
  }
2400
- function ur(e) {
2406
+ function dr(e) {
2401
2407
  return typeof e == "string" && e !== "" ? e : void 0;
2402
2408
  }
2403
2409
  function Y(e) {
2404
- let t = lr(e);
2410
+ let t = ur(e);
2405
2411
  if (!e || !t) return;
2406
2412
  let n = {};
2407
2413
  try {
2408
2414
  let t = j(e);
2409
2415
  typeof t == "object" && t && (n = t);
2410
2416
  } catch {}
2411
- let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = ur(n.sub), o = ur(n.sid);
2417
+ let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = dr(n.sub), o = dr(n.sid);
2412
2418
  return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
2413
2419
  }
2414
- var dr = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
2415
- function fr(e = (e) => Yn().warn(e)) {
2420
+ var fr = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
2421
+ function pr(e = (e) => Xn().warn(e)) {
2416
2422
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
2417
- a || (a = !0, e(dr));
2423
+ a || (a = !0, e(fr));
2418
2424
  }, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
2419
2425
  if (!e) return;
2420
2426
  if (e.iat === void 0) {
@@ -2455,16 +2461,16 @@ function fr(e = (e) => Yn().warn(e)) {
2455
2461
  };
2456
2462
  }
2457
2463
  // lib/refresh/fence.ts
2458
- var pr = class extends Error {
2464
+ var mr = class extends Error {
2459
2465
  constructor(e) {
2460
2466
  super(e === "emptied" ? "The shared token storage was emptied" : "The stored refresh token belongs to an ended session"), this.name = "SessionEnded", this.cause = e;
2461
2467
  }
2462
- }, mr = class extends Error {
2468
+ }, hr = class extends Error {
2463
2469
  constructor() {
2464
2470
  super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
2465
2471
  }
2466
2472
  };
2467
- function hr(e) {
2473
+ function gr(e) {
2468
2474
  if (e) try {
2469
2475
  let t = j(e).sub;
2470
2476
  return typeof t == "string" && t !== "" ? t : void 0;
@@ -2473,20 +2479,20 @@ function hr(e) {
2473
2479
  }
2474
2480
  }
2475
2481
  function X(e) {
2476
- return hr(e?.access_token) ?? hr(e?.refresh_token) ?? hr(e?.id_token);
2482
+ return gr(e?.access_token) ?? gr(e?.refresh_token) ?? gr(e?.id_token);
2477
2483
  }
2478
- function gr(e, t) {
2484
+ function _r(e, t) {
2479
2485
  return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
2480
2486
  }
2481
- function _r(e) {
2487
+ function vr(e) {
2482
2488
  return typeof e == "object" && !!e;
2483
2489
  }
2484
- function vr(e) {
2485
- let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => Yn().warn(e)), o = e.lineage ?? fr(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
2490
+ function yr(e) {
2491
+ let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => Xn().warn(e)), o = e.lineage ?? pr(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
2486
2492
  let e = t.getTokens(), n = e?.refresh_token;
2487
2493
  if (!n) return p = l, e;
2488
2494
  p !== void 0 && (f = Math.max(f, p, m), p = void 0);
2489
- let r = lr(n) ?? "";
2495
+ let r = ur(n) ?? "";
2490
2496
  return r !== c?.fp && (c = {
2491
2497
  fp: r,
2492
2498
  seq: l
@@ -2519,7 +2525,7 @@ function vr(e) {
2519
2525
  let t = E();
2520
2526
  t === "wait" && e && (t = "end"), t !== "wait" && D(), t === "wait" && !h && (h = r(() => {
2521
2527
  h = void 0, y()?.refresh_token ? P() : O(!0) === "end" && s?.("emptied");
2522
- }, Tn));
2528
+ }, En));
2523
2529
  let n = t === "keep" ? T() : void 0;
2524
2530
  return n && (m = Math.max(m, n.seq)), n && g !== n.fp && (g = n.fp, a(`[passflow] The shared token storage was emptied by the end of the session of ${n.fp}, a refresh token the ${b()?.fp ?? "(none)"} this tab holds is ahead of: keeping it. Nothing is refreshed until the storage holds a token again.`)), t;
2525
2531
  }, ee = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, k = (e) => {
@@ -2532,7 +2538,7 @@ function vr(e) {
2532
2538
  return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
2533
2539
  }, j = (e, t) => o.isForward(e, t) ? !0 : !!e && !!t && e.iat !== void 0 && e.sid !== t.sid && o.isRetired(t) && !o.isRetired(e) && !o.isEnded(e), M = (e) => {
2534
2540
  let t = b();
2535
- t && t.fp !== lr(e.refresh_token) && o.retire(t), n.setTokensCache(e);
2541
+ t && t.fp !== ur(e.refresh_token) && o.retire(t), n.setTokensCache(e);
2536
2542
  }, N = (e) => {
2537
2543
  let t = y(), n = t?.refresh_token;
2538
2544
  if (n === e.refreshToken) return null;
@@ -2543,7 +2549,7 @@ function vr(e) {
2543
2549
  kind: "superseded",
2544
2550
  adopted: !1
2545
2551
  };
2546
- let r = hr(t.access_token) ?? hr(n);
2552
+ let r = gr(t.access_token) ?? gr(n);
2547
2553
  if (e.sub && r && e.sub !== r) return {
2548
2554
  kind: "identity-changed",
2549
2555
  saved: !1
@@ -2583,22 +2589,22 @@ function vr(e) {
2583
2589
  }, ne = !!s || !!e.onStoredSessionSeen, re = ne && e.onStorageChange ? e.onStorageChange(P) : void 0, ie = ne && e.onWake ? e.onWake(P) : void 0, F = () => {
2584
2590
  let e = y();
2585
2591
  if (!e?.refresh_token) {
2586
- if (O() === "end") throw new pr("emptied");
2592
+ if (O() === "end") throw new mr("emptied");
2587
2593
  return "held";
2588
2594
  }
2589
2595
  let t = n.getTokens();
2590
2596
  if (e.refresh_token === t?.refresh_token) return "send";
2591
2597
  let r = i() ?? X(t), a = X(e);
2592
- if (r && a && r !== a) throw new mr();
2598
+ if (r && a && r !== a) throw new hr();
2593
2599
  let s = Y(e.refresh_token);
2594
2600
  if (o.isEnded(s)) {
2595
2601
  if (s && C(s)) return "held";
2596
- throw new pr("ended");
2602
+ throw new mr("ended");
2597
2603
  }
2598
2604
  let c = Y(t?.refresh_token);
2599
2605
  return j(s, c) ? (M(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && k(s) ? "held" : "send";
2600
2606
  }, ae = (e) => {
2601
- let t = i(), r = hr(e);
2607
+ let t = i(), r = gr(e);
2602
2608
  if (t && r && t !== r) return { kind: "identity-changed" };
2603
2609
  let a = Y(e) ?? { fp: e };
2604
2610
  if (o.isEnded(a)) return C(a) ? { kind: "superseded" } : { kind: "ended" };
@@ -2606,7 +2612,7 @@ function vr(e) {
2606
2612
  let s = {
2607
2613
  refreshToken: e,
2608
2614
  order: a
2609
- }, c = t ?? r ?? hr(n.getTokens()?.access_token);
2615
+ }, c = t ?? r ?? gr(n.getTokens()?.access_token);
2610
2616
  return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
2611
2617
  kind: "send",
2612
2618
  sent: s
@@ -2615,7 +2621,7 @@ function vr(e) {
2615
2621
  if (o.isEnded(e.order)) return te(e.order);
2616
2622
  let i = N(e);
2617
2623
  if (i) return i;
2618
- if (!ee(e) && A(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${lr(r.refresh_token) ?? "(no refresh token)"}, but this tab already holds ${b()?.fp ?? "(none)"}, a later successor of ${e.order.fp}. Neither saved nor adopted.`), {
2624
+ if (!ee(e) && A(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${ur(r.refresh_token) ?? "(no refresh token)"}, but this tab already holds ${b()?.fp ?? "(none)"}, a later successor of ${e.order.fp}. Neither saved nor adopted.`), {
2619
2625
  kind: "superseded",
2620
2626
  adopted: !1
2621
2627
  };
@@ -2625,7 +2631,7 @@ function vr(e) {
2625
2631
  saved: !0
2626
2632
  };
2627
2633
  let c = Y(r.refresh_token);
2628
- return c && (gr(c, e.order) || gr(c, b())) ? (a(`[passflow] Refused to save a refresh result older than the token this tab holds: ${e.order.fp} was answered with ${c.fp}. Neither saved nor adopted.`), {
2634
+ return c && (_r(c, e.order) || _r(c, b())) ? (a(`[passflow] Refused to save a refresh result older than the token this tab holds: ${e.order.fp} was answered with ${c.fp}. Neither saved nor adopted.`), {
2629
2635
  kind: "superseded",
2630
2636
  adopted: !1
2631
2637
  }) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
@@ -2637,7 +2643,7 @@ function vr(e) {
2637
2643
  kind: "superseded",
2638
2644
  adopted: !1
2639
2645
  };
2640
- let r = tr(t), i = r.kind === "blocked" || r.kind === "auth";
2646
+ let r = nr(t), i = r.kind === "blocked" || r.kind === "auth";
2641
2647
  return ee(e) && i ? (o.retire(e.order), _ = e.order, {
2642
2648
  kind: "own",
2643
2649
  failure: r,
@@ -2648,11 +2654,11 @@ function vr(e) {
2648
2654
  heldRefused: !1
2649
2655
  });
2650
2656
  }, se = (e) => {
2651
- if (!_r(e)) return !1;
2657
+ if (!vr(e)) return !1;
2652
2658
  let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
2653
- if (typeof t != "string" || typeof c != "string" || !_r(l)) return !1;
2659
+ if (typeof t != "string" || typeof c != "string" || !vr(l)) return !1;
2654
2660
  let u = l;
2655
- if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || lr(u.refresh_token) !== c) return !1;
2661
+ if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || ur(u.refresh_token) !== c) return !1;
2656
2662
  let d = y();
2657
2663
  if (!d?.refresh_token) return !1;
2658
2664
  let f = n.getTokens(), p = i() ?? X(f), m = X(u);
@@ -2669,7 +2675,7 @@ function vr(e) {
2669
2675
  }
2670
2676
  return !0;
2671
2677
  };
2672
- return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && lr(d.refresh_token) !== c ? !1 : (M({ ...u }), _());
2678
+ return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && ur(d.refresh_token) !== c ? !1 : (M({ ...u }), _());
2673
2679
  }, L = (e) => {
2674
2680
  if (!e || !_) return !1;
2675
2681
  let t = _;
@@ -2735,7 +2741,7 @@ function vr(e) {
2735
2741
  };
2736
2742
  }
2737
2743
  // lib/refresh/controller.ts
2738
- function yr() {
2744
+ function br() {
2739
2745
  let e, t, n = new Promise((n, r) => {
2740
2746
  e = n, t = r;
2741
2747
  });
@@ -2745,7 +2751,7 @@ function yr() {
2745
2751
  reject: t
2746
2752
  };
2747
2753
  }
2748
- var br = {
2754
+ var xr = {
2749
2755
  strikes: q.sessionEnded,
2750
2756
  "session-ended": q.sessionEnded,
2751
2757
  "stored-ended": q.sessionEnded,
@@ -2756,42 +2762,42 @@ var br = {
2756
2762
  "identity-changed": q.identityChanged,
2757
2763
  disposed: q.disposed
2758
2764
  };
2759
- function xr(e) {
2765
+ function Sr(e) {
2760
2766
  throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
2761
2767
  }
2762
- function Sr(e) {
2768
+ function Cr(e) {
2763
2769
  if (e === void 0 || !Number.isFinite(e)) return 3;
2764
2770
  let t = Math.floor(e);
2765
2771
  return t >= 1 ? t : 3;
2766
2772
  }
2767
- function Cr(e, t) {
2773
+ function wr(e, t) {
2768
2774
  return e instanceof Error && e.message ? e.message : t;
2769
2775
  }
2770
- function wr(e) {
2776
+ function Tr(e) {
2771
2777
  if (typeof e != "object" || !e) return;
2772
2778
  let t = e.id;
2773
2779
  return typeof t == "string" || typeof t == "number" ? t : void 0;
2774
2780
  }
2775
- function Tr(e) {
2781
+ function Er(e) {
2776
2782
  let t = {};
2777
2783
  return e?.access_token && (t.access_token = e.access_token), e?.refresh_token && (t.refresh_token = e.refresh_token), e?.id_token && (t.id_token = e.id_token), e?.scopes && (t.scopes = [...e.scopes]), t;
2778
2784
  }
2779
- function Er(e, t) {
2785
+ function Dr(e, t) {
2780
2786
  let n = {};
2781
2787
  e.access_token && (n.access_token = e.access_token), e.refresh_token && (n.refresh_token = e.refresh_token), e.id_token && (n.id_token = e.id_token);
2782
2788
  let r = t?.scopes ?? e.scopes;
2783
2789
  return r && (n.scopes = r), n;
2784
2790
  }
2785
- function Dr(e) {
2786
- let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? Yn(), c = Sr(e.strikes), l = a.transports ? ir({
2791
+ function Or(e) {
2792
+ let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? Xn(), c = Cr(e.strikes), l = a.transports ? ar({
2787
2793
  locks: a.transports.locks,
2788
2794
  channel: a.transports.channel,
2789
2795
  tabId: a.transports.tabId,
2790
2796
  names: a.names,
2791
2797
  clock: o
2792
- }) : ar(), u = { kind: "idle" }, d = 0, f = !1, p = !a.warnOnFirstCycle, m = 0, h = 0, g, _, v, y, b, x, S, C, w = !1, T = () => o.now(), E = () => i.mode(), D = () => lr(r.getTokens()?.refresh_token), O = () => ({ ...r.getTokens() ?? {} }), ee = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, k = () => (S === void 0 && (S = X(r.getTokens() ?? n.getTokens())), S), A = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Set(), M = (e) => () => {
2798
+ }) : or(), u = { kind: "idle" }, d = 0, f = !1, p = !a.warnOnFirstCycle, m = 0, h = 0, g, _, v, y, b, x, S, C, w = !1, T = () => o.now(), E = () => i.mode(), D = () => ur(r.getTokens()?.refresh_token), O = () => ({ ...r.getTokens() ?? {} }), ee = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, k = () => (S === void 0 && (S = X(r.getTokens() ?? n.getTokens())), S), A = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Set(), M = (e) => () => {
2793
2799
  for (let t of Array.from(e)) t();
2794
- }, N = a.onStorageChange?.(M(A)), te = e.platform?.onForeground(M(j)), P = vr({
2800
+ }, N = a.onStorageChange?.(M(A)), te = e.platform?.onForeground(M(j)), P = yr({
2795
2801
  storage: n,
2796
2802
  cache: r,
2797
2803
  identity: k,
@@ -2806,13 +2812,13 @@ function Dr(e) {
2806
2812
  }), ne = (e) => ({
2807
2813
  trigger: e,
2808
2814
  startedAt: T(),
2809
- plain: yr(),
2815
+ plain: br(),
2810
2816
  fresh: []
2811
2817
  }), re = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, ie = (e, t) => {
2812
2818
  if (t === void 0) return e.plain.promise;
2813
2819
  let n = {
2814
2820
  callTime: t,
2815
- deferred: yr()
2821
+ deferred: br()
2816
2822
  };
2817
2823
  return e.fresh.push(n), n.deferred.promise;
2818
2824
  }, F = (e, t, n = !1) => {
@@ -2831,11 +2837,11 @@ function Dr(e) {
2831
2837
  }
2832
2838
  }, I = (e, n, r, i) => {
2833
2839
  let a = {
2834
- message: Cr(r, "Token refresh failed"),
2840
+ message: wr(r, "Token refresh failed"),
2835
2841
  originalError: r,
2836
2842
  operation: e,
2837
2843
  source: n
2838
- }, o = wr(r);
2844
+ }, o = Tr(r);
2839
2845
  o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
2840
2846
  }, se = (e, t) => {
2841
2847
  let n = {
@@ -2865,10 +2871,10 @@ function Dr(e) {
2865
2871
  };
2866
2872
  n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
2867
2873
  }, le = (e, t) => {
2868
- let n = r.getTokens(), i = lr(n?.refresh_token);
2874
+ let n = r.getTokens(), i = ur(n?.refresh_token);
2869
2875
  e.fp && i && l.post({
2870
2876
  type: "tokens-refreshed",
2871
- tokens: Tr(n),
2877
+ tokens: Er(n),
2872
2878
  from: e.fp,
2873
2879
  ...e.iat === void 0 ? {} : { fromIat: e.iat },
2874
2880
  fromSid: e.sid ?? "",
@@ -2876,7 +2882,7 @@ function Dr(e) {
2876
2882
  ...t === void 0 ? {} : { sentAt: t }
2877
2883
  });
2878
2884
  }, ue = () => {
2879
- p || (p = !0, s.warn(Rn));
2885
+ p || (p = !0, s.warn(zn));
2880
2886
  }, de = (e) => {
2881
2887
  (e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
2882
2888
  }, R = (e, n) => {
@@ -2890,7 +2896,7 @@ function Dr(e) {
2890
2896
  }, e !== "disposed" && P.dropSession(), (e === "strikes" || e === "successor-timeout") && E() !== "json" && i.invalidate(), u = {
2891
2897
  kind: "ended",
2892
2898
  cause: e
2893
- }, oe(r, n ?? new J(br[e])), e) {
2899
+ }, oe(r, n ?? new J(xr[e])), e) {
2894
2900
  case "strikes":
2895
2901
  t("session:expired", {
2896
2902
  reason: "refresh_failed",
@@ -2925,7 +2931,7 @@ function Dr(e) {
2925
2931
  break;
2926
2932
  case "signed-out-here":
2927
2933
  case "disposed": break;
2928
- default: xr(e);
2934
+ default: Sr(e);
2929
2935
  }
2930
2936
  }, fe = () => {
2931
2937
  if (u.kind !== "ended" || u.cause === "disposed" || f || E() !== "json") return;
@@ -2942,10 +2948,10 @@ function Dr(e) {
2942
2948
  }, pe = (e) => {
2943
2949
  u.kind === "ended" || f || E() === "json" && (R(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && fe());
2944
2950
  }, me = (e) => {
2945
- e instanceof mr ? (R("identity-changed"), fe()) : e instanceof pr ? R(e.cause === "emptied" ? "emptied" : "stored-ended") : R("stored-ended", e);
2951
+ e instanceof hr ? (R("identity-changed"), fe()) : e instanceof mr ? R(e.cause === "emptied" ? "emptied" : "stored-ended") : R("stored-ended", e);
2946
2952
  }, he = () => {
2947
2953
  u = { kind: "idle" }, w || l.release();
2948
- }, ge = (e) => !e.from || E() !== "json" || e.from === D() || e.from === lr(n.getTokens()?.refresh_token), _e = (e) => {
2954
+ }, ge = (e) => !e.from || E() !== "json" || e.from === D() || e.from === ur(n.getTokens()?.refresh_token), _e = (e) => {
2949
2955
  let t = g;
2950
2956
  if (!t) return;
2951
2957
  if (!l.holding) {
@@ -3011,14 +3017,14 @@ function Dr(e) {
3011
3017
  case "ended": return P.endHeldSend(), R("stored-ended"), !1;
3012
3018
  case "identity-changed": return P.endHeldSend(), R("identity-changed"), fe(), !1;
3013
3019
  case "send": return Ce(e, t, a.sent, r);
3014
- default: return xr(a);
3020
+ default: return Sr(a);
3015
3021
  }
3016
3022
  }, Ce = (e, n, r, a) => {
3017
3023
  let o = {
3018
3024
  generation: d,
3019
3025
  sentAt: T(),
3020
3026
  trigger: n,
3021
- settled: yr()
3027
+ settled: br()
3022
3028
  };
3023
3029
  r ? o.sent = r : o.marker = ee(), a && (o.stored = a), u = {
3024
3030
  kind: "refreshing",
@@ -3055,7 +3061,7 @@ function Dr(e) {
3055
3061
  if (!we(e)) return;
3056
3062
  r.setTokensCache({
3057
3063
  ...n.getTokens() ?? {},
3058
- ...Er(t, void 0)
3064
+ ...Dr(t, void 0)
3059
3065
  }), L("refresh", "this-tab");
3060
3066
  let c = k();
3061
3067
  l.post(c === void 0 ? {
@@ -3068,7 +3074,7 @@ function Dr(e) {
3068
3074
  }), he(), F(a, e.sentAt);
3069
3075
  return;
3070
3076
  }
3071
- let o = D(), s = P.commitSave(e.sent, Er(t, e.stored));
3077
+ let o = D(), s = P.commitSave(e.sent, Dr(t, e.stored));
3072
3078
  switch (s.kind) {
3073
3079
  case "saved":
3074
3080
  L("refresh", "this-tab"), le(e.sent.order, e.sentAt), he(), F(a, e.sentAt);
@@ -3086,7 +3092,7 @@ function Dr(e) {
3086
3092
  I("refresh", e.trigger, t, se("auth")), R("identity-changed", t), fe();
3087
3093
  return;
3088
3094
  }
3089
- default: xr(s);
3095
+ default: Sr(s);
3090
3096
  }
3091
3097
  }, Ee = (e, t) => {
3092
3098
  if (e.sent?.held && P.endHeldSend(), !we(e) || u.kind !== "refreshing") return;
@@ -3106,9 +3112,9 @@ function Dr(e) {
3106
3112
  case "own":
3107
3113
  r = o.failure, i = o.heldRefused;
3108
3114
  break;
3109
- default: xr(o);
3115
+ default: Sr(o);
3110
3116
  }
3111
- } else r = tr(t, T());
3117
+ } else r = nr(t, T());
3112
3118
  if (i) I("refresh", e.trigger, t, se(r.kind)), L("adopted", "other-tab"), he(), F(n, void 0, !0);
3113
3119
  else switch (r.kind) {
3114
3120
  case "blocked":
@@ -3124,10 +3130,10 @@ function Dr(e) {
3124
3130
  case "transient":
3125
3131
  m += 1, De(e, n, t, r);
3126
3132
  return;
3127
- default: xr(r.kind);
3133
+ default: Sr(r.kind);
3128
3134
  }
3129
3135
  }, De = (e, t, n, r) => {
3130
- let i = T() + nr(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
3136
+ let i = T() + rr(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
3131
3137
  I("refresh", e.trigger, n, se(a, i)), a === "transient" && ce(T(), i, "this-tab");
3132
3138
  let s = {
3133
3139
  kind: a,
@@ -3137,7 +3143,7 @@ function Dr(e) {
3137
3143
  }, c = e.sent?.order.fp;
3138
3144
  c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
3139
3145
  type: "retry-scheduled",
3140
- message: Cr(n, "Token refresh failed"),
3146
+ message: wr(n, "Token refresh failed"),
3141
3147
  retry: s
3142
3148
  }), _e(ne("retry")), ae(t, n, e.sentAt);
3143
3149
  }, Oe = (e, t) => {
@@ -3150,8 +3156,8 @@ function Dr(e) {
3150
3156
  fp: i.fp
3151
3157
  })), r && P.deleteIfStillDead(r), R("strikes", t);
3152
3158
  }, z = (e, t, n, r) => {
3153
- l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${Cr(n, "blocked")}`);
3154
- let i = d, a = T() + Cn, c = {
3159
+ l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${wr(n, "blocked")}`);
3160
+ let i = d, a = T() + wn, c = {
3155
3161
  kind: "blocked-wait",
3156
3162
  pending: e,
3157
3163
  deadline: a,
@@ -3164,9 +3170,9 @@ function Dr(e) {
3164
3170
  i === d && u === c && (B() || (f ? (e.cookieRetried = !0, u = {
3165
3171
  kind: "waiting",
3166
3172
  pending: e
3167
- }, l.request()) : T() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), R("successor-timeout")) : c.cancel = o.setTimeout(p, wn)));
3173
+ }, l.request()) : T() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), R("successor-timeout")) : c.cancel = o.setTimeout(p, Tn)));
3168
3174
  };
3169
- c.cancel = o.setTimeout(p, f ? En : wn);
3175
+ c.cancel = o.setTimeout(p, f ? Dn : Tn);
3170
3176
  }, B = () => {
3171
3177
  if (u.kind !== "blocked-wait") return !1;
3172
3178
  let e = u;
@@ -3210,7 +3216,7 @@ function Dr(e) {
3210
3216
  case "idle":
3211
3217
  case "refreshing":
3212
3218
  case "ended": return;
3213
- default: xr(u);
3219
+ default: Sr(u);
3214
3220
  }
3215
3221
  }, V = (e) => {
3216
3222
  let t = {};
@@ -3253,7 +3259,7 @@ function Dr(e) {
3253
3259
  je(e.retry, !0, e.message), Pe();
3254
3260
  return;
3255
3261
  case "refresh-failed":
3256
- if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !== lr(n.getTokens()?.refresh_token)) return;
3262
+ if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !== ur(n.getTokens()?.refresh_token)) return;
3257
3263
  if (ce(T(), void 0, "other-tab"), u.kind === "waiting") {
3258
3264
  let t = u.pending;
3259
3265
  u.pending = ne(t.trigger), ae(t, new J(q.unavailable, { cause: e.message }), void 0);
@@ -3274,7 +3280,7 @@ function Dr(e) {
3274
3280
  return;
3275
3281
  case "takeover":
3276
3282
  case "rate-limited": return;
3277
- default: xr(e);
3283
+ default: Sr(e);
3278
3284
  }
3279
3285
  }, Pe = () => {
3280
3286
  C && !l.holding && l.post({
@@ -3339,7 +3345,7 @@ function Dr(e) {
3339
3345
  case "refreshing":
3340
3346
  case "backoff":
3341
3347
  case "blocked-wait": return ie(u.pending, t);
3342
- default: return xr(u);
3348
+ default: return Sr(u);
3343
3349
  }
3344
3350
  }, Le = (e) => {
3345
3351
  if (f) return Promise.reject(new J(q.disposed));
@@ -3390,9 +3396,9 @@ function Dr(e) {
3390
3396
  }, He = async (e, t) => {
3391
3397
  if (f) throw new J(q.disposed);
3392
3398
  ue();
3393
- let n = T() + Dn;
3399
+ let n = T() + On;
3394
3400
  if (await Be(n - T()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await ze("commit", n - T())) === "timeout") {
3395
- let e = new cr("lock-timeout");
3401
+ let e = new lr("lock-timeout");
3396
3402
  throw I("upgrade.commit", "upgrade", e), e;
3397
3403
  }
3398
3404
  w = !0;
@@ -3439,7 +3445,7 @@ function Dr(e) {
3439
3445
  if (!o) {
3440
3446
  await i.applyOpaque(u), r.setTokensCache({
3441
3447
  ...n.getTokens() ?? {},
3442
- ...Er(u, void 0)
3448
+ ...Dr(u, void 0)
3443
3449
  }), We(c);
3444
3450
  let e = k();
3445
3451
  return l.post(e === void 0 ? {
@@ -3451,9 +3457,9 @@ function Dr(e) {
3451
3457
  sub: e
3452
3458
  }), O();
3453
3459
  }
3454
- let d = P.commitSave(o, Er(u, s));
3460
+ let d = P.commitSave(o, Dr(u, s));
3455
3461
  if (d.kind === "saved") return We(c), le(o.order, c), O();
3456
- let f = new cr("superseded");
3462
+ let f = new lr("superseded");
3457
3463
  throw I("upgrade.commit", "upgrade", f), d.kind === "superseded" && d.adopted && L("adopted", "other-tab"), f;
3458
3464
  }, We = (e) => {
3459
3465
  if (L("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
@@ -3479,7 +3485,7 @@ function Dr(e) {
3479
3485
  commitUpgrade: He,
3480
3486
  signOut: async (e) => {
3481
3487
  if (f) return e(n.getTokens()?.refresh_token);
3482
- let t = T() + On;
3488
+ let t = T() + kn;
3483
3489
  Ke(), await Be(t - T()), Ke(), l.coordinated && !l.holding && await ze("logout", t - T());
3484
3490
  try {
3485
3491
  Ge(), await e(n.getTokens()?.refresh_token);
@@ -3524,7 +3530,7 @@ function Dr(e) {
3524
3530
  // lib/store.ts
3525
3531
  var Z = /* @__PURE__ */ function(e) {
3526
3532
  return e.SignIn = "signin", e.SignInStart = "signin:start", e.Register = "register", e.RegisterStart = "register:start", e.EmailVerificationRequired = "email-verification:required", e.SignOut = "signout", e.SessionRestored = "session:restored", e.SessionExpired = "session:expired", e.Error = "error", e.Refresh = "refresh", e.RefreshStart = "refresh:start", e.TokenCacheExpired = "token-cache-expired", e.TwoFactorRequired = "2fa:required", e.TwoFactorSetupStarted = "2fa:setup_started", e.TwoFactorEnabled = "2fa:enabled", e.TwoFactorDisabled = "2fa:disabled", e.TwoFactorVerified = "2fa:verified", e.TwoFactorRecoveryUsed = "2fa:recovery_used", e.TwoFactorRecoveryCodesLow = "2fa:recovery_low", e.TwoFactorRecoveryCodesExhausted = "2fa:recovery_exhausted", e.TwoFactorSetupMagicLinkValidated = "2fa:magic_link_validated", e.TwoFactorSetupMagicLinkFailed = "2fa:magic_link_failed", e.TwoFactorChallengeReceived = "two_factor_challenge_received", e.TwoFactorMethodSwitched = "two_factor_method_switched", e.TwoFactorDeviceTrusted = "two_factor_device_trusted", e.RefreshFailing = "refresh:failing", e.RefreshRecovered = "refresh:recovered", e;
3527
- }({}), Or = class {
3533
+ }({}), kr = class {
3528
3534
  constructor() {
3529
3535
  this.subscribers = /* @__PURE__ */ new Map();
3530
3536
  }
@@ -3543,14 +3549,14 @@ var Z = /* @__PURE__ */ function(e) {
3543
3549
  n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
3544
3550
  }
3545
3551
  notify(e, t) {
3546
- e === "error" && hn(this, t?.originalError), this.subscribers.forEach((n, r) => {
3552
+ e === "error" && gn(this, t?.originalError), this.subscribers.forEach((n, r) => {
3547
3553
  (!n || n.has(e)) && r.onAuthChange?.(e, t);
3548
3554
  });
3549
3555
  }
3550
3556
  notifyError(e) {
3551
3557
  return W(this, e);
3552
3558
  }
3553
- }, kr = {
3559
+ }, Ar = {
3554
3560
  ES256: {
3555
3561
  kty: "EC",
3556
3562
  key: (e) => ({
@@ -3581,34 +3587,34 @@ var Z = /* @__PURE__ */ function(e) {
3581
3587
  },
3582
3588
  signature: { name: "RSASSA-PKCS1-v1_5" }
3583
3589
  }
3584
- }, Ar = (e) => {
3590
+ }, jr = (e) => {
3585
3591
  let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = globalThis.atob(t + "=".repeat((4 - t.length % 4) % 4));
3586
3592
  return Uint8Array.from(n, (e) => e.charCodeAt(0));
3587
- }, jr = () => {
3593
+ }, Mr = () => {
3588
3594
  let e = globalThis.crypto;
3589
3595
  if (!e?.subtle) throw Error("Verifying tokens needs the Web Crypto API, available only in a secure context (https or localhost)");
3590
3596
  return e;
3591
3597
  };
3592
- async function Mr(e, t, n, r, i) {
3593
- let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(Ar(a))), l = c.alg === "ES256" || c.alg === "RS256" ? kr[c.alg] : void 0;
3598
+ async function Nr(e, t, n, r, i) {
3599
+ let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(jr(a))), l = c.alg === "ES256" || c.alg === "RS256" ? Ar[c.alg] : void 0;
3594
3600
  if (!l) throw Error(`Token signing algorithm ${String(c.alg)} is not accepted`);
3595
3601
  let u = t.find((e) => e.kid === c.kid && e.kty === l.kty && (e.kty !== "EC" || e.crv === "P-256"));
3596
3602
  if (!u) throw Error("Token signing key is not published by the server");
3597
- let d = jr().subtle, f = await d.importKey("jwk", l.key(u), l.imported, !1, ["verify"]), p = new TextEncoder().encode(`${a}.${o}`);
3598
- if (!await d.verify(l.signature, f, Ar(s), p)) throw Error("Token signature is not valid");
3603
+ let d = Mr().subtle, f = await d.importKey("jwk", l.key(u), l.imported, !1, ["verify"]), p = new TextEncoder().encode(`${a}.${o}`);
3604
+ if (!await d.verify(l.signature, f, jr(s), p)) throw Error("Token signature is not valid");
3599
3605
  let m = j(e), h = Array.isArray(m.aud) ? m.aud : [m.aud];
3600
3606
  if (m.iss !== n) throw Error("Token issuer does not match the server");
3601
3607
  if (!h.includes(r)) throw Error("Token is not issued for this app");
3602
3608
  if (typeof m.exp != "number" || A(m, 0)) throw Error("Token has expired");
3603
3609
  if (i && m.type !== i) throw Error("Token type is not valid");
3604
3610
  }
3605
- async function Nr(t, n, r) {
3611
+ async function Pr(t, n, r) {
3606
3612
  if (!n) throw Error("An app id is required to accept tokens from the URL");
3607
3613
  if (!r.access_token) throw Error("No access token received");
3608
- jr();
3614
+ Mr();
3609
3615
  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 ?? [];
3610
3616
  if (!s) throw Error("The server did not publish an issuer");
3611
- await Mr(r.access_token, c, s, n, M.access_token), r.refresh_token && await Mr(r.refresh_token, c, s, n, M.refresh_token), r.id_token && await Mr(r.id_token, c, s, n);
3617
+ await Nr(r.access_token, c, s, n, M.access_token), r.refresh_token && await Nr(r.refresh_token, c, s, n, M.refresh_token), r.id_token && await Nr(r.id_token, c, s, n);
3612
3618
  }
3613
3619
  // lib/upgrade/errors.ts
3614
3620
  var Q = {
@@ -3625,18 +3631,18 @@ var Q = {
3625
3631
  twoFactorNotEnabled: "error.2fa.not_enabled",
3626
3632
  notImplemented: "error.not.implemented",
3627
3633
  tokenInvalid: "error.api.request.token.invalid"
3628
- }, Pr = Object.freeze([
3634
+ }, Fr = Object.freeze([
3629
3635
  Q.twoFactorCodeInvalid,
3630
3636
  Q.twoFactorNotEnabled,
3631
3637
  Q.challengeInvalid,
3632
3638
  Q.challengeSessionMismatch,
3633
3639
  Q.challengeTooManyAttempts
3634
- ]), Fr = Object.freeze([Q.tokenInvalid]), Ir = Object.freeze([
3640
+ ]), Ir = Object.freeze([Q.tokenInvalid]), Lr = Object.freeze([
3635
3641
  "wrong_code",
3636
3642
  "challenge_spent",
3637
3643
  "not_registered",
3638
3644
  "prepare_not_required"
3639
- ]), Lr = (e) => Ir.includes(e), Rr = {
3645
+ ]), Rr = (e) => Lr.includes(e), zr = {
3640
3646
  wrong_code: "That code was not accepted. Try again.",
3641
3647
  challenge_spent: "That verification challenge is no longer valid. Start again.",
3642
3648
  exhausted: "Too many attempts. Try again later.",
@@ -3650,16 +3656,16 @@ var Q = {
3650
3656
  session_changed: "The session ended during verification."
3651
3657
  }, $ = class extends Error {
3652
3658
  constructor(e) {
3653
- super(e.message || Rr[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, this.retryable = Lr(e.kind), e.cause !== void 0 && (this.cause = e.cause);
3659
+ super(e.message || zr[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, this.retryable = Rr(e.kind), e.cause !== void 0 && (this.cause = e.cause);
3654
3660
  }
3655
- }, zr = Object.freeze([
3661
+ }, Br = Object.freeze([
3656
3662
  "upgrade_transport",
3657
3663
  "upgrade_insufficient",
3658
3664
  "upgrade_unavailable",
3659
3665
  "upgrade_session_changed",
3660
3666
  "upgrade_cancelled",
3661
3667
  "upgrade_unsatisfiable"
3662
- ]), Br = (e) => typeof e == "object" && !!e && typeof e.code == "string" && zr.includes(e.code), Vr = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", Hr = (e) => {
3668
+ ]), Vr = (e) => typeof e == "object" && !!e && typeof e.code == "string" && Br.includes(e.code), Hr = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", Ur = (e) => {
3663
3669
  if (typeof e != "object" || !e) return {
3664
3670
  hasResponse: !1,
3665
3671
  message: typeof e == "string" ? e : void 0
@@ -3671,7 +3677,7 @@ var Q = {
3671
3677
  message: typeof t.message == "string" ? t.message : void 0,
3672
3678
  hasResponse: n !== void 0 || typeof t.status == "number"
3673
3679
  };
3674
- }, Ur = (e, t) => {
3680
+ }, Wr = (e, t) => {
3675
3681
  switch (e) {
3676
3682
  case Q.twoFactorCodeInvalid: return "wrong_code";
3677
3683
  case Q.challengeInvalid:
@@ -3689,11 +3695,11 @@ var Q = {
3689
3695
  case "error.service.unavailable": return "network";
3690
3696
  default: return;
3691
3697
  }
3692
- }, Wr = (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) => {
3698
+ }, Gr = (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", Kr = (e, t) => {
3693
3699
  if (e instanceof $) return e;
3694
- let n = Hr(e);
3700
+ let n = Ur(e);
3695
3701
  return n.hasResponse ? new $({
3696
- kind: Ur(n.errorId, t) ?? Wr(n.status, t),
3702
+ kind: Wr(n.errorId, t) ?? Gr(n.status, t),
3697
3703
  message: n.message,
3698
3704
  status: n.status,
3699
3705
  errorId: n.errorId,
@@ -3703,60 +3709,60 @@ var Q = {
3703
3709
  message: n.message,
3704
3710
  cause: e
3705
3711
  });
3706
- }, Kr = (e) => e.errorId !== void 0 && Pr.includes(e.errorId), qr = (e) => e.errorId !== void 0 && Fr.includes(e.errorId), Jr = class extends Error {
3712
+ }, qr = (e) => e.errorId !== void 0 && Fr.includes(e.errorId), Jr = (e) => e.errorId !== void 0 && Ir.includes(e.errorId), Yr = class extends Error {
3707
3713
  constructor(e, t, n) {
3708
3714
  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;
3709
3715
  }
3710
- }, Yr = class extends Error {
3716
+ }, Xr = class extends Error {
3711
3717
  constructor(e = "Step-up verification is not available on this deployment") {
3712
3718
  super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
3713
3719
  }
3714
- }, Xr = class extends Error {
3720
+ }, Zr = class extends Error {
3715
3721
  constructor(e = "The session changed during verification") {
3716
3722
  super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
3717
3723
  }
3718
- }, Zr = (e) => {
3724
+ }, Qr = (e) => {
3719
3725
  if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
3720
3726
  sub: e.sub,
3721
3727
  sid: e.sid
3722
3728
  } : { sub: e.sub };
3723
- }, Qr = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
3729
+ }, $r = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
3724
3730
  // lib/utils/validation.ts
3725
- function $r(e) {
3731
+ function ei(e) {
3726
3732
  if (!e || typeof e != "string") return !1;
3727
3733
  let t = e.split(".");
3728
3734
  if (t.length !== 3) return !1;
3729
3735
  let n = /^[A-Za-z0-9_-]+$/;
3730
3736
  return t.every((e) => n.test(e) && e.length > 0);
3731
3737
  }
3732
- function ei(e) {
3738
+ function ti(e) {
3733
3739
  return e.replace(/<[^>]*>/g, "").substring(0, 200);
3734
3740
  }
3735
- function ti(e) {
3741
+ function ni(e) {
3736
3742
  if (!e || typeof e != "string") return !1;
3737
3743
  let t = e.trim();
3738
3744
  return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
3739
3745
  }
3740
- function ni(e) {
3746
+ function ri(e) {
3741
3747
  if (!e || typeof e != "string") return !1;
3742
3748
  let t = e.trim();
3743
3749
  return /^\+[1-9]\d{1,14}$/.test(t);
3744
3750
  }
3745
- function ri(e) {
3751
+ function ii(e) {
3746
3752
  if (!e || typeof e != "string") return !1;
3747
3753
  let t = e.trim();
3748
3754
  return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
3749
3755
  }
3750
- function ii(e, t = 6) {
3756
+ function ai(e, t = 6) {
3751
3757
  return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
3752
3758
  }
3753
- function ai(e) {
3759
+ function oi(e) {
3754
3760
  if (!e || typeof e != "string") return null;
3755
3761
  let t = e.toUpperCase().replace(/\s+/g, "");
3756
3762
  return /^[A-Z0-9-]{4,16}$/.test(t) ? t : null;
3757
3763
  }
3758
3764
  // lib/services/auth-service.ts
3759
- var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3, ui = "passflow_federated_pkce", di = 6e5, fi = "AppId is required for federated auth", pi = 10, mi = "The sign-in answered with a PKCE code, but its verifier is gone", hi = (e, t) => new Promise((n, r) => {
3765
+ var si = "passflow_2fa_pkce", ci = 3e5, li = "passflow_pwless_pending", ui = 3e3, di = "passflow_federated_pkce", fi = 6e5, pi = "AppId is required for federated auth", mi = 10, hi = "The sign-in answered with a PKCE code, but its verifier is gone", gi = (e, t) => new Promise((n, r) => {
3760
3766
  if (t?.aborted) {
3761
3767
  r(t.reason);
3762
3768
  return;
@@ -3767,21 +3773,21 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
3767
3773
  t?.removeEventListener("abort", i), n();
3768
3774
  }, e);
3769
3775
  t?.addEventListener("abort", i, { once: !0 });
3770
- }), gi = (e) => {
3776
+ }), _i = (e) => {
3771
3777
  if (!e) return;
3772
3778
  let t = new URLSearchParams(e.search).get("token");
3773
3779
  if (t) return t;
3774
3780
  let n = e.hash.indexOf("?");
3775
3781
  return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
3776
- }, _i = (e) => {
3782
+ }, vi = (e) => {
3777
3783
  if (e) try {
3778
3784
  return j(e).email;
3779
3785
  } catch {
3780
3786
  return;
3781
3787
  }
3782
- }, vi = class {
3783
- constructor(e, t, n, r, i, a, o, s, c, l, u, d = ae, f, p = { coordination: Kn() }, m) {
3784
- this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.readAppSettings = m, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new P(n), u?.enabled && this.tokenDeliveryManager.setMode(N.BFF), this.refresh = Dr({
3788
+ }, yi = class {
3789
+ constructor(e, t, n, r, i, a, o, s, c, l, u, d = ae, f, p = { coordination: qn() }, m) {
3790
+ this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.readAppSettings = m, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new P(n), u?.enabled && this.tokenDeliveryManager.setMode(N.BFF), this.refresh = Or({
3785
3791
  emit: this.createRefreshEmit(),
3786
3792
  storage: n,
3787
3793
  cache: i,
@@ -3789,7 +3795,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
3789
3795
  coordination: p.coordination,
3790
3796
  platform: d,
3791
3797
  ...p.strikes === void 0 ? {} : { strikes: p.strikes },
3792
- logger: Yn()
3798
+ logger: Xn()
3793
3799
  }), this.initializeSession();
3794
3800
  }
3795
3801
  setAppId(e) {
@@ -3854,7 +3860,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
3854
3860
  rememberEmailChallenge(e, t) {
3855
3861
  this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
3856
3862
  for (let e of this.emailChallenges.keys()) {
3857
- if (this.emailChallenges.size <= pi) break;
3863
+ if (this.emailChallenges.size <= mi) break;
3858
3864
  this.emailChallenges.delete(e);
3859
3865
  }
3860
3866
  }
@@ -3862,14 +3868,14 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
3862
3868
  if (this.pendingPkce = {
3863
3869
  verifier: e,
3864
3870
  scopes: t,
3865
- expiresAt: Date.now() + si
3871
+ expiresAt: Date.now() + ci
3866
3872
  }, typeof sessionStorage < "u") try {
3867
- sessionStorage.setItem(oi, JSON.stringify(this.pendingPkce));
3873
+ sessionStorage.setItem(si, JSON.stringify(this.pendingPkce));
3868
3874
  } catch {}
3869
3875
  }
3870
3876
  readPendingPkce() {
3871
3877
  if (!this.pendingPkce && typeof sessionStorage < "u") try {
3872
- let e = sessionStorage.getItem(oi);
3878
+ let e = sessionStorage.getItem(si);
3873
3879
  this.pendingPkce = e ? JSON.parse(e) : void 0;
3874
3880
  } catch {
3875
3881
  this.pendingPkce = void 0;
@@ -3881,17 +3887,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
3881
3887
  }
3882
3888
  forgetPkceSignIn() {
3883
3889
  if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
3884
- sessionStorage.removeItem(oi);
3890
+ sessionStorage.removeItem(si);
3885
3891
  } catch {}
3886
3892
  }
3887
3893
  rememberPendingPasswordless(e) {
3888
3894
  if (this.pendingPasswordless = e, typeof sessionStorage < "u") try {
3889
- sessionStorage.setItem(ci, JSON.stringify(e));
3895
+ sessionStorage.setItem(li, JSON.stringify(e));
3890
3896
  } catch {}
3891
3897
  }
3892
3898
  readPendingPasswordless() {
3893
3899
  if (!this.pendingPasswordless && typeof sessionStorage < "u") try {
3894
- let e = sessionStorage.getItem(ci);
3900
+ let e = sessionStorage.getItem(li);
3895
3901
  this.pendingPasswordless = e ? JSON.parse(e) : void 0;
3896
3902
  } catch {
3897
3903
  this.pendingPasswordless = void 0;
@@ -3900,21 +3906,21 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
3900
3906
  }
3901
3907
  forgetPendingPasswordless() {
3902
3908
  if (this.pendingPasswordless = void 0, typeof sessionStorage < "u") try {
3903
- sessionStorage.removeItem(ci);
3909
+ sessionStorage.removeItem(li);
3904
3910
  } catch {}
3905
3911
  }
3906
3912
  rememberFederatedSlot(e, t) {
3907
3913
  if (this.federatedSlot = {
3908
3914
  verifier: e,
3909
3915
  scopes: t,
3910
- expiresAt: Date.now() + di
3916
+ expiresAt: Date.now() + fi
3911
3917
  }, typeof sessionStorage < "u") try {
3912
- sessionStorage.setItem(ui, JSON.stringify(this.federatedSlot));
3918
+ sessionStorage.setItem(di, JSON.stringify(this.federatedSlot));
3913
3919
  } catch {}
3914
3920
  }
3915
3921
  readFederatedSlot() {
3916
3922
  if (!this.federatedSlot && typeof sessionStorage < "u") try {
3917
- let e = sessionStorage.getItem(ui);
3923
+ let e = sessionStorage.getItem(di);
3918
3924
  this.federatedSlot = e ? JSON.parse(e) : void 0;
3919
3925
  } catch {
3920
3926
  this.federatedSlot = void 0;
@@ -3923,7 +3929,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
3923
3929
  }
3924
3930
  forgetFederatedSlot() {
3925
3931
  if (this.federatedSlot = void 0, typeof sessionStorage < "u") try {
3926
- sessionStorage.removeItem(ui);
3932
+ sessionStorage.removeItem(di);
3927
3933
  } catch {}
3928
3934
  }
3929
3935
  async startPkce() {
@@ -3931,17 +3937,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
3931
3937
  try {
3932
3938
  e = await this.readPkceEnabled?.() ?? !1;
3933
3939
  } catch (e) {
3934
- Yn().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
3940
+ Xn().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
3935
3941
  return;
3936
3942
  }
3937
- return e ? Xt() : void 0;
3943
+ return e ? Zt() : void 0;
3938
3944
  }
3939
3945
  async exchangeCode(e, t) {
3940
3946
  return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
3941
3947
  }
3942
3948
  async completePkceSignIn(e) {
3943
3949
  let t = this.readPendingPkce();
3944
- if (!t) throw Error(mi);
3950
+ if (!t) throw Error(hi);
3945
3951
  let n = await this.authApi.pkceExchange(e, t.verifier);
3946
3952
  return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
3947
3953
  }
@@ -3965,7 +3971,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
3965
3971
  if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
3966
3972
  }
3967
3973
  async signIn(e) {
3968
- if ("email" in e && e.email && !ti(e.email)) {
3974
+ if ("email" in e && e.email && !ni(e.email)) {
3969
3975
  let e = /* @__PURE__ */ Error("Invalid email format"), t = {
3970
3976
  operation: "sign-in",
3971
3977
  message: "Invalid email format",
@@ -3974,7 +3980,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
3974
3980
  };
3975
3981
  throw W(this.subscribeStore, t), e;
3976
3982
  }
3977
- if ("username" in e && e.username && !ri(e.username)) {
3983
+ if ("username" in e && e.username && !ii(e.username)) {
3978
3984
  let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
3979
3985
  operation: "sign-in",
3980
3986
  message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
@@ -3983,7 +3989,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
3983
3989
  };
3984
3990
  throw W(this.subscribeStore, t), e;
3985
3991
  }
3986
- if ("phone" in e && e.phone && !ni(e.phone)) {
3992
+ if ("phone" in e && e.phone && !ri(e.phone)) {
3987
3993
  let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
3988
3994
  operation: "sign-in",
3989
3995
  message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
@@ -4017,7 +4023,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4017
4023
  }
4018
4024
  }
4019
4025
  async signUp(e) {
4020
- if (e.user.email && !ti(e.user.email)) {
4026
+ if (e.user.email && !ni(e.user.email)) {
4021
4027
  let e = /* @__PURE__ */ Error("Invalid email format"), t = {
4022
4028
  operation: "sign-up",
4023
4029
  message: "Invalid email format",
@@ -4026,7 +4032,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4026
4032
  };
4027
4033
  throw W(this.subscribeStore, t), e;
4028
4034
  }
4029
- if (e.user.phone_number && !ni(e.user.phone_number)) {
4035
+ if (e.user.phone_number && !ri(e.user.phone_number)) {
4030
4036
  let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
4031
4037
  operation: "sign-up",
4032
4038
  message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
@@ -4058,7 +4064,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4058
4064
  }
4059
4065
  }
4060
4066
  async passwordlessSignIn(e) {
4061
- if (e.email && !ti(e.email)) {
4067
+ if (e.email && !ni(e.email)) {
4062
4068
  let e = /* @__PURE__ */ Error("Invalid email format"), t = {
4063
4069
  operation: "passwordless.start",
4064
4070
  message: "Invalid email format",
@@ -4067,7 +4073,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4067
4073
  };
4068
4074
  throw W(this.subscribeStore, t), e;
4069
4075
  }
4070
- if (e.phone && !ni(e.phone)) {
4076
+ if (e.phone && !ri(e.phone)) {
4071
4077
  let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
4072
4078
  operation: "passwordless.start",
4073
4079
  message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
@@ -4111,7 +4117,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4111
4117
  if (r = !0, this.handlePendingSecondFactor(t, n?.email, n && { verifier: n.verifier }, n?.scopes)) return this.forgetPendingPasswordless(), t;
4112
4118
  let i = t;
4113
4119
  if (t.code) {
4114
- if (!n) throw Error(mi);
4120
+ if (!n) throw Error(hi);
4115
4121
  if (i = await this.authApi.pkceExchange(t.code, n.verifier), this.handlePendingSecondFactor(i)) return this.forgetPendingPasswordless(), {
4116
4122
  ...i,
4117
4123
  redirect_url: t.redirect_url ?? ""
@@ -4143,11 +4149,11 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4143
4149
  let n = t?.signal;
4144
4150
  try {
4145
4151
  let t = this.readPendingPasswordless();
4146
- if (t?.challengeId !== e) throw Error(mi);
4152
+ if (t?.challengeId !== e) throw Error(hi);
4147
4153
  for (;;) {
4148
4154
  if (n?.aborted) throw n.reason;
4149
4155
  if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
4150
- if (this.readPendingPasswordless()?.challengeId !== e) throw Error(mi);
4156
+ if (this.readPendingPasswordless()?.challengeId !== e) throw Error(hi);
4151
4157
  let r;
4152
4158
  try {
4153
4159
  r = await this.authApi.passwordlessStatus({
@@ -4165,7 +4171,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4165
4171
  status: "signed-in",
4166
4172
  tokens: { redirect_url: r.redirect_url }
4167
4173
  };
4168
- await hi(li, n);
4174
+ await gi(ui, n);
4169
4175
  }
4170
4176
  } catch (e) {
4171
4177
  if (n?.aborted && e === n.reason) throw e;
@@ -4234,14 +4240,14 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4234
4240
  let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
4235
4241
  try {
4236
4242
  let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
4237
- if (t?.pkce && !r) throw Error(mi);
4243
+ if (t?.pkce && !r) throw Error(hi);
4238
4244
  let i = await this.authApi.validateEmailCode(e);
4239
4245
  this.emailChallenges.delete(e.challenge_id);
4240
4246
  let a = r?.scopes ?? t?.scopes ?? this.scopes;
4241
4247
  if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
4242
4248
  let o = i;
4243
4249
  if (i.code) {
4244
- if (!r) throw Error(mi);
4250
+ if (!r) throw Error(hi);
4245
4251
  if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
4246
4252
  }
4247
4253
  let s = i.redirect_url ? {
@@ -4295,13 +4301,13 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4295
4301
  readSessionPin() {
4296
4302
  try {
4297
4303
  let e = this.storageManager.getToken(M.access_token);
4298
- return e ? Zr(j(e)) : void 0;
4304
+ return e ? Qr(j(e)) : void 0;
4299
4305
  } catch {
4300
4306
  return;
4301
4307
  }
4302
4308
  }
4303
4309
  assertSessionPin(e) {
4304
- if (e && !Qr(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");
4310
+ if (e && !$r(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 Zr("The session changed during verification, so the elevated tokens were discarded");
4305
4311
  }
4306
4312
  refreshMode() {
4307
4313
  return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
@@ -4349,7 +4355,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4349
4355
  case "signout":
4350
4356
  n.notify(Z.SignOut, t);
4351
4357
  return;
4352
- default: Yn().warn(`[passflow] Unknown refresh event: ${String(e)}`);
4358
+ default: Xn().warn(`[passflow] Unknown refresh event: ${String(e)}`);
4353
4359
  }
4354
4360
  };
4355
4361
  }
@@ -4435,10 +4441,10 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4435
4441
  }
4436
4442
  async resetPassword(e, t, n) {
4437
4443
  this.subscribeStore.notify(Z.SignInStart, {});
4438
- let r = n ?? gi(this.platform.getCurrentUrl()), i = t ?? this.scopes;
4444
+ let r = n ?? _i(this.platform.getCurrentUrl()), i = t ?? this.scopes;
4439
4445
  try {
4440
4446
  let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
4441
- if (this.handleEmailVerificationStep(n, "reset-password", _i(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
4447
+ if (this.handleEmailVerificationStep(n, "reset-password", vi(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
4442
4448
  let a = await this.exchangeCode(n, t);
4443
4449
  if (this.handlePendingSecondFactor(a)) return a;
4444
4450
  let o = n.redirect_url ? {
@@ -4519,7 +4525,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4519
4525
  }
4520
4526
  createFederatedAuthUrl(e) {
4521
4527
  let t = `/auth/federated/start/${e.provider}`;
4522
- if (!this.appId) throw Error(fi);
4528
+ if (!this.appId) throw Error(pi);
4523
4529
  let n = {
4524
4530
  scopes: (e.scopes ?? this.scopes).join(" "),
4525
4531
  redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
@@ -4535,7 +4541,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4535
4541
  return r.search = new URLSearchParams(n).toString(), r.toString();
4536
4542
  }
4537
4543
  async federatedAuthWithPopup(e) {
4538
- if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(fi);
4544
+ if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(pi);
4539
4545
  let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
4540
4546
  try {
4541
4547
  this.forgetFederatedSlot();
@@ -4563,11 +4569,11 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4563
4569
  scopes: t
4564
4570
  };
4565
4571
  if (r) {
4566
- if (!l) throw tn();
4572
+ if (!l) throw nn();
4567
4573
  if (m = await this.authApi.pkceExchange(l, r.verifier), this.handlePendingSecondFactor(m)) return;
4568
4574
  } else {
4569
- if (!await this.isSimpleModeApp()) throw tn();
4570
- await Nr(this.url, this.appId, m);
4575
+ if (!await this.isSimpleModeApp()) throw nn();
4576
+ await Pr(this.url, this.appId, m);
4571
4577
  }
4572
4578
  await this.processAuthResponse(m, t), this.subscribeStore.notify(Z.SignIn, {
4573
4579
  tokens: m,
@@ -4593,7 +4599,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4593
4599
  }
4594
4600
  }
4595
4601
  federatedAuthWithRedirect(e) {
4596
- if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(fi);
4602
+ if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(pi);
4597
4603
  let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
4598
4604
  this.startPkce().then((r) => {
4599
4605
  let i = this.createFederatedAuthUrl({
@@ -4657,7 +4663,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4657
4663
  async authRedirect(e = {}) {
4658
4664
  try {
4659
4665
  let { url: t, appId: n, redirectUrl: r, scopes: i, state: a } = e;
4660
- if (t !== void 0 && an(t) !== an(this.url) || n !== void 0 && n !== (this.appId ?? "")) throw new U("OVERRIDE_NOT_SUPPORTED", "authRedirect() signs in to this instance's url and appId; create a Passflow instance for another server or app");
4666
+ if (t !== void 0 && on(t) !== on(this.url) || n !== void 0 && n !== (this.appId ?? "")) throw new U("OVERRIDE_NOT_SUPPORTED", "authRedirect() signs in to this instance's url and appId; create a Passflow instance for another server or app");
4661
4667
  let o = await this.readAppSettings?.();
4662
4668
  if (o?.pkce_enabled !== !0) {
4663
4669
  let e = this.authRedirectUrl({
@@ -4667,8 +4673,8 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4667
4673
  this.platform.navigateTo(a ? `${e}&${new URLSearchParams({ state: a })}` : e);
4668
4674
  return;
4669
4675
  }
4670
- if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT", $t(o.type));
4671
- let s = this.platform.getCurrentUrl(), c = await sn({
4676
+ if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT", en(o.type));
4677
+ let s = this.platform.getCurrentUrl(), c = await cn({
4672
4678
  url: this.url,
4673
4679
  clientId: this.appId ?? "",
4674
4680
  redirectUri: r ?? (s ? s.origin + s.pathname : ""),
@@ -4689,9 +4695,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4689
4695
  if (!this.appId) return !1;
4690
4696
  let t = new URLSearchParams(e.search), n = t.get("code"), r = t.get("state"), i = t.get("error"), a = t.get("error_description");
4691
4697
  if (t.get("user_state") || r === null || !n && !i) return !1;
4692
- let o = ln();
4698
+ let o = un();
4693
4699
  if (o.status === "none") return !1;
4694
- un();
4700
+ dn();
4695
4701
  for (let e of [
4696
4702
  "code",
4697
4703
  "state",
@@ -4703,9 +4709,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4703
4709
  return this.platform.replaceUrl(e.pathname + (s ? `?${s}` : "") + e.hash), this.finishOidcLanding(async () => {
4704
4710
  if (o.status === "unusable") throw new U("VERIFIER_MISSING", "This sign-in has expired or its proof key is gone. Sign in again.");
4705
4711
  if (o.slot.state !== r) throw new U("STATE_MISMATCH", "The sign-in answer does not belong to this sign-in. Sign in again.");
4706
- if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED", ei(a || i || "Sign in again."));
4712
+ if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED", ti(a || i || "Sign in again."));
4707
4713
  return {
4708
- tokens: await fn(this.url, n, o.slot),
4714
+ tokens: await pn(this.url, n, o.slot),
4709
4715
  scopes: o.slot.scopes
4710
4716
  };
4711
4717
  }), !0;
@@ -4785,7 +4791,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4785
4791
  return;
4786
4792
  }
4787
4793
  }
4788
- }, yi = class {
4794
+ }, bi = class {
4789
4795
  constructor(e) {
4790
4796
  this.invitationApi = e;
4791
4797
  }
@@ -4804,7 +4810,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4804
4810
  getInvitationLink(e) {
4805
4811
  return this.invitationApi.getInvitationLink(e);
4806
4812
  }
4807
- }, bi = class {
4813
+ }, xi = class {
4808
4814
  constructor(e) {
4809
4815
  this.data = this.normalize(e);
4810
4816
  }
@@ -4861,9 +4867,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4861
4867
  getData() {
4862
4868
  return this.data;
4863
4869
  }
4864
- }, xi = class {
4870
+ }, Si = class {
4865
4871
  constructor(e, t, n) {
4866
- this.tenantApi = e, this.scopes = t, this.logger = n || Yn();
4872
+ this.tenantApi = e, this.scopes = t, this.logger = n || Xn();
4867
4873
  }
4868
4874
  handlePassflowError(t, n) {
4869
4875
  if (e.isAxiosError(t) && t.response?.data) {
@@ -4899,7 +4905,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
4899
4905
  }
4900
4906
  async getTenantUserMembership(e) {
4901
4907
  try {
4902
- return new bi(await this.tenantApi.getTenantDetails(e));
4908
+ return new xi(await this.tenantApi.getTenantDetails(e));
4903
4909
  } catch (t) {
4904
4910
  this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
4905
4911
  }
@@ -5044,7 +5050,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5044
5050
  this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
5045
5051
  }
5046
5052
  }
5047
- }, Si = class {
5053
+ }, Ci = class {
5048
5054
  constructor(e, t, n, r = ae) {
5049
5055
  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();
5050
5056
  }
@@ -5124,7 +5130,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5124
5130
  isExpired() {
5125
5131
  return this.tokensCache ? this.tokensCache.access_token ? A(j(this.tokensCache.access_token)) : !1 : !0;
5126
5132
  }
5127
- }, Ci = class {
5133
+ }, wi = class {
5128
5134
  constructor(e, t, n) {
5129
5135
  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) => {
5130
5136
  if (e === Z.TwoFactorRequired) {
@@ -5201,7 +5207,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5201
5207
  }
5202
5208
  }
5203
5209
  assertTotpCode(e) {
5204
- if (!ii(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
5210
+ if (!ai(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
5205
5211
  }
5206
5212
  requirePendingTfaToken() {
5207
5213
  let e = this.pendingTfaToken();
@@ -5220,7 +5226,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5220
5226
  }), e;
5221
5227
  }
5222
5228
  async verify(e, t) {
5223
- if (!ii(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
5229
+ if (!ai(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
5224
5230
  if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
5225
5231
  if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
5226
5232
  try {
@@ -5236,7 +5242,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5236
5242
  }
5237
5243
  async useRecoveryCode(e, t) {
5238
5244
  try {
5239
- let n = ai(e);
5245
+ let n = oi(e);
5240
5246
  if (!n) throw Error("Invalid recovery code format. Expected format: XXXX-XXXX or XXXXXXXX (alphanumeric).");
5241
5247
  if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
5242
5248
  if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
@@ -5257,7 +5263,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5257
5263
  }
5258
5264
  }
5259
5265
  async disable(e) {
5260
- if (!ii(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
5266
+ if (!ai(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
5261
5267
  try {
5262
5268
  let t = await this.twoFactorApi.disable({ code: e });
5263
5269
  return this.subscribeStore.notify(Z.TwoFactorDisabled, {}), t;
@@ -5266,7 +5272,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5266
5272
  }
5267
5273
  }
5268
5274
  async regenerateRecoveryCodes(e) {
5269
- if (!ii(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
5275
+ if (!ai(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
5270
5276
  try {
5271
5277
  let t = await this.twoFactorApi.regenerateRecoveryCodes({ code: e }), n = [...t.recovery_codes];
5272
5278
  return t.recovery_codes = [], t.recovery_codes = n, t;
@@ -5450,7 +5456,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5450
5456
  this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
5451
5457
  }
5452
5458
  }
5453
- }, wi = class {
5459
+ }, Ti = class {
5454
5460
  constructor(e, t, n = ae) {
5455
5461
  this.userAPI = e, this.deviceService = t, this.platform = n;
5456
5462
  }
@@ -5477,69 +5483,69 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5477
5483
  if (!s) throw Error("Passkey registration was not completed");
5478
5484
  return await this.userAPI.addUserPasskeyComplete(s, r, a);
5479
5485
  }
5480
- }, Ti = class extends Error {
5486
+ }, Ei = class extends Error {
5481
5487
  constructor(e, t, n = !1) {
5482
5488
  super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
5483
5489
  }
5484
- }, Ei = (e, t) => {
5490
+ }, Di = (e, t) => {
5485
5491
  let n = t?.trim();
5486
- if (!n) throw new Ti(e, "A verification code is required");
5492
+ if (!n) throw new Ei(e, "A verification code is required");
5487
5493
  return n;
5488
- }, Di = {
5494
+ }, Oi = {
5489
5495
  type: "totp",
5490
5496
  requiresPrepare: !1,
5491
5497
  input: "code",
5492
- assert: async ({ code: e }) => ({ code: Ei("totp", e) })
5493
- }, Oi = {
5498
+ assert: async ({ code: e }) => ({ code: Di("totp", e) })
5499
+ }, ki = {
5494
5500
  type: "recovery_codes",
5495
5501
  requiresPrepare: !1,
5496
5502
  input: "code",
5497
- assert: async ({ code: e }) => ({ code: Ei("recovery_codes", e) })
5498
- }, ki = {
5503
+ assert: async ({ code: e }) => ({ code: Di("recovery_codes", e) })
5504
+ }, Ai = {
5499
5505
  type: "passkey",
5500
5506
  requiresPrepare: !0,
5501
5507
  input: "none",
5502
5508
  assert: async ({ prepared: e, platform: t }) => {
5503
- if (!e?.webauthn) throw new Ti("passkey", "The upgrade challenge carried no WebAuthn options");
5509
+ if (!e?.webauthn) throw new Ei("passkey", "The upgrade challenge carried no WebAuthn options");
5504
5510
  let n = t.passkeys;
5505
- if (!n) throw new Ti("passkey", "This platform does not support passkeys");
5511
+ if (!n) throw new Ei("passkey", "This platform does not support passkeys");
5506
5512
  let r;
5507
5513
  try {
5508
5514
  r = await n.startAuthentication(e.webauthn);
5509
5515
  } catch (e) {
5510
- throw new Ti("passkey", e?.message || "Passkey verification was cancelled", !0);
5516
+ throw new Ei("passkey", e?.message || "Passkey verification was cancelled", !0);
5511
5517
  }
5512
- if (!r) throw new Ti("passkey", "Passkey verification was cancelled", !0);
5518
+ if (!r) throw new Ei("passkey", "Passkey verification was cancelled", !0);
5513
5519
  return {
5514
5520
  challenge_id: e.challengeId,
5515
5521
  credential: r
5516
5522
  };
5517
5523
  }
5518
- }, Ai = Object.freeze([
5519
- Di,
5520
- ki,
5521
- Oi
5522
- ]), ji = (e = Ai) => new Map(e.map((e) => [e.type, e])), Mi = 3, Ni = {
5524
+ }, ji = Object.freeze([
5525
+ Oi,
5526
+ Ai,
5527
+ ki
5528
+ ]), Mi = (e = ji) => new Map(e.map((e) => [e.type, e])), Ni = 3, Pi = {
5523
5529
  passkey: 0,
5524
5530
  totp: 1,
5525
5531
  email_otp: 2,
5526
5532
  sms_otp: 3,
5527
5533
  recovery_codes: 9
5528
- }, Pi = (e) => e.requiredLevel ?? ce(e.acrValues), Fi = (e, t) => {
5529
- let n = Ni[e.type] ?? 5, r = t !== void 0 && t >= Mi, i = e.type === "passkey";
5534
+ }, Fi = (e) => e.requiredLevel ?? ce(e.acrValues), Ii = (e, t) => {
5535
+ let n = Pi[e.type] ?? 5, r = t !== void 0 && t >= Ni, i = e.type === "passkey";
5530
5536
  return (r && !i ? 100 : 0) + n;
5531
- }, Ii = (e, t) => {
5532
- let n = Pi(t);
5533
- return [...e].sort((e, t) => Fi(e, n) - Fi(t, n));
5534
- }, Li = class extends Error {
5537
+ }, Li = (e, t) => {
5538
+ let n = Fi(t);
5539
+ return [...e].sort((e, t) => Ii(e, n) - Ii(t, n));
5540
+ }, Ri = class extends Error {
5535
5541
  constructor(e) {
5536
5542
  super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
5537
5543
  }
5538
- }, Ri = class extends Error {
5544
+ }, zi = class extends Error {
5539
5545
  constructor(e = "No available authentication factor can satisfy this challenge") {
5540
5546
  super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
5541
5547
  }
5542
- }, zi = 4, Bi = 3e4, Vi = () => {
5548
+ }, Bi = 4, Vi = 3e4, Hi = () => {
5543
5549
  let e = () => void 0, t = () => void 0;
5544
5550
  return {
5545
5551
  promise: new Promise((n, r) => {
@@ -5548,11 +5554,11 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5548
5554
  resolve: e,
5549
5555
  reject: t
5550
5556
  };
5551
- }, Hi = (e) => ({
5557
+ }, Ui = (e) => ({
5552
5558
  acrValues: e.acrValues,
5553
5559
  level: e.requiredLevel,
5554
5560
  maxAge: e.maxAge
5555
- }), Ui = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, Wi = (e, t) => {
5561
+ }), Wi = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, Gi = (e, t) => {
5556
5562
  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 ?? []]));
5557
5563
  return {
5558
5564
  acrValues: r,
@@ -5561,12 +5567,12 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5561
5567
  status: e.status,
5562
5568
  ...a.length > 0 ? { channels: a } : {}
5563
5569
  };
5564
- }, Gi = (e, t) => {
5570
+ }, Ki = (e, t) => {
5565
5571
  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);
5566
5572
  return n || r;
5567
- }, Ki = class {
5573
+ }, qi = class {
5568
5574
  constructor(e) {
5569
- 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 ?? Ai, this.registry = ji(this.available), this.maxAttempts = e.maxAttempts ?? zi, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? Bi;
5575
+ 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 ?? ji, this.registry = Mi(this.available), this.maxAttempts = e.maxAttempts ?? Bi, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? Vi;
5570
5576
  }
5571
5577
  get currentState() {
5572
5578
  return this.state;
@@ -5586,9 +5592,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5586
5592
  }
5587
5593
  register(e, t) {
5588
5594
  let n = t.kind === "imperative" && t.requested !== void 0, r = {
5589
- demanded: t.kind === "imperative" && t.requested ? t.requested : Hi(e),
5595
+ demanded: t.kind === "imperative" && t.requested ? t.requested : Ui(e),
5590
5596
  statedBar: n,
5591
- settlement: Vi(),
5597
+ settlement: Hi(),
5592
5598
  reported: !1,
5593
5599
  entry: {
5594
5600
  ...t,
@@ -5604,15 +5610,15 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5604
5610
  this.requirement = e;
5605
5611
  return;
5606
5612
  }
5607
- let n = Gi(t, e);
5608
- this.requirement = Wi(t, e), n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
5613
+ let n = Ki(t, e);
5614
+ this.requirement = Gi(t, e), n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
5609
5615
  challenge: this.requirement,
5610
5616
  factors: this.offeredFactors()
5611
5617
  });
5612
5618
  }
5613
5619
  offeredFactors() {
5614
5620
  let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
5615
- return t ? Ii(e, t) : e;
5621
+ return t ? Li(e, t) : e;
5616
5622
  }
5617
5623
  receiveReport(e, t) {
5618
5624
  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());
@@ -5647,12 +5653,12 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5647
5653
  }
5648
5654
  release(e, t) {
5649
5655
  if (e.entry.kind === "imperative") {
5650
- if (e.statedBar && !Ui(t, e.demanded)) {
5656
+ if (e.statedBar && !Wi(t, e.demanded)) {
5651
5657
  this.receiveReport(e, {
5652
5658
  outcome: "insufficient",
5653
5659
  obtained: t,
5654
5660
  required: e.demanded
5655
- }), e.settlement.reject(new Jr(t, e.demanded));
5661
+ }), e.settlement.reject(new Yr(t, e.demanded));
5656
5662
  return;
5657
5663
  }
5658
5664
  this.receiveReport(e, {
@@ -5725,7 +5731,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5725
5731
  let t = this.offeredFactors();
5726
5732
  if (t.length === 0) return {
5727
5733
  status: "failed",
5728
- reason: new Ri()
5734
+ reason: new zi()
5729
5735
  };
5730
5736
  let n = this.requirement, r;
5731
5737
  try {
@@ -5733,24 +5739,24 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5733
5739
  } catch (e) {
5734
5740
  return {
5735
5741
  status: "failed",
5736
- reason: new Li(e)
5742
+ reason: new Ri(e)
5737
5743
  };
5738
5744
  }
5739
5745
  if (r.type === "cancel") return {
5740
5746
  status: "failed",
5741
- reason: new Li()
5747
+ reason: new Ri()
5742
5748
  };
5743
5749
  let i = this.registry.get(r.factor);
5744
- if (!i) e = new Ri(`Unknown authentication factor: ${r.factor}`), this.state = "collecting", this.selected = null;
5750
+ if (!i) e = new zi(`Unknown authentication factor: ${r.factor}`), this.state = "collecting", this.selected = null;
5745
5751
  else try {
5746
5752
  return await this.proveAndCommit(i, r.code), {
5747
5753
  status: "proven",
5748
- obtained: this.readObtainedBar?.() ?? Hi(this.rankedRequirement ?? n)
5754
+ obtained: this.readObtainedBar?.() ?? Ui(this.rankedRequirement ?? n)
5749
5755
  };
5750
5756
  } catch (t) {
5751
- if (t instanceof Ti && t.cancelled) return {
5757
+ if (t instanceof Ei && t.cancelled) return {
5752
5758
  status: "failed",
5753
- reason: new Li()
5759
+ reason: new Ri()
5754
5760
  };
5755
5761
  let n = this.classifyProofFailure(t);
5756
5762
  if (n) return {
@@ -5780,15 +5786,15 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5780
5786
  return this.openPrompt = r, this.prompt(r);
5781
5787
  }
5782
5788
  classifyProofFailure(e) {
5783
- if (e instanceof Jr || e instanceof Yr || e instanceof Xr) return e;
5789
+ if (e instanceof Yr || e instanceof Xr || e instanceof Zr) return e;
5784
5790
  if (e instanceof $) switch (e.kind) {
5785
- case "unavailable": return new Yr(e.message);
5791
+ case "unavailable": return new Xr(e.message);
5786
5792
  case "exhausted":
5787
5793
  case "attempts_exhausted":
5788
5794
  case "fatal":
5789
5795
  case "protocol":
5790
5796
  case "network": return e;
5791
- case "session_changed": return new Xr(e.message);
5797
+ case "session_changed": return new Zr(e.message);
5792
5798
  default: return;
5793
5799
  }
5794
5800
  }
@@ -5800,28 +5806,28 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5800
5806
  });
5801
5807
  await this.transport.commit(e.type, r);
5802
5808
  }
5803
- }, qi = (e) => typeof e == "function" ? e() : e, Ji = (e) => {
5809
+ }, Ji = (e) => typeof e == "function" ? e() : e, Yi = (e) => {
5804
5810
  try {
5805
5811
  return new URL(e);
5806
5812
  } catch {
5807
5813
  return;
5808
5814
  }
5809
- }, Yi = (e, t) => {
5815
+ }, Xi = (e, t) => {
5810
5816
  if (!t || t === "/") return !0;
5811
5817
  let n = t.replace(/\/+$/, "");
5812
5818
  return e === n || e.startsWith(`${n}/`);
5813
- }, Xi = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && Yi(e.pathname, t.pathPrefix), Zi = (e, t) => {
5819
+ }, Zi = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && Xi(e.pathname, t.pathPrefix), Qi = (e, t) => {
5814
5820
  for (let n of t) {
5815
5821
  if (n === "") continue;
5816
5822
  if (n.startsWith("/")) {
5817
- if (e.relativeToBase && Yi(e.pathname, n)) return !0;
5823
+ if (e.relativeToBase && Xi(e.pathname, n)) return !0;
5818
5824
  continue;
5819
5825
  }
5820
- let t = Ji(n) ?? Ji(`https://${n}`);
5821
- if (t && e.origin !== void 0 && e.origin === t.origin && Yi(e.pathname, t.pathname)) return !0;
5826
+ let t = Yi(n) ?? Yi(`https://${n}`);
5827
+ if (t && e.origin !== void 0 && e.origin === t.origin && Xi(e.pathname, t.pathname)) return !0;
5822
5828
  }
5823
5829
  return !1;
5824
- }, Qi = (e, t, n) => Xi(e, t.passflow) || Zi(e, t.backend) ? !n || n(e.href) !== !1 : !1, $i = (e) => {
5830
+ }, $i = (e, t, n) => Zi(e, t.passflow) || Qi(e, t.backend) ? !n || n(e.href) !== !1 : !1, ea = (e) => {
5825
5831
  let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
5826
5832
  console.warn(n, {
5827
5833
  status: e.status,
@@ -5829,8 +5835,8 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5829
5835
  reason: e.reason,
5830
5836
  detail: t
5831
5837
  });
5832
- }, ea = (e, t) => {
5833
- let n = t.onUpgradeDiagnostic ?? $i;
5838
+ }, ta = (e, t) => {
5839
+ let n = t.onUpgradeDiagnostic ?? ea;
5834
5840
  return (t, r) => {
5835
5841
  n({
5836
5842
  status: e.status,
@@ -5842,8 +5848,8 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5842
5848
  }
5843
5849
  });
5844
5850
  };
5845
- }, ta = (e, t, n) => {
5846
- let r = n.onUpgradeDiagnostic ?? $i;
5851
+ }, na = (e, t, n) => {
5852
+ let r = n.onUpgradeDiagnostic ?? ea;
5847
5853
  for (let n of e) r({
5848
5854
  ...n,
5849
5855
  url: t.request.href,
@@ -5852,8 +5858,8 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5852
5858
  ...n.detail ?? {}
5853
5859
  }
5854
5860
  });
5855
- }, na = /\bjson\b/i, ra = async (e, t) => {
5856
- let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && na.test(r), a;
5861
+ }, ra = /\bjson\b/i, ia = async (e, t) => {
5862
+ let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && ra.test(r), a;
5857
5863
  if (i) try {
5858
5864
  a = await e.readBody();
5859
5865
  } catch {
@@ -5867,10 +5873,10 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5867
5873
  status: e.status,
5868
5874
  getHeader: (t) => e.getHeader(t) ?? void 0
5869
5875
  }, { requireChallengeChannel: t.requireChallengeChannel });
5870
- }, ia = (e) => ye({
5876
+ }, aa = (e) => ye({
5871
5877
  status: e.status,
5872
5878
  getHeader: (t) => e.getHeader(t) ?? void 0
5873
- }, { requireChallengeChannel: "header" }).challenge, aa = (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.`, oa = (e, t) => e instanceof Li ? { kind: "cancelled" } : e instanceof Ri ? { kind: "unsatisfiable" } : e instanceof Yr ? { kind: "unavailable" } : e instanceof Xr ? { kind: "session-changed" } : e instanceof Jr ? {
5879
+ }, { requireChallengeChannel: "header" }).challenge, oa = (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.`, sa = (e, t) => e instanceof Ri ? { kind: "cancelled" } : e instanceof zi ? { kind: "unsatisfiable" } : e instanceof Xr ? { kind: "unavailable" } : e instanceof Zr ? { kind: "session-changed" } : e instanceof Yr ? {
5874
5880
  kind: "insufficient",
5875
5881
  obtained: e.obtained,
5876
5882
  required: e.required
@@ -5886,17 +5892,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5886
5892
  kind: "transport-failure",
5887
5893
  retryable: !1,
5888
5894
  error: e instanceof Error ? e : Error(String(e))
5889
- }, sa = async (e, t, n, r) => {
5895
+ }, ca = async (e, t, n, r) => {
5890
5896
  if (e.status !== 401 && e.status !== 403) return {
5891
5897
  kind: "replayed",
5892
5898
  response: e
5893
5899
  };
5894
- let { challenge: i, diagnostics: a } = await ra(e, t);
5895
- if (ta(a, e, t), !i) return {
5900
+ let { challenge: i, diagnostics: a } = await ia(e, t);
5901
+ if (na(a, e, t), !i) return {
5896
5902
  kind: "replayed",
5897
5903
  response: e
5898
5904
  };
5899
- let o = Hi(i);
5905
+ let o = Ui(i);
5900
5906
  return r("elevated-insufficient", {
5901
5907
  obtained: n,
5902
5908
  required: o
@@ -5906,7 +5912,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5906
5912
  required: o,
5907
5913
  response: e
5908
5914
  };
5909
- }, ca = async (e, t) => {
5915
+ }, la = async (e, t) => {
5910
5916
  if (!t) return {
5911
5917
  aborted: !1,
5912
5918
  value: await e
@@ -5933,14 +5939,14 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5933
5939
  } finally {
5934
5940
  n && t.removeEventListener?.("abort", n);
5935
5941
  }
5936
- }, la = async (e, t) => {
5942
+ }, ua = async (e, t) => {
5937
5943
  if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
5938
- let n = ea(e, t);
5944
+ let n = ta(e, t);
5939
5945
  if (e.markers.replayed) {
5940
- if (!Qi(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
5941
- let { challenge: r, diagnostics: i } = await ra(e, t);
5942
- if (ta(i, e, t), !r) return { kind: "not-a-challenge" };
5943
- let a = t.readObtainedBar?.() ?? {}, o = Hi(r);
5946
+ if (!$i(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
5947
+ let { challenge: r, diagnostics: i } = await ia(e, t);
5948
+ if (na(i, e, t), !r) return { kind: "not-a-challenge" };
5949
+ let a = t.readObtainedBar?.() ?? {}, o = Ui(r);
5944
5950
  return n("elevated-insufficient", {
5945
5951
  obtained: a,
5946
5952
  required: o
@@ -5951,12 +5957,12 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5951
5957
  response: e
5952
5958
  };
5953
5959
  }
5954
- if (!Qi(e.request, t.scope, t.shouldIntercept)) return ia(e) ? (n("challenge-out-of-scope", {
5960
+ if (!$i(e.request, t.scope, t.shouldIntercept)) return aa(e) ? (n("challenge-out-of-scope", {
5955
5961
  header: e.getHeader("www-authenticate") ?? void 0,
5956
- message: aa(e.request.href, t.scope)
5962
+ message: oa(e.request.href, t.scope)
5957
5963
  }), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
5958
- let { challenge: r, diagnostics: i } = await ra(e, t);
5959
- if (ta(i, e, t), !r) {
5964
+ let { challenge: r, diagnostics: i } = await ia(e, t);
5965
+ if (na(i, e, t), !r) {
5960
5966
  let r = e.getHeader("www-authenticate");
5961
5967
  return t.requireChallengeChannel !== "header" && n("no-channel", {
5962
5968
  ...r ? { header: r } : {},
@@ -5970,9 +5976,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5970
5976
  method: e.request.method
5971
5977
  }, s, c;
5972
5978
  try {
5973
- s = Promise.resolve(t.elevate(r, o)), c = await ca(s, e.signal);
5979
+ s = Promise.resolve(t.elevate(r, o)), c = await la(s, e.signal);
5974
5980
  } catch (e) {
5975
- return oa(e, void 0);
5981
+ return sa(e, void 0);
5976
5982
  }
5977
5983
  if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
5978
5984
  kind: "aborted",
@@ -5983,7 +5989,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5983
5989
  kind: "aborted",
5984
5990
  reason: e.signal.reason
5985
5991
  };
5986
- let u = l?.obtained ?? t.readObtainedBar?.() ?? Hi(r), d = t.authorizationSwap?.(), f = d ? {
5992
+ let u = l?.obtained ?? t.readObtainedBar?.() ?? Ui(r), d = t.authorizationSwap?.(), f = d ? {
5987
5993
  from: a?.from ?? d.from,
5988
5994
  to: d.to
5989
5995
  } : void 0;
@@ -5992,7 +5998,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
5992
5998
  try {
5993
5999
  p = await e.replay(f ? { authorizationSwap: f } : void 0);
5994
6000
  } catch (t) {
5995
- if (t instanceof Jr) return l?.waiter.report({
6001
+ if (t instanceof Yr) return l?.waiter.report({
5996
6002
  outcome: "insufficient",
5997
6003
  obtained: t.obtained,
5998
6004
  required: t.required
@@ -6010,7 +6016,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6010
6016
  };
6011
6017
  throw t;
6012
6018
  }
6013
- let m = await sa(p, t, u, n);
6019
+ let m = await ca(p, t, u, n);
6014
6020
  return m.kind === "insufficient" ? l?.waiter.report({
6015
6021
  outcome: "insufficient",
6016
6022
  obtained: m.obtained,
@@ -6019,18 +6025,18 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6019
6025
  outcome: "replayed",
6020
6026
  obtained: u
6021
6027
  }), m;
6022
- }, ua = (e) => {
6028
+ }, da = (e) => {
6023
6029
  switch (e.kind) {
6024
- case "cancelled": return new Li();
6025
- case "unsatisfiable": return new Ri();
6026
- case "unavailable": return new Yr();
6027
- case "session-changed": return new Xr();
6028
- case "insufficient": return new Jr(e.obtained, e.required);
6030
+ case "cancelled": return new Ri();
6031
+ case "unsatisfiable": return new zi();
6032
+ case "unavailable": return new Xr();
6033
+ case "session-changed": return new Zr();
6034
+ case "insufficient": return new Yr(e.obtained, e.required);
6029
6035
  case "exhausted": return e.error;
6030
6036
  case "transport-failure": return e.error;
6031
6037
  default: return;
6032
6038
  }
6033
- }, da = (e, t, n) => {
6039
+ }, fa = (e, t, n) => {
6034
6040
  switch (e.kind) {
6035
6041
  case "replayed": return {
6036
6042
  settle: "resolve",
@@ -6048,21 +6054,21 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6048
6054
  };
6049
6055
  case "cancelled": return n.onCancel === "reject" ? {
6050
6056
  settle: "reject",
6051
- error: new Li()
6057
+ error: new Ri()
6052
6058
  } : {
6053
6059
  settle: "resolve",
6054
- value: ba(t, e)
6060
+ value: xa(t, e)
6055
6061
  };
6056
6062
  case "insufficient": return {
6057
6063
  settle: "resolve",
6058
- value: ba(e.response?.raw ?? t, e)
6064
+ value: xa(e.response?.raw ?? t, e)
6059
6065
  };
6060
6066
  default: return {
6061
6067
  settle: "resolve",
6062
- value: ba(t, e)
6068
+ value: xa(t, e)
6063
6069
  };
6064
6070
  }
6065
- }, fa = (e, t) => {
6071
+ }, pa = (e, t) => {
6066
6072
  switch (e.kind) {
6067
6073
  case "replayed": return e.response.rejected ? {
6068
6074
  settle: "reject",
@@ -6077,39 +6083,39 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6077
6083
  };
6078
6084
  default: return {
6079
6085
  settle: "reject",
6080
- error: ua(e) ?? t
6086
+ error: da(e) ?? t
6081
6087
  };
6082
6088
  }
6083
- }, pa = /* @__PURE__ */ new WeakSet(), ma = /* @__PURE__ */ new WeakSet(), ha = /* @__PURE__ */ new WeakSet(), ga = /* @__PURE__ */ new WeakSet(), _a = /* @__PURE__ */ new WeakSet(), va = /* @__PURE__ */ new WeakSet(), ya = /* @__PURE__ */ new WeakSet(), ba = (e, t) => {
6089
+ }, ma = /* @__PURE__ */ new WeakSet(), ha = /* @__PURE__ */ new WeakSet(), ga = /* @__PURE__ */ new WeakSet(), _a = /* @__PURE__ */ new WeakSet(), va = /* @__PURE__ */ new WeakSet(), ya = /* @__PURE__ */ new WeakSet(), ba = /* @__PURE__ */ new WeakSet(), xa = (e, t) => {
6084
6090
  switch (t.kind) {
6085
6091
  case "cancelled":
6086
- pa.add(e);
6092
+ ma.add(e);
6087
6093
  break;
6088
6094
  case "exhausted":
6089
- ma.add(e);
6095
+ ha.add(e);
6090
6096
  break;
6091
6097
  case "insufficient":
6092
- ha.add(e);
6098
+ ga.add(e);
6093
6099
  break;
6094
6100
  case "unsatisfiable":
6095
- ga.add(e);
6101
+ _a.add(e);
6096
6102
  break;
6097
6103
  case "unavailable":
6098
- _a.add(e);
6104
+ va.add(e);
6099
6105
  break;
6100
6106
  case "session-changed":
6101
- va.add(e);
6107
+ ya.add(e);
6102
6108
  break;
6103
- case "transport-failure": ya.add(e);
6109
+ case "transport-failure": ba.add(e);
6104
6110
  }
6105
6111
  return e;
6106
- }, xa = (e) => pa.has(e), Sa = (e) => ma.has(e), Ca = (e) => ha.has(e), wa = (e) => ga.has(e), Ta = (e) => _a.has(e), Ea = (e) => va.has(e), Da = (e) => ya.has(e), Oa = "https://passflow-relative.invalid", ka = () => {
6112
+ }, Sa = (e) => ma.has(e), Ca = (e) => ha.has(e), wa = (e) => ga.has(e), Ta = (e) => _a.has(e), Ea = (e) => va.has(e), Da = (e) => ya.has(e), Oa = (e) => ba.has(e), ka = "https://passflow-relative.invalid", Aa = () => {
6107
6113
  let e = globalThis, t = e.document?.baseURI;
6108
6114
  if (typeof t == "string" && t !== "") return t;
6109
6115
  let n = e.location?.href;
6110
- return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Oa;
6111
- }, Aa = (e, t = ka()) => {
6112
- let n = t === Oa, r;
6116
+ return typeof n == "string" && n !== "" && n !== "about:blank" ? n : ka;
6117
+ }, ja = (e, t = Aa()) => {
6118
+ let n = t === ka, r;
6113
6119
  try {
6114
6120
  r = new URL(t).origin;
6115
6121
  } catch {
@@ -6135,28 +6141,28 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6135
6141
  relativeToBase: !1,
6136
6142
  sentinelBase: n
6137
6143
  };
6138
- }, ja = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Ma = (e) => {
6144
+ }, Ma = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Na = (e) => {
6139
6145
  let t = [];
6140
6146
  if (e == null) return Object.freeze(t);
6141
6147
  let n = e;
6142
6148
  if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
6143
- let r = ja(n, e);
6149
+ let r = Ma(n, e);
6144
6150
  r && t.push(r);
6145
6151
  }), Object.freeze(t);
6146
6152
  if (Array.isArray(e)) {
6147
6153
  for (let n of e) if (Array.isArray(n) && n.length >= 2) {
6148
- let e = ja(String(n[0]), n[1]);
6154
+ let e = Ma(String(n[0]), n[1]);
6149
6155
  e && t.push(e);
6150
6156
  }
6151
6157
  return Object.freeze(t);
6152
6158
  }
6153
6159
  if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
6154
- let e = ja(n, Array.isArray(r) ? r.join(", ") : r);
6160
+ let e = Ma(n, Array.isArray(r) ? r.join(", ") : r);
6155
6161
  e && t.push(e);
6156
6162
  }
6157
6163
  return Object.freeze(t);
6158
- }, Na = (e) => {
6159
- let t = e.base === void 0 ? Aa(e.url) : Aa(e.url, e.base), n = {
6164
+ }, Pa = (e) => {
6165
+ let t = e.base === void 0 ? ja(e.url) : ja(e.url, e.base), n = {
6160
6166
  raw: e.url,
6161
6167
  href: t.href,
6162
6168
  dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
@@ -6165,29 +6171,29 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6165
6171
  resolved: t.resolved,
6166
6172
  relativeToBase: t.relativeToBase,
6167
6173
  method: (e.method ?? "GET").toUpperCase(),
6168
- headers: Ma(e.headers),
6174
+ headers: Na(e.headers),
6169
6175
  bodyKind: e.bodyKind,
6170
6176
  ..."body" in e ? { body: e.body } : {}
6171
6177
  };
6172
6178
  return Object.freeze(n);
6173
- }, Pa = (e, t) => {
6179
+ }, Fa = (e, t) => {
6174
6180
  if (!t || t.from === t.to) return e;
6175
6181
  let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
6176
6182
  return n ? Object.freeze(r) : e;
6177
- }, Fa = (e) => {
6183
+ }, Ia = (e) => {
6178
6184
  let t = {};
6179
6185
  for (let [n, r] of e) t[n] = r;
6180
6186
  return t;
6181
- }, Ia = /* @__PURE__ */ new Set([
6187
+ }, La = /* @__PURE__ */ new Set([
6182
6188
  "GET",
6183
6189
  "HEAD",
6184
6190
  "OPTIONS"
6185
- ]), La = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, Ra = (e) => typeof e == "string" ? e : La(e) ? e.url : String(e), za = (e, t) => (t?.method ?? (La(e) ? e.method : void 0) ?? "GET").toUpperCase(), Ba = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", Va = (e) => {
6191
+ ]), Ra = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, za = (e) => typeof e == "string" ? e : Ra(e) ? e.url : String(e), Ba = (e, t) => (t?.method ?? (Ra(e) ? e.method : void 0) ?? "GET").toUpperCase(), Va = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", Ha = (e) => {
6186
6192
  if (typeof e == "string") return e.length;
6187
6193
  let t = e;
6188
6194
  if (typeof t?.size == "number") return t.size;
6189
6195
  if (typeof t?.byteLength == "number") return t.byteLength;
6190
- }, Ha = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? Ia.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), Ua = (e, t, n, r, i) => ({
6196
+ }, Ua = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? La.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), Wa = (e, t, n, r, i) => ({
6191
6197
  replayable: !1,
6192
6198
  bodyKind: e,
6193
6199
  reason: t,
@@ -6195,11 +6201,11 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6195
6201
  forwardInit: i,
6196
6202
  snapshot: r,
6197
6203
  replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
6198
- }), Wa = (e, t) => Fa(Pa(e.headers, t?.authorizationSwap)), Ga = (e) => {
6204
+ }), Ga = (e, t) => Ia(Fa(e.headers, t?.authorizationSwap)), Ka = (e) => {
6199
6205
  if (!e || !("headers" in e)) return e;
6200
6206
  let { headers: t, ...n } = e;
6201
6207
  return n;
6202
- }, Ka = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : La(e) ? e.headers : void 0, qa = (e) => {
6208
+ }, qa = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : Ra(e) ? e.headers : void 0, Ja = (e) => {
6203
6209
  if (e === null || typeof e == "string") return e;
6204
6210
  if (typeof FormData < "u" && e instanceof FormData) {
6205
6211
  let t = new FormData();
@@ -6207,18 +6213,18 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6207
6213
  return t;
6208
6214
  }
6209
6215
  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;
6210
- }, Ja = (e, t, n) => new Request(e, { headers: Wa(t, n) }), Ya = (e, t, n) => {
6211
- let r = Ra(e), i = za(e, t), a = Ka(e, t), o = (e, t) => Na({
6216
+ }, Ya = (e, t, n) => new Request(e, { headers: Ga(t, n) }), Xa = (e, t, n) => {
6217
+ let r = za(e), i = Ba(e, t), a = qa(e, t), o = (e, t) => Pa({
6212
6218
  url: r,
6213
6219
  method: i,
6214
6220
  headers: a,
6215
6221
  bodyKind: e,
6216
6222
  ...t === void 0 ? {} : { body: t }
6217
6223
  });
6218
- if (La(e)) {
6224
+ if (Ra(e)) {
6219
6225
  if (e.body === null || e.body === void 0) {
6220
6226
  let a = o("none");
6221
- return Ha(n, {
6227
+ return Ua(n, {
6222
6228
  url: r,
6223
6229
  method: i,
6224
6230
  bodyKind: "none"
@@ -6228,20 +6234,20 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6228
6234
  forwardInput: e,
6229
6235
  forwardInit: t,
6230
6236
  snapshot: a,
6231
- replay: (n, r) => n(Ja(e, a, r), Ga(t))
6232
- } : Ua("none", "the replay policy refused this request", e, a, t);
6237
+ replay: (n, r) => n(Ya(e, a, r), Ka(t))
6238
+ } : Wa("none", "the replay policy refused this request", e, a, t);
6233
6239
  }
6234
6240
  let a = o("request-clone");
6235
- if (!Ha(n, {
6241
+ if (!Ua(n, {
6236
6242
  url: r,
6237
6243
  method: i,
6238
6244
  bodyKind: "request-clone"
6239
- })) return Ua("request-clone", "the replay policy refused this request", e, a, t);
6245
+ })) return Wa("request-clone", "the replay policy refused this request", e, a, t);
6240
6246
  let s;
6241
6247
  try {
6242
6248
  s = e.clone();
6243
6249
  } catch {
6244
- return Ua("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
6250
+ return Wa("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
6245
6251
  }
6246
6252
  return {
6247
6253
  replayable: !0,
@@ -6249,17 +6255,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6249
6255
  forwardInput: e,
6250
6256
  forwardInit: t,
6251
6257
  snapshot: a,
6252
- replay: (e, n) => e(Ja(s, a, n), Ga(t))
6258
+ replay: (e, n) => e(Ya(s, a, n), Ka(t))
6253
6259
  };
6254
6260
  }
6255
- let s = Ba(t?.body);
6256
- if (s === "one-shot") return Ua("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
6257
- if (!Ha(n, {
6261
+ let s = Va(t?.body);
6262
+ if (s === "one-shot") return Wa("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
6263
+ if (!Ua(n, {
6258
6264
  url: r,
6259
6265
  method: i,
6260
6266
  bodyKind: s
6261
- }, Va(t?.body))) return Ua(s, "the replay policy refused this request", e, o(s), t);
6262
- let c = t && "body" in t ? qa(t.body ?? null) : void 0, l = o(s, c);
6267
+ }, Ha(t?.body))) return Wa(s, "the replay policy refused this request", e, o(s), t);
6268
+ let c = t && "body" in t ? Ja(t.body ?? null) : void 0, l = o(s, c);
6263
6269
  return {
6264
6270
  replayable: !0,
6265
6271
  bodyKind: s,
@@ -6267,21 +6273,21 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6267
6273
  forwardInit: t,
6268
6274
  snapshot: l,
6269
6275
  replay: (e, n) => e(l.dispatchUrl, {
6270
- ...Ga(t),
6276
+ ...Ka(t),
6271
6277
  ...c === void 0 ? {} : { body: c },
6272
- headers: Wa(l, n),
6278
+ headers: Ga(l, n),
6273
6279
  method: l.method
6274
6280
  })
6275
6281
  };
6276
- }, Xa = (e) => typeof e == "object" && !!e, Za = (e) => (t) => {
6277
- if (!Xa(e)) return;
6282
+ }, Za = (e) => typeof e == "object" && !!e, Qa = (e) => (t) => {
6283
+ if (!Za(e)) return;
6278
6284
  let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
6279
6285
  return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
6280
- }, Qa = (e) => {
6286
+ }, $a = (e) => {
6281
6287
  let t = e?.url ?? "", n = e?.baseURL;
6282
6288
  return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
6283
- }, $a = (e) => (e?.method ?? "GET").toUpperCase(), eo = (e) => e == null ? "none" : Xa(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", to = (e, t, n) => {
6284
- let r = Fa(Pa(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
6289
+ }, eo = (e) => (e?.method ?? "GET").toUpperCase(), to = (e) => e == null ? "none" : Za(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", no = (e, t, n) => {
6290
+ let r = Ia(Fa(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
6285
6291
  return {
6286
6292
  ...e,
6287
6293
  ...i ? { baseURL: void 0 } : {},
@@ -6290,10 +6296,10 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6290
6296
  headers: r,
6291
6297
  ..."body" in t ? { data: t.body } : {}
6292
6298
  };
6293
- }, no = (e, t, n, r, i, a) => {
6294
- let o = t ?? e?.config, s = eo(o?.data), c = a ?? Na({
6295
- url: Qa(o),
6296
- method: $a(o),
6299
+ }, ro = (e, t, n, r, i, a) => {
6300
+ let o = t ?? e?.config, s = to(o?.data), c = a ?? Pa({
6301
+ url: $a(o),
6302
+ method: eo(o),
6297
6303
  headers: o?.headers,
6298
6304
  bodyKind: s,
6299
6305
  body: o?.data
@@ -6301,22 +6307,22 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6301
6307
  url: c.href,
6302
6308
  method: c.method,
6303
6309
  bodyKind: s
6304
- }, u = s !== "one-shot" && Ha(i.replay, l);
6310
+ }, u = s !== "one-shot" && Ua(i.replay, l);
6305
6311
  return {
6306
6312
  status: e?.status ?? 0,
6307
- getHeader: Za(e?.headers),
6313
+ getHeader: Qa(e?.headers),
6308
6314
  readBody: async () => e?.data,
6309
6315
  request: c,
6310
6316
  replay: async (e) => {
6311
- let t = Ee(to(o ?? {}, c, e));
6317
+ let t = Ee(no(o ?? {}, c, e));
6312
6318
  try {
6313
6319
  let e = await r(t);
6314
- return no(e, e?.config ?? t, e, r, i, c);
6320
+ return ro(e, e?.config ?? t, e, r, i, c);
6315
6321
  } catch (e) {
6316
- let n = Xa(e) ? e : {};
6317
- if (!n.response || typeof n.response.status != "number" || Br(e)) throw e;
6322
+ let n = Za(e) ? e : {};
6323
+ if (!n.response || typeof n.response.status != "number" || Vr(e)) throw e;
6318
6324
  return {
6319
- ...no(n.response, n.config ?? t, e, r, i, c),
6325
+ ...ro(n.response, n.config ?? t, e, r, i, c),
6320
6326
  rejected: !0
6321
6327
  };
6322
6328
  }
@@ -6330,19 +6336,19 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6330
6336
  replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
6331
6337
  signal: o?.signal
6332
6338
  };
6333
- }, ro = (e, t) => async (n) => {
6334
- let r = qi(e), i = Xa(n) ? n : {}, a = fa(await la(no(i.response, i.config, i.response, t, r), r), n);
6339
+ }, io = (e, t) => async (n) => {
6340
+ let r = Ji(e), i = Za(n) ? n : {}, a = pa(await ua(ro(i.response, i.config, i.response, t, r), r), n);
6335
6341
  if (a.settle === "reject") throw a.error;
6336
6342
  return a.value;
6337
- }, io = (e, t, n) => {
6338
- 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, ro(t, i)), o = !1;
6343
+ }, ao = (e, t, n) => {
6344
+ 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, io(t, i)), o = !1;
6339
6345
  return () => {
6340
6346
  o || (o = !0, e.interceptors.response.eject(a));
6341
6347
  };
6342
- }, ao = (t, n) => {
6348
+ }, oo = (t, n) => {
6343
6349
  let r = e.create(t);
6344
6350
  return n(r), r;
6345
- }, oo = 0, so = (e, t) => {
6351
+ }, so = 0, co = (e, t) => {
6346
6352
  let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
6347
6353
  if (n) return {
6348
6354
  get aborted() {
@@ -6356,34 +6362,34 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6356
6362
  removeEventListener: (e, t) => n.removeEventListener(e, t)
6357
6363
  } : {}
6358
6364
  };
6359
- }, co = (e) => (t) => e.headers?.get(t), lo = (e, t, n, r, i) => ({
6365
+ }, lo = (e) => (t) => e.headers?.get(t), uo = (e, t, n, r, i) => ({
6360
6366
  status: e.status,
6361
- getHeader: co(e),
6367
+ getHeader: lo(e),
6362
6368
  readBody: () => e.clone().json(),
6363
6369
  request: t.snapshot,
6364
- replay: async (e) => lo(await t.replay(n, e), t, n, r, i),
6370
+ replay: async (e) => uo(await t.replay(n, e), t, n, r, i),
6365
6371
  markers: r,
6366
6372
  raw: e,
6367
6373
  replayable: t.replayable,
6368
6374
  replayUnsupportedReason: t.reason,
6369
6375
  signal: i,
6370
6376
  responseType: e.type
6371
- }), uo = (e, t) => {
6377
+ }), fo = (e, t) => {
6372
6378
  let n = (t, n) => {
6373
- oo += 1;
6379
+ so += 1;
6374
6380
  try {
6375
6381
  return e(t, n);
6376
6382
  } finally {
6377
- --oo;
6383
+ --so;
6378
6384
  }
6379
6385
  };
6380
6386
  return async (e, r) => {
6381
- if (oo > 0) return n(e, r);
6382
- let i = qi(t), a = Ya(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = da(await la(lo(o, a, n, {}, so(e, r)), i), o, i);
6387
+ if (so > 0) return n(e, r);
6388
+ let i = Ji(t), a = Xa(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = fa(await ua(uo(o, a, n, {}, co(e, r)), i), o, i);
6383
6389
  if (s.settle === "reject") throw s.error;
6384
6390
  return s.value;
6385
6391
  };
6386
- }, fo = new Set(Ai.filter((e) => !e.requiresPrepare).map((e) => e.type)), po = (e) => {
6392
+ }, po = new Set(ji.filter((e) => !e.requiresPrepare).map((e) => e.type)), mo = (e) => {
6387
6393
  if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
6388
6394
  kind: "protocol",
6389
6395
  message: "The upgrade start response is missing challenge_id or expires_at"
@@ -6395,17 +6401,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6395
6401
  webauthn: e.webauthn,
6396
6402
  codeSentTo: e.code_sent_to
6397
6403
  };
6398
- }, mo = (e) => Br(e) && !Vr(e), ho = (e) => ({
6404
+ }, ho = (e) => Vr(e) && !Hr(e), go = (e) => ({
6399
6405
  async prepare(t) {
6400
- if (!fo.has(t)) try {
6406
+ if (!po.has(t)) try {
6401
6407
  let n = e.relyingPartyId?.();
6402
- return po(await e.startUpgrade(n ? {
6408
+ return mo(await e.startUpgrade(n ? {
6403
6409
  method: t,
6404
6410
  relying_party_id: n
6405
6411
  } : { method: t }));
6406
6412
  } catch (e) {
6407
- if (mo(e)) throw e;
6408
- let t = Gr(e, "start");
6413
+ if (ho(e)) throw e;
6414
+ let t = Kr(e, "start");
6409
6415
  if (t.kind === "prepare_not_required") return;
6410
6416
  throw t;
6411
6417
  }
@@ -6422,17 +6428,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6422
6428
  assertion: n
6423
6429
  });
6424
6430
  } catch (t) {
6425
- if (mo(t)) throw t;
6426
- let n = Gr(t, "refresh");
6427
- throw n.status === 401 && qr(n) && e.markSessionInvalid?.(), n;
6431
+ if (ho(t)) throw t;
6432
+ let n = Kr(t, "refresh");
6433
+ throw n.status === 401 && Jr(n) && e.markSessionInvalid?.(), n;
6428
6434
  }
6429
6435
  }
6430
- }), go = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), _o = (e) => {
6436
+ }), _o = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), vo = (e) => {
6431
6437
  let t, n = (e) => e !== void 0 && t === e, r = (r) => {
6432
6438
  let i = () => {
6433
6439
  if (!n(r())) throw new $({ kind: "session_changed" });
6434
6440
  };
6435
- return ho({
6441
+ return go({
6436
6442
  ...e,
6437
6443
  relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
6438
6444
  startUpgrade: (t) => (i(), e.startUpgrade(t)),
@@ -6443,7 +6449,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6443
6449
  });
6444
6450
  }, i = (t, n) => {
6445
6451
  let i = {}, a = {
6446
- controller: new Ki({
6452
+ controller: new qi({
6447
6453
  transport: r(() => i.current),
6448
6454
  prompt: t.prompt,
6449
6455
  platform: e.platform,
@@ -6455,17 +6461,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6455
6461
  options: t,
6456
6462
  scope: {
6457
6463
  passflow: e.passflowDomain,
6458
- backend: go(t.backend)
6464
+ backend: _o(t.backend)
6459
6465
  },
6460
6466
  generation: n
6461
6467
  };
6462
6468
  return i.current = a, a;
6463
6469
  }, a = async (r, i) => {
6464
6470
  let a = t;
6465
- if (!a) throw new Yr("Step-up verification is not enabled on this Passflow instance");
6471
+ if (!a) throw new Xr("Step-up verification is not enabled on this Passflow instance");
6466
6472
  a.controller.active || (a.pin = e.readSessionPin?.());
6467
6473
  let o = await a.controller.elevate(r, i);
6468
- if (!n(a)) throw new Xr();
6474
+ if (!n(a)) throw new Zr();
6469
6475
  return o;
6470
6476
  }, o = () => {
6471
6477
  let n = t, r = n?.scope ?? {
@@ -6509,9 +6515,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6509
6515
  let r = [];
6510
6516
  if (e.attachInternalSeam) {
6511
6517
  let t = e.attachInternalSeam;
6512
- t((e) => ro(o, e)), r.push(() => t(void 0));
6518
+ t((e) => io(o, e)), r.push(() => t(void 0));
6513
6519
  }
6514
- n.interceptFetch && r.push(Pt((e, t, n) => uo(e, o)(t, n), {
6520
+ n.interceptFetch && r.push(Ft((e, t, n) => fo(e, o)(t, n), {
6515
6521
  priority: 20,
6516
6522
  name: "passflow-upgrade"
6517
6523
  })), e.onSessionChange && r.push(e.onSessionChange(() => {
@@ -6542,18 +6548,18 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6542
6548
  withAuth: {
6543
6549
  enumerable: !0,
6544
6550
  value: (e) => {
6545
- if (e) return uo(e, o);
6551
+ if (e) return fo(e, o);
6546
6552
  let t = typeof globalThis > "u" ? void 0 : globalThis;
6547
6553
  if (!t || typeof t.fetch != "function") throw Error("Passflow: withAuth() needs a fetch to wrap — this runtime has none.");
6548
- return uo(t.fetch.bind(t), o);
6554
+ return fo(t.fetch.bind(t), o);
6549
6555
  }
6550
6556
  },
6551
6557
  attachAuth: {
6552
6558
  enumerable: !0,
6553
- value: (e) => io(e, o)
6559
+ value: (e) => ao(e, o)
6554
6560
  }
6555
6561
  });
6556
- }, vo, yo = class {
6562
+ }, yo, bo = class {
6557
6563
  get origin() {
6558
6564
  return this.platform.getCurrentUrl()?.origin ?? "";
6559
6565
  }
@@ -6565,9 +6571,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6565
6571
  this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? ae, this.deferFederatedLanding = e.deferFederatedLanding ?? !1, this.storageManager = new ne({
6566
6572
  prefix: e.keyStoragePrefix ?? "",
6567
6573
  storage: this.platform.storage
6568
- }), this.deviceService = new re(this.storageManager), this.authApi = new lt(e, this.storageManager, this.deviceService), this.appApi = new rt(e, this.storageManager, this.deviceService), this.userApi = new bt(e, this.storageManager, this.deviceService), this.settingApi = new ft(e, this.storageManager, this.deviceService), this.tenantApi = new pt(e, this.storageManager, this.deviceService), this.invitationApi = new dt(e, this.storageManager, this.deviceService), this.twoFactorApi = new vt(e, this.storageManager, this.deviceService), this.upgradeApi = new yt(e, this.storageManager, this.deviceService), this.upgradeDomain = ke(e.url), this.subscribeStore = new Or(), this.tokenCacheService = new Si(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? d, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
6569
- let i = qn(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
6570
- this.authService = new vi(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
6574
+ }), this.deviceService = new re(this.storageManager), this.authApi = new ut(e, this.storageManager, this.deviceService), this.appApi = new it(e, this.storageManager, this.deviceService), this.userApi = new xt(e, this.storageManager, this.deviceService), this.settingApi = new pt(e, this.storageManager, this.deviceService), this.tenantApi = new mt(e, this.storageManager, this.deviceService), this.invitationApi = new ft(e, this.storageManager, this.deviceService), this.twoFactorApi = new yt(e, this.storageManager, this.deviceService), this.upgradeApi = new bt(e, this.storageManager, this.deviceService), this.upgradeDomain = ke(e.url), this.subscribeStore = new kr(), this.tokenCacheService = new Ci(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? d, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
6575
+ let i = Jn(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
6576
+ this.authService = new yi(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
6571
6577
  createSession: this.createSessionCallback,
6572
6578
  expiredSession: this.expiredSessionCallback
6573
6579
  }, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
@@ -6575,7 +6581,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6575
6581
  ...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
6576
6582
  }, () => this.readAppSettings()), this.tokenCacheService.attachRefreshController(this.authService.refresh);
6577
6583
  for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
6578
- this.userService = new wi(this.userApi, this.deviceService, this.platform), this.tenantService = new xi(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new yi(this.invitationApi), this.twoFactorService = new Ci(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = _o({
6584
+ this.userService = new Ti(this.userApi, this.deviceService, this.platform), this.tenantService = new Si(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new bi(this.invitationApi), this.twoFactorService = new wi(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = vo({
6579
6585
  startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
6580
6586
  commitRefresh: async (e, t) => {
6581
6587
  await this.authService.refreshToken(e, t);
@@ -6600,6 +6606,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6600
6606
  },
6601
6607
  attachInternalSeam: (e) => this.attachUpgradeSeam(e),
6602
6608
  onSessionChange: (e) => this.subscribeToSessionChange(e)
6609
+ }), this.hostedUpgrade = vo({
6610
+ startUpgrade: (e) => this.upgradeApi.startHostedUpgrade(e),
6611
+ commitRefresh: (e) => this.upgradeApi.commitHostedUpgrade(e),
6612
+ canCommit: () => ({ ok: !0 }),
6613
+ readSessionPin: () => void 0,
6614
+ readObtainedBar: () => void 0,
6615
+ markSessionInvalid: () => {},
6616
+ platform: this.platform,
6617
+ passflowDomain: this.upgradeDomain,
6618
+ ...e.upgrade?.factors ? { factors: e.upgrade.factors } : {},
6619
+ ...e.upgrade?.relyingPartyId ? { relyingPartyId: () => e.upgrade?.relyingPartyId } : {}
6603
6620
  }), e.parseQueryParams && this.checkAndSetTokens(), this.setTokensToCacheFromLocalStorage();
6604
6621
  }
6605
6622
  readAppSettings() {
@@ -6625,7 +6642,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6625
6642
  return this.upgrade.attachAuth(e);
6626
6643
  }
6627
6644
  createClient(e) {
6628
- return ao(e, (e) => this.upgrade.attachAuth(e));
6645
+ return oo(e, (e) => this.upgrade.attachAuth(e));
6629
6646
  }
6630
6647
  readAssuranceBar() {
6631
6648
  let e = this.storageManager.getToken(M.access_token);
@@ -6708,7 +6725,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6708
6725
  }
6709
6726
  let n = t.get("access_token"), r = t.get("refresh_token"), i = t.get("id_token"), a = t.get("state") ?? void 0, o = t.get("scopes")?.split(",") ?? this.scopes;
6710
6727
  if (n) {
6711
- if (!$r(n)) {
6728
+ if (!ei(n)) {
6712
6729
  W(this.subscribeStore, {
6713
6730
  operation: "tokens.from-url",
6714
6731
  message: "Invalid access token format received",
@@ -6716,7 +6733,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6716
6733
  }), this.cleanupUrlParams(e);
6717
6734
  return;
6718
6735
  }
6719
- if (r && !$r(r)) {
6736
+ if (r && !ei(r)) {
6720
6737
  W(this.subscribeStore, {
6721
6738
  operation: "tokens.from-url",
6722
6739
  message: "Invalid refresh token format received",
@@ -6724,7 +6741,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6724
6741
  }), this.cleanupUrlParams(e);
6725
6742
  return;
6726
6743
  }
6727
- if (i && !$r(i)) {
6744
+ if (i && !ei(i)) {
6728
6745
  W(this.subscribeStore, {
6729
6746
  operation: "tokens.from-url",
6730
6747
  message: "Invalid ID token format received",
@@ -6739,8 +6756,8 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6739
6756
  scopes: o
6740
6757
  };
6741
6758
  this.cleanupUrlParams(e), this.error = void 0, this.readAppSettings().catch(() => void 0).then((e) => {
6742
- if (e?.pkce_enabled !== !1) throw tn();
6743
- return Nr(this.url, this.appId, t);
6759
+ if (e?.pkce_enabled !== !1) throw nn();
6760
+ return Pr(this.url, this.appId, t);
6744
6761
  }).then(() => {
6745
6762
  this.storageManager.clearDeliveryMode(), this.storageManager.saveTokens(t), this.tokenCacheService.setTokensCache(t), this.authService.refresh.sessionStarted();
6746
6763
  }).then(() => (this.subscribeStore.notify(Z.SignIn, {
@@ -6775,7 +6792,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6775
6792
  if (!n) return !1;
6776
6793
  t.delete("tfa_token");
6777
6794
  let r = t.toString();
6778
- return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), $r(n) ? (this.subscribeStore.notify(Z.TwoFactorRequired, {
6795
+ return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), ei(n) ? (this.subscribeStore.notify(Z.TwoFactorRequired, {
6779
6796
  email: "",
6780
6797
  challengeId: "",
6781
6798
  tfaToken: n
@@ -6788,7 +6805,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
6788
6805
  checkErrorsFromURL() {
6789
6806
  let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
6790
6807
  if (e) {
6791
- let t = ei(e);
6808
+ let t = ti(e);
6792
6809
  return Error(t);
6793
6810
  }
6794
6811
  }
@@ -7194,7 +7211,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
7194
7211
  this.twoFactorService.clearMagicLinkSession();
7195
7212
  }
7196
7213
  };
7197
- vo = yo, vo.version = l;
7198
- export { a as APP_ID_HEADER_KEY, Pe as APP_SECRET_NAMES, o as AUTHORIZATION_HEADER_KEY, rt as AppAPI, lt as AuthAPI, vi as AuthService, ut as CLIAuthAPI, p as DEFAULT_GROUP_NAME, d as DEFAULT_SCOPES, Ai as DEFAULT_UPGRADE_FACTORS, s as DEVICE_ID_HEADER_KEY, c as DEVICE_TYPE_HEADER_KEY, x as ERROR_MESSAGE_MAX_LENGTH, xt as FETCH_PRIORITY_OIDC, St as FETCH_PRIORITY_UPGRADE, Ct as FetchMiddlewareContractError, le as INSUFFICIENT_USER_AUTHENTICATION, dt as InvitationAPI, yi as InvitationService, Ut as M2MClient, Rt as M2MConfigError, H as M2MError, zt as M2MErrorCodes, It as M2MNetworkError, Lt as M2MTokenParseError, Bt as M2M_DEFAULTS, Fe as MASKED_SECRET_PREFIX, u as MINIMAL_DEFAULT_SCOPES, Re as OS, f as PASSFLOW_CLOUD_URL, h as POPUP_HEIGHT, g as POPUP_POLL_INTERVAL_MS, _ as POPUP_TIMEOUT_MS, m as POPUP_WIDTH, yo as Passflow, B as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, V as PassflowError, Z as PassflowEvent, U as PassflowOidcError, J as PassflowRefreshError, ie as PopupClosedError, Ne as Providers, Pr as RECOVERABLE_COMMIT_ERROR_IDS, Xn as REFRESH_AUTH_FAILURE_IDS, q as RefreshErrorId, Oe as RequestMethod, l as SDK_VERSION, je as SERVICE_UNAVAILABLE_ERROR_ID, Me as SERVICE_UNAVAILABLE_MESSAGE, Fr as SESSION_INVALIDATING_COMMIT_ERROR_IDS, Ie as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, te as SessionState, ft as SettingAPI, v as TOKEN_EXPIRY_BUFFER_SECONDS, pt as TenantAPI, xi as TenantService, bi as TenantUserMembership, Si as TokenCacheService, N as TokenDeliveryMode, M as TokenType, vt as TwoFactorApiClient, Ve as TwoFactorPolicy, Ci as TwoFactorService, ue as UPGRADE_REQUIRED, b as USERNAME_MAX_LENGTH, y as USERNAME_MIN_LENGTH, yt as UpgradeAPI, Li as UpgradeCancelledError, cr as UpgradeCommitInterruptedError, Ki as UpgradeController, Q as UpgradeErrorIds, Ti as UpgradeFactorError, Jr as UpgradeInsufficientError, Xr as UpgradeSessionChangedError, $ as UpgradeTransportError, Yr as UpgradeUnavailableError, Ri as UpgradeUnsatisfiableError, bt as UserAPI, wi as UserService, F as WebAdapter, Gr as classifyUpgradeError, ji as factorRegistry, Ft as fetchRegistryState, ze as getOSFromDeviceType, qr as invalidatesSessionOnCommit, Ae as isEmailVerificationStep, Le as isMaskedSecret, Kr as isRecoverableCommitFailure, Lr as isRetryableUpgradeKind, A as isTokenExpired, xa as isUpgradeCancelled, Sa as isUpgradeExhausted, Ca as isUpgradeInsufficient, Ea as isUpgradeSessionChanged, Vr as isUpgradeTransportError, Da as isUpgradeTransportFailure, Ta as isUpgradeUnavailable, wa as isUpgradeUnsatisfiable, ti as isValidEmail, $r as isValidJWTFormat, ni as isValidPhoneNumber, ri as isValidUsername, ge as parseChallengeBody, he as parseChallengeHeader, j as parseToken, be as parseUpgradeChallenge, ki as passkeyFactor, Be as pathWithParams, Oi as recoveryCodesFactor, Pt as registerFetchMiddleware, ce as requiredAcrLevel, ke as resolveUpgradeDomain, ei as sanitizeErrorMessage, Ii as selectFactors, Di as totpFactor, ae as webAdapter };
7214
+ yo = bo, yo.version = l;
7215
+ export { a as APP_ID_HEADER_KEY, Pe as APP_SECRET_NAMES, o as AUTHORIZATION_HEADER_KEY, it as AppAPI, ut as AuthAPI, yi as AuthService, dt as CLIAuthAPI, p as DEFAULT_GROUP_NAME, d as DEFAULT_SCOPES, ji as DEFAULT_UPGRADE_FACTORS, s as DEVICE_ID_HEADER_KEY, c as DEVICE_TYPE_HEADER_KEY, x as ERROR_MESSAGE_MAX_LENGTH, St as FETCH_PRIORITY_OIDC, Ct as FETCH_PRIORITY_UPGRADE, wt as FetchMiddlewareContractError, le as INSUFFICIENT_USER_AUTHENTICATION, ft as InvitationAPI, bi as InvitationService, Wt as M2MClient, zt as M2MConfigError, H as M2MError, Bt as M2MErrorCodes, Lt as M2MNetworkError, Rt as M2MTokenParseError, Vt as M2M_DEFAULTS, Fe as MASKED_SECRET_PREFIX, u as MINIMAL_DEFAULT_SCOPES, Re as OS, f as PASSFLOW_CLOUD_URL, h as POPUP_HEIGHT, g as POPUP_POLL_INTERVAL_MS, _ as POPUP_TIMEOUT_MS, m as POPUP_WIDTH, bo as Passflow, B as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, V as PassflowError, Z as PassflowEvent, U as PassflowOidcError, J as PassflowRefreshError, ie as PopupClosedError, Ne as Providers, Fr as RECOVERABLE_COMMIT_ERROR_IDS, Zn as REFRESH_AUTH_FAILURE_IDS, q as RefreshErrorId, Oe as RequestMethod, l as SDK_VERSION, je as SERVICE_UNAVAILABLE_ERROR_ID, Me as SERVICE_UNAVAILABLE_MESSAGE, Ir as SESSION_INVALIDATING_COMMIT_ERROR_IDS, Ie as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, te as SessionState, pt as SettingAPI, v as TOKEN_EXPIRY_BUFFER_SECONDS, mt as TenantAPI, Si as TenantService, xi as TenantUserMembership, Ci as TokenCacheService, N as TokenDeliveryMode, M as TokenType, yt as TwoFactorApiClient, Ve as TwoFactorPolicy, wi as TwoFactorService, ue as UPGRADE_REQUIRED, b as USERNAME_MAX_LENGTH, y as USERNAME_MIN_LENGTH, bt as UpgradeAPI, Ri as UpgradeCancelledError, lr as UpgradeCommitInterruptedError, qi as UpgradeController, Q as UpgradeErrorIds, Ei as UpgradeFactorError, Yr as UpgradeInsufficientError, Zr as UpgradeSessionChangedError, $ as UpgradeTransportError, Xr as UpgradeUnavailableError, zi as UpgradeUnsatisfiableError, xt as UserAPI, Ti as UserService, F as WebAdapter, Kr as classifyUpgradeError, Mi as factorRegistry, It as fetchRegistryState, ze as getOSFromDeviceType, Jr as invalidatesSessionOnCommit, Ae as isEmailVerificationStep, Le as isMaskedSecret, qr as isRecoverableCommitFailure, Rr as isRetryableUpgradeKind, A as isTokenExpired, Sa as isUpgradeCancelled, Ca as isUpgradeExhausted, wa as isUpgradeInsufficient, Da as isUpgradeSessionChanged, Hr as isUpgradeTransportError, Oa as isUpgradeTransportFailure, Ea as isUpgradeUnavailable, Ta as isUpgradeUnsatisfiable, ni as isValidEmail, ei as isValidJWTFormat, ri as isValidPhoneNumber, ii as isValidUsername, ge as parseChallengeBody, he as parseChallengeHeader, j as parseToken, be as parseUpgradeChallenge, Ai as passkeyFactor, Be as pathWithParams, ki as recoveryCodesFactor, Ft as registerFetchMiddleware, ce as requiredAcrLevel, ke as resolveUpgradeDomain, ti as sanitizeErrorMessage, Li as selectFactors, Oi as totpFactor, ae as webAdapter };
7199
7216
 
7200
7217
  //# sourceMappingURL=index.mjs.map