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