@passflow/core 0.48.1 → 0.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -11,7 +11,7 @@ var a = "__passflowAntiBot", o = (e, t) => {
11
11
  if (typeof e != "object" || !e) return;
12
12
  let t = e[a];
13
13
  return typeof t == "object" && t ? t : void 0;
14
- }, c = "0.48.1", l = "X-Passflow-Clientid", u = "Authorization", d = "X-Passflow-DeviceId", f = "X-Passflow-DeviceType", p = "X-Passflow-Anti-Bot", m = "X-Passflow-Agent-Tool", h = "X-Passflow-Device-Proof", g = "X-Passflow-Fingerprint-Event", _ = "X-Passflow-Stytch-Telemetry", v = "passflow_auth", y = c, b = [
14
+ }, c = "0.49.1", l = "X-Passflow-Clientid", u = "Authorization", d = "X-Passflow-DeviceId", f = "X-Passflow-DeviceType", p = "X-Passflow-Anti-Bot", m = "X-Passflow-Agent-Tool", h = "X-Passflow-Device-Proof", g = "X-Passflow-Fingerprint-Event", _ = "X-Passflow-Stytch-Telemetry", v = "passflow_auth", y = c, b = [
15
15
  "id",
16
16
  "offline",
17
17
  "openid"
@@ -5921,13 +5921,27 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
5921
5921
  getInvitationLink(e) {
5922
5922
  return this.invitationApi.getInvitationLink(e);
5923
5923
  }
5924
- }, wo = class {
5924
+ };
5925
+ // lib/services/tenant-user-membership.ts
5926
+ function wo(e) {
5927
+ return {
5928
+ id: e.id,
5929
+ name: To(e),
5930
+ email: e.email || null,
5931
+ phone: e.phone || null
5932
+ };
5933
+ }
5934
+ function To(e) {
5935
+ let t = [e.given_name, e.family_name].filter(Boolean).join(" ");
5936
+ return e.preferred_username || t || e.nickname || e.username || null;
5937
+ }
5938
+ var Eo = class {
5925
5939
  constructor(e) {
5926
5940
  this.data = this.normalize(e);
5927
5941
  }
5928
5942
  normalize(e) {
5929
5943
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = [];
5930
- return e.groups?.forEach((e) => {
5944
+ e.groups?.forEach((e) => {
5931
5945
  n.set(e.id, {
5932
5946
  id: e.id,
5933
5947
  name: e.name,
@@ -5941,19 +5955,13 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
5941
5955
  tenant_id: e.tenant_id,
5942
5956
  name: e.name
5943
5957
  });
5944
- }), e.users_in_groups?.forEach((e) => {
5945
- let r = e.user;
5946
- r && !t.has(r.id) && t.set(r.id, {
5947
- id: r.id,
5948
- name: r.name ?? null,
5949
- email: r.email ?? null,
5950
- phone: r.phone ?? null
5951
- }), r && e.group_id && n.has(e.group_id) && i.push({
5952
- userId: r.id,
5953
- groupId: e.group_id,
5954
- roleIds: e.roles?.map((e) => e.id) ?? []
5955
- });
5956
- }), {
5958
+ });
5959
+ for (let [r, a] of Object.entries(e.users_in_groups ?? {})) for (let e of a ?? []) e?.id && (t.has(e.id) || t.set(e.id, wo(e)), n.has(r) && i.push({
5960
+ userId: e.id,
5961
+ groupId: r,
5962
+ roleIds: Object.keys(e.roles ?? {})
5963
+ }));
5964
+ return {
5957
5965
  tenant_id: e.tenant_id,
5958
5966
  tenant_name: e.tenant_name,
5959
5967
  users: Array.from(t.values()),
@@ -5978,7 +5986,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
5978
5986
  getData() {
5979
5987
  return this.data;
5980
5988
  }
5981
- }, To = "[passflow] The access token has no tenant membership (no passflow_tm claim): the sign-in did not ask for the tenant scope. Add 'access:tenant:all' to your scopes (for example PassflowProvider `scopes`) and sign in again. A token refresh keeps the old scopes, so refreshing does not fix this.", Eo = class {
5989
+ }, Do = "[passflow] The access token has no tenant membership (no passflow_tm claim): the sign-in did not ask for the tenant scope. Add 'access:tenant:all' to your scopes (for example PassflowProvider `scopes`) and sign in again. A token refresh keeps the old scopes, so refreshing does not fix this.", Oo = class {
5982
5990
  constructor(e, t, n, r) {
5983
5991
  this.tenantApi = e, this.scopes = t, this.readStoredAccessToken = r, this.tenantScopeWarned = !1, this.logger = n || li();
5984
5992
  }
@@ -5992,7 +6000,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
5992
6000
  } catch {
5993
6001
  return;
5994
6002
  }
5995
- t.passflow_tm === void 0 && (this.tenantScopeWarned = !0, this.logger.warn(To));
6003
+ t.passflow_tm === void 0 && (this.tenantScopeWarned = !0, this.logger.warn(Do));
5996
6004
  }
5997
6005
  handlePassflowError(t, n) {
5998
6006
  if (e.isAxiosError(t) && t.response?.data) {
@@ -6031,7 +6039,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
6031
6039
  async getTenantUserMembership(e) {
6032
6040
  this.warnIfNoTenantMembership();
6033
6041
  try {
6034
- return new wo(await this.tenantApi.getTenantDetails(e));
6042
+ return new Eo(await this.tenantApi.getTenantDetails(e));
6035
6043
  } catch (t) {
6036
6044
  this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
6037
6045
  }
@@ -6177,7 +6185,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
6177
6185
  this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
6178
6186
  }
6179
6187
  }
6180
- }, Do = class {
6188
+ }, ko = class {
6181
6189
  constructor(e, t, n, r = Ee) {
6182
6190
  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();
6183
6191
  }
@@ -6257,7 +6265,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
6257
6265
  isExpired() {
6258
6266
  return this.tokensCache ? this.tokensCache.access_token ? j(M(this.tokensCache.access_token)) : !1 : !0;
6259
6267
  }
6260
- }, Oo = class {
6268
+ }, Ao = class {
6261
6269
  constructor(e, t, n) {
6262
6270
  this.twoFactorApi = e, this.subscribeStore = t, this.signInCompleter = n, this.PARTIAL_AUTH_TIMEOUT_MS = 3e5, this.SESSION_STORAGE_KEY = "passflow_2fa_challenge", this.subscribeStore.subscribe({ onAuthChange: (e, t) => {
6263
6271
  if (e === G.TwoFactorRequired) {
@@ -6639,7 +6647,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
6639
6647
  this.emitErrorAndThrow(e, "2fa.preferred-method.clear", "Clear preferred 2FA method");
6640
6648
  }
6641
6649
  }
6642
- }, ko = class {
6650
+ }, jo = class {
6643
6651
  constructor(e, t, n = Ee) {
6644
6652
  this.userAPI = e, this.deviceService = t, this.platform = n;
6645
6653
  }
@@ -6681,77 +6689,90 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
6681
6689
  updateProfile(e, t) {
6682
6690
  return this.userAPI.updateProfile(e, t);
6683
6691
  }
6684
- }, Ao = class extends Error {
6692
+ }, Mo = class extends Error {
6685
6693
  constructor(e, t, n = !1) {
6686
6694
  super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
6687
6695
  }
6688
- }, jo = (e, t) => {
6696
+ }, No = (e, t) => {
6689
6697
  let n = t?.trim();
6690
- if (!n) throw new Ao(e, "A verification code is required");
6698
+ if (!n) throw new Mo(e, "A verification code is required");
6691
6699
  return n;
6692
- }, Mo = {
6700
+ }, Po = {
6693
6701
  type: "totp",
6694
6702
  requiresPrepare: !1,
6695
6703
  input: "code",
6696
- assert: async ({ code: e }) => ({ code: jo("totp", e) })
6697
- }, No = {
6704
+ assert: async ({ code: e }) => ({ code: No("totp", e) })
6705
+ }, Fo = {
6698
6706
  type: "recovery_codes",
6699
6707
  requiresPrepare: !1,
6700
6708
  input: "code",
6701
- assert: async ({ code: e }) => ({ code: jo("recovery_codes", e) })
6702
- }, Po = {
6709
+ assert: async ({ code: e }) => ({ code: No("recovery_codes", e) })
6710
+ }, Io = {
6703
6711
  type: "passkey",
6704
6712
  requiresPrepare: !0,
6705
6713
  input: "none",
6706
6714
  assert: async ({ prepared: e, platform: t }) => {
6707
- if (!e?.webauthn) throw new Ao("passkey", "The upgrade challenge carried no WebAuthn options");
6715
+ if (!e?.webauthn) throw new Mo("passkey", "The upgrade challenge carried no WebAuthn options");
6708
6716
  let n = t.passkeys;
6709
- if (!n) throw new Ao("passkey", "This platform does not support passkeys");
6717
+ if (!n) throw new Mo("passkey", "This platform does not support passkeys");
6710
6718
  let r;
6711
6719
  try {
6712
6720
  r = await n.startAuthentication(e.webauthn);
6713
6721
  } catch (e) {
6714
- throw new Ao("passkey", e?.message || "Passkey verification was cancelled", !0);
6722
+ throw new Mo("passkey", e?.message || "Passkey verification was cancelled", !0);
6715
6723
  }
6716
- if (!r) throw new Ao("passkey", "Passkey verification was cancelled", !0);
6724
+ if (!r) throw new Mo("passkey", "Passkey verification was cancelled", !0);
6717
6725
  return {
6718
6726
  challenge_id: e.challengeId,
6719
6727
  credential: r
6720
6728
  };
6721
6729
  }
6722
- }, Fo = Object.freeze([
6723
- Mo,
6730
+ }, Lo = (e) => ({
6731
+ type: e,
6732
+ requiresPrepare: !0,
6733
+ input: "code",
6734
+ assert: ({ code: t, prepared: n }) => new Promise((r) => {
6735
+ if (!n?.challengeId) throw new Mo(e, "No verification code has been sent yet");
6736
+ r({
6737
+ challenge_id: n.challengeId,
6738
+ code: No(e, t)
6739
+ });
6740
+ })
6741
+ }), Ro = Lo("email_otp"), zo = Lo("sms_otp"), Bo = (e) => e.requiresPrepare && e.input === "code", Vo = Object.freeze([
6724
6742
  Po,
6725
- No
6726
- ]), Io = (e = Fo) => new Map(e.map((e) => [e.type, e])), Lo = 3, Ro = {
6743
+ Io,
6744
+ Ro,
6745
+ zo,
6746
+ Fo
6747
+ ]), Ho = (e = Vo) => new Map(e.map((e) => [e.type, e])), Uo = 3, Wo = {
6727
6748
  totp: 0,
6728
6749
  passkey: 1,
6729
6750
  email_otp: 2,
6730
6751
  sms_otp: 3,
6731
6752
  recovery_codes: 9
6732
- }, zo = (e) => e.requiredLevel ?? je(e.acrValues), Bo = (e, t) => {
6733
- let n = Ro[e.type] ?? 5, r = t !== void 0 && t >= Lo, i = e.type === "passkey";
6753
+ }, Go = (e) => e.requiredLevel ?? je(e.acrValues), Ko = (e, t) => {
6754
+ let n = Wo[e.type] ?? 5, r = t !== void 0 && t >= Uo, i = e.type === "passkey";
6734
6755
  return (r && !i ? 100 : 0) + n;
6735
- }, Vo = (e, t) => {
6756
+ }, qo = (e, t) => {
6736
6757
  if (t.availableFactors) return t.availableFactors.flatMap((t) => e.find((e) => e.type === t) ?? []);
6737
- let n = zo(t);
6738
- return [...e].sort((e, t) => Bo(e, n) - Bo(t, n));
6739
- }, Ho = class extends Error {
6758
+ let n = Go(t);
6759
+ return [...e].sort((e, t) => Ko(e, n) - Ko(t, n));
6760
+ }, Jo = class extends Error {
6740
6761
  constructor(e) {
6741
6762
  super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
6742
6763
  }
6743
- }, Uo = class extends Error {
6764
+ }, Yo = class extends Error {
6744
6765
  constructor(e = "Only a fresh sign-in can meet this challenge") {
6745
6766
  super(e), this.code = "upgrade_sign_in_required", this.name = "UpgradeSignInRequiredError";
6746
6767
  }
6747
- }, Wo = (e) => e?.signInRequired === !0 || e?.signInRequired === void 0 && e?.availableFactors?.length === 0, Go = (e) => e?.signInRequired === !1 && e.availableFactors?.length === 0, Ko = "This account has no factor that reaches the required level (it may need a device-bound passkey)", qo = (e) => {
6748
- if (Wo(e)) return new Uo();
6749
- if (Go(e)) return new Jo(Ko);
6750
- }, Jo = class extends Error {
6768
+ }, Xo = (e) => e?.signInRequired === !0 || e?.signInRequired === void 0 && e?.availableFactors?.length === 0, Zo = (e) => e?.signInRequired === !1 && e.availableFactors?.length === 0, Qo = "This account has no factor that reaches the required level (it may need a device-bound passkey)", $o = (e) => {
6769
+ if (Xo(e)) return new Yo();
6770
+ if (Zo(e)) return new es(Qo);
6771
+ }, es = class extends Error {
6751
6772
  constructor(e = "No available authentication factor can satisfy this challenge") {
6752
6773
  super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
6753
6774
  }
6754
- }, Yo = 4, Xo = 3e4, Zo = () => {
6775
+ }, ts = 4, ns = 3e4, rs = () => {
6755
6776
  let e = () => void 0, t = () => void 0;
6756
6777
  return {
6757
6778
  promise: new Promise((n, r) => {
@@ -6760,12 +6781,12 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
6760
6781
  resolve: e,
6761
6782
  reject: t
6762
6783
  };
6763
- }, Qo = (e) => ({
6784
+ }, is = (e) => ({
6764
6785
  acrValues: e.acrValues,
6765
6786
  level: e.requiredLevel,
6766
6787
  maxAge: e.maxAge
6767
- }), $o = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, es = (e, t) => {
6768
- let n = e.requiredLevel === void 0 ? t.requiredLevel : t.requiredLevel === void 0 ? e.requiredLevel : Math.max(e.requiredLevel, t.requiredLevel), r = n === void 0 ? e.acrValues ?? t.acrValues : n === e.requiredLevel ? e.acrValues : t.acrValues, i = e.maxAge === void 0 ? t.maxAge : t.maxAge === void 0 ? e.maxAge : Math.min(e.maxAge, t.maxAge), a = Array.from(/* @__PURE__ */ new Set([...e.channels ?? [], ...t.channels ?? []])), { availableFactors: o, signInRequired: s } = ts(t, e) && !ts(e, t) || !t.availableFactors ? e : t;
6788
+ }), as = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, os = (e, t) => {
6789
+ let n = e.requiredLevel === void 0 ? t.requiredLevel : t.requiredLevel === void 0 ? e.requiredLevel : Math.max(e.requiredLevel, t.requiredLevel), r = n === void 0 ? e.acrValues ?? t.acrValues : n === e.requiredLevel ? e.acrValues : t.acrValues, i = e.maxAge === void 0 ? t.maxAge : t.maxAge === void 0 ? e.maxAge : Math.min(e.maxAge, t.maxAge), a = Array.from(/* @__PURE__ */ new Set([...e.channels ?? [], ...t.channels ?? []])), { availableFactors: o, signInRequired: s } = ss(t, e) && !ss(e, t) || !t.availableFactors ? e : t;
6769
6790
  return {
6770
6791
  acrValues: r,
6771
6792
  requiredLevel: n,
@@ -6775,12 +6796,12 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
6775
6796
  ...o ? { availableFactors: o } : {},
6776
6797
  ...s === void 0 ? {} : { signInRequired: s }
6777
6798
  };
6778
- }, ts = (e, t) => {
6799
+ }, ss = (e, t) => {
6779
6800
  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);
6780
6801
  return n || r;
6781
- }, ns = class {
6802
+ }, cs = class {
6782
6803
  constructor(e) {
6783
- this.state = "idle", this.inFlight = null, this.requirement = null, this.selected = null, this.rankedRequirement = null, this.registrations = [], this.proof = null, this.pruned = /* @__PURE__ */ new Set(), this.openPrompt = null, this.transport = e.transport, this.prompt = e.prompt, this.platform = e.platform, this.available = e.factors ?? Fo, this.registry = Io(this.available), this.maxAttempts = e.maxAttempts ?? Yo, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? Xo;
6804
+ 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.heldCode = null, this.codeSent = null, this.codeSentChallenge = null, this.transport = e.transport, this.prompt = e.prompt, this.platform = e.platform, this.available = e.factors ?? Vo, this.registry = Ho(this.available), this.maxAttempts = e.maxAttempts ?? ts, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? ns;
6784
6805
  }
6785
6806
  get currentState() {
6786
6807
  return this.state;
@@ -6800,9 +6821,9 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
6800
6821
  }
6801
6822
  register(e, t) {
6802
6823
  let n = t.kind === "imperative" && t.requested !== void 0, r = {
6803
- demanded: t.kind === "imperative" && t.requested ? t.requested : Qo(e),
6824
+ demanded: t.kind === "imperative" && t.requested ? t.requested : is(e),
6804
6825
  statedBar: n,
6805
- settlement: Zo(),
6826
+ settlement: rs(),
6806
6827
  reported: !1,
6807
6828
  entry: {
6808
6829
  ...t,
@@ -6818,15 +6839,15 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
6818
6839
  this.requirement = e;
6819
6840
  return;
6820
6841
  }
6821
- let n = ts(t, e);
6822
- this.requirement = es(t, e), qo(this.requirement) ? this.state === "collecting" && this.selected === null && (this.openPrompt?.onClosed?.(), this.closeOpenPrompt?.()) : n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
6842
+ let n = ss(t, e);
6843
+ this.requirement = os(t, e), $o(this.requirement) ? this.state === "collecting" && this.selected === null && (this.openPrompt?.onClosed?.(), this.closeOpenPrompt?.()) : n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
6823
6844
  challenge: this.requirement,
6824
6845
  factors: this.offeredFactors()
6825
6846
  });
6826
6847
  }
6827
6848
  offeredFactors() {
6828
6849
  let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
6829
- return t ? Vo(e, t) : e;
6850
+ return t ? qo(e, t) : e;
6830
6851
  }
6831
6852
  receiveReport(e, t) {
6832
6853
  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());
@@ -6857,11 +6878,11 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
6857
6878
  try {
6858
6879
  this.onFlightSettled?.(t);
6859
6880
  } catch {}
6860
- this.state = "done", 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.reportsSettled = void 0, this.state = "idle";
6881
+ this.state = "done", 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.heldCode = null, this.codeSent = null, this.codeSentChallenge = null, this.reportsSettled = void 0, this.state = "idle";
6861
6882
  }
6862
6883
  release(e, t) {
6863
6884
  if (e.entry.kind === "imperative") {
6864
- if (e.statedBar && !$o(t, e.demanded)) {
6885
+ if (e.statedBar && !as(t, e.demanded)) {
6865
6886
  this.receiveReport(e, {
6866
6887
  outcome: "insufficient",
6867
6888
  obtained: t,
@@ -6936,52 +6957,52 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
6936
6957
  async prove() {
6937
6958
  let e;
6938
6959
  for (let t = 0; t < this.maxAttempts; t++) {
6939
- let t = qo(this.requirement);
6940
- if (t) return {
6960
+ let n = $o(this.requirement);
6961
+ if (n) return {
6941
6962
  status: "failed",
6942
- reason: t
6963
+ reason: n
6943
6964
  };
6944
- let n = this.offeredFactors();
6945
- if (n.length === 0) return {
6965
+ let r = this.offeredFactors();
6966
+ if (r.length === 0) return {
6946
6967
  status: "failed",
6947
- reason: new Jo()
6968
+ reason: new es()
6948
6969
  };
6949
- let r = this.requirement, i;
6970
+ let i = this.requirement, a;
6950
6971
  try {
6951
- i = await this.collect(r, n, e);
6972
+ a = await this.collect(i, r, e);
6952
6973
  } catch (e) {
6953
6974
  return {
6954
6975
  status: "failed",
6955
- reason: new Ho(e)
6976
+ reason: new Jo(e)
6956
6977
  };
6957
6978
  }
6958
- let a = qo(this.requirement);
6959
- if (a) return {
6979
+ let o = $o(this.requirement);
6980
+ if (o) return {
6960
6981
  status: "failed",
6961
- reason: a
6982
+ reason: o
6962
6983
  };
6963
- if (i.type === "cancel") return {
6984
+ if (a.type === "cancel") return {
6964
6985
  status: "failed",
6965
- reason: new Ho()
6986
+ reason: new Jo()
6966
6987
  };
6967
- let o = this.registry.get(i.factor);
6968
- if (!o) e = new Jo(`Unknown authentication factor: ${i.factor}`), this.state = "collecting", this.selected = null;
6988
+ let s = this.registry.get(a.factor);
6989
+ if (!s) e = new es(`Unknown authentication factor: ${a.factor}`), this.state = "collecting", this.selected = null;
6969
6990
  else try {
6970
- return await this.proveAndCommit(o, i.code), {
6991
+ return await this.proveAndCommit(s, a.code, t < this.maxAttempts - 1), {
6971
6992
  status: "proven",
6972
- obtained: this.readObtainedBar?.() ?? Qo(this.rankedRequirement ?? r)
6993
+ obtained: this.readObtainedBar?.() ?? is(this.rankedRequirement ?? i)
6973
6994
  };
6974
6995
  } catch (t) {
6975
- if (t instanceof Ao && t.cancelled) return {
6996
+ if (t instanceof Mo && t.cancelled) return {
6976
6997
  status: "failed",
6977
- reason: new Ho()
6998
+ reason: new Jo()
6978
6999
  };
6979
7000
  let n = this.classifyProofFailure(t);
6980
7001
  if (n) return {
6981
7002
  status: "failed",
6982
7003
  reason: n
6983
7004
  };
6984
- t instanceof $ && t.kind === "not_registered" && this.pruned.add(o.type), e = t, this.state = "collecting", this.selected = null;
7005
+ t instanceof $ && t.kind === "not_registered" && this.pruned.add(s.type), e = t, this.state = "collecting", this.selected = null;
6985
7006
  }
6986
7007
  }
6987
7008
  return {
@@ -6997,8 +7018,18 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
6997
7018
  challenge: e,
6998
7019
  factors: t,
6999
7020
  ...n ? { previousError: n } : {},
7021
+ ...this.codeSent ? { codeSent: this.codeSent } : {},
7000
7022
  onFactorSelected: (e) => {
7001
7023
  this.state === "collecting" && (this.state = "proving"), this.selected = e, this.rankedRequirement = this.requirement;
7024
+ let t = this.registry.get(e);
7025
+ this.openPrompt === r && t && Bo(t) && this.heldCode?.factor !== e && this.sendCode(e).catch(() => void 0);
7026
+ },
7027
+ resend: async (e) => {
7028
+ let t = this.registry.get(e);
7029
+ if (!t || !Bo(t)) throw new Mo(e, "This factor does not send a code");
7030
+ if (this.openPrompt !== r) throw new Mo(e, "This step-up has ended");
7031
+ if (await this.sendCode(e, !0), !this.codeSent || this.codeSent.factor !== e) throw new Mo(e, "The server sent no code");
7032
+ return this.codeSent;
7002
7033
  }
7003
7034
  };
7004
7035
  this.openPrompt = r;
@@ -7023,36 +7054,89 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7023
7054
  default: return;
7024
7055
  }
7025
7056
  }
7026
- async proveAndCommit(e, t) {
7027
- let n = e.requiresPrepare ? await this.transport.prepare(e.type) : void 0, r = await e.assert({
7057
+ async proveAndCommit(e, t, n) {
7058
+ if (Bo(e)) {
7059
+ await this.proveSentCode(e, t, n);
7060
+ return;
7061
+ }
7062
+ let r = e.requiresPrepare ? await this.transport.prepare(e.type) : void 0, i = await e.assert({
7063
+ code: t,
7064
+ prepared: r,
7065
+ platform: this.platform
7066
+ });
7067
+ await this.transport.commit(e.type, i);
7068
+ }
7069
+ async proveSentCode(e, t, n) {
7070
+ this.heldCode?.factor !== e.type && this.sendCode(e.type).catch(() => void 0);
7071
+ let r = this.heldCode, i;
7072
+ try {
7073
+ i = await r.prepared;
7074
+ } catch (e) {
7075
+ throw this.heldCode === r && (this.heldCode = null), e;
7076
+ }
7077
+ let a = await e.assert({
7028
7078
  code: t,
7029
- prepared: n,
7079
+ prepared: i,
7030
7080
  platform: this.platform
7031
7081
  });
7032
- await this.transport.commit(e.type, r);
7082
+ try {
7083
+ await this.transport.commit(e.type, a);
7084
+ } catch (t) {
7085
+ if (t instanceof $ && t.kind === "challenge_spent") {
7086
+ if (!n) this.heldCode = null;
7087
+ else {
7088
+ let t = this.sendCode(e.type), n = this.heldCode;
7089
+ try {
7090
+ await t;
7091
+ } catch (e) {
7092
+ throw this.heldCode === n && (this.heldCode = null), e;
7093
+ }
7094
+ }
7095
+ }
7096
+ throw t;
7097
+ }
7098
+ this.heldCode = null, this.codeSent = null, this.codeSentChallenge = null;
7033
7099
  }
7034
- }, rs = (e) => typeof e == "function" ? e() : e, is = (e) => {
7100
+ sendCode(e, t = !1) {
7101
+ let n = this.heldCode?.factor === e ? {
7102
+ hold: this.heldCode,
7103
+ codeSent: this.codeSent,
7104
+ challenge: this.codeSentChallenge
7105
+ } : null, r = this.transport.prepare(e, t ? { resend: !0 } : void 0), i = {
7106
+ factor: e,
7107
+ prepared: r
7108
+ };
7109
+ return this.heldCode = i, n || (this.codeSent = null, this.codeSentChallenge = null), r.then((t) => (this.heldCode === i && (this.codeSent = t ? {
7110
+ factor: e,
7111
+ expiresAt: t.expiresAt,
7112
+ ...t.codeSentTo ? { codeSentTo: t.codeSentTo } : {},
7113
+ resent: n?.challenge != null && n.challenge !== t.challengeId
7114
+ } : null, this.codeSentChallenge = t?.challengeId ?? null, this.codeSent && this.openPrompt?.onCodeSent?.(this.codeSent)), t), (e) => {
7115
+ throw this.heldCode === i && n && t && (this.heldCode = n.hold, this.codeSent = n.codeSent, this.codeSentChallenge = n.challenge), e;
7116
+ });
7117
+ }
7118
+ }, ls = (e) => typeof e == "function" ? e() : e, us = (e) => {
7035
7119
  try {
7036
7120
  return new URL(e);
7037
7121
  } catch {
7038
7122
  return;
7039
7123
  }
7040
- }, as = (e, t) => {
7124
+ }, ds = (e, t) => {
7041
7125
  if (!t || t === "/") return !0;
7042
7126
  let n = t.replace(/\/+$/, "");
7043
7127
  return e === n || e.startsWith(`${n}/`);
7044
- }, os = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && as(e.pathname, t.pathPrefix), ss = (e, t) => {
7128
+ }, fs = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && ds(e.pathname, t.pathPrefix), ps = (e, t) => {
7045
7129
  for (let n of t) {
7046
7130
  if (n === "") continue;
7047
7131
  if (n.startsWith("/")) {
7048
- if (e.relativeToBase && as(e.pathname, n)) return !0;
7132
+ if (e.relativeToBase && ds(e.pathname, n)) return !0;
7049
7133
  continue;
7050
7134
  }
7051
- let t = is(n) ?? is(`https://${n}`);
7052
- if (t && e.origin !== void 0 && e.origin === t.origin && as(e.pathname, t.pathname)) return !0;
7135
+ let t = us(n) ?? us(`https://${n}`);
7136
+ if (t && e.origin !== void 0 && e.origin === t.origin && ds(e.pathname, t.pathname)) return !0;
7053
7137
  }
7054
7138
  return !1;
7055
- }, cs = (e, t, n) => os(e, t.passflow) || ss(e, t.backend) ? !n || n(e.href) !== !1 : !1, ls = (e) => {
7139
+ }, ms = (e, t, n) => fs(e, t.passflow) || ps(e, t.backend) ? !n || n(e.href) !== !1 : !1, hs = (e) => {
7056
7140
  let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
7057
7141
  console.warn(n, {
7058
7142
  status: e.status,
@@ -7060,8 +7144,8 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7060
7144
  reason: e.reason,
7061
7145
  detail: t
7062
7146
  });
7063
- }, us = (e, t) => {
7064
- let n = t.onUpgradeDiagnostic ?? ls;
7147
+ }, gs = (e, t) => {
7148
+ let n = t.onUpgradeDiagnostic ?? hs;
7065
7149
  return (t, r) => {
7066
7150
  n({
7067
7151
  status: e.status,
@@ -7073,8 +7157,8 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7073
7157
  }
7074
7158
  });
7075
7159
  };
7076
- }, ds = (e, t, n) => {
7077
- let r = n.onUpgradeDiagnostic ?? ls;
7160
+ }, _s = (e, t, n) => {
7161
+ let r = n.onUpgradeDiagnostic ?? hs;
7078
7162
  for (let n of e) r({
7079
7163
  ...n,
7080
7164
  url: t.request.href,
@@ -7083,8 +7167,8 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7083
7167
  ...n.detail ?? {}
7084
7168
  }
7085
7169
  });
7086
- }, fs = /\bjson\b/i, ps = async (e, t) => {
7087
- let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && fs.test(r), a;
7170
+ }, vs = /\bjson\b/i, ys = async (e, t) => {
7171
+ let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && vs.test(r), a;
7088
7172
  if (i) try {
7089
7173
  a = await e.readBody();
7090
7174
  } catch {
@@ -7098,10 +7182,10 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7098
7182
  status: e.status,
7099
7183
  getHeader: (t) => e.getHeader(t) ?? void 0
7100
7184
  }, { requireChallengeChannel: t.requireChallengeChannel });
7101
- }, ms = (e) => Ue({
7185
+ }, bs = (e) => Ue({
7102
7186
  status: e.status,
7103
7187
  getHeader: (t) => e.getHeader(t) ?? void 0
7104
- }, { requireChallengeChannel: "header" }).challenge, hs = (e, t) => t.passflow === null ? `[passflow] a 401/403 from ${e} carried an upgrade challenge, but no Passflow endpoint is configured — set \`url\` on the Passflow config.` : `[passflow] a 401/403 from ${e} carried an upgrade challenge, but that URL is not covered by the provider's \`backend\` prop — add it there to enable step-up for this API.`, gs = (e, t) => e instanceof Ho ? { kind: "cancelled" } : e instanceof Uo ? { kind: "sign-in-required" } : e instanceof Jo ? {
7188
+ }, { requireChallengeChannel: "header" }).challenge, xs = (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.`, Ss = (e, t) => e instanceof Jo ? { kind: "cancelled" } : e instanceof Yo ? { kind: "sign-in-required" } : e instanceof es ? {
7105
7189
  kind: "unsatisfiable",
7106
7190
  error: e
7107
7191
  } : e instanceof Ga ? { kind: "unavailable" } : e instanceof Ka ? { kind: "session-changed" } : e instanceof Wa ? {
@@ -7120,26 +7204,26 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7120
7204
  kind: "transport-failure",
7121
7205
  retryable: !1,
7122
7206
  error: e instanceof Error ? e : Error(String(e))
7123
- }, _s = async (e, t, n, r) => {
7207
+ }, Cs = async (e, t, n, r) => {
7124
7208
  if (e.status !== 401 && e.status !== 403) return {
7125
7209
  kind: "replayed",
7126
7210
  response: e
7127
7211
  };
7128
- let { challenge: i, diagnostics: a } = await ps(e, t);
7129
- if (ds(a, e, t), !i) return {
7212
+ let { challenge: i, diagnostics: a } = await ys(e, t);
7213
+ if (_s(a, e, t), !i) return {
7130
7214
  kind: "replayed",
7131
7215
  response: e
7132
7216
  };
7133
- if (Wo(i)) return {
7217
+ if (Xo(i)) return {
7134
7218
  kind: "sign-in-required",
7135
7219
  response: e
7136
7220
  };
7137
- if (Go(i)) return {
7221
+ if (Zo(i)) return {
7138
7222
  kind: "unsatisfiable",
7139
- error: qo(i),
7223
+ error: $o(i),
7140
7224
  response: e
7141
7225
  };
7142
- let o = Qo(i);
7226
+ let o = is(i);
7143
7227
  return r("elevated-insufficient", {
7144
7228
  obtained: n,
7145
7229
  required: o
@@ -7149,7 +7233,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7149
7233
  required: o,
7150
7234
  response: e
7151
7235
  };
7152
- }, vs = async (e, t) => {
7236
+ }, ws = async (e, t) => {
7153
7237
  if (!t) return {
7154
7238
  aborted: !1,
7155
7239
  value: await e
@@ -7176,14 +7260,14 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7176
7260
  } finally {
7177
7261
  n && t.removeEventListener?.("abort", n);
7178
7262
  }
7179
- }, ys = async (e, t) => {
7263
+ }, Ts = async (e, t) => {
7180
7264
  if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
7181
- let n = us(e, t);
7265
+ let n = gs(e, t);
7182
7266
  if (e.markers.replayed) {
7183
- if (!cs(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
7184
- let { challenge: r, diagnostics: i } = await ps(e, t);
7185
- if (ds(i, e, t), !r) return { kind: "not-a-challenge" };
7186
- let a = t.readObtainedBar?.() ?? {}, o = Qo(r);
7267
+ if (!ms(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
7268
+ let { challenge: r, diagnostics: i } = await ys(e, t);
7269
+ if (_s(i, e, t), !r) return { kind: "not-a-challenge" };
7270
+ let a = t.readObtainedBar?.() ?? {}, o = is(r);
7187
7271
  return n("elevated-insufficient", {
7188
7272
  obtained: a,
7189
7273
  required: o
@@ -7194,12 +7278,12 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7194
7278
  response: e
7195
7279
  };
7196
7280
  }
7197
- if (!cs(e.request, t.scope, t.shouldIntercept)) return ms(e) ? (n("challenge-out-of-scope", {
7281
+ if (!ms(e.request, t.scope, t.shouldIntercept)) return bs(e) ? (n("challenge-out-of-scope", {
7198
7282
  header: e.getHeader("www-authenticate") ?? void 0,
7199
- message: hs(e.request.href, t.scope)
7283
+ message: xs(e.request.href, t.scope)
7200
7284
  }), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
7201
- let { challenge: r, diagnostics: i } = await ps(e, t);
7202
- if (ds(i, e, t), !r) {
7285
+ let { challenge: r, diagnostics: i } = await ys(e, t);
7286
+ if (_s(i, e, t), !r) {
7203
7287
  let r = e.getHeader("www-authenticate");
7204
7288
  return t.requireChallengeChannel !== "header" && n("no-channel", {
7205
7289
  ...r ? { header: r } : {},
@@ -7213,9 +7297,9 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7213
7297
  method: e.request.method
7214
7298
  }, s, c;
7215
7299
  try {
7216
- s = Promise.resolve(t.elevate(r, o)), c = await vs(s, e.signal);
7300
+ s = Promise.resolve(t.elevate(r, o)), c = await ws(s, e.signal);
7217
7301
  } catch (e) {
7218
- return gs(e, void 0);
7302
+ return Ss(e, void 0);
7219
7303
  }
7220
7304
  if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
7221
7305
  kind: "aborted",
@@ -7226,7 +7310,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7226
7310
  kind: "aborted",
7227
7311
  reason: e.signal.reason
7228
7312
  };
7229
- let u = l?.obtained ?? t.readObtainedBar?.() ?? Qo(r), d = t.authorizationSwap?.(), f = d ? {
7313
+ let u = l?.obtained ?? t.readObtainedBar?.() ?? is(r), d = t.authorizationSwap?.(), f = d ? {
7230
7314
  from: a?.from ?? d.from,
7231
7315
  to: d.to
7232
7316
  } : void 0;
@@ -7253,7 +7337,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7253
7337
  };
7254
7338
  throw t;
7255
7339
  }
7256
- let m = await _s(p, t, u, n);
7340
+ let m = await Cs(p, t, u, n);
7257
7341
  return m.kind === "insufficient" ? l?.waiter.report({
7258
7342
  outcome: "insufficient",
7259
7343
  obtained: m.obtained,
@@ -7262,11 +7346,11 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7262
7346
  outcome: "replayed",
7263
7347
  obtained: u
7264
7348
  }), m;
7265
- }, bs = (e) => {
7349
+ }, Es = (e) => {
7266
7350
  switch (e.kind) {
7267
- case "cancelled": return new Ho();
7268
- case "unsatisfiable": return e.error ?? new Jo();
7269
- case "sign-in-required": return new Uo();
7351
+ case "cancelled": return new Jo();
7352
+ case "unsatisfiable": return e.error ?? new es();
7353
+ case "sign-in-required": return new Yo();
7270
7354
  case "unavailable": return new Ga();
7271
7355
  case "session-changed": return new Ka();
7272
7356
  case "insufficient": return new Wa(e.obtained, e.required);
@@ -7274,7 +7358,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7274
7358
  case "transport-failure": return e.error;
7275
7359
  default: return;
7276
7360
  }
7277
- }, xs = (e, t, n) => {
7361
+ }, Ds = (e, t, n) => {
7278
7362
  switch (e.kind) {
7279
7363
  case "replayed": return {
7280
7364
  settle: "resolve",
@@ -7292,26 +7376,26 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7292
7376
  };
7293
7377
  case "cancelled": return n.onCancel === "reject" ? {
7294
7378
  settle: "reject",
7295
- error: new Ho()
7379
+ error: new Jo()
7296
7380
  } : {
7297
7381
  settle: "resolve",
7298
- value: js(t, e)
7382
+ value: Ls(t, e)
7299
7383
  };
7300
7384
  case "unsatisfiable":
7301
7385
  case "sign-in-required": return {
7302
7386
  settle: "resolve",
7303
- value: js(e.response?.raw ?? t, e)
7387
+ value: Ls(e.response?.raw ?? t, e)
7304
7388
  };
7305
7389
  case "insufficient": return {
7306
7390
  settle: "resolve",
7307
- value: js(e.response?.raw ?? t, e)
7391
+ value: Ls(e.response?.raw ?? t, e)
7308
7392
  };
7309
7393
  default: return {
7310
7394
  settle: "resolve",
7311
- value: js(t, e)
7395
+ value: Ls(t, e)
7312
7396
  };
7313
7397
  }
7314
- }, Ss = (e, t) => {
7398
+ }, Os = (e, t) => {
7315
7399
  switch (e.kind) {
7316
7400
  case "replayed": return e.response.rejected ? {
7317
7401
  settle: "reject",
@@ -7326,42 +7410,42 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7326
7410
  };
7327
7411
  default: return {
7328
7412
  settle: "reject",
7329
- error: bs(e) ?? t
7413
+ error: Es(e) ?? t
7330
7414
  };
7331
7415
  }
7332
- }, Cs = /* @__PURE__ */ new WeakSet(), ws = /* @__PURE__ */ new WeakSet(), Ts = /* @__PURE__ */ new WeakSet(), Es = /* @__PURE__ */ new WeakSet(), Ds = /* @__PURE__ */ new WeakSet(), Os = /* @__PURE__ */ new WeakSet(), ks = /* @__PURE__ */ new WeakSet(), As = /* @__PURE__ */ new WeakSet(), js = (e, t) => {
7416
+ }, ks = /* @__PURE__ */ new WeakSet(), As = /* @__PURE__ */ new WeakSet(), js = /* @__PURE__ */ new WeakSet(), Ms = /* @__PURE__ */ new WeakSet(), Ns = /* @__PURE__ */ new WeakSet(), Ps = /* @__PURE__ */ new WeakSet(), Fs = /* @__PURE__ */ new WeakSet(), Is = /* @__PURE__ */ new WeakSet(), Ls = (e, t) => {
7333
7417
  switch (t.kind) {
7334
7418
  case "cancelled":
7335
- Cs.add(e);
7419
+ ks.add(e);
7336
7420
  break;
7337
7421
  case "exhausted":
7338
- ws.add(e);
7422
+ As.add(e);
7339
7423
  break;
7340
7424
  case "insufficient":
7341
- Ts.add(e);
7425
+ js.add(e);
7342
7426
  break;
7343
7427
  case "unsatisfiable":
7344
- Es.add(e);
7428
+ Ms.add(e);
7345
7429
  break;
7346
7430
  case "sign-in-required":
7347
- Ds.add(e);
7431
+ Ns.add(e);
7348
7432
  break;
7349
7433
  case "unavailable":
7350
- Os.add(e);
7434
+ Ps.add(e);
7351
7435
  break;
7352
7436
  case "session-changed":
7353
- ks.add(e);
7437
+ Fs.add(e);
7354
7438
  break;
7355
- case "transport-failure": As.add(e);
7439
+ case "transport-failure": Is.add(e);
7356
7440
  }
7357
7441
  return e;
7358
- }, Ms = (e) => Cs.has(e), Ns = (e) => ws.has(e), Ps = (e) => Ts.has(e), Fs = (e) => Es.has(e), Is = (e) => Ds.has(e), Ls = (e) => Os.has(e), Rs = (e) => ks.has(e), zs = (e) => As.has(e), Bs = "https://passflow-relative.invalid", Vs = () => {
7442
+ }, Rs = (e) => ks.has(e), zs = (e) => As.has(e), Bs = (e) => js.has(e), Vs = (e) => Ms.has(e), Hs = (e) => Ns.has(e), Us = (e) => Ps.has(e), Ws = (e) => Fs.has(e), Gs = (e) => Is.has(e), Ks = "https://passflow-relative.invalid", qs = () => {
7359
7443
  let e = globalThis, t = e.document?.baseURI;
7360
7444
  if (typeof t == "string" && t !== "") return t;
7361
7445
  let n = e.location?.href;
7362
- return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Bs;
7363
- }, Hs = (e, t = Vs()) => {
7364
- let n = t === Bs, r;
7446
+ return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Ks;
7447
+ }, Js = (e, t = qs()) => {
7448
+ let n = t === Ks, r;
7365
7449
  try {
7366
7450
  r = new URL(t).origin;
7367
7451
  } catch {
@@ -7387,28 +7471,28 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7387
7471
  relativeToBase: !1,
7388
7472
  sentinelBase: n
7389
7473
  };
7390
- }, Us = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Ws = (e) => {
7474
+ }, Ys = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Xs = (e) => {
7391
7475
  let t = [];
7392
7476
  if (e == null) return Object.freeze(t);
7393
7477
  let n = e;
7394
7478
  if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
7395
- let r = Us(n, e);
7479
+ let r = Ys(n, e);
7396
7480
  r && t.push(r);
7397
7481
  }), Object.freeze(t);
7398
7482
  if (Array.isArray(e)) {
7399
7483
  for (let n of e) if (Array.isArray(n) && n.length >= 2) {
7400
- let e = Us(String(n[0]), n[1]);
7484
+ let e = Ys(String(n[0]), n[1]);
7401
7485
  e && t.push(e);
7402
7486
  }
7403
7487
  return Object.freeze(t);
7404
7488
  }
7405
7489
  if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
7406
- let e = Us(n, Array.isArray(r) ? r.join(", ") : r);
7490
+ let e = Ys(n, Array.isArray(r) ? r.join(", ") : r);
7407
7491
  e && t.push(e);
7408
7492
  }
7409
7493
  return Object.freeze(t);
7410
- }, Gs = (e) => {
7411
- let t = e.base === void 0 ? Hs(e.url) : Hs(e.url, e.base), n = {
7494
+ }, Zs = (e) => {
7495
+ let t = e.base === void 0 ? Js(e.url) : Js(e.url, e.base), n = {
7412
7496
  raw: e.url,
7413
7497
  href: t.href,
7414
7498
  dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
@@ -7417,29 +7501,29 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7417
7501
  resolved: t.resolved,
7418
7502
  relativeToBase: t.relativeToBase,
7419
7503
  method: (e.method ?? "GET").toUpperCase(),
7420
- headers: Ws(e.headers),
7504
+ headers: Xs(e.headers),
7421
7505
  bodyKind: e.bodyKind,
7422
7506
  ..."body" in e ? { body: e.body } : {}
7423
7507
  };
7424
7508
  return Object.freeze(n);
7425
- }, Ks = (e, t) => {
7509
+ }, Qs = (e, t) => {
7426
7510
  if (!t || t.from === t.to) return e;
7427
7511
  let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
7428
7512
  return n ? Object.freeze(r) : e;
7429
- }, qs = (e) => {
7513
+ }, $s = (e) => {
7430
7514
  let t = {};
7431
7515
  for (let [n, r] of e) t[n] = r;
7432
7516
  return t;
7433
- }, Js = /* @__PURE__ */ new Set([
7517
+ }, ec = /* @__PURE__ */ new Set([
7434
7518
  "GET",
7435
7519
  "HEAD",
7436
7520
  "OPTIONS"
7437
- ]), Ys = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, Xs = (e) => typeof e == "string" ? e : Ys(e) ? e.url : String(e), Zs = (e, t) => (t?.method ?? (Ys(e) ? e.method : void 0) ?? "GET").toUpperCase(), Qs = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", $s = (e) => {
7521
+ ]), tc = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, nc = (e) => typeof e == "string" ? e : tc(e) ? e.url : String(e), rc = (e, t) => (t?.method ?? (tc(e) ? e.method : void 0) ?? "GET").toUpperCase(), ic = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", ac = (e) => {
7438
7522
  if (typeof e == "string") return e.length;
7439
7523
  let t = e;
7440
7524
  if (typeof t?.size == "number") return t.size;
7441
7525
  if (typeof t?.byteLength == "number") return t.byteLength;
7442
- }, ec = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? Js.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), tc = (e, t, n, r, i) => ({
7526
+ }, oc = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? ec.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), sc = (e, t, n, r, i) => ({
7443
7527
  replayable: !1,
7444
7528
  bodyKind: e,
7445
7529
  reason: t,
@@ -7447,11 +7531,11 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7447
7531
  forwardInit: i,
7448
7532
  snapshot: r,
7449
7533
  replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
7450
- }), nc = (e, t) => qs(Ks(e.headers, t?.authorizationSwap)), rc = (e) => {
7534
+ }), cc = (e, t) => $s(Qs(e.headers, t?.authorizationSwap)), lc = (e) => {
7451
7535
  if (!e || !("headers" in e)) return e;
7452
7536
  let { headers: t, ...n } = e;
7453
7537
  return n;
7454
- }, ic = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : Ys(e) ? e.headers : void 0, ac = (e) => {
7538
+ }, uc = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : tc(e) ? e.headers : void 0, dc = (e) => {
7455
7539
  if (e === null || typeof e == "string") return e;
7456
7540
  if (typeof FormData < "u" && e instanceof FormData) {
7457
7541
  let t = new FormData();
@@ -7459,18 +7543,18 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7459
7543
  return t;
7460
7544
  }
7461
7545
  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;
7462
- }, oc = (e, t, n) => new Request(e, { headers: nc(t, n) }), sc = (e, t, n) => {
7463
- let r = Xs(e), i = Zs(e, t), a = ic(e, t), o = (e, t) => Gs({
7546
+ }, fc = (e, t, n) => new Request(e, { headers: cc(t, n) }), pc = (e, t, n) => {
7547
+ let r = nc(e), i = rc(e, t), a = uc(e, t), o = (e, t) => Zs({
7464
7548
  url: r,
7465
7549
  method: i,
7466
7550
  headers: a,
7467
7551
  bodyKind: e,
7468
7552
  ...t === void 0 ? {} : { body: t }
7469
7553
  });
7470
- if (Ys(e)) {
7554
+ if (tc(e)) {
7471
7555
  if (e.body === null || e.body === void 0) {
7472
7556
  let a = o("none");
7473
- return ec(n, {
7557
+ return oc(n, {
7474
7558
  url: r,
7475
7559
  method: i,
7476
7560
  bodyKind: "none"
@@ -7480,20 +7564,20 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7480
7564
  forwardInput: e,
7481
7565
  forwardInit: t,
7482
7566
  snapshot: a,
7483
- replay: (n, r) => n(oc(e, a, r), rc(t))
7484
- } : tc("none", "the replay policy refused this request", e, a, t);
7567
+ replay: (n, r) => n(fc(e, a, r), lc(t))
7568
+ } : sc("none", "the replay policy refused this request", e, a, t);
7485
7569
  }
7486
7570
  let a = o("request-clone");
7487
- if (!ec(n, {
7571
+ if (!oc(n, {
7488
7572
  url: r,
7489
7573
  method: i,
7490
7574
  bodyKind: "request-clone"
7491
- })) return tc("request-clone", "the replay policy refused this request", e, a, t);
7575
+ })) return sc("request-clone", "the replay policy refused this request", e, a, t);
7492
7576
  let s;
7493
7577
  try {
7494
7578
  s = e.clone();
7495
7579
  } catch {
7496
- return tc("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
7580
+ return sc("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
7497
7581
  }
7498
7582
  return {
7499
7583
  replayable: !0,
@@ -7501,17 +7585,17 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7501
7585
  forwardInput: e,
7502
7586
  forwardInit: t,
7503
7587
  snapshot: a,
7504
- replay: (e, n) => e(oc(s, a, n), rc(t))
7588
+ replay: (e, n) => e(fc(s, a, n), lc(t))
7505
7589
  };
7506
7590
  }
7507
- let s = Qs(t?.body);
7508
- if (s === "one-shot") return tc("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
7509
- if (!ec(n, {
7591
+ let s = ic(t?.body);
7592
+ if (s === "one-shot") return sc("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
7593
+ if (!oc(n, {
7510
7594
  url: r,
7511
7595
  method: i,
7512
7596
  bodyKind: s
7513
- }, $s(t?.body))) return tc(s, "the replay policy refused this request", e, o(s), t);
7514
- let c = t && "body" in t ? ac(t.body ?? null) : void 0, l = o(s, c);
7597
+ }, ac(t?.body))) return sc(s, "the replay policy refused this request", e, o(s), t);
7598
+ let c = t && "body" in t ? dc(t.body ?? null) : void 0, l = o(s, c);
7515
7599
  return {
7516
7600
  replayable: !0,
7517
7601
  bodyKind: s,
@@ -7519,21 +7603,21 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7519
7603
  forwardInit: t,
7520
7604
  snapshot: l,
7521
7605
  replay: (e, n) => e(l.dispatchUrl, {
7522
- ...rc(t),
7606
+ ...lc(t),
7523
7607
  ...c === void 0 ? {} : { body: c },
7524
- headers: nc(l, n),
7608
+ headers: cc(l, n),
7525
7609
  method: l.method
7526
7610
  })
7527
7611
  };
7528
- }, cc = (e) => typeof e == "object" && !!e, lc = (e) => (t) => {
7529
- if (!cc(e)) return;
7612
+ }, mc = (e) => typeof e == "object" && !!e, hc = (e) => (t) => {
7613
+ if (!mc(e)) return;
7530
7614
  let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
7531
7615
  return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
7532
- }, uc = (e) => {
7616
+ }, gc = (e) => {
7533
7617
  let t = e?.url ?? "", n = e?.baseURL;
7534
7618
  return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
7535
- }, dc = (e) => (e?.method ?? "GET").toUpperCase(), fc = (e) => e == null ? "none" : cc(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", pc = (e, t, n) => {
7536
- let r = qs(Ks(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
7619
+ }, _c = (e) => (e?.method ?? "GET").toUpperCase(), vc = (e) => e == null ? "none" : mc(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", yc = (e, t, n) => {
7620
+ let r = $s(Qs(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
7537
7621
  return {
7538
7622
  ...e,
7539
7623
  ...i ? { baseURL: void 0 } : {},
@@ -7542,10 +7626,10 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7542
7626
  headers: r,
7543
7627
  ..."body" in t ? { data: t.body } : {}
7544
7628
  };
7545
- }, mc = (e, t, n, r, i, a) => {
7546
- let o = t ?? e?.config, s = fc(o?.data), c = a ?? Gs({
7547
- url: uc(o),
7548
- method: dc(o),
7629
+ }, bc = (e, t, n, r, i, a) => {
7630
+ let o = t ?? e?.config, s = vc(o?.data), c = a ?? Zs({
7631
+ url: gc(o),
7632
+ method: _c(o),
7549
7633
  headers: o?.headers,
7550
7634
  bodyKind: s,
7551
7635
  body: o?.data
@@ -7553,22 +7637,22 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7553
7637
  url: c.href,
7554
7638
  method: c.method,
7555
7639
  bodyKind: s
7556
- }, u = s !== "one-shot" && ec(i.replay, l);
7640
+ }, u = s !== "one-shot" && oc(i.replay, l);
7557
7641
  return {
7558
7642
  status: e?.status ?? 0,
7559
- getHeader: lc(e?.headers),
7643
+ getHeader: hc(e?.headers),
7560
7644
  readBody: async () => e?.data,
7561
7645
  request: c,
7562
7646
  replay: async (e) => {
7563
- let t = Xe(pc(o ?? {}, c, e));
7647
+ let t = Xe(yc(o ?? {}, c, e));
7564
7648
  try {
7565
7649
  let e = await r(t);
7566
- return mc(e, e?.config ?? t, e, r, i, c);
7650
+ return bc(e, e?.config ?? t, e, r, i, c);
7567
7651
  } catch (e) {
7568
- let n = cc(e) ? e : {};
7652
+ let n = mc(e) ? e : {};
7569
7653
  if (!n.response || typeof n.response.status != "number" || Pa(e)) throw e;
7570
7654
  return {
7571
- ...mc(n.response, n.config ?? t, e, r, i, c),
7655
+ ...bc(n.response, n.config ?? t, e, r, i, c),
7572
7656
  rejected: !0
7573
7657
  };
7574
7658
  }
@@ -7582,30 +7666,30 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7582
7666
  replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
7583
7667
  signal: o?.signal
7584
7668
  };
7585
- }, hc = (e, t) => async (n) => {
7586
- let r = rs(e), i = cc(n) ? n : {}, a = Ss(await ys(mc(i.response, i.config, i.response, t, r), r), n);
7669
+ }, xc = (e, t) => async (n) => {
7670
+ let r = ls(e), i = mc(n) ? n : {}, a = Os(await Ts(bc(i.response, i.config, i.response, t, r), r), n);
7587
7671
  if (a.settle === "reject") throw a.error;
7588
7672
  return a.value;
7589
- }, gc = (e, t, n) => {
7590
- let r = e.request, i = n ?? (typeof r == "function" ? (t) => r.call(e, t) : () => Promise.reject(/* @__PURE__ */ Error("Passflow: this client exposes no request() to replay through."))), a = e.interceptors.response.use(void 0, hc(t, i)), o = !1;
7673
+ }, Sc = (e, t, n) => {
7674
+ 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, xc(t, i)), o = !1;
7591
7675
  return () => {
7592
7676
  o || (o = !0, e.interceptors.response.eject(a));
7593
7677
  };
7594
- }, _c = (t, n) => {
7678
+ }, Cc = (t, n) => {
7595
7679
  let r = e.create(t);
7596
7680
  return n(r), r;
7597
- }, vc = () => {
7681
+ }, wc = () => {
7598
7682
  let e = typeof location > "u" ? void 0 : location.origin;
7599
7683
  return e && e !== "null" ? e : void 0;
7600
- }, yc = (e) => {
7684
+ }, Tc = (e) => {
7601
7685
  let t = new URL(e).origin;
7602
7686
  if (t === "null") throw Error(`Passflow: "${e}" has no origin a request can be matched against; list http(s) origins only.`);
7603
7687
  return t;
7604
- }, bc = (e, t) => {
7605
- let n = (t?.origins ?? []).map(yc);
7688
+ }, Ec = (e, t) => {
7689
+ let n = (t?.origins ?? []).map(Tc);
7606
7690
  return (t, r) => {
7607
7691
  if (r) return Promise.resolve(void 0);
7608
- let i = vc(), a;
7692
+ let i = wc(), a;
7609
7693
  try {
7610
7694
  a = new URL(t, i).origin;
7611
7695
  } catch {
@@ -7613,22 +7697,22 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7613
7697
  }
7614
7698
  return a !== i && !n.includes(a) ? Promise.resolve(void 0) : e();
7615
7699
  };
7616
- }, xc = (e) => typeof Request < "u" && e instanceof Request, Sc = (e, t) => new Headers(t?.headers === void 0 ? xc(e) ? e.headers : void 0 : t.headers), Cc = (e, t, n) => {
7617
- let r = bc(t, n);
7700
+ }, Dc = (e) => typeof Request < "u" && e instanceof Request, Oc = (e, t) => new Headers(t?.headers === void 0 ? Dc(e) ? e.headers : void 0 : t.headers), kc = (e, t, n) => {
7701
+ let r = Ec(t, n);
7618
7702
  return async (t, n) => {
7619
- let i = xc(t) ? t.url : t instanceof URL ? t.href : String(t), a = Sc(t, n), o = await r(i, a.has("authorization"));
7703
+ let i = Dc(t) ? t.url : t instanceof URL ? t.href : String(t), a = Oc(t, n), o = await r(i, a.has("authorization"));
7620
7704
  return o ? (a.set("authorization", `Bearer ${o}`), e(t, {
7621
7705
  ...n,
7622
7706
  headers: a
7623
7707
  })) : e(t, n);
7624
7708
  };
7625
- }, wc = (e) => {
7709
+ }, Ac = (e) => {
7626
7710
  let t = e.url ?? "", n = /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
7627
7711
  return !e.baseURL || n && e.allowAbsoluteUrls !== !1 ? t : t ? `${e.baseURL.replace(/\/?\/$/, "")}/${t.replace(/^\/+/, "")}` : e.baseURL;
7628
- }, Tc = (e) => e ? typeof e.has == "function" ? e.has("Authorization") : Object.keys(e).some((t) => t.toLowerCase() === "authorization" && e[t] != null) : !1, Ec = (e, t) => {
7629
- let n = bc(e, t);
7712
+ }, jc = (e) => e ? typeof e.has == "function" ? e.has("Authorization") : Object.keys(e).some((t) => t.toLowerCase() === "authorization" && e[t] != null) : !1, Mc = (e, t) => {
7713
+ let n = Ec(e, t);
7630
7714
  return async (e) => {
7631
- let t = e.headers, r = await n(wc(e), Tc(t));
7715
+ let t = e.headers, r = await n(Ac(e), jc(t));
7632
7716
  if (!r) return e;
7633
7717
  let i = `Bearer ${r}`;
7634
7718
  return t && typeof t.set == "function" ? t.set("Authorization", i) : e.headers = {
@@ -7636,7 +7720,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7636
7720
  Authorization: i
7637
7721
  }, e;
7638
7722
  };
7639
- }, Dc = 0, Oc = (e, t) => {
7723
+ }, Nc = 0, Pc = (e, t) => {
7640
7724
  let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
7641
7725
  if (n) return {
7642
7726
  get aborted() {
@@ -7650,34 +7734,34 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7650
7734
  removeEventListener: (e, t) => n.removeEventListener(e, t)
7651
7735
  } : {}
7652
7736
  };
7653
- }, kc = (e) => (t) => e.headers?.get(t), Ac = (e, t, n, r, i) => ({
7737
+ }, Fc = (e) => (t) => e.headers?.get(t), Ic = (e, t, n, r, i) => ({
7654
7738
  status: e.status,
7655
- getHeader: kc(e),
7739
+ getHeader: Fc(e),
7656
7740
  readBody: () => e.clone().json(),
7657
7741
  request: t.snapshot,
7658
- replay: async (e) => Ac(await t.replay(n, e), t, n, r, i),
7742
+ replay: async (e) => Ic(await t.replay(n, e), t, n, r, i),
7659
7743
  markers: r,
7660
7744
  raw: e,
7661
7745
  replayable: t.replayable,
7662
7746
  replayUnsupportedReason: t.reason,
7663
7747
  signal: i,
7664
7748
  responseType: e.type
7665
- }), jc = (e, t) => {
7749
+ }), Lc = (e, t) => {
7666
7750
  let n = (t, n) => {
7667
- Dc += 1;
7751
+ Nc += 1;
7668
7752
  try {
7669
7753
  return e(t, n);
7670
7754
  } finally {
7671
- --Dc;
7755
+ --Nc;
7672
7756
  }
7673
7757
  };
7674
7758
  return async (e, r) => {
7675
- if (Dc > 0) return n(e, r);
7676
- let i = rs(t), a = sc(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = xs(await ys(Ac(o, a, n, {}, Oc(e, r)), i), o, i);
7759
+ if (Nc > 0) return n(e, r);
7760
+ let i = ls(t), a = pc(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = Ds(await Ts(Ic(o, a, n, {}, Pc(e, r)), i), o, i);
7677
7761
  if (s.settle === "reject") throw s.error;
7678
7762
  return s.value;
7679
7763
  };
7680
- }, Mc = new Set(Fo.filter((e) => !e.requiresPrepare).map((e) => e.type)), Nc = (e) => {
7764
+ }, Rc = new Set(Vo.filter((e) => !e.requiresPrepare).map((e) => e.type)), zc = (e) => {
7681
7765
  if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
7682
7766
  kind: "protocol",
7683
7767
  message: "The upgrade start response is missing challenge_id or expires_at"
@@ -7689,16 +7773,17 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7689
7773
  webauthn: e.webauthn,
7690
7774
  codeSentTo: e.code_sent_to
7691
7775
  };
7692
- }, Pc = (e) => Pa(e) && !Fa(e), Fc = (e) => ({
7693
- async prepare(t) {
7694
- if (!Mc.has(t)) try {
7695
- let n = e.relyingPartyId?.();
7696
- return Nc(await e.startUpgrade(n ? {
7776
+ }, Bc = (e) => Pa(e) && !Fa(e), Vc = (e) => ({
7777
+ async prepare(t, n) {
7778
+ if (!Rc.has(t)) try {
7779
+ let r = e.relyingPartyId?.();
7780
+ return zc(await e.startUpgrade({
7697
7781
  method: t,
7698
- relying_party_id: n
7699
- } : { method: t }));
7782
+ ...r ? { relying_party_id: r } : {},
7783
+ ...n?.resend ? { resend: !0 } : {}
7784
+ }));
7700
7785
  } catch (e) {
7701
- if (Pc(e)) throw e;
7786
+ if (Bc(e)) throw e;
7702
7787
  let t = Va(e, "start");
7703
7788
  if (t.kind === "prepare_not_required") return;
7704
7789
  throw t;
@@ -7716,17 +7801,17 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7716
7801
  assertion: n
7717
7802
  });
7718
7803
  } catch (t) {
7719
- if (Pc(t)) throw t;
7804
+ if (Bc(t)) throw t;
7720
7805
  let n = Va(t, "refresh");
7721
7806
  throw n.status === 401 && Ua(n) && e.markSessionInvalid?.(), n;
7722
7807
  }
7723
7808
  }
7724
- }), Ic = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Lc = (e) => {
7809
+ }), Hc = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Uc = (e) => {
7725
7810
  let t, n = (e) => e !== void 0 && t === e, r = (r) => {
7726
7811
  let i = () => {
7727
7812
  if (!n(r())) throw new $({ kind: "session_changed" });
7728
7813
  };
7729
- return Fc({
7814
+ return Vc({
7730
7815
  ...e,
7731
7816
  relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
7732
7817
  startUpgrade: (t) => (i(), e.startUpgrade(t)),
@@ -7737,7 +7822,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7737
7822
  });
7738
7823
  }, i = (t, n) => {
7739
7824
  let i = {}, a = {
7740
- controller: new ns({
7825
+ controller: new cs({
7741
7826
  transport: r(() => i.current),
7742
7827
  prompt: t.prompt,
7743
7828
  platform: e.platform,
@@ -7749,7 +7834,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7749
7834
  options: t,
7750
7835
  scope: {
7751
7836
  passflow: e.passflowDomain,
7752
- backend: Ic(t.backend)
7837
+ backend: Hc(t.backend)
7753
7838
  },
7754
7839
  generation: n
7755
7840
  };
@@ -7759,14 +7844,14 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7759
7844
  s = void 0;
7760
7845
  });
7761
7846
  let c = (e) => {
7762
- if (!s || ts(s.challenge, e)) return;
7847
+ if (!s || ss(s.challenge, e)) return;
7763
7848
  let t = Math.min(o, e.maxAge === void 0 ? o : e.maxAge * 1e3);
7764
7849
  if (!(Date.now() - s.at > t)) return s.challenge;
7765
7850
  }, l = async (r, i) => {
7766
7851
  let o = t;
7767
7852
  if (!o) throw new Ga("Step-up verification is not enabled on this Passflow instance");
7768
7853
  let l = e.stopRepeatedElevation ? c(r) : void 0;
7769
- if (l) throw new Wa(Qo(l), Qo(r), "This requirement was already proved and the server still refused it: sign the user in again");
7854
+ if (l) throw new Wa(is(l), is(r), "This requirement was already proved and the server still refused it: sign the user in again");
7770
7855
  o.controller.active || (o.pin = e.readSessionPin?.());
7771
7856
  let u = await o.controller.elevate(r, i);
7772
7857
  if (!n(o)) throw new Ka();
@@ -7816,9 +7901,9 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7816
7901
  let r = [];
7817
7902
  if (e.attachInternalSeam) {
7818
7903
  let t = e.attachInternalSeam;
7819
- t((e) => hc(u, e)), r.push(() => t(void 0));
7904
+ t((e) => xc(u, e)), r.push(() => t(void 0));
7820
7905
  }
7821
- n.interceptFetch && r.push(ur((e, t, n) => jc(e, u)(t, n), {
7906
+ n.interceptFetch && r.push(ur((e, t, n) => Lc(e, u)(t, n), {
7822
7907
  priority: 20,
7823
7908
  name: "passflow-upgrade"
7824
7909
  })), e.onSessionChange && r.push(e.onSessionChange(() => {
@@ -7850,8 +7935,8 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7850
7935
  enumerable: !0,
7851
7936
  value: (t, n) => {
7852
7937
  let r = (t) => {
7853
- let r = jc(t, u);
7854
- return e.readAccessToken ? Cc(r, e.readAccessToken, n) : r;
7938
+ let r = Lc(t, u);
7939
+ return e.readAccessToken ? kc(r, e.readAccessToken, n) : r;
7855
7940
  };
7856
7941
  if (t) return r(t);
7857
7942
  let i = typeof globalThis > "u" ? void 0 : globalThis;
@@ -7862,14 +7947,14 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7862
7947
  attachAuth: {
7863
7948
  enumerable: !0,
7864
7949
  value: (t, n) => {
7865
- let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(Ec(e.readAccessToken, n)), a = gc(t, u);
7950
+ let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(Mc(e.readAccessToken, n)), a = Sc(t, u);
7866
7951
  return () => {
7867
7952
  a(), r && i !== void 0 && r.eject(i);
7868
7953
  };
7869
7954
  }
7870
7955
  }
7871
7956
  });
7872
- }, Rc, zc = class {
7957
+ }, Wc, Gc = class {
7873
7958
  get origin() {
7874
7959
  return this.platform.getCurrentUrl()?.origin ?? "";
7875
7960
  }
@@ -7882,7 +7967,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7882
7967
  prefix: e.keyStoragePrefix ?? "",
7883
7968
  storage: this.platform.storage,
7884
7969
  appId: n
7885
- }), this.deviceService = new he(this.storageManager), this.authApi = new vn(e, this.storageManager, this.deviceService), this.appApi = new dn(e, this.storageManager, this.deviceService), this.userApi = new kn(e, this.storageManager, this.deviceService), this.settingApi = new xn(e, this.storageManager, this.deviceService), this.tenantApi = new Sn(e, this.storageManager, this.deviceService), this.invitationApi = new bn(e, this.storageManager, this.deviceService), this.twoFactorApi = new Dn(e, this.storageManager, this.deviceService), this.upgradeApi = new On(e, this.storageManager, this.deviceService), this.upgradeDomain = et(e.url), this.subscribeStore = new Gr(), this.tokenCacheService = new Do(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? x, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
7970
+ }), this.deviceService = new he(this.storageManager), this.authApi = new vn(e, this.storageManager, this.deviceService), this.appApi = new dn(e, this.storageManager, this.deviceService), this.userApi = new kn(e, this.storageManager, this.deviceService), this.settingApi = new xn(e, this.storageManager, this.deviceService), this.tenantApi = new Sn(e, this.storageManager, this.deviceService), this.invitationApi = new bn(e, this.storageManager, this.deviceService), this.twoFactorApi = new Dn(e, this.storageManager, this.deviceService), this.upgradeApi = new On(e, this.storageManager, this.deviceService), this.upgradeDomain = et(e.url), this.subscribeStore = new Gr(), this.tokenCacheService = new ko(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? x, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
7886
7971
  let i = Ui(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
7887
7972
  this.deviceKeyService = e.deviceKey === !0 && !e.tokenExchange?.enabled ? Jn({
7888
7973
  dbName: Gn(e.keyStoragePrefix),
@@ -7913,7 +7998,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7913
7998
  ...e.antiBotWorkerUrl ? { workerUrl: e.antiBotWorkerUrl } : {}
7914
7999
  }), this.authApi.setAntiBotHandler((e) => this.antiBot.headerFor(e)), this.riskIds = di({ readSettings: () => this.readAppSettings() }), this.authApi.setRiskIdHandler((e) => this.riskIds.headersFor(e)), this.tokenCacheService.attachRefreshController(this.authService.refresh);
7915
8000
  for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
7916
- this.userService = new ko(this.userApi, this.deviceService, this.platform), this.tenantService = new Eo(this.tenantApi, this.scopes, void 0, () => this.storageManager.getToken(N.access_token)), this.tenant = this.tenantService, this.invitationService = new Co(this.invitationApi), this.twoFactorService = new Oo(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Lc({
8001
+ this.userService = new jo(this.userApi, this.deviceService, this.platform), this.tenantService = new Oo(this.tenantApi, this.scopes, void 0, () => this.storageManager.getToken(N.access_token)), this.tenant = this.tenantService, this.invitationService = new Co(this.invitationApi), this.twoFactorService = new Ao(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Uc({
7917
8002
  startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
7918
8003
  commitRefresh: async (e, t) => {
7919
8004
  await this.authService.refreshToken(e, t);
@@ -7942,7 +8027,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7942
8027
  let e = (await this.getTokens(!0))?.access_token;
7943
8028
  return e && !j(M(e)) ? e : void 0;
7944
8029
  }
7945
- }), this.hostedUpgrade = Lc({
8030
+ }), this.hostedUpgrade = Uc({
7946
8031
  startUpgrade: (e) => this.upgradeApi.startHostedUpgrade(e),
7947
8032
  commitRefresh: (e) => this.upgradeApi.commitHostedUpgrade(e),
7948
8033
  canCommit: () => ({ ok: !0 }),
@@ -7979,7 +8064,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
7979
8064
  return this.upgrade.attachAuth(e, t);
7980
8065
  }
7981
8066
  createClient(e, t) {
7982
- return _c(e, (e) => this.upgrade.attachAuth(e, t));
8067
+ return Cc(e, (e) => this.upgrade.attachAuth(e, t));
7983
8068
  }
7984
8069
  readAssuranceBar() {
7985
8070
  let e = this.storageManager.getToken(N.access_token);
@@ -8665,7 +8750,7 @@ var _o = 10, vo = "The sign-in answered with a PKCE code, but its verifier is go
8665
8750
  this.twoFactorService.clearMagicLinkSession();
8666
8751
  }
8667
8752
  };
8668
- Rc = zc, Rc.version = y;
8669
- export { bt as ADDRESS_CHANGE_PROOF_REQUIRED_ERROR_ID, m as AGENT_TOOL_HEADER_KEY, v as ANTI_BOT_ACTION, ot as ANTI_BOT_FAILED_ERROR_ID, p as ANTI_BOT_HEADER_KEY, ut as ANTI_BOT_PROVIDER_FAILED_ERROR_ID, lt as ANTI_BOT_PROVIDER_MISSING_ERROR_ID, at as ANTI_BOT_REQUIRED_ERROR_ID, dt as ANTI_BOT_SOLVE_FAILED_ERROR_ID, ct as ANTI_BOT_UNAVAILABLE_ERROR_ID, l as APP_ID_HEADER_KEY, Dt as APP_SECRET_NAMES, u as AUTHORIZATION_HEADER_KEY, dn as AppAPI, vn as AuthAPI, So as AuthService, yn as CLIAuthAPI, S as DEFAULT_GROUP_NAME, x as DEFAULT_SCOPES, Fo as DEFAULT_UPGRADE_FACTORS, d as DEVICE_ID_HEADER_KEY, h as DEVICE_PROOF_HEADER_KEY, f as DEVICE_TYPE_HEADER_KEY, Yn as DeviceKeyErrorId, ht as ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID, ft as ENTERPRISE_EMAIL_INVALID_ERROR_ID, mt as ENTERPRISE_NO_CONNECTION_ERROR_ID, pt as ENTERPRISE_START_INPUT_ERROR_ID, re as ERROR_MESSAGE_MAX_LENGTH, Zn as FETCH_PRIORITY_OIDC, Qn as FETCH_PRIORITY_UPGRADE, g as FINGERPRINT_EVENT_HEADER_KEY, $n as FetchMiddlewareContractError, Me as INSUFFICIENT_USER_AUTHENTICATION, bn as InvitationAPI, Co as InvitationService, yr as M2MClient, mr as M2MConfigError, H as M2MError, hr as M2MErrorCodes, fr as M2MNetworkError, pr as M2MTokenParseError, gr as M2M_DEFAULTS, Ot as MASKED_SECRET_PREFIX, b as MINIMAL_DEFAULT_SCOPES, L as NativeSignInError, jt as OS, ee as PASSFLOW_CLOUD_URL, it as PASSWORD_CHANGE_REQUIRED_ERROR_ID, w as POPUP_HEIGHT, T as POPUP_POLL_INTERVAL_MS, E as POPUP_TIMEOUT_MS, C as POPUP_WIDTH, zc as Passflow, Tt as PassflowAddressChangeProofRequiredError, $e as PassflowAdminEndpointPaths, wt as PassflowAntiBotChallengeError, R as PassflowEndpointPaths, z as PassflowError, G as PassflowEvent, U as PassflowOidcError, gt as PassflowPasswordChangeRequiredError, Ct as PassflowRecoveryCodesStepUpRequiredError, Y as PassflowRefreshError, St as PassflowSendLimitError, xt as PassflowSmsQuotaExceededError, ge as PopupClosedError, Et as Providers, Oa as RECOVERABLE_COMMIT_ERROR_IDS, yt as RECOVERY_CODES_STEP_UP_REQUIRED_ERROR_ID, Wi as REFRESH_AUTH_FAILURE_IDS, J as RefreshErrorId, Qe as RequestMethod, y as SDK_VERSION, nt as SERVICE_UNAVAILABLE_ERROR_ID, rt as SERVICE_UNAVAILABLE_MESSAGE, ka as SESSION_INVALIDATING_COMMIT_ERROR_IDS, kt as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, st as SIGN_IN_REFUSED_ERROR_ID, _ as STYTCH_TELEMETRY_HEADER_KEY, F as SessionState, xn as SettingAPI, te as TOKEN_EXPIRY_BUFFER_SECONDS, vt as TWO_FACTOR_SEND_LIMIT_ERROR_ID, _t as TWO_FACTOR_SMS_QUOTA_EXCEEDED_ERROR_ID, Sn as TenantAPI, Eo as TenantService, wo as TenantUserMembership, Do as TokenCacheService, P as TokenDeliveryMode, N as TokenType, Dn as TwoFactorApiClient, Pt as TwoFactorPolicy, Oo as TwoFactorService, Ne as UPGRADE_REQUIRED, D as USERNAME_MAX_LENGTH, ne as USERNAME_MIN_LENGTH, On as UpgradeAPI, Ho as UpgradeCancelledError, ra as UpgradeCommitInterruptedError, ns as UpgradeController, Q as UpgradeErrorIds, Ao as UpgradeFactorError, Wa as UpgradeInsufficientError, Ka as UpgradeSessionChangedError, Uo as UpgradeSignInRequiredError, $ as UpgradeTransportError, Ga as UpgradeUnavailableError, Jo as UpgradeUnsatisfiableError, kn as UserAPI, ko as UserService, Te as WebAdapter, Va as classifyUpgradeError, Io as factorRegistry, dr as fetchRegistryState, Mt as getOSFromDeviceType, Ua as invalidatesSessionOnCommit, tt as isEmailVerificationStep, At as isMaskedSecret, Ha as isRecoverableCommitFailure, ja as isRetryableUpgradeKind, j as isTokenExpired, Ms as isUpgradeCancelled, Ns as isUpgradeExhausted, Ps as isUpgradeInsufficient, Rs as isUpgradeSessionChanged, Is as isUpgradeSignInRequired, Fa as isUpgradeTransportError, zs as isUpgradeTransportFailure, Ls as isUpgradeUnavailable, Fs as isUpgradeUnsatisfiable, Za as isValidEmail, Ya as isValidJWTFormat, Qa as isValidPhoneNumber, $a as isValidUsername, Be as parseChallengeBody, ze as parseChallengeHeader, M as parseToken, We as parseUpgradeChallenge, Po as passkeyFactor, Nt as pathWithParams, In as pushChallengeOf, No as recoveryCodesFactor, ur as registerFetchMiddleware, je as requiredAcrLevel, et as resolveUpgradeDomain, Xa as sanitizeErrorMessage, Vo as selectFactors, Mo as totpFactor, Ee as webAdapter };
8753
+ Wc = Gc, Wc.version = y;
8754
+ export { bt as ADDRESS_CHANGE_PROOF_REQUIRED_ERROR_ID, m as AGENT_TOOL_HEADER_KEY, v as ANTI_BOT_ACTION, ot as ANTI_BOT_FAILED_ERROR_ID, p as ANTI_BOT_HEADER_KEY, ut as ANTI_BOT_PROVIDER_FAILED_ERROR_ID, lt as ANTI_BOT_PROVIDER_MISSING_ERROR_ID, at as ANTI_BOT_REQUIRED_ERROR_ID, dt as ANTI_BOT_SOLVE_FAILED_ERROR_ID, ct as ANTI_BOT_UNAVAILABLE_ERROR_ID, l as APP_ID_HEADER_KEY, Dt as APP_SECRET_NAMES, u as AUTHORIZATION_HEADER_KEY, dn as AppAPI, vn as AuthAPI, So as AuthService, yn as CLIAuthAPI, S as DEFAULT_GROUP_NAME, x as DEFAULT_SCOPES, Vo as DEFAULT_UPGRADE_FACTORS, d as DEVICE_ID_HEADER_KEY, h as DEVICE_PROOF_HEADER_KEY, f as DEVICE_TYPE_HEADER_KEY, Yn as DeviceKeyErrorId, ht as ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID, ft as ENTERPRISE_EMAIL_INVALID_ERROR_ID, mt as ENTERPRISE_NO_CONNECTION_ERROR_ID, pt as ENTERPRISE_START_INPUT_ERROR_ID, re as ERROR_MESSAGE_MAX_LENGTH, Zn as FETCH_PRIORITY_OIDC, Qn as FETCH_PRIORITY_UPGRADE, g as FINGERPRINT_EVENT_HEADER_KEY, $n as FetchMiddlewareContractError, Me as INSUFFICIENT_USER_AUTHENTICATION, bn as InvitationAPI, Co as InvitationService, yr as M2MClient, mr as M2MConfigError, H as M2MError, hr as M2MErrorCodes, fr as M2MNetworkError, pr as M2MTokenParseError, gr as M2M_DEFAULTS, Ot as MASKED_SECRET_PREFIX, b as MINIMAL_DEFAULT_SCOPES, L as NativeSignInError, jt as OS, ee as PASSFLOW_CLOUD_URL, it as PASSWORD_CHANGE_REQUIRED_ERROR_ID, w as POPUP_HEIGHT, T as POPUP_POLL_INTERVAL_MS, E as POPUP_TIMEOUT_MS, C as POPUP_WIDTH, Gc as Passflow, Tt as PassflowAddressChangeProofRequiredError, $e as PassflowAdminEndpointPaths, wt as PassflowAntiBotChallengeError, R as PassflowEndpointPaths, z as PassflowError, G as PassflowEvent, U as PassflowOidcError, gt as PassflowPasswordChangeRequiredError, Ct as PassflowRecoveryCodesStepUpRequiredError, Y as PassflowRefreshError, St as PassflowSendLimitError, xt as PassflowSmsQuotaExceededError, ge as PopupClosedError, Et as Providers, Oa as RECOVERABLE_COMMIT_ERROR_IDS, yt as RECOVERY_CODES_STEP_UP_REQUIRED_ERROR_ID, Wi as REFRESH_AUTH_FAILURE_IDS, J as RefreshErrorId, Qe as RequestMethod, y as SDK_VERSION, nt as SERVICE_UNAVAILABLE_ERROR_ID, rt as SERVICE_UNAVAILABLE_MESSAGE, ka as SESSION_INVALIDATING_COMMIT_ERROR_IDS, kt as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, st as SIGN_IN_REFUSED_ERROR_ID, _ as STYTCH_TELEMETRY_HEADER_KEY, F as SessionState, xn as SettingAPI, te as TOKEN_EXPIRY_BUFFER_SECONDS, vt as TWO_FACTOR_SEND_LIMIT_ERROR_ID, _t as TWO_FACTOR_SMS_QUOTA_EXCEEDED_ERROR_ID, Sn as TenantAPI, Oo as TenantService, Eo as TenantUserMembership, ko as TokenCacheService, P as TokenDeliveryMode, N as TokenType, Dn as TwoFactorApiClient, Pt as TwoFactorPolicy, Ao as TwoFactorService, Ne as UPGRADE_REQUIRED, D as USERNAME_MAX_LENGTH, ne as USERNAME_MIN_LENGTH, On as UpgradeAPI, Jo as UpgradeCancelledError, ra as UpgradeCommitInterruptedError, cs as UpgradeController, Q as UpgradeErrorIds, Mo as UpgradeFactorError, Wa as UpgradeInsufficientError, Ka as UpgradeSessionChangedError, Yo as UpgradeSignInRequiredError, $ as UpgradeTransportError, Ga as UpgradeUnavailableError, es as UpgradeUnsatisfiableError, kn as UserAPI, jo as UserService, Te as WebAdapter, Va as classifyUpgradeError, Ro as emailOtpFactor, Ho as factorRegistry, dr as fetchRegistryState, Mt as getOSFromDeviceType, Ua as invalidatesSessionOnCommit, tt as isEmailVerificationStep, At as isMaskedSecret, Ha as isRecoverableCommitFailure, ja as isRetryableUpgradeKind, j as isTokenExpired, Rs as isUpgradeCancelled, zs as isUpgradeExhausted, Bs as isUpgradeInsufficient, Ws as isUpgradeSessionChanged, Hs as isUpgradeSignInRequired, Fa as isUpgradeTransportError, Gs as isUpgradeTransportFailure, Us as isUpgradeUnavailable, Vs as isUpgradeUnsatisfiable, Za as isValidEmail, Ya as isValidJWTFormat, Qa as isValidPhoneNumber, $a as isValidUsername, Be as parseChallengeBody, ze as parseChallengeHeader, M as parseToken, We as parseUpgradeChallenge, Io as passkeyFactor, Nt as pathWithParams, In as pushChallengeOf, Fo as recoveryCodesFactor, ur as registerFetchMiddleware, je as requiredAcrLevel, et as resolveUpgradeDomain, Xa as sanitizeErrorMessage, qo as selectFactors, zo as smsOtpFactor, Po as totpFactor, Ee as webAdapter };
8670
8755
 
8671
8756
  //# sourceMappingURL=index.mjs.map