@passflow/core 0.23.0 → 0.24.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/README.md +50 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -2
- package/dist/index.d.ts +210 -2
- package/dist/index.mjs +831 -546
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import e from "axios";
|
|
2
2
|
import { startAuthentication as t, startRegistration as n } from "@simplewebauthn/browser";
|
|
3
3
|
// package.json
|
|
4
|
-
var r = "0.
|
|
4
|
+
var r = "0.24.0", i = "X-Passflow-Clientid", a = "Authorization", o = "X-Passflow-DeviceId", s = "X-Passflow-DeviceType", c = r, l = [
|
|
5
5
|
"id",
|
|
6
6
|
"offline",
|
|
7
7
|
"openid"
|
|
@@ -567,7 +567,7 @@ var j = /* @__PURE__ */ function(e) {
|
|
|
567
567
|
}), Ee = (e) => Se(e, xe), De = /* @__PURE__ */ function(e) {
|
|
568
568
|
return e.GET = "get", e.POST = "post", e.PUT = "put", e.PATCH = "patch", e.DELETE = "delete", e;
|
|
569
569
|
}({}), z = /* @__PURE__ */ function(e) {
|
|
570
|
-
return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.signInWithProvider = "/auth/federated/start/", e.passwordless = "/auth/passwordless/start", e.passwordlessComplete = "/auth/passwordless/complete", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e;
|
|
570
|
+
return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.signInWithProvider = "/auth/federated/start/", e.passwordless = "/auth/passwordless/start", e.passwordlessComplete = "/auth/passwordless/complete", e.passwordlessStatus = "/auth/passwordless/status", e.passwordlessApprovalInfo = "/auth/passwordless/approval/info", e.passwordlessApprovalDecide = "/auth/passwordless/approval/decide", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e;
|
|
571
571
|
}({}), Oe = /* @__PURE__ */ function(e) {
|
|
572
572
|
return e.passkeyRegisterStart = "/admin/auth/passkey/register/start", e.passkeyRegisterComplete = "/admin/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/admin/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/admin/auth/passkey/authenticate/complete", e.passkeyValidate = "/admin/auth/validate", e.logout = "/admin/auth/logout", e;
|
|
573
573
|
}({}), ke = (e) => {
|
|
@@ -781,7 +781,17 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
781
781
|
getAppSettings() {
|
|
782
782
|
return this.axiosClient.get(z.appSettings);
|
|
783
783
|
}
|
|
784
|
-
}, qe = { withCredentials: !0 }, Je =
|
|
784
|
+
}, qe = { withCredentials: !0 }, Je = 15e3, Ye = "Sign-in failed. Start again.", Xe = "Something went wrong. Try again later.", Ze = (e, t, n, r) => {
|
|
785
|
+
if (e instanceof B) return e;
|
|
786
|
+
let i = e?.response?.data?.error;
|
|
787
|
+
return new B({
|
|
788
|
+
id: typeof i?.id == "string" ? i.id : n,
|
|
789
|
+
message: typeof i?.message == "string" ? i.message : r,
|
|
790
|
+
status: typeof i?.status == "number" ? i.status : 0,
|
|
791
|
+
location: t,
|
|
792
|
+
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
793
|
+
});
|
|
794
|
+
}, Qe = class {
|
|
785
795
|
constructor(e, t, n) {
|
|
786
796
|
this.axiosClient = new H(e, t, n);
|
|
787
797
|
}
|
|
@@ -812,23 +822,60 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
812
822
|
};
|
|
813
823
|
return this.axiosClient.post(z.signup, r, qe);
|
|
814
824
|
}
|
|
815
|
-
pkceExchange(e, t) {
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
825
|
+
async pkceExchange(e, t) {
|
|
826
|
+
try {
|
|
827
|
+
return await this.axiosClient.post(z.pkceExchange, {
|
|
828
|
+
authz_code: e,
|
|
829
|
+
verifier: t
|
|
830
|
+
}, qe);
|
|
831
|
+
} catch (e) {
|
|
832
|
+
throw Ze(e, z.pkceExchange, "error.pkce.exchange", Ye);
|
|
833
|
+
}
|
|
820
834
|
}
|
|
821
|
-
passwordlessSignIn(e, t, n) {
|
|
835
|
+
async passwordlessSignIn(e, t, n) {
|
|
822
836
|
let { create_tenant: r } = e, i = {
|
|
823
837
|
...e,
|
|
824
838
|
create_tenant: r ?? !1,
|
|
825
839
|
device: t,
|
|
826
840
|
os: n
|
|
827
841
|
};
|
|
828
|
-
|
|
842
|
+
try {
|
|
843
|
+
return await this.axiosClient.post(z.passwordless, i);
|
|
844
|
+
} catch (e) {
|
|
845
|
+
throw Ze(e, z.passwordless, "error.passwordless.start", Xe);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
async passwordlessSignInComplete(e) {
|
|
849
|
+
try {
|
|
850
|
+
return await this.axiosClient.post(z.passwordlessComplete, e, qe);
|
|
851
|
+
} catch (e) {
|
|
852
|
+
throw Ze(e, z.passwordlessComplete, "error.passwordless.complete", Xe);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
async passwordlessStatus(e, t) {
|
|
856
|
+
try {
|
|
857
|
+
return await this.axiosClient.post(z.passwordlessStatus, e, {
|
|
858
|
+
...qe,
|
|
859
|
+
timeout: Je,
|
|
860
|
+
signal: t?.signal
|
|
861
|
+
});
|
|
862
|
+
} catch (e) {
|
|
863
|
+
throw Ze(e, z.passwordlessStatus, "error.passwordless.status", Ye);
|
|
864
|
+
}
|
|
829
865
|
}
|
|
830
|
-
|
|
831
|
-
|
|
866
|
+
async passwordlessApprovalInfo(e) {
|
|
867
|
+
try {
|
|
868
|
+
return await this.axiosClient.post(z.passwordlessApprovalInfo, e);
|
|
869
|
+
} catch (e) {
|
|
870
|
+
throw Ze(e, z.passwordlessApprovalInfo, "error.passwordless.approval", Xe);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
async passwordlessApprovalDecide(e) {
|
|
874
|
+
try {
|
|
875
|
+
return await this.axiosClient.post(z.passwordlessApprovalDecide, e);
|
|
876
|
+
} catch (e) {
|
|
877
|
+
throw Ze(e, z.passwordlessApprovalDecide, "error.passwordless.approval", Xe);
|
|
878
|
+
}
|
|
832
879
|
}
|
|
833
880
|
validateEmailCode(e) {
|
|
834
881
|
return this.axiosClient.post(z.passkeyValidate, {
|
|
@@ -904,7 +951,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
904
951
|
let c = a ? { [i]: a } : {};
|
|
905
952
|
return this.axiosClient.post(s, o, { headers: c });
|
|
906
953
|
}
|
|
907
|
-
},
|
|
954
|
+
}, $e = class {
|
|
908
955
|
constructor(e, t, n) {
|
|
909
956
|
this.axiosClient = new H(e, t, n);
|
|
910
957
|
}
|
|
@@ -918,7 +965,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
918
965
|
completeCLIAuth(e) {
|
|
919
966
|
return this.axiosClient.post(z.cliAuthComplete, e);
|
|
920
967
|
}
|
|
921
|
-
},
|
|
968
|
+
}, et = class {
|
|
922
969
|
constructor(e, t, n) {
|
|
923
970
|
this.axiosClient = new H(e, t, n);
|
|
924
971
|
}
|
|
@@ -949,7 +996,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
949
996
|
let t = V(z.invitationGetLink, { invitationID: e });
|
|
950
997
|
return this.axiosClient.get(t);
|
|
951
998
|
}
|
|
952
|
-
},
|
|
999
|
+
}, tt = class {
|
|
953
1000
|
constructor(e, t, n) {
|
|
954
1001
|
this.axiosClient = new H(e, t, n);
|
|
955
1002
|
}
|
|
@@ -965,7 +1012,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
965
1012
|
getPasskeySettings() {
|
|
966
1013
|
return this.axiosClient.get(z.settingsPasskey);
|
|
967
1014
|
}
|
|
968
|
-
},
|
|
1015
|
+
}, nt = class {
|
|
969
1016
|
constructor(e, t, n) {
|
|
970
1017
|
this.axiosClient = new H(e, t, n);
|
|
971
1018
|
}
|
|
@@ -1081,10 +1128,10 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1081
1128
|
let r = `${z.tenantPath}/${e}/group/${t}/invite/email/${n}`;
|
|
1082
1129
|
return this.axiosClient.delete(r);
|
|
1083
1130
|
}
|
|
1084
|
-
},
|
|
1131
|
+
}, rt = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, it = (e) => ({
|
|
1085
1132
|
withCredentials: !0,
|
|
1086
|
-
|
|
1087
|
-
}),
|
|
1133
|
+
...rt(e)
|
|
1134
|
+
}), at = class {
|
|
1088
1135
|
constructor(e, t, n) {
|
|
1089
1136
|
this.axiosClient = new H(e, t, n);
|
|
1090
1137
|
}
|
|
@@ -1105,14 +1152,14 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1105
1152
|
return this.axiosClient.post(z.twoFactorVerify, {
|
|
1106
1153
|
code: n,
|
|
1107
1154
|
...r ? { trust_device: !0 } : {}
|
|
1108
|
-
},
|
|
1155
|
+
}, it(t));
|
|
1109
1156
|
}
|
|
1110
1157
|
useRecoveryCode(e) {
|
|
1111
1158
|
let { tfa_token: t, recovery_code: n, trust_device: r } = e;
|
|
1112
1159
|
return this.axiosClient.post(z.twoFactorRecovery, {
|
|
1113
1160
|
recovery_code: n,
|
|
1114
1161
|
...r ? { trust_device: !0 } : {}
|
|
1115
|
-
},
|
|
1162
|
+
}, it(t));
|
|
1116
1163
|
}
|
|
1117
1164
|
disable(e) {
|
|
1118
1165
|
return this.axiosClient.delete(z.twoFactor, { data: e });
|
|
@@ -1193,17 +1240,17 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1193
1240
|
return this.axiosClient.delete(t);
|
|
1194
1241
|
}
|
|
1195
1242
|
requestChallenge(e, t) {
|
|
1196
|
-
return this.axiosClient.post(z.TwoFactorChallenge, e,
|
|
1243
|
+
return this.axiosClient.post(z.TwoFactorChallenge, e, rt(t));
|
|
1197
1244
|
}
|
|
1198
1245
|
verifyV2(e, t) {
|
|
1199
1246
|
let { trust_device: n, ...r } = e;
|
|
1200
1247
|
return this.axiosClient.post(z.TwoFactorVerifyV2, {
|
|
1201
1248
|
...r,
|
|
1202
1249
|
...n ? { trust_device: !0 } : {}
|
|
1203
|
-
},
|
|
1250
|
+
}, it(t));
|
|
1204
1251
|
}
|
|
1205
1252
|
switchToAlternative(e, t) {
|
|
1206
|
-
return this.axiosClient.post(z.TwoFactorAlternative, e,
|
|
1253
|
+
return this.axiosClient.post(z.TwoFactorAlternative, e, rt(t));
|
|
1207
1254
|
}
|
|
1208
1255
|
async getTrustedDevices() {
|
|
1209
1256
|
return (await this.axiosClient.get(z.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
|
|
@@ -1212,7 +1259,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1212
1259
|
let t = V(z.TwoFactorTrustedDeviceRevoke, { id: e });
|
|
1213
1260
|
return this.axiosClient.delete(t);
|
|
1214
1261
|
}
|
|
1215
|
-
},
|
|
1262
|
+
}, ot = class {
|
|
1216
1263
|
constructor(e, t, n) {
|
|
1217
1264
|
this.axiosClient = new H(e, t, n);
|
|
1218
1265
|
}
|
|
@@ -1222,7 +1269,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1222
1269
|
startUpgrade(e) {
|
|
1223
1270
|
return this.axiosClient.post(z.upgradeStart, e, Ce({}));
|
|
1224
1271
|
}
|
|
1225
|
-
},
|
|
1272
|
+
}, st = class {
|
|
1226
1273
|
constructor(e, t, n) {
|
|
1227
1274
|
this.axiosClient = new H(e, t, n);
|
|
1228
1275
|
}
|
|
@@ -1255,48 +1302,48 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1255
1302
|
passkey_data: e
|
|
1256
1303
|
});
|
|
1257
1304
|
}
|
|
1258
|
-
},
|
|
1305
|
+
}, ct = 10, lt = 20, ut = class extends Error {
|
|
1259
1306
|
constructor(e) {
|
|
1260
1307
|
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;
|
|
1261
1308
|
}
|
|
1262
|
-
},
|
|
1309
|
+
}, dt = [], ft = 0, pt = !1, mt, ht, gt = (e, t) => e.priority - t.priority || e.seq - t.seq, _t = () => typeof globalThis > "u" ? void 0 : globalThis, vt = async (e, t, n, r) => {
|
|
1263
1310
|
if (t >= e.length) {
|
|
1264
|
-
let e =
|
|
1311
|
+
let e = mt;
|
|
1265
1312
|
if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
|
|
1266
1313
|
return e(n, r);
|
|
1267
1314
|
}
|
|
1268
1315
|
let i = e[t];
|
|
1269
|
-
if (!i) return
|
|
1270
|
-
let a = !1, o = await i.middleware((n, r) => (a = !0,
|
|
1271
|
-
if (!a) throw new
|
|
1316
|
+
if (!i) return vt(e, e.length, n, r);
|
|
1317
|
+
let a = !1, o = await i.middleware((n, r) => (a = !0, vt(e, t + 1, n, r)), n, r);
|
|
1318
|
+
if (!a) throw new ut(i.name);
|
|
1272
1319
|
return o;
|
|
1273
|
-
},
|
|
1274
|
-
let e =
|
|
1320
|
+
}, yt = () => {
|
|
1321
|
+
let e = _t();
|
|
1275
1322
|
if (!e || typeof e.fetch != "function") return !1;
|
|
1276
|
-
let t = e.fetch.bind(e), n = (e, t) =>
|
|
1277
|
-
return
|
|
1278
|
-
},
|
|
1279
|
-
let e =
|
|
1280
|
-
e &&
|
|
1281
|
-
},
|
|
1282
|
-
if (!
|
|
1323
|
+
let t = e.fetch.bind(e), n = (e, t) => vt([...dt].sort(gt), 0, e, t);
|
|
1324
|
+
return mt = t, ht = n, e.fetch = n, pt = !0, !0;
|
|
1325
|
+
}, bt = () => {
|
|
1326
|
+
let e = _t();
|
|
1327
|
+
e && ht && e.fetch === ht && (mt && (e.fetch = mt), pt = !1, ht = void 0, mt = void 0);
|
|
1328
|
+
}, xt = (e, t) => {
|
|
1329
|
+
if (!pt && !yt()) return () => {};
|
|
1283
1330
|
let n = {
|
|
1284
1331
|
middleware: e,
|
|
1285
1332
|
name: t.name,
|
|
1286
1333
|
priority: t.priority,
|
|
1287
|
-
seq:
|
|
1334
|
+
seq: ft++
|
|
1288
1335
|
};
|
|
1289
|
-
|
|
1336
|
+
dt.push(n);
|
|
1290
1337
|
let r = !1;
|
|
1291
1338
|
return () => {
|
|
1292
|
-
r || (r = !0,
|
|
1339
|
+
r || (r = !0, dt = dt.filter((e) => e !== n), dt.length === 0 && bt());
|
|
1293
1340
|
};
|
|
1294
|
-
},
|
|
1295
|
-
let e =
|
|
1341
|
+
}, St = () => {
|
|
1342
|
+
let e = _t();
|
|
1296
1343
|
return {
|
|
1297
|
-
installed:
|
|
1298
|
-
names: [...
|
|
1299
|
-
foreignPatch:
|
|
1344
|
+
installed: pt,
|
|
1345
|
+
names: [...dt].sort(gt).map((e) => e.name),
|
|
1346
|
+
foreignPatch: pt && !!e && !!ht && e.fetch !== ht
|
|
1300
1347
|
};
|
|
1301
1348
|
}, U = class e extends Error {
|
|
1302
1349
|
constructor(t) {
|
|
@@ -1367,7 +1414,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1367
1414
|
let e = `M2MError [${this.code}]: ${this.message}`;
|
|
1368
1415
|
return this.status && (e += ` (HTTP ${this.status})`), e;
|
|
1369
1416
|
}
|
|
1370
|
-
},
|
|
1417
|
+
}, Ct = class extends U {
|
|
1371
1418
|
constructor(e, t) {
|
|
1372
1419
|
super({
|
|
1373
1420
|
code: "temporarily_unavailable",
|
|
@@ -1376,7 +1423,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1376
1423
|
cause: t
|
|
1377
1424
|
}), this.name = "M2MNetworkError";
|
|
1378
1425
|
}
|
|
1379
|
-
},
|
|
1426
|
+
}, wt = class extends U {
|
|
1380
1427
|
constructor(e, t) {
|
|
1381
1428
|
super({
|
|
1382
1429
|
code: "invalid_request",
|
|
@@ -1385,7 +1432,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1385
1432
|
cause: t
|
|
1386
1433
|
}), this.name = "M2MTokenParseError";
|
|
1387
1434
|
}
|
|
1388
|
-
},
|
|
1435
|
+
}, Tt = class extends U {
|
|
1389
1436
|
constructor(e) {
|
|
1390
1437
|
super({
|
|
1391
1438
|
code: "invalid_request",
|
|
@@ -1393,7 +1440,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1393
1440
|
status: 400
|
|
1394
1441
|
}), this.name = "M2MConfigError";
|
|
1395
1442
|
}
|
|
1396
|
-
},
|
|
1443
|
+
}, Et = {
|
|
1397
1444
|
InvalidRequest: "invalid_request",
|
|
1398
1445
|
InvalidClient: "invalid_client",
|
|
1399
1446
|
InvalidGrant: "invalid_grant",
|
|
@@ -1403,14 +1450,14 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1403
1450
|
RateLimitExceeded: "rate_limit_exceeded",
|
|
1404
1451
|
ServerError: "server_error",
|
|
1405
1452
|
TemporarilyUnavailable: "temporarily_unavailable"
|
|
1406
|
-
},
|
|
1453
|
+
}, Dt = {
|
|
1407
1454
|
TOKEN_ENDPOINT: "/oauth2/token",
|
|
1408
1455
|
TIMEOUT: 1e4,
|
|
1409
1456
|
RETRIES: 3,
|
|
1410
1457
|
RETRY_DELAY: 1e3,
|
|
1411
1458
|
REFRESH_THRESHOLD: 30,
|
|
1412
1459
|
CONTENT_TYPE: "application/x-www-form-urlencoded"
|
|
1413
|
-
},
|
|
1460
|
+
}, Ot = class {
|
|
1414
1461
|
constructor() {
|
|
1415
1462
|
this.cache = /* @__PURE__ */ new Map();
|
|
1416
1463
|
}
|
|
@@ -1427,18 +1474,18 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1427
1474
|
delete(e) {
|
|
1428
1475
|
return this.cache.delete(e), Promise.resolve();
|
|
1429
1476
|
}
|
|
1430
|
-
},
|
|
1477
|
+
}, kt = {
|
|
1431
1478
|
shouldRetry(e, t) {
|
|
1432
1479
|
return t >= 3 ? !1 : e.code === "server_error" || e.code === "temporarily_unavailable" || e.code === "rate_limit_exceeded" || e.status !== void 0 && e.status >= 500;
|
|
1433
1480
|
},
|
|
1434
1481
|
getDelay(e) {
|
|
1435
1482
|
return 2 ** (e - 1) * 1e3;
|
|
1436
1483
|
}
|
|
1437
|
-
},
|
|
1484
|
+
}, At = class {
|
|
1438
1485
|
constructor(e) {
|
|
1439
|
-
if (!e.url) throw new
|
|
1440
|
-
if (!e.clientId) throw new
|
|
1441
|
-
if (!e.clientSecret) throw new
|
|
1486
|
+
if (!e.url) throw new Tt("M2M client requires a URL");
|
|
1487
|
+
if (!e.clientId) throw new Tt("M2M client requires a clientId");
|
|
1488
|
+
if (!e.clientSecret) throw new Tt("M2M client requires a clientSecret");
|
|
1442
1489
|
let t = e.url.replace(/\/$/, "");
|
|
1443
1490
|
this.config = {
|
|
1444
1491
|
url: t,
|
|
@@ -1447,16 +1494,16 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1447
1494
|
scopes: e.scopes,
|
|
1448
1495
|
audience: e.audience,
|
|
1449
1496
|
autoRefresh: e.autoRefresh ?? !1,
|
|
1450
|
-
refreshThreshold: e.refreshThreshold ??
|
|
1451
|
-
timeout: e.timeout ??
|
|
1452
|
-
retries: e.retries ??
|
|
1453
|
-
retryDelay: e.retryDelay ??
|
|
1497
|
+
refreshThreshold: e.refreshThreshold ?? Dt.REFRESH_THRESHOLD,
|
|
1498
|
+
timeout: e.timeout ?? Dt.TIMEOUT,
|
|
1499
|
+
retries: e.retries ?? Dt.RETRIES,
|
|
1500
|
+
retryDelay: e.retryDelay ?? Dt.RETRY_DELAY,
|
|
1454
1501
|
retryStrategy: e.retryStrategy,
|
|
1455
1502
|
cache: e.cache,
|
|
1456
1503
|
onTokenRequest: e.onTokenRequest,
|
|
1457
1504
|
onTokenResponse: e.onTokenResponse,
|
|
1458
1505
|
onError: e.onError
|
|
1459
|
-
}, this.cache = e.cache ?? new
|
|
1506
|
+
}, this.cache = e.cache ?? new Ot(), this.retryStrategy = e.retryStrategy ?? kt, this.tokenEndpoint = `${t}${Dt.TOKEN_ENDPOINT}`;
|
|
1460
1507
|
}
|
|
1461
1508
|
getCacheKey(e, t) {
|
|
1462
1509
|
let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
|
|
@@ -1501,7 +1548,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1501
1548
|
let e = await fetch(this.tokenEndpoint, {
|
|
1502
1549
|
method: "POST",
|
|
1503
1550
|
headers: {
|
|
1504
|
-
"Content-Type":
|
|
1551
|
+
"Content-Type": Dt.CONTENT_TYPE,
|
|
1505
1552
|
Accept: "application/json"
|
|
1506
1553
|
},
|
|
1507
1554
|
body: t.toString(),
|
|
@@ -1526,7 +1573,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1526
1573
|
}
|
|
1527
1574
|
return a;
|
|
1528
1575
|
} catch (e) {
|
|
1529
|
-
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new
|
|
1576
|
+
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new Ct(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new Ct(`Network error: ${e.message}`, e) : e instanceof U ? e : U.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1530
1577
|
}
|
|
1531
1578
|
}
|
|
1532
1579
|
async executeWithRetry(e) {
|
|
@@ -1569,13 +1616,13 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1569
1616
|
parseToken(e) {
|
|
1570
1617
|
try {
|
|
1571
1618
|
let t = e.split(".");
|
|
1572
|
-
if (t.length !== 3) throw new
|
|
1619
|
+
if (t.length !== 3) throw new wt("Invalid JWT format: expected 3 parts");
|
|
1573
1620
|
let n = t[1];
|
|
1574
|
-
if (!n) throw new
|
|
1621
|
+
if (!n) throw new wt("Invalid JWT format: missing payload");
|
|
1575
1622
|
let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
|
|
1576
1623
|
return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
|
|
1577
1624
|
} catch (e) {
|
|
1578
|
-
throw e instanceof
|
|
1625
|
+
throw e instanceof wt ? e : new wt(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
1579
1626
|
}
|
|
1580
1627
|
}
|
|
1581
1628
|
clearCache() {
|
|
@@ -1590,7 +1637,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1590
1637
|
try {
|
|
1591
1638
|
let e = await fetch(t, {
|
|
1592
1639
|
method: "POST",
|
|
1593
|
-
headers: { "Content-Type":
|
|
1640
|
+
headers: { "Content-Type": Dt.CONTENT_TYPE },
|
|
1594
1641
|
body: n.toString()
|
|
1595
1642
|
});
|
|
1596
1643
|
if (!e.ok && e.status !== 200) {
|
|
@@ -1617,101 +1664,101 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1617
1664
|
get audience() {
|
|
1618
1665
|
return this.config.audience;
|
|
1619
1666
|
}
|
|
1620
|
-
},
|
|
1667
|
+
}, jt = "error", Mt = /* @__PURE__ */ new WeakMap(), Nt = (e, t) => {
|
|
1621
1668
|
if (typeof t != "object" && typeof t != "function" || t === null) return !0;
|
|
1622
|
-
let n =
|
|
1623
|
-
return n || (n = /* @__PURE__ */ new WeakSet(),
|
|
1624
|
-
}, W = (e, t) =>
|
|
1669
|
+
let n = Mt.get(e);
|
|
1670
|
+
return n || (n = /* @__PURE__ */ new WeakSet(), Mt.set(e, n)), !n.has(t) && (n.add(t), !0);
|
|
1671
|
+
}, W = (e, t) => Nt(e, t.originalError) ? (e.notify(jt, t), !0) : !1, Pt = "passflow-refresh", Ft = "passflow-refresh-takeover", It = "passflow-auth", Lt = Object.freeze([
|
|
1625
1672
|
1e3,
|
|
1626
1673
|
3e3,
|
|
1627
1674
|
1e4,
|
|
1628
1675
|
3e4,
|
|
1629
1676
|
6e4
|
|
1630
|
-
]),
|
|
1677
|
+
]), Rt = .2, zt = 6e5, Bt = 5e3, G = 2e4, Vt = 2e4, Ht = 1e3, Ut = 2e3, Wt = 1e3, Gt = 1e4, Kt = 5e3;
|
|
1631
1678
|
// lib/refresh/protocol.ts
|
|
1632
|
-
function
|
|
1679
|
+
function qt(e) {
|
|
1633
1680
|
let t = e ? `:${e}` : "";
|
|
1634
1681
|
return {
|
|
1635
|
-
lock: `${
|
|
1636
|
-
takeoverLock: `${
|
|
1637
|
-
channel: `${
|
|
1682
|
+
lock: `${Pt}${t}`,
|
|
1683
|
+
takeoverLock: `${Ft}${t}`,
|
|
1684
|
+
channel: `${It}${t}`
|
|
1638
1685
|
};
|
|
1639
1686
|
}
|
|
1640
1687
|
function K(e) {
|
|
1641
1688
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
1642
1689
|
}
|
|
1643
|
-
function
|
|
1690
|
+
function Jt(e) {
|
|
1644
1691
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
1645
1692
|
}
|
|
1646
|
-
function
|
|
1693
|
+
function Yt(e) {
|
|
1647
1694
|
return typeof e == "object" && !!e;
|
|
1648
1695
|
}
|
|
1649
|
-
function
|
|
1696
|
+
function Xt(e, t) {
|
|
1650
1697
|
for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
|
|
1651
1698
|
return e;
|
|
1652
1699
|
}
|
|
1653
|
-
function
|
|
1654
|
-
if (!
|
|
1700
|
+
function Zt(e) {
|
|
1701
|
+
if (!Yt(e)) return null;
|
|
1655
1702
|
let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
|
|
1656
|
-
return
|
|
1703
|
+
return Xt({}, {
|
|
1657
1704
|
access_token: K(e.access_token),
|
|
1658
1705
|
refresh_token: K(e.refresh_token),
|
|
1659
1706
|
id_token: K(e.id_token),
|
|
1660
1707
|
scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
|
|
1661
1708
|
});
|
|
1662
1709
|
}
|
|
1663
|
-
function
|
|
1664
|
-
if (!
|
|
1710
|
+
function Qt(e) {
|
|
1711
|
+
if (!Yt(e)) return null;
|
|
1665
1712
|
let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
|
|
1666
|
-
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 ||
|
|
1713
|
+
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || Jt(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Xt({
|
|
1667
1714
|
kind: t,
|
|
1668
1715
|
attempt: n,
|
|
1669
1716
|
nextAt: r,
|
|
1670
1717
|
strikes: i
|
|
1671
1718
|
}, {
|
|
1672
1719
|
from: K(e.from),
|
|
1673
|
-
failingSince:
|
|
1720
|
+
failingSince: Jt(e.failingSince)
|
|
1674
1721
|
});
|
|
1675
1722
|
}
|
|
1676
|
-
function
|
|
1677
|
-
return
|
|
1723
|
+
function $t(e) {
|
|
1724
|
+
return Xt({}, {
|
|
1678
1725
|
fp: K(e.fp),
|
|
1679
1726
|
sub: K(e.sub),
|
|
1680
1727
|
sid: K(e.sid),
|
|
1681
|
-
iat:
|
|
1728
|
+
iat: Jt(e.iat)
|
|
1682
1729
|
});
|
|
1683
1730
|
}
|
|
1684
|
-
function
|
|
1685
|
-
if (!
|
|
1731
|
+
function en(e) {
|
|
1732
|
+
if (!Yt(e)) return null;
|
|
1686
1733
|
let t = e;
|
|
1687
1734
|
if (t.v !== void 0 && t.v !== 1) return null;
|
|
1688
1735
|
let n = K(t.tabId);
|
|
1689
1736
|
if (!n) return null;
|
|
1690
1737
|
switch (t.type) {
|
|
1691
1738
|
case "tokens-refreshed": {
|
|
1692
|
-
let e =
|
|
1693
|
-
return !e || !r || !i ? null :
|
|
1739
|
+
let e = Zt(t.tokens), r = K(t.from), i = K(t.to);
|
|
1740
|
+
return !e || !r || !i ? null : Xt({
|
|
1694
1741
|
type: t.type,
|
|
1695
1742
|
tabId: n,
|
|
1696
1743
|
tokens: e,
|
|
1697
1744
|
from: r,
|
|
1698
1745
|
to: i
|
|
1699
1746
|
}, {
|
|
1700
|
-
fromIat:
|
|
1747
|
+
fromIat: Jt(t.fromIat),
|
|
1701
1748
|
fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
|
|
1702
|
-
sentAt:
|
|
1749
|
+
sentAt: Jt(t.sentAt)
|
|
1703
1750
|
});
|
|
1704
1751
|
}
|
|
1705
1752
|
case "session-refreshed": {
|
|
1706
|
-
let e =
|
|
1707
|
-
return e === void 0 ? null :
|
|
1753
|
+
let e = Jt(t.at);
|
|
1754
|
+
return e === void 0 ? null : Xt({
|
|
1708
1755
|
type: t.type,
|
|
1709
1756
|
tabId: n,
|
|
1710
1757
|
at: e
|
|
1711
1758
|
}, { sub: K(t.sub) });
|
|
1712
1759
|
}
|
|
1713
1760
|
case "still-refreshing": {
|
|
1714
|
-
let e = t.retry === void 0 ? null :
|
|
1761
|
+
let e = t.retry === void 0 ? null : Qt(t.retry);
|
|
1715
1762
|
return e ? {
|
|
1716
1763
|
type: t.type,
|
|
1717
1764
|
tabId: n,
|
|
@@ -1722,7 +1769,7 @@ function Xt(e) {
|
|
|
1722
1769
|
};
|
|
1723
1770
|
}
|
|
1724
1771
|
case "retry-scheduled": {
|
|
1725
|
-
let e =
|
|
1772
|
+
let e = Qt(t);
|
|
1726
1773
|
return e ? {
|
|
1727
1774
|
type: t.type,
|
|
1728
1775
|
tabId: n,
|
|
@@ -1743,10 +1790,10 @@ function Xt(e) {
|
|
|
1743
1790
|
case "signed-out": return {
|
|
1744
1791
|
type: t.type,
|
|
1745
1792
|
tabId: n,
|
|
1746
|
-
|
|
1793
|
+
...$t(t)
|
|
1747
1794
|
};
|
|
1748
1795
|
case "rate-limited": {
|
|
1749
|
-
let e =
|
|
1796
|
+
let e = Jt(t.until);
|
|
1750
1797
|
return e === void 0 ? null : {
|
|
1751
1798
|
type: t.type,
|
|
1752
1799
|
tabId: n,
|
|
@@ -1765,22 +1812,22 @@ function Xt(e) {
|
|
|
1765
1812
|
default: return null;
|
|
1766
1813
|
}
|
|
1767
1814
|
}
|
|
1768
|
-
function
|
|
1815
|
+
function tn(e, t) {
|
|
1769
1816
|
let n = {
|
|
1770
1817
|
v: 1,
|
|
1771
1818
|
tabId: e
|
|
1772
1819
|
};
|
|
1773
1820
|
if (t.type === "retry-scheduled") {
|
|
1774
1821
|
let { retry: e, ...r } = t;
|
|
1775
|
-
return
|
|
1822
|
+
return Xt(n, {
|
|
1776
1823
|
...r,
|
|
1777
1824
|
...e
|
|
1778
1825
|
});
|
|
1779
1826
|
}
|
|
1780
|
-
return
|
|
1827
|
+
return Xt(n, { ...t });
|
|
1781
1828
|
}
|
|
1782
1829
|
// lib/refresh/resolve.ts
|
|
1783
|
-
var
|
|
1830
|
+
var nn = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", rn = {
|
|
1784
1831
|
now: () => Date.now(),
|
|
1785
1832
|
random: () => Math.random(),
|
|
1786
1833
|
setTimeout: (e, t) => {
|
|
@@ -1788,28 +1835,28 @@ var Qt = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
|
|
|
1788
1835
|
return n.unref?.(), () => clearTimeout(n);
|
|
1789
1836
|
}
|
|
1790
1837
|
};
|
|
1791
|
-
function
|
|
1838
|
+
function an() {
|
|
1792
1839
|
let e = globalThis.crypto;
|
|
1793
1840
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
1794
1841
|
}
|
|
1795
|
-
function
|
|
1842
|
+
function on(e) {
|
|
1796
1843
|
return e ? {
|
|
1797
1844
|
now: () => e.now(),
|
|
1798
1845
|
setTimeout: (t, n) => e.setTimeout(t, n),
|
|
1799
|
-
random: e.random ? () => e.random?.() ?? Math.random() :
|
|
1800
|
-
} :
|
|
1846
|
+
random: e.random ? () => e.random?.() ?? Math.random() : rn.random
|
|
1847
|
+
} : rn;
|
|
1801
1848
|
}
|
|
1802
|
-
function
|
|
1849
|
+
function sn(e) {
|
|
1803
1850
|
return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
|
|
1804
1851
|
}
|
|
1805
|
-
function
|
|
1852
|
+
function cn(e) {
|
|
1806
1853
|
try {
|
|
1807
1854
|
return e.storageSharedAcrossTabs === !0;
|
|
1808
1855
|
} catch {
|
|
1809
1856
|
return !1;
|
|
1810
1857
|
}
|
|
1811
1858
|
}
|
|
1812
|
-
function
|
|
1859
|
+
function ln() {
|
|
1813
1860
|
try {
|
|
1814
1861
|
let e = globalThis.navigator?.locks;
|
|
1815
1862
|
return e && typeof e.request == "function" ? e : void 0;
|
|
@@ -1817,7 +1864,7 @@ function an() {
|
|
|
1817
1864
|
return;
|
|
1818
1865
|
}
|
|
1819
1866
|
}
|
|
1820
|
-
function
|
|
1867
|
+
function un(e) {
|
|
1821
1868
|
return (t) => {
|
|
1822
1869
|
let n = (n) => {
|
|
1823
1870
|
let r = n.key;
|
|
@@ -1826,20 +1873,20 @@ function on(e) {
|
|
|
1826
1873
|
return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
|
|
1827
1874
|
};
|
|
1828
1875
|
}
|
|
1829
|
-
function
|
|
1876
|
+
function dn(e) {
|
|
1830
1877
|
return {
|
|
1831
1878
|
transports: null,
|
|
1832
|
-
names:
|
|
1833
|
-
clock:
|
|
1879
|
+
names: qt(e),
|
|
1880
|
+
clock: rn,
|
|
1834
1881
|
warnOnFirstCycle: !1
|
|
1835
1882
|
};
|
|
1836
1883
|
}
|
|
1837
|
-
function
|
|
1838
|
-
let i =
|
|
1884
|
+
function fn(e, t, n, r) {
|
|
1885
|
+
let i = qt(n), a = sn(t), o = a ? un(r.tokenKeys) : void 0, s = (e) => {
|
|
1839
1886
|
let t = {
|
|
1840
1887
|
transports: null,
|
|
1841
1888
|
names: i,
|
|
1842
|
-
clock:
|
|
1889
|
+
clock: rn,
|
|
1843
1890
|
warnOnFirstCycle: e
|
|
1844
1891
|
};
|
|
1845
1892
|
return o && (t.onStorageChange = o), t;
|
|
@@ -1849,16 +1896,16 @@ function cn(e, t, n, r) {
|
|
|
1849
1896
|
transports: {
|
|
1850
1897
|
locks: e.locks,
|
|
1851
1898
|
channel: e.channel,
|
|
1852
|
-
tabId: e.tabId ??
|
|
1899
|
+
tabId: e.tabId ?? an()
|
|
1853
1900
|
},
|
|
1854
1901
|
names: i,
|
|
1855
|
-
clock:
|
|
1902
|
+
clock: on(e.clock),
|
|
1856
1903
|
warnOnFirstCycle: !1
|
|
1857
1904
|
};
|
|
1858
1905
|
return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
|
|
1859
1906
|
}
|
|
1860
|
-
if (e === "none" || !a || !
|
|
1861
|
-
let c =
|
|
1907
|
+
if (e === "none" || !a || !cn(t)) return s(!1);
|
|
1908
|
+
let c = ln();
|
|
1862
1909
|
if (!c || typeof BroadcastChannel != "function") return s(!0);
|
|
1863
1910
|
let l;
|
|
1864
1911
|
try {
|
|
@@ -1870,36 +1917,36 @@ function cn(e, t, n, r) {
|
|
|
1870
1917
|
transports: {
|
|
1871
1918
|
locks: c,
|
|
1872
1919
|
channel: l,
|
|
1873
|
-
tabId:
|
|
1920
|
+
tabId: an()
|
|
1874
1921
|
},
|
|
1875
1922
|
names: i,
|
|
1876
|
-
clock:
|
|
1923
|
+
clock: rn,
|
|
1877
1924
|
warnOnFirstCycle: !1
|
|
1878
1925
|
};
|
|
1879
1926
|
return o && (u.onStorageChange = o), u;
|
|
1880
1927
|
}
|
|
1881
1928
|
// lib/pkce.ts
|
|
1882
|
-
var
|
|
1929
|
+
var pn = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", mn = 32, hn = (e) => {
|
|
1883
1930
|
let t = "";
|
|
1884
1931
|
for (let n = 0; n < e.length; n += 3) {
|
|
1885
1932
|
let r = e[n], i = e[n + 1], a = e[n + 2];
|
|
1886
|
-
t +=
|
|
1933
|
+
t += pn.charAt(r >> 2), t += pn.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += pn.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += pn.charAt(a & 63));
|
|
1887
1934
|
}
|
|
1888
1935
|
return t;
|
|
1889
|
-
},
|
|
1936
|
+
}, gn = () => {
|
|
1890
1937
|
let e = globalThis.crypto;
|
|
1891
1938
|
if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1892
1939
|
return e;
|
|
1893
|
-
},
|
|
1894
|
-
let t = await
|
|
1895
|
-
return
|
|
1896
|
-
},
|
|
1897
|
-
let e =
|
|
1940
|
+
}, _n = async (e) => {
|
|
1941
|
+
let t = await gn().subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
1942
|
+
return hn(new Uint8Array(t));
|
|
1943
|
+
}, vn = async () => {
|
|
1944
|
+
let e = hn(gn().getRandomValues(new Uint8Array(mn)));
|
|
1898
1945
|
return {
|
|
1899
1946
|
verifier: e,
|
|
1900
|
-
challenge: await
|
|
1947
|
+
challenge: await _n(e)
|
|
1901
1948
|
};
|
|
1902
|
-
},
|
|
1949
|
+
}, yn = class {
|
|
1903
1950
|
error(e, ...t) {
|
|
1904
1951
|
console.error(e, ...t);
|
|
1905
1952
|
}
|
|
@@ -1913,10 +1960,10 @@ var ln = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", un
|
|
|
1913
1960
|
console.debug(e, ...t);
|
|
1914
1961
|
}
|
|
1915
1962
|
};
|
|
1916
|
-
function
|
|
1917
|
-
return new
|
|
1963
|
+
function bn() {
|
|
1964
|
+
return new yn();
|
|
1918
1965
|
}
|
|
1919
|
-
var
|
|
1966
|
+
var xn = Object.freeze([
|
|
1920
1967
|
"error.token.invalid.error",
|
|
1921
1968
|
"error.api.token.parse.error",
|
|
1922
1969
|
"error.api.user.blocked",
|
|
@@ -1924,25 +1971,25 @@ var _n = Object.freeze([
|
|
|
1924
1971
|
"error.validation.token.invalid.subject",
|
|
1925
1972
|
"error.not.found"
|
|
1926
1973
|
]);
|
|
1927
|
-
function
|
|
1974
|
+
function Sn(e) {
|
|
1928
1975
|
if (typeof e != "object" || !e) return;
|
|
1929
1976
|
let t = e;
|
|
1930
1977
|
return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
|
|
1931
1978
|
}
|
|
1932
|
-
function
|
|
1933
|
-
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(
|
|
1979
|
+
function Cn(e, t) {
|
|
1980
|
+
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(zt, Math.floor(e) * 1e3);
|
|
1934
1981
|
if (typeof e != "string") return;
|
|
1935
1982
|
let n = e.trim();
|
|
1936
1983
|
if (n === "") return;
|
|
1937
|
-
if (/^\d+$/.test(n)) return Math.min(
|
|
1984
|
+
if (/^\d+$/.test(n)) return Math.min(zt, Number.parseInt(n, 10) * 1e3);
|
|
1938
1985
|
if (!/[a-z]/i.test(n)) return;
|
|
1939
1986
|
let r = Date.parse(n);
|
|
1940
|
-
if (!Number.isNaN(r)) return Math.min(
|
|
1987
|
+
if (!Number.isNaN(r)) return Math.min(zt, Math.max(0, r - t));
|
|
1941
1988
|
}
|
|
1942
|
-
function
|
|
1989
|
+
function wn(e) {
|
|
1943
1990
|
return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
|
|
1944
1991
|
}
|
|
1945
|
-
function
|
|
1992
|
+
function Tn(e) {
|
|
1946
1993
|
if (typeof e.id == "string" && e.id !== "") return e.id;
|
|
1947
1994
|
let t = e.response?.data;
|
|
1948
1995
|
if (typeof t != "object" || !t) return;
|
|
@@ -1951,14 +1998,14 @@ function xn(e) {
|
|
|
1951
1998
|
let r = n.id;
|
|
1952
1999
|
return typeof r == "string" && r !== "" ? r : void 0;
|
|
1953
2000
|
}
|
|
1954
|
-
function
|
|
2001
|
+
function En(e, t = Date.now()) {
|
|
1955
2002
|
if (typeof e != "object" || !e) return { kind: "transient" };
|
|
1956
|
-
let n = e, r =
|
|
2003
|
+
let n = e, r = Tn(n), i = wn(n.response?.status) ?? wn(n.status), a = {};
|
|
1957
2004
|
if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
|
|
1958
2005
|
kind: "blocked",
|
|
1959
2006
|
...a
|
|
1960
2007
|
};
|
|
1961
|
-
if (r !== void 0 &&
|
|
2008
|
+
if (r !== void 0 && xn.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
|
|
1962
2009
|
kind: "auth",
|
|
1963
2010
|
...a
|
|
1964
2011
|
};
|
|
@@ -1966,7 +2013,7 @@ function Sn(e, t = Date.now()) {
|
|
|
1966
2013
|
kind: "transient",
|
|
1967
2014
|
...a
|
|
1968
2015
|
};
|
|
1969
|
-
let o =
|
|
2016
|
+
let o = Cn(n.retryAfter ?? Sn(n.response?.headers), t);
|
|
1970
2017
|
return o === void 0 ? {
|
|
1971
2018
|
kind: "transient",
|
|
1972
2019
|
...a
|
|
@@ -1976,19 +2023,19 @@ function Sn(e, t = Date.now()) {
|
|
|
1976
2023
|
retryAfterMs: o
|
|
1977
2024
|
};
|
|
1978
2025
|
}
|
|
1979
|
-
function
|
|
1980
|
-
let r =
|
|
1981
|
-
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0),
|
|
2026
|
+
function Dn(e, t, n) {
|
|
2027
|
+
let r = Lt.length, i = Lt[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? Lt[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * Rt * a);
|
|
2028
|
+
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), zt) : 0);
|
|
1982
2029
|
}
|
|
1983
2030
|
// lib/refresh/coordinator.ts
|
|
1984
|
-
var
|
|
2031
|
+
var On = {
|
|
1985
2032
|
onGranted: () => !1,
|
|
1986
2033
|
onLockLost: () => void 0,
|
|
1987
2034
|
onMessage: () => void 0
|
|
1988
2035
|
};
|
|
1989
|
-
function
|
|
1990
|
-
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o =
|
|
1991
|
-
g || n.postMessage(
|
|
2036
|
+
function kn(e) {
|
|
2037
|
+
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = On, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
|
|
2038
|
+
g || n.postMessage(tn(r, e));
|
|
1992
2039
|
}, v = () => s !== null && c === null, y = () => {
|
|
1993
2040
|
f?.(), f = null;
|
|
1994
2041
|
}, b = (e) => {
|
|
@@ -2003,7 +2050,7 @@ function Tn(e) {
|
|
|
2003
2050
|
type: "still-refreshing",
|
|
2004
2051
|
retry: m
|
|
2005
2052
|
} : { type: "still-refreshing" }), S());
|
|
2006
|
-
},
|
|
2053
|
+
}, Bt);
|
|
2007
2054
|
}, C = () => {
|
|
2008
2055
|
y(), x(), u?.(), u = null;
|
|
2009
2056
|
let e = s;
|
|
@@ -2054,7 +2101,7 @@ function Tn(e) {
|
|
|
2054
2101
|
});
|
|
2055
2102
|
}, ee = (e) => {
|
|
2056
2103
|
if (g) return;
|
|
2057
|
-
let t =
|
|
2104
|
+
let t = en(e.data);
|
|
2058
2105
|
if (t && t.tabId !== r) {
|
|
2059
2106
|
switch (t.type) {
|
|
2060
2107
|
case "still-refreshing":
|
|
@@ -2097,8 +2144,8 @@ function Tn(e) {
|
|
|
2097
2144
|
}
|
|
2098
2145
|
};
|
|
2099
2146
|
}
|
|
2100
|
-
function
|
|
2101
|
-
let t =
|
|
2147
|
+
function An(e = "local") {
|
|
2148
|
+
let t = On, n = !1, r = !1, i = 0, a = !1, o = () => {
|
|
2102
2149
|
n = !1, r = !1, i += 1;
|
|
2103
2150
|
};
|
|
2104
2151
|
return {
|
|
@@ -2146,7 +2193,7 @@ var q = {
|
|
|
2146
2193
|
successorTimeout: "error.refresh.successor_timeout",
|
|
2147
2194
|
identityChanged: "error.refresh.identity_changed",
|
|
2148
2195
|
disposed: "error.refresh.disposed"
|
|
2149
|
-
},
|
|
2196
|
+
}, jn = {
|
|
2150
2197
|
"error.refresh.unavailable": 503,
|
|
2151
2198
|
"error.refresh.auth_retry": 401,
|
|
2152
2199
|
"error.refresh.session_ended": 401,
|
|
@@ -2154,7 +2201,7 @@ var q = {
|
|
|
2154
2201
|
"error.refresh.successor_timeout": 401,
|
|
2155
2202
|
"error.refresh.identity_changed": 401,
|
|
2156
2203
|
"error.refresh.disposed": 499
|
|
2157
|
-
},
|
|
2204
|
+
}, Mn = {
|
|
2158
2205
|
"error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
|
|
2159
2206
|
"error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
|
|
2160
2207
|
"error.refresh.session_ended": "The session has ended",
|
|
@@ -2166,19 +2213,19 @@ var q = {
|
|
|
2166
2213
|
constructor(e, t = {}) {
|
|
2167
2214
|
super({
|
|
2168
2215
|
id: e,
|
|
2169
|
-
message: t.message ??
|
|
2170
|
-
status:
|
|
2216
|
+
message: t.message ?? Mn[e],
|
|
2217
|
+
status: jn[e],
|
|
2171
2218
|
location: "/auth/refresh",
|
|
2172
2219
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2173
2220
|
}), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
|
|
2174
2221
|
}
|
|
2175
|
-
},
|
|
2222
|
+
}, Nn = class extends Error {
|
|
2176
2223
|
constructor(e, t) {
|
|
2177
2224
|
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;
|
|
2178
2225
|
}
|
|
2179
2226
|
};
|
|
2180
2227
|
// lib/refresh/lineage.ts
|
|
2181
|
-
function
|
|
2228
|
+
function Pn(e) {
|
|
2182
2229
|
if (!e) return;
|
|
2183
2230
|
let t = 3735928559, n = 1103547991;
|
|
2184
2231
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -2187,24 +2234,24 @@ function An(e) {
|
|
|
2187
2234
|
}
|
|
2188
2235
|
return t = Math.imul(t ^ t >>> 16, 2246822507), t ^= Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507), n ^= Math.imul(t ^ t >>> 13, 3266489909), (4294967296 * (2097151 & n) + (t >>> 0)).toString(16);
|
|
2189
2236
|
}
|
|
2190
|
-
function
|
|
2237
|
+
function Fn(e) {
|
|
2191
2238
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2192
2239
|
}
|
|
2193
2240
|
function Y(e) {
|
|
2194
|
-
let t =
|
|
2241
|
+
let t = Pn(e);
|
|
2195
2242
|
if (!e || !t) return;
|
|
2196
2243
|
let n = {};
|
|
2197
2244
|
try {
|
|
2198
2245
|
let t = A(e);
|
|
2199
2246
|
typeof t == "object" && t && (n = t);
|
|
2200
2247
|
} catch {}
|
|
2201
|
-
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a =
|
|
2248
|
+
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = Fn(n.sub), o = Fn(n.sid);
|
|
2202
2249
|
return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
|
|
2203
2250
|
}
|
|
2204
|
-
var
|
|
2205
|
-
function
|
|
2251
|
+
var In = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
|
|
2252
|
+
function Ln(e = (e) => bn().warn(e)) {
|
|
2206
2253
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
|
|
2207
|
-
a || (a = !0, e(
|
|
2254
|
+
a || (a = !0, e(In));
|
|
2208
2255
|
}, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
|
|
2209
2256
|
if (!e) return;
|
|
2210
2257
|
if (e.iat === void 0) {
|
|
@@ -2245,16 +2292,16 @@ function Nn(e = (e) => gn().warn(e)) {
|
|
|
2245
2292
|
};
|
|
2246
2293
|
}
|
|
2247
2294
|
// lib/refresh/fence.ts
|
|
2248
|
-
var
|
|
2295
|
+
var Rn = class extends Error {
|
|
2249
2296
|
constructor(e) {
|
|
2250
2297
|
super(e === "emptied" ? "The shared token storage was emptied" : "The stored refresh token belongs to an ended session"), this.name = "SessionEnded", this.cause = e;
|
|
2251
2298
|
}
|
|
2252
|
-
},
|
|
2299
|
+
}, zn = class extends Error {
|
|
2253
2300
|
constructor() {
|
|
2254
2301
|
super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
|
|
2255
2302
|
}
|
|
2256
2303
|
};
|
|
2257
|
-
function
|
|
2304
|
+
function Bn(e) {
|
|
2258
2305
|
if (e) try {
|
|
2259
2306
|
let t = A(e).sub;
|
|
2260
2307
|
return typeof t == "string" && t !== "" ? t : void 0;
|
|
@@ -2263,20 +2310,20 @@ function In(e) {
|
|
|
2263
2310
|
}
|
|
2264
2311
|
}
|
|
2265
2312
|
function X(e) {
|
|
2266
|
-
return
|
|
2313
|
+
return Bn(e?.access_token) ?? Bn(e?.refresh_token) ?? Bn(e?.id_token);
|
|
2267
2314
|
}
|
|
2268
|
-
function
|
|
2315
|
+
function Vn(e, t) {
|
|
2269
2316
|
return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
|
|
2270
2317
|
}
|
|
2271
|
-
function
|
|
2318
|
+
function Hn(e) {
|
|
2272
2319
|
return typeof e == "object" && !!e;
|
|
2273
2320
|
}
|
|
2274
|
-
function
|
|
2275
|
-
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) =>
|
|
2321
|
+
function Un(e) {
|
|
2322
|
+
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => bn().warn(e)), o = e.lineage ?? Ln(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
|
|
2276
2323
|
let e = t.getTokens(), n = e?.refresh_token;
|
|
2277
2324
|
if (!n) return p = l, e;
|
|
2278
2325
|
p !== void 0 && (f = Math.max(f, p, m), p = void 0);
|
|
2279
|
-
let r =
|
|
2326
|
+
let r = Pn(n) ?? "";
|
|
2280
2327
|
return r !== c?.fp && (c = {
|
|
2281
2328
|
fp: r,
|
|
2282
2329
|
seq: l
|
|
@@ -2309,7 +2356,7 @@ function zn(e) {
|
|
|
2309
2356
|
let t = E();
|
|
2310
2357
|
t === "wait" && e && (t = "end"), t !== "wait" && D(), t === "wait" && !h && (h = r(() => {
|
|
2311
2358
|
h = void 0, y()?.refresh_token ? N() : O(!0) === "end" && s?.("emptied");
|
|
2312
|
-
},
|
|
2359
|
+
}, Ut));
|
|
2313
2360
|
let n = t === "keep" ? T() : void 0;
|
|
2314
2361
|
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;
|
|
2315
2362
|
}, ee = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, k = (e) => {
|
|
@@ -2322,7 +2369,7 @@ function zn(e) {
|
|
|
2322
2369
|
return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
|
|
2323
2370
|
}, j = (e, t) => o.isForward(e, t) ? !0 : !!e && !!t && e.iat !== void 0 && e.sid !== t.sid && o.isRetired(t) && !o.isRetired(e) && !o.isEnded(e), M = (e) => {
|
|
2324
2371
|
let t = b();
|
|
2325
|
-
t && t.fp !==
|
|
2372
|
+
t && t.fp !== Pn(e.refresh_token) && o.retire(t), n.setTokensCache(e);
|
|
2326
2373
|
}, te = (e) => {
|
|
2327
2374
|
let t = y(), n = t?.refresh_token;
|
|
2328
2375
|
if (n === e.refreshToken) return null;
|
|
@@ -2333,7 +2380,7 @@ function zn(e) {
|
|
|
2333
2380
|
kind: "superseded",
|
|
2334
2381
|
adopted: !1
|
|
2335
2382
|
};
|
|
2336
|
-
let r =
|
|
2383
|
+
let r = Bn(t.access_token) ?? Bn(n);
|
|
2337
2384
|
if (e.sub && r && e.sub !== r) return {
|
|
2338
2385
|
kind: "identity-changed",
|
|
2339
2386
|
saved: !1
|
|
@@ -2373,22 +2420,22 @@ function zn(e) {
|
|
|
2373
2420
|
}, re = !!s || !!e.onStoredSessionSeen, ie = re && e.onStorageChange ? e.onStorageChange(N) : void 0, ae = re && e.onWake ? e.onWake(N) : void 0, P = () => {
|
|
2374
2421
|
let e = y();
|
|
2375
2422
|
if (!e?.refresh_token) {
|
|
2376
|
-
if (O() === "end") throw new
|
|
2423
|
+
if (O() === "end") throw new Rn("emptied");
|
|
2377
2424
|
return "held";
|
|
2378
2425
|
}
|
|
2379
2426
|
let t = n.getTokens();
|
|
2380
2427
|
if (e.refresh_token === t?.refresh_token) return "send";
|
|
2381
2428
|
let r = i() ?? X(t), a = X(e);
|
|
2382
|
-
if (r && a && r !== a) throw new
|
|
2429
|
+
if (r && a && r !== a) throw new zn();
|
|
2383
2430
|
let s = Y(e.refresh_token);
|
|
2384
2431
|
if (o.isEnded(s)) {
|
|
2385
2432
|
if (s && C(s)) return "held";
|
|
2386
|
-
throw new
|
|
2433
|
+
throw new Rn("ended");
|
|
2387
2434
|
}
|
|
2388
2435
|
let c = Y(t?.refresh_token);
|
|
2389
2436
|
return j(s, c) ? (M(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && k(s) ? "held" : "send";
|
|
2390
2437
|
}, oe = (e) => {
|
|
2391
|
-
let t = i(), r =
|
|
2438
|
+
let t = i(), r = Bn(e);
|
|
2392
2439
|
if (t && r && t !== r) return { kind: "identity-changed" };
|
|
2393
2440
|
let a = Y(e) ?? { fp: e };
|
|
2394
2441
|
if (o.isEnded(a)) return C(a) ? { kind: "superseded" } : { kind: "ended" };
|
|
@@ -2396,7 +2443,7 @@ function zn(e) {
|
|
|
2396
2443
|
let s = {
|
|
2397
2444
|
refreshToken: e,
|
|
2398
2445
|
order: a
|
|
2399
|
-
}, c = t ?? r ??
|
|
2446
|
+
}, c = t ?? r ?? Bn(n.getTokens()?.access_token);
|
|
2400
2447
|
return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
|
|
2401
2448
|
kind: "send",
|
|
2402
2449
|
sent: s
|
|
@@ -2405,7 +2452,7 @@ function zn(e) {
|
|
|
2405
2452
|
if (o.isEnded(e.order)) return ne(e.order);
|
|
2406
2453
|
let i = te(e);
|
|
2407
2454
|
if (i) return i;
|
|
2408
|
-
if (!ee(e) && A(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${
|
|
2455
|
+
if (!ee(e) && A(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${Pn(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.`), {
|
|
2409
2456
|
kind: "superseded",
|
|
2410
2457
|
adopted: !1
|
|
2411
2458
|
};
|
|
@@ -2415,7 +2462,7 @@ function zn(e) {
|
|
|
2415
2462
|
saved: !0
|
|
2416
2463
|
};
|
|
2417
2464
|
let c = Y(r.refresh_token);
|
|
2418
|
-
return c && (
|
|
2465
|
+
return c && (Vn(c, e.order) || Vn(c, b())) ? (a(`[passflow] Refused to save a refresh result older than the token this tab holds: ${e.order.fp} was answered with ${c.fp}. Neither saved nor adopted.`), {
|
|
2419
2466
|
kind: "superseded",
|
|
2420
2467
|
adopted: !1
|
|
2421
2468
|
}) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
|
|
@@ -2427,7 +2474,7 @@ function zn(e) {
|
|
|
2427
2474
|
kind: "superseded",
|
|
2428
2475
|
adopted: !1
|
|
2429
2476
|
};
|
|
2430
|
-
let r =
|
|
2477
|
+
let r = En(t), i = r.kind === "blocked" || r.kind === "auth";
|
|
2431
2478
|
return ee(e) && i ? (o.retire(e.order), _ = e.order, {
|
|
2432
2479
|
kind: "own",
|
|
2433
2480
|
failure: r,
|
|
@@ -2438,11 +2485,11 @@ function zn(e) {
|
|
|
2438
2485
|
heldRefused: !1
|
|
2439
2486
|
});
|
|
2440
2487
|
}, I = (e) => {
|
|
2441
|
-
if (!
|
|
2488
|
+
if (!Hn(e)) return !1;
|
|
2442
2489
|
let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
|
|
2443
|
-
if (typeof t != "string" || typeof c != "string" || !
|
|
2490
|
+
if (typeof t != "string" || typeof c != "string" || !Hn(l)) return !1;
|
|
2444
2491
|
let u = l;
|
|
2445
|
-
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" ||
|
|
2492
|
+
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || Pn(u.refresh_token) !== c) return !1;
|
|
2446
2493
|
let d = y();
|
|
2447
2494
|
if (!d?.refresh_token) return !1;
|
|
2448
2495
|
let f = n.getTokens(), p = i() ?? X(f), m = X(u);
|
|
@@ -2459,7 +2506,7 @@ function zn(e) {
|
|
|
2459
2506
|
}
|
|
2460
2507
|
return !0;
|
|
2461
2508
|
};
|
|
2462
|
-
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t &&
|
|
2509
|
+
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && Pn(d.refresh_token) !== c ? !1 : (M({ ...u }), _());
|
|
2463
2510
|
}, L = (e) => {
|
|
2464
2511
|
if (!e || !_) return !1;
|
|
2465
2512
|
let t = _;
|
|
@@ -2525,7 +2572,7 @@ function zn(e) {
|
|
|
2525
2572
|
};
|
|
2526
2573
|
}
|
|
2527
2574
|
// lib/refresh/controller.ts
|
|
2528
|
-
function
|
|
2575
|
+
function Wn() {
|
|
2529
2576
|
let e, t, n = new Promise((n, r) => {
|
|
2530
2577
|
e = n, t = r;
|
|
2531
2578
|
});
|
|
@@ -2535,7 +2582,7 @@ function Bn() {
|
|
|
2535
2582
|
reject: t
|
|
2536
2583
|
};
|
|
2537
2584
|
}
|
|
2538
|
-
var
|
|
2585
|
+
var Gn = {
|
|
2539
2586
|
strikes: q.sessionEnded,
|
|
2540
2587
|
"session-ended": q.sessionEnded,
|
|
2541
2588
|
"stored-ended": q.sessionEnded,
|
|
@@ -2546,42 +2593,42 @@ var Vn = {
|
|
|
2546
2593
|
"identity-changed": q.identityChanged,
|
|
2547
2594
|
disposed: q.disposed
|
|
2548
2595
|
};
|
|
2549
|
-
function
|
|
2596
|
+
function Kn(e) {
|
|
2550
2597
|
throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
|
|
2551
2598
|
}
|
|
2552
|
-
function
|
|
2599
|
+
function qn(e) {
|
|
2553
2600
|
if (e === void 0 || !Number.isFinite(e)) return 3;
|
|
2554
2601
|
let t = Math.floor(e);
|
|
2555
2602
|
return t >= 1 ? t : 3;
|
|
2556
2603
|
}
|
|
2557
|
-
function
|
|
2604
|
+
function Jn(e, t) {
|
|
2558
2605
|
return e instanceof Error && e.message ? e.message : t;
|
|
2559
2606
|
}
|
|
2560
|
-
function
|
|
2607
|
+
function Yn(e) {
|
|
2561
2608
|
if (typeof e != "object" || !e) return;
|
|
2562
2609
|
let t = e.id;
|
|
2563
2610
|
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
2564
2611
|
}
|
|
2565
|
-
function
|
|
2612
|
+
function Xn(e) {
|
|
2566
2613
|
let t = {};
|
|
2567
2614
|
return e?.access_token && (t.access_token = e.access_token), e?.refresh_token && (t.refresh_token = e.refresh_token), e?.id_token && (t.id_token = e.id_token), e?.scopes && (t.scopes = [...e.scopes]), t;
|
|
2568
2615
|
}
|
|
2569
|
-
function
|
|
2616
|
+
function Zn(e, t) {
|
|
2570
2617
|
let n = {};
|
|
2571
2618
|
e.access_token && (n.access_token = e.access_token), e.refresh_token && (n.refresh_token = e.refresh_token), e.id_token && (n.id_token = e.id_token);
|
|
2572
2619
|
let r = t?.scopes ?? e.scopes;
|
|
2573
2620
|
return r && (n.scopes = r), n;
|
|
2574
2621
|
}
|
|
2575
|
-
function
|
|
2576
|
-
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ??
|
|
2622
|
+
function Qn(e) {
|
|
2623
|
+
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? bn(), c = qn(e.strikes), l = a.transports ? kn({
|
|
2577
2624
|
locks: a.transports.locks,
|
|
2578
2625
|
channel: a.transports.channel,
|
|
2579
2626
|
tabId: a.transports.tabId,
|
|
2580
2627
|
names: a.names,
|
|
2581
2628
|
clock: o
|
|
2582
|
-
}) :
|
|
2629
|
+
}) : An(), u = { kind: "idle" }, d = 0, f = !1, p = !a.warnOnFirstCycle, m = 0, h = 0, g, _, v, y, b, x, S, C, w = !1, T = () => o.now(), E = () => i.mode(), D = () => Pn(r.getTokens()?.refresh_token), O = () => ({ ...r.getTokens() ?? {} }), ee = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, k = () => (S === void 0 && (S = X(r.getTokens() ?? n.getTokens())), S), A = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Set(), M = (e) => () => {
|
|
2583
2630
|
for (let t of Array.from(e)) t();
|
|
2584
|
-
}, te = a.onStorageChange?.(M(A)), ne = e.platform?.onForeground(M(j)), N =
|
|
2631
|
+
}, te = a.onStorageChange?.(M(A)), ne = e.platform?.onForeground(M(j)), N = Un({
|
|
2585
2632
|
storage: n,
|
|
2586
2633
|
cache: r,
|
|
2587
2634
|
identity: k,
|
|
@@ -2596,13 +2643,13 @@ function Jn(e) {
|
|
|
2596
2643
|
}), re = (e) => ({
|
|
2597
2644
|
trigger: e,
|
|
2598
2645
|
startedAt: T(),
|
|
2599
|
-
plain:
|
|
2646
|
+
plain: Wn(),
|
|
2600
2647
|
fresh: []
|
|
2601
2648
|
}), ie = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, ae = (e, t) => {
|
|
2602
2649
|
if (t === void 0) return e.plain.promise;
|
|
2603
2650
|
let n = {
|
|
2604
2651
|
callTime: t,
|
|
2605
|
-
deferred:
|
|
2652
|
+
deferred: Wn()
|
|
2606
2653
|
};
|
|
2607
2654
|
return e.fresh.push(n), n.deferred.promise;
|
|
2608
2655
|
}, P = (e, t, n = !1) => {
|
|
@@ -2621,11 +2668,11 @@ function Jn(e) {
|
|
|
2621
2668
|
}
|
|
2622
2669
|
}, F = (e, n, r, i) => {
|
|
2623
2670
|
let a = {
|
|
2624
|
-
message:
|
|
2671
|
+
message: Jn(r, "Token refresh failed"),
|
|
2625
2672
|
originalError: r,
|
|
2626
2673
|
operation: e,
|
|
2627
2674
|
source: n
|
|
2628
|
-
}, o =
|
|
2675
|
+
}, o = Yn(r);
|
|
2629
2676
|
o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
|
|
2630
2677
|
}, I = (e, t) => {
|
|
2631
2678
|
let n = {
|
|
@@ -2655,10 +2702,10 @@ function Jn(e) {
|
|
|
2655
2702
|
};
|
|
2656
2703
|
n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
|
|
2657
2704
|
}, le = (e, t) => {
|
|
2658
|
-
let n = r.getTokens(), i =
|
|
2705
|
+
let n = r.getTokens(), i = Pn(n?.refresh_token);
|
|
2659
2706
|
e.fp && i && l.post({
|
|
2660
2707
|
type: "tokens-refreshed",
|
|
2661
|
-
tokens:
|
|
2708
|
+
tokens: Xn(n),
|
|
2662
2709
|
from: e.fp,
|
|
2663
2710
|
...e.iat === void 0 ? {} : { fromIat: e.iat },
|
|
2664
2711
|
fromSid: e.sid ?? "",
|
|
@@ -2666,7 +2713,7 @@ function Jn(e) {
|
|
|
2666
2713
|
...t === void 0 ? {} : { sentAt: t }
|
|
2667
2714
|
});
|
|
2668
2715
|
}, ue = () => {
|
|
2669
|
-
p || (p = !0, s.warn(
|
|
2716
|
+
p || (p = !0, s.warn(nn));
|
|
2670
2717
|
}, de = (e) => {
|
|
2671
2718
|
(e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
|
|
2672
2719
|
}, R = (e, n) => {
|
|
@@ -2680,7 +2727,7 @@ function Jn(e) {
|
|
|
2680
2727
|
}, e !== "disposed" && N.dropSession(), (e === "strikes" || e === "successor-timeout") && E() !== "json" && i.invalidate(), u = {
|
|
2681
2728
|
kind: "ended",
|
|
2682
2729
|
cause: e
|
|
2683
|
-
}, se(r, n ?? new J(
|
|
2730
|
+
}, se(r, n ?? new J(Gn[e])), e) {
|
|
2684
2731
|
case "strikes":
|
|
2685
2732
|
t("session:expired", {
|
|
2686
2733
|
reason: "refresh_failed",
|
|
@@ -2715,7 +2762,7 @@ function Jn(e) {
|
|
|
2715
2762
|
break;
|
|
2716
2763
|
case "signed-out-here":
|
|
2717
2764
|
case "disposed": break;
|
|
2718
|
-
default:
|
|
2765
|
+
default: Kn(e);
|
|
2719
2766
|
}
|
|
2720
2767
|
}, fe = () => {
|
|
2721
2768
|
if (u.kind !== "ended" || u.cause === "disposed" || f || E() !== "json") return;
|
|
@@ -2732,10 +2779,10 @@ function Jn(e) {
|
|
|
2732
2779
|
}, pe = (e) => {
|
|
2733
2780
|
u.kind === "ended" || f || E() === "json" && (R(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && fe());
|
|
2734
2781
|
}, me = (e) => {
|
|
2735
|
-
e instanceof
|
|
2782
|
+
e instanceof zn ? (R("identity-changed"), fe()) : e instanceof Rn ? R(e.cause === "emptied" ? "emptied" : "stored-ended") : R("stored-ended", e);
|
|
2736
2783
|
}, he = () => {
|
|
2737
2784
|
u = { kind: "idle" }, w || l.release();
|
|
2738
|
-
}, ge = (e) => !e.from || E() !== "json" || e.from === D() || e.from ===
|
|
2785
|
+
}, ge = (e) => !e.from || E() !== "json" || e.from === D() || e.from === Pn(n.getTokens()?.refresh_token), _e = (e) => {
|
|
2739
2786
|
let t = g;
|
|
2740
2787
|
if (!t) return;
|
|
2741
2788
|
if (!l.holding) {
|
|
@@ -2801,14 +2848,14 @@ function Jn(e) {
|
|
|
2801
2848
|
case "ended": return N.endHeldSend(), R("stored-ended"), !1;
|
|
2802
2849
|
case "identity-changed": return N.endHeldSend(), R("identity-changed"), fe(), !1;
|
|
2803
2850
|
case "send": return Ce(e, t, a.sent, r);
|
|
2804
|
-
default: return
|
|
2851
|
+
default: return Kn(a);
|
|
2805
2852
|
}
|
|
2806
2853
|
}, Ce = (e, n, r, a) => {
|
|
2807
2854
|
let o = {
|
|
2808
2855
|
generation: d,
|
|
2809
2856
|
sentAt: T(),
|
|
2810
2857
|
trigger: n,
|
|
2811
|
-
settled:
|
|
2858
|
+
settled: Wn()
|
|
2812
2859
|
};
|
|
2813
2860
|
r ? o.sent = r : o.marker = ee(), a && (o.stored = a), u = {
|
|
2814
2861
|
kind: "refreshing",
|
|
@@ -2845,7 +2892,7 @@ function Jn(e) {
|
|
|
2845
2892
|
if (!we(e)) return;
|
|
2846
2893
|
r.setTokensCache({
|
|
2847
2894
|
...n.getTokens() ?? {},
|
|
2848
|
-
...
|
|
2895
|
+
...Zn(t, void 0)
|
|
2849
2896
|
}), L("refresh", "this-tab");
|
|
2850
2897
|
let c = k();
|
|
2851
2898
|
l.post(c === void 0 ? {
|
|
@@ -2858,7 +2905,7 @@ function Jn(e) {
|
|
|
2858
2905
|
}), he(), P(a, e.sentAt);
|
|
2859
2906
|
return;
|
|
2860
2907
|
}
|
|
2861
|
-
let o = D(), s = N.commitSave(e.sent,
|
|
2908
|
+
let o = D(), s = N.commitSave(e.sent, Zn(t, e.stored));
|
|
2862
2909
|
switch (s.kind) {
|
|
2863
2910
|
case "saved":
|
|
2864
2911
|
L("refresh", "this-tab"), le(e.sent.order, e.sentAt), he(), P(a, e.sentAt);
|
|
@@ -2876,7 +2923,7 @@ function Jn(e) {
|
|
|
2876
2923
|
F("refresh", e.trigger, t, I("auth")), R("identity-changed", t), fe();
|
|
2877
2924
|
return;
|
|
2878
2925
|
}
|
|
2879
|
-
default:
|
|
2926
|
+
default: Kn(s);
|
|
2880
2927
|
}
|
|
2881
2928
|
}, Ee = (e, t) => {
|
|
2882
2929
|
if (e.sent?.held && N.endHeldSend(), !we(e) || u.kind !== "refreshing") return;
|
|
@@ -2896,9 +2943,9 @@ function Jn(e) {
|
|
|
2896
2943
|
case "own":
|
|
2897
2944
|
r = o.failure, i = o.heldRefused;
|
|
2898
2945
|
break;
|
|
2899
|
-
default:
|
|
2946
|
+
default: Kn(o);
|
|
2900
2947
|
}
|
|
2901
|
-
} else r =
|
|
2948
|
+
} else r = En(t, T());
|
|
2902
2949
|
if (i) F("refresh", e.trigger, t, I(r.kind)), L("adopted", "other-tab"), he(), P(n, void 0, !0);
|
|
2903
2950
|
else switch (r.kind) {
|
|
2904
2951
|
case "blocked":
|
|
@@ -2914,10 +2961,10 @@ function Jn(e) {
|
|
|
2914
2961
|
case "transient":
|
|
2915
2962
|
m += 1, De(e, n, t, r);
|
|
2916
2963
|
return;
|
|
2917
|
-
default:
|
|
2964
|
+
default: Kn(r.kind);
|
|
2918
2965
|
}
|
|
2919
2966
|
}, De = (e, t, n, r) => {
|
|
2920
|
-
let i = T() +
|
|
2967
|
+
let i = T() + Dn(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
|
|
2921
2968
|
F("refresh", e.trigger, n, I(a, i)), a === "transient" && ce(T(), i, "this-tab");
|
|
2922
2969
|
let s = {
|
|
2923
2970
|
kind: a,
|
|
@@ -2927,7 +2974,7 @@ function Jn(e) {
|
|
|
2927
2974
|
}, c = e.sent?.order.fp;
|
|
2928
2975
|
c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
|
|
2929
2976
|
type: "retry-scheduled",
|
|
2930
|
-
message:
|
|
2977
|
+
message: Jn(n, "Token refresh failed"),
|
|
2931
2978
|
retry: s
|
|
2932
2979
|
}), _e(re("retry")), oe(t, n, e.sentAt);
|
|
2933
2980
|
}, z = (e, t) => {
|
|
@@ -2940,8 +2987,8 @@ function Jn(e) {
|
|
|
2940
2987
|
fp: i.fp
|
|
2941
2988
|
})), r && N.deleteIfStillDead(r), R("strikes", t);
|
|
2942
2989
|
}, Oe = (e, t, n, r) => {
|
|
2943
|
-
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${
|
|
2944
|
-
let i = d, a = T() +
|
|
2990
|
+
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${Jn(n, "blocked")}`);
|
|
2991
|
+
let i = d, a = T() + Vt, c = {
|
|
2945
2992
|
kind: "blocked-wait",
|
|
2946
2993
|
pending: e,
|
|
2947
2994
|
deadline: a,
|
|
@@ -2954,9 +3001,9 @@ function Jn(e) {
|
|
|
2954
3001
|
i === d && u === c && (ke() || (f ? (e.cookieRetried = !0, u = {
|
|
2955
3002
|
kind: "waiting",
|
|
2956
3003
|
pending: e
|
|
2957
|
-
}, l.request()) : T() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), R("successor-timeout")) : c.cancel = o.setTimeout(p,
|
|
3004
|
+
}, l.request()) : T() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), R("successor-timeout")) : c.cancel = o.setTimeout(p, Ht)));
|
|
2958
3005
|
};
|
|
2959
|
-
c.cancel = o.setTimeout(p, f ?
|
|
3006
|
+
c.cancel = o.setTimeout(p, f ? Wt : Ht);
|
|
2960
3007
|
}, ke = () => {
|
|
2961
3008
|
if (u.kind !== "blocked-wait") return !1;
|
|
2962
3009
|
let e = u;
|
|
@@ -3000,7 +3047,7 @@ function Jn(e) {
|
|
|
3000
3047
|
case "idle":
|
|
3001
3048
|
case "refreshing":
|
|
3002
3049
|
case "ended": return;
|
|
3003
|
-
default:
|
|
3050
|
+
default: Kn(u);
|
|
3004
3051
|
}
|
|
3005
3052
|
}, Ne = (e) => {
|
|
3006
3053
|
let t = {};
|
|
@@ -3043,7 +3090,7 @@ function Jn(e) {
|
|
|
3043
3090
|
je(e.retry, !0, e.message), Fe();
|
|
3044
3091
|
return;
|
|
3045
3092
|
case "refresh-failed":
|
|
3046
|
-
if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !==
|
|
3093
|
+
if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !== Pn(n.getTokens()?.refresh_token)) return;
|
|
3047
3094
|
if (ce(T(), void 0, "other-tab"), u.kind === "waiting") {
|
|
3048
3095
|
let t = u.pending;
|
|
3049
3096
|
u.pending = re(t.trigger), oe(t, new J(q.unavailable, { cause: e.message }), void 0);
|
|
@@ -3064,7 +3111,7 @@ function Jn(e) {
|
|
|
3064
3111
|
return;
|
|
3065
3112
|
case "takeover":
|
|
3066
3113
|
case "rate-limited": return;
|
|
3067
|
-
default:
|
|
3114
|
+
default: Kn(e);
|
|
3068
3115
|
}
|
|
3069
3116
|
}, Fe = () => {
|
|
3070
3117
|
C && !l.holding && l.post({
|
|
@@ -3129,7 +3176,7 @@ function Jn(e) {
|
|
|
3129
3176
|
case "refreshing":
|
|
3130
3177
|
case "backoff":
|
|
3131
3178
|
case "blocked-wait": return ae(u.pending, t);
|
|
3132
|
-
default: return
|
|
3179
|
+
default: return Kn(u);
|
|
3133
3180
|
}
|
|
3134
3181
|
}, V = (e) => {
|
|
3135
3182
|
if (f) return Promise.reject(new J(q.disposed));
|
|
@@ -3180,9 +3227,9 @@ function Jn(e) {
|
|
|
3180
3227
|
}, He = async (e, t) => {
|
|
3181
3228
|
if (f) throw new J(q.disposed);
|
|
3182
3229
|
ue();
|
|
3183
|
-
let n = T() +
|
|
3230
|
+
let n = T() + Gt;
|
|
3184
3231
|
if (await Be(n - T()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await ze("commit", n - T())) === "timeout") {
|
|
3185
|
-
let e = new
|
|
3232
|
+
let e = new Nn("lock-timeout");
|
|
3186
3233
|
throw F("upgrade.commit", "upgrade", e), e;
|
|
3187
3234
|
}
|
|
3188
3235
|
w = !0;
|
|
@@ -3229,7 +3276,7 @@ function Jn(e) {
|
|
|
3229
3276
|
if (!o) {
|
|
3230
3277
|
await i.applyOpaque(u), r.setTokensCache({
|
|
3231
3278
|
...n.getTokens() ?? {},
|
|
3232
|
-
...
|
|
3279
|
+
...Zn(u, void 0)
|
|
3233
3280
|
}), We(c);
|
|
3234
3281
|
let e = k();
|
|
3235
3282
|
return l.post(e === void 0 ? {
|
|
@@ -3241,9 +3288,9 @@ function Jn(e) {
|
|
|
3241
3288
|
sub: e
|
|
3242
3289
|
}), O();
|
|
3243
3290
|
}
|
|
3244
|
-
let d = N.commitSave(o,
|
|
3291
|
+
let d = N.commitSave(o, Zn(u, s));
|
|
3245
3292
|
if (d.kind === "saved") return We(c), le(o.order, c), O();
|
|
3246
|
-
let f = new
|
|
3293
|
+
let f = new Nn("superseded");
|
|
3247
3294
|
throw F("upgrade.commit", "upgrade", f), d.kind === "superseded" && d.adopted && L("adopted", "other-tab"), f;
|
|
3248
3295
|
}, We = (e) => {
|
|
3249
3296
|
if (L("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
|
|
@@ -3269,7 +3316,7 @@ function Jn(e) {
|
|
|
3269
3316
|
commitUpgrade: He,
|
|
3270
3317
|
signOut: async (e) => {
|
|
3271
3318
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3272
|
-
let t = T() +
|
|
3319
|
+
let t = T() + Kt;
|
|
3273
3320
|
H(), await Be(t - T()), H(), l.coordinated && !l.holding && await ze("logout", t - T());
|
|
3274
3321
|
try {
|
|
3275
3322
|
Ge(), await e(n.getTokens()?.refresh_token);
|
|
@@ -3314,7 +3361,7 @@ function Jn(e) {
|
|
|
3314
3361
|
// lib/store.ts
|
|
3315
3362
|
var Z = /* @__PURE__ */ function(e) {
|
|
3316
3363
|
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;
|
|
3317
|
-
}({}),
|
|
3364
|
+
}({}), $n = class {
|
|
3318
3365
|
constructor() {
|
|
3319
3366
|
this.subscribers = /* @__PURE__ */ new Map();
|
|
3320
3367
|
}
|
|
@@ -3333,7 +3380,7 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3333
3380
|
n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
|
|
3334
3381
|
}
|
|
3335
3382
|
notify(e, t) {
|
|
3336
|
-
e === "error" &&
|
|
3383
|
+
e === "error" && Nt(this, t?.originalError), this.subscribers.forEach((n, r) => {
|
|
3337
3384
|
(!n || n.has(e)) && r.onAuthChange?.(e, t);
|
|
3338
3385
|
});
|
|
3339
3386
|
}
|
|
@@ -3354,18 +3401,18 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3354
3401
|
twoFactorNotEnabled: "error.2fa.not_enabled",
|
|
3355
3402
|
notImplemented: "error.not.implemented",
|
|
3356
3403
|
tokenInvalid: "error.api.request.token.invalid"
|
|
3357
|
-
},
|
|
3404
|
+
}, er = Object.freeze([
|
|
3358
3405
|
Q.twoFactorCodeInvalid,
|
|
3359
3406
|
Q.twoFactorNotEnabled,
|
|
3360
3407
|
Q.challengeInvalid,
|
|
3361
3408
|
Q.challengeSessionMismatch,
|
|
3362
3409
|
Q.challengeTooManyAttempts
|
|
3363
|
-
]),
|
|
3410
|
+
]), tr = Object.freeze([Q.tokenInvalid]), nr = Object.freeze([
|
|
3364
3411
|
"wrong_code",
|
|
3365
3412
|
"challenge_spent",
|
|
3366
3413
|
"not_registered",
|
|
3367
3414
|
"prepare_not_required"
|
|
3368
|
-
]),
|
|
3415
|
+
]), rr = (e) => nr.includes(e), ir = {
|
|
3369
3416
|
wrong_code: "That code was not accepted. Try again.",
|
|
3370
3417
|
challenge_spent: "That verification challenge is no longer valid. Start again.",
|
|
3371
3418
|
exhausted: "Too many attempts. Try again later.",
|
|
@@ -3379,16 +3426,16 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3379
3426
|
session_changed: "The session ended during verification."
|
|
3380
3427
|
}, $ = class extends Error {
|
|
3381
3428
|
constructor(e) {
|
|
3382
|
-
super(e.message ||
|
|
3429
|
+
super(e.message || ir[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, this.retryable = rr(e.kind), e.cause !== void 0 && (this.cause = e.cause);
|
|
3383
3430
|
}
|
|
3384
|
-
},
|
|
3431
|
+
}, ar = Object.freeze([
|
|
3385
3432
|
"upgrade_transport",
|
|
3386
3433
|
"upgrade_insufficient",
|
|
3387
3434
|
"upgrade_unavailable",
|
|
3388
3435
|
"upgrade_session_changed",
|
|
3389
3436
|
"upgrade_cancelled",
|
|
3390
3437
|
"upgrade_unsatisfiable"
|
|
3391
|
-
]),
|
|
3438
|
+
]), or = (e) => typeof e == "object" && !!e && typeof e.code == "string" && ar.includes(e.code), sr = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", cr = (e) => {
|
|
3392
3439
|
if (typeof e != "object" || !e) return {
|
|
3393
3440
|
hasResponse: !1,
|
|
3394
3441
|
message: typeof e == "string" ? e : void 0
|
|
@@ -3400,7 +3447,7 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3400
3447
|
message: typeof t.message == "string" ? t.message : void 0,
|
|
3401
3448
|
hasResponse: n !== void 0 || typeof t.status == "number"
|
|
3402
3449
|
};
|
|
3403
|
-
},
|
|
3450
|
+
}, lr = (e, t) => {
|
|
3404
3451
|
switch (e) {
|
|
3405
3452
|
case Q.twoFactorCodeInvalid: return "wrong_code";
|
|
3406
3453
|
case Q.challengeInvalid:
|
|
@@ -3417,11 +3464,11 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3417
3464
|
case Q.tokenInvalid: return t === "refresh" ? "session_changed" : "fatal";
|
|
3418
3465
|
default: return;
|
|
3419
3466
|
}
|
|
3420
|
-
},
|
|
3467
|
+
}, ur = (e, t) => e === void 0 ? "network" : e === 501 ? "unavailable" : e === 400 ? "fatal" : e === 401 || e === 403 ? t === "start" ? "challenge_spent" : "session_changed" : e >= 500 ? "network" : "fatal", dr = (e, t) => {
|
|
3421
3468
|
if (e instanceof $) return e;
|
|
3422
|
-
let n =
|
|
3469
|
+
let n = cr(e);
|
|
3423
3470
|
return n.hasResponse ? new $({
|
|
3424
|
-
kind:
|
|
3471
|
+
kind: lr(n.errorId, t) ?? ur(n.status, t),
|
|
3425
3472
|
message: n.message,
|
|
3426
3473
|
status: n.status,
|
|
3427
3474
|
errorId: n.errorId,
|
|
@@ -3431,74 +3478,85 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3431
3478
|
message: n.message,
|
|
3432
3479
|
cause: e
|
|
3433
3480
|
});
|
|
3434
|
-
},
|
|
3481
|
+
}, fr = (e) => e.errorId !== void 0 && er.includes(e.errorId), pr = (e) => e.errorId !== void 0 && tr.includes(e.errorId), mr = class extends Error {
|
|
3435
3482
|
constructor(e, t, n) {
|
|
3436
3483
|
super(n ?? "The session was elevated, but this action requires a higher assurance level"), this.name = "UpgradeInsufficientError", this.code = "upgrade_insufficient", this.obtained = e, this.required = t;
|
|
3437
3484
|
}
|
|
3438
|
-
},
|
|
3485
|
+
}, hr = class extends Error {
|
|
3439
3486
|
constructor(e = "Step-up verification is not available on this deployment") {
|
|
3440
3487
|
super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
|
|
3441
3488
|
}
|
|
3442
|
-
},
|
|
3489
|
+
}, gr = class extends Error {
|
|
3443
3490
|
constructor(e = "The session changed during verification") {
|
|
3444
3491
|
super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
|
|
3445
3492
|
}
|
|
3446
|
-
},
|
|
3493
|
+
}, _r = (e) => {
|
|
3447
3494
|
if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
|
|
3448
3495
|
sub: e.sub,
|
|
3449
3496
|
sid: e.sid
|
|
3450
3497
|
} : { sub: e.sub };
|
|
3451
|
-
},
|
|
3498
|
+
}, vr = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
|
|
3452
3499
|
// lib/utils/validation.ts
|
|
3453
|
-
function
|
|
3500
|
+
function yr(e) {
|
|
3454
3501
|
if (!e || typeof e != "string") return !1;
|
|
3455
3502
|
let t = e.split(".");
|
|
3456
3503
|
if (t.length !== 3) return !1;
|
|
3457
3504
|
let n = /^[A-Za-z0-9_-]+$/;
|
|
3458
3505
|
return t.every((e) => n.test(e) && e.length > 0);
|
|
3459
3506
|
}
|
|
3460
|
-
function
|
|
3507
|
+
function br(e) {
|
|
3461
3508
|
return e.replace(/<[^>]*>/g, "").substring(0, 200);
|
|
3462
3509
|
}
|
|
3463
|
-
function
|
|
3510
|
+
function xr(e) {
|
|
3464
3511
|
if (!e || typeof e != "string") return !1;
|
|
3465
3512
|
let t = e.trim();
|
|
3466
3513
|
return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
|
|
3467
3514
|
}
|
|
3468
|
-
function
|
|
3515
|
+
function Sr(e) {
|
|
3469
3516
|
if (!e || typeof e != "string") return !1;
|
|
3470
3517
|
let t = e.trim();
|
|
3471
3518
|
return /^\+[1-9]\d{1,14}$/.test(t);
|
|
3472
3519
|
}
|
|
3473
|
-
function
|
|
3520
|
+
function Cr(e) {
|
|
3474
3521
|
if (!e || typeof e != "string") return !1;
|
|
3475
3522
|
let t = e.trim();
|
|
3476
3523
|
return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
|
|
3477
3524
|
}
|
|
3478
|
-
function
|
|
3525
|
+
function wr(e, t = 6) {
|
|
3479
3526
|
return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
|
|
3480
3527
|
}
|
|
3481
|
-
function
|
|
3528
|
+
function Tr(e) {
|
|
3482
3529
|
if (!e || typeof e != "string") return null;
|
|
3483
3530
|
let t = e.toUpperCase().replace(/\s+/g, "");
|
|
3484
3531
|
return /^[A-Z0-9-]{4,16}$/.test(t) ? t : null;
|
|
3485
3532
|
}
|
|
3486
3533
|
// lib/services/auth-service.ts
|
|
3487
|
-
var
|
|
3534
|
+
var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3, Ar = "passflow_federated_pkce", jr = 6e5, Mr = "AppId is required for federated auth", Nr = 10, Pr = "The sign-in answered with a PKCE code, but its verifier is gone", Fr = (e, t) => new Promise((n, r) => {
|
|
3535
|
+
if (t?.aborted) {
|
|
3536
|
+
r(t.reason);
|
|
3537
|
+
return;
|
|
3538
|
+
}
|
|
3539
|
+
let i = () => {
|
|
3540
|
+
clearTimeout(a), r(t?.reason);
|
|
3541
|
+
}, a = setTimeout(() => {
|
|
3542
|
+
t?.removeEventListener("abort", i), n();
|
|
3543
|
+
}, e);
|
|
3544
|
+
t?.addEventListener("abort", i, { once: !0 });
|
|
3545
|
+
}), Ir = (e) => {
|
|
3488
3546
|
if (!e) return;
|
|
3489
3547
|
let t = new URLSearchParams(e.search).get("token");
|
|
3490
3548
|
if (t) return t;
|
|
3491
3549
|
let n = e.hash.indexOf("?");
|
|
3492
3550
|
return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
|
|
3493
|
-
},
|
|
3551
|
+
}, Lr = (e) => {
|
|
3494
3552
|
if (e) try {
|
|
3495
3553
|
return A(e).email;
|
|
3496
3554
|
} catch {
|
|
3497
3555
|
return;
|
|
3498
3556
|
}
|
|
3499
|
-
},
|
|
3500
|
-
constructor(e, t, n, r, i, a, o, s, c, l, u, d = P, f, p = { coordination:
|
|
3501
|
-
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new ne(n), u?.enabled && this.tokenDeliveryManager.setMode(M.BFF), this.refresh =
|
|
3557
|
+
}, Rr = class {
|
|
3558
|
+
constructor(e, t, n, r, i, a, o, s, c, l, u, d = P, f, p = { coordination: dn() }) {
|
|
3559
|
+
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new ne(n), u?.enabled && this.tokenDeliveryManager.setMode(M.BFF), this.refresh = Qn({
|
|
3502
3560
|
emit: this.createRefreshEmit(),
|
|
3503
3561
|
storage: n,
|
|
3504
3562
|
cache: i,
|
|
@@ -3506,7 +3564,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3506
3564
|
coordination: p.coordination,
|
|
3507
3565
|
platform: d,
|
|
3508
3566
|
...p.strikes === void 0 ? {} : { strikes: p.strikes },
|
|
3509
|
-
logger:
|
|
3567
|
+
logger: bn()
|
|
3510
3568
|
}), this.initializeSession();
|
|
3511
3569
|
}
|
|
3512
3570
|
async initializeSession() {
|
|
@@ -3561,7 +3619,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3561
3619
|
rememberEmailChallenge(e, t) {
|
|
3562
3620
|
this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
|
|
3563
3621
|
for (let e of this.emailChallenges.keys()) {
|
|
3564
|
-
if (this.emailChallenges.size <=
|
|
3622
|
+
if (this.emailChallenges.size <= Nr) break;
|
|
3565
3623
|
this.emailChallenges.delete(e);
|
|
3566
3624
|
}
|
|
3567
3625
|
}
|
|
@@ -3569,14 +3627,14 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3569
3627
|
if (this.pendingPkce = {
|
|
3570
3628
|
verifier: e,
|
|
3571
3629
|
scopes: t,
|
|
3572
|
-
expiresAt: Date.now() +
|
|
3630
|
+
expiresAt: Date.now() + Dr
|
|
3573
3631
|
}, typeof sessionStorage < "u") try {
|
|
3574
|
-
sessionStorage.setItem(
|
|
3632
|
+
sessionStorage.setItem(Er, JSON.stringify(this.pendingPkce));
|
|
3575
3633
|
} catch {}
|
|
3576
3634
|
}
|
|
3577
3635
|
readPendingPkce() {
|
|
3578
3636
|
if (!this.pendingPkce && typeof sessionStorage < "u") try {
|
|
3579
|
-
let e = sessionStorage.getItem(
|
|
3637
|
+
let e = sessionStorage.getItem(Er);
|
|
3580
3638
|
this.pendingPkce = e ? JSON.parse(e) : void 0;
|
|
3581
3639
|
} catch {
|
|
3582
3640
|
this.pendingPkce = void 0;
|
|
@@ -3588,7 +3646,49 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3588
3646
|
}
|
|
3589
3647
|
forgetPkceSignIn() {
|
|
3590
3648
|
if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
|
|
3591
|
-
sessionStorage.removeItem(
|
|
3649
|
+
sessionStorage.removeItem(Er);
|
|
3650
|
+
} catch {}
|
|
3651
|
+
}
|
|
3652
|
+
rememberPendingPasswordless(e) {
|
|
3653
|
+
if (this.pendingPasswordless = e, typeof sessionStorage < "u") try {
|
|
3654
|
+
sessionStorage.setItem(Or, JSON.stringify(e));
|
|
3655
|
+
} catch {}
|
|
3656
|
+
}
|
|
3657
|
+
readPendingPasswordless() {
|
|
3658
|
+
if (!this.pendingPasswordless && typeof sessionStorage < "u") try {
|
|
3659
|
+
let e = sessionStorage.getItem(Or);
|
|
3660
|
+
this.pendingPasswordless = e ? JSON.parse(e) : void 0;
|
|
3661
|
+
} catch {
|
|
3662
|
+
this.pendingPasswordless = void 0;
|
|
3663
|
+
}
|
|
3664
|
+
return this.pendingPasswordless && !(Date.now() < this.pendingPasswordless.expiresAt) && this.forgetPendingPasswordless(), this.pendingPasswordless;
|
|
3665
|
+
}
|
|
3666
|
+
forgetPendingPasswordless() {
|
|
3667
|
+
if (this.pendingPasswordless = void 0, typeof sessionStorage < "u") try {
|
|
3668
|
+
sessionStorage.removeItem(Or);
|
|
3669
|
+
} catch {}
|
|
3670
|
+
}
|
|
3671
|
+
rememberFederatedSlot(e, t) {
|
|
3672
|
+
if (this.federatedSlot = {
|
|
3673
|
+
verifier: e,
|
|
3674
|
+
scopes: t,
|
|
3675
|
+
expiresAt: Date.now() + jr
|
|
3676
|
+
}, typeof sessionStorage < "u") try {
|
|
3677
|
+
sessionStorage.setItem(Ar, JSON.stringify(this.federatedSlot));
|
|
3678
|
+
} catch {}
|
|
3679
|
+
}
|
|
3680
|
+
readFederatedSlot() {
|
|
3681
|
+
if (!this.federatedSlot && typeof sessionStorage < "u") try {
|
|
3682
|
+
let e = sessionStorage.getItem(Ar);
|
|
3683
|
+
this.federatedSlot = e ? JSON.parse(e) : void 0;
|
|
3684
|
+
} catch {
|
|
3685
|
+
this.federatedSlot = void 0;
|
|
3686
|
+
}
|
|
3687
|
+
return this.federatedSlot && Date.now() < this.federatedSlot.expiresAt ? this.federatedSlot : void 0;
|
|
3688
|
+
}
|
|
3689
|
+
forgetFederatedSlot() {
|
|
3690
|
+
if (this.federatedSlot = void 0, typeof sessionStorage < "u") try {
|
|
3691
|
+
sessionStorage.removeItem(Ar);
|
|
3592
3692
|
} catch {}
|
|
3593
3693
|
}
|
|
3594
3694
|
async startPkce() {
|
|
@@ -3596,17 +3696,17 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3596
3696
|
try {
|
|
3597
3697
|
e = await this.readPkceEnabled?.() ?? !1;
|
|
3598
3698
|
} catch (e) {
|
|
3599
|
-
|
|
3699
|
+
bn().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
|
|
3600
3700
|
return;
|
|
3601
3701
|
}
|
|
3602
|
-
return e ?
|
|
3702
|
+
return e ? vn() : void 0;
|
|
3603
3703
|
}
|
|
3604
3704
|
async exchangeCode(e, t) {
|
|
3605
3705
|
return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
|
|
3606
3706
|
}
|
|
3607
3707
|
async completePkceSignIn(e) {
|
|
3608
3708
|
let t = this.readPendingPkce();
|
|
3609
|
-
if (!t) throw Error(
|
|
3709
|
+
if (!t) throw Error(Pr);
|
|
3610
3710
|
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
3611
3711
|
return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
|
|
3612
3712
|
}
|
|
@@ -3630,7 +3730,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3630
3730
|
if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
|
|
3631
3731
|
}
|
|
3632
3732
|
async signIn(e) {
|
|
3633
|
-
if ("email" in e && e.email && !
|
|
3733
|
+
if ("email" in e && e.email && !xr(e.email)) {
|
|
3634
3734
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3635
3735
|
operation: "sign-in",
|
|
3636
3736
|
message: "Invalid email format",
|
|
@@ -3639,7 +3739,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3639
3739
|
};
|
|
3640
3740
|
throw W(this.subscribeStore, t), e;
|
|
3641
3741
|
}
|
|
3642
|
-
if ("username" in e && e.username && !
|
|
3742
|
+
if ("username" in e && e.username && !Cr(e.username)) {
|
|
3643
3743
|
let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
|
|
3644
3744
|
operation: "sign-in",
|
|
3645
3745
|
message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
|
|
@@ -3648,7 +3748,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3648
3748
|
};
|
|
3649
3749
|
throw W(this.subscribeStore, t), e;
|
|
3650
3750
|
}
|
|
3651
|
-
if ("phone" in e && e.phone && !
|
|
3751
|
+
if ("phone" in e && e.phone && !Sr(e.phone)) {
|
|
3652
3752
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3653
3753
|
operation: "sign-in",
|
|
3654
3754
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -3682,7 +3782,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3682
3782
|
}
|
|
3683
3783
|
}
|
|
3684
3784
|
async signUp(e) {
|
|
3685
|
-
if (e.user.email && !
|
|
3785
|
+
if (e.user.email && !xr(e.user.email)) {
|
|
3686
3786
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3687
3787
|
operation: "sign-up",
|
|
3688
3788
|
message: "Invalid email format",
|
|
@@ -3691,7 +3791,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3691
3791
|
};
|
|
3692
3792
|
throw W(this.subscribeStore, t), e;
|
|
3693
3793
|
}
|
|
3694
|
-
if (e.user.phone_number && !
|
|
3794
|
+
if (e.user.phone_number && !Sr(e.user.phone_number)) {
|
|
3695
3795
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3696
3796
|
operation: "sign-up",
|
|
3697
3797
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -3723,7 +3823,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3723
3823
|
}
|
|
3724
3824
|
}
|
|
3725
3825
|
async passwordlessSignIn(e) {
|
|
3726
|
-
if (e.email && !
|
|
3826
|
+
if (e.email && !xr(e.email)) {
|
|
3727
3827
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3728
3828
|
operation: "passwordless.start",
|
|
3729
3829
|
message: "Invalid email format",
|
|
@@ -3732,7 +3832,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3732
3832
|
};
|
|
3733
3833
|
throw W(this.subscribeStore, t), e;
|
|
3734
3834
|
}
|
|
3735
|
-
if (e.phone && !
|
|
3835
|
+
if (e.phone && !Sr(e.phone)) {
|
|
3736
3836
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3737
3837
|
operation: "passwordless.start",
|
|
3738
3838
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -3741,10 +3841,23 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3741
3841
|
};
|
|
3742
3842
|
throw W(this.subscribeStore, t), e;
|
|
3743
3843
|
}
|
|
3744
|
-
this.subscribeStore.notify(Z.SignInStart, { email: e.email })
|
|
3745
|
-
let t = this.deviceService.getDeviceId(),
|
|
3844
|
+
this.subscribeStore.notify(Z.SignInStart, { email: e.email });
|
|
3845
|
+
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId(), r = Le(this.platform.getDeviceType());
|
|
3746
3846
|
try {
|
|
3747
|
-
|
|
3847
|
+
let i = await this.startPkce(), a = await this.authApi.passwordlessSignIn({
|
|
3848
|
+
...e,
|
|
3849
|
+
scopes: t,
|
|
3850
|
+
...i ? { code_challenge: i.challenge } : {}
|
|
3851
|
+
}, n, r);
|
|
3852
|
+
return i && a.challenge_id ? this.rememberPendingPasswordless({
|
|
3853
|
+
challengeId: a.challenge_id,
|
|
3854
|
+
verifier: i.verifier,
|
|
3855
|
+
codeChallenge: i.challenge,
|
|
3856
|
+
matchCode: a.match_code,
|
|
3857
|
+
email: e.email,
|
|
3858
|
+
scopes: t,
|
|
3859
|
+
expiresAt: new Date(a.expires_at).getTime()
|
|
3860
|
+
}) : this.forgetPendingPasswordless(), a;
|
|
3748
3861
|
} catch (e) {
|
|
3749
3862
|
let t = {
|
|
3750
3863
|
operation: "passwordless.start",
|
|
@@ -3757,13 +3870,31 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3757
3870
|
}
|
|
3758
3871
|
async passwordlessSignInComplete(e) {
|
|
3759
3872
|
this.subscribeStore.notify(Z.SignInStart, {}), e.scopes = e.scopes ?? this.scopes, e.device = this.deviceService.getDeviceId();
|
|
3873
|
+
let t = this.readPendingPasswordless(), n = t?.challengeId === e.challenge_id ? t : void 0, r = !1;
|
|
3760
3874
|
try {
|
|
3761
3875
|
let t = await this.authApi.passwordlessSignInComplete(e);
|
|
3762
|
-
|
|
3763
|
-
|
|
3876
|
+
if (r = !0, this.handlePendingSecondFactor(t, n?.email, n && { verifier: n.verifier }, n?.scopes)) return this.forgetPendingPasswordless(), t;
|
|
3877
|
+
let i = t;
|
|
3878
|
+
if (t.code) {
|
|
3879
|
+
if (!n) throw Error(Pr);
|
|
3880
|
+
if (i = await this.authApi.pkceExchange(t.code, n.verifier), this.handlePendingSecondFactor(i)) return this.forgetPendingPasswordless(), {
|
|
3881
|
+
...i,
|
|
3882
|
+
redirect_url: t.redirect_url ?? ""
|
|
3883
|
+
};
|
|
3884
|
+
}
|
|
3885
|
+
let a = t.redirect_url ? {
|
|
3886
|
+
...i,
|
|
3887
|
+
redirect_url: t.redirect_url
|
|
3888
|
+
} : i;
|
|
3889
|
+
return await this.processAuthResponse(a, n?.scopes ?? e.scopes), this.forgetPendingPasswordless(), this.subscribeStore.notify(Z.SignIn, {
|
|
3890
|
+
tokens: a,
|
|
3764
3891
|
parsedTokens: this.tokenCacheService.getParsedTokens()
|
|
3765
|
-
}), await this.submitSessionCheck()
|
|
3892
|
+
}), await this.submitSessionCheck(), {
|
|
3893
|
+
...a,
|
|
3894
|
+
redirect_url: t.redirect_url ?? ""
|
|
3895
|
+
};
|
|
3766
3896
|
} catch (e) {
|
|
3897
|
+
r && this.forgetPendingPasswordless();
|
|
3767
3898
|
let t = {
|
|
3768
3899
|
operation: "passwordless.complete",
|
|
3769
3900
|
message: e instanceof Error ? e.message : "Passwordless sign in failed",
|
|
@@ -3773,18 +3904,101 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3773
3904
|
throw W(this.subscribeStore, t), e;
|
|
3774
3905
|
}
|
|
3775
3906
|
}
|
|
3907
|
+
async waitForPasswordlessSignIn(e, t) {
|
|
3908
|
+
let n = t?.signal;
|
|
3909
|
+
try {
|
|
3910
|
+
let t = this.readPendingPasswordless();
|
|
3911
|
+
if (t?.challengeId !== e) throw Error(Pr);
|
|
3912
|
+
for (;;) {
|
|
3913
|
+
if (n?.aborted) throw n.reason;
|
|
3914
|
+
if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
|
|
3915
|
+
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(Pr);
|
|
3916
|
+
let r;
|
|
3917
|
+
try {
|
|
3918
|
+
r = await this.authApi.passwordlessStatus({
|
|
3919
|
+
challenge_id: e,
|
|
3920
|
+
code_challenge: t.codeChallenge
|
|
3921
|
+
}, { signal: n });
|
|
3922
|
+
} catch (e) {
|
|
3923
|
+
if (n?.aborted) throw n.reason;
|
|
3924
|
+
if (e instanceof B && e.status >= 400 && e.status < 500 && e.status !== 429) throw this.forgetPendingPasswordless(), e;
|
|
3925
|
+
}
|
|
3926
|
+
if (r?.status === "denied" || r?.status === "expired" || r?.status === "completed") return this.forgetPendingPasswordless(), { status: r.status };
|
|
3927
|
+
if (r?.status === "approved" && r.code) return await this.finishApprovedPasswordless(r.code, t);
|
|
3928
|
+
await Fr(kr, n);
|
|
3929
|
+
}
|
|
3930
|
+
} catch (e) {
|
|
3931
|
+
if (n?.aborted && e === n.reason) throw e;
|
|
3932
|
+
let t = {
|
|
3933
|
+
operation: "passwordless.wait",
|
|
3934
|
+
message: e instanceof Error ? e.message : "Waiting for the passwordless sign-in failed",
|
|
3935
|
+
originalError: e,
|
|
3936
|
+
code: e instanceof B ? e.id : void 0
|
|
3937
|
+
};
|
|
3938
|
+
throw W(this.subscribeStore, t), e;
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
async finishApprovedPasswordless(e, t) {
|
|
3942
|
+
try {
|
|
3943
|
+
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
3944
|
+
return this.handlePendingSecondFactor(n, t.email) ? (this.forgetPendingPasswordless(), { status: "second-factor-required" }) : (await this.processAuthResponse(n, t.scopes), this.forgetPendingPasswordless(), this.subscribeStore.notify(Z.SignIn, {
|
|
3945
|
+
tokens: n,
|
|
3946
|
+
parsedTokens: this.tokenCacheService.getParsedTokens()
|
|
3947
|
+
}), await this.submitSessionCheck(), {
|
|
3948
|
+
status: "signed-in",
|
|
3949
|
+
tokens: n
|
|
3950
|
+
});
|
|
3951
|
+
} catch (e) {
|
|
3952
|
+
throw this.forgetPendingPasswordless(), e;
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
getPendingPasswordlessSignIn(e) {
|
|
3956
|
+
let t = this.readPendingPasswordless();
|
|
3957
|
+
if (t?.challengeId === e && t.matchCode) return {
|
|
3958
|
+
matchCode: t.matchCode,
|
|
3959
|
+
expiresAt: t.expiresAt
|
|
3960
|
+
};
|
|
3961
|
+
}
|
|
3962
|
+
async getPasswordlessApproval(e) {
|
|
3963
|
+
try {
|
|
3964
|
+
return await this.authApi.passwordlessApprovalInfo({ challenge_id: e });
|
|
3965
|
+
} catch (e) {
|
|
3966
|
+
throw this.reportApprovalFailure(e), e;
|
|
3967
|
+
}
|
|
3968
|
+
}
|
|
3969
|
+
async decidePasswordlessApproval(e, t, n, r) {
|
|
3970
|
+
try {
|
|
3971
|
+
await this.authApi.passwordlessApprovalDecide({
|
|
3972
|
+
challenge_id: e,
|
|
3973
|
+
otp: t,
|
|
3974
|
+
approve: n,
|
|
3975
|
+
match_code: r
|
|
3976
|
+
});
|
|
3977
|
+
} catch (e) {
|
|
3978
|
+
throw this.reportApprovalFailure(e), e;
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
reportApprovalFailure(e) {
|
|
3982
|
+
let t = {
|
|
3983
|
+
operation: "passwordless.approval",
|
|
3984
|
+
message: e instanceof Error ? e.message : "Passwordless approval failed",
|
|
3985
|
+
originalError: e,
|
|
3986
|
+
code: e instanceof B ? e.id : void 0
|
|
3987
|
+
};
|
|
3988
|
+
W(this.subscribeStore, t);
|
|
3989
|
+
}
|
|
3776
3990
|
async verifyEmailCode(e) {
|
|
3777
3991
|
let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
|
|
3778
3992
|
try {
|
|
3779
3993
|
let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
|
|
3780
|
-
if (t?.pkce && !r) throw Error(
|
|
3994
|
+
if (t?.pkce && !r) throw Error(Pr);
|
|
3781
3995
|
let i = await this.authApi.validateEmailCode(e);
|
|
3782
3996
|
this.emailChallenges.delete(e.challenge_id);
|
|
3783
3997
|
let a = r?.scopes ?? t?.scopes ?? this.scopes;
|
|
3784
3998
|
if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
|
|
3785
3999
|
let o = i;
|
|
3786
4000
|
if (i.code) {
|
|
3787
|
-
if (!r) throw Error(
|
|
4001
|
+
if (!r) throw Error(Pr);
|
|
3788
4002
|
if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
|
|
3789
4003
|
}
|
|
3790
4004
|
let s = i.redirect_url ? {
|
|
@@ -3808,7 +4022,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3808
4022
|
async logOut() {
|
|
3809
4023
|
let e = this.refresh.identity();
|
|
3810
4024
|
return await this.refresh.signOut(async (e) => {
|
|
3811
|
-
await this.callLogoutApi(e), this.forgetPkceSignIn(), this.emailChallenges.clear(), this.clearLocalSession();
|
|
4025
|
+
await this.callLogoutApi(e), this.forgetPkceSignIn(), this.forgetPendingPasswordless(), this.emailChallenges.clear(), this.clearLocalSession();
|
|
3812
4026
|
}), e;
|
|
3813
4027
|
}
|
|
3814
4028
|
resetSession() {
|
|
@@ -3838,13 +4052,13 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3838
4052
|
readSessionPin() {
|
|
3839
4053
|
try {
|
|
3840
4054
|
let e = this.storageManager.getToken(j.access_token);
|
|
3841
|
-
return e ?
|
|
4055
|
+
return e ? _r(A(e)) : void 0;
|
|
3842
4056
|
} catch {
|
|
3843
4057
|
return;
|
|
3844
4058
|
}
|
|
3845
4059
|
}
|
|
3846
4060
|
assertSessionPin(e) {
|
|
3847
|
-
if (e && !
|
|
4061
|
+
if (e && !vr(e, this.readSessionPin())) throw console.warn("[passflow] the session or user changed while a step-up upgrade was in flight; the elevated tokens were discarded and the live session was left untouched."), new gr("The session changed during verification, so the elevated tokens were discarded");
|
|
3848
4062
|
}
|
|
3849
4063
|
refreshMode() {
|
|
3850
4064
|
return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
|
|
@@ -3892,7 +4106,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3892
4106
|
case "signout":
|
|
3893
4107
|
n.notify(Z.SignOut, t);
|
|
3894
4108
|
return;
|
|
3895
|
-
default:
|
|
4109
|
+
default: bn().warn(`[passflow] Unknown refresh event: ${String(e)}`);
|
|
3896
4110
|
}
|
|
3897
4111
|
};
|
|
3898
4112
|
}
|
|
@@ -3978,10 +4192,10 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3978
4192
|
}
|
|
3979
4193
|
async resetPassword(e, t, n) {
|
|
3980
4194
|
this.subscribeStore.notify(Z.SignInStart, {});
|
|
3981
|
-
let r = n ??
|
|
4195
|
+
let r = n ?? Ir(this.platform.getCurrentUrl()), i = t ?? this.scopes;
|
|
3982
4196
|
try {
|
|
3983
4197
|
let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
|
|
3984
|
-
if (this.handleEmailVerificationStep(n, "reset-password",
|
|
4198
|
+
if (this.handleEmailVerificationStep(n, "reset-password", Lr(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
|
|
3985
4199
|
let a = await this.exchangeCode(n, t);
|
|
3986
4200
|
if (this.handlePendingSecondFactor(a)) return a;
|
|
3987
4201
|
let o = n.redirect_url ? {
|
|
@@ -4062,41 +4276,54 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4062
4276
|
}
|
|
4063
4277
|
createFederatedAuthUrl(e) {
|
|
4064
4278
|
let t = `/auth/federated/start/${e.provider}`;
|
|
4065
|
-
if (!this.appId) throw Error(
|
|
4279
|
+
if (!this.appId) throw Error(Mr);
|
|
4066
4280
|
let n = {
|
|
4067
4281
|
scopes: (e.scopes ?? this.scopes).join(" "),
|
|
4068
4282
|
redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
|
|
4069
4283
|
appId: this.appId,
|
|
4070
4284
|
...e.invite_token ? { invite_token: e.invite_token } : {},
|
|
4071
4285
|
...e.create_tenant ? { create_tenant: e.create_tenant.toString() } : {},
|
|
4072
|
-
...e.device ? { device: e.device } : {}
|
|
4286
|
+
...e.device ? { device: e.device } : {},
|
|
4287
|
+
...e.code_challenge ? { code_challenge: e.code_challenge } : {},
|
|
4288
|
+
...e.code_challenge_method ? { code_challenge_method: e.code_challenge_method } : {}
|
|
4073
4289
|
}, r = new URL(t, this.url);
|
|
4074
4290
|
return r.search = new URLSearchParams(n).toString(), r.toString();
|
|
4075
4291
|
}
|
|
4076
4292
|
async federatedAuthWithPopup(e) {
|
|
4077
|
-
this.subscribeStore.notify(Z.SignInStart, { provider: e.provider });
|
|
4078
|
-
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId()
|
|
4079
|
-
...e,
|
|
4080
|
-
scopes: t,
|
|
4081
|
-
device: n
|
|
4082
|
-
});
|
|
4293
|
+
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(Mr);
|
|
4294
|
+
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
|
|
4083
4295
|
try {
|
|
4084
|
-
|
|
4296
|
+
this.forgetFederatedSlot();
|
|
4297
|
+
let r = await this.startPkce(), i = this.createFederatedAuthUrl({
|
|
4298
|
+
...e,
|
|
4299
|
+
scopes: t,
|
|
4300
|
+
device: n,
|
|
4301
|
+
...r ? {
|
|
4302
|
+
code_challenge: r.challenge,
|
|
4303
|
+
code_challenge_method: "S256"
|
|
4304
|
+
} : {}
|
|
4305
|
+
}), a = this.platform.openAuthUrl(i, {
|
|
4085
4306
|
mode: "popup",
|
|
4086
4307
|
expectedReturnOrigin: this.platform.getCurrentUrl()?.origin ?? ""
|
|
4087
|
-
})
|
|
4088
|
-
|
|
4089
|
-
let
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4308
|
+
});
|
|
4309
|
+
r && this.rememberFederatedSlot(r.verifier, t);
|
|
4310
|
+
let o = await a;
|
|
4311
|
+
this.forgetFederatedSlot();
|
|
4312
|
+
let s = new URLSearchParams(o.callbackHash.replace(/^#/, ""));
|
|
4313
|
+
if (this.handlePendingSecondFactor({ tfa_token: s.get("tfa_token") ?? void 0 })) return;
|
|
4314
|
+
let c = new URLSearchParams(o.callbackSearch), l = c.get("code"), u = c.get("access_token") || "", d = c.get("refresh_token") || "", f = c.get("id_token") || "", p = {
|
|
4315
|
+
access_token: u,
|
|
4316
|
+
refresh_token: d || void 0,
|
|
4317
|
+
id_token: f || void 0,
|
|
4093
4318
|
scopes: t
|
|
4094
4319
|
};
|
|
4095
|
-
await this.
|
|
4096
|
-
|
|
4320
|
+
if (l && r && (p = await this.authApi.pkceExchange(l, r.verifier), this.handlePendingSecondFactor(p))) return;
|
|
4321
|
+
await this.processAuthResponse(p, t), this.subscribeStore.notify(Z.SignIn, {
|
|
4322
|
+
tokens: p,
|
|
4097
4323
|
parsedTokens: this.tokenCacheService.getParsedTokens()
|
|
4098
4324
|
}), this.platform.navigateTo(this.platform.getCurrentUrl()?.origin ?? "");
|
|
4099
4325
|
} catch (e) {
|
|
4326
|
+
this.forgetFederatedSlot();
|
|
4100
4327
|
let t = {
|
|
4101
4328
|
operation: "federated.popup",
|
|
4102
4329
|
message: e instanceof Error ? e.message : "Authentication failed",
|
|
@@ -4107,13 +4334,47 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4107
4334
|
}
|
|
4108
4335
|
}
|
|
4109
4336
|
federatedAuthWithRedirect(e) {
|
|
4110
|
-
this.subscribeStore.notify(Z.SignInStart, { provider: e.provider });
|
|
4111
|
-
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId()
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4337
|
+
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(Mr);
|
|
4338
|
+
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
|
|
4339
|
+
this.startPkce().then((r) => {
|
|
4340
|
+
let i = this.createFederatedAuthUrl({
|
|
4341
|
+
...e,
|
|
4342
|
+
scopes: t,
|
|
4343
|
+
device: n,
|
|
4344
|
+
...r ? {
|
|
4345
|
+
code_challenge: r.challenge,
|
|
4346
|
+
code_challenge_method: "S256"
|
|
4347
|
+
} : {}
|
|
4348
|
+
});
|
|
4349
|
+
r ? this.rememberFederatedSlot(r.verifier, t) : this.forgetFederatedSlot(), this.platform.navigateTo(i);
|
|
4350
|
+
}).catch((e) => this.reportFederatedRedirectFailure(e));
|
|
4351
|
+
}
|
|
4352
|
+
handleFederatedCode(e) {
|
|
4353
|
+
if (!this.appId) return !1;
|
|
4354
|
+
let t = this.readFederatedSlot();
|
|
4355
|
+
return t ? (this.forgetFederatedSlot(), this.finishFederatedLanding(e, t), !0) : !1;
|
|
4356
|
+
}
|
|
4357
|
+
async finishFederatedLanding(e, t) {
|
|
4358
|
+
try {
|
|
4359
|
+
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
4360
|
+
if (this.handlePendingSecondFactor(n)) return;
|
|
4361
|
+
await this.processAuthResponse(n, t.scopes), this.subscribeStore.notify(Z.SignIn, {
|
|
4362
|
+
tokens: n,
|
|
4363
|
+
parsedTokens: this.tokenCacheService.getParsedTokens(),
|
|
4364
|
+
source: "federated-landing"
|
|
4365
|
+
}), await this.submitSessionCheck();
|
|
4366
|
+
} catch (e) {
|
|
4367
|
+
this.reportFederatedRedirectFailure(e);
|
|
4368
|
+
}
|
|
4369
|
+
}
|
|
4370
|
+
reportFederatedRedirectFailure(e) {
|
|
4371
|
+
let t = {
|
|
4372
|
+
operation: "federated.redirect",
|
|
4373
|
+
message: e instanceof Error ? e.message : "Federated sign-in failed",
|
|
4374
|
+
originalError: e,
|
|
4375
|
+
code: e instanceof B ? e.id : void 0
|
|
4376
|
+
};
|
|
4377
|
+
W(this.subscribeStore, t);
|
|
4117
4378
|
}
|
|
4118
4379
|
authRedirectUrl(e = {}) {
|
|
4119
4380
|
try {
|
|
@@ -4203,7 +4464,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4203
4464
|
return;
|
|
4204
4465
|
}
|
|
4205
4466
|
}
|
|
4206
|
-
},
|
|
4467
|
+
}, zr = class {
|
|
4207
4468
|
constructor(e) {
|
|
4208
4469
|
this.invitationApi = e;
|
|
4209
4470
|
}
|
|
@@ -4222,7 +4483,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4222
4483
|
getInvitationLink(e) {
|
|
4223
4484
|
return this.invitationApi.getInvitationLink(e);
|
|
4224
4485
|
}
|
|
4225
|
-
},
|
|
4486
|
+
}, Br = class {
|
|
4226
4487
|
constructor(e) {
|
|
4227
4488
|
this.data = this.normalize(e);
|
|
4228
4489
|
}
|
|
@@ -4279,9 +4540,9 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4279
4540
|
getData() {
|
|
4280
4541
|
return this.data;
|
|
4281
4542
|
}
|
|
4282
|
-
},
|
|
4543
|
+
}, Vr = class {
|
|
4283
4544
|
constructor(e, t, n) {
|
|
4284
|
-
this.tenantApi = e, this.scopes = t, this.logger = n ||
|
|
4545
|
+
this.tenantApi = e, this.scopes = t, this.logger = n || bn();
|
|
4285
4546
|
}
|
|
4286
4547
|
handlePassflowError(t, n) {
|
|
4287
4548
|
if (e.isAxiosError(t) && t.response?.data) {
|
|
@@ -4317,7 +4578,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4317
4578
|
}
|
|
4318
4579
|
async getTenantUserMembership(e) {
|
|
4319
4580
|
try {
|
|
4320
|
-
return new
|
|
4581
|
+
return new Br(await this.tenantApi.getTenantDetails(e));
|
|
4321
4582
|
} catch (t) {
|
|
4322
4583
|
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
4323
4584
|
}
|
|
@@ -4462,7 +4723,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4462
4723
|
this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
|
|
4463
4724
|
}
|
|
4464
4725
|
}
|
|
4465
|
-
},
|
|
4726
|
+
}, Hr = class {
|
|
4466
4727
|
constructor(e, t, n, r = P) {
|
|
4467
4728
|
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();
|
|
4468
4729
|
}
|
|
@@ -4542,7 +4803,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4542
4803
|
isExpired() {
|
|
4543
4804
|
return this.tokensCache ? this.tokensCache.access_token ? k(A(this.tokensCache.access_token)) : !1 : !0;
|
|
4544
4805
|
}
|
|
4545
|
-
},
|
|
4806
|
+
}, Ur = class {
|
|
4546
4807
|
constructor(e, t, n) {
|
|
4547
4808
|
this.twoFactorApi = e, this.subscribeStore = t, this.signInCompleter = n, this.PARTIAL_AUTH_TIMEOUT_MS = 3e5, this.SESSION_STORAGE_KEY = "passflow_2fa_challenge", this.totpDigits = 6, this.subscribeStore.subscribe({ onAuthChange: (e, t) => {
|
|
4548
4809
|
if (e === Z.TwoFactorRequired) {
|
|
@@ -4582,7 +4843,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4582
4843
|
}
|
|
4583
4844
|
}
|
|
4584
4845
|
async confirmSetup(e) {
|
|
4585
|
-
if (!
|
|
4846
|
+
if (!wr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4586
4847
|
try {
|
|
4587
4848
|
let t = await this.twoFactorApi.confirmSetup({ code: e });
|
|
4588
4849
|
return this.subscribeStore.notify(Z.TwoFactorEnabled, {
|
|
@@ -4596,7 +4857,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4596
4857
|
}
|
|
4597
4858
|
}
|
|
4598
4859
|
async verify(e, t) {
|
|
4599
|
-
if (!
|
|
4860
|
+
if (!wr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4600
4861
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4601
4862
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
4602
4863
|
try {
|
|
@@ -4612,7 +4873,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4612
4873
|
}
|
|
4613
4874
|
async useRecoveryCode(e, t) {
|
|
4614
4875
|
try {
|
|
4615
|
-
let n =
|
|
4876
|
+
let n = Tr(e);
|
|
4616
4877
|
if (!n) throw Error("Invalid recovery code format. Expected format: XXXX-XXXX or XXXXXXXX (alphanumeric).");
|
|
4617
4878
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4618
4879
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
@@ -4633,7 +4894,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4633
4894
|
}
|
|
4634
4895
|
}
|
|
4635
4896
|
async disable(e) {
|
|
4636
|
-
if (!
|
|
4897
|
+
if (!wr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4637
4898
|
try {
|
|
4638
4899
|
let t = await this.twoFactorApi.disable({ code: e });
|
|
4639
4900
|
return this.subscribeStore.notify(Z.TwoFactorDisabled, {}), t;
|
|
@@ -4642,7 +4903,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4642
4903
|
}
|
|
4643
4904
|
}
|
|
4644
4905
|
async regenerateRecoveryCodes(e) {
|
|
4645
|
-
if (!
|
|
4906
|
+
if (!wr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4646
4907
|
try {
|
|
4647
4908
|
let t = await this.twoFactorApi.regenerateRecoveryCodes({ code: e }), n = [...t.recovery_codes];
|
|
4648
4909
|
return t.recovery_codes = [], t.recovery_codes = n, t;
|
|
@@ -4826,7 +5087,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4826
5087
|
this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
|
|
4827
5088
|
}
|
|
4828
5089
|
}
|
|
4829
|
-
},
|
|
5090
|
+
}, Wr = class {
|
|
4830
5091
|
constructor(e, t, n = P) {
|
|
4831
5092
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
4832
5093
|
}
|
|
@@ -4853,69 +5114,69 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4853
5114
|
if (!s) throw Error("Passkey registration was not completed");
|
|
4854
5115
|
return await this.userAPI.addUserPasskeyComplete(s, r, a);
|
|
4855
5116
|
}
|
|
4856
|
-
},
|
|
5117
|
+
}, Gr = class extends Error {
|
|
4857
5118
|
constructor(e, t, n = !1) {
|
|
4858
5119
|
super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
|
|
4859
5120
|
}
|
|
4860
|
-
},
|
|
5121
|
+
}, Kr = (e, t) => {
|
|
4861
5122
|
let n = t?.trim();
|
|
4862
|
-
if (!n) throw new
|
|
5123
|
+
if (!n) throw new Gr(e, "A verification code is required");
|
|
4863
5124
|
return n;
|
|
4864
|
-
},
|
|
5125
|
+
}, qr = {
|
|
4865
5126
|
type: "totp",
|
|
4866
5127
|
requiresPrepare: !1,
|
|
4867
5128
|
input: "code",
|
|
4868
|
-
assert: async ({ code: e }) => ({ code:
|
|
4869
|
-
},
|
|
5129
|
+
assert: async ({ code: e }) => ({ code: Kr("totp", e) })
|
|
5130
|
+
}, Jr = {
|
|
4870
5131
|
type: "recovery_codes",
|
|
4871
5132
|
requiresPrepare: !1,
|
|
4872
5133
|
input: "code",
|
|
4873
|
-
assert: async ({ code: e }) => ({ code:
|
|
4874
|
-
},
|
|
5134
|
+
assert: async ({ code: e }) => ({ code: Kr("recovery_codes", e) })
|
|
5135
|
+
}, Yr = {
|
|
4875
5136
|
type: "passkey",
|
|
4876
5137
|
requiresPrepare: !0,
|
|
4877
5138
|
input: "none",
|
|
4878
5139
|
assert: async ({ prepared: e, platform: t }) => {
|
|
4879
|
-
if (!e?.webauthn) throw new
|
|
5140
|
+
if (!e?.webauthn) throw new Gr("passkey", "The upgrade challenge carried no WebAuthn options");
|
|
4880
5141
|
let n = t.passkeys;
|
|
4881
|
-
if (!n) throw new
|
|
5142
|
+
if (!n) throw new Gr("passkey", "This platform does not support passkeys");
|
|
4882
5143
|
let r;
|
|
4883
5144
|
try {
|
|
4884
5145
|
r = await n.startAuthentication(e.webauthn);
|
|
4885
5146
|
} catch (e) {
|
|
4886
|
-
throw new
|
|
5147
|
+
throw new Gr("passkey", e?.message || "Passkey verification was cancelled", !0);
|
|
4887
5148
|
}
|
|
4888
|
-
if (!r) throw new
|
|
5149
|
+
if (!r) throw new Gr("passkey", "Passkey verification was cancelled", !0);
|
|
4889
5150
|
return {
|
|
4890
5151
|
challenge_id: e.challengeId,
|
|
4891
5152
|
credential: r
|
|
4892
5153
|
};
|
|
4893
5154
|
}
|
|
4894
|
-
},
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
]),
|
|
5155
|
+
}, Xr = Object.freeze([
|
|
5156
|
+
qr,
|
|
5157
|
+
Yr,
|
|
5158
|
+
Jr
|
|
5159
|
+
]), Zr = (e = Xr) => new Map(e.map((e) => [e.type, e])), Qr = 3, $r = {
|
|
4899
5160
|
passkey: 0,
|
|
4900
5161
|
totp: 1,
|
|
4901
5162
|
email_otp: 2,
|
|
4902
5163
|
sms_otp: 3,
|
|
4903
5164
|
recovery_codes: 9
|
|
4904
|
-
},
|
|
4905
|
-
let n =
|
|
5165
|
+
}, ei = (e) => e.requiredLevel ?? L(e.acrValues), ti = (e, t) => {
|
|
5166
|
+
let n = $r[e.type] ?? 5, r = t !== void 0 && t >= Qr, i = e.type === "passkey";
|
|
4906
5167
|
return (r && !i ? 100 : 0) + n;
|
|
4907
|
-
},
|
|
4908
|
-
let n =
|
|
4909
|
-
return [...e].sort((e, t) =>
|
|
4910
|
-
},
|
|
5168
|
+
}, ni = (e, t) => {
|
|
5169
|
+
let n = ei(t);
|
|
5170
|
+
return [...e].sort((e, t) => ti(e, n) - ti(t, n));
|
|
5171
|
+
}, ri = class extends Error {
|
|
4911
5172
|
constructor(e) {
|
|
4912
5173
|
super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
|
|
4913
5174
|
}
|
|
4914
|
-
},
|
|
5175
|
+
}, ii = class extends Error {
|
|
4915
5176
|
constructor(e = "No available authentication factor can satisfy this challenge") {
|
|
4916
5177
|
super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
|
|
4917
5178
|
}
|
|
4918
|
-
},
|
|
5179
|
+
}, ai = 4, oi = 3e4, si = () => {
|
|
4919
5180
|
let e = () => void 0, t = () => void 0;
|
|
4920
5181
|
return {
|
|
4921
5182
|
promise: new Promise((n, r) => {
|
|
@@ -4924,11 +5185,11 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4924
5185
|
resolve: e,
|
|
4925
5186
|
reject: t
|
|
4926
5187
|
};
|
|
4927
|
-
},
|
|
5188
|
+
}, ci = (e) => ({
|
|
4928
5189
|
acrValues: e.acrValues,
|
|
4929
5190
|
level: e.requiredLevel,
|
|
4930
5191
|
maxAge: e.maxAge
|
|
4931
|
-
}),
|
|
5192
|
+
}), li = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, ui = (e, t) => {
|
|
4932
5193
|
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 ?? []]));
|
|
4933
5194
|
return {
|
|
4934
5195
|
acrValues: r,
|
|
@@ -4937,12 +5198,12 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4937
5198
|
status: e.status,
|
|
4938
5199
|
...a.length > 0 ? { channels: a } : {}
|
|
4939
5200
|
};
|
|
4940
|
-
},
|
|
5201
|
+
}, di = (e, t) => {
|
|
4941
5202
|
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);
|
|
4942
5203
|
return n || r;
|
|
4943
|
-
},
|
|
5204
|
+
}, fi = class {
|
|
4944
5205
|
constructor(e) {
|
|
4945
|
-
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 ??
|
|
5206
|
+
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 ?? Xr, this.registry = Zr(this.available), this.maxAttempts = e.maxAttempts ?? ai, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? oi;
|
|
4946
5207
|
}
|
|
4947
5208
|
get currentState() {
|
|
4948
5209
|
return this.state;
|
|
@@ -4962,9 +5223,9 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4962
5223
|
}
|
|
4963
5224
|
register(e, t) {
|
|
4964
5225
|
let n = t.kind === "imperative" && t.requested !== void 0, r = {
|
|
4965
|
-
demanded: t.kind === "imperative" && t.requested ? t.requested :
|
|
5226
|
+
demanded: t.kind === "imperative" && t.requested ? t.requested : ci(e),
|
|
4966
5227
|
statedBar: n,
|
|
4967
|
-
settlement:
|
|
5228
|
+
settlement: si(),
|
|
4968
5229
|
reported: !1,
|
|
4969
5230
|
entry: {
|
|
4970
5231
|
...t,
|
|
@@ -4980,15 +5241,15 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4980
5241
|
this.requirement = e;
|
|
4981
5242
|
return;
|
|
4982
5243
|
}
|
|
4983
|
-
let n =
|
|
4984
|
-
this.requirement =
|
|
5244
|
+
let n = di(t, e);
|
|
5245
|
+
this.requirement = ui(t, e), n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
|
|
4985
5246
|
challenge: this.requirement,
|
|
4986
5247
|
factors: this.offeredFactors()
|
|
4987
5248
|
});
|
|
4988
5249
|
}
|
|
4989
5250
|
offeredFactors() {
|
|
4990
5251
|
let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
|
|
4991
|
-
return t ?
|
|
5252
|
+
return t ? ni(e, t) : e;
|
|
4992
5253
|
}
|
|
4993
5254
|
receiveReport(e, t) {
|
|
4994
5255
|
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());
|
|
@@ -5023,12 +5284,12 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5023
5284
|
}
|
|
5024
5285
|
release(e, t) {
|
|
5025
5286
|
if (e.entry.kind === "imperative") {
|
|
5026
|
-
if (e.statedBar &&
|
|
5287
|
+
if (e.statedBar && !li(t, e.demanded)) {
|
|
5027
5288
|
this.receiveReport(e, {
|
|
5028
5289
|
outcome: "insufficient",
|
|
5029
5290
|
obtained: t,
|
|
5030
5291
|
required: e.demanded
|
|
5031
|
-
}), e.settlement.reject(new
|
|
5292
|
+
}), e.settlement.reject(new mr(t, e.demanded));
|
|
5032
5293
|
return;
|
|
5033
5294
|
}
|
|
5034
5295
|
this.receiveReport(e, {
|
|
@@ -5101,7 +5362,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5101
5362
|
let t = this.offeredFactors();
|
|
5102
5363
|
if (t.length === 0) return {
|
|
5103
5364
|
status: "failed",
|
|
5104
|
-
reason: new
|
|
5365
|
+
reason: new ii()
|
|
5105
5366
|
};
|
|
5106
5367
|
let n = this.requirement, r;
|
|
5107
5368
|
try {
|
|
@@ -5109,24 +5370,24 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5109
5370
|
} catch (e) {
|
|
5110
5371
|
return {
|
|
5111
5372
|
status: "failed",
|
|
5112
|
-
reason: new
|
|
5373
|
+
reason: new ri(e)
|
|
5113
5374
|
};
|
|
5114
5375
|
}
|
|
5115
5376
|
if (r.type === "cancel") return {
|
|
5116
5377
|
status: "failed",
|
|
5117
|
-
reason: new
|
|
5378
|
+
reason: new ri()
|
|
5118
5379
|
};
|
|
5119
5380
|
let i = this.registry.get(r.factor);
|
|
5120
|
-
if (!i) e = new
|
|
5381
|
+
if (!i) e = new ii(`Unknown authentication factor: ${r.factor}`), this.state = "collecting", this.selected = null;
|
|
5121
5382
|
else try {
|
|
5122
5383
|
return await this.proveAndCommit(i, r.code), {
|
|
5123
5384
|
status: "proven",
|
|
5124
|
-
obtained: this.readObtainedBar?.() ??
|
|
5385
|
+
obtained: this.readObtainedBar?.() ?? ci(this.rankedRequirement ?? n)
|
|
5125
5386
|
};
|
|
5126
5387
|
} catch (t) {
|
|
5127
|
-
if (t instanceof
|
|
5388
|
+
if (t instanceof Gr && t.cancelled) return {
|
|
5128
5389
|
status: "failed",
|
|
5129
|
-
reason: new
|
|
5390
|
+
reason: new ri()
|
|
5130
5391
|
};
|
|
5131
5392
|
let n = this.classifyProofFailure(t);
|
|
5132
5393
|
if (n) return {
|
|
@@ -5156,15 +5417,15 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5156
5417
|
return this.openPrompt = r, this.prompt(r);
|
|
5157
5418
|
}
|
|
5158
5419
|
classifyProofFailure(e) {
|
|
5159
|
-
if (e instanceof
|
|
5420
|
+
if (e instanceof mr || e instanceof hr || e instanceof gr) return e;
|
|
5160
5421
|
if (e instanceof $) switch (e.kind) {
|
|
5161
|
-
case "unavailable": return new
|
|
5422
|
+
case "unavailable": return new hr(e.message);
|
|
5162
5423
|
case "exhausted":
|
|
5163
5424
|
case "attempts_exhausted":
|
|
5164
5425
|
case "fatal":
|
|
5165
5426
|
case "protocol":
|
|
5166
5427
|
case "network": return e;
|
|
5167
|
-
case "session_changed": return new
|
|
5428
|
+
case "session_changed": return new gr(e.message);
|
|
5168
5429
|
default: return;
|
|
5169
5430
|
}
|
|
5170
5431
|
}
|
|
@@ -5176,28 +5437,28 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5176
5437
|
});
|
|
5177
5438
|
await this.transport.commit(e.type, r);
|
|
5178
5439
|
}
|
|
5179
|
-
},
|
|
5440
|
+
}, pi = (e) => typeof e == "function" ? e() : e, mi = (e) => {
|
|
5180
5441
|
try {
|
|
5181
5442
|
return new URL(e);
|
|
5182
5443
|
} catch {
|
|
5183
5444
|
return;
|
|
5184
5445
|
}
|
|
5185
|
-
},
|
|
5446
|
+
}, hi = (e, t) => {
|
|
5186
5447
|
if (!t || t === "/") return !0;
|
|
5187
5448
|
let n = t.replace(/\/+$/, "");
|
|
5188
5449
|
return e === n || e.startsWith(`${n}/`);
|
|
5189
|
-
},
|
|
5450
|
+
}, gi = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && hi(e.pathname, t.pathPrefix), _i = (e, t) => {
|
|
5190
5451
|
for (let n of t) {
|
|
5191
5452
|
if (n === "") continue;
|
|
5192
5453
|
if (n.startsWith("/")) {
|
|
5193
|
-
if (e.relativeToBase &&
|
|
5454
|
+
if (e.relativeToBase && hi(e.pathname, n)) return !0;
|
|
5194
5455
|
continue;
|
|
5195
5456
|
}
|
|
5196
|
-
let t =
|
|
5197
|
-
if (t && e.origin !== void 0 && e.origin === t.origin &&
|
|
5457
|
+
let t = mi(n) ?? mi(`https://${n}`);
|
|
5458
|
+
if (t && e.origin !== void 0 && e.origin === t.origin && hi(e.pathname, t.pathname)) return !0;
|
|
5198
5459
|
}
|
|
5199
5460
|
return !1;
|
|
5200
|
-
},
|
|
5461
|
+
}, vi = (e, t, n) => gi(e, t.passflow) || _i(e, t.backend) ? !n || n(e.href) !== !1 : !1, yi = (e) => {
|
|
5201
5462
|
let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
|
|
5202
5463
|
console.warn(n, {
|
|
5203
5464
|
status: e.status,
|
|
@@ -5205,8 +5466,8 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5205
5466
|
reason: e.reason,
|
|
5206
5467
|
detail: t
|
|
5207
5468
|
});
|
|
5208
|
-
},
|
|
5209
|
-
let n = t.onUpgradeDiagnostic ??
|
|
5469
|
+
}, bi = (e, t) => {
|
|
5470
|
+
let n = t.onUpgradeDiagnostic ?? yi;
|
|
5210
5471
|
return (t, r) => {
|
|
5211
5472
|
n({
|
|
5212
5473
|
status: e.status,
|
|
@@ -5218,8 +5479,8 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5218
5479
|
}
|
|
5219
5480
|
});
|
|
5220
5481
|
};
|
|
5221
|
-
},
|
|
5222
|
-
let r = n.onUpgradeDiagnostic ??
|
|
5482
|
+
}, xi = (e, t, n) => {
|
|
5483
|
+
let r = n.onUpgradeDiagnostic ?? yi;
|
|
5223
5484
|
for (let n of e) r({
|
|
5224
5485
|
...n,
|
|
5225
5486
|
url: t.request.href,
|
|
@@ -5228,8 +5489,8 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5228
5489
|
...n.detail ?? {}
|
|
5229
5490
|
}
|
|
5230
5491
|
});
|
|
5231
|
-
},
|
|
5232
|
-
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n &&
|
|
5492
|
+
}, Si = /\bjson\b/i, Ci = async (e, t) => {
|
|
5493
|
+
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && Si.test(r), a;
|
|
5233
5494
|
if (i) try {
|
|
5234
5495
|
a = await e.readBody();
|
|
5235
5496
|
} catch {
|
|
@@ -5243,10 +5504,10 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5243
5504
|
status: e.status,
|
|
5244
5505
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5245
5506
|
}, { requireChallengeChannel: t.requireChallengeChannel });
|
|
5246
|
-
},
|
|
5507
|
+
}, wi = (e) => ve({
|
|
5247
5508
|
status: e.status,
|
|
5248
5509
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5249
|
-
}, { requireChallengeChannel: "header" }).challenge,
|
|
5510
|
+
}, { requireChallengeChannel: "header" }).challenge, Ti = (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.`, Ei = (e, t) => e instanceof ri ? { kind: "cancelled" } : e instanceof ii ? { kind: "unsatisfiable" } : e instanceof hr ? { kind: "unavailable" } : e instanceof gr ? { kind: "session-changed" } : e instanceof mr ? {
|
|
5250
5511
|
kind: "insufficient",
|
|
5251
5512
|
obtained: e.obtained,
|
|
5252
5513
|
required: e.required
|
|
@@ -5262,17 +5523,17 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5262
5523
|
kind: "transport-failure",
|
|
5263
5524
|
retryable: !1,
|
|
5264
5525
|
error: e instanceof Error ? e : Error(String(e))
|
|
5265
|
-
},
|
|
5526
|
+
}, Di = async (e, t, n, r) => {
|
|
5266
5527
|
if (e.status !== 401 && e.status !== 403) return {
|
|
5267
5528
|
kind: "replayed",
|
|
5268
5529
|
response: e
|
|
5269
5530
|
};
|
|
5270
|
-
let { challenge: i, diagnostics: a } = await
|
|
5271
|
-
if (
|
|
5531
|
+
let { challenge: i, diagnostics: a } = await Ci(e, t);
|
|
5532
|
+
if (xi(a, e, t), !i) return {
|
|
5272
5533
|
kind: "replayed",
|
|
5273
5534
|
response: e
|
|
5274
5535
|
};
|
|
5275
|
-
let o =
|
|
5536
|
+
let o = ci(i);
|
|
5276
5537
|
return r("elevated-insufficient", {
|
|
5277
5538
|
obtained: n,
|
|
5278
5539
|
required: o
|
|
@@ -5282,7 +5543,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5282
5543
|
required: o,
|
|
5283
5544
|
response: e
|
|
5284
5545
|
};
|
|
5285
|
-
},
|
|
5546
|
+
}, Oi = async (e, t) => {
|
|
5286
5547
|
if (!t) return {
|
|
5287
5548
|
aborted: !1,
|
|
5288
5549
|
value: await e
|
|
@@ -5309,14 +5570,14 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5309
5570
|
} finally {
|
|
5310
5571
|
n && t.removeEventListener?.("abort", n);
|
|
5311
5572
|
}
|
|
5312
|
-
},
|
|
5573
|
+
}, ki = async (e, t) => {
|
|
5313
5574
|
if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
|
|
5314
|
-
let n =
|
|
5575
|
+
let n = bi(e, t);
|
|
5315
5576
|
if (e.markers.replayed) {
|
|
5316
|
-
if (!
|
|
5317
|
-
let { challenge: r, diagnostics: i } = await
|
|
5318
|
-
if (
|
|
5319
|
-
let a = t.readObtainedBar?.() ?? {}, o =
|
|
5577
|
+
if (!vi(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
|
|
5578
|
+
let { challenge: r, diagnostics: i } = await Ci(e, t);
|
|
5579
|
+
if (xi(i, e, t), !r) return { kind: "not-a-challenge" };
|
|
5580
|
+
let a = t.readObtainedBar?.() ?? {}, o = ci(r);
|
|
5320
5581
|
return n("elevated-insufficient", {
|
|
5321
5582
|
obtained: a,
|
|
5322
5583
|
required: o
|
|
@@ -5327,12 +5588,12 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5327
5588
|
response: e
|
|
5328
5589
|
};
|
|
5329
5590
|
}
|
|
5330
|
-
if (!
|
|
5591
|
+
if (!vi(e.request, t.scope, t.shouldIntercept)) return wi(e) ? (n("challenge-out-of-scope", {
|
|
5331
5592
|
header: e.getHeader("www-authenticate") ?? void 0,
|
|
5332
|
-
message:
|
|
5593
|
+
message: Ti(e.request.href, t.scope)
|
|
5333
5594
|
}), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
|
|
5334
|
-
let { challenge: r, diagnostics: i } = await
|
|
5335
|
-
if (
|
|
5595
|
+
let { challenge: r, diagnostics: i } = await Ci(e, t);
|
|
5596
|
+
if (xi(i, e, t), !r) {
|
|
5336
5597
|
let r = e.getHeader("www-authenticate");
|
|
5337
5598
|
return t.requireChallengeChannel !== "header" && n("no-channel", {
|
|
5338
5599
|
...r ? { header: r } : {},
|
|
@@ -5346,9 +5607,9 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5346
5607
|
method: e.request.method
|
|
5347
5608
|
}, s, c;
|
|
5348
5609
|
try {
|
|
5349
|
-
s = Promise.resolve(t.elevate(r, o)), c = await
|
|
5610
|
+
s = Promise.resolve(t.elevate(r, o)), c = await Oi(s, e.signal);
|
|
5350
5611
|
} catch (e) {
|
|
5351
|
-
return
|
|
5612
|
+
return Ei(e, void 0);
|
|
5352
5613
|
}
|
|
5353
5614
|
if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
|
|
5354
5615
|
kind: "aborted",
|
|
@@ -5359,7 +5620,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5359
5620
|
kind: "aborted",
|
|
5360
5621
|
reason: e.signal.reason
|
|
5361
5622
|
};
|
|
5362
|
-
let u = l?.obtained ?? t.readObtainedBar?.() ??
|
|
5623
|
+
let u = l?.obtained ?? t.readObtainedBar?.() ?? ci(r), d = t.authorizationSwap?.(), f = d ? {
|
|
5363
5624
|
from: a?.from ?? d.from,
|
|
5364
5625
|
to: d.to
|
|
5365
5626
|
} : void 0;
|
|
@@ -5368,7 +5629,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5368
5629
|
try {
|
|
5369
5630
|
p = await e.replay(f ? { authorizationSwap: f } : void 0);
|
|
5370
5631
|
} catch (t) {
|
|
5371
|
-
if (t instanceof
|
|
5632
|
+
if (t instanceof mr) return l?.waiter.report({
|
|
5372
5633
|
outcome: "insufficient",
|
|
5373
5634
|
obtained: t.obtained,
|
|
5374
5635
|
required: t.required
|
|
@@ -5386,7 +5647,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5386
5647
|
};
|
|
5387
5648
|
throw t;
|
|
5388
5649
|
}
|
|
5389
|
-
let m = await
|
|
5650
|
+
let m = await Di(p, t, u, n);
|
|
5390
5651
|
return m.kind === "insufficient" ? l?.waiter.report({
|
|
5391
5652
|
outcome: "insufficient",
|
|
5392
5653
|
obtained: m.obtained,
|
|
@@ -5395,18 +5656,18 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5395
5656
|
outcome: "replayed",
|
|
5396
5657
|
obtained: u
|
|
5397
5658
|
}), m;
|
|
5398
|
-
},
|
|
5659
|
+
}, Ai = (e) => {
|
|
5399
5660
|
switch (e.kind) {
|
|
5400
|
-
case "cancelled": return new
|
|
5401
|
-
case "unsatisfiable": return new
|
|
5402
|
-
case "unavailable": return new
|
|
5403
|
-
case "session-changed": return new
|
|
5404
|
-
case "insufficient": return new
|
|
5661
|
+
case "cancelled": return new ri();
|
|
5662
|
+
case "unsatisfiable": return new ii();
|
|
5663
|
+
case "unavailable": return new hr();
|
|
5664
|
+
case "session-changed": return new gr();
|
|
5665
|
+
case "insufficient": return new mr(e.obtained, e.required);
|
|
5405
5666
|
case "exhausted": return e.error;
|
|
5406
5667
|
case "transport-failure": return e.error;
|
|
5407
5668
|
default: return;
|
|
5408
5669
|
}
|
|
5409
|
-
},
|
|
5670
|
+
}, ji = (e, t, n) => {
|
|
5410
5671
|
switch (e.kind) {
|
|
5411
5672
|
case "replayed": return {
|
|
5412
5673
|
settle: "resolve",
|
|
@@ -5424,21 +5685,21 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5424
5685
|
};
|
|
5425
5686
|
case "cancelled": return n.onCancel === "reject" ? {
|
|
5426
5687
|
settle: "reject",
|
|
5427
|
-
error: new
|
|
5688
|
+
error: new ri()
|
|
5428
5689
|
} : {
|
|
5429
5690
|
settle: "resolve",
|
|
5430
|
-
value:
|
|
5691
|
+
value: Bi(t, e)
|
|
5431
5692
|
};
|
|
5432
5693
|
case "insufficient": return {
|
|
5433
5694
|
settle: "resolve",
|
|
5434
|
-
value:
|
|
5695
|
+
value: Bi(e.response?.raw ?? t, e)
|
|
5435
5696
|
};
|
|
5436
5697
|
default: return {
|
|
5437
5698
|
settle: "resolve",
|
|
5438
|
-
value:
|
|
5699
|
+
value: Bi(t, e)
|
|
5439
5700
|
};
|
|
5440
5701
|
}
|
|
5441
|
-
},
|
|
5702
|
+
}, Mi = (e, t) => {
|
|
5442
5703
|
switch (e.kind) {
|
|
5443
5704
|
case "replayed": return e.response.rejected ? {
|
|
5444
5705
|
settle: "reject",
|
|
@@ -5453,39 +5714,39 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5453
5714
|
};
|
|
5454
5715
|
default: return {
|
|
5455
5716
|
settle: "reject",
|
|
5456
|
-
error:
|
|
5717
|
+
error: Ai(e) ?? t
|
|
5457
5718
|
};
|
|
5458
5719
|
}
|
|
5459
|
-
},
|
|
5720
|
+
}, Ni = /* @__PURE__ */ new WeakSet(), Pi = /* @__PURE__ */ new WeakSet(), Fi = /* @__PURE__ */ new WeakSet(), Ii = /* @__PURE__ */ new WeakSet(), Li = /* @__PURE__ */ new WeakSet(), Ri = /* @__PURE__ */ new WeakSet(), zi = /* @__PURE__ */ new WeakSet(), Bi = (e, t) => {
|
|
5460
5721
|
switch (t.kind) {
|
|
5461
5722
|
case "cancelled":
|
|
5462
|
-
|
|
5723
|
+
Ni.add(e);
|
|
5463
5724
|
break;
|
|
5464
5725
|
case "exhausted":
|
|
5465
|
-
|
|
5726
|
+
Pi.add(e);
|
|
5466
5727
|
break;
|
|
5467
5728
|
case "insufficient":
|
|
5468
|
-
|
|
5729
|
+
Fi.add(e);
|
|
5469
5730
|
break;
|
|
5470
5731
|
case "unsatisfiable":
|
|
5471
|
-
|
|
5732
|
+
Ii.add(e);
|
|
5472
5733
|
break;
|
|
5473
5734
|
case "unavailable":
|
|
5474
|
-
|
|
5735
|
+
Li.add(e);
|
|
5475
5736
|
break;
|
|
5476
5737
|
case "session-changed":
|
|
5477
|
-
|
|
5738
|
+
Ri.add(e);
|
|
5478
5739
|
break;
|
|
5479
|
-
case "transport-failure":
|
|
5740
|
+
case "transport-failure": zi.add(e);
|
|
5480
5741
|
}
|
|
5481
5742
|
return e;
|
|
5482
|
-
},
|
|
5743
|
+
}, Vi = (e) => Ni.has(e), Hi = (e) => Pi.has(e), Ui = (e) => Fi.has(e), Wi = (e) => Ii.has(e), Gi = (e) => Li.has(e), Ki = (e) => Ri.has(e), qi = (e) => zi.has(e), Ji = "https://passflow-relative.invalid", Yi = () => {
|
|
5483
5744
|
let e = globalThis, t = e.document?.baseURI;
|
|
5484
5745
|
if (typeof t == "string" && t !== "") return t;
|
|
5485
5746
|
let n = e.location?.href;
|
|
5486
|
-
return typeof n == "string" && n !== "" && n !== "about:blank" ? n :
|
|
5487
|
-
},
|
|
5488
|
-
let n = t ===
|
|
5747
|
+
return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Ji;
|
|
5748
|
+
}, Xi = (e, t = Yi()) => {
|
|
5749
|
+
let n = t === Ji, r;
|
|
5489
5750
|
try {
|
|
5490
5751
|
r = new URL(t).origin;
|
|
5491
5752
|
} catch {
|
|
@@ -5511,28 +5772,28 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5511
5772
|
relativeToBase: !1,
|
|
5512
5773
|
sentinelBase: n
|
|
5513
5774
|
};
|
|
5514
|
-
},
|
|
5775
|
+
}, Zi = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Qi = (e) => {
|
|
5515
5776
|
let t = [];
|
|
5516
5777
|
if (e == null) return Object.freeze(t);
|
|
5517
5778
|
let n = e;
|
|
5518
5779
|
if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
|
|
5519
|
-
let r =
|
|
5780
|
+
let r = Zi(n, e);
|
|
5520
5781
|
r && t.push(r);
|
|
5521
5782
|
}), Object.freeze(t);
|
|
5522
5783
|
if (Array.isArray(e)) {
|
|
5523
5784
|
for (let n of e) if (Array.isArray(n) && n.length >= 2) {
|
|
5524
|
-
let e =
|
|
5785
|
+
let e = Zi(String(n[0]), n[1]);
|
|
5525
5786
|
e && t.push(e);
|
|
5526
5787
|
}
|
|
5527
5788
|
return Object.freeze(t);
|
|
5528
5789
|
}
|
|
5529
5790
|
if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
|
|
5530
|
-
let e =
|
|
5791
|
+
let e = Zi(n, Array.isArray(r) ? r.join(", ") : r);
|
|
5531
5792
|
e && t.push(e);
|
|
5532
5793
|
}
|
|
5533
5794
|
return Object.freeze(t);
|
|
5534
|
-
},
|
|
5535
|
-
let t = e.base === void 0 ?
|
|
5795
|
+
}, $i = (e) => {
|
|
5796
|
+
let t = e.base === void 0 ? Xi(e.url) : Xi(e.url, e.base), n = {
|
|
5536
5797
|
raw: e.url,
|
|
5537
5798
|
href: t.href,
|
|
5538
5799
|
dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
|
|
@@ -5541,29 +5802,29 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5541
5802
|
resolved: t.resolved,
|
|
5542
5803
|
relativeToBase: t.relativeToBase,
|
|
5543
5804
|
method: (e.method ?? "GET").toUpperCase(),
|
|
5544
|
-
headers:
|
|
5805
|
+
headers: Qi(e.headers),
|
|
5545
5806
|
bodyKind: e.bodyKind,
|
|
5546
5807
|
..."body" in e ? { body: e.body } : {}
|
|
5547
5808
|
};
|
|
5548
5809
|
return Object.freeze(n);
|
|
5549
|
-
},
|
|
5810
|
+
}, ea = (e, t) => {
|
|
5550
5811
|
if (!t || t.from === t.to) return e;
|
|
5551
5812
|
let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
|
|
5552
5813
|
return n ? Object.freeze(r) : e;
|
|
5553
|
-
},
|
|
5814
|
+
}, ta = (e) => {
|
|
5554
5815
|
let t = {};
|
|
5555
5816
|
for (let [n, r] of e) t[n] = r;
|
|
5556
5817
|
return t;
|
|
5557
|
-
},
|
|
5818
|
+
}, na = /* @__PURE__ */ new Set([
|
|
5558
5819
|
"GET",
|
|
5559
5820
|
"HEAD",
|
|
5560
5821
|
"OPTIONS"
|
|
5561
|
-
]),
|
|
5822
|
+
]), ra = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, ia = (e) => typeof e == "string" ? e : ra(e) ? e.url : String(e), aa = (e, t) => (t?.method ?? (ra(e) ? e.method : void 0) ?? "GET").toUpperCase(), oa = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", sa = (e) => {
|
|
5562
5823
|
if (typeof e == "string") return e.length;
|
|
5563
5824
|
let t = e;
|
|
5564
5825
|
if (typeof t?.size == "number") return t.size;
|
|
5565
5826
|
if (typeof t?.byteLength == "number") return t.byteLength;
|
|
5566
|
-
},
|
|
5827
|
+
}, ca = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? na.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), la = (e, t, n, r, i) => ({
|
|
5567
5828
|
replayable: !1,
|
|
5568
5829
|
bodyKind: e,
|
|
5569
5830
|
reason: t,
|
|
@@ -5571,11 +5832,11 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5571
5832
|
forwardInit: i,
|
|
5572
5833
|
snapshot: r,
|
|
5573
5834
|
replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
|
|
5574
|
-
}),
|
|
5835
|
+
}), ua = (e, t) => ta(ea(e.headers, t?.authorizationSwap)), da = (e) => {
|
|
5575
5836
|
if (!e || !("headers" in e)) return e;
|
|
5576
5837
|
let { headers: t, ...n } = e;
|
|
5577
5838
|
return n;
|
|
5578
|
-
},
|
|
5839
|
+
}, fa = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : ra(e) ? e.headers : void 0, pa = (e) => {
|
|
5579
5840
|
if (e === null || typeof e == "string") return e;
|
|
5580
5841
|
if (typeof FormData < "u" && e instanceof FormData) {
|
|
5581
5842
|
let t = new FormData();
|
|
@@ -5583,18 +5844,18 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5583
5844
|
return t;
|
|
5584
5845
|
}
|
|
5585
5846
|
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;
|
|
5586
|
-
},
|
|
5587
|
-
let r =
|
|
5847
|
+
}, ma = (e, t, n) => new Request(e, { headers: ua(t, n) }), ha = (e, t, n) => {
|
|
5848
|
+
let r = ia(e), i = aa(e, t), a = fa(e, t), o = (e, t) => $i({
|
|
5588
5849
|
url: r,
|
|
5589
5850
|
method: i,
|
|
5590
5851
|
headers: a,
|
|
5591
5852
|
bodyKind: e,
|
|
5592
5853
|
...t === void 0 ? {} : { body: t }
|
|
5593
5854
|
});
|
|
5594
|
-
if (
|
|
5855
|
+
if (ra(e)) {
|
|
5595
5856
|
if (e.body === null || e.body === void 0) {
|
|
5596
5857
|
let a = o("none");
|
|
5597
|
-
return
|
|
5858
|
+
return ca(n, {
|
|
5598
5859
|
url: r,
|
|
5599
5860
|
method: i,
|
|
5600
5861
|
bodyKind: "none"
|
|
@@ -5604,20 +5865,20 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5604
5865
|
forwardInput: e,
|
|
5605
5866
|
forwardInit: t,
|
|
5606
5867
|
snapshot: a,
|
|
5607
|
-
replay: (n, r) => n(
|
|
5608
|
-
} :
|
|
5868
|
+
replay: (n, r) => n(ma(e, a, r), da(t))
|
|
5869
|
+
} : la("none", "the replay policy refused this request", e, a, t);
|
|
5609
5870
|
}
|
|
5610
5871
|
let a = o("request-clone");
|
|
5611
|
-
if (!
|
|
5872
|
+
if (!ca(n, {
|
|
5612
5873
|
url: r,
|
|
5613
5874
|
method: i,
|
|
5614
5875
|
bodyKind: "request-clone"
|
|
5615
|
-
})) return
|
|
5876
|
+
})) return la("request-clone", "the replay policy refused this request", e, a, t);
|
|
5616
5877
|
let s;
|
|
5617
5878
|
try {
|
|
5618
5879
|
s = e.clone();
|
|
5619
5880
|
} catch {
|
|
5620
|
-
return
|
|
5881
|
+
return la("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
|
|
5621
5882
|
}
|
|
5622
5883
|
return {
|
|
5623
5884
|
replayable: !0,
|
|
@@ -5625,17 +5886,17 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5625
5886
|
forwardInput: e,
|
|
5626
5887
|
forwardInit: t,
|
|
5627
5888
|
snapshot: a,
|
|
5628
|
-
replay: (e, n) => e(
|
|
5889
|
+
replay: (e, n) => e(ma(s, a, n), da(t))
|
|
5629
5890
|
};
|
|
5630
5891
|
}
|
|
5631
|
-
let s =
|
|
5632
|
-
if (s === "one-shot") return
|
|
5633
|
-
if (!
|
|
5892
|
+
let s = oa(t?.body);
|
|
5893
|
+
if (s === "one-shot") return la("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
|
|
5894
|
+
if (!ca(n, {
|
|
5634
5895
|
url: r,
|
|
5635
5896
|
method: i,
|
|
5636
5897
|
bodyKind: s
|
|
5637
|
-
},
|
|
5638
|
-
let c = t && "body" in t ?
|
|
5898
|
+
}, sa(t?.body))) return la(s, "the replay policy refused this request", e, o(s), t);
|
|
5899
|
+
let c = t && "body" in t ? pa(t.body ?? null) : void 0, l = o(s, c);
|
|
5639
5900
|
return {
|
|
5640
5901
|
replayable: !0,
|
|
5641
5902
|
bodyKind: s,
|
|
@@ -5643,21 +5904,21 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5643
5904
|
forwardInit: t,
|
|
5644
5905
|
snapshot: l,
|
|
5645
5906
|
replay: (e, n) => e(l.dispatchUrl, {
|
|
5646
|
-
...
|
|
5907
|
+
...da(t),
|
|
5647
5908
|
...c === void 0 ? {} : { body: c },
|
|
5648
|
-
headers:
|
|
5909
|
+
headers: ua(l, n),
|
|
5649
5910
|
method: l.method
|
|
5650
5911
|
})
|
|
5651
5912
|
};
|
|
5652
|
-
},
|
|
5653
|
-
if (!
|
|
5913
|
+
}, ga = (e) => typeof e == "object" && !!e, _a = (e) => (t) => {
|
|
5914
|
+
if (!ga(e)) return;
|
|
5654
5915
|
let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
|
|
5655
5916
|
return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
|
|
5656
|
-
},
|
|
5917
|
+
}, va = (e) => {
|
|
5657
5918
|
let t = e?.url ?? "", n = e?.baseURL;
|
|
5658
5919
|
return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
5659
|
-
},
|
|
5660
|
-
let r =
|
|
5920
|
+
}, ya = (e) => (e?.method ?? "GET").toUpperCase(), ba = (e) => e == null ? "none" : ga(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", xa = (e, t, n) => {
|
|
5921
|
+
let r = ta(ea(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
|
|
5661
5922
|
return {
|
|
5662
5923
|
...e,
|
|
5663
5924
|
...i ? { baseURL: void 0 } : {},
|
|
@@ -5666,10 +5927,10 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5666
5927
|
headers: r,
|
|
5667
5928
|
..."body" in t ? { data: t.body } : {}
|
|
5668
5929
|
};
|
|
5669
|
-
},
|
|
5670
|
-
let o = t ?? e?.config, s =
|
|
5671
|
-
url:
|
|
5672
|
-
method:
|
|
5930
|
+
}, Sa = (e, t, n, r, i, a) => {
|
|
5931
|
+
let o = t ?? e?.config, s = ba(o?.data), c = a ?? $i({
|
|
5932
|
+
url: va(o),
|
|
5933
|
+
method: ya(o),
|
|
5673
5934
|
headers: o?.headers,
|
|
5674
5935
|
bodyKind: s,
|
|
5675
5936
|
body: o?.data
|
|
@@ -5677,22 +5938,22 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5677
5938
|
url: c.href,
|
|
5678
5939
|
method: c.method,
|
|
5679
5940
|
bodyKind: s
|
|
5680
|
-
}, u = s !== "one-shot" &&
|
|
5941
|
+
}, u = s !== "one-shot" && ca(i.replay, l);
|
|
5681
5942
|
return {
|
|
5682
5943
|
status: e?.status ?? 0,
|
|
5683
|
-
getHeader:
|
|
5944
|
+
getHeader: _a(e?.headers),
|
|
5684
5945
|
readBody: async () => e?.data,
|
|
5685
5946
|
request: c,
|
|
5686
5947
|
replay: async (e) => {
|
|
5687
|
-
let t = Te(
|
|
5948
|
+
let t = Te(xa(o ?? {}, c, e));
|
|
5688
5949
|
try {
|
|
5689
5950
|
let e = await r(t);
|
|
5690
|
-
return
|
|
5951
|
+
return Sa(e, e?.config ?? t, e, r, i, c);
|
|
5691
5952
|
} catch (e) {
|
|
5692
|
-
let n =
|
|
5693
|
-
if (!n.response || typeof n.response.status != "number" ||
|
|
5953
|
+
let n = ga(e) ? e : {};
|
|
5954
|
+
if (!n.response || typeof n.response.status != "number" || or(e)) throw e;
|
|
5694
5955
|
return {
|
|
5695
|
-
...
|
|
5956
|
+
...Sa(n.response, n.config ?? t, e, r, i, c),
|
|
5696
5957
|
rejected: !0
|
|
5697
5958
|
};
|
|
5698
5959
|
}
|
|
@@ -5706,19 +5967,19 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5706
5967
|
replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
|
|
5707
5968
|
signal: o?.signal
|
|
5708
5969
|
};
|
|
5709
|
-
},
|
|
5710
|
-
let r =
|
|
5970
|
+
}, Ca = (e, t) => async (n) => {
|
|
5971
|
+
let r = pi(e), i = ga(n) ? n : {}, a = Mi(await ki(Sa(i.response, i.config, i.response, t, r), r), n);
|
|
5711
5972
|
if (a.settle === "reject") throw a.error;
|
|
5712
5973
|
return a.value;
|
|
5713
|
-
},
|
|
5714
|
-
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,
|
|
5974
|
+
}, wa = (e, t, n) => {
|
|
5975
|
+
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, Ca(t, i)), o = !1;
|
|
5715
5976
|
return () => {
|
|
5716
5977
|
o || (o = !0, e.interceptors.response.eject(a));
|
|
5717
5978
|
};
|
|
5718
|
-
},
|
|
5979
|
+
}, Ta = (t, n) => {
|
|
5719
5980
|
let r = e.create(t);
|
|
5720
5981
|
return n(r), r;
|
|
5721
|
-
},
|
|
5982
|
+
}, Ea = 0, Da = (e, t) => {
|
|
5722
5983
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
5723
5984
|
if (n) return {
|
|
5724
5985
|
get aborted() {
|
|
@@ -5732,34 +5993,34 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5732
5993
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
5733
5994
|
} : {}
|
|
5734
5995
|
};
|
|
5735
|
-
},
|
|
5996
|
+
}, Oa = (e) => (t) => e.headers?.get(t), ka = (e, t, n, r, i) => ({
|
|
5736
5997
|
status: e.status,
|
|
5737
|
-
getHeader:
|
|
5998
|
+
getHeader: Oa(e),
|
|
5738
5999
|
readBody: () => e.clone().json(),
|
|
5739
6000
|
request: t.snapshot,
|
|
5740
|
-
replay: async (e) =>
|
|
6001
|
+
replay: async (e) => ka(await t.replay(n, e), t, n, r, i),
|
|
5741
6002
|
markers: r,
|
|
5742
6003
|
raw: e,
|
|
5743
6004
|
replayable: t.replayable,
|
|
5744
6005
|
replayUnsupportedReason: t.reason,
|
|
5745
6006
|
signal: i,
|
|
5746
6007
|
responseType: e.type
|
|
5747
|
-
}),
|
|
6008
|
+
}), Aa = (e, t) => {
|
|
5748
6009
|
let n = (t, n) => {
|
|
5749
|
-
|
|
6010
|
+
Ea += 1;
|
|
5750
6011
|
try {
|
|
5751
6012
|
return e(t, n);
|
|
5752
6013
|
} finally {
|
|
5753
|
-
--
|
|
6014
|
+
--Ea;
|
|
5754
6015
|
}
|
|
5755
6016
|
};
|
|
5756
6017
|
return async (e, r) => {
|
|
5757
|
-
if (
|
|
5758
|
-
let i =
|
|
6018
|
+
if (Ea > 0) return n(e, r);
|
|
6019
|
+
let i = pi(t), a = ha(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = ji(await ki(ka(o, a, n, {}, Da(e, r)), i), o, i);
|
|
5759
6020
|
if (s.settle === "reject") throw s.error;
|
|
5760
6021
|
return s.value;
|
|
5761
6022
|
};
|
|
5762
|
-
},
|
|
6023
|
+
}, ja = new Set(Xr.filter((e) => !e.requiresPrepare).map((e) => e.type)), Ma = (e) => {
|
|
5763
6024
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
5764
6025
|
kind: "protocol",
|
|
5765
6026
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -5771,17 +6032,17 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5771
6032
|
webauthn: e.webauthn,
|
|
5772
6033
|
codeSentTo: e.code_sent_to
|
|
5773
6034
|
};
|
|
5774
|
-
},
|
|
6035
|
+
}, Na = (e) => or(e) && !sr(e), Pa = (e) => ({
|
|
5775
6036
|
async prepare(t) {
|
|
5776
|
-
if (!
|
|
6037
|
+
if (!ja.has(t)) try {
|
|
5777
6038
|
let n = e.relyingPartyId?.();
|
|
5778
|
-
return
|
|
6039
|
+
return Ma(await e.startUpgrade(n ? {
|
|
5779
6040
|
method: t,
|
|
5780
6041
|
relying_party_id: n
|
|
5781
6042
|
} : { method: t }));
|
|
5782
6043
|
} catch (e) {
|
|
5783
|
-
if (
|
|
5784
|
-
let t =
|
|
6044
|
+
if (Na(e)) throw e;
|
|
6045
|
+
let t = dr(e, "start");
|
|
5785
6046
|
if (t.kind === "prepare_not_required") return;
|
|
5786
6047
|
throw t;
|
|
5787
6048
|
}
|
|
@@ -5798,17 +6059,17 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5798
6059
|
assertion: n
|
|
5799
6060
|
});
|
|
5800
6061
|
} catch (t) {
|
|
5801
|
-
if (
|
|
5802
|
-
let n =
|
|
5803
|
-
throw n.status === 401 &&
|
|
6062
|
+
if (Na(t)) throw t;
|
|
6063
|
+
let n = dr(t, "refresh");
|
|
6064
|
+
throw n.status === 401 && pr(n) && e.markSessionInvalid?.(), n;
|
|
5804
6065
|
}
|
|
5805
6066
|
}
|
|
5806
|
-
}),
|
|
6067
|
+
}), Fa = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Ia = (e) => {
|
|
5807
6068
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
5808
6069
|
let i = () => {
|
|
5809
6070
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
5810
6071
|
};
|
|
5811
|
-
return
|
|
6072
|
+
return Pa({
|
|
5812
6073
|
...e,
|
|
5813
6074
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
5814
6075
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -5819,7 +6080,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5819
6080
|
});
|
|
5820
6081
|
}, i = (t, n) => {
|
|
5821
6082
|
let i = {}, a = {
|
|
5822
|
-
controller: new
|
|
6083
|
+
controller: new fi({
|
|
5823
6084
|
transport: r(() => i.current),
|
|
5824
6085
|
prompt: t.prompt,
|
|
5825
6086
|
platform: e.platform,
|
|
@@ -5831,17 +6092,17 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5831
6092
|
options: t,
|
|
5832
6093
|
scope: {
|
|
5833
6094
|
passflow: e.passflowDomain,
|
|
5834
|
-
backend:
|
|
6095
|
+
backend: Fa(t.backend)
|
|
5835
6096
|
},
|
|
5836
6097
|
generation: n
|
|
5837
6098
|
};
|
|
5838
6099
|
return i.current = a, a;
|
|
5839
6100
|
}, a = async (r, i) => {
|
|
5840
6101
|
let a = t;
|
|
5841
|
-
if (!a) throw new
|
|
6102
|
+
if (!a) throw new hr("Step-up verification is not enabled on this Passflow instance");
|
|
5842
6103
|
a.controller.active || (a.pin = e.readSessionPin?.());
|
|
5843
6104
|
let o = await a.controller.elevate(r, i);
|
|
5844
|
-
if (!n(a)) throw new
|
|
6105
|
+
if (!n(a)) throw new gr();
|
|
5845
6106
|
return o;
|
|
5846
6107
|
}, o = () => {
|
|
5847
6108
|
let n = t, r = n?.scope ?? {
|
|
@@ -5885,9 +6146,9 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5885
6146
|
let r = [];
|
|
5886
6147
|
if (e.attachInternalSeam) {
|
|
5887
6148
|
let t = e.attachInternalSeam;
|
|
5888
|
-
t((e) =>
|
|
6149
|
+
t((e) => Ca(o, e)), r.push(() => t(void 0));
|
|
5889
6150
|
}
|
|
5890
|
-
n.interceptFetch && r.push(
|
|
6151
|
+
n.interceptFetch && r.push(xt((e, t, n) => Aa(e, o)(t, n), {
|
|
5891
6152
|
priority: 20,
|
|
5892
6153
|
name: "passflow-upgrade"
|
|
5893
6154
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -5918,18 +6179,18 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5918
6179
|
withAuth: {
|
|
5919
6180
|
enumerable: !0,
|
|
5920
6181
|
value: (e) => {
|
|
5921
|
-
if (e) return
|
|
6182
|
+
if (e) return Aa(e, o);
|
|
5922
6183
|
let t = typeof globalThis > "u" ? void 0 : globalThis;
|
|
5923
6184
|
if (!t || typeof t.fetch != "function") throw Error("Passflow: withAuth() needs a fetch to wrap — this runtime has none.");
|
|
5924
|
-
return
|
|
6185
|
+
return Aa(t.fetch.bind(t), o);
|
|
5925
6186
|
}
|
|
5926
6187
|
},
|
|
5927
6188
|
attachAuth: {
|
|
5928
6189
|
enumerable: !0,
|
|
5929
|
-
value: (e) =>
|
|
6190
|
+
value: (e) => wa(e, o)
|
|
5930
6191
|
}
|
|
5931
6192
|
});
|
|
5932
|
-
},
|
|
6193
|
+
}, La, Ra = class {
|
|
5933
6194
|
get origin() {
|
|
5934
6195
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
5935
6196
|
}
|
|
@@ -5938,12 +6199,12 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5938
6199
|
this.createSessionCallback = e, this.expiredSessionCallback = t, this.doRefreshTokens = n, await this.submitSessionCheck();
|
|
5939
6200
|
};
|
|
5940
6201
|
let { url: t, appId: n, scopes: r } = e;
|
|
5941
|
-
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? P, this.storageManager = new N({
|
|
6202
|
+
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? P, this.deferFederatedLanding = e.deferFederatedLanding ?? !1, this.storageManager = new N({
|
|
5942
6203
|
prefix: e.keyStoragePrefix ?? "",
|
|
5943
6204
|
storage: this.platform.storage
|
|
5944
|
-
}), this.deviceService = new re(this.storageManager), this.authApi = new
|
|
5945
|
-
let i =
|
|
5946
|
-
this.authService = new
|
|
6205
|
+
}), this.deviceService = new re(this.storageManager), this.authApi = new Qe(e, this.storageManager, this.deviceService), this.appApi = new Ke(e, this.storageManager, this.deviceService), this.userApi = new st(e, this.storageManager, this.deviceService), this.settingApi = new tt(e, this.storageManager, this.deviceService), this.tenantApi = new nt(e, this.storageManager, this.deviceService), this.invitationApi = new et(e, this.storageManager, this.deviceService), this.twoFactorApi = new at(e, this.storageManager, this.deviceService), this.upgradeApi = new ot(e, this.storageManager, this.deviceService), this.upgradeDomain = ke(e.url), this.subscribeStore = new $n(), this.tokenCacheService = new Hr(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? u, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
|
|
6206
|
+
let i = fn(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
|
|
6207
|
+
this.authService = new Rr(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
|
|
5947
6208
|
createSession: this.createSessionCallback,
|
|
5948
6209
|
expiredSession: this.expiredSessionCallback
|
|
5949
6210
|
}, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
|
|
@@ -5951,7 +6212,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5951
6212
|
...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
|
|
5952
6213
|
}), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
5953
6214
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
5954
|
-
this.userService = new
|
|
6215
|
+
this.userService = new Wr(this.userApi, this.deviceService, this.platform), this.tenantService = new Vr(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new zr(this.invitationApi), this.twoFactorService = new Ur(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Ia({
|
|
5955
6216
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
5956
6217
|
commitRefresh: async (e, t) => {
|
|
5957
6218
|
await this.authService.refreshToken(e, t);
|
|
@@ -5998,7 +6259,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5998
6259
|
return this.upgrade.attachAuth(e);
|
|
5999
6260
|
}
|
|
6000
6261
|
createClient(e) {
|
|
6001
|
-
return
|
|
6262
|
+
return Ta(e, (e) => this.upgrade.attachAuth(e));
|
|
6002
6263
|
}
|
|
6003
6264
|
readAssuranceBar() {
|
|
6004
6265
|
let e = this.storageManager.getToken(j.access_token);
|
|
@@ -6066,6 +6327,9 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6066
6327
|
handleTokensRedirect() {
|
|
6067
6328
|
return this.checkAndSetTokens();
|
|
6068
6329
|
}
|
|
6330
|
+
completeFederatedLanding() {
|
|
6331
|
+
return this.takeFederatedLanding();
|
|
6332
|
+
}
|
|
6069
6333
|
checkAndSetTokens() {
|
|
6070
6334
|
let e = this.platform.getCurrentUrl(), t = new URLSearchParams(e?.search ?? ""), n = !1;
|
|
6071
6335
|
if (!t.get("access_token") && e?.hash) {
|
|
@@ -6078,7 +6342,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6078
6342
|
}
|
|
6079
6343
|
let r = t.get("access_token"), i = t.get("refresh_token"), a = t.get("id_token"), o = t.get("scopes")?.split(",") ?? this.scopes, s;
|
|
6080
6344
|
if (r) {
|
|
6081
|
-
if (!
|
|
6345
|
+
if (!yr(r)) {
|
|
6082
6346
|
W(this.subscribeStore, {
|
|
6083
6347
|
operation: "tokens.from-url",
|
|
6084
6348
|
message: "Invalid access token format received",
|
|
@@ -6086,7 +6350,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6086
6350
|
}), this.cleanupUrlParams(n, e);
|
|
6087
6351
|
return;
|
|
6088
6352
|
}
|
|
6089
|
-
if (i && !
|
|
6353
|
+
if (i && !yr(i)) {
|
|
6090
6354
|
W(this.subscribeStore, {
|
|
6091
6355
|
operation: "tokens.from-url",
|
|
6092
6356
|
message: "Invalid refresh token format received",
|
|
@@ -6094,7 +6358,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6094
6358
|
}), this.cleanupUrlParams(n, e);
|
|
6095
6359
|
return;
|
|
6096
6360
|
}
|
|
6097
|
-
if (a && !
|
|
6361
|
+
if (a && !yr(a)) {
|
|
6098
6362
|
W(this.subscribeStore, {
|
|
6099
6363
|
operation: "tokens.from-url",
|
|
6100
6364
|
message: "Invalid ID token format received",
|
|
@@ -6112,7 +6376,16 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6112
6376
|
parsedTokens: this.getParsedTokens()
|
|
6113
6377
|
}), this.submitSessionCheck(), this.cleanupUrlParams(n, e), this.error = void 0, s;
|
|
6114
6378
|
}
|
|
6115
|
-
this.error = this.checkErrorsFromURL();
|
|
6379
|
+
this.deferFederatedLanding || this.takeFederatedLanding(), this.error = this.checkErrorsFromURL();
|
|
6380
|
+
}
|
|
6381
|
+
takeFederatedLanding() {
|
|
6382
|
+
let e = this.platform.getCurrentUrl();
|
|
6383
|
+
if (!e) return !1;
|
|
6384
|
+
let t = new URLSearchParams(e.search), n = t.get("code");
|
|
6385
|
+
if (t.get("access_token") || new URLSearchParams(e.hash?.substring(1)).get("access_token") || !n || !t.get("user_state") || !this.authService.handleFederatedCode(n)) return !1;
|
|
6386
|
+
t.delete("code"), t.delete("user_state");
|
|
6387
|
+
let r = t.toString();
|
|
6388
|
+
return this.platform.replaceUrl(e.pathname + (r ? `?${r}` : "") + e.hash), !0;
|
|
6116
6389
|
}
|
|
6117
6390
|
adoptTwoFactorTokenFromUrl(e) {
|
|
6118
6391
|
if (!e?.hash) return !1;
|
|
@@ -6120,7 +6393,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6120
6393
|
if (!n) return !1;
|
|
6121
6394
|
t.delete("tfa_token");
|
|
6122
6395
|
let r = t.toString();
|
|
6123
|
-
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")),
|
|
6396
|
+
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), yr(n) ? (this.subscribeStore.notify(Z.TwoFactorRequired, {
|
|
6124
6397
|
email: "",
|
|
6125
6398
|
challengeId: "",
|
|
6126
6399
|
tfaToken: n
|
|
@@ -6133,7 +6406,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6133
6406
|
checkErrorsFromURL() {
|
|
6134
6407
|
let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
|
|
6135
6408
|
if (e) {
|
|
6136
|
-
let t =
|
|
6409
|
+
let t = br(e);
|
|
6137
6410
|
return Error(t);
|
|
6138
6411
|
}
|
|
6139
6412
|
}
|
|
@@ -6194,6 +6467,18 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6194
6467
|
async passwordlessSignInComplete(e) {
|
|
6195
6468
|
return await this.authService.passwordlessSignInComplete(e);
|
|
6196
6469
|
}
|
|
6470
|
+
waitForPasswordlessSignIn(e, t) {
|
|
6471
|
+
return this.authService.waitForPasswordlessSignIn(e, t);
|
|
6472
|
+
}
|
|
6473
|
+
getPendingPasswordlessSignIn(e) {
|
|
6474
|
+
return this.authService.getPendingPasswordlessSignIn(e);
|
|
6475
|
+
}
|
|
6476
|
+
getPasswordlessApproval(e) {
|
|
6477
|
+
return this.authService.getPasswordlessApproval(e);
|
|
6478
|
+
}
|
|
6479
|
+
decidePasswordlessApproval(e, t, n, r) {
|
|
6480
|
+
return this.authService.decidePasswordlessApproval(e, t, n, r);
|
|
6481
|
+
}
|
|
6197
6482
|
async verifyEmailCode(e) {
|
|
6198
6483
|
return await this.authService.verifyEmailCode(e);
|
|
6199
6484
|
}
|
|
@@ -6477,7 +6762,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6477
6762
|
this.twoFactorService.clearMagicLinkSession();
|
|
6478
6763
|
}
|
|
6479
6764
|
};
|
|
6480
|
-
|
|
6481
|
-
export { i as APP_ID_HEADER_KEY, Me as APP_SECRET_NAMES, a as AUTHORIZATION_HEADER_KEY, Ke as AppAPI,
|
|
6765
|
+
La = Ra, La.version = c;
|
|
6766
|
+
export { i as APP_ID_HEADER_KEY, Me as APP_SECRET_NAMES, a as AUTHORIZATION_HEADER_KEY, Ke as AppAPI, Qe as AuthAPI, Rr as AuthService, $e as CLIAuthAPI, f as DEFAULT_GROUP_NAME, u as DEFAULT_SCOPES, Xr as DEFAULT_UPGRADE_FACTORS, o as DEVICE_ID_HEADER_KEY, s as DEVICE_TYPE_HEADER_KEY, b as ERROR_MESSAGE_MAX_LENGTH, ct as FETCH_PRIORITY_OIDC, lt as FETCH_PRIORITY_UPGRADE, ut as FetchMiddlewareContractError, ce as INSUFFICIENT_USER_AUTHENTICATION, et as InvitationAPI, zr as InvitationService, At as M2MClient, Tt as M2MConfigError, U as M2MError, Et as M2MErrorCodes, Ct as M2MNetworkError, wt as M2MTokenParseError, Dt as M2M_DEFAULTS, Ne as MASKED_SECRET_PREFIX, l as MINIMAL_DEFAULT_SCOPES, Ie as OS, d as PASSFLOW_CLOUD_URL, m as POPUP_HEIGHT, h as POPUP_POLL_INTERVAL_MS, g as POPUP_TIMEOUT_MS, p as POPUP_WIDTH, Ra as Passflow, Oe as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, B as PassflowError, Z as PassflowEvent, J as PassflowRefreshError, ie as PopupClosedError, je as Providers, er as RECOVERABLE_COMMIT_ERROR_IDS, xn as REFRESH_AUTH_FAILURE_IDS, q as RefreshErrorId, De as RequestMethod, c as SDK_VERSION, tr as SESSION_INVALIDATING_COMMIT_ERROR_IDS, Pe as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, te as SessionState, tt as SettingAPI, _ as TOKEN_EXPIRY_BUFFER_SECONDS, nt as TenantAPI, Vr as TenantService, Br as TenantUserMembership, Hr as TokenCacheService, M as TokenDeliveryMode, j as TokenType, at as TwoFactorApiClient, Re as TwoFactorPolicy, Ur as TwoFactorService, le as UPGRADE_REQUIRED, y as USERNAME_MAX_LENGTH, v as USERNAME_MIN_LENGTH, ot as UpgradeAPI, ri as UpgradeCancelledError, Nn as UpgradeCommitInterruptedError, fi as UpgradeController, Q as UpgradeErrorIds, Gr as UpgradeFactorError, mr as UpgradeInsufficientError, gr as UpgradeSessionChangedError, $ as UpgradeTransportError, hr as UpgradeUnavailableError, ii as UpgradeUnsatisfiableError, st as UserAPI, Wr as UserService, ae as WebAdapter, dr as classifyUpgradeError, Zr as factorRegistry, St as fetchRegistryState, Le as getOSFromDeviceType, pr as invalidatesSessionOnCommit, Ae as isEmailVerificationStep, Fe as isMaskedSecret, fr as isRecoverableCommitFailure, rr as isRetryableUpgradeKind, k as isTokenExpired, Vi as isUpgradeCancelled, Hi as isUpgradeExhausted, Ui as isUpgradeInsufficient, Ki as isUpgradeSessionChanged, sr as isUpgradeTransportError, qi as isUpgradeTransportFailure, Gi as isUpgradeUnavailable, Wi as isUpgradeUnsatisfiable, xr as isValidEmail, yr as isValidJWTFormat, Sr as isValidPhoneNumber, Cr as isValidUsername, he as parseChallengeBody, me as parseChallengeHeader, A as parseToken, ye as parseUpgradeChallenge, Yr as passkeyFactor, V as pathWithParams, Jr as recoveryCodesFactor, xt as registerFetchMiddleware, L as requiredAcrLevel, ke as resolveUpgradeDomain, br as sanitizeErrorMessage, ni as selectFactors, qr as totpFactor, P as webAdapter };
|
|
6482
6767
|
|
|
6483
6768
|
//# sourceMappingURL=index.mjs.map
|