@passflow/core 0.39.4 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -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.39.4", 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 = "passflow_auth", g = c, _ = [
14
+ }, c = "0.40.0", l = "X-Passflow-Clientid", u = "Authorization", d = "X-Passflow-DeviceId", f = "X-Passflow-DeviceType", p = "X-Passflow-Anti-Bot", m = "X-Passflow-Agent-Tool", h = "passflow_auth", g = c, _ = [
15
15
  "id",
16
16
  "offline",
17
17
  "openid"
@@ -1009,7 +1009,7 @@ var bt = /* @__PURE__ */ function(e) {
1009
1009
  getAppSettings() {
1010
1010
  return this.axiosClient.get(R.appSettings);
1011
1011
  }
1012
- }, Xt = { withCredentials: !0 }, Zt = 15e3, Qt = "X-Passflow-CSRF", $t = "Sign-in failed. Start again.", en = "Something went wrong. Try again later.", tn = (e, t, n, r) => {
1012
+ }, B = { withCredentials: !0 }, Xt = 15e3, Zt = "X-Passflow-CSRF", Qt = "Sign-in failed. Start again.", $t = "Something went wrong. Try again later.", en = (e, t, n, r) => {
1013
1013
  if (e instanceof z) return e;
1014
1014
  let i = e?.response?.data?.error;
1015
1015
  return new z({
@@ -1019,14 +1019,14 @@ var bt = /* @__PURE__ */ function(e) {
1019
1019
  location: t,
1020
1020
  time: (/* @__PURE__ */ new Date()).toISOString()
1021
1021
  });
1022
- }, B = (e, t, n, r) => !t && !r?.agentTool ? e : {
1022
+ }, V = (e, t, n, r) => !t && !r?.agentTool ? e : {
1023
1023
  ...e,
1024
1024
  ...t ? o(t, n) : {},
1025
1025
  ...r?.agentTool ? { headers: {
1026
1026
  ...e?.headers,
1027
1027
  [m]: "1"
1028
1028
  } } : {}
1029
- }, nn = class {
1029
+ }, tn = class {
1030
1030
  constructor(e, t, n) {
1031
1031
  this.axiosClient = new Jt(e, t, n);
1032
1032
  }
@@ -1040,24 +1040,24 @@ var bt = /* @__PURE__ */ function(e) {
1040
1040
  try {
1041
1041
  return await this.axiosClient.post(R.antiBotChallenge, e);
1042
1042
  } catch (e) {
1043
- throw tn(e, R.antiBotChallenge, "error.anti_bot.challenge", en);
1043
+ throw en(e, R.antiBotChallenge, "error.anti_bot.challenge", $t);
1044
1044
  }
1045
1045
  }
1046
1046
  async deviceAntiBotChallenge(e, t) {
1047
1047
  try {
1048
- return await this.axiosClient.post(R.deviceAntiBotChallenge, e, { headers: { [Qt]: t } });
1048
+ return await this.axiosClient.post(R.deviceAntiBotChallenge, e, { headers: { [Zt]: t } });
1049
1049
  } catch (e) {
1050
- throw tn(e, R.deviceAntiBotChallenge, "error.anti_bot.challenge", en);
1050
+ throw en(e, R.deviceAntiBotChallenge, "error.anti_bot.challenge", $t);
1051
1051
  }
1052
1052
  }
1053
1053
  federatedStart(e, t, n) {
1054
- return this.axiosClient.post(`${R.signInWithProvider}${e}`, t, B(Xt, "federated.start", void 0, n));
1054
+ return this.axiosClient.post(`${R.signInWithProvider}${e}`, t, V(B, "federated.start", void 0, n));
1055
1055
  }
1056
1056
  enterpriseResolve(e) {
1057
1057
  return this.axiosClient.post(R.enterpriseResolve, { email: e });
1058
1058
  }
1059
1059
  enterpriseStart(e, t) {
1060
- return this.axiosClient.post(R.enterpriseStart, e, B(Xt, "federated.start", e.email, t));
1060
+ return this.axiosClient.post(R.enterpriseStart, e, V(B, "federated.start", e.email, t));
1061
1061
  }
1062
1062
  refreshToken(e, t, n, r) {
1063
1063
  let i = {
@@ -1073,7 +1073,7 @@ var bt = /* @__PURE__ */ function(e) {
1073
1073
  device: t,
1074
1074
  os: n
1075
1075
  };
1076
- return this.axiosClient.post(R.signin, i, B(Xt, "sign-in", e.email ?? e.phone ?? e.username, r));
1076
+ return this.axiosClient.post(R.signin, i, V(B, "sign-in", e.email ?? e.phone ?? e.username, r));
1077
1077
  }
1078
1078
  signUp(e, t) {
1079
1079
  let { create_tenant: n, anonymous: r } = e, i = {
@@ -1081,16 +1081,16 @@ var bt = /* @__PURE__ */ function(e) {
1081
1081
  create_tenant: n ?? !1,
1082
1082
  anonymous: r ?? !1
1083
1083
  };
1084
- return this.axiosClient.post(R.signup, i, B(Xt, "sign-up", e.user.email ?? e.user.phone_number ?? e.user.username, t));
1084
+ return this.axiosClient.post(R.signup, i, V(B, "sign-up", e.user.email ?? e.user.phone_number ?? e.user.username, t));
1085
1085
  }
1086
1086
  async pkceExchange(e, t) {
1087
1087
  try {
1088
1088
  return await this.axiosClient.post(R.pkceExchange, {
1089
1089
  authz_code: e,
1090
1090
  verifier: t
1091
- }, Xt);
1091
+ }, B);
1092
1092
  } catch (e) {
1093
- throw tn(e, R.pkceExchange, "error.pkce.exchange", $t);
1093
+ throw en(e, R.pkceExchange, "error.pkce.exchange", Qt);
1094
1094
  }
1095
1095
  }
1096
1096
  async passwordlessSignIn(e, t, n, r) {
@@ -1101,55 +1101,55 @@ var bt = /* @__PURE__ */ function(e) {
1101
1101
  os: n
1102
1102
  };
1103
1103
  try {
1104
- return await this.axiosClient.post(R.passwordless, a, B(void 0, "passwordless.start", e.email ?? e.phone, r));
1104
+ return await this.axiosClient.post(R.passwordless, a, V(void 0, "passwordless.start", e.email ?? e.phone, r));
1105
1105
  } catch (e) {
1106
- throw tn(e, R.passwordless, "error.passwordless.start", en);
1106
+ throw en(e, R.passwordless, "error.passwordless.start", $t);
1107
1107
  }
1108
1108
  }
1109
1109
  async passwordlessSignInComplete(e, t) {
1110
1110
  try {
1111
- return await this.axiosClient.post(R.passwordlessComplete, e, B(Xt, void 0, void 0, t));
1111
+ return await this.axiosClient.post(R.passwordlessComplete, e, V(B, void 0, void 0, t));
1112
1112
  } catch (e) {
1113
- throw tn(e, R.passwordlessComplete, "error.passwordless.complete", en);
1113
+ throw en(e, R.passwordlessComplete, "error.passwordless.complete", $t);
1114
1114
  }
1115
1115
  }
1116
1116
  async passwordlessStatus(e, t) {
1117
1117
  try {
1118
1118
  return await this.axiosClient.post(R.passwordlessStatus, e, {
1119
- ...Xt,
1120
- timeout: Zt,
1119
+ ...B,
1120
+ timeout: Xt,
1121
1121
  signal: t?.signal
1122
1122
  });
1123
1123
  } catch (e) {
1124
- throw tn(e, R.passwordlessStatus, "error.passwordless.status", $t);
1124
+ throw en(e, R.passwordlessStatus, "error.passwordless.status", Qt);
1125
1125
  }
1126
1126
  }
1127
1127
  async checkRedirectUrl(e) {
1128
1128
  try {
1129
1129
  return (await this.axiosClient.post(R.redirectCheck, { redirect_url: e })).redirect_url;
1130
1130
  } catch (e) {
1131
- throw tn(e, R.redirectCheck, "error.redirect.check", en);
1131
+ throw en(e, R.redirectCheck, "error.redirect.check", $t);
1132
1132
  }
1133
1133
  }
1134
1134
  async passwordlessApprovalInfo(e) {
1135
1135
  try {
1136
1136
  return await this.axiosClient.post(R.passwordlessApprovalInfo, e);
1137
1137
  } catch (e) {
1138
- throw tn(e, R.passwordlessApprovalInfo, "error.passwordless.approval", en);
1138
+ throw en(e, R.passwordlessApprovalInfo, "error.passwordless.approval", $t);
1139
1139
  }
1140
1140
  }
1141
1141
  async passwordlessApprovalDecide(e) {
1142
1142
  try {
1143
1143
  return await this.axiosClient.post(R.passwordlessApprovalDecide, e);
1144
1144
  } catch (e) {
1145
- throw tn(e, R.passwordlessApprovalDecide, "error.passwordless.approval", en);
1145
+ throw en(e, R.passwordlessApprovalDecide, "error.passwordless.approval", $t);
1146
1146
  }
1147
1147
  }
1148
1148
  validateEmailCode(e) {
1149
1149
  return this.axiosClient.post(R.passkeyValidate, {
1150
1150
  challenge_id: e.challenge_id,
1151
1151
  otp: e.otp
1152
- }, Xt);
1152
+ }, B);
1153
1153
  }
1154
1154
  logOut(e, t, n = !1) {
1155
1155
  let r = n ? void 0 : {
@@ -1162,7 +1162,7 @@ var bt = /* @__PURE__ */ function(e) {
1162
1162
  return this.axiosClient.get(R.validateSession);
1163
1163
  }
1164
1164
  sendPasswordResetEmail(e, t) {
1165
- return this.axiosClient.post(R.sendPasswordResetEmail, e, B(void 0, "password-reset.send", e.email ?? e.phone ?? e.username, t));
1165
+ return this.axiosClient.post(R.sendPasswordResetEmail, e, V(void 0, "password-reset.send", e.email ?? e.phone ?? e.username, t));
1166
1166
  }
1167
1167
  resetPassword(e, t, n, r) {
1168
1168
  let i = {
@@ -1182,7 +1182,7 @@ var bt = /* @__PURE__ */ function(e) {
1182
1182
  device: t,
1183
1183
  os: n
1184
1184
  }, s = r ? Ve.passkeyRegisterStart : R.passkeyRegisterStart;
1185
- return this.axiosClient.post(s, o, B(void 0, r ? void 0 : "passkey.register", e.passkey_username, i));
1185
+ return this.axiosClient.post(s, o, V(void 0, r ? void 0 : "passkey.register", e.passkey_username, i));
1186
1186
  }
1187
1187
  passkeyRegisterComplete(e, t, n, r = !1, i) {
1188
1188
  let a = {
@@ -1190,7 +1190,7 @@ var bt = /* @__PURE__ */ function(e) {
1190
1190
  device: t,
1191
1191
  passkey_data: e
1192
1192
  }, o = r ? Ve.passkeyRegisterComplete : R.passkeyRegisterComplete;
1193
- return this.axiosClient.post(o, a, B(Xt, void 0, void 0, i));
1193
+ return this.axiosClient.post(o, a, V(B, void 0, void 0, i));
1194
1194
  }
1195
1195
  passkeyAuthenticateStart(e, t, n, r = !1, i) {
1196
1196
  let a = {
@@ -1199,7 +1199,7 @@ var bt = /* @__PURE__ */ function(e) {
1199
1199
  device: t,
1200
1200
  os: n
1201
1201
  }, o = r ? Ve.passkeyAuthenticateStart : R.passkeyAuthenticateStart;
1202
- return this.axiosClient.post(o, a, B(void 0, r ? void 0 : "passkey.authenticate", void 0, i));
1202
+ return this.axiosClient.post(o, a, V(void 0, r ? void 0 : "passkey.authenticate", void 0, i));
1203
1203
  }
1204
1204
  passkeyAuthenticateComplete(e, t, n, r = !1, i) {
1205
1205
  let a = {
@@ -1207,7 +1207,7 @@ var bt = /* @__PURE__ */ function(e) {
1207
1207
  device: t,
1208
1208
  passkey_data: e
1209
1209
  }, o = r ? Ve.passkeyAuthenticateComplete : R.passkeyAuthenticateComplete;
1210
- return this.axiosClient.post(o, a, B(Xt, void 0, void 0, i));
1210
+ return this.axiosClient.post(o, a, V(B, void 0, void 0, i));
1211
1211
  }
1212
1212
  passkeyValidate(e, t, n, r = !1, i) {
1213
1213
  let a = {
@@ -1219,7 +1219,7 @@ var bt = /* @__PURE__ */ function(e) {
1219
1219
  let s = i ? { [l]: i } : {};
1220
1220
  return this.axiosClient.post(o, a, { headers: s });
1221
1221
  }
1222
- }, rn = class {
1222
+ }, nn = class {
1223
1223
  constructor(e, t, n) {
1224
1224
  this.axiosClient = new Jt(e, t, n);
1225
1225
  }
@@ -1233,7 +1233,7 @@ var bt = /* @__PURE__ */ function(e) {
1233
1233
  completeCLIAuth(e) {
1234
1234
  return this.axiosClient.post(R.cliAuthComplete, e);
1235
1235
  }
1236
- }, an = class {
1236
+ }, rn = class {
1237
1237
  constructor(e, t, n) {
1238
1238
  this.axiosClient = new Jt(e, t, n);
1239
1239
  }
@@ -1264,7 +1264,7 @@ var bt = /* @__PURE__ */ function(e) {
1264
1264
  let t = yt(R.invitationGetLink, { invitationID: e });
1265
1265
  return this.axiosClient.get(t);
1266
1266
  }
1267
- }, on = class {
1267
+ }, an = class {
1268
1268
  constructor(e, t, n) {
1269
1269
  this.axiosClient = new Jt(e, t, n);
1270
1270
  }
@@ -1280,7 +1280,7 @@ var bt = /* @__PURE__ */ function(e) {
1280
1280
  getPasskeySettings() {
1281
1281
  return this.axiosClient.get(R.settingsPasskey);
1282
1282
  }
1283
- }, sn = class {
1283
+ }, on = class {
1284
1284
  constructor(e, t, n) {
1285
1285
  this.axiosClient = new Jt(e, t, n);
1286
1286
  }
@@ -1396,18 +1396,18 @@ var bt = /* @__PURE__ */ function(e) {
1396
1396
  let r = `${R.tenantPath}/${e}/group/${t}/invite/email/${n}`;
1397
1397
  return this.axiosClient.delete(r);
1398
1398
  }
1399
- }, cn = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, ln = (e) => ({
1399
+ }, sn = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, cn = (e) => ({
1400
1400
  withCredentials: !0,
1401
- ...cn(e)
1402
- }), un = ({ qr_code_image: e, qr_code: t, ...n }) => ({
1401
+ ...sn(e)
1402
+ }), ln = ({ qr_code_image: e, qr_code: t, ...n }) => ({
1403
1403
  ...n,
1404
1404
  qr_code: (t ?? e ?? "").replace(/^data:image\/png;base64,/, "")
1405
- }), dn = {
1405
+ }), un = {
1406
1406
  "error.2fa.setup.token.expired": "EXPIRED_TOKEN",
1407
1407
  "error.2fa.setup.token.revoked": "REVOKED_TOKEN",
1408
1408
  "error.2fa.setup.token.already_used": "ALREADY_USED",
1409
1409
  "error.2fa.setup.token.rate.limit.exceeded": "RATE_LIMITED"
1410
- }, fn = class {
1410
+ }, dn = class {
1411
1411
  constructor(e, t, n) {
1412
1412
  this.axiosClient = new Jt(e, t, n);
1413
1413
  }
@@ -1418,7 +1418,7 @@ var bt = /* @__PURE__ */ function(e) {
1418
1418
  return this.axiosClient.get(R.twoFactorStatus, Bt(e));
1419
1419
  }
1420
1420
  async beginSetup(e) {
1421
- return un(await this.axiosClient.post(R.twoFactorSetupBegin, {}, Bt(e)));
1421
+ return ln(await this.axiosClient.post(R.twoFactorSetupBegin, {}, Bt(e)));
1422
1422
  }
1423
1423
  confirmSetup(e, t) {
1424
1424
  return this.axiosClient.post(R.twoFactorSetupConfirm, e, Bt(t));
@@ -1430,7 +1430,7 @@ var bt = /* @__PURE__ */ function(e) {
1430
1430
  return this.axiosClient.post(R.twoFactorEnrollmentEmailLink, void 0, Bt(e));
1431
1431
  }
1432
1432
  async beginEnrollment(e) {
1433
- return un(await this.axiosClient.post(R.twoFactorEnrollmentBegin, void 0, Bt(e)));
1433
+ return ln(await this.axiosClient.post(R.twoFactorEnrollmentBegin, void 0, Bt(e)));
1434
1434
  }
1435
1435
  confirmEnrollment(e, t) {
1436
1436
  return this.axiosClient.post(R.twoFactorEnrollmentConfirm, t, Bt(e));
@@ -1440,14 +1440,14 @@ var bt = /* @__PURE__ */ function(e) {
1440
1440
  return this.axiosClient.post(R.twoFactorVerify, {
1441
1441
  code: n,
1442
1442
  ...r ? { trust_device: !0 } : {}
1443
- }, ln(t));
1443
+ }, cn(t));
1444
1444
  }
1445
1445
  useRecoveryCode(e) {
1446
1446
  let { tfa_token: t, recovery_code: n, trust_device: r } = e;
1447
1447
  return this.axiosClient.post(R.twoFactorRecovery, {
1448
1448
  recovery_code: n,
1449
1449
  ...r ? { trust_device: !0 } : {}
1450
- }, ln(t));
1450
+ }, cn(t));
1451
1451
  }
1452
1452
  disable(e) {
1453
1453
  return this.axiosClient.delete(R.twoFactor, { data: e });
@@ -1477,7 +1477,7 @@ var bt = /* @__PURE__ */ function(e) {
1477
1477
  if (e instanceof z) return {
1478
1478
  success: !1,
1479
1479
  error: {
1480
- code: dn[e.id] ?? this.mapStatusToErrorCode(e.status),
1480
+ code: un[e.id] ?? this.mapStatusToErrorCode(e.status),
1481
1481
  message: e.message || this.getDefaultErrorMessage(e.status)
1482
1482
  }
1483
1483
  };
@@ -1556,17 +1556,17 @@ var bt = /* @__PURE__ */ function(e) {
1556
1556
  return this.axiosClient.delete(t);
1557
1557
  }
1558
1558
  requestChallenge(e, t) {
1559
- return this.axiosClient.post(R.TwoFactorChallenge, e, Ut(cn(t)));
1559
+ return this.axiosClient.post(R.TwoFactorChallenge, e, Ut(sn(t)));
1560
1560
  }
1561
1561
  verifyV2(e, t) {
1562
1562
  let { trust_device: n, ...r } = e;
1563
1563
  return this.axiosClient.post(R.TwoFactorVerifyV2, {
1564
1564
  ...r,
1565
1565
  ...n ? { trust_device: !0 } : {}
1566
- }, ln(t));
1566
+ }, cn(t));
1567
1567
  }
1568
1568
  switchToAlternative(e, t) {
1569
- return this.axiosClient.post(R.TwoFactorAlternative, e, Ut(cn(t)));
1569
+ return this.axiosClient.post(R.TwoFactorAlternative, e, Ut(sn(t)));
1570
1570
  }
1571
1571
  async getTrustedDevices() {
1572
1572
  return (await this.axiosClient.get(R.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
@@ -1584,7 +1584,7 @@ var bt = /* @__PURE__ */ function(e) {
1584
1584
  async clearPreferredMethod() {
1585
1585
  await this.axiosClient.delete(R.TwoFactorPreferredMethod);
1586
1586
  }
1587
- }, pn = class {
1587
+ }, fn = class {
1588
1588
  constructor(e, t, n) {
1589
1589
  this.axiosClient = new Jt(e, t, n);
1590
1590
  }
@@ -1600,7 +1600,7 @@ var bt = /* @__PURE__ */ function(e) {
1600
1600
  async commitHostedUpgrade(e) {
1601
1601
  await this.axiosClient.post(R.hostedUpgrade, e, { withCredentials: !0 });
1602
1602
  }
1603
- }, mn = class {
1603
+ }, pn = class {
1604
1604
  constructor(e, t, n) {
1605
1605
  this.axiosClient = new Jt(e, t, n);
1606
1606
  }
@@ -1651,50 +1651,50 @@ var bt = /* @__PURE__ */ function(e) {
1651
1651
  ...t ? { proof: t } : {}
1652
1652
  }, Ut());
1653
1653
  }
1654
- }, hn = 10, gn = 20, _n = class extends Error {
1654
+ }, mn = 10, hn = 20, gn = class extends Error {
1655
1655
  constructor(e) {
1656
1656
  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;
1657
1657
  }
1658
- }, vn = [], yn = 0, bn = !1, xn, Sn, Cn = (e, t) => e.priority - t.priority || e.seq - t.seq, wn = () => typeof globalThis > "u" ? void 0 : globalThis, Tn = async (e, t, n, r) => {
1658
+ }, _n = [], vn = 0, yn = !1, bn, xn, Sn = (e, t) => e.priority - t.priority || e.seq - t.seq, Cn = () => typeof globalThis > "u" ? void 0 : globalThis, wn = async (e, t, n, r) => {
1659
1659
  if (t >= e.length) {
1660
- let e = xn;
1660
+ let e = bn;
1661
1661
  if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
1662
1662
  return e(n, r);
1663
1663
  }
1664
1664
  let i = e[t];
1665
- if (!i) return Tn(e, e.length, n, r);
1666
- let a = !1, o = await i.middleware((n, r) => (a = !0, Tn(e, t + 1, n, r)), n, r);
1667
- if (!a) throw new _n(i.name);
1665
+ if (!i) return wn(e, e.length, n, r);
1666
+ let a = !1, o = await i.middleware((n, r) => (a = !0, wn(e, t + 1, n, r)), n, r);
1667
+ if (!a) throw new gn(i.name);
1668
1668
  return o;
1669
- }, En = () => {
1670
- let e = wn();
1669
+ }, Tn = () => {
1670
+ let e = Cn();
1671
1671
  if (!e || typeof e.fetch != "function") return !1;
1672
- let t = e.fetch.bind(e), n = (e, t) => Tn([...vn].sort(Cn), 0, e, t);
1673
- return xn = t, Sn = n, e.fetch = n, bn = !0, !0;
1674
- }, Dn = () => {
1675
- let e = wn();
1676
- e && Sn && e.fetch === Sn && (xn && (e.fetch = xn), bn = !1, Sn = void 0, xn = void 0);
1677
- }, On = (e, t) => {
1678
- if (!bn && !En()) return () => {};
1672
+ let t = e.fetch.bind(e), n = (e, t) => wn([..._n].sort(Sn), 0, e, t);
1673
+ return bn = t, xn = n, e.fetch = n, yn = !0, !0;
1674
+ }, En = () => {
1675
+ let e = Cn();
1676
+ e && xn && e.fetch === xn && (bn && (e.fetch = bn), yn = !1, xn = void 0, bn = void 0);
1677
+ }, Dn = (e, t) => {
1678
+ if (!yn && !Tn()) return () => {};
1679
1679
  let n = {
1680
1680
  middleware: e,
1681
1681
  name: t.name,
1682
1682
  priority: t.priority,
1683
- seq: yn++
1683
+ seq: vn++
1684
1684
  };
1685
- vn.push(n);
1685
+ _n.push(n);
1686
1686
  let r = !1;
1687
1687
  return () => {
1688
- r || (r = !0, vn = vn.filter((e) => e !== n), vn.length === 0 && Dn());
1688
+ r || (r = !0, _n = _n.filter((e) => e !== n), _n.length === 0 && En());
1689
1689
  };
1690
- }, kn = () => {
1691
- let e = wn();
1690
+ }, On = () => {
1691
+ let e = Cn();
1692
1692
  return {
1693
- installed: bn,
1694
- names: [...vn].sort(Cn).map((e) => e.name),
1695
- foreignPatch: bn && !!e && !!Sn && e.fetch !== Sn
1693
+ installed: yn,
1694
+ names: [..._n].sort(Sn).map((e) => e.name),
1695
+ foreignPatch: yn && !!e && !!xn && e.fetch !== xn
1696
1696
  };
1697
- }, V = class e extends Error {
1697
+ }, H = class e extends Error {
1698
1698
  constructor(t) {
1699
1699
  super(t.message), this.name = "M2MError", this.code = t.code, this.status = t.status ?? 400, this.errorUri = t.errorUri, this.rateLimitInfo = t.rateLimitInfo, this.headers = t.headers, this.cause = t.cause, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this, e);
1700
1700
  }
@@ -1763,7 +1763,7 @@ var bt = /* @__PURE__ */ function(e) {
1763
1763
  let e = `M2MError [${this.code}]: ${this.message}`;
1764
1764
  return this.status && (e += ` (HTTP ${this.status})`), e;
1765
1765
  }
1766
- }, An = class extends V {
1766
+ }, kn = class extends H {
1767
1767
  constructor(e, t) {
1768
1768
  super({
1769
1769
  code: "temporarily_unavailable",
@@ -1772,7 +1772,7 @@ var bt = /* @__PURE__ */ function(e) {
1772
1772
  cause: t
1773
1773
  }), this.name = "M2MNetworkError";
1774
1774
  }
1775
- }, jn = class extends V {
1775
+ }, An = class extends H {
1776
1776
  constructor(e, t) {
1777
1777
  super({
1778
1778
  code: "invalid_request",
@@ -1781,7 +1781,7 @@ var bt = /* @__PURE__ */ function(e) {
1781
1781
  cause: t
1782
1782
  }), this.name = "M2MTokenParseError";
1783
1783
  }
1784
- }, Mn = class extends V {
1784
+ }, jn = class extends H {
1785
1785
  constructor(e) {
1786
1786
  super({
1787
1787
  code: "invalid_request",
@@ -1789,7 +1789,7 @@ var bt = /* @__PURE__ */ function(e) {
1789
1789
  status: 400
1790
1790
  }), this.name = "M2MConfigError";
1791
1791
  }
1792
- }, Nn = {
1792
+ }, Mn = {
1793
1793
  InvalidRequest: "invalid_request",
1794
1794
  InvalidClient: "invalid_client",
1795
1795
  InvalidGrant: "invalid_grant",
@@ -1799,14 +1799,14 @@ var bt = /* @__PURE__ */ function(e) {
1799
1799
  RateLimitExceeded: "rate_limit_exceeded",
1800
1800
  ServerError: "server_error",
1801
1801
  TemporarilyUnavailable: "temporarily_unavailable"
1802
- }, Pn = {
1802
+ }, Nn = {
1803
1803
  TOKEN_ENDPOINT: "/oauth2/token",
1804
1804
  TIMEOUT: 1e4,
1805
1805
  RETRIES: 3,
1806
1806
  RETRY_DELAY: 1e3,
1807
1807
  REFRESH_THRESHOLD: 30,
1808
1808
  CONTENT_TYPE: "application/x-www-form-urlencoded"
1809
- }, Fn = class {
1809
+ }, Pn = class {
1810
1810
  constructor() {
1811
1811
  this.cache = /* @__PURE__ */ new Map();
1812
1812
  }
@@ -1823,18 +1823,18 @@ var bt = /* @__PURE__ */ function(e) {
1823
1823
  delete(e) {
1824
1824
  return this.cache.delete(e), Promise.resolve();
1825
1825
  }
1826
- }, In = {
1826
+ }, Fn = {
1827
1827
  shouldRetry(e, t) {
1828
1828
  return t >= 3 ? !1 : e.code === "server_error" || e.code === "temporarily_unavailable" || e.code === "rate_limit_exceeded" || e.status !== void 0 && e.status >= 500;
1829
1829
  },
1830
1830
  getDelay(e) {
1831
1831
  return 2 ** (e - 1) * 1e3;
1832
1832
  }
1833
- }, Ln = class {
1833
+ }, In = class {
1834
1834
  constructor(e) {
1835
- if (!e.url) throw new Mn("M2M client requires a URL");
1836
- if (!e.clientId) throw new Mn("M2M client requires a clientId");
1837
- if (!e.clientSecret) throw new Mn("M2M client requires a clientSecret");
1835
+ if (!e.url) throw new jn("M2M client requires a URL");
1836
+ if (!e.clientId) throw new jn("M2M client requires a clientId");
1837
+ if (!e.clientSecret) throw new jn("M2M client requires a clientSecret");
1838
1838
  let t = e.url.replace(/\/$/, "");
1839
1839
  this.config = {
1840
1840
  url: t,
@@ -1843,16 +1843,16 @@ var bt = /* @__PURE__ */ function(e) {
1843
1843
  scopes: e.scopes,
1844
1844
  audience: e.audience,
1845
1845
  autoRefresh: e.autoRefresh ?? !1,
1846
- refreshThreshold: e.refreshThreshold ?? Pn.REFRESH_THRESHOLD,
1847
- timeout: e.timeout ?? Pn.TIMEOUT,
1848
- retries: e.retries ?? Pn.RETRIES,
1849
- retryDelay: e.retryDelay ?? Pn.RETRY_DELAY,
1846
+ refreshThreshold: e.refreshThreshold ?? Nn.REFRESH_THRESHOLD,
1847
+ timeout: e.timeout ?? Nn.TIMEOUT,
1848
+ retries: e.retries ?? Nn.RETRIES,
1849
+ retryDelay: e.retryDelay ?? Nn.RETRY_DELAY,
1850
1850
  retryStrategy: e.retryStrategy,
1851
1851
  cache: e.cache,
1852
1852
  onTokenRequest: e.onTokenRequest,
1853
1853
  onTokenResponse: e.onTokenResponse,
1854
1854
  onError: e.onError
1855
- }, this.cache = e.cache ?? new Fn(), this.retryStrategy = e.retryStrategy ?? In, this.tokenEndpoint = `${t}${Pn.TOKEN_ENDPOINT}`;
1855
+ }, this.cache = e.cache ?? new Pn(), this.retryStrategy = e.retryStrategy ?? Fn, this.tokenEndpoint = `${t}${Nn.TOKEN_ENDPOINT}`;
1856
1856
  }
1857
1857
  getCacheKey(e, t) {
1858
1858
  let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
@@ -1897,7 +1897,7 @@ var bt = /* @__PURE__ */ function(e) {
1897
1897
  let e = await fetch(this.tokenEndpoint, {
1898
1898
  method: "POST",
1899
1899
  headers: {
1900
- "Content-Type": Pn.CONTENT_TYPE,
1900
+ "Content-Type": Nn.CONTENT_TYPE,
1901
1901
  Accept: "application/json"
1902
1902
  },
1903
1903
  body: t.toString(),
@@ -1910,7 +1910,7 @@ var bt = /* @__PURE__ */ function(e) {
1910
1910
  });
1911
1911
  let a = await e.json();
1912
1912
  if (!e.ok) {
1913
- let t = V.fromOAuthError({
1913
+ let t = H.fromOAuthError({
1914
1914
  error: a.error || "server_error",
1915
1915
  error_description: a.error_description || a.message,
1916
1916
  error_uri: a.error_uri
@@ -1922,7 +1922,7 @@ var bt = /* @__PURE__ */ function(e) {
1922
1922
  }
1923
1923
  return a;
1924
1924
  } catch (e) {
1925
- throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new An(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new An(`Network error: ${e.message}`, e) : e instanceof V ? e : V.fromError(e instanceof Error ? e : Error(String(e)));
1925
+ throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new kn(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new kn(`Network error: ${e.message}`, e) : e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
1926
1926
  }
1927
1927
  }
1928
1928
  async executeWithRetry(e) {
@@ -1930,7 +1930,7 @@ var bt = /* @__PURE__ */ function(e) {
1930
1930
  for (let n = 1; n <= this.config.retries; n++) try {
1931
1931
  return await e();
1932
1932
  } catch (e) {
1933
- if (!(e instanceof V)) throw e;
1933
+ if (!(e instanceof H)) throw e;
1934
1934
  if (t = e, n < this.config.retries && this.retryStrategy.shouldRetry({
1935
1935
  code: e.code,
1936
1936
  status: e.status
@@ -1941,7 +1941,7 @@ var bt = /* @__PURE__ */ function(e) {
1941
1941
  }
1942
1942
  throw e;
1943
1943
  }
1944
- throw t ?? new V({
1944
+ throw t ?? new H({
1945
1945
  code: "server_error",
1946
1946
  message: "Request failed after retries"
1947
1947
  });
@@ -1965,13 +1965,13 @@ var bt = /* @__PURE__ */ function(e) {
1965
1965
  parseToken(e) {
1966
1966
  try {
1967
1967
  let t = e.split(".");
1968
- if (t.length !== 3) throw new jn("Invalid JWT format: expected 3 parts");
1968
+ if (t.length !== 3) throw new An("Invalid JWT format: expected 3 parts");
1969
1969
  let n = t[1];
1970
- if (!n) throw new jn("Invalid JWT format: missing payload");
1970
+ if (!n) throw new An("Invalid JWT format: missing payload");
1971
1971
  let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
1972
1972
  return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
1973
1973
  } catch (e) {
1974
- throw e instanceof jn ? e : new jn(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
1974
+ throw e instanceof An ? e : new An(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
1975
1975
  }
1976
1976
  }
1977
1977
  clearCache() {
@@ -1986,19 +1986,19 @@ var bt = /* @__PURE__ */ function(e) {
1986
1986
  try {
1987
1987
  let e = await fetch(t, {
1988
1988
  method: "POST",
1989
- headers: { "Content-Type": Pn.CONTENT_TYPE },
1989
+ headers: { "Content-Type": Nn.CONTENT_TYPE },
1990
1990
  body: n.toString()
1991
1991
  });
1992
1992
  if (!e.ok && e.status !== 200) {
1993
1993
  let t = await e.json().catch(() => ({}));
1994
- throw V.fromOAuthError({
1994
+ throw H.fromOAuthError({
1995
1995
  error: t.error || "server_error",
1996
1996
  error_description: t.error_description || "Token revocation failed"
1997
1997
  }, e.status);
1998
1998
  }
1999
1999
  this.clearCache();
2000
2000
  } catch (e) {
2001
- throw e instanceof V ? e : V.fromError(e instanceof Error ? e : Error(String(e)));
2001
+ throw e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
2002
2002
  }
2003
2003
  }
2004
2004
  get url() {
@@ -2013,52 +2013,52 @@ var bt = /* @__PURE__ */ function(e) {
2013
2013
  get audience() {
2014
2014
  return this.config.audience;
2015
2015
  }
2016
- }, Rn = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", zn = 32, Bn = (e) => {
2016
+ }, Ln = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", Rn = 32, zn = (e) => {
2017
2017
  let t = "";
2018
2018
  for (let n = 0; n < e.length; n += 3) {
2019
2019
  let r = e[n], i = e[n + 1], a = e[n + 2];
2020
- t += Rn.charAt(r >> 2), t += Rn.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += Rn.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += Rn.charAt(a & 63));
2020
+ t += Ln.charAt(r >> 2), t += Ln.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += Ln.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += Ln.charAt(a & 63));
2021
2021
  }
2022
2022
  return t;
2023
- }, Vn = () => {
2023
+ }, Bn = () => {
2024
2024
  let e = globalThis.crypto;
2025
2025
  if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
2026
2026
  return e;
2027
- }, Hn = async (e) => {
2028
- let t = await Vn().subtle.digest("SHA-256", new TextEncoder().encode(e));
2029
- return Bn(new Uint8Array(t));
2030
- }, Un = (e = zn) => Bn(Vn().getRandomValues(new Uint8Array(e))), Wn = async () => {
2031
- let e = Un(zn);
2027
+ }, Vn = async (e) => {
2028
+ let t = await Bn().subtle.digest("SHA-256", new TextEncoder().encode(e));
2029
+ return zn(new Uint8Array(t));
2030
+ }, Hn = (e = Rn) => zn(Bn().getRandomValues(new Uint8Array(e))), Un = async () => {
2031
+ let e = Hn(Rn);
2032
2032
  return {
2033
2033
  verifier: e,
2034
- challenge: await Hn(e)
2034
+ challenge: await Vn(e)
2035
2035
  };
2036
- }, Gn = () => !!globalThis.crypto?.subtle, H = class extends Error {
2036
+ }, Wn = () => !!globalThis.crypto?.subtle, U = class extends Error {
2037
2037
  constructor(e, t) {
2038
2038
  super(t), this.code = e, this.name = "PassflowOidcError";
2039
2039
  }
2040
- }, Kn = "Sign in again.", qn = (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.`, Jn = "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.", Yn = () => new H("TOKENS_IN_URL_NOT_ALLOWED", "Tokens in the URL are accepted only for apps in Simple mode"), Xn = "passflow_oidc_pkce", Zn = 6e5, Qn = (e) => {
2040
+ }, Gn = "Sign in again.", Kn = (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.`, qn = "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.", Jn = () => new U("TOKENS_IN_URL_NOT_ALLOWED", "Tokens in the URL are accepted only for apps in Simple mode"), Yn = "passflow_oidc_pkce", Xn = 6e5, Zn = (e) => {
2041
2041
  try {
2042
2042
  let t = new URL(e);
2043
2043
  return `${t.protocol}//${t.host}${t.pathname.replace(/\/+$/, "")}`;
2044
2044
  } catch {
2045
2045
  return e;
2046
2046
  }
2047
- }, $n = (e) => !e.includes("openid") && (e.includes("id") || e.includes("oidc")) ? [...e, "openid"] : [...e], er = async (e) => {
2048
- if (!Gn()) throw new H("SECURE_CONTEXT_REQUIRED", "Sign-in needs the Web Crypto API, which is available only in a secure context (https or localhost)");
2049
- let t = $n(e.scopes), n = await Wn(), r = {
2047
+ }, Qn = (e) => !e.includes("openid") && (e.includes("id") || e.includes("oidc")) ? [...e, "openid"] : [...e], $n = async (e) => {
2048
+ if (!Wn()) throw new U("SECURE_CONTEXT_REQUIRED", "Sign-in needs the Web Crypto API, which is available only in a secure context (https or localhost)");
2049
+ let t = Qn(e.scopes), n = await Un(), r = {
2050
2050
  verifier: n.verifier,
2051
- state: Un(),
2052
- ...t.includes("openid") ? { nonce: Un() } : {},
2051
+ state: Hn(),
2052
+ ...t.includes("openid") ? { nonce: Hn() } : {},
2053
2053
  clientId: e.clientId,
2054
2054
  redirectUri: e.redirectUri,
2055
2055
  scopes: t,
2056
- expiresAt: Date.now() + Zn
2056
+ expiresAt: Date.now() + Xn
2057
2057
  };
2058
2058
  try {
2059
- sessionStorage.setItem(Xn, JSON.stringify(r));
2059
+ sessionStorage.setItem(Yn, JSON.stringify(r));
2060
2060
  } catch {
2061
- throw new H("STORAGE_UNAVAILABLE", "Sign-in needs sessionStorage, which cannot be written here");
2061
+ throw new U("STORAGE_UNAVAILABLE", "Sign-in needs sessionStorage, which cannot be written here");
2062
2062
  }
2063
2063
  let i = new URL(`${e.url.replace(/\/+$/, "")}/oidc/authorize`);
2064
2064
  return i.search = new URLSearchParams({
@@ -2071,37 +2071,37 @@ var bt = /* @__PURE__ */ function(e) {
2071
2071
  code_challenge_method: "S256",
2072
2072
  ...r.nonce ? { nonce: r.nonce } : {}
2073
2073
  }).toString(), i.toString();
2074
- }, tr = (e) => {
2074
+ }, er = (e) => {
2075
2075
  let t = e;
2076
2076
  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";
2077
- }, nr = () => {
2077
+ }, tr = () => {
2078
2078
  let e;
2079
2079
  try {
2080
- e = sessionStorage.getItem(Xn);
2080
+ e = sessionStorage.getItem(Yn);
2081
2081
  } catch {
2082
2082
  return { status: "none" };
2083
2083
  }
2084
2084
  if (!e) return { status: "none" };
2085
2085
  try {
2086
2086
  let t = JSON.parse(e);
2087
- if (tr(t) && Date.now() < t.expiresAt) return {
2087
+ if (er(t) && Date.now() < t.expiresAt) return {
2088
2088
  status: "live",
2089
2089
  slot: t
2090
2090
  };
2091
2091
  } catch {}
2092
2092
  return { status: "unusable" };
2093
- }, rr = () => {
2093
+ }, nr = () => {
2094
2094
  try {
2095
- sessionStorage.removeItem(Xn);
2095
+ sessionStorage.removeItem(Yn);
2096
2096
  } catch {}
2097
- }, ir = async (e) => {
2097
+ }, rr = async (e) => {
2098
2098
  try {
2099
2099
  let t = await e.json();
2100
2100
  return typeof t == "object" && t ? t : void 0;
2101
2101
  } catch {
2102
2102
  return;
2103
2103
  }
2104
- }, ar = async (e, t, n) => {
2104
+ }, ir = async (e, t, n) => {
2105
2105
  let r;
2106
2106
  try {
2107
2107
  r = await fetch(`${e.replace(/\/+$/, "")}/oidc/token`, {
@@ -2116,11 +2116,11 @@ var bt = /* @__PURE__ */ function(e) {
2116
2116
  }).toString()
2117
2117
  });
2118
2118
  } catch {
2119
- throw new H("TOKEN_EXCHANGE_FAILED", Kn);
2119
+ throw new U("TOKEN_EXCHANGE_FAILED", Gn);
2120
2120
  }
2121
- let i = await ir(r);
2122
- if (!r.ok) throw i?.error === "invalid_client" ? new H("invalid_client", Jn) : i?.error === "invalid_grant" ? new H("invalid_grant", Kn) : new H("TOKEN_EXCHANGE_FAILED", Kn);
2123
- if (typeof i?.access_token != "string") throw new H("TOKEN_EXCHANGE_FAILED", Kn);
2121
+ let i = await rr(r);
2122
+ if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client", qn) : i?.error === "invalid_grant" ? new U("invalid_grant", Gn) : new U("TOKEN_EXCHANGE_FAILED", Gn);
2123
+ if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED", Gn);
2124
2124
  let a = typeof i.id_token == "string" ? i.id_token : void 0;
2125
2125
  if (n.scopes.includes("openid")) {
2126
2126
  let e;
@@ -2129,7 +2129,7 @@ var bt = /* @__PURE__ */ function(e) {
2129
2129
  } catch {
2130
2130
  e = void 0;
2131
2131
  }
2132
- if (!a || e !== n.nonce) throw new H("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${Kn}`);
2132
+ if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${Gn}`);
2133
2133
  }
2134
2134
  return {
2135
2135
  access_token: i.access_token,
@@ -2137,13 +2137,13 @@ var bt = /* @__PURE__ */ function(e) {
2137
2137
  ...a ? { id_token: a } : {},
2138
2138
  scopes: n.scopes
2139
2139
  };
2140
- }, or = "error", sr = /* @__PURE__ */ new WeakMap(), cr = (e, t) => {
2140
+ }, ar = "error", or = /* @__PURE__ */ new WeakMap(), sr = (e, t) => {
2141
2141
  if (typeof t != "object" && typeof t != "function" || t === null) return !0;
2142
- let n = sr.get(e);
2143
- return n || (n = /* @__PURE__ */ new WeakSet(), sr.set(e, n)), !n.has(t) && (n.add(t), !0);
2144
- }, U = (e, t) => cr(e, t.originalError) ? (e.notify(or, t), !0) : !1, W = /* @__PURE__ */ function(e) {
2142
+ let n = or.get(e);
2143
+ return n || (n = /* @__PURE__ */ new WeakSet(), or.set(e, n)), !n.has(t) && (n.add(t), !0);
2144
+ }, W = (e, t) => sr(e, t.originalError) ? (e.notify(ar, t), !0) : !1, G = /* @__PURE__ */ function(e) {
2145
2145
  return e.SignIn = "signin", e.SignInStart = "signin:start", e.Register = "register", e.RegisterStart = "register:start", e.EmailVerificationRequired = "email-verification:required", e.SignOut = "signout", e.SessionRestored = "session:restored", e.SessionExpired = "session:expired", e.Error = "error", e.Refresh = "refresh", e.RefreshStart = "refresh:start", e.TokenCacheExpired = "token-cache-expired", e.TwoFactorRequired = "2fa:required", e.TwoFactorSetupStarted = "2fa:setup_started", e.TwoFactorEnabled = "2fa:enabled", e.TwoFactorDisabled = "2fa:disabled", e.TwoFactorVerified = "2fa:verified", e.TwoFactorRecoveryUsed = "2fa:recovery_used", e.TwoFactorRecoveryCodesLow = "2fa:recovery_low", e.TwoFactorRecoveryCodesExhausted = "2fa:recovery_exhausted", e.TwoFactorSetupMagicLinkValidated = "2fa:magic_link_validated", e.TwoFactorSetupMagicLinkFailed = "2fa:magic_link_failed", e.TwoFactorChallengeReceived = "two_factor_challenge_received", e.TwoFactorMethodSwitched = "two_factor_method_switched", e.TwoFactorDeviceTrusted = "two_factor_device_trusted", e.RefreshFailing = "refresh:failing", e.RefreshRecovered = "refresh:recovered", e.AntiBotSolving = "anti-bot:solving", e.AntiBotSolved = "anti-bot:solved", e;
2146
- }({}), lr = class {
2146
+ }({}), cr = class {
2147
2147
  constructor() {
2148
2148
  this.subscribers = /* @__PURE__ */ new Map();
2149
2149
  }
@@ -2162,40 +2162,40 @@ var bt = /* @__PURE__ */ function(e) {
2162
2162
  n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
2163
2163
  }
2164
2164
  notify(e, t) {
2165
- e === "error" && cr(this, t?.originalError), this.subscribers.forEach((n, r) => {
2165
+ e === "error" && sr(this, t?.originalError), this.subscribers.forEach((n, r) => {
2166
2166
  (!n || n.has(e)) && r.onAuthChange?.(e, t);
2167
2167
  });
2168
2168
  }
2169
2169
  notifyError(e) {
2170
- return U(this, e);
2170
+ return W(this, e);
2171
2171
  }
2172
- }, ur = 256, dr = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), fr = (e) => {
2172
+ }, lr = 256, ur = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), dr = (e) => {
2173
2173
  let t = new Uint8Array(e), n = "";
2174
- for (let e of t) n += dr[e];
2174
+ for (let e of t) n += ur[e];
2175
2175
  return n;
2176
- }, pr = class extends Error {};
2177
- async function mr(e, t, n, r = Infinity) {
2176
+ }, fr = class extends Error {};
2177
+ async function pr(e, t, n, r = Infinity) {
2178
2178
  let i = globalThis.crypto?.subtle;
2179
2179
  if (!i) throw Error("Web Crypto unavailable");
2180
2180
  let a = t.toLowerCase(), o = new TextEncoder();
2181
- for (let t = 0; t <= n; t += ur) {
2182
- if (Date.now() > r) throw new pr("Solve timed out");
2183
- let s = Math.min(t + ur - 1, n), c = [];
2181
+ for (let t = 0; t <= n; t += lr) {
2182
+ if (Date.now() > r) throw new fr("Solve timed out");
2183
+ let s = Math.min(t + lr - 1, n), c = [];
2184
2184
  for (let n = t; n <= s; n++) c.push(i.digest("SHA-256", o.encode(`${e}:${n}`)));
2185
2185
  let l = await Promise.all(c);
2186
- for (let e = 0; e < l.length; e++) if (fr(l[e]) === a) return t + e;
2186
+ for (let e = 0; e < l.length; e++) if (dr(l[e]) === a) return t + e;
2187
2187
  }
2188
2188
  return null;
2189
2189
  }
2190
2190
  // lib/anti-bot/solve.ts
2191
- var hr = "The browser check could not be completed. Try again later.", gr = "Verification failed. Try again.", _r = 6e4, vr = class extends Error {}, yr = (e, t, n, r) => new z({
2191
+ var mr = "The browser check could not be completed. Try again later.", hr = "Verification failed. Try again.", gr = 6e4, _r = class extends Error {}, vr = (e, t, n, r) => new z({
2192
2192
  id: e,
2193
2193
  message: t,
2194
2194
  status: 0,
2195
2195
  location: n,
2196
2196
  time: (/* @__PURE__ */ new Date()).toISOString()
2197
- }, r === void 0 ? void 0 : { cause: r }), br = (e, t) => new Promise((n, r) => {
2198
- let i = new Worker(e), a = setTimeout(() => o(() => r(new vr())), _r), o = (e) => {
2197
+ }, r === void 0 ? void 0 : { cause: r }), yr = (e, t) => new Promise((n, r) => {
2198
+ let i = new Worker(e), a = setTimeout(() => o(() => r(new _r())), gr), o = (e) => {
2199
2199
  clearTimeout(a), i.terminate(), e();
2200
2200
  };
2201
2201
  i.addEventListener("message", (e) => {
@@ -2203,23 +2203,23 @@ var hr = "The browser check could not be completed. Try again later.", gr = "Ver
2203
2203
  t && "error" in t ? o(() => r(Error(t.error))) : o(() => n(t?.number ?? null));
2204
2204
  }), i.addEventListener("error", () => o(() => r(/* @__PURE__ */ Error("Anti-bot worker failed")))), i.addEventListener("messageerror", () => o(() => r(/* @__PURE__ */ Error("Anti-bot worker message failed")))), i.postMessage(t);
2205
2205
  });
2206
- async function xr(e, t, n = "anti-bot") {
2207
- if (e.algorithm !== "SHA-256") throw yr(Qe, hr, n);
2208
- if (!Number.isSafeInteger(e.max) || e.max < 0 || e.max > 5e6) throw yr(Qe, gr, n);
2206
+ async function br(e, t, n = "anti-bot") {
2207
+ if (e.algorithm !== "SHA-256") throw vr(Qe, mr, n);
2208
+ if (!Number.isSafeInteger(e.max) || e.max < 0 || e.max > 5e6) throw vr(Qe, hr, n);
2209
2209
  let r = {
2210
2210
  salt: e.salt,
2211
2211
  challenge: e.challenge,
2212
2212
  max: e.max
2213
2213
  }, i;
2214
2214
  try {
2215
- i = t && typeof Worker < "u" ? await br(t, r) : await mr(r.salt, r.challenge, r.max, Date.now() + _r);
2215
+ i = t && typeof Worker < "u" ? await yr(t, r) : await pr(r.salt, r.challenge, r.max, Date.now() + gr);
2216
2216
  } catch (e) {
2217
- throw yr(Qe, e instanceof vr || e instanceof pr ? gr : hr, n, e);
2217
+ throw vr(Qe, e instanceof _r || e instanceof fr ? hr : mr, n, e);
2218
2218
  }
2219
- if (i === null) throw yr(Qe, hr, n);
2219
+ if (i === null) throw vr(Qe, mr, n);
2220
2220
  return i;
2221
2221
  }
2222
- function Sr(e, t) {
2222
+ function xr(e, t) {
2223
2223
  let n = {
2224
2224
  app: e.app,
2225
2225
  exp: e.exp,
@@ -2232,8 +2232,8 @@ function Sr(e, t) {
2232
2232
  return btoa(JSON.stringify(n));
2233
2233
  }
2234
2234
  // lib/anti-bot/anti-bot.ts
2235
- var Cr = "This app requires a verification token. Call setAntiBotTokenProvider() before signing in.", wr = "The verification could not be completed. Try again.";
2236
- function Tr(e) {
2235
+ var Sr = "This app requires a verification token. Call setAntiBotTokenProvider() before signing in.", Cr = "The verification could not be completed. Try again.";
2236
+ function wr(e) {
2237
2237
  let t, n = async (e, t) => {
2238
2238
  let n;
2239
2239
  try {
@@ -2242,16 +2242,16 @@ function Tr(e) {
2242
2242
  operation: t.operation
2243
2243
  });
2244
2244
  } catch (e) {
2245
- throw yr(Ze, wr, t.operation, e);
2245
+ throw vr(Ze, Cr, t.operation, e);
2246
2246
  }
2247
- if (typeof n != "string" || n === "") throw yr(Ze, wr, t.operation);
2247
+ if (typeof n != "string" || n === "") throw vr(Ze, Cr, t.operation);
2248
2248
  return n;
2249
2249
  }, r = async (t) => {
2250
2250
  let n = await e.fetchChallenge({
2251
2251
  ...t.identifier ? { identifier: t.identifier } : {},
2252
2252
  ...t.device ? { device: t.device } : {}
2253
2253
  });
2254
- return Sr(n, await xr(n, e.workerUrl, t.operation));
2254
+ return xr(n, await br(n, e.workerUrl, t.operation));
2255
2255
  };
2256
2256
  return {
2257
2257
  setTokenProvider(e) {
@@ -2261,7 +2261,7 @@ function Tr(e) {
2261
2261
  let a = i.settings ?? await e.readSettings().catch(() => void 0);
2262
2262
  if (a?.bot_mode !== "human_only") return;
2263
2263
  let o = a.anti_bot?.provider ?? "builtin", s = o === "builtin";
2264
- e.store.notify(W.AntiBotSolving, {
2264
+ e.store.notify(G.AntiBotSolving, {
2265
2265
  operation: i.operation,
2266
2266
  provider: o
2267
2267
  });
@@ -2269,10 +2269,10 @@ function Tr(e) {
2269
2269
  if (s) c = await r(i);
2270
2270
  else {
2271
2271
  let e = t;
2272
- if (!e) throw yr(Xe, Cr, i.operation);
2272
+ if (!e) throw vr(Xe, Sr, i.operation);
2273
2273
  c = await n(e, i);
2274
2274
  }
2275
- return e.store.notify(W.AntiBotSolved, {
2275
+ return e.store.notify(G.AntiBotSolved, {
2276
2276
  operation: i.operation,
2277
2277
  provider: o
2278
2278
  }), {
@@ -2283,97 +2283,97 @@ function Tr(e) {
2283
2283
  };
2284
2284
  }
2285
2285
  // lib/refresh/constants.ts
2286
- var Er = "passflow-refresh", Dr = "passflow-refresh-takeover", Or = "passflow-auth", kr = Object.freeze([
2286
+ var Tr = "passflow-refresh", Er = "passflow-refresh-takeover", Dr = "passflow-auth", Or = Object.freeze([
2287
2287
  1e3,
2288
2288
  3e3,
2289
2289
  1e4,
2290
2290
  3e4,
2291
2291
  6e4
2292
- ]), Ar = .2, jr = 6e5, Mr = 5e3, G = 2e4, Nr = 2e4, Pr = 1e3, Fr = 2e3, Ir = 1e3, Lr = 1e4, Rr = 5e3;
2292
+ ]), kr = .2, Ar = 6e5, jr = 5e3, K = 2e4, Mr = 2e4, Nr = 1e3, Pr = 2e3, Fr = 1e3, Ir = 1e4, Lr = 5e3;
2293
2293
  // lib/refresh/protocol.ts
2294
- function zr(e) {
2294
+ function Rr(e) {
2295
2295
  let t = e ? `:${e}` : "";
2296
2296
  return {
2297
- lock: `${Er}${t}`,
2298
- takeoverLock: `${Dr}${t}`,
2299
- channel: `${Or}${t}`
2297
+ lock: `${Tr}${t}`,
2298
+ takeoverLock: `${Er}${t}`,
2299
+ channel: `${Dr}${t}`
2300
2300
  };
2301
2301
  }
2302
- function K(e) {
2302
+ function q(e) {
2303
2303
  return typeof e == "string" && e !== "" ? e : void 0;
2304
2304
  }
2305
- function Br(e) {
2305
+ function zr(e) {
2306
2306
  return typeof e == "number" && Number.isFinite(e) ? e : void 0;
2307
2307
  }
2308
- function Vr(e) {
2308
+ function Br(e) {
2309
2309
  return typeof e == "object" && !!e;
2310
2310
  }
2311
- function Hr(e, t) {
2311
+ function Vr(e, t) {
2312
2312
  for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
2313
2313
  return e;
2314
2314
  }
2315
- function Ur(e) {
2316
- if (!Vr(e)) return null;
2315
+ function Hr(e) {
2316
+ if (!Br(e)) return null;
2317
2317
  let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
2318
- return Hr({}, {
2319
- access_token: K(e.access_token),
2320
- refresh_token: K(e.refresh_token),
2321
- id_token: K(e.id_token),
2318
+ return Vr({}, {
2319
+ access_token: q(e.access_token),
2320
+ refresh_token: q(e.refresh_token),
2321
+ id_token: q(e.id_token),
2322
2322
  scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
2323
2323
  });
2324
2324
  }
2325
- function Wr(e) {
2326
- if (!Vr(e)) return null;
2325
+ function Ur(e) {
2326
+ if (!Br(e)) return null;
2327
2327
  let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
2328
- return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || Br(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Hr({
2328
+ return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || zr(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Vr({
2329
2329
  kind: t,
2330
2330
  attempt: n,
2331
2331
  nextAt: r,
2332
2332
  strikes: i
2333
2333
  }, {
2334
- from: K(e.from),
2335
- failingSince: Br(e.failingSince)
2334
+ from: q(e.from),
2335
+ failingSince: zr(e.failingSince)
2336
2336
  });
2337
2337
  }
2338
- function Gr(e) {
2339
- return Hr({}, {
2340
- fp: K(e.fp),
2341
- sub: K(e.sub),
2342
- sid: K(e.sid),
2343
- iat: Br(e.iat)
2338
+ function Wr(e) {
2339
+ return Vr({}, {
2340
+ fp: q(e.fp),
2341
+ sub: q(e.sub),
2342
+ sid: q(e.sid),
2343
+ iat: zr(e.iat)
2344
2344
  });
2345
2345
  }
2346
- function Kr(e) {
2347
- if (!Vr(e)) return null;
2346
+ function Gr(e) {
2347
+ if (!Br(e)) return null;
2348
2348
  let t = e;
2349
2349
  if (t.v !== void 0 && t.v !== 1) return null;
2350
- let n = K(t.tabId);
2350
+ let n = q(t.tabId);
2351
2351
  if (!n) return null;
2352
2352
  switch (t.type) {
2353
2353
  case "tokens-refreshed": {
2354
- let e = Ur(t.tokens), r = K(t.from), i = K(t.to);
2355
- return !e || !r || !i ? null : Hr({
2354
+ let e = Hr(t.tokens), r = q(t.from), i = q(t.to);
2355
+ return !e || !r || !i ? null : Vr({
2356
2356
  type: t.type,
2357
2357
  tabId: n,
2358
2358
  tokens: e,
2359
2359
  from: r,
2360
2360
  to: i
2361
2361
  }, {
2362
- fromIat: Br(t.fromIat),
2362
+ fromIat: zr(t.fromIat),
2363
2363
  fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
2364
- sentAt: Br(t.sentAt)
2364
+ sentAt: zr(t.sentAt)
2365
2365
  });
2366
2366
  }
2367
2367
  case "session-refreshed": {
2368
- let e = Br(t.at);
2369
- return e === void 0 ? null : Hr({
2368
+ let e = zr(t.at);
2369
+ return e === void 0 ? null : Vr({
2370
2370
  type: t.type,
2371
2371
  tabId: n,
2372
2372
  at: e
2373
- }, { sub: K(t.sub) });
2373
+ }, { sub: q(t.sub) });
2374
2374
  }
2375
2375
  case "still-refreshing": {
2376
- let e = t.retry === void 0 ? null : Wr(t.retry);
2376
+ let e = t.retry === void 0 ? null : Ur(t.retry);
2377
2377
  return e ? {
2378
2378
  type: t.type,
2379
2379
  tabId: n,
@@ -2384,7 +2384,7 @@ function Kr(e) {
2384
2384
  };
2385
2385
  }
2386
2386
  case "retry-scheduled": {
2387
- let e = Wr(t);
2387
+ let e = Ur(t);
2388
2388
  return e ? {
2389
2389
  type: t.type,
2390
2390
  tabId: n,
@@ -2405,10 +2405,10 @@ function Kr(e) {
2405
2405
  case "signed-out": return {
2406
2406
  type: t.type,
2407
2407
  tabId: n,
2408
- ...Gr(t)
2408
+ ...Wr(t)
2409
2409
  };
2410
2410
  case "rate-limited": {
2411
- let e = Br(t.until);
2411
+ let e = zr(t.until);
2412
2412
  return e === void 0 ? null : {
2413
2413
  type: t.type,
2414
2414
  tabId: n,
@@ -2416,7 +2416,7 @@ function Kr(e) {
2416
2416
  };
2417
2417
  }
2418
2418
  case "refresh-failed": {
2419
- let e = K(t.from);
2419
+ let e = q(t.from);
2420
2420
  return e ? {
2421
2421
  type: t.type,
2422
2422
  tabId: n,
@@ -2427,22 +2427,22 @@ function Kr(e) {
2427
2427
  default: return null;
2428
2428
  }
2429
2429
  }
2430
- function qr(e, t) {
2430
+ function Kr(e, t) {
2431
2431
  let n = {
2432
2432
  v: 1,
2433
2433
  tabId: e
2434
2434
  };
2435
2435
  if (t.type === "retry-scheduled") {
2436
2436
  let { retry: e, ...r } = t;
2437
- return Hr(n, {
2437
+ return Vr(n, {
2438
2438
  ...r,
2439
2439
  ...e
2440
2440
  });
2441
2441
  }
2442
- return Hr(n, { ...t });
2442
+ return Vr(n, { ...t });
2443
2443
  }
2444
2444
  // lib/refresh/resolve.ts
2445
- var Jr = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", Yr = {
2445
+ var qr = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", Jr = {
2446
2446
  now: () => Date.now(),
2447
2447
  random: () => Math.random(),
2448
2448
  setTimeout: (e, t) => {
@@ -2450,28 +2450,28 @@ var Jr = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
2450
2450
  return n.unref?.(), () => clearTimeout(n);
2451
2451
  }
2452
2452
  };
2453
- function Xr() {
2453
+ function Yr() {
2454
2454
  let e = globalThis.crypto;
2455
2455
  return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
2456
2456
  }
2457
- function Zr(e) {
2457
+ function Xr(e) {
2458
2458
  return e ? {
2459
2459
  now: () => e.now(),
2460
2460
  setTimeout: (t, n) => e.setTimeout(t, n),
2461
- random: e.random ? () => e.random?.() ?? Math.random() : Yr.random
2462
- } : Yr;
2461
+ random: e.random ? () => e.random?.() ?? Math.random() : Jr.random
2462
+ } : Jr;
2463
2463
  }
2464
- function Qr(e) {
2464
+ function Zr(e) {
2465
2465
  return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
2466
2466
  }
2467
- function $r(e) {
2467
+ function Qr(e) {
2468
2468
  try {
2469
2469
  return e.storageSharedAcrossTabs === !0;
2470
2470
  } catch {
2471
2471
  return !1;
2472
2472
  }
2473
2473
  }
2474
- function ei() {
2474
+ function $r() {
2475
2475
  try {
2476
2476
  let e = globalThis.navigator?.locks;
2477
2477
  return e && typeof e.request == "function" ? e : void 0;
@@ -2479,7 +2479,7 @@ function ei() {
2479
2479
  return;
2480
2480
  }
2481
2481
  }
2482
- function ti(e) {
2482
+ function ei(e) {
2483
2483
  return (t) => {
2484
2484
  let n = (n) => {
2485
2485
  let r = n.key;
@@ -2488,20 +2488,20 @@ function ti(e) {
2488
2488
  return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
2489
2489
  };
2490
2490
  }
2491
- function ni(e) {
2491
+ function ti(e) {
2492
2492
  return {
2493
2493
  transports: null,
2494
- names: zr(e),
2495
- clock: Yr,
2494
+ names: Rr(e),
2495
+ clock: Jr,
2496
2496
  warnOnFirstCycle: !1
2497
2497
  };
2498
2498
  }
2499
- function ri(e, t, n, r) {
2500
- let i = zr(n), a = Qr(t), o = a ? ti(r.tokenKeys) : void 0, s = (e) => {
2499
+ function ni(e, t, n, r) {
2500
+ let i = Rr(n), a = Zr(t), o = a ? ei(r.tokenKeys) : void 0, s = (e) => {
2501
2501
  let t = {
2502
2502
  transports: null,
2503
2503
  names: i,
2504
- clock: Yr,
2504
+ clock: Jr,
2505
2505
  warnOnFirstCycle: e
2506
2506
  };
2507
2507
  return o && (t.onStorageChange = o), t;
@@ -2511,16 +2511,16 @@ function ri(e, t, n, r) {
2511
2511
  transports: {
2512
2512
  locks: e.locks,
2513
2513
  channel: e.channel,
2514
- tabId: e.tabId ?? Xr()
2514
+ tabId: e.tabId ?? Yr()
2515
2515
  },
2516
2516
  names: i,
2517
- clock: Zr(e.clock),
2517
+ clock: Xr(e.clock),
2518
2518
  warnOnFirstCycle: !1
2519
2519
  };
2520
2520
  return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
2521
2521
  }
2522
- if (e === "none" || !a || !$r(t)) return s(!1);
2523
- let c = ei();
2522
+ if (e === "none" || !a || !Qr(t)) return s(!1);
2523
+ let c = $r();
2524
2524
  if (!c || typeof BroadcastChannel != "function") return s(!0);
2525
2525
  let l;
2526
2526
  try {
@@ -2532,16 +2532,16 @@ function ri(e, t, n, r) {
2532
2532
  transports: {
2533
2533
  locks: c,
2534
2534
  channel: l,
2535
- tabId: Xr()
2535
+ tabId: Yr()
2536
2536
  },
2537
2537
  names: i,
2538
- clock: Yr,
2538
+ clock: Jr,
2539
2539
  warnOnFirstCycle: !1
2540
2540
  };
2541
2541
  return o && (u.onStorageChange = o), u;
2542
2542
  }
2543
2543
  // lib/services/logger.ts
2544
- var ii = class {
2544
+ var ri = class {
2545
2545
  error(e, ...t) {
2546
2546
  console.error(e, ...t);
2547
2547
  }
@@ -2555,10 +2555,10 @@ var ii = class {
2555
2555
  console.debug(e, ...t);
2556
2556
  }
2557
2557
  };
2558
- function ai() {
2559
- return new ii();
2558
+ function ii() {
2559
+ return new ri();
2560
2560
  }
2561
- var oi = Object.freeze([
2561
+ var ai = Object.freeze([
2562
2562
  "error.token.invalid.error",
2563
2563
  "error.api.token.parse.error",
2564
2564
  "error.api.user.blocked",
@@ -2566,25 +2566,25 @@ var oi = Object.freeze([
2566
2566
  "error.validation.token.invalid.subject",
2567
2567
  "error.not.found"
2568
2568
  ]);
2569
- function si(e) {
2569
+ function oi(e) {
2570
2570
  if (typeof e != "object" || !e) return;
2571
2571
  let t = e;
2572
2572
  return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
2573
2573
  }
2574
- function ci(e, t) {
2575
- if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(jr, Math.floor(e) * 1e3);
2574
+ function si(e, t) {
2575
+ if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(Ar, Math.floor(e) * 1e3);
2576
2576
  if (typeof e != "string") return;
2577
2577
  let n = e.trim();
2578
2578
  if (n === "") return;
2579
- if (/^\d+$/.test(n)) return Math.min(jr, Number.parseInt(n, 10) * 1e3);
2579
+ if (/^\d+$/.test(n)) return Math.min(Ar, Number.parseInt(n, 10) * 1e3);
2580
2580
  if (!/[a-z]/i.test(n)) return;
2581
2581
  let r = Date.parse(n);
2582
- if (!Number.isNaN(r)) return Math.min(jr, Math.max(0, r - t));
2582
+ if (!Number.isNaN(r)) return Math.min(Ar, Math.max(0, r - t));
2583
2583
  }
2584
- function li(e) {
2584
+ function ci(e) {
2585
2585
  return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
2586
2586
  }
2587
- function ui(e) {
2587
+ function li(e) {
2588
2588
  if (typeof e.id == "string" && e.id !== "") return e.id;
2589
2589
  let t = e.response?.data;
2590
2590
  if (typeof t != "object" || !t) return;
@@ -2593,14 +2593,14 @@ function ui(e) {
2593
2593
  let r = n.id;
2594
2594
  return typeof r == "string" && r !== "" ? r : void 0;
2595
2595
  }
2596
- function di(e, t = Date.now()) {
2596
+ function ui(e, t = Date.now()) {
2597
2597
  if (typeof e != "object" || !e) return { kind: "transient" };
2598
- let n = e, r = ui(n), i = li(n.response?.status) ?? li(n.status), a = {};
2598
+ let n = e, r = li(n), i = ci(n.response?.status) ?? ci(n.status), a = {};
2599
2599
  if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
2600
2600
  kind: "blocked",
2601
2601
  ...a
2602
2602
  };
2603
- if (r !== void 0 && oi.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
2603
+ if (r !== void 0 && ai.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
2604
2604
  kind: "auth",
2605
2605
  ...a
2606
2606
  };
@@ -2608,7 +2608,7 @@ function di(e, t = Date.now()) {
2608
2608
  kind: "transient",
2609
2609
  ...a
2610
2610
  };
2611
- let o = ci(n.retryAfter ?? si(n.response?.headers), t);
2611
+ let o = si(n.retryAfter ?? oi(n.response?.headers), t);
2612
2612
  return o === void 0 ? {
2613
2613
  kind: "transient",
2614
2614
  ...a
@@ -2618,19 +2618,19 @@ function di(e, t = Date.now()) {
2618
2618
  retryAfterMs: o
2619
2619
  };
2620
2620
  }
2621
- function fi(e, t, n) {
2622
- let r = kr.length, i = kr[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? kr[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * Ar * a);
2623
- return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), jr) : 0);
2621
+ function di(e, t, n) {
2622
+ let r = Or.length, i = Or[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? Or[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * kr * a);
2623
+ return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), Ar) : 0);
2624
2624
  }
2625
2625
  // lib/refresh/coordinator.ts
2626
- var pi = {
2626
+ var fi = {
2627
2627
  onGranted: () => !1,
2628
2628
  onLockLost: () => void 0,
2629
2629
  onMessage: () => void 0
2630
2630
  };
2631
- function mi(e) {
2632
- let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = pi, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
2633
- g || n.postMessage(qr(r, e));
2631
+ function pi(e) {
2632
+ let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = fi, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
2633
+ g || n.postMessage(Kr(r, e));
2634
2634
  }, v = () => s !== null && c === null, y = () => {
2635
2635
  f?.(), f = null;
2636
2636
  }, b = (e) => {
@@ -2645,7 +2645,7 @@ function mi(e) {
2645
2645
  type: "still-refreshing",
2646
2646
  retry: m
2647
2647
  } : { type: "still-refreshing" }), ee());
2648
- }, Mr);
2648
+ }, jr);
2649
2649
  }, S = () => {
2650
2650
  y(), x(), u?.(), u = null;
2651
2651
  let e = s;
@@ -2686,29 +2686,29 @@ function mi(e) {
2686
2686
  let e = s;
2687
2687
  t.request(i.takeoverLock, { ifAvailable: !0 }, (t) => {
2688
2688
  if (s === e && v()) {
2689
- if (t === null) b(a.now() + G);
2689
+ if (t === null) b(a.now() + K);
2690
2690
  else return _({ type: "takeover" }), new Promise((t) => {
2691
2691
  u = t, e && (e.dead = !0, e.abort.abort()), E(!0);
2692
2692
  });
2693
2693
  }
2694
2694
  }).catch(() => {
2695
- v() && b(a.now() + G);
2695
+ v() && b(a.now() + K);
2696
2696
  });
2697
2697
  }, D = (e) => {
2698
2698
  if (g) return;
2699
- let t = Kr(e.data);
2699
+ let t = Gr(e.data);
2700
2700
  if (t && t.tabId !== r) {
2701
2701
  switch (t.type) {
2702
2702
  case "still-refreshing":
2703
- h = !0, v() && (b(a.now() + G), t.retry && b(t.retry.nextAt + G));
2703
+ h = !0, v() && (b(a.now() + K), t.retry && b(t.retry.nextAt + K));
2704
2704
  break;
2705
2705
  case "takeover":
2706
- h = !0, v() && b(a.now() + G);
2706
+ h = !0, v() && b(a.now() + K);
2707
2707
  break;
2708
2708
  case "retry-scheduled":
2709
- h = !0, v() && b(Math.max(a.now(), t.retry.nextAt) + G);
2709
+ h = !0, v() && b(Math.max(a.now(), t.retry.nextAt) + K);
2710
2710
  break;
2711
- case "rate-limited": v() && b(t.until + G);
2711
+ case "rate-limited": v() && b(t.until + K);
2712
2712
  }
2713
2713
  o.onMessage(t);
2714
2714
  }
@@ -2726,7 +2726,7 @@ function mi(e) {
2726
2726
  o = e;
2727
2727
  },
2728
2728
  request: (e) => {
2729
- g || s || (p = 0, b(Math.max(a.now() + G, e ?? 0)), E(!1));
2729
+ g || s || (p = 0, b(Math.max(a.now() + K, e ?? 0)), E(!1));
2730
2730
  },
2731
2731
  release: S,
2732
2732
  post: _,
@@ -2739,8 +2739,8 @@ function mi(e) {
2739
2739
  }
2740
2740
  };
2741
2741
  }
2742
- function hi(e = "local") {
2743
- let t = pi, n = !1, r = !1, i = 0, a = !1, o = () => {
2742
+ function mi(e = "local") {
2743
+ let t = fi, n = !1, r = !1, i = 0, a = !1, o = () => {
2744
2744
  n = !1, r = !1, i += 1;
2745
2745
  };
2746
2746
  return {
@@ -2780,7 +2780,7 @@ function hi(e = "local") {
2780
2780
  };
2781
2781
  }
2782
2782
  // lib/refresh/errors.ts
2783
- var q = {
2783
+ var J = {
2784
2784
  unavailable: "error.refresh.unavailable",
2785
2785
  authRetry: "error.refresh.auth_retry",
2786
2786
  sessionEnded: "error.refresh.session_ended",
@@ -2788,7 +2788,7 @@ var q = {
2788
2788
  successorTimeout: "error.refresh.successor_timeout",
2789
2789
  identityChanged: "error.refresh.identity_changed",
2790
2790
  disposed: "error.refresh.disposed"
2791
- }, gi = {
2791
+ }, hi = {
2792
2792
  "error.refresh.unavailable": 503,
2793
2793
  "error.refresh.auth_retry": 401,
2794
2794
  "error.refresh.session_ended": 401,
@@ -2796,7 +2796,7 @@ var q = {
2796
2796
  "error.refresh.successor_timeout": 401,
2797
2797
  "error.refresh.identity_changed": 401,
2798
2798
  "error.refresh.disposed": 499
2799
- }, _i = {
2799
+ }, gi = {
2800
2800
  "error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
2801
2801
  "error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
2802
2802
  "error.refresh.session_ended": "The session has ended",
@@ -2804,23 +2804,23 @@ var q = {
2804
2804
  "error.refresh.successor_timeout": "The refresh token was already used and no successor arrived",
2805
2805
  "error.refresh.identity_changed": "Storage holds another user's tokens",
2806
2806
  "error.refresh.disposed": "The Passflow instance was disposed"
2807
- }, J = class extends z {
2807
+ }, Y = class extends z {
2808
2808
  constructor(e, t = {}) {
2809
2809
  super({
2810
2810
  id: e,
2811
- message: t.message ?? _i[e],
2812
- status: gi[e],
2811
+ message: t.message ?? gi[e],
2812
+ status: hi[e],
2813
2813
  location: "/auth/refresh",
2814
2814
  time: (/* @__PURE__ */ new Date()).toISOString()
2815
2815
  }), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
2816
2816
  }
2817
- }, vi = class extends Error {
2817
+ }, _i = class extends Error {
2818
2818
  constructor(e, t) {
2819
2819
  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;
2820
2820
  }
2821
2821
  };
2822
2822
  // lib/refresh/lineage.ts
2823
- function Y(e) {
2823
+ function vi(e) {
2824
2824
  if (!e) return;
2825
2825
  let t = 3735928559, n = 1103547991;
2826
2826
  for (let r = 0; r < e.length; r++) {
@@ -2833,7 +2833,7 @@ function yi(e) {
2833
2833
  return typeof e == "string" && e !== "" ? e : void 0;
2834
2834
  }
2835
2835
  function X(e) {
2836
- let t = Y(e);
2836
+ let t = vi(e);
2837
2837
  if (!e || !t) return;
2838
2838
  let n = {};
2839
2839
  try {
@@ -2844,7 +2844,7 @@ function X(e) {
2844
2844
  return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
2845
2845
  }
2846
2846
  var bi = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
2847
- function xi(e = (e) => ai().warn(e)) {
2847
+ function xi(e = (e) => ii().warn(e)) {
2848
2848
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
2849
2849
  a || (a = !0, e(bi));
2850
2850
  }, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
@@ -2914,11 +2914,11 @@ function Ei(e) {
2914
2914
  return typeof e == "object" && !!e;
2915
2915
  }
2916
2916
  function Di(e) {
2917
- let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => ai().warn(e)), o = e.lineage ?? xi(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
2917
+ let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => ii().warn(e)), o = e.lineage ?? xi(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
2918
2918
  let e = t.getTokens(), n = e?.refresh_token;
2919
2919
  if (!n) return p = l, e;
2920
2920
  p !== void 0 && (f = Math.max(f, p, m), p = void 0);
2921
- let r = Y(n) ?? "";
2921
+ let r = vi(n) ?? "";
2922
2922
  return r !== c?.fp && (c = {
2923
2923
  fp: r,
2924
2924
  seq: l
@@ -2953,7 +2953,7 @@ function Di(e) {
2953
2953
  h = void 0;
2954
2954
  let e = y();
2955
2955
  e?.refresh_token || C(e) ? se() : D(!0) === "end" && s?.("emptied");
2956
- }, Fr));
2956
+ }, Pr));
2957
2957
  let n = t === "keep" ? T() : void 0;
2958
2958
  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;
2959
2959
  }, O = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, ne = (e) => {
@@ -2966,7 +2966,7 @@ function Di(e) {
2966
2966
  return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
2967
2967
  }, ie = (e, t) => o.isForward(e, t) ? !0 : !!e && !!t && e.iat !== void 0 && e.sid !== t.sid && o.isRetired(t) && !o.isRetired(e) && !o.isEnded(e), ae = (e) => {
2968
2968
  let t = b();
2969
- t && t.fp !== Y(e.refresh_token) && o.retire(t), n.setTokensCache(e);
2969
+ t && t.fp !== vi(e.refresh_token) && o.retire(t), n.setTokensCache(e);
2970
2970
  }, oe = (e) => {
2971
2971
  let t = y(), n = t?.refresh_token;
2972
2972
  if (n === e.refreshToken) return null;
@@ -3050,7 +3050,7 @@ function Di(e) {
3050
3050
  if (o.isEnded(e.order)) return k(e.order);
3051
3051
  let i = oe(e);
3052
3052
  if (i) return i;
3053
- if (!O(e) && re(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${Y(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.`), {
3053
+ if (!O(e) && re(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${vi(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.`), {
3054
3054
  kind: "superseded",
3055
3055
  adopted: !1
3056
3056
  };
@@ -3072,7 +3072,7 @@ function Di(e) {
3072
3072
  kind: "superseded",
3073
3073
  adopted: !1
3074
3074
  };
3075
- let r = di(t), i = r.kind === "blocked" || r.kind === "auth";
3075
+ let r = ui(t), i = r.kind === "blocked" || r.kind === "auth";
3076
3076
  return O(e) && i ? (o.retire(e.order), _ = e.order, {
3077
3077
  kind: "own",
3078
3078
  failure: r,
@@ -3087,7 +3087,7 @@ function Di(e) {
3087
3087
  let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
3088
3088
  if (typeof t != "string" || typeof c != "string" || !Ei(l)) return !1;
3089
3089
  let u = l;
3090
- if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || Y(u.refresh_token) !== c) return !1;
3090
+ if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || vi(u.refresh_token) !== c) return !1;
3091
3091
  let d = y();
3092
3092
  if (!d?.refresh_token) return !1;
3093
3093
  let f = n.getTokens(), p = i() ?? Z(f), m = Z(u);
@@ -3104,7 +3104,7 @@ function Di(e) {
3104
3104
  }
3105
3105
  return !0;
3106
3106
  };
3107
- return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && Y(d.refresh_token) !== c ? !1 : (ae({ ...u }), _());
3107
+ return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && vi(d.refresh_token) !== c ? !1 : (ae({ ...u }), _());
3108
3108
  }, le = (e) => {
3109
3109
  if (!e || !_) return !1;
3110
3110
  let t = _;
@@ -3181,15 +3181,15 @@ function Oi() {
3181
3181
  };
3182
3182
  }
3183
3183
  var ki = {
3184
- strikes: q.sessionEnded,
3185
- "session-ended": q.sessionEnded,
3186
- "stored-ended": q.sessionEnded,
3187
- "signed-out": q.signedOut,
3188
- emptied: q.signedOut,
3189
- "signed-out-here": q.signedOut,
3190
- "successor-timeout": q.successorTimeout,
3191
- "identity-changed": q.identityChanged,
3192
- disposed: q.disposed
3184
+ strikes: J.sessionEnded,
3185
+ "session-ended": J.sessionEnded,
3186
+ "stored-ended": J.sessionEnded,
3187
+ "signed-out": J.signedOut,
3188
+ emptied: J.signedOut,
3189
+ "signed-out-here": J.signedOut,
3190
+ "successor-timeout": J.successorTimeout,
3191
+ "identity-changed": J.identityChanged,
3192
+ disposed: J.disposed
3193
3193
  };
3194
3194
  function Ai(e) {
3195
3195
  throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
@@ -3218,13 +3218,13 @@ function Fi(e, t) {
3218
3218
  return r && (n.scopes = r), n;
3219
3219
  }
3220
3220
  function Ii(e) {
3221
- let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? ai(), c = ji(e.strikes), l = a.transports ? mi({
3221
+ let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? ii(), c = ji(e.strikes), l = a.transports ? pi({
3222
3222
  locks: a.transports.locks,
3223
3223
  channel: a.transports.channel,
3224
3224
  tabId: a.transports.tabId,
3225
3225
  names: a.names,
3226
3226
  clock: o
3227
- }) : hi(), u = { kind: "idle" }, d = 0, f = !1, p = !a.warnOnFirstCycle, m = 0, h = 0, g, _, v, y, b, x, ee, S, C = !1, w = () => o.now(), T = () => i.mode(), E = () => Y(r.getTokens()?.refresh_token), te = () => ({ ...r.getTokens() ?? {} }), D = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, O = () => (ee === void 0 && (ee = Z(r.getTokens() ?? n.getTokens())), ee), ne = /* @__PURE__ */ new Set(), re = /* @__PURE__ */ new Set(), ie = (e) => () => {
3227
+ }) : mi(), u = { kind: "idle" }, d = 0, f = !1, p = !a.warnOnFirstCycle, m = 0, h = 0, g, _, v, y, b, x, ee, S, C = !1, w = () => o.now(), T = () => i.mode(), E = () => vi(r.getTokens()?.refresh_token), te = () => ({ ...r.getTokens() ?? {} }), D = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, O = () => (ee === void 0 && (ee = Z(r.getTokens() ?? n.getTokens())), ee), ne = /* @__PURE__ */ new Set(), re = /* @__PURE__ */ new Set(), ie = (e) => () => {
3228
3228
  for (let t of Array.from(e)) t();
3229
3229
  }, ae = a.onStorageChange?.(ie(ne)), oe = e.platform?.onForeground(ie(re)), k = Di({
3230
3230
  storage: n,
@@ -3300,7 +3300,7 @@ function Ii(e) {
3300
3300
  };
3301
3301
  n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
3302
3302
  }, ue = (e, t) => {
3303
- let n = r.getTokens(), i = Y(n?.refresh_token);
3303
+ let n = r.getTokens(), i = vi(n?.refresh_token);
3304
3304
  e.fp && i && l.post({
3305
3305
  type: "tokens-refreshed",
3306
3306
  tokens: Pi(n),
@@ -3311,7 +3311,7 @@ function Ii(e) {
3311
3311
  ...t === void 0 ? {} : { sentAt: t }
3312
3312
  });
3313
3313
  }, de = () => {
3314
- p || (p = !0, s.warn(Jr));
3314
+ p || (p = !0, s.warn(qr));
3315
3315
  }, fe = (e) => {
3316
3316
  (e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
3317
3317
  }, L = (e, n) => {
@@ -3325,7 +3325,7 @@ function Ii(e) {
3325
3325
  }, e !== "disposed" && k.dropSession(), (e === "strikes" || e === "successor-timeout") && T() !== "json" && i.invalidate(), u = {
3326
3326
  kind: "ended",
3327
3327
  cause: e
3328
- }, ce(r, n ?? new J(ki[e])), e) {
3328
+ }, ce(r, n ?? new Y(ki[e])), e) {
3329
3329
  case "strikes":
3330
3330
  t("session:expired", {
3331
3331
  reason: "refresh_failed",
@@ -3380,14 +3380,14 @@ function Ii(e) {
3380
3380
  e instanceof Ci ? (L("identity-changed"), pe()) : e instanceof Si ? L(e.cause === "emptied" ? "emptied" : "stored-ended") : L("stored-ended", e);
3381
3381
  }, ge = () => {
3382
3382
  u = { kind: "idle" }, C || l.release();
3383
- }, _e = (e) => !e.from || T() !== "json" || e.from === E() || e.from === Y(n.getTokens()?.refresh_token), ve = (e) => {
3383
+ }, _e = (e) => !e.from || T() !== "json" || e.from === E() || e.from === vi(n.getTokens()?.refresh_token), ve = (e) => {
3384
3384
  let t = g;
3385
3385
  if (!t) return;
3386
3386
  if (!l.holding) {
3387
3387
  u = {
3388
3388
  kind: "waiting",
3389
3389
  pending: e
3390
- }, l.request(t.nextAt + G);
3390
+ }, l.request(t.nextAt + K);
3391
3391
  return;
3392
3392
  }
3393
3393
  l.setRetryInfo(t);
@@ -3406,7 +3406,7 @@ function Ii(e) {
3406
3406
  !l.holding || l.foreignHolderHeard() || w() - t > 2e4 ? (l.release(), u = {
3407
3407
  kind: "waiting",
3408
3408
  pending: e
3409
- }, l.request((g?.nextAt ?? w()) + G)) : (u = {
3409
+ }, l.request((g?.nextAt ?? w()) + K)) : (u = {
3410
3410
  kind: "waiting",
3411
3411
  pending: e
3412
3412
  }, xe() || be());
@@ -3477,7 +3477,7 @@ function Ii(e) {
3477
3477
  if (!e.sent) {
3478
3478
  let o = Z({ ...t.id_token ? { id_token: t.id_token } : {} }), s = O();
3479
3479
  if (o !== void 0 && s !== void 0 && o !== s) {
3480
- let t = new J(q.identityChanged);
3480
+ let t = new Y(J.identityChanged);
3481
3481
  P("refresh", e.trigger, t, F("auth")), L("identity-changed", t);
3482
3482
  return;
3483
3483
  }
@@ -3512,12 +3512,12 @@ function Ii(e) {
3512
3512
  e.outcome && E() === o || I("adopted", "other-tab"), s.adopted && ue(e.sent.order), ge(), M(a, e.sentAt);
3513
3513
  return;
3514
3514
  case "ended": {
3515
- let t = new J(s.cause === "emptied" ? q.signedOut : q.sessionEnded);
3515
+ let t = new Y(s.cause === "emptied" ? J.signedOut : J.sessionEnded);
3516
3516
  P("refresh", e.trigger, t, F("auth")), L(s.cause === "emptied" ? "emptied" : "stored-ended", t);
3517
3517
  return;
3518
3518
  }
3519
3519
  case "identity-changed": {
3520
- let t = new J(q.identityChanged);
3520
+ let t = new Y(J.identityChanged);
3521
3521
  P("refresh", e.trigger, t, F("auth")), L("identity-changed", t), pe();
3522
3522
  return;
3523
3523
  }
@@ -3543,7 +3543,7 @@ function Ii(e) {
3543
3543
  break;
3544
3544
  default: Ai(o);
3545
3545
  }
3546
- } else r = di(t, w());
3546
+ } else r = ui(t, w());
3547
3547
  if (i) P("refresh", e.trigger, t, F(r.kind)), I("adopted", "other-tab"), ge(), M(n, void 0, !0);
3548
3548
  else switch (r.kind) {
3549
3549
  case "blocked":
@@ -3562,7 +3562,7 @@ function Ii(e) {
3562
3562
  default: Ai(r.kind);
3563
3563
  }
3564
3564
  }, Oe = (e, t, n, r) => {
3565
- let i = w() + fi(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
3565
+ let i = w() + di(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
3566
3566
  P("refresh", e.trigger, n, F(a, i)), a === "transient" && le(w(), i, "this-tab");
3567
3567
  let s = {
3568
3568
  kind: a,
@@ -3586,7 +3586,7 @@ function Ii(e) {
3586
3586
  })), r && k.deleteIfStillDead(r), L("strikes", t);
3587
3587
  }, Ae = (e, t, n, r) => {
3588
3588
  l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${Mi(n, "blocked")}`);
3589
- let i = d, a = w() + Nr, c = {
3589
+ let i = d, a = w() + Mr, c = {
3590
3590
  kind: "blocked-wait",
3591
3591
  pending: e,
3592
3592
  deadline: a,
@@ -3599,9 +3599,9 @@ function Ii(e) {
3599
3599
  i === d && u === c && (je() || (f ? (e.cookieRetried = !0, u = {
3600
3600
  kind: "waiting",
3601
3601
  pending: e
3602
- }, l.request()) : w() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), L("successor-timeout")) : c.cancel = o.setTimeout(p, Pr)));
3602
+ }, l.request()) : w() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), L("successor-timeout")) : c.cancel = o.setTimeout(p, Nr)));
3603
3603
  };
3604
- c.cancel = o.setTimeout(p, f ? Ir : Pr);
3604
+ c.cancel = o.setTimeout(p, f ? Fr : Nr);
3605
3605
  }, je = () => {
3606
3606
  if (u.kind !== "blocked-wait") return !1;
3607
3607
  let e = u;
@@ -3624,7 +3624,7 @@ function Ii(e) {
3624
3624
  if (u.kind === "ended" || !_e(e)) return;
3625
3625
  let r = g?.nextAt;
3626
3626
  if (g = e, e.failingSince !== void 0 && le(e.failingSince, e.nextAt, "other-tab"), !t || u.kind !== "waiting") return;
3627
- let i = new J(e.kind === "transient" ? q.unavailable : q.authRetry, {
3627
+ let i = new Y(e.kind === "transient" ? J.unavailable : J.authRetry, {
3628
3628
  nextRetryAt: e.nextAt,
3629
3629
  cause: n || void 0
3630
3630
  }), a = u.pending;
@@ -3688,10 +3688,10 @@ function Ii(e) {
3688
3688
  Pe(e.retry, !0, e.message), Re();
3689
3689
  return;
3690
3690
  case "refresh-failed":
3691
- if (u.kind === "ended" || T() !== "json" || e.from !== E() && e.from !== Y(n.getTokens()?.refresh_token)) return;
3691
+ if (u.kind === "ended" || T() !== "json" || e.from !== E() && e.from !== vi(n.getTokens()?.refresh_token)) return;
3692
3692
  if (le(w(), void 0, "other-tab"), u.kind === "waiting") {
3693
3693
  let t = u.pending;
3694
- u.pending = se(t.trigger), N(t, new J(q.unavailable, { cause: e.message }), void 0);
3694
+ u.pending = se(t.trigger), N(t, new Y(J.unavailable, { cause: e.message }), void 0);
3695
3695
  }
3696
3696
  return;
3697
3697
  case "lock-wanted":
@@ -3700,7 +3700,7 @@ function Ii(e) {
3700
3700
  u.cancel(), l.release(), u = {
3701
3701
  kind: "waiting",
3702
3702
  pending: e
3703
- }, l.request((g?.nextAt ?? w()) + G);
3703
+ }, l.request((g?.nextAt ?? w()) + K);
3704
3704
  }
3705
3705
  return;
3706
3706
  case "session-ended":
@@ -3732,7 +3732,7 @@ function Ii(e) {
3732
3732
  u.cancel(), u = {
3733
3733
  kind: "waiting",
3734
3734
  pending: e
3735
- }, l.request((g?.nextAt ?? w()) + G);
3735
+ }, l.request((g?.nextAt ?? w()) + K);
3736
3736
  }
3737
3737
  },
3738
3738
  onMessage: Le
@@ -3758,9 +3758,9 @@ function Ii(e) {
3758
3758
  };
3759
3759
  ne.add(ze), re.add(ze);
3760
3760
  let Be = (e, t) => {
3761
- if (f) return Promise.reject(new J(q.disposed));
3761
+ if (f) return Promise.reject(new Y(J.disposed));
3762
3762
  switch (u.kind) {
3763
- case "ended": return Promise.reject(new J(q.sessionEnded));
3763
+ case "ended": return Promise.reject(new Y(J.sessionEnded));
3764
3764
  case "idle": {
3765
3765
  let n = se(e);
3766
3766
  u = {
@@ -3768,7 +3768,7 @@ function Ii(e) {
3768
3768
  pending: n
3769
3769
  };
3770
3770
  let r = j(n, t);
3771
- return l.holding && !C ? xe() || be() : l.request(g ? g.nextAt + G : void 0), r;
3771
+ return l.holding && !C ? xe() || be() : l.request(g ? g.nextAt + K : void 0), r;
3772
3772
  }
3773
3773
  case "waiting":
3774
3774
  case "refreshing":
@@ -3777,8 +3777,8 @@ function Ii(e) {
3777
3777
  default: return Ai(u);
3778
3778
  }
3779
3779
  }, R = (e) => {
3780
- if (f) return Promise.reject(new J(q.disposed));
3781
- if (de(), u.kind === "ended") return Promise.reject(new J(q.sessionEnded));
3780
+ if (f) return Promise.reject(new Y(J.disposed));
3781
+ if (de(), u.kind === "ended") return Promise.reject(new Y(J.sessionEnded));
3782
3782
  if (T() === "json" && !r.getTokens()?.refresh_token) {
3783
3783
  let t = n.getTokens();
3784
3784
  if (!t?.refresh_token) {
@@ -3788,7 +3788,7 @@ function Ii(e) {
3788
3788
  }
3789
3789
  return Be(e.trigger, e.fresh ? w() : void 0);
3790
3790
  }, Ve = (e) => {
3791
- if (f) return Promise.reject(new J(q.disposed));
3791
+ if (f) return Promise.reject(new Y(J.disposed));
3792
3792
  if (u.kind === "ended") return Promise.resolve(r.getTokens());
3793
3793
  let t = u.kind === "backoff" || u.kind === "blocked-wait" || g !== void 0 && g.nextAt > w();
3794
3794
  return e.allowStale && t ? Promise.resolve(r.getTokens()) : R({ trigger: e.trigger }).then(() => r.getTokens());
@@ -3823,11 +3823,11 @@ function Ii(e) {
3823
3823
  } else u.kind === "idle" && g && g.nextAt > w() && _e(g) ? (m = g.attempt, h = g.strikes, ve(se("retry"))) : u.kind === "idle" && l.release();
3824
3824
  }
3825
3825
  }, Ge = async (e, t) => {
3826
- if (f) throw new J(q.disposed);
3826
+ if (f) throw new Y(J.disposed);
3827
3827
  de();
3828
- let n = w() + Lr;
3828
+ let n = w() + Ir;
3829
3829
  if (await Ue(n - w()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await He("commit", n - w())) === "timeout") {
3830
- let e = new vi("lock-timeout");
3830
+ let e = new _i("lock-timeout");
3831
3831
  throw P("upgrade.commit", "upgrade", e), e;
3832
3832
  }
3833
3833
  C = !0;
@@ -3873,7 +3873,7 @@ function Ii(e) {
3873
3873
  }
3874
3874
  if (!o) {
3875
3875
  if (u !== d) {
3876
- let e = new vi("superseded");
3876
+ let e = new _i("superseded");
3877
3877
  throw P("upgrade.commit", "upgrade", e), e;
3878
3878
  }
3879
3879
  await i.applyOpaque(f), r.setTokensCache({
@@ -3892,7 +3892,7 @@ function Ii(e) {
3892
3892
  }
3893
3893
  let p = k.commitSave(o, Fi(f, s));
3894
3894
  if (p.kind === "saved") return Ke(c), ue(o.order, c), te();
3895
- let m = new vi("superseded");
3895
+ let m = new _i("superseded");
3896
3896
  throw P("upgrade.commit", "upgrade", m), p.kind === "superseded" && p.adopted && I("adopted", "other-tab"), m;
3897
3897
  }, Ke = (e) => {
3898
3898
  if (I("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
@@ -3910,7 +3910,7 @@ function Ii(e) {
3910
3910
  }));
3911
3911
  }, Je = () => {
3912
3912
  let e = A(u);
3913
- ce(e, new J(q.signedOut)), (u.kind === "backoff" || u.kind === "blocked-wait" || u.kind === "waiting") && (fe(u), u = { kind: "idle" });
3913
+ ce(e, new Y(J.signedOut)), (u.kind === "backoff" || u.kind === "blocked-wait" || u.kind === "waiting") && (fe(u), u = { kind: "idle" });
3914
3914
  };
3915
3915
  return {
3916
3916
  refresh: R,
@@ -3918,7 +3918,7 @@ function Ii(e) {
3918
3918
  commitUpgrade: Ge,
3919
3919
  signOut: async (e) => {
3920
3920
  if (f) return e(n.getTokens()?.refresh_token);
3921
- let t = w() + Rr;
3921
+ let t = w() + Lr;
3922
3922
  Je(), await Ue(t - w()), Je(), l.coordinated && !l.holding && await He("logout", t - w());
3923
3923
  try {
3924
3924
  qe(), await e(n.getTokens()?.refresh_token);
@@ -3959,7 +3959,7 @@ function Ii(e) {
3959
3959
  fe(u), f = !0, d += 1, u = {
3960
3960
  kind: "ended",
3961
3961
  cause: "disposed"
3962
- }, ce(e, new J(q.disposed)), S = void 0, k.stop(), l.dispose(), ae?.(), oe?.();
3962
+ }, ce(e, new Y(J.disposed)), S = void 0, k.stop(), l.dispose(), ae?.(), oe?.();
3963
3963
  }
3964
3964
  };
3965
3965
  }
@@ -4210,10 +4210,21 @@ function wa(e) {
4210
4210
  return e;
4211
4211
  }
4212
4212
  function Ta(e) {
4213
+ if (e) try {
4214
+ let { protocol: t } = new URL(e);
4215
+ return t === "https:" || t === "http:" ? e : void 0;
4216
+ } catch {
4217
+ return;
4218
+ }
4219
+ }
4220
+ function Ea(e) {
4221
+ return e.provider?.startsWith("conn_") ? e.login_hint : void 0;
4222
+ }
4223
+ function Da(e) {
4213
4224
  let t = {};
4214
4225
  return e.connection_id !== void 0 && (t.connection_id = e.connection_id), e.email !== void 0 && (t.email = e.email), t;
4215
4226
  }
4216
- var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is gone", Oa = (e, t) => new Promise((n, r) => {
4227
+ var Oa = 10, ka = "The sign-in answered with a PKCE code, but its verifier is gone", Aa = (e, t) => new Promise((n, r) => {
4217
4228
  if (t?.aborted) {
4218
4229
  r(t.reason);
4219
4230
  return;
@@ -4224,20 +4235,20 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4224
4235
  t?.removeEventListener("abort", i), n();
4225
4236
  }, e);
4226
4237
  t?.addEventListener("abort", i, { once: !0 });
4227
- }), ka = (e) => {
4238
+ }), ja = (e) => {
4228
4239
  if (!e) return;
4229
4240
  let t = new URLSearchParams(e.search).get("token");
4230
4241
  if (t) return t;
4231
4242
  let n = e.hash.indexOf("?");
4232
4243
  return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
4233
- }, Aa = (e) => {
4244
+ }, Ma = (e) => {
4234
4245
  if (e) try {
4235
4246
  return j(e).email;
4236
4247
  } catch {
4237
4248
  return;
4238
4249
  }
4239
- }, ja = class {
4240
- constructor(e, t, n, r, i, a, o, s, c, l, u, d = me, f, p = { coordination: ni() }, m) {
4250
+ }, Na = class {
4251
+ constructor(e, t, n, r, i, a, o, s, c, l, u, d = me, f, p = { coordination: ti() }, m) {
4241
4252
  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), this.setBffModeIfConfigured(), this.refresh = Ii({
4242
4253
  emit: this.createRefreshEmit(),
4243
4254
  storage: n,
@@ -4246,7 +4257,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4246
4257
  coordination: p.coordination,
4247
4258
  platform: d,
4248
4259
  ...p.strikes === void 0 ? {} : { strikes: p.strikes },
4249
- logger: ai()
4260
+ logger: ii()
4250
4261
  }), this.initializeSession();
4251
4262
  }
4252
4263
  setAppId(e) {
@@ -4281,7 +4292,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4281
4292
  if (!this.tokenDeliveryManager.isCookieMode()) return !1;
4282
4293
  try {
4283
4294
  let e = await this.authApi.validateSession();
4284
- return t() ? !1 : e?.id ? (this.tokenDeliveryManager.setSessionValid(), this.subscribeStore.notify(W.SessionRestored, e), !0) : (this.tokenDeliveryManager.setSessionInvalid(), !1);
4295
+ return t() ? !1 : e?.id ? (this.tokenDeliveryManager.setSessionValid(), this.subscribeStore.notify(G.SessionRestored, e), !0) : (this.tokenDeliveryManager.setSessionInvalid(), !1);
4285
4296
  } catch {
4286
4297
  return t() || this.tokenDeliveryManager.setSessionInvalid(), !1;
4287
4298
  }
@@ -4311,10 +4322,10 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4311
4322
  tokens: e,
4312
4323
  parsedTokens: this.tokenCacheService.getParsedTokens()
4313
4324
  };
4314
- this.subscribeStore.notify(W.Register, t), this.subscribeStore.notify(W.SignIn, t);
4325
+ this.subscribeStore.notify(G.Register, t), this.subscribeStore.notify(G.SignIn, t);
4315
4326
  }
4316
4327
  handlePendingSecondFactor(e, t, n, r) {
4317
- return e.tfa_token ? (n ? this.rememberPkceSignIn(n.verifier, r) : this.forgetPkceSignIn(), this.subscribeStore.notify(W.TwoFactorRequired, {
4328
+ return e.tfa_token ? (n ? this.rememberPkceSignIn(n.verifier, r) : this.forgetPkceSignIn(), this.subscribeStore.notify(G.TwoFactorRequired, {
4318
4329
  email: t || "",
4319
4330
  challengeId: e.challenge_id || "",
4320
4331
  tfaToken: e.tfa_token || ""
@@ -4328,7 +4339,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4328
4339
  email: n,
4329
4340
  scopes: i,
4330
4341
  pkce: r !== void 0
4331
- }), this.subscribeStore.notify(W.EmailVerificationRequired, {
4342
+ }), this.subscribeStore.notify(G.EmailVerificationRequired, {
4332
4343
  email: n,
4333
4344
  challengeId: a,
4334
4345
  operation: t
@@ -4337,7 +4348,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4337
4348
  rememberEmailChallenge(e, t) {
4338
4349
  this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
4339
4350
  for (let e of this.emailChallenges.keys()) {
4340
- if (this.emailChallenges.size <= Ea) break;
4351
+ if (this.emailChallenges.size <= Oa) break;
4341
4352
  this.emailChallenges.delete(e);
4342
4353
  }
4343
4354
  }
@@ -4414,17 +4425,17 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4414
4425
  try {
4415
4426
  e = await this.readPkceEnabled?.() ?? !1;
4416
4427
  } catch (e) {
4417
- ai().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
4428
+ ii().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
4418
4429
  return;
4419
4430
  }
4420
- return e ? Wn() : void 0;
4431
+ return e ? Un() : void 0;
4421
4432
  }
4422
4433
  async exchangeCode(e, t) {
4423
4434
  return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
4424
4435
  }
4425
4436
  async completePkceSignIn(e) {
4426
4437
  let t = this.readPendingPkce();
4427
- if (!t) throw Error(Da);
4438
+ if (!t) throw Error(ka);
4428
4439
  let n = await this.authApi.pkceExchange(e, t.verifier);
4429
4440
  return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
4430
4441
  }
@@ -4433,7 +4444,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4433
4444
  (t.access_token || t.id_token || t.token_delivery) && await this.processAuthResponse(t, t.scopes ?? this.readPendingPkce()?.scopes ?? this.scopes);
4434
4445
  }
4435
4446
  async notifySignedIn(e) {
4436
- this.subscribeStore.notify(W.SignIn, {
4447
+ this.subscribeStore.notify(G.SignIn, {
4437
4448
  tokens: e,
4438
4449
  parsedTokens: this.tokenCacheService.getParsedTokens()
4439
4450
  }), await this.submitSessionCheck();
@@ -4461,7 +4472,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4461
4472
  originalError: e,
4462
4473
  code: "VALIDATION_ERROR"
4463
4474
  };
4464
- throw U(this.subscribeStore, t), e;
4475
+ throw W(this.subscribeStore, t), e;
4465
4476
  }
4466
4477
  if ("username" in e && e.username && !pa(e.username)) {
4467
4478
  let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
@@ -4470,7 +4481,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4470
4481
  originalError: e,
4471
4482
  code: "VALIDATION_ERROR"
4472
4483
  };
4473
- throw U(this.subscribeStore, t), e;
4484
+ throw W(this.subscribeStore, t), e;
4474
4485
  }
4475
4486
  if ("phone" in e && e.phone && !fa(e.phone)) {
4476
4487
  let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
@@ -4479,9 +4490,9 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4479
4490
  originalError: e,
4480
4491
  code: "VALIDATION_ERROR"
4481
4492
  };
4482
- throw U(this.subscribeStore, t), e;
4493
+ throw W(this.subscribeStore, t), e;
4483
4494
  }
4484
- this.subscribeStore.notify(W.SignInStart, { email: e.email });
4495
+ this.subscribeStore.notify(G.SignInStart, { email: e.email });
4485
4496
  let n = this.deviceService.getDeviceId(), r = vt(this.platform.getDeviceType());
4486
4497
  e.scopes = e.scopes ?? this.scopes;
4487
4498
  try {
@@ -4491,7 +4502,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4491
4502
  } : e, n, r, ...ga(t));
4492
4503
  if (this.handleEmailVerificationStep(a, "sign-in", e.email, i, e.scopes) || this.handlePendingSecondFactor(a, e.email, i, e.scopes)) return a;
4493
4504
  let o = await this.exchangeCode(a, i);
4494
- return this.handlePendingSecondFactor(o, e.email) || (await this.processAuthResponse(o, e.scopes), this.subscribeStore.notify(W.SignIn, {
4505
+ return this.handlePendingSecondFactor(o, e.email) || (await this.processAuthResponse(o, e.scopes), this.subscribeStore.notify(G.SignIn, {
4495
4506
  tokens: o,
4496
4507
  parsedTokens: this.tokenCacheService.getParsedTokens()
4497
4508
  }), await this.submitSessionCheck()), o;
@@ -4502,7 +4513,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4502
4513
  originalError: e,
4503
4514
  code: e instanceof z ? e.id : void 0
4504
4515
  };
4505
- throw U(this.subscribeStore, t), e;
4516
+ throw W(this.subscribeStore, t), e;
4506
4517
  }
4507
4518
  }
4508
4519
  async signUp(e, t) {
@@ -4513,7 +4524,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4513
4524
  originalError: e,
4514
4525
  code: "VALIDATION_ERROR"
4515
4526
  };
4516
- throw U(this.subscribeStore, t), e;
4527
+ throw W(this.subscribeStore, t), e;
4517
4528
  }
4518
4529
  if (e.user.phone_number && !fa(e.user.phone_number)) {
4519
4530
  let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
@@ -4522,9 +4533,9 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4522
4533
  originalError: e,
4523
4534
  code: "VALIDATION_ERROR"
4524
4535
  };
4525
- throw U(this.subscribeStore, t), e;
4536
+ throw W(this.subscribeStore, t), e;
4526
4537
  }
4527
- this.subscribeStore.notify(W.RegisterStart, { email: e.user.email }), e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
4538
+ this.subscribeStore.notify(G.RegisterStart, { email: e.user.email }), e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
4528
4539
  try {
4529
4540
  let n = await this.startPkce(), r = await this.authApi.signUp(n ? {
4530
4541
  ...e,
@@ -4540,7 +4551,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4540
4551
  originalError: e,
4541
4552
  code: e instanceof z ? e.id : void 0
4542
4553
  };
4543
- throw U(this.subscribeStore, t), e;
4554
+ throw W(this.subscribeStore, t), e;
4544
4555
  }
4545
4556
  }
4546
4557
  async passwordlessSignIn(e, t) {
@@ -4551,7 +4562,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4551
4562
  originalError: e,
4552
4563
  code: "VALIDATION_ERROR"
4553
4564
  };
4554
- throw U(this.subscribeStore, t), e;
4565
+ throw W(this.subscribeStore, t), e;
4555
4566
  }
4556
4567
  if (e.phone && !fa(e.phone)) {
4557
4568
  let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
@@ -4560,9 +4571,9 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4560
4571
  originalError: e,
4561
4572
  code: "VALIDATION_ERROR"
4562
4573
  };
4563
- throw U(this.subscribeStore, t), e;
4574
+ throw W(this.subscribeStore, t), e;
4564
4575
  }
4565
- this.subscribeStore.notify(W.SignInStart, { email: e.email });
4576
+ this.subscribeStore.notify(G.SignInStart, { email: e.email });
4566
4577
  let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId(), i = vt(this.platform.getDeviceType());
4567
4578
  try {
4568
4579
  let a = await this.startPkce(), o = await this.authApi.passwordlessSignIn({
@@ -4586,18 +4597,18 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4586
4597
  originalError: e,
4587
4598
  code: e instanceof z ? e.id : void 0
4588
4599
  };
4589
- throw U(this.subscribeStore, t), e;
4600
+ throw W(this.subscribeStore, t), e;
4590
4601
  }
4591
4602
  }
4592
4603
  async passwordlessSignInComplete(e, t) {
4593
- this.subscribeStore.notify(W.SignInStart, {}), e.scopes = e.scopes ?? this.scopes, e.device = this.deviceService.getDeviceId();
4604
+ this.subscribeStore.notify(G.SignInStart, {}), e.scopes = e.scopes ?? this.scopes, e.device = this.deviceService.getDeviceId();
4594
4605
  let n = this.readPendingPasswordless(), r = n?.challengeId === e.challenge_id ? n : void 0, i = !1;
4595
4606
  try {
4596
4607
  let n = await this.authApi.passwordlessSignInComplete(e, ...ga(t));
4597
4608
  if (i = !0, this.handlePendingSecondFactor(n, r?.email, r && { verifier: r.verifier }, r?.scopes)) return this.forgetPendingPasswordless(), n;
4598
4609
  let a = n;
4599
4610
  if (n.code) {
4600
- if (!r) throw Error(Da);
4611
+ if (!r) throw Error(ka);
4601
4612
  if (a = await this.authApi.pkceExchange(n.code, r.verifier), this.handlePendingSecondFactor(a)) return this.forgetPendingPasswordless(), {
4602
4613
  ...a,
4603
4614
  redirect_url: n.redirect_url ?? ""
@@ -4607,7 +4618,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4607
4618
  ...a,
4608
4619
  redirect_url: n.redirect_url
4609
4620
  } : a;
4610
- return await this.processAuthResponse(o, r?.scopes ?? e.scopes), this.forgetPendingPasswordless(), this.subscribeStore.notify(W.SignIn, {
4621
+ return await this.processAuthResponse(o, r?.scopes ?? e.scopes), this.forgetPendingPasswordless(), this.subscribeStore.notify(G.SignIn, {
4611
4622
  tokens: o,
4612
4623
  parsedTokens: this.tokenCacheService.getParsedTokens()
4613
4624
  }), await this.submitSessionCheck(), {
@@ -4622,18 +4633,18 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4622
4633
  originalError: e,
4623
4634
  code: e instanceof z ? e.id : void 0
4624
4635
  };
4625
- throw U(this.subscribeStore, t), e;
4636
+ throw W(this.subscribeStore, t), e;
4626
4637
  }
4627
4638
  }
4628
4639
  async waitForPasswordlessSignIn(e, t) {
4629
4640
  let n = t?.signal;
4630
4641
  try {
4631
4642
  let t = this.readPendingPasswordless();
4632
- if (t?.challengeId !== e) throw Error(Da);
4643
+ if (t?.challengeId !== e) throw Error(ka);
4633
4644
  for (;;) {
4634
4645
  if (n?.aborted) throw n.reason;
4635
4646
  if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
4636
- if (this.readPendingPasswordless()?.challengeId !== e) throw Error(Da);
4647
+ if (this.readPendingPasswordless()?.challengeId !== e) throw Error(ka);
4637
4648
  let r;
4638
4649
  try {
4639
4650
  r = await this.authApi.passwordlessStatus({
@@ -4651,7 +4662,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4651
4662
  status: "signed-in",
4652
4663
  tokens: { redirect_url: r.redirect_url }
4653
4664
  };
4654
- await Oa(ba, n);
4665
+ await Aa(ba, n);
4655
4666
  }
4656
4667
  } catch (e) {
4657
4668
  if (n?.aborted && e === n.reason) throw e;
@@ -4661,13 +4672,13 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4661
4672
  originalError: e,
4662
4673
  code: e instanceof z ? e.id : void 0
4663
4674
  };
4664
- throw U(this.subscribeStore, t), e;
4675
+ throw W(this.subscribeStore, t), e;
4665
4676
  }
4666
4677
  }
4667
4678
  async finishApprovedPasswordless(e, t) {
4668
4679
  try {
4669
4680
  let n = await this.authApi.pkceExchange(e, t.verifier);
4670
- return this.handlePendingSecondFactor(n, t.email) ? (this.forgetPendingPasswordless(), { status: "second-factor-required" }) : (await this.processAuthResponse(n, t.scopes), this.forgetPendingPasswordless(), this.subscribeStore.notify(W.SignIn, {
4681
+ return this.handlePendingSecondFactor(n, t.email) ? (this.forgetPendingPasswordless(), { status: "second-factor-required" }) : (await this.processAuthResponse(n, t.scopes), this.forgetPendingPasswordless(), this.subscribeStore.notify(G.SignIn, {
4671
4682
  tokens: n,
4672
4683
  parsedTokens: this.tokenCacheService.getParsedTokens()
4673
4684
  }), await this.submitSessionCheck(), {
@@ -4714,27 +4725,27 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4714
4725
  originalError: e,
4715
4726
  code: e instanceof z ? e.id : void 0
4716
4727
  };
4717
- U(this.subscribeStore, t);
4728
+ W(this.subscribeStore, t);
4718
4729
  }
4719
4730
  async verifyEmailCode(e) {
4720
4731
  let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
4721
4732
  try {
4722
4733
  let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
4723
- if (t?.pkce && !r) throw Error(Da);
4734
+ if (t?.pkce && !r) throw Error(ka);
4724
4735
  let i = await this.authApi.validateEmailCode(e);
4725
4736
  this.emailChallenges.delete(e.challenge_id);
4726
4737
  let a = r?.scopes ?? t?.scopes ?? this.scopes;
4727
4738
  if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
4728
4739
  let o = i;
4729
4740
  if (i.code) {
4730
- if (!r) throw Error(Da);
4741
+ if (!r) throw Error(ka);
4731
4742
  if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
4732
4743
  }
4733
4744
  let s = i.redirect_url ? {
4734
4745
  ...o,
4735
4746
  redirect_url: i.redirect_url
4736
4747
  } : o;
4737
- return await this.processAuthResponse(s, a), this.forgetPkceSignIn(), t?.operation === "sign-up" ? this.notifyRegisteredAndSignedIn(s) : this.subscribeStore.notify(W.SignIn, {
4748
+ return await this.processAuthResponse(s, a), this.forgetPkceSignIn(), t?.operation === "sign-up" ? this.notifyRegisteredAndSignedIn(s) : this.subscribeStore.notify(G.SignIn, {
4738
4749
  tokens: s,
4739
4750
  parsedTokens: this.tokenCacheService.getParsedTokens()
4740
4751
  }), await this.submitSessionCheck(), s;
@@ -4745,14 +4756,17 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4745
4756
  originalError: e,
4746
4757
  code: e instanceof z ? e.id : void 0
4747
4758
  };
4748
- throw U(this.subscribeStore, t), e;
4759
+ throw W(this.subscribeStore, t), e;
4749
4760
  }
4750
4761
  }
4751
4762
  async logOut() {
4752
- let e = this.refresh.identity();
4763
+ let e = this.refresh.identity(), t;
4753
4764
  return await this.refresh.signOut(async (e) => {
4754
- await this.callLogoutApi(e), this.forgetPkceSignIn(), this.forgetPendingPasswordless(), this.emailChallenges.clear(), this.clearLocalSession();
4755
- }), e;
4765
+ t = await this.callLogoutApi(e), this.forgetPkceSignIn(), this.forgetPendingPasswordless(), this.emailChallenges.clear(), this.clearLocalSession();
4766
+ }), {
4767
+ userId: e,
4768
+ samlLogoutUrl: t
4769
+ };
4756
4770
  }
4757
4771
  resetSession() {
4758
4772
  let e = this.refresh.identity();
@@ -4780,8 +4794,12 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4780
4794
  }
4781
4795
  let t = e ?? this.storageManager.getToken(M.refresh_token), n = this.storageManager.getDeviceId();
4782
4796
  try {
4783
- if ((await this.authApi.logOut(n, t, !this.appId)).status !== "ok") throw Error("Logout failed");
4784
- } catch {}
4797
+ let e = await this.authApi.logOut(n, t, !this.appId);
4798
+ if (e.status !== "ok") throw Error("Logout failed");
4799
+ return Ta(e.saml_logout_url);
4800
+ } catch {
4801
+ return;
4802
+ }
4785
4803
  }
4786
4804
  clearLocalSession() {
4787
4805
  this.storageManager.deleteTokens(), this.tokenDeliveryManager.reset(), this.tokenCacheService.setTokensCache(void 0), this.tokenCacheService.stopTokenCheck?.();
@@ -4806,7 +4824,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4806
4824
  switch (e) {
4807
4825
  case "refresh": {
4808
4826
  let { tokens: e, source: r } = t;
4809
- n.notify(W.Refresh, {
4827
+ n.notify(G.Refresh, {
4810
4828
  tokens: e,
4811
4829
  parsedTokens: this.tokenCacheService.getParsedTokens(),
4812
4830
  source: r
@@ -4815,7 +4833,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4815
4833
  }
4816
4834
  case "signin": {
4817
4835
  let { tokens: e, origin: r } = t;
4818
- n.notify(W.SignIn, {
4836
+ n.notify(G.SignIn, {
4819
4837
  tokens: e,
4820
4838
  parsedTokens: this.tokenCacheService.getParsedTokens(),
4821
4839
  origin: r
@@ -4823,27 +4841,27 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4823
4841
  return;
4824
4842
  }
4825
4843
  case "error":
4826
- U(n, t);
4844
+ W(n, t);
4827
4845
  return;
4828
4846
  case "refresh:start":
4829
- n.notify(W.RefreshStart, {});
4847
+ n.notify(G.RefreshStart, {});
4830
4848
  return;
4831
4849
  case "token-cache-expired":
4832
- n.notify(W.TokenCacheExpired, t);
4850
+ n.notify(G.TokenCacheExpired, t);
4833
4851
  return;
4834
4852
  case "refresh:failing":
4835
- n.notify(W.RefreshFailing, t);
4853
+ n.notify(G.RefreshFailing, t);
4836
4854
  return;
4837
4855
  case "refresh:recovered":
4838
- n.notify(W.RefreshRecovered, t);
4856
+ n.notify(G.RefreshRecovered, t);
4839
4857
  return;
4840
4858
  case "session:expired":
4841
- n.notify(W.SessionExpired, t);
4859
+ n.notify(G.SessionExpired, t);
4842
4860
  return;
4843
4861
  case "signout":
4844
- n.notify(W.SignOut, t);
4862
+ n.notify(G.SignOut, t);
4845
4863
  return;
4846
- default: ai().warn(`[passflow] Unknown refresh event: ${String(e)}`);
4864
+ default: ii().warn(`[passflow] Unknown refresh event: ${String(e)}`);
4847
4865
  }
4848
4866
  };
4849
4867
  }
@@ -4901,7 +4919,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4901
4919
  let e = this.storageManager.getTokens();
4902
4920
  if (!e?.refresh_token) {
4903
4921
  let t = /* @__PURE__ */ Error(e ? "No refresh token found" : "No tokens found");
4904
- throw U(this.subscribeStore, {
4922
+ throw W(this.subscribeStore, {
4905
4923
  operation: "refresh",
4906
4924
  source: "refresh-token",
4907
4925
  message: t.message,
@@ -4924,22 +4942,22 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4924
4942
  originalError: e,
4925
4943
  code: e instanceof z ? e.id : void 0
4926
4944
  };
4927
- throw U(this.subscribeStore, t), e;
4945
+ throw W(this.subscribeStore, t), e;
4928
4946
  }
4929
4947
  }
4930
4948
  async resetPassword(e, t, n) {
4931
- this.subscribeStore.notify(W.SignInStart, {});
4932
- let r = n ?? ka(this.platform.getCurrentUrl()), i = t ?? this.scopes;
4949
+ this.subscribeStore.notify(G.SignInStart, {});
4950
+ let r = n ?? ja(this.platform.getCurrentUrl()), i = t ?? this.scopes;
4933
4951
  try {
4934
4952
  let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
4935
- if (this.handleEmailVerificationStep(n, "reset-password", Aa(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
4953
+ if (this.handleEmailVerificationStep(n, "reset-password", Ma(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
4936
4954
  let a = await this.exchangeCode(n, t);
4937
4955
  if (this.handlePendingSecondFactor(a)) return a;
4938
4956
  let o = n.redirect_url ? {
4939
4957
  ...a,
4940
4958
  redirect_url: n.redirect_url
4941
4959
  } : a;
4942
- return await this.processAuthResponse(o, i), this.subscribeStore.notify(W.SignIn, {
4960
+ return await this.processAuthResponse(o, i), this.subscribeStore.notify(G.SignIn, {
4943
4961
  tokens: o,
4944
4962
  parsedTokens: this.tokenCacheService.getParsedTokens()
4945
4963
  }), await this.submitSessionCheck(), o;
@@ -4950,12 +4968,12 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4950
4968
  originalError: e,
4951
4969
  code: e instanceof z ? e.id : void 0
4952
4970
  };
4953
- throw U(this.subscribeStore, t), e;
4971
+ throw W(this.subscribeStore, t), e;
4954
4972
  }
4955
4973
  }
4956
4974
  async passkeyRegister(e, t) {
4957
4975
  if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
4958
- this.subscribeStore.notify(W.RegisterStart, {});
4976
+ this.subscribeStore.notify(G.RegisterStart, {});
4959
4977
  let n = this.deviceService.getDeviceId(), r = vt(this.platform.getDeviceType());
4960
4978
  e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
4961
4979
  try {
@@ -4977,12 +4995,12 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4977
4995
  originalError: e,
4978
4996
  code: e instanceof z ? e.id : void 0
4979
4997
  };
4980
- throw U(this.subscribeStore, t), e;
4998
+ throw W(this.subscribeStore, t), e;
4981
4999
  }
4982
5000
  }
4983
5001
  async passkeyAuthenticate(e, t) {
4984
5002
  if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
4985
- this.subscribeStore.notify(W.SignInStart, {});
5003
+ this.subscribeStore.notify(G.SignInStart, {});
4986
5004
  let n = this.deviceService.getDeviceId(), r = vt(this.platform.getDeviceType());
4987
5005
  e.scopes = e.scopes ?? this.scopes;
4988
5006
  try {
@@ -4994,7 +5012,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
4994
5012
  let c = await this.authApi.passkeyAuthenticateComplete(s, n, a, !this.appId, ...ga(t));
4995
5013
  if (this.handlePendingSecondFactor(c, void 0, i, e.scopes)) return c;
4996
5014
  let l = await this.exchangeCode(c, i);
4997
- return this.handlePendingSecondFactor(l) || "access_token" in l && (await this.processAuthResponse(l, e.scopes), this.subscribeStore.notify(W.SignIn, {
5015
+ return this.handlePendingSecondFactor(l) || "access_token" in l && (await this.processAuthResponse(l, e.scopes), this.subscribeStore.notify(G.SignIn, {
4998
5016
  tokens: l,
4999
5017
  parsedTokens: this.tokenCacheService.getParsedTokens()
5000
5018
  }), await this.submitSessionCheck()), l;
@@ -5005,7 +5023,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5005
5023
  originalError: e,
5006
5024
  code: e instanceof z ? e.id : void 0
5007
5025
  };
5008
- throw U(this.subscribeStore, t), e;
5026
+ throw W(this.subscribeStore, t), e;
5009
5027
  }
5010
5028
  }
5011
5029
  async usesFederatedPost(e) {
@@ -5017,6 +5035,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5017
5035
  }
5018
5036
  }
5019
5037
  federatedStartBody(e, t) {
5038
+ let n = Ea(e);
5020
5039
  return {
5021
5040
  redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
5022
5041
  scopes: t,
@@ -5026,7 +5045,8 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5026
5045
  ...e.parent_challenge_id ? { parent_challenge_id: e.parent_challenge_id } : {},
5027
5046
  ...e.code_challenge ? { code_challenge: e.code_challenge } : {},
5028
5047
  ...e.code_challenge_method ? { code_challenge_method: e.code_challenge_method } : {},
5029
- ...e.state ? { state: e.state } : {}
5048
+ ...e.state ? { state: e.state } : {},
5049
+ ...n ? { login_hint: n } : {}
5030
5050
  };
5031
5051
  }
5032
5052
  createFederatedAuthUrl(e) {
@@ -5035,6 +5055,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5035
5055
  return t.search = new URLSearchParams(this.federatedStartQuery(e, e.scopes ?? this.scopes, this.appId)).toString(), t.toString();
5036
5056
  }
5037
5057
  federatedStartQuery(e, t, n) {
5058
+ let r = Ea(e);
5038
5059
  return {
5039
5060
  scopes: t.join(" "),
5040
5061
  redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
@@ -5045,14 +5066,15 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5045
5066
  ...e.code_challenge ? { code_challenge: e.code_challenge } : {},
5046
5067
  ...e.code_challenge_method ? { code_challenge_method: e.code_challenge_method } : {},
5047
5068
  ...e.state ? { state: e.state } : {},
5048
- ...e.parent_challenge_id ? { parent_challenge_id: e.parent_challenge_id } : {}
5069
+ ...e.parent_challenge_id ? { parent_challenge_id: e.parent_challenge_id } : {},
5070
+ ...r ? { login_hint: r } : {}
5049
5071
  };
5050
5072
  }
5051
5073
  createEnterpriseAuthUrl(e) {
5052
5074
  if (!this.appId) throw Error(Ca);
5053
5075
  let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId(), r = new URL(R.enterpriseStart, this.url);
5054
5076
  return r.search = new URLSearchParams({
5055
- ...Ta(e),
5077
+ ...Da(e),
5056
5078
  ...this.federatedStartQuery({
5057
5079
  ...e,
5058
5080
  device: n
@@ -5062,7 +5084,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5062
5084
  async enterpriseStart(e, t) {
5063
5085
  let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
5064
5086
  return { auth_url: wa((await this.authApi.enterpriseStart({
5065
- ...Ta(e),
5087
+ ...Da(e),
5066
5088
  ...this.federatedStartBody({
5067
5089
  ...e,
5068
5090
  device: r
@@ -5070,7 +5092,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5070
5092
  }, t)).auth_url) };
5071
5093
  }
5072
5094
  async federatedAuthWithPopup(e, t) {
5073
- if (this.subscribeStore.notify(W.SignInStart, { provider: e.provider }), !this.appId) throw Error(Ca);
5095
+ if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(Ca);
5074
5096
  let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
5075
5097
  try {
5076
5098
  this.forgetFederatedSlot();
@@ -5110,19 +5132,19 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5110
5132
  scopes: n
5111
5133
  };
5112
5134
  if (o) {
5113
- if (!f) throw Yn();
5135
+ if (!f) throw Jn();
5114
5136
  if (_ = await this.authApi.pkceExchange(f, o.verifier), this.handlePendingSecondFactor(_)) return;
5115
5137
  } else {
5116
- if (!await this.isSimpleModeApp()) throw Yn();
5138
+ if (!await this.isSimpleModeApp()) throw Jn();
5117
5139
  await Vi(this.url, this.appId, _);
5118
5140
  }
5119
- await this.processAuthResponse(_, n), this.subscribeStore.notify(W.SignIn, {
5141
+ await this.processAuthResponse(_, n), this.subscribeStore.notify(G.SignIn, {
5120
5142
  tokens: _,
5121
5143
  parsedTokens: this.tokenCacheService.getParsedTokens()
5122
5144
  }), this.platform.navigateTo(this.platform.getCurrentUrl()?.origin ?? "");
5123
5145
  } catch (e) {
5124
- if (this.forgetFederatedSlot(), e instanceof H && e.code === "TOKENS_IN_URL_NOT_ALLOWED") {
5125
- U(this.subscribeStore, {
5146
+ if (this.forgetFederatedSlot(), e instanceof U && e.code === "TOKENS_IN_URL_NOT_ALLOWED") {
5147
+ W(this.subscribeStore, {
5126
5148
  operation: "tokens.from-url",
5127
5149
  message: e.message,
5128
5150
  code: e.code,
@@ -5136,11 +5158,11 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5136
5158
  code: e instanceof L ? "POPUP_CLOSED" : "AUTH_FAILED",
5137
5159
  originalError: e
5138
5160
  };
5139
- U(this.subscribeStore, t);
5161
+ W(this.subscribeStore, t);
5140
5162
  }
5141
5163
  }
5142
5164
  federatedAuthWithRedirect(e, t) {
5143
- if (this.subscribeStore.notify(W.SignInStart, { provider: e.provider }), !this.appId) throw Error(Ca);
5165
+ if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(Ca);
5144
5166
  let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
5145
5167
  this.startPkce().then(async (i) => {
5146
5168
  let a = {
@@ -5164,7 +5186,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5164
5186
  try {
5165
5187
  let n = await this.authApi.pkceExchange(e, t.verifier);
5166
5188
  if (this.handlePendingSecondFactor(n)) return;
5167
- await this.processAuthResponse(n, t.scopes), this.subscribeStore.notify(W.SignIn, {
5189
+ await this.processAuthResponse(n, t.scopes), this.subscribeStore.notify(G.SignIn, {
5168
5190
  tokens: n,
5169
5191
  parsedTokens: this.tokenCacheService.getParsedTokens(),
5170
5192
  source: "federated-landing"
@@ -5180,7 +5202,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5180
5202
  originalError: e,
5181
5203
  code: e instanceof z ? e.id : void 0
5182
5204
  };
5183
- U(this.subscribeStore, t);
5205
+ W(this.subscribeStore, t);
5184
5206
  }
5185
5207
  authRedirectUrl(e = {}) {
5186
5208
  try {
@@ -5198,13 +5220,13 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5198
5220
  message: e instanceof Error ? e.message : "Failed to create auth redirect URL",
5199
5221
  originalError: e
5200
5222
  };
5201
- throw U(this.subscribeStore, t), e;
5223
+ throw W(this.subscribeStore, t), e;
5202
5224
  }
5203
5225
  }
5204
5226
  async authRedirect(e = {}) {
5205
5227
  try {
5206
5228
  let { url: t, appId: n, redirectUrl: r, scopes: i, state: a } = e;
5207
- if (t !== void 0 && Qn(t) !== Qn(this.url) || n !== void 0 && n !== (this.appId ?? "")) throw new H("OVERRIDE_NOT_SUPPORTED", "authRedirect() signs in to this instance's url and appId; create a Passflow instance for another server or app");
5229
+ if (t !== void 0 && Zn(t) !== Zn(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");
5208
5230
  let o = await this.readAppSettings?.();
5209
5231
  if (o?.pkce_enabled !== !0) {
5210
5232
  let e = this.authRedirectUrl({
@@ -5214,8 +5236,8 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5214
5236
  this.platform.navigateTo(a ? `${e}&${new URLSearchParams({ state: a })}` : e);
5215
5237
  return;
5216
5238
  }
5217
- if (o.public_client === !1) throw new H("CONFIDENTIAL_CLIENT", qn(o.type));
5218
- let s = this.platform.getCurrentUrl(), c = await er({
5239
+ if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT", Kn(o.type));
5240
+ let s = this.platform.getCurrentUrl(), c = await $n({
5219
5241
  url: this.url,
5220
5242
  clientId: this.appId ?? "",
5221
5243
  redirectUri: r ?? (s ? s.origin + s.pathname : ""),
@@ -5227,18 +5249,18 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5227
5249
  operation: "auth-redirect",
5228
5250
  message: e instanceof Error ? e.message : "Failed to redirect to auth page",
5229
5251
  originalError: e,
5230
- code: e instanceof H ? e.code : e instanceof z ? e.id : void 0
5252
+ code: e instanceof U ? e.code : e instanceof z ? e.id : void 0
5231
5253
  };
5232
- throw U(this.subscribeStore, t), e;
5254
+ throw W(this.subscribeStore, t), e;
5233
5255
  }
5234
5256
  }
5235
5257
  handleOidcLanding(e) {
5236
5258
  if (!this.appId) return !1;
5237
5259
  let t = new URLSearchParams(e.search), n = t.get("code"), r = t.get("state"), i = t.get("error"), a = t.get("error_description");
5238
5260
  if (t.get("user_state") || r === null || !n && !i) return !1;
5239
- let o = nr();
5261
+ let o = tr();
5240
5262
  if (o.status === "none") return !1;
5241
- rr();
5263
+ nr();
5242
5264
  for (let e of [
5243
5265
  "code",
5244
5266
  "state",
@@ -5248,11 +5270,11 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5248
5270
  ]) t.delete(e);
5249
5271
  let s = t.toString();
5250
5272
  return this.platform.replaceUrl(e.pathname + (s ? `?${s}` : "") + e.hash), this.finishOidcLanding(async () => {
5251
- if (o.status === "unusable") throw new H("VERIFIER_MISSING", "This sign-in has expired or its proof key is gone. Sign in again.");
5252
- if (o.slot.state !== r) throw new H("STATE_MISMATCH", "The sign-in answer does not belong to this sign-in. Sign in again.");
5253
- if (i || !n) throw new H(i ?? "TOKEN_EXCHANGE_FAILED", ua(a || i || "Sign in again."));
5273
+ if (o.status === "unusable") throw new U("VERIFIER_MISSING", "This sign-in has expired or its proof key is gone. Sign in again.");
5274
+ if (o.slot.state !== r) throw new U("STATE_MISMATCH", "The sign-in answer does not belong to this sign-in. Sign in again.");
5275
+ if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED", ua(a || i || "Sign in again."));
5254
5276
  return {
5255
- tokens: await ar(this.url, n, o.slot),
5277
+ tokens: await ir(this.url, n, o.slot),
5256
5278
  scopes: o.slot.scopes,
5257
5279
  returnUrl: o.slot.redirectUri
5258
5280
  };
@@ -5262,16 +5284,16 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5262
5284
  try {
5263
5285
  await Promise.resolve();
5264
5286
  let { tokens: t, scopes: n, returnUrl: r } = await e();
5265
- await this.processAuthResponse(t, n), this.storageManager.setHostedSignIn(r), this.subscribeStore.notify(W.SignIn, {
5287
+ await this.processAuthResponse(t, n), this.storageManager.setHostedSignIn(r), this.subscribeStore.notify(G.SignIn, {
5266
5288
  tokens: t,
5267
5289
  parsedTokens: this.tokenCacheService.getParsedTokens(),
5268
5290
  source: "oidc-landing"
5269
5291
  }), await this.submitSessionCheck();
5270
5292
  } catch (e) {
5271
- U(this.subscribeStore, {
5293
+ W(this.subscribeStore, {
5272
5294
  operation: "oidc.redirect",
5273
5295
  message: e instanceof Error ? e.message : "Sign-in failed",
5274
- code: e instanceof H ? e.code : void 0,
5296
+ code: e instanceof U ? e.code : void 0,
5275
5297
  originalError: e
5276
5298
  });
5277
5299
  }
@@ -5289,7 +5311,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5289
5311
  message: e instanceof Error ? e.message : "Failed to check authentication status",
5290
5312
  originalError: e
5291
5313
  };
5292
- return U(this.subscribeStore, t), !1;
5314
+ return W(this.subscribeStore, t), !1;
5293
5315
  }
5294
5316
  }
5295
5317
  async submitSessionCheck(e = !1) {
@@ -5302,7 +5324,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5302
5324
  message: e instanceof Error || e instanceof z ? e.message : "Session check failed",
5303
5325
  originalError: e
5304
5326
  };
5305
- U(this.subscribeStore, n), t = void 0;
5327
+ W(this.subscribeStore, n), t = void 0;
5306
5328
  }
5307
5329
  return t && this.sessionCallbacks.createSession && await this.sessionCallbacks.createSession({
5308
5330
  tokens: t,
@@ -5337,11 +5359,11 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5337
5359
  message: e instanceof Error ? e.message : "Failed to get tokens",
5338
5360
  originalError: e
5339
5361
  };
5340
- U(this.subscribeStore, t);
5362
+ W(this.subscribeStore, t);
5341
5363
  return;
5342
5364
  }
5343
5365
  }
5344
- }, Ma = class {
5366
+ }, Pa = class {
5345
5367
  constructor(e) {
5346
5368
  this.invitationApi = e;
5347
5369
  }
@@ -5360,7 +5382,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5360
5382
  getInvitationLink(e) {
5361
5383
  return this.invitationApi.getInvitationLink(e);
5362
5384
  }
5363
- }, Na = class {
5385
+ }, Fa = class {
5364
5386
  constructor(e) {
5365
5387
  this.data = this.normalize(e);
5366
5388
  }
@@ -5417,9 +5439,9 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5417
5439
  getData() {
5418
5440
  return this.data;
5419
5441
  }
5420
- }, Pa = class {
5442
+ }, Ia = class {
5421
5443
  constructor(e, t, n) {
5422
- this.tenantApi = e, this.scopes = t, this.logger = n || ai();
5444
+ this.tenantApi = e, this.scopes = t, this.logger = n || ii();
5423
5445
  }
5424
5446
  handlePassflowError(t, n) {
5425
5447
  if (e.isAxiosError(t) && t.response?.data) {
@@ -5455,7 +5477,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5455
5477
  }
5456
5478
  async getTenantUserMembership(e) {
5457
5479
  try {
5458
- return new Na(await this.tenantApi.getTenantDetails(e));
5480
+ return new Fa(await this.tenantApi.getTenantDetails(e));
5459
5481
  } catch (t) {
5460
5482
  this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
5461
5483
  }
@@ -5600,7 +5622,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5600
5622
  this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
5601
5623
  }
5602
5624
  }
5603
- }, Fa = class {
5625
+ }, La = class {
5604
5626
  constructor(e, t, n, r = me) {
5605
5627
  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();
5606
5628
  }
@@ -5618,24 +5640,24 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5618
5640
  e || this.setTokensCache(t), this.startTokenCheck();
5619
5641
  return;
5620
5642
  }
5621
- A(j(t.access_token)) ? (this.stopTokenCheck(), this.tokenExpiredFlag || (this.tokenExpiredFlag = !0, this.subscribeStore.notify(W.TokenCacheExpired, { isExpired: !0 }))) : (e || this.setTokensCache(t), this.startTokenCheck());
5643
+ A(j(t.access_token)) ? (this.stopTokenCheck(), this.tokenExpiredFlag || (this.tokenExpiredFlag = !0, this.subscribeStore.notify(G.TokenCacheExpired, { isExpired: !0 }))) : (e || this.setTokensCache(t), this.startTokenCheck());
5622
5644
  } catch (e) {
5623
5645
  let t = {
5624
5646
  operation: "tokens.load",
5625
5647
  message: e instanceof Error ? e.message : "Failed to get tokens",
5626
5648
  originalError: e
5627
5649
  };
5628
- U(this.subscribeStore, t), this.setTokensCache(void 0);
5650
+ W(this.subscribeStore, t), this.setTokensCache(void 0);
5629
5651
  }
5630
5652
  }
5631
5653
  startTokenCheck() {
5632
5654
  this.checkInterval && clearInterval(this.checkInterval), this.tokenExpiredFlag || (this.setupLifecycleListeners(), this.checkInterval = setInterval(() => {
5633
- this.platform.isInForeground() && (this.isRefreshing || this.tokenExpiredFlag || this.isExpired() && !this.tokenExpiredFlag && (this.tokenExpiredFlag = !0, this.subscribeStore.notify(W.TokenCacheExpired, { isExpired: !0 }), this.stopTokenCheck()));
5655
+ this.platform.isInForeground() && (this.isRefreshing || this.tokenExpiredFlag || this.isExpired() && !this.tokenExpiredFlag && (this.tokenExpiredFlag = !0, this.subscribeStore.notify(G.TokenCacheExpired, { isExpired: !0 }), this.stopTokenCheck()));
5634
5656
  }, this.CHECK_INTERVAL));
5635
5657
  }
5636
5658
  setupLifecycleListeners() {
5637
5659
  this.unsubscribeForeground && (this.unsubscribeForeground(), this.unsubscribeForeground = null), this.unsubscribeForeground = this.platform.onForeground(() => {
5638
- this.checkInterval && !this.isRefreshing && !this.tokenExpiredFlag && this.isExpired() && (this.tokenExpiredFlag = !0, this.subscribeStore.notify(W.TokenCacheExpired, { isExpired: !0 }), this.stopTokenCheck());
5660
+ this.checkInterval && !this.isRefreshing && !this.tokenExpiredFlag && this.isExpired() && (this.tokenExpiredFlag = !0, this.subscribeStore.notify(G.TokenCacheExpired, { isExpired: !0 }), this.stopTokenCheck());
5639
5661
  }), this.unsubscribeUnload || (this.unsubscribeUnload = this.platform.onBeforeUnload(() => {
5640
5662
  this.destroy();
5641
5663
  }));
@@ -5670,7 +5692,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5670
5692
  message: e instanceof Error ? e.message : "Failed to get tokens",
5671
5693
  originalError: e
5672
5694
  };
5673
- U(this.subscribeStore, t);
5695
+ W(this.subscribeStore, t);
5674
5696
  return;
5675
5697
  }
5676
5698
  }
@@ -5680,18 +5702,18 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5680
5702
  isExpired() {
5681
5703
  return this.tokensCache ? this.tokensCache.access_token ? A(j(this.tokensCache.access_token)) : !1 : !0;
5682
5704
  }
5683
- }, Ia = class {
5705
+ }, Ra = class {
5684
5706
  constructor(e, t, n) {
5685
5707
  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) => {
5686
- if (e === W.TwoFactorRequired) {
5708
+ if (e === G.TwoFactorRequired) {
5687
5709
  let e = t;
5688
5710
  this.setPartialAuthState(e.email, e.challengeId, e.tfaToken);
5689
5711
  }
5690
- (e === W.SignIn || e === W.Register) && (this.clearPartialAuthState(), this.clearMagicLinkSession());
5712
+ (e === G.SignIn || e === G.Register) && (this.clearPartialAuthState(), this.clearMagicLinkSession());
5691
5713
  } }, [
5692
- W.TwoFactorRequired,
5693
- W.SignIn,
5694
- W.Register
5714
+ G.TwoFactorRequired,
5715
+ G.SignIn,
5716
+ G.Register
5695
5717
  ]);
5696
5718
  }
5697
5719
  emitErrorAndThrow(e, t, n) {
@@ -5701,7 +5723,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5701
5723
  originalError: e,
5702
5724
  code: r?.id || void 0
5703
5725
  };
5704
- throw U(this.subscribeStore, i), e;
5726
+ throw W(this.subscribeStore, i), e;
5705
5727
  }
5706
5728
  async getStatus() {
5707
5729
  try {
@@ -5772,11 +5794,11 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5772
5794
  e && (this.totpDigits = e);
5773
5795
  }
5774
5796
  setupStarted(e) {
5775
- return this.storeTotpDigits(e.totp_digits), this.subscribeStore.notify(W.TwoFactorSetupStarted, { secret: e.secret }), e;
5797
+ return this.storeTotpDigits(e.totp_digits), this.subscribeStore.notify(G.TwoFactorSetupStarted, { secret: e.secret }), e;
5776
5798
  }
5777
5799
  setupConfirmed(e) {
5778
5800
  let t = e.recovery_codes ?? [];
5779
- return this.subscribeStore.notify(W.TwoFactorEnabled, {
5801
+ return this.subscribeStore.notify(G.TwoFactorEnabled, {
5780
5802
  recoveryCodes: t,
5781
5803
  clearRecoveryCodes: () => {
5782
5804
  t.length = 0;
@@ -5792,7 +5814,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5792
5814
  tfa_token: this.partialAuthState.tfaToken,
5793
5815
  ...t?.trustDevice ? { trust_device: !0 } : {}
5794
5816
  }), r = await this.finishSignIn(n);
5795
- return this.subscribeStore.notify(W.TwoFactorVerified, { tokens: r }), r;
5817
+ return this.subscribeStore.notify(G.TwoFactorVerified, { tokens: r }), r;
5796
5818
  } catch (e) {
5797
5819
  this.emitErrorAndThrow(e, "2fa.verify", "Verify 2FA code");
5798
5820
  }
@@ -5808,13 +5830,13 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5808
5830
  tfa_token: this.partialAuthState.tfaToken,
5809
5831
  ...t?.trustDevice ? { trust_device: !0 } : {}
5810
5832
  })), i = r.remaining_recovery_codes;
5811
- return i === 0 ? this.subscribeStore.notify(W.TwoFactorRecoveryCodesExhausted, { tokens: r }) : typeof i == "number" && i <= 2 && this.subscribeStore.notify(W.TwoFactorRecoveryCodesLow, {
5833
+ return i === 0 ? this.subscribeStore.notify(G.TwoFactorRecoveryCodesExhausted, { tokens: r }) : typeof i == "number" && i <= 2 && this.subscribeStore.notify(G.TwoFactorRecoveryCodesLow, {
5812
5834
  tokens: r,
5813
5835
  remainingCodes: i
5814
- }), this.subscribeStore.notify(W.TwoFactorRecoveryUsed, {
5836
+ }), this.subscribeStore.notify(G.TwoFactorRecoveryUsed, {
5815
5837
  tokens: r,
5816
5838
  remainingCodes: r.remaining_recovery_codes
5817
- }), this.subscribeStore.notify(W.TwoFactorVerified, { tokens: r }), r;
5839
+ }), this.subscribeStore.notify(G.TwoFactorVerified, { tokens: r }), r;
5818
5840
  } catch (e) {
5819
5841
  this.emitErrorAndThrow(e, "2fa.recovery.use", "Use recovery code");
5820
5842
  }
@@ -5823,7 +5845,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5823
5845
  this.assertTotpCode(e);
5824
5846
  try {
5825
5847
  let t = await this.twoFactorApi.disable({ code: e });
5826
- return this.subscribeStore.notify(W.TwoFactorDisabled, {}), t;
5848
+ return this.subscribeStore.notify(G.TwoFactorDisabled, {}), t;
5827
5849
  } catch (e) {
5828
5850
  this.emitErrorAndThrow(e, "2fa.disable", "Disable 2FA");
5829
5851
  }
@@ -5898,13 +5920,13 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5898
5920
  reset: t.reset === !0,
5899
5921
  timestamp: Date.now(),
5900
5922
  expiresAt: Date.now() + (t.expiresIn || 3600) * 1e3
5901
- }, this.subscribeStore.notify(W.TwoFactorSetupMagicLinkValidated, {
5923
+ }, this.subscribeStore.notify(G.TwoFactorSetupMagicLinkValidated, {
5902
5924
  userId: t.userId,
5903
5925
  appId: t.appId,
5904
5926
  expiresIn: t.expiresIn || 3600,
5905
5927
  sessionToken: t.sessionToken,
5906
5928
  reset: t.reset === !0
5907
- })) : t.error && this.subscribeStore.notify(W.TwoFactorSetupMagicLinkFailed, { error: t.error }), t;
5929
+ })) : t.error && this.subscribeStore.notify(G.TwoFactorSetupMagicLinkFailed, { error: t.error }), t;
5908
5930
  }
5909
5931
  getMagicLinkSession() {
5910
5932
  return this.magicLinkSession ? Date.now() > this.magicLinkSession.expiresAt ? (this.clearMagicLinkSession(), null) : this.magicLinkSession : null;
@@ -5952,7 +5974,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5952
5974
  async startMethodSetup(e, t) {
5953
5975
  try {
5954
5976
  let n = await this.twoFactorApi.startMethodSetup(e, t);
5955
- return this.subscribeStore.notify(W.TwoFactorSetupStarted, {
5977
+ return this.subscribeStore.notify(G.TwoFactorSetupStarted, {
5956
5978
  secret: "",
5957
5979
  method: e
5958
5980
  }), n;
@@ -5963,7 +5985,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5963
5985
  async completeMethodSetup(e, t) {
5964
5986
  try {
5965
5987
  let n = await this.twoFactorApi.completeMethodSetup(e, t);
5966
- return this.subscribeStore.notify(W.TwoFactorEnabled, {
5988
+ return this.subscribeStore.notify(G.TwoFactorEnabled, {
5967
5989
  recoveryCodes: [],
5968
5990
  clearRecoveryCodes: () => {}
5969
5991
  }), n;
@@ -5981,7 +6003,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5981
6003
  async requestChallenge(e) {
5982
6004
  try {
5983
6005
  let t = await this.twoFactorApi.requestChallenge(e, this.pendingTfaToken());
5984
- return this.storeTotpDigits(t.totp_digits), this.subscribeStore.notify(W.TwoFactorChallengeReceived, {
6006
+ return this.storeTotpDigits(t.totp_digits), this.subscribeStore.notify(G.TwoFactorChallengeReceived, {
5985
6007
  challengeId: t.challenge_id,
5986
6008
  method: t.method,
5987
6009
  alternativeMethods: t.alternative_methods ?? []
@@ -5993,7 +6015,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
5993
6015
  async verifyV2(e) {
5994
6016
  try {
5995
6017
  let t = await this.twoFactorApi.verifyV2(e, this.pendingTfaToken()), n = await this.finishSignIn(t);
5996
- return this.subscribeStore.notify(W.TwoFactorVerified, { tokens: {
6018
+ return this.subscribeStore.notify(G.TwoFactorVerified, { tokens: {
5997
6019
  access_token: n.access_token,
5998
6020
  refresh_token: n.refresh_token
5999
6021
  } }), await this.signInCompleter?.notifySignedIn(n), n;
@@ -6004,7 +6026,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6004
6026
  async switchToAlternative(e) {
6005
6027
  try {
6006
6028
  let t = await this.twoFactorApi.switchToAlternative(e, this.pendingTfaToken());
6007
- return this.storeTotpDigits(t.totp_digits), this.subscribeStore.notify(W.TwoFactorMethodSwitched, {
6029
+ return this.storeTotpDigits(t.totp_digits), this.subscribeStore.notify(G.TwoFactorMethodSwitched, {
6008
6030
  challengeId: t.challenge_id,
6009
6031
  method: t.method,
6010
6032
  alternativeMethods: t.alternative_methods ?? []
@@ -6048,7 +6070,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6048
6070
  this.emitErrorAndThrow(e, "2fa.preferred-method.clear", "Clear preferred 2FA method");
6049
6071
  }
6050
6072
  }
6051
- }, La = class {
6073
+ }, za = class {
6052
6074
  constructor(e, t, n = me) {
6053
6075
  this.userAPI = e, this.deviceService = t, this.platform = n;
6054
6076
  }
@@ -6090,77 +6112,77 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6090
6112
  updateProfile(e, t) {
6091
6113
  return this.userAPI.updateProfile(e, t);
6092
6114
  }
6093
- }, Ra = class extends Error {
6115
+ }, Ba = class extends Error {
6094
6116
  constructor(e, t, n = !1) {
6095
6117
  super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
6096
6118
  }
6097
- }, za = (e, t) => {
6119
+ }, Va = (e, t) => {
6098
6120
  let n = t?.trim();
6099
- if (!n) throw new Ra(e, "A verification code is required");
6121
+ if (!n) throw new Ba(e, "A verification code is required");
6100
6122
  return n;
6101
- }, Ba = {
6123
+ }, Ha = {
6102
6124
  type: "totp",
6103
6125
  requiresPrepare: !1,
6104
6126
  input: "code",
6105
- assert: async ({ code: e }) => ({ code: za("totp", e) })
6106
- }, Va = {
6127
+ assert: async ({ code: e }) => ({ code: Va("totp", e) })
6128
+ }, Ua = {
6107
6129
  type: "recovery_codes",
6108
6130
  requiresPrepare: !1,
6109
6131
  input: "code",
6110
- assert: async ({ code: e }) => ({ code: za("recovery_codes", e) })
6111
- }, Ha = {
6132
+ assert: async ({ code: e }) => ({ code: Va("recovery_codes", e) })
6133
+ }, Wa = {
6112
6134
  type: "passkey",
6113
6135
  requiresPrepare: !0,
6114
6136
  input: "none",
6115
6137
  assert: async ({ prepared: e, platform: t }) => {
6116
- if (!e?.webauthn) throw new Ra("passkey", "The upgrade challenge carried no WebAuthn options");
6138
+ if (!e?.webauthn) throw new Ba("passkey", "The upgrade challenge carried no WebAuthn options");
6117
6139
  let n = t.passkeys;
6118
- if (!n) throw new Ra("passkey", "This platform does not support passkeys");
6140
+ if (!n) throw new Ba("passkey", "This platform does not support passkeys");
6119
6141
  let r;
6120
6142
  try {
6121
6143
  r = await n.startAuthentication(e.webauthn);
6122
6144
  } catch (e) {
6123
- throw new Ra("passkey", e?.message || "Passkey verification was cancelled", !0);
6145
+ throw new Ba("passkey", e?.message || "Passkey verification was cancelled", !0);
6124
6146
  }
6125
- if (!r) throw new Ra("passkey", "Passkey verification was cancelled", !0);
6147
+ if (!r) throw new Ba("passkey", "Passkey verification was cancelled", !0);
6126
6148
  return {
6127
6149
  challenge_id: e.challengeId,
6128
6150
  credential: r
6129
6151
  };
6130
6152
  }
6131
- }, Ua = Object.freeze([
6132
- Ba,
6153
+ }, Ga = Object.freeze([
6133
6154
  Ha,
6134
- Va
6135
- ]), Wa = (e = Ua) => new Map(e.map((e) => [e.type, e])), Ga = 3, Ka = {
6155
+ Wa,
6156
+ Ua
6157
+ ]), Ka = (e = Ga) => new Map(e.map((e) => [e.type, e])), qa = 3, Ja = {
6136
6158
  totp: 0,
6137
6159
  passkey: 1,
6138
6160
  email_otp: 2,
6139
6161
  sms_otp: 3,
6140
6162
  recovery_codes: 9
6141
- }, qa = (e) => e.requiredLevel ?? ye(e.acrValues), Ja = (e, t) => {
6142
- let n = Ka[e.type] ?? 5, r = t !== void 0 && t >= Ga, i = e.type === "passkey";
6163
+ }, Ya = (e) => e.requiredLevel ?? ye(e.acrValues), Xa = (e, t) => {
6164
+ let n = Ja[e.type] ?? 5, r = t !== void 0 && t >= qa, i = e.type === "passkey";
6143
6165
  return (r && !i ? 100 : 0) + n;
6144
- }, Ya = (e, t) => {
6166
+ }, Za = (e, t) => {
6145
6167
  if (t.availableFactors) return t.availableFactors.flatMap((t) => e.find((e) => e.type === t) ?? []);
6146
- let n = qa(t);
6147
- return [...e].sort((e, t) => Ja(e, n) - Ja(t, n));
6148
- }, Xa = class extends Error {
6168
+ let n = Ya(t);
6169
+ return [...e].sort((e, t) => Xa(e, n) - Xa(t, n));
6170
+ }, Qa = class extends Error {
6149
6171
  constructor(e) {
6150
6172
  super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
6151
6173
  }
6152
- }, Za = class extends Error {
6174
+ }, $a = class extends Error {
6153
6175
  constructor(e = "Only a fresh sign-in can meet this challenge") {
6154
6176
  super(e), this.code = "upgrade_sign_in_required", this.name = "UpgradeSignInRequiredError";
6155
6177
  }
6156
- }, Qa = (e) => e?.signInRequired === !0 || e?.signInRequired === void 0 && e?.availableFactors?.length === 0, $a = (e) => e?.signInRequired === !1 && e.availableFactors?.length === 0, eo = "This account has no factor that reaches the required level (it may need a device-bound passkey)", to = (e) => {
6157
- if (Qa(e)) return new Za();
6158
- if ($a(e)) return new no(eo);
6159
- }, no = class extends Error {
6178
+ }, eo = (e) => e?.signInRequired === !0 || e?.signInRequired === void 0 && e?.availableFactors?.length === 0, to = (e) => e?.signInRequired === !1 && e.availableFactors?.length === 0, no = "This account has no factor that reaches the required level (it may need a device-bound passkey)", ro = (e) => {
6179
+ if (eo(e)) return new $a();
6180
+ if (to(e)) return new io(no);
6181
+ }, io = class extends Error {
6160
6182
  constructor(e = "No available authentication factor can satisfy this challenge") {
6161
6183
  super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
6162
6184
  }
6163
- }, ro = 4, io = 3e4, ao = () => {
6185
+ }, ao = 4, oo = 3e4, so = () => {
6164
6186
  let e = () => void 0, t = () => void 0;
6165
6187
  return {
6166
6188
  promise: new Promise((n, r) => {
@@ -6169,12 +6191,12 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6169
6191
  resolve: e,
6170
6192
  reject: t
6171
6193
  };
6172
- }, oo = (e) => ({
6194
+ }, co = (e) => ({
6173
6195
  acrValues: e.acrValues,
6174
6196
  level: e.requiredLevel,
6175
6197
  maxAge: e.maxAge
6176
- }), so = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, co = (e, t) => {
6177
- 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 } = lo(t, e) && !lo(e, t) || !t.availableFactors ? e : t;
6198
+ }), lo = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, uo = (e, t) => {
6199
+ 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 } = fo(t, e) && !fo(e, t) || !t.availableFactors ? e : t;
6178
6200
  return {
6179
6201
  acrValues: r,
6180
6202
  requiredLevel: n,
@@ -6184,12 +6206,12 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6184
6206
  ...o ? { availableFactors: o } : {},
6185
6207
  ...s === void 0 ? {} : { signInRequired: s }
6186
6208
  };
6187
- }, lo = (e, t) => {
6209
+ }, fo = (e, t) => {
6188
6210
  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);
6189
6211
  return n || r;
6190
- }, uo = class {
6212
+ }, po = class {
6191
6213
  constructor(e) {
6192
- 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 ?? Ua, this.registry = Wa(this.available), this.maxAttempts = e.maxAttempts ?? ro, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? io;
6214
+ 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 ?? Ga, this.registry = Ka(this.available), this.maxAttempts = e.maxAttempts ?? ao, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? oo;
6193
6215
  }
6194
6216
  get currentState() {
6195
6217
  return this.state;
@@ -6209,9 +6231,9 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6209
6231
  }
6210
6232
  register(e, t) {
6211
6233
  let n = t.kind === "imperative" && t.requested !== void 0, r = {
6212
- demanded: t.kind === "imperative" && t.requested ? t.requested : oo(e),
6234
+ demanded: t.kind === "imperative" && t.requested ? t.requested : co(e),
6213
6235
  statedBar: n,
6214
- settlement: ao(),
6236
+ settlement: so(),
6215
6237
  reported: !1,
6216
6238
  entry: {
6217
6239
  ...t,
@@ -6227,15 +6249,15 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6227
6249
  this.requirement = e;
6228
6250
  return;
6229
6251
  }
6230
- let n = lo(t, e);
6231
- this.requirement = co(t, e), to(this.requirement) ? this.state === "collecting" && this.selected === null && (this.openPrompt?.onClosed?.(), this.closeOpenPrompt?.()) : n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
6252
+ let n = fo(t, e);
6253
+ this.requirement = uo(t, e), ro(this.requirement) ? this.state === "collecting" && this.selected === null && (this.openPrompt?.onClosed?.(), this.closeOpenPrompt?.()) : n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
6232
6254
  challenge: this.requirement,
6233
6255
  factors: this.offeredFactors()
6234
6256
  });
6235
6257
  }
6236
6258
  offeredFactors() {
6237
6259
  let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
6238
- return t ? Ya(e, t) : e;
6260
+ return t ? Za(e, t) : e;
6239
6261
  }
6240
6262
  receiveReport(e, t) {
6241
6263
  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());
@@ -6270,7 +6292,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6270
6292
  }
6271
6293
  release(e, t) {
6272
6294
  if (e.entry.kind === "imperative") {
6273
- if (e.statedBar && !so(t, e.demanded)) {
6295
+ if (e.statedBar && !lo(t, e.demanded)) {
6274
6296
  this.receiveReport(e, {
6275
6297
  outcome: "insufficient",
6276
6298
  obtained: t,
@@ -6345,7 +6367,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6345
6367
  async prove() {
6346
6368
  let e;
6347
6369
  for (let t = 0; t < this.maxAttempts; t++) {
6348
- let t = to(this.requirement);
6370
+ let t = ro(this.requirement);
6349
6371
  if (t) return {
6350
6372
  status: "failed",
6351
6373
  reason: t
@@ -6353,7 +6375,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6353
6375
  let n = this.offeredFactors();
6354
6376
  if (n.length === 0) return {
6355
6377
  status: "failed",
6356
- reason: new no()
6378
+ reason: new io()
6357
6379
  };
6358
6380
  let r = this.requirement, i;
6359
6381
  try {
@@ -6361,29 +6383,29 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6361
6383
  } catch (e) {
6362
6384
  return {
6363
6385
  status: "failed",
6364
- reason: new Xa(e)
6386
+ reason: new Qa(e)
6365
6387
  };
6366
6388
  }
6367
- let a = to(this.requirement);
6389
+ let a = ro(this.requirement);
6368
6390
  if (a) return {
6369
6391
  status: "failed",
6370
6392
  reason: a
6371
6393
  };
6372
6394
  if (i.type === "cancel") return {
6373
6395
  status: "failed",
6374
- reason: new Xa()
6396
+ reason: new Qa()
6375
6397
  };
6376
6398
  let o = this.registry.get(i.factor);
6377
- if (!o) e = new no(`Unknown authentication factor: ${i.factor}`), this.state = "collecting", this.selected = null;
6399
+ if (!o) e = new io(`Unknown authentication factor: ${i.factor}`), this.state = "collecting", this.selected = null;
6378
6400
  else try {
6379
6401
  return await this.proveAndCommit(o, i.code), {
6380
6402
  status: "proven",
6381
- obtained: this.readObtainedBar?.() ?? oo(this.rankedRequirement ?? r)
6403
+ obtained: this.readObtainedBar?.() ?? co(this.rankedRequirement ?? r)
6382
6404
  };
6383
6405
  } catch (t) {
6384
- if (t instanceof Ra && t.cancelled) return {
6406
+ if (t instanceof Ba && t.cancelled) return {
6385
6407
  status: "failed",
6386
- reason: new Xa()
6408
+ reason: new Qa()
6387
6409
  };
6388
6410
  let n = this.classifyProofFailure(t);
6389
6411
  if (n) return {
@@ -6440,28 +6462,28 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6440
6462
  });
6441
6463
  await this.transport.commit(e.type, r);
6442
6464
  }
6443
- }, fo = (e) => typeof e == "function" ? e() : e, po = (e) => {
6465
+ }, mo = (e) => typeof e == "function" ? e() : e, ho = (e) => {
6444
6466
  try {
6445
6467
  return new URL(e);
6446
6468
  } catch {
6447
6469
  return;
6448
6470
  }
6449
- }, mo = (e, t) => {
6471
+ }, go = (e, t) => {
6450
6472
  if (!t || t === "/") return !0;
6451
6473
  let n = t.replace(/\/+$/, "");
6452
6474
  return e === n || e.startsWith(`${n}/`);
6453
- }, ho = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && mo(e.pathname, t.pathPrefix), go = (e, t) => {
6475
+ }, _o = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && go(e.pathname, t.pathPrefix), vo = (e, t) => {
6454
6476
  for (let n of t) {
6455
6477
  if (n === "") continue;
6456
6478
  if (n.startsWith("/")) {
6457
- if (e.relativeToBase && mo(e.pathname, n)) return !0;
6479
+ if (e.relativeToBase && go(e.pathname, n)) return !0;
6458
6480
  continue;
6459
6481
  }
6460
- let t = po(n) ?? po(`https://${n}`);
6461
- if (t && e.origin !== void 0 && e.origin === t.origin && mo(e.pathname, t.pathname)) return !0;
6482
+ let t = ho(n) ?? ho(`https://${n}`);
6483
+ if (t && e.origin !== void 0 && e.origin === t.origin && go(e.pathname, t.pathname)) return !0;
6462
6484
  }
6463
6485
  return !1;
6464
- }, _o = (e, t, n) => ho(e, t.passflow) || go(e, t.backend) ? !n || n(e.href) !== !1 : !1, vo = (e) => {
6486
+ }, yo = (e, t, n) => _o(e, t.passflow) || vo(e, t.backend) ? !n || n(e.href) !== !1 : !1, bo = (e) => {
6465
6487
  let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
6466
6488
  console.warn(n, {
6467
6489
  status: e.status,
@@ -6469,8 +6491,8 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6469
6491
  reason: e.reason,
6470
6492
  detail: t
6471
6493
  });
6472
- }, yo = (e, t) => {
6473
- let n = t.onUpgradeDiagnostic ?? vo;
6494
+ }, xo = (e, t) => {
6495
+ let n = t.onUpgradeDiagnostic ?? bo;
6474
6496
  return (t, r) => {
6475
6497
  n({
6476
6498
  status: e.status,
@@ -6482,8 +6504,8 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6482
6504
  }
6483
6505
  });
6484
6506
  };
6485
- }, bo = (e, t, n) => {
6486
- let r = n.onUpgradeDiagnostic ?? vo;
6507
+ }, So = (e, t, n) => {
6508
+ let r = n.onUpgradeDiagnostic ?? bo;
6487
6509
  for (let n of e) r({
6488
6510
  ...n,
6489
6511
  url: t.request.href,
@@ -6492,8 +6514,8 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6492
6514
  ...n.detail ?? {}
6493
6515
  }
6494
6516
  });
6495
- }, xo = /\bjson\b/i, So = async (e, t) => {
6496
- let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && xo.test(r), a;
6517
+ }, Co = /\bjson\b/i, wo = async (e, t) => {
6518
+ let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && Co.test(r), a;
6497
6519
  if (i) try {
6498
6520
  a = await e.readBody();
6499
6521
  } catch {
@@ -6507,10 +6529,10 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6507
6529
  status: e.status,
6508
6530
  getHeader: (t) => e.getHeader(t) ?? void 0
6509
6531
  }, { requireChallengeChannel: t.requireChallengeChannel });
6510
- }, Co = (e) => je({
6532
+ }, To = (e) => je({
6511
6533
  status: e.status,
6512
6534
  getHeader: (t) => e.getHeader(t) ?? void 0
6513
- }, { requireChallengeChannel: "header" }).challenge, wo = (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.`, To = (e, t) => e instanceof Xa ? { kind: "cancelled" } : e instanceof Za ? { kind: "sign-in-required" } : e instanceof no ? {
6535
+ }, { requireChallengeChannel: "header" }).challenge, Eo = (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.`, Do = (e, t) => e instanceof Qa ? { kind: "cancelled" } : e instanceof $a ? { kind: "sign-in-required" } : e instanceof io ? {
6514
6536
  kind: "unsatisfiable",
6515
6537
  error: e
6516
6538
  } : e instanceof aa ? { kind: "unavailable" } : e instanceof oa ? { kind: "session-changed" } : e instanceof ia ? {
@@ -6529,26 +6551,26 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6529
6551
  kind: "transport-failure",
6530
6552
  retryable: !1,
6531
6553
  error: e instanceof Error ? e : Error(String(e))
6532
- }, Eo = async (e, t, n, r) => {
6554
+ }, Oo = async (e, t, n, r) => {
6533
6555
  if (e.status !== 401 && e.status !== 403) return {
6534
6556
  kind: "replayed",
6535
6557
  response: e
6536
6558
  };
6537
- let { challenge: i, diagnostics: a } = await So(e, t);
6538
- if (bo(a, e, t), !i) return {
6559
+ let { challenge: i, diagnostics: a } = await wo(e, t);
6560
+ if (So(a, e, t), !i) return {
6539
6561
  kind: "replayed",
6540
6562
  response: e
6541
6563
  };
6542
- if (Qa(i)) return {
6564
+ if (eo(i)) return {
6543
6565
  kind: "sign-in-required",
6544
6566
  response: e
6545
6567
  };
6546
- if ($a(i)) return {
6568
+ if (to(i)) return {
6547
6569
  kind: "unsatisfiable",
6548
- error: to(i),
6570
+ error: ro(i),
6549
6571
  response: e
6550
6572
  };
6551
- let o = oo(i);
6573
+ let o = co(i);
6552
6574
  return r("elevated-insufficient", {
6553
6575
  obtained: n,
6554
6576
  required: o
@@ -6558,7 +6580,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6558
6580
  required: o,
6559
6581
  response: e
6560
6582
  };
6561
- }, Do = async (e, t) => {
6583
+ }, ko = async (e, t) => {
6562
6584
  if (!t) return {
6563
6585
  aborted: !1,
6564
6586
  value: await e
@@ -6585,14 +6607,14 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6585
6607
  } finally {
6586
6608
  n && t.removeEventListener?.("abort", n);
6587
6609
  }
6588
- }, Oo = async (e, t) => {
6610
+ }, Ao = async (e, t) => {
6589
6611
  if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
6590
- let n = yo(e, t);
6612
+ let n = xo(e, t);
6591
6613
  if (e.markers.replayed) {
6592
- if (!_o(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
6593
- let { challenge: r, diagnostics: i } = await So(e, t);
6594
- if (bo(i, e, t), !r) return { kind: "not-a-challenge" };
6595
- let a = t.readObtainedBar?.() ?? {}, o = oo(r);
6614
+ if (!yo(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
6615
+ let { challenge: r, diagnostics: i } = await wo(e, t);
6616
+ if (So(i, e, t), !r) return { kind: "not-a-challenge" };
6617
+ let a = t.readObtainedBar?.() ?? {}, o = co(r);
6596
6618
  return n("elevated-insufficient", {
6597
6619
  obtained: a,
6598
6620
  required: o
@@ -6603,12 +6625,12 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6603
6625
  response: e
6604
6626
  };
6605
6627
  }
6606
- if (!_o(e.request, t.scope, t.shouldIntercept)) return Co(e) ? (n("challenge-out-of-scope", {
6628
+ if (!yo(e.request, t.scope, t.shouldIntercept)) return To(e) ? (n("challenge-out-of-scope", {
6607
6629
  header: e.getHeader("www-authenticate") ?? void 0,
6608
- message: wo(e.request.href, t.scope)
6630
+ message: Eo(e.request.href, t.scope)
6609
6631
  }), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
6610
- let { challenge: r, diagnostics: i } = await So(e, t);
6611
- if (bo(i, e, t), !r) {
6632
+ let { challenge: r, diagnostics: i } = await wo(e, t);
6633
+ if (So(i, e, t), !r) {
6612
6634
  let r = e.getHeader("www-authenticate");
6613
6635
  return t.requireChallengeChannel !== "header" && n("no-channel", {
6614
6636
  ...r ? { header: r } : {},
@@ -6622,9 +6644,9 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6622
6644
  method: e.request.method
6623
6645
  }, s, c;
6624
6646
  try {
6625
- s = Promise.resolve(t.elevate(r, o)), c = await Do(s, e.signal);
6647
+ s = Promise.resolve(t.elevate(r, o)), c = await ko(s, e.signal);
6626
6648
  } catch (e) {
6627
- return To(e, void 0);
6649
+ return Do(e, void 0);
6628
6650
  }
6629
6651
  if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
6630
6652
  kind: "aborted",
@@ -6635,7 +6657,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6635
6657
  kind: "aborted",
6636
6658
  reason: e.signal.reason
6637
6659
  };
6638
- let u = l?.obtained ?? t.readObtainedBar?.() ?? oo(r), d = t.authorizationSwap?.(), f = d ? {
6660
+ let u = l?.obtained ?? t.readObtainedBar?.() ?? co(r), d = t.authorizationSwap?.(), f = d ? {
6639
6661
  from: a?.from ?? d.from,
6640
6662
  to: d.to
6641
6663
  } : void 0;
@@ -6662,7 +6684,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6662
6684
  };
6663
6685
  throw t;
6664
6686
  }
6665
- let m = await Eo(p, t, u, n);
6687
+ let m = await Oo(p, t, u, n);
6666
6688
  return m.kind === "insufficient" ? l?.waiter.report({
6667
6689
  outcome: "insufficient",
6668
6690
  obtained: m.obtained,
@@ -6671,11 +6693,11 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6671
6693
  outcome: "replayed",
6672
6694
  obtained: u
6673
6695
  }), m;
6674
- }, ko = (e) => {
6696
+ }, jo = (e) => {
6675
6697
  switch (e.kind) {
6676
- case "cancelled": return new Xa();
6677
- case "unsatisfiable": return e.error ?? new no();
6678
- case "sign-in-required": return new Za();
6698
+ case "cancelled": return new Qa();
6699
+ case "unsatisfiable": return e.error ?? new io();
6700
+ case "sign-in-required": return new $a();
6679
6701
  case "unavailable": return new aa();
6680
6702
  case "session-changed": return new oa();
6681
6703
  case "insufficient": return new ia(e.obtained, e.required);
@@ -6683,7 +6705,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6683
6705
  case "transport-failure": return e.error;
6684
6706
  default: return;
6685
6707
  }
6686
- }, Ao = (e, t, n) => {
6708
+ }, Mo = (e, t, n) => {
6687
6709
  switch (e.kind) {
6688
6710
  case "replayed": return {
6689
6711
  settle: "resolve",
@@ -6701,26 +6723,26 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6701
6723
  };
6702
6724
  case "cancelled": return n.onCancel === "reject" ? {
6703
6725
  settle: "reject",
6704
- error: new Xa()
6726
+ error: new Qa()
6705
6727
  } : {
6706
6728
  settle: "resolve",
6707
- value: Bo(t, e)
6729
+ value: Ho(t, e)
6708
6730
  };
6709
6731
  case "unsatisfiable":
6710
6732
  case "sign-in-required": return {
6711
6733
  settle: "resolve",
6712
- value: Bo(e.response?.raw ?? t, e)
6734
+ value: Ho(e.response?.raw ?? t, e)
6713
6735
  };
6714
6736
  case "insufficient": return {
6715
6737
  settle: "resolve",
6716
- value: Bo(e.response?.raw ?? t, e)
6738
+ value: Ho(e.response?.raw ?? t, e)
6717
6739
  };
6718
6740
  default: return {
6719
6741
  settle: "resolve",
6720
- value: Bo(t, e)
6742
+ value: Ho(t, e)
6721
6743
  };
6722
6744
  }
6723
- }, jo = (e, t) => {
6745
+ }, No = (e, t) => {
6724
6746
  switch (e.kind) {
6725
6747
  case "replayed": return e.response.rejected ? {
6726
6748
  settle: "reject",
@@ -6735,42 +6757,42 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6735
6757
  };
6736
6758
  default: return {
6737
6759
  settle: "reject",
6738
- error: ko(e) ?? t
6760
+ error: jo(e) ?? t
6739
6761
  };
6740
6762
  }
6741
- }, Mo = /* @__PURE__ */ new WeakSet(), No = /* @__PURE__ */ new WeakSet(), Po = /* @__PURE__ */ new WeakSet(), Fo = /* @__PURE__ */ new WeakSet(), Io = /* @__PURE__ */ new WeakSet(), Lo = /* @__PURE__ */ new WeakSet(), Ro = /* @__PURE__ */ new WeakSet(), zo = /* @__PURE__ */ new WeakSet(), Bo = (e, t) => {
6763
+ }, Po = /* @__PURE__ */ new WeakSet(), Fo = /* @__PURE__ */ new WeakSet(), Io = /* @__PURE__ */ new WeakSet(), Lo = /* @__PURE__ */ new WeakSet(), Ro = /* @__PURE__ */ new WeakSet(), zo = /* @__PURE__ */ new WeakSet(), Bo = /* @__PURE__ */ new WeakSet(), Vo = /* @__PURE__ */ new WeakSet(), Ho = (e, t) => {
6742
6764
  switch (t.kind) {
6743
6765
  case "cancelled":
6744
- Mo.add(e);
6766
+ Po.add(e);
6745
6767
  break;
6746
6768
  case "exhausted":
6747
- No.add(e);
6769
+ Fo.add(e);
6748
6770
  break;
6749
6771
  case "insufficient":
6750
- Po.add(e);
6772
+ Io.add(e);
6751
6773
  break;
6752
6774
  case "unsatisfiable":
6753
- Fo.add(e);
6775
+ Lo.add(e);
6754
6776
  break;
6755
6777
  case "sign-in-required":
6756
- Io.add(e);
6778
+ Ro.add(e);
6757
6779
  break;
6758
6780
  case "unavailable":
6759
- Lo.add(e);
6781
+ zo.add(e);
6760
6782
  break;
6761
6783
  case "session-changed":
6762
- Ro.add(e);
6784
+ Bo.add(e);
6763
6785
  break;
6764
- case "transport-failure": zo.add(e);
6786
+ case "transport-failure": Vo.add(e);
6765
6787
  }
6766
6788
  return e;
6767
- }, Vo = (e) => Mo.has(e), Ho = (e) => No.has(e), Uo = (e) => Po.has(e), Wo = (e) => Fo.has(e), Go = (e) => Io.has(e), Ko = (e) => Lo.has(e), qo = (e) => Ro.has(e), Jo = (e) => zo.has(e), Yo = "https://passflow-relative.invalid", Xo = () => {
6789
+ }, Uo = (e) => Po.has(e), Wo = (e) => Fo.has(e), Go = (e) => Io.has(e), Ko = (e) => Lo.has(e), qo = (e) => Ro.has(e), Jo = (e) => zo.has(e), Yo = (e) => Bo.has(e), Xo = (e) => Vo.has(e), Zo = "https://passflow-relative.invalid", Qo = () => {
6768
6790
  let e = globalThis, t = e.document?.baseURI;
6769
6791
  if (typeof t == "string" && t !== "") return t;
6770
6792
  let n = e.location?.href;
6771
- return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Yo;
6772
- }, Zo = (e, t = Xo()) => {
6773
- let n = t === Yo, r;
6793
+ return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Zo;
6794
+ }, $o = (e, t = Qo()) => {
6795
+ let n = t === Zo, r;
6774
6796
  try {
6775
6797
  r = new URL(t).origin;
6776
6798
  } catch {
@@ -6796,28 +6818,28 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6796
6818
  relativeToBase: !1,
6797
6819
  sentinelBase: n
6798
6820
  };
6799
- }, Qo = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, $o = (e) => {
6821
+ }, es = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, ts = (e) => {
6800
6822
  let t = [];
6801
6823
  if (e == null) return Object.freeze(t);
6802
6824
  let n = e;
6803
6825
  if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
6804
- let r = Qo(n, e);
6826
+ let r = es(n, e);
6805
6827
  r && t.push(r);
6806
6828
  }), Object.freeze(t);
6807
6829
  if (Array.isArray(e)) {
6808
6830
  for (let n of e) if (Array.isArray(n) && n.length >= 2) {
6809
- let e = Qo(String(n[0]), n[1]);
6831
+ let e = es(String(n[0]), n[1]);
6810
6832
  e && t.push(e);
6811
6833
  }
6812
6834
  return Object.freeze(t);
6813
6835
  }
6814
6836
  if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
6815
- let e = Qo(n, Array.isArray(r) ? r.join(", ") : r);
6837
+ let e = es(n, Array.isArray(r) ? r.join(", ") : r);
6816
6838
  e && t.push(e);
6817
6839
  }
6818
6840
  return Object.freeze(t);
6819
- }, es = (e) => {
6820
- let t = e.base === void 0 ? Zo(e.url) : Zo(e.url, e.base), n = {
6841
+ }, ns = (e) => {
6842
+ let t = e.base === void 0 ? $o(e.url) : $o(e.url, e.base), n = {
6821
6843
  raw: e.url,
6822
6844
  href: t.href,
6823
6845
  dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
@@ -6826,29 +6848,29 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6826
6848
  resolved: t.resolved,
6827
6849
  relativeToBase: t.relativeToBase,
6828
6850
  method: (e.method ?? "GET").toUpperCase(),
6829
- headers: $o(e.headers),
6851
+ headers: ts(e.headers),
6830
6852
  bodyKind: e.bodyKind,
6831
6853
  ..."body" in e ? { body: e.body } : {}
6832
6854
  };
6833
6855
  return Object.freeze(n);
6834
- }, ts = (e, t) => {
6856
+ }, rs = (e, t) => {
6835
6857
  if (!t || t.from === t.to) return e;
6836
6858
  let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
6837
6859
  return n ? Object.freeze(r) : e;
6838
- }, ns = (e) => {
6860
+ }, is = (e) => {
6839
6861
  let t = {};
6840
6862
  for (let [n, r] of e) t[n] = r;
6841
6863
  return t;
6842
- }, rs = /* @__PURE__ */ new Set([
6864
+ }, as = /* @__PURE__ */ new Set([
6843
6865
  "GET",
6844
6866
  "HEAD",
6845
6867
  "OPTIONS"
6846
- ]), is = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, as = (e) => typeof e == "string" ? e : is(e) ? e.url : String(e), os = (e, t) => (t?.method ?? (is(e) ? e.method : void 0) ?? "GET").toUpperCase(), ss = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", cs = (e) => {
6868
+ ]), os = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, ss = (e) => typeof e == "string" ? e : os(e) ? e.url : String(e), cs = (e, t) => (t?.method ?? (os(e) ? e.method : void 0) ?? "GET").toUpperCase(), ls = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", us = (e) => {
6847
6869
  if (typeof e == "string") return e.length;
6848
6870
  let t = e;
6849
6871
  if (typeof t?.size == "number") return t.size;
6850
6872
  if (typeof t?.byteLength == "number") return t.byteLength;
6851
- }, ls = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? rs.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), us = (e, t, n, r, i) => ({
6873
+ }, ds = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? as.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), fs = (e, t, n, r, i) => ({
6852
6874
  replayable: !1,
6853
6875
  bodyKind: e,
6854
6876
  reason: t,
@@ -6856,11 +6878,11 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6856
6878
  forwardInit: i,
6857
6879
  snapshot: r,
6858
6880
  replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
6859
- }), ds = (e, t) => ns(ts(e.headers, t?.authorizationSwap)), fs = (e) => {
6881
+ }), ps = (e, t) => is(rs(e.headers, t?.authorizationSwap)), ms = (e) => {
6860
6882
  if (!e || !("headers" in e)) return e;
6861
6883
  let { headers: t, ...n } = e;
6862
6884
  return n;
6863
- }, ps = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : is(e) ? e.headers : void 0, ms = (e) => {
6885
+ }, hs = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : os(e) ? e.headers : void 0, gs = (e) => {
6864
6886
  if (e === null || typeof e == "string") return e;
6865
6887
  if (typeof FormData < "u" && e instanceof FormData) {
6866
6888
  let t = new FormData();
@@ -6868,18 +6890,18 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6868
6890
  return t;
6869
6891
  }
6870
6892
  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;
6871
- }, hs = (e, t, n) => new Request(e, { headers: ds(t, n) }), gs = (e, t, n) => {
6872
- let r = as(e), i = os(e, t), a = ps(e, t), o = (e, t) => es({
6893
+ }, _s = (e, t, n) => new Request(e, { headers: ps(t, n) }), vs = (e, t, n) => {
6894
+ let r = ss(e), i = cs(e, t), a = hs(e, t), o = (e, t) => ns({
6873
6895
  url: r,
6874
6896
  method: i,
6875
6897
  headers: a,
6876
6898
  bodyKind: e,
6877
6899
  ...t === void 0 ? {} : { body: t }
6878
6900
  });
6879
- if (is(e)) {
6901
+ if (os(e)) {
6880
6902
  if (e.body === null || e.body === void 0) {
6881
6903
  let a = o("none");
6882
- return ls(n, {
6904
+ return ds(n, {
6883
6905
  url: r,
6884
6906
  method: i,
6885
6907
  bodyKind: "none"
@@ -6889,20 +6911,20 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6889
6911
  forwardInput: e,
6890
6912
  forwardInit: t,
6891
6913
  snapshot: a,
6892
- replay: (n, r) => n(hs(e, a, r), fs(t))
6893
- } : us("none", "the replay policy refused this request", e, a, t);
6914
+ replay: (n, r) => n(_s(e, a, r), ms(t))
6915
+ } : fs("none", "the replay policy refused this request", e, a, t);
6894
6916
  }
6895
6917
  let a = o("request-clone");
6896
- if (!ls(n, {
6918
+ if (!ds(n, {
6897
6919
  url: r,
6898
6920
  method: i,
6899
6921
  bodyKind: "request-clone"
6900
- })) return us("request-clone", "the replay policy refused this request", e, a, t);
6922
+ })) return fs("request-clone", "the replay policy refused this request", e, a, t);
6901
6923
  let s;
6902
6924
  try {
6903
6925
  s = e.clone();
6904
6926
  } catch {
6905
- return us("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
6927
+ return fs("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
6906
6928
  }
6907
6929
  return {
6908
6930
  replayable: !0,
@@ -6910,17 +6932,17 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6910
6932
  forwardInput: e,
6911
6933
  forwardInit: t,
6912
6934
  snapshot: a,
6913
- replay: (e, n) => e(hs(s, a, n), fs(t))
6935
+ replay: (e, n) => e(_s(s, a, n), ms(t))
6914
6936
  };
6915
6937
  }
6916
- let s = ss(t?.body);
6917
- if (s === "one-shot") return us("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
6918
- if (!ls(n, {
6938
+ let s = ls(t?.body);
6939
+ if (s === "one-shot") return fs("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
6940
+ if (!ds(n, {
6919
6941
  url: r,
6920
6942
  method: i,
6921
6943
  bodyKind: s
6922
- }, cs(t?.body))) return us(s, "the replay policy refused this request", e, o(s), t);
6923
- let c = t && "body" in t ? ms(t.body ?? null) : void 0, l = o(s, c);
6944
+ }, us(t?.body))) return fs(s, "the replay policy refused this request", e, o(s), t);
6945
+ let c = t && "body" in t ? gs(t.body ?? null) : void 0, l = o(s, c);
6924
6946
  return {
6925
6947
  replayable: !0,
6926
6948
  bodyKind: s,
@@ -6928,21 +6950,21 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6928
6950
  forwardInit: t,
6929
6951
  snapshot: l,
6930
6952
  replay: (e, n) => e(l.dispatchUrl, {
6931
- ...fs(t),
6953
+ ...ms(t),
6932
6954
  ...c === void 0 ? {} : { body: c },
6933
- headers: ds(l, n),
6955
+ headers: ps(l, n),
6934
6956
  method: l.method
6935
6957
  })
6936
6958
  };
6937
- }, _s = (e) => typeof e == "object" && !!e, vs = (e) => (t) => {
6938
- if (!_s(e)) return;
6959
+ }, ys = (e) => typeof e == "object" && !!e, bs = (e) => (t) => {
6960
+ if (!ys(e)) return;
6939
6961
  let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
6940
6962
  return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
6941
- }, ys = (e) => {
6963
+ }, xs = (e) => {
6942
6964
  let t = e?.url ?? "", n = e?.baseURL;
6943
6965
  return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
6944
- }, bs = (e) => (e?.method ?? "GET").toUpperCase(), xs = (e) => e == null ? "none" : _s(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", Ss = (e, t, n) => {
6945
- let r = ns(ts(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
6966
+ }, Ss = (e) => (e?.method ?? "GET").toUpperCase(), Cs = (e) => e == null ? "none" : ys(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", ws = (e, t, n) => {
6967
+ let r = is(rs(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
6946
6968
  return {
6947
6969
  ...e,
6948
6970
  ...i ? { baseURL: void 0 } : {},
@@ -6951,10 +6973,10 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6951
6973
  headers: r,
6952
6974
  ..."body" in t ? { data: t.body } : {}
6953
6975
  };
6954
- }, Cs = (e, t, n, r, i, a) => {
6955
- let o = t ?? e?.config, s = xs(o?.data), c = a ?? es({
6956
- url: ys(o),
6957
- method: bs(o),
6976
+ }, Ts = (e, t, n, r, i, a) => {
6977
+ let o = t ?? e?.config, s = Cs(o?.data), c = a ?? ns({
6978
+ url: xs(o),
6979
+ method: Ss(o),
6958
6980
  headers: o?.headers,
6959
6981
  bodyKind: s,
6960
6982
  body: o?.data
@@ -6962,22 +6984,22 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6962
6984
  url: c.href,
6963
6985
  method: c.method,
6964
6986
  bodyKind: s
6965
- }, u = s !== "one-shot" && ls(i.replay, l);
6987
+ }, u = s !== "one-shot" && ds(i.replay, l);
6966
6988
  return {
6967
6989
  status: e?.status ?? 0,
6968
- getHeader: vs(e?.headers),
6990
+ getHeader: bs(e?.headers),
6969
6991
  readBody: async () => e?.data,
6970
6992
  request: c,
6971
6993
  replay: async (e) => {
6972
- let t = Re(Ss(o ?? {}, c, e));
6994
+ let t = Re(ws(o ?? {}, c, e));
6973
6995
  try {
6974
6996
  let e = await r(t);
6975
- return Cs(e, e?.config ?? t, e, r, i, c);
6997
+ return Ts(e, e?.config ?? t, e, r, i, c);
6976
6998
  } catch (e) {
6977
- let n = _s(e) ? e : {};
6999
+ let n = ys(e) ? e : {};
6978
7000
  if (!n.response || typeof n.response.status != "number" || Ji(e)) throw e;
6979
7001
  return {
6980
- ...Cs(n.response, n.config ?? t, e, r, i, c),
7002
+ ...Ts(n.response, n.config ?? t, e, r, i, c),
6981
7003
  rejected: !0
6982
7004
  };
6983
7005
  }
@@ -6991,30 +7013,30 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
6991
7013
  replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
6992
7014
  signal: o?.signal
6993
7015
  };
6994
- }, ws = (e, t) => async (n) => {
6995
- let r = fo(e), i = _s(n) ? n : {}, a = jo(await Oo(Cs(i.response, i.config, i.response, t, r), r), n);
7016
+ }, Es = (e, t) => async (n) => {
7017
+ let r = mo(e), i = ys(n) ? n : {}, a = No(await Ao(Ts(i.response, i.config, i.response, t, r), r), n);
6996
7018
  if (a.settle === "reject") throw a.error;
6997
7019
  return a.value;
6998
- }, Ts = (e, t, n) => {
6999
- 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, ws(t, i)), o = !1;
7020
+ }, Ds = (e, t, n) => {
7021
+ 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, Es(t, i)), o = !1;
7000
7022
  return () => {
7001
7023
  o || (o = !0, e.interceptors.response.eject(a));
7002
7024
  };
7003
- }, Es = (t, n) => {
7025
+ }, Os = (t, n) => {
7004
7026
  let r = e.create(t);
7005
7027
  return n(r), r;
7006
- }, Ds = () => {
7028
+ }, ks = () => {
7007
7029
  let e = typeof location > "u" ? void 0 : location.origin;
7008
7030
  return e && e !== "null" ? e : void 0;
7009
- }, Os = (e) => {
7031
+ }, As = (e) => {
7010
7032
  let t = new URL(e).origin;
7011
7033
  if (t === "null") throw Error(`Passflow: "${e}" has no origin a request can be matched against; list http(s) origins only.`);
7012
7034
  return t;
7013
- }, ks = (e, t) => {
7014
- let n = (t?.origins ?? []).map(Os);
7035
+ }, js = (e, t) => {
7036
+ let n = (t?.origins ?? []).map(As);
7015
7037
  return (t, r) => {
7016
7038
  if (r) return Promise.resolve(void 0);
7017
- let i = Ds(), a;
7039
+ let i = ks(), a;
7018
7040
  try {
7019
7041
  a = new URL(t, i).origin;
7020
7042
  } catch {
@@ -7022,22 +7044,22 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7022
7044
  }
7023
7045
  return a !== i && !n.includes(a) ? Promise.resolve(void 0) : e();
7024
7046
  };
7025
- }, As = (e) => typeof Request < "u" && e instanceof Request, js = (e, t) => new Headers(t?.headers === void 0 ? As(e) ? e.headers : void 0 : t.headers), Ms = (e, t, n) => {
7026
- let r = ks(t, n);
7047
+ }, Ms = (e) => typeof Request < "u" && e instanceof Request, Ns = (e, t) => new Headers(t?.headers === void 0 ? Ms(e) ? e.headers : void 0 : t.headers), Ps = (e, t, n) => {
7048
+ let r = js(t, n);
7027
7049
  return async (t, n) => {
7028
- let i = As(t) ? t.url : t instanceof URL ? t.href : String(t), a = js(t, n), o = await r(i, a.has("authorization"));
7050
+ let i = Ms(t) ? t.url : t instanceof URL ? t.href : String(t), a = Ns(t, n), o = await r(i, a.has("authorization"));
7029
7051
  return o ? (a.set("authorization", `Bearer ${o}`), e(t, {
7030
7052
  ...n,
7031
7053
  headers: a
7032
7054
  })) : e(t, n);
7033
7055
  };
7034
- }, Ns = (e) => {
7056
+ }, Fs = (e) => {
7035
7057
  let t = e.url ?? "", n = /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
7036
7058
  return !e.baseURL || n && e.allowAbsoluteUrls !== !1 ? t : t ? `${e.baseURL.replace(/\/?\/$/, "")}/${t.replace(/^\/+/, "")}` : e.baseURL;
7037
- }, Ps = (e) => e ? typeof e.has == "function" ? e.has("Authorization") : Object.keys(e).some((t) => t.toLowerCase() === "authorization" && e[t] != null) : !1, Fs = (e, t) => {
7038
- let n = ks(e, t);
7059
+ }, Is = (e) => e ? typeof e.has == "function" ? e.has("Authorization") : Object.keys(e).some((t) => t.toLowerCase() === "authorization" && e[t] != null) : !1, Ls = (e, t) => {
7060
+ let n = js(e, t);
7039
7061
  return async (e) => {
7040
- let t = e.headers, r = await n(Ns(e), Ps(t));
7062
+ let t = e.headers, r = await n(Fs(e), Is(t));
7041
7063
  if (!r) return e;
7042
7064
  let i = `Bearer ${r}`;
7043
7065
  return t && typeof t.set == "function" ? t.set("Authorization", i) : e.headers = {
@@ -7045,7 +7067,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7045
7067
  Authorization: i
7046
7068
  }, e;
7047
7069
  };
7048
- }, Is = 0, Ls = (e, t) => {
7070
+ }, Rs = 0, zs = (e, t) => {
7049
7071
  let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
7050
7072
  if (n) return {
7051
7073
  get aborted() {
@@ -7059,34 +7081,34 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7059
7081
  removeEventListener: (e, t) => n.removeEventListener(e, t)
7060
7082
  } : {}
7061
7083
  };
7062
- }, Rs = (e) => (t) => e.headers?.get(t), zs = (e, t, n, r, i) => ({
7084
+ }, Bs = (e) => (t) => e.headers?.get(t), Vs = (e, t, n, r, i) => ({
7063
7085
  status: e.status,
7064
- getHeader: Rs(e),
7086
+ getHeader: Bs(e),
7065
7087
  readBody: () => e.clone().json(),
7066
7088
  request: t.snapshot,
7067
- replay: async (e) => zs(await t.replay(n, e), t, n, r, i),
7089
+ replay: async (e) => Vs(await t.replay(n, e), t, n, r, i),
7068
7090
  markers: r,
7069
7091
  raw: e,
7070
7092
  replayable: t.replayable,
7071
7093
  replayUnsupportedReason: t.reason,
7072
7094
  signal: i,
7073
7095
  responseType: e.type
7074
- }), Bs = (e, t) => {
7096
+ }), Hs = (e, t) => {
7075
7097
  let n = (t, n) => {
7076
- Is += 1;
7098
+ Rs += 1;
7077
7099
  try {
7078
7100
  return e(t, n);
7079
7101
  } finally {
7080
- --Is;
7102
+ --Rs;
7081
7103
  }
7082
7104
  };
7083
7105
  return async (e, r) => {
7084
- if (Is > 0) return n(e, r);
7085
- let i = fo(t), a = gs(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = Ao(await Oo(zs(o, a, n, {}, Ls(e, r)), i), o, i);
7106
+ if (Rs > 0) return n(e, r);
7107
+ let i = mo(t), a = vs(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = Mo(await Ao(Vs(o, a, n, {}, zs(e, r)), i), o, i);
7086
7108
  if (s.settle === "reject") throw s.error;
7087
7109
  return s.value;
7088
7110
  };
7089
- }, Vs = new Set(Ua.filter((e) => !e.requiresPrepare).map((e) => e.type)), Hs = (e) => {
7111
+ }, Us = new Set(Ga.filter((e) => !e.requiresPrepare).map((e) => e.type)), Ws = (e) => {
7090
7112
  if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
7091
7113
  kind: "protocol",
7092
7114
  message: "The upgrade start response is missing challenge_id or expires_at"
@@ -7098,16 +7120,16 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7098
7120
  webauthn: e.webauthn,
7099
7121
  codeSentTo: e.code_sent_to
7100
7122
  };
7101
- }, Us = (e) => Ji(e) && !Yi(e), Ws = (e) => ({
7123
+ }, Gs = (e) => Ji(e) && !Yi(e), Ks = (e) => ({
7102
7124
  async prepare(t) {
7103
- if (!Vs.has(t)) try {
7125
+ if (!Us.has(t)) try {
7104
7126
  let n = e.relyingPartyId?.();
7105
- return Hs(await e.startUpgrade(n ? {
7127
+ return Ws(await e.startUpgrade(n ? {
7106
7128
  method: t,
7107
7129
  relying_party_id: n
7108
7130
  } : { method: t }));
7109
7131
  } catch (e) {
7110
- if (Us(e)) throw e;
7132
+ if (Gs(e)) throw e;
7111
7133
  let t = ta(e, "start");
7112
7134
  if (t.kind === "prepare_not_required") return;
7113
7135
  throw t;
@@ -7125,17 +7147,17 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7125
7147
  assertion: n
7126
7148
  });
7127
7149
  } catch (t) {
7128
- if (Us(t)) throw t;
7150
+ if (Gs(t)) throw t;
7129
7151
  let n = ta(t, "refresh");
7130
7152
  throw n.status === 401 && ra(n) && e.markSessionInvalid?.(), n;
7131
7153
  }
7132
7154
  }
7133
- }), Gs = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Ks = (e) => {
7155
+ }), qs = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Js = (e) => {
7134
7156
  let t, n = (e) => e !== void 0 && t === e, r = (r) => {
7135
7157
  let i = () => {
7136
7158
  if (!n(r())) throw new $({ kind: "session_changed" });
7137
7159
  };
7138
- return Ws({
7160
+ return Ks({
7139
7161
  ...e,
7140
7162
  relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
7141
7163
  startUpgrade: (t) => (i(), e.startUpgrade(t)),
@@ -7146,7 +7168,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7146
7168
  });
7147
7169
  }, i = (t, n) => {
7148
7170
  let i = {}, a = {
7149
- controller: new uo({
7171
+ controller: new po({
7150
7172
  transport: r(() => i.current),
7151
7173
  prompt: t.prompt,
7152
7174
  platform: e.platform,
@@ -7158,7 +7180,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7158
7180
  options: t,
7159
7181
  scope: {
7160
7182
  passflow: e.passflowDomain,
7161
- backend: Gs(t.backend)
7183
+ backend: qs(t.backend)
7162
7184
  },
7163
7185
  generation: n
7164
7186
  };
@@ -7168,14 +7190,14 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7168
7190
  s = void 0;
7169
7191
  });
7170
7192
  let c = (e) => {
7171
- if (!s || lo(s.challenge, e)) return;
7193
+ if (!s || fo(s.challenge, e)) return;
7172
7194
  let t = Math.min(o, e.maxAge === void 0 ? o : e.maxAge * 1e3);
7173
7195
  if (!(Date.now() - s.at > t)) return s.challenge;
7174
7196
  }, l = async (r, i) => {
7175
7197
  let o = t;
7176
7198
  if (!o) throw new aa("Step-up verification is not enabled on this Passflow instance");
7177
7199
  let l = e.stopRepeatedElevation ? c(r) : void 0;
7178
- if (l) throw new ia(oo(l), oo(r), "This requirement was already proved and the server still refused it: sign the user in again");
7200
+ if (l) throw new ia(co(l), co(r), "This requirement was already proved and the server still refused it: sign the user in again");
7179
7201
  o.controller.active || (o.pin = e.readSessionPin?.());
7180
7202
  let u = await o.controller.elevate(r, i);
7181
7203
  if (!n(o)) throw new oa();
@@ -7225,9 +7247,9 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7225
7247
  let r = [];
7226
7248
  if (e.attachInternalSeam) {
7227
7249
  let t = e.attachInternalSeam;
7228
- t((e) => ws(u, e)), r.push(() => t(void 0));
7250
+ t((e) => Es(u, e)), r.push(() => t(void 0));
7229
7251
  }
7230
- n.interceptFetch && r.push(On((e, t, n) => Bs(e, u)(t, n), {
7252
+ n.interceptFetch && r.push(Dn((e, t, n) => Hs(e, u)(t, n), {
7231
7253
  priority: 20,
7232
7254
  name: "passflow-upgrade"
7233
7255
  })), e.onSessionChange && r.push(e.onSessionChange(() => {
@@ -7259,8 +7281,8 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7259
7281
  enumerable: !0,
7260
7282
  value: (t, n) => {
7261
7283
  let r = (t) => {
7262
- let r = Bs(t, u);
7263
- return e.readAccessToken ? Ms(r, e.readAccessToken, n) : r;
7284
+ let r = Hs(t, u);
7285
+ return e.readAccessToken ? Ps(r, e.readAccessToken, n) : r;
7264
7286
  };
7265
7287
  if (t) return r(t);
7266
7288
  let i = typeof globalThis > "u" ? void 0 : globalThis;
@@ -7271,14 +7293,14 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7271
7293
  attachAuth: {
7272
7294
  enumerable: !0,
7273
7295
  value: (t, n) => {
7274
- let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(Fs(e.readAccessToken, n)), a = Ts(t, u);
7296
+ let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(Ls(e.readAccessToken, n)), a = Ds(t, u);
7275
7297
  return () => {
7276
7298
  a(), r && i !== void 0 && r.eject(i);
7277
7299
  };
7278
7300
  }
7279
7301
  }
7280
7302
  });
7281
- }, qs, Js = class {
7303
+ }, Ys, Xs = class {
7282
7304
  get origin() {
7283
7305
  return this.platform.getCurrentUrl()?.origin ?? "";
7284
7306
  }
@@ -7291,9 +7313,9 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7291
7313
  prefix: e.keyStoragePrefix ?? "",
7292
7314
  storage: this.platform.storage,
7293
7315
  appId: n
7294
- }), this.deviceService = new fe(this.storageManager), this.authApi = new nn(e, this.storageManager, this.deviceService), this.appApi = new Yt(e, this.storageManager, this.deviceService), this.userApi = new mn(e, this.storageManager, this.deviceService), this.settingApi = new on(e, this.storageManager, this.deviceService), this.tenantApi = new sn(e, this.storageManager, this.deviceService), this.invitationApi = new an(e, this.storageManager, this.deviceService), this.twoFactorApi = new fn(e, this.storageManager, this.deviceService), this.upgradeApi = new pn(e, this.storageManager, this.deviceService), this.upgradeDomain = He(e.url), this.subscribeStore = new lr(), this.tokenCacheService = new Fa(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? v, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
7295
- let i = ri(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
7296
- this.authService = new ja(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
7316
+ }), this.deviceService = new fe(this.storageManager), this.authApi = new tn(e, this.storageManager, this.deviceService), this.appApi = new Yt(e, this.storageManager, this.deviceService), this.userApi = new pn(e, this.storageManager, this.deviceService), this.settingApi = new an(e, this.storageManager, this.deviceService), this.tenantApi = new on(e, this.storageManager, this.deviceService), this.invitationApi = new rn(e, this.storageManager, this.deviceService), this.twoFactorApi = new dn(e, this.storageManager, this.deviceService), this.upgradeApi = new fn(e, this.storageManager, this.deviceService), this.upgradeDomain = He(e.url), this.subscribeStore = new cr(), this.tokenCacheService = new La(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? v, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
7317
+ let i = ni(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
7318
+ this.authService = new Na(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
7297
7319
  createSession: async (e) => {
7298
7320
  await this.createSessionCallback?.(e);
7299
7321
  },
@@ -7303,7 +7325,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7303
7325
  }, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
7304
7326
  coordination: i,
7305
7327
  ...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
7306
- }, () => this.readAppSettings()), this.antiBot = Tr({
7328
+ }, () => this.readAppSettings()), this.antiBot = wr({
7307
7329
  readSettings: () => this.readAppSettings(),
7308
7330
  fetchChallenge: ({ identifier: e, device: t }) => t ? this.authApi.deviceAntiBotChallenge({
7309
7331
  user_code: t.userCode,
@@ -7313,7 +7335,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7313
7335
  ...e.antiBotWorkerUrl ? { workerUrl: e.antiBotWorkerUrl } : {}
7314
7336
  }), this.authApi.setAntiBotHandler((e) => this.antiBot.headerFor(e)), this.tokenCacheService.attachRefreshController(this.authService.refresh);
7315
7337
  for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
7316
- this.userService = new La(this.userApi, this.deviceService, this.platform), this.tenantService = new Pa(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new Ma(this.invitationApi), this.twoFactorService = new Ia(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Ks({
7338
+ this.userService = new za(this.userApi, this.deviceService, this.platform), this.tenantService = new Ia(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new Pa(this.invitationApi), this.twoFactorService = new Ra(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Js({
7317
7339
  startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
7318
7340
  commitRefresh: async (e, t) => {
7319
7341
  await this.authService.refreshToken(e, t);
@@ -7342,7 +7364,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7342
7364
  let e = (await this.getTokens(!0))?.access_token;
7343
7365
  return e && !A(j(e)) ? e : void 0;
7344
7366
  }
7345
- }), this.hostedUpgrade = Ks({
7367
+ }), this.hostedUpgrade = Js({
7346
7368
  startUpgrade: (e) => this.upgradeApi.startHostedUpgrade(e),
7347
7369
  commitRefresh: (e) => this.upgradeApi.commitHostedUpgrade(e),
7348
7370
  canCommit: () => ({ ok: !0 }),
@@ -7379,7 +7401,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7379
7401
  return this.upgrade.attachAuth(e, t);
7380
7402
  }
7381
7403
  createClient(e, t) {
7382
- return Es(e, (e) => this.upgrade.attachAuth(e, t));
7404
+ return Os(e, (e) => this.upgrade.attachAuth(e, t));
7383
7405
  }
7384
7406
  readAssuranceBar() {
7385
7407
  let e = this.storageManager.getToken(M.access_token);
@@ -7419,7 +7441,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7419
7441
  }
7420
7442
  subscribeToSessionChange(e) {
7421
7443
  let t = { onAuthChange: () => e() };
7422
- return this.subscribeStore.subscribe(t, [W.SignIn, W.SignOut]), () => this.subscribeStore.unsubscribe(t);
7444
+ return this.subscribeStore.subscribe(t, [G.SignIn, G.SignOut]), () => this.subscribeStore.unsubscribe(t);
7423
7445
  }
7424
7446
  async submitSessionCheck() {
7425
7447
  let e, t;
@@ -7431,7 +7453,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7431
7453
  message: t instanceof Error || t instanceof z ? t.message : "Session check failed",
7432
7454
  originalError: t
7433
7455
  };
7434
- U(this.subscribeStore, n), e = void 0;
7456
+ W(this.subscribeStore, n), e = void 0;
7435
7457
  }
7436
7458
  e && this.createSessionCallback && await this.createSessionCallback({
7437
7459
  tokens: e,
@@ -7463,7 +7485,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7463
7485
  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;
7464
7486
  if (n) {
7465
7487
  if (!la(n)) {
7466
- U(this.subscribeStore, {
7488
+ W(this.subscribeStore, {
7467
7489
  operation: "tokens.from-url",
7468
7490
  message: "Invalid access token format received",
7469
7491
  code: "INVALID_TOKEN_FORMAT"
@@ -7471,7 +7493,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7471
7493
  return;
7472
7494
  }
7473
7495
  if (r && !la(r)) {
7474
- U(this.subscribeStore, {
7496
+ W(this.subscribeStore, {
7475
7497
  operation: "tokens.from-url",
7476
7498
  message: "Invalid refresh token format received",
7477
7499
  code: "INVALID_TOKEN_FORMAT"
@@ -7479,7 +7501,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7479
7501
  return;
7480
7502
  }
7481
7503
  if (i && !la(i)) {
7482
- U(this.subscribeStore, {
7504
+ W(this.subscribeStore, {
7483
7505
  operation: "tokens.from-url",
7484
7506
  message: "Invalid ID token format received",
7485
7507
  code: "INVALID_TOKEN_FORMAT"
@@ -7493,19 +7515,19 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7493
7515
  scopes: o
7494
7516
  };
7495
7517
  this.cleanupUrlParams(e), this.error = void 0, this.readAppSettings().catch(() => void 0).then((e) => {
7496
- if (e?.pkce_enabled !== !1) throw Yn();
7518
+ if (e?.pkce_enabled !== !1) throw Jn();
7497
7519
  return Vi(this.url, this.appId, t);
7498
7520
  }).then(() => {
7499
7521
  this.storageManager.clearDeliveryMode(), this.storageManager.saveTokens(t, void 0, { replace: !0 }), e && this.storageManager.setHostedSignIn(e.origin + e.pathname), this.tokenCacheService.setTokensCache(t), this.authService.refresh.sessionStarted();
7500
- }).then(() => (this.subscribeStore.notify(W.SignIn, {
7522
+ }).then(() => (this.subscribeStore.notify(G.SignIn, {
7501
7523
  tokens: t,
7502
7524
  parsedTokens: this.getParsedTokens(),
7503
7525
  source: "tokens-in-url",
7504
7526
  ...a ? { state: a } : {}
7505
- }), this.submitSessionCheck()), (e) => U(this.subscribeStore, {
7527
+ }), this.submitSessionCheck()), (e) => W(this.subscribeStore, {
7506
7528
  operation: "tokens.from-url",
7507
7529
  message: e instanceof Error ? e.message : "Tokens in the URL could not be verified",
7508
- code: e instanceof H ? e.code : "TOKEN_NOT_VERIFIED",
7530
+ code: e instanceof U ? e.code : "TOKEN_NOT_VERIFIED",
7509
7531
  originalError: e
7510
7532
  }));
7511
7533
  } else this.cleanupUrlParams(e), !this.deferFederatedLanding && !this.takeFederatedLanding() && this.takeOidcLanding(), this.error = this.checkErrorsFromURL();
@@ -7531,11 +7553,11 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7531
7553
  let r = t.toString(), i = new URLSearchParams(e.search);
7532
7554
  i.delete("user_state");
7533
7555
  let a = i.toString();
7534
- return this.platform.replaceUrl(e.pathname + (a ? `?${a}` : "") + (r ? `#${r}` : "")), la(n) ? (this.subscribeStore.notify(W.TwoFactorRequired, {
7556
+ return this.platform.replaceUrl(e.pathname + (a ? `?${a}` : "") + (r ? `#${r}` : "")), la(n) ? (this.subscribeStore.notify(G.TwoFactorRequired, {
7535
7557
  email: "",
7536
7558
  challengeId: "",
7537
7559
  tfaToken: n
7538
- }), !0) : (U(this.subscribeStore, {
7560
+ }), !0) : (W(this.subscribeStore, {
7539
7561
  operation: "tokens.from-url",
7540
7562
  message: "Invalid 2FA token format received",
7541
7563
  code: "INVALID_TOKEN_FORMAT"
@@ -7656,16 +7678,17 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7656
7678
  originalError: e,
7657
7679
  code: e instanceof z ? e.id : void 0
7658
7680
  };
7659
- throw U(this.subscribeStore, r), e;
7681
+ throw W(this.subscribeStore, r), e;
7660
7682
  }
7661
7683
  async logOut(e = {}) {
7662
7684
  try {
7663
- let t = this.authService.hostedEndSessionUrl(e.postLogoutRedirectUri), n = await this.authService.logOut();
7685
+ let t = this.authService.hostedEndSessionUrl(e.postLogoutRedirectUri), { userId: n, samlLogoutUrl: r } = await this.authService.logOut(), i = t ?? (e.followSamlLogout ? r : void 0);
7664
7686
  try {
7665
7687
  this.twoFactorService.clearPartialAuthState(), this.notifySignedOut(n), await this.submitSessionCheck();
7666
7688
  } finally {
7667
- t && this.platform.navigateTo(t);
7689
+ i && this.platform.navigateTo(i);
7668
7690
  }
7691
+ return r ? { samlLogoutUrl: r } : {};
7669
7692
  } catch (e) {
7670
7693
  this.handleError(e, "log-out", "Log out");
7671
7694
  }
@@ -7701,11 +7724,11 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7701
7724
  message: e,
7702
7725
  code: "RESET_ERROR"
7703
7726
  };
7704
- throw U(this.subscribeStore, t), this.error;
7727
+ throw W(this.subscribeStore, t), this.error;
7705
7728
  }
7706
7729
  }
7707
7730
  notifySignedOut(e) {
7708
- this.subscribeStore.notify(W.SignOut, e === void 0 ? { origin: "this-tab" } : {
7731
+ this.subscribeStore.notify(G.SignOut, e === void 0 ? { origin: "this-tab" } : {
7709
7732
  origin: "this-tab",
7710
7733
  userId: e
7711
7734
  });
@@ -7758,7 +7781,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7758
7781
  }
7759
7782
  setTokens(e) {
7760
7783
  let t = this.getDeliveryMode(), n = t === N.Cookie || t === N.BFF;
7761
- this.storageManager.saveTokens(e, n ? t : void 0, { replace: !0 }), this.tokenCacheService.setTokensCache(e), this.authService.refresh.sessionStarted(), this.subscribeStore.notify(W.SignIn, {
7784
+ this.storageManager.saveTokens(e, n ? t : void 0, { replace: !0 }), this.tokenCacheService.setTokensCache(e), this.authService.refresh.sessionStarted(), this.subscribeStore.notify(G.SignIn, {
7762
7785
  tokens: e,
7763
7786
  parsedTokens: this.tokenCacheService.getParsedTokens()
7764
7787
  });
@@ -7959,7 +7982,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7959
7982
  async verifyTwoFactor(e, t) {
7960
7983
  try {
7961
7984
  let n = await this.twoFactorService.verify(e, t);
7962
- return this.subscribeStore.notify(W.SignIn, {
7985
+ return this.subscribeStore.notify(G.SignIn, {
7963
7986
  tokens: n,
7964
7987
  parsedTokens: this.tokenCacheService.getParsedTokens()
7965
7988
  }), await this.submitSessionCheck(), n;
@@ -7970,7 +7993,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
7970
7993
  async useTwoFactorRecoveryCode(e, t) {
7971
7994
  try {
7972
7995
  let n = await this.twoFactorService.useRecoveryCode(e, t);
7973
- return this.subscribeStore.notify(W.SignIn, {
7996
+ return this.subscribeStore.notify(G.SignIn, {
7974
7997
  tokens: n,
7975
7998
  parsedTokens: this.tokenCacheService.getParsedTokens()
7976
7999
  }), await this.submitSessionCheck(), n;
@@ -8046,7 +8069,7 @@ var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is go
8046
8069
  this.twoFactorService.clearMagicLinkSession();
8047
8070
  }
8048
8071
  };
8049
- qs = Js, qs.version = g;
8050
- export { st as ADDRESS_CHANGE_PROOF_REQUIRED_ERROR_ID, m as AGENT_TOOL_HEADER_KEY, h as ANTI_BOT_ACTION, Je as ANTI_BOT_FAILED_ERROR_ID, p as ANTI_BOT_HEADER_KEY, Ze as ANTI_BOT_PROVIDER_FAILED_ERROR_ID, Xe as ANTI_BOT_PROVIDER_MISSING_ERROR_ID, qe as ANTI_BOT_REQUIRED_ERROR_ID, Qe as ANTI_BOT_SOLVE_FAILED_ERROR_ID, Ye as ANTI_BOT_UNAVAILABLE_ERROR_ID, l as APP_ID_HEADER_KEY, pt as APP_SECRET_NAMES, u as AUTHORIZATION_HEADER_KEY, Yt as AppAPI, nn as AuthAPI, ja as AuthService, rn as CLIAuthAPI, b as DEFAULT_GROUP_NAME, v as DEFAULT_SCOPES, Ua as DEFAULT_UPGRADE_FACTORS, d as DEVICE_ID_HEADER_KEY, f as DEVICE_TYPE_HEADER_KEY, nt as ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID, $e as ENTERPRISE_EMAIL_INVALID_ERROR_ID, tt as ENTERPRISE_NO_CONNECTION_ERROR_ID, et as ENTERPRISE_START_INPUT_ERROR_ID, te as ERROR_MESSAGE_MAX_LENGTH, hn as FETCH_PRIORITY_OIDC, gn as FETCH_PRIORITY_UPGRADE, _n as FetchMiddlewareContractError, be as INSUFFICIENT_USER_AUTHENTICATION, an as InvitationAPI, Ma as InvitationService, Ln as M2MClient, Mn as M2MConfigError, V as M2MError, Nn as M2MErrorCodes, An as M2MNetworkError, jn as M2MTokenParseError, Pn as M2M_DEFAULTS, mt as MASKED_SECRET_PREFIX, _ as MINIMAL_DEFAULT_SCOPES, _t as OS, y as PASSFLOW_CLOUD_URL, Ke as PASSWORD_CHANGE_REQUIRED_ERROR_ID, ee as POPUP_HEIGHT, S as POPUP_POLL_INTERVAL_MS, C as POPUP_TIMEOUT_MS, x as POPUP_WIDTH, Js as Passflow, dt as PassflowAddressChangeProofRequiredError, Ve as PassflowAdminEndpointPaths, R as PassflowEndpointPaths, z as PassflowError, W as PassflowEvent, H as PassflowOidcError, rt as PassflowPasswordChangeRequiredError, ut as PassflowRecoveryCodesStepUpRequiredError, J as PassflowRefreshError, lt as PassflowSendLimitError, ct as PassflowSmsQuotaExceededError, L as PopupClosedError, ft as Providers, Hi as RECOVERABLE_COMMIT_ERROR_IDS, ot as RECOVERY_CODES_STEP_UP_REQUIRED_ERROR_ID, oi as REFRESH_AUTH_FAILURE_IDS, q as RefreshErrorId, Be as RequestMethod, g as SDK_VERSION, We as SERVICE_UNAVAILABLE_ERROR_ID, Ge as SERVICE_UNAVAILABLE_MESSAGE, Ui as SESSION_INVALIDATING_COMMIT_ERROR_IDS, ht as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, ce as SessionState, on as SettingAPI, w as TOKEN_EXPIRY_BUFFER_SECONDS, at as TWO_FACTOR_SEND_LIMIT_ERROR_ID, it as TWO_FACTOR_SMS_QUOTA_EXCEEDED_ERROR_ID, sn as TenantAPI, Pa as TenantService, Na as TenantUserMembership, Fa as TokenCacheService, N as TokenDeliveryMode, M as TokenType, fn as TwoFactorApiClient, bt as TwoFactorPolicy, Ia as TwoFactorService, xe as UPGRADE_REQUIRED, E as USERNAME_MAX_LENGTH, T as USERNAME_MIN_LENGTH, pn as UpgradeAPI, Xa as UpgradeCancelledError, vi as UpgradeCommitInterruptedError, uo as UpgradeController, Q as UpgradeErrorIds, Ra as UpgradeFactorError, ia as UpgradeInsufficientError, oa as UpgradeSessionChangedError, Za as UpgradeSignInRequiredError, $ as UpgradeTransportError, aa as UpgradeUnavailableError, no as UpgradeUnsatisfiableError, mn as UserAPI, La as UserService, pe as WebAdapter, ta as classifyUpgradeError, Wa as factorRegistry, kn as fetchRegistryState, vt as getOSFromDeviceType, ra as invalidatesSessionOnCommit, Ue as isEmailVerificationStep, gt as isMaskedSecret, na as isRecoverableCommitFailure, Gi as isRetryableUpgradeKind, A as isTokenExpired, Vo as isUpgradeCancelled, Ho as isUpgradeExhausted, Uo as isUpgradeInsufficient, qo as isUpgradeSessionChanged, Go as isUpgradeSignInRequired, Yi as isUpgradeTransportError, Jo as isUpgradeTransportFailure, Ko as isUpgradeUnavailable, Wo as isUpgradeUnsatisfiable, da as isValidEmail, la as isValidJWTFormat, fa as isValidPhoneNumber, pa as isValidUsername, Oe as parseChallengeBody, De as parseChallengeHeader, j as parseToken, Me as parseUpgradeChallenge, Ha as passkeyFactor, yt as pathWithParams, Va as recoveryCodesFactor, On as registerFetchMiddleware, ye as requiredAcrLevel, He as resolveUpgradeDomain, ua as sanitizeErrorMessage, Ya as selectFactors, Ba as totpFactor, me as webAdapter };
8072
+ Ys = Xs, Ys.version = g;
8073
+ export { st as ADDRESS_CHANGE_PROOF_REQUIRED_ERROR_ID, m as AGENT_TOOL_HEADER_KEY, h as ANTI_BOT_ACTION, Je as ANTI_BOT_FAILED_ERROR_ID, p as ANTI_BOT_HEADER_KEY, Ze as ANTI_BOT_PROVIDER_FAILED_ERROR_ID, Xe as ANTI_BOT_PROVIDER_MISSING_ERROR_ID, qe as ANTI_BOT_REQUIRED_ERROR_ID, Qe as ANTI_BOT_SOLVE_FAILED_ERROR_ID, Ye as ANTI_BOT_UNAVAILABLE_ERROR_ID, l as APP_ID_HEADER_KEY, pt as APP_SECRET_NAMES, u as AUTHORIZATION_HEADER_KEY, Yt as AppAPI, tn as AuthAPI, Na as AuthService, nn as CLIAuthAPI, b as DEFAULT_GROUP_NAME, v as DEFAULT_SCOPES, Ga as DEFAULT_UPGRADE_FACTORS, d as DEVICE_ID_HEADER_KEY, f as DEVICE_TYPE_HEADER_KEY, nt as ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID, $e as ENTERPRISE_EMAIL_INVALID_ERROR_ID, tt as ENTERPRISE_NO_CONNECTION_ERROR_ID, et as ENTERPRISE_START_INPUT_ERROR_ID, te as ERROR_MESSAGE_MAX_LENGTH, mn as FETCH_PRIORITY_OIDC, hn as FETCH_PRIORITY_UPGRADE, gn as FetchMiddlewareContractError, be as INSUFFICIENT_USER_AUTHENTICATION, rn as InvitationAPI, Pa as InvitationService, In as M2MClient, jn as M2MConfigError, H as M2MError, Mn as M2MErrorCodes, kn as M2MNetworkError, An as M2MTokenParseError, Nn as M2M_DEFAULTS, mt as MASKED_SECRET_PREFIX, _ as MINIMAL_DEFAULT_SCOPES, _t as OS, y as PASSFLOW_CLOUD_URL, Ke as PASSWORD_CHANGE_REQUIRED_ERROR_ID, ee as POPUP_HEIGHT, S as POPUP_POLL_INTERVAL_MS, C as POPUP_TIMEOUT_MS, x as POPUP_WIDTH, Xs as Passflow, dt as PassflowAddressChangeProofRequiredError, Ve as PassflowAdminEndpointPaths, R as PassflowEndpointPaths, z as PassflowError, G as PassflowEvent, U as PassflowOidcError, rt as PassflowPasswordChangeRequiredError, ut as PassflowRecoveryCodesStepUpRequiredError, Y as PassflowRefreshError, lt as PassflowSendLimitError, ct as PassflowSmsQuotaExceededError, L as PopupClosedError, ft as Providers, Hi as RECOVERABLE_COMMIT_ERROR_IDS, ot as RECOVERY_CODES_STEP_UP_REQUIRED_ERROR_ID, ai as REFRESH_AUTH_FAILURE_IDS, J as RefreshErrorId, Be as RequestMethod, g as SDK_VERSION, We as SERVICE_UNAVAILABLE_ERROR_ID, Ge as SERVICE_UNAVAILABLE_MESSAGE, Ui as SESSION_INVALIDATING_COMMIT_ERROR_IDS, ht as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, ce as SessionState, an as SettingAPI, w as TOKEN_EXPIRY_BUFFER_SECONDS, at as TWO_FACTOR_SEND_LIMIT_ERROR_ID, it as TWO_FACTOR_SMS_QUOTA_EXCEEDED_ERROR_ID, on as TenantAPI, Ia as TenantService, Fa as TenantUserMembership, La as TokenCacheService, N as TokenDeliveryMode, M as TokenType, dn as TwoFactorApiClient, bt as TwoFactorPolicy, Ra as TwoFactorService, xe as UPGRADE_REQUIRED, E as USERNAME_MAX_LENGTH, T as USERNAME_MIN_LENGTH, fn as UpgradeAPI, Qa as UpgradeCancelledError, _i as UpgradeCommitInterruptedError, po as UpgradeController, Q as UpgradeErrorIds, Ba as UpgradeFactorError, ia as UpgradeInsufficientError, oa as UpgradeSessionChangedError, $a as UpgradeSignInRequiredError, $ as UpgradeTransportError, aa as UpgradeUnavailableError, io as UpgradeUnsatisfiableError, pn as UserAPI, za as UserService, pe as WebAdapter, ta as classifyUpgradeError, Ka as factorRegistry, On as fetchRegistryState, vt as getOSFromDeviceType, ra as invalidatesSessionOnCommit, Ue as isEmailVerificationStep, gt as isMaskedSecret, na as isRecoverableCommitFailure, Gi as isRetryableUpgradeKind, A as isTokenExpired, Uo as isUpgradeCancelled, Wo as isUpgradeExhausted, Go as isUpgradeInsufficient, Yo as isUpgradeSessionChanged, qo as isUpgradeSignInRequired, Yi as isUpgradeTransportError, Xo as isUpgradeTransportFailure, Jo as isUpgradeUnavailable, Ko as isUpgradeUnsatisfiable, da as isValidEmail, la as isValidJWTFormat, fa as isValidPhoneNumber, pa as isValidUsername, Oe as parseChallengeBody, De as parseChallengeHeader, j as parseToken, Me as parseUpgradeChallenge, Wa as passkeyFactor, yt as pathWithParams, Ua as recoveryCodesFactor, Dn as registerFetchMiddleware, ye as requiredAcrLevel, He as resolveUpgradeDomain, ua as sanitizeErrorMessage, Za as selectFactors, Ha as totpFactor, me as webAdapter };
8051
8074
 
8052
8075
  //# sourceMappingURL=index.mjs.map