@passflow/core 0.39.1 → 0.39.3
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 +18 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -6
- package/dist/index.d.ts +22 -6
- package/dist/index.mjs +688 -686
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ var a = "__passflowAntiBot", o = (e, t) => {
|
|
|
11
11
|
if (typeof e != "object" || !e) return;
|
|
12
12
|
let t = e[a];
|
|
13
13
|
return typeof t == "object" && t ? t : void 0;
|
|
14
|
-
}, c = "0.39.
|
|
14
|
+
}, c = "0.39.3", l = "X-Passflow-Clientid", u = "Authorization", d = "X-Passflow-DeviceId", f = "X-Passflow-DeviceType", p = "X-Passflow-Anti-Bot", m = "X-Passflow-Agent-Tool", h = "passflow_auth", g = c, _ = [
|
|
15
15
|
"id",
|
|
16
16
|
"offline",
|
|
17
17
|
"openid"
|
|
@@ -699,11 +699,11 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
699
699
|
}
|
|
700
700
|
}, it = "error.2fa.sms.quota.exceeded", at = "error.2fa.rate_limit_exceeded", ot = "error.2fa.recovery_codes.step_up_required", st = "error.user.address.change.proof.required", ct = class extends z {
|
|
701
701
|
constructor(e, t) {
|
|
702
|
-
super(e, t), this.name = "PassflowSmsQuotaExceededError";
|
|
702
|
+
super(e, t), this.name = "PassflowSmsQuotaExceededError", this.challenge = t?.challenge;
|
|
703
703
|
}
|
|
704
704
|
}, lt = class extends z {
|
|
705
705
|
constructor(e, t, n) {
|
|
706
|
-
super(e, n), this.name = "PassflowSendLimitError", this.retryAfter = t;
|
|
706
|
+
super(e, n), this.name = "PassflowSendLimitError", this.retryAfter = t, this.challenge = n?.challenge;
|
|
707
707
|
}
|
|
708
708
|
}, ut = class extends z {
|
|
709
709
|
constructor(e, t, n) {
|
|
@@ -777,19 +777,24 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
777
777
|
let n = Date.parse(t);
|
|
778
778
|
return Number.isNaN(n) ? void 0 : Math.max(0, Math.ceil((n - Date.now()) / 1e3));
|
|
779
779
|
}, Gt = (e) => {
|
|
780
|
+
let { challenge_id: t, suggested_method: n, alternative_methods: r } = e;
|
|
781
|
+
if (typeof t != "string" || t === "") return;
|
|
782
|
+
let i = { challenge_id: t };
|
|
783
|
+
return typeof n == "string" && (i.suggested_method = n), Array.isArray(r) && (i.alternative_methods = r.filter((e) => typeof e == "string")), i;
|
|
784
|
+
}, Kt = (e) => {
|
|
780
785
|
let t = e.response?.data;
|
|
781
786
|
if (!kt(t)) return;
|
|
782
|
-
let { error: n } = t;
|
|
787
|
+
let { error: n } = t, r = Gt(t);
|
|
783
788
|
switch (n.id) {
|
|
784
|
-
case it: return new ct(n);
|
|
785
|
-
case at: return new lt(n, Wt(e.response));
|
|
789
|
+
case it: return new ct(n, { challenge: r });
|
|
790
|
+
case at: return new lt(n, Wt(e.response), { challenge: r });
|
|
786
791
|
default: return;
|
|
787
792
|
}
|
|
788
|
-
},
|
|
793
|
+
}, qt = {
|
|
789
794
|
acrValues: "2",
|
|
790
795
|
requiredLevel: 2,
|
|
791
796
|
status: 403
|
|
792
|
-
},
|
|
797
|
+
}, Jt = class {
|
|
793
798
|
get origin() {
|
|
794
799
|
return this._platform.getCurrentUrl()?.origin ?? "";
|
|
795
800
|
}
|
|
@@ -870,7 +875,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
870
875
|
}
|
|
871
876
|
}
|
|
872
877
|
if (e.response?.status === 429) {
|
|
873
|
-
let t = Ht(e.config) ?
|
|
878
|
+
let t = Ht(e.config) ? Kt(e) : void 0;
|
|
874
879
|
return t ? Promise.reject(t) : await this.handleRateLimitError(e);
|
|
875
880
|
}
|
|
876
881
|
return this.handleAxiosError(e);
|
|
@@ -945,7 +950,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
945
950
|
switch (t.id) {
|
|
946
951
|
case Ke: return Promise.reject(new rt(t));
|
|
947
952
|
case st: return Promise.reject(new dt(t));
|
|
948
|
-
case ot: return Promise.reject(new ut(t, wt(e.response) ?? { ...
|
|
953
|
+
case ot: return Promise.reject(new ut(t, wt(e.response) ?? { ...qt }));
|
|
949
954
|
default: return Promise.reject(new z(t));
|
|
950
955
|
}
|
|
951
956
|
}
|
|
@@ -994,9 +999,9 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
994
999
|
[l]: e
|
|
995
1000
|
}, this.instance.defaults.headers[l] = e;
|
|
996
1001
|
}
|
|
997
|
-
},
|
|
1002
|
+
}, Yt = class {
|
|
998
1003
|
constructor(e, t, n) {
|
|
999
|
-
this.axiosClient = new
|
|
1004
|
+
this.axiosClient = new Jt(e, t, n);
|
|
1000
1005
|
}
|
|
1001
1006
|
setAppId(e) {
|
|
1002
1007
|
this.axiosClient.setAppId(e);
|
|
@@ -1004,7 +1009,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1004
1009
|
getAppSettings() {
|
|
1005
1010
|
return this.axiosClient.get(R.appSettings);
|
|
1006
1011
|
}
|
|
1007
|
-
},
|
|
1012
|
+
}, Xt = { withCredentials: !0 }, Zt = 15e3, Qt = "X-Passflow-CSRF", $t = "Sign-in failed. Start again.", en = "Something went wrong. Try again later.", tn = (e, t, n, r) => {
|
|
1008
1013
|
if (e instanceof z) return e;
|
|
1009
1014
|
let i = e?.response?.data?.error;
|
|
1010
1015
|
return new z({
|
|
@@ -1021,9 +1026,9 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1021
1026
|
...e?.headers,
|
|
1022
1027
|
[m]: "1"
|
|
1023
1028
|
} } : {}
|
|
1024
|
-
},
|
|
1029
|
+
}, nn = class {
|
|
1025
1030
|
constructor(e, t, n) {
|
|
1026
|
-
this.axiosClient = new
|
|
1031
|
+
this.axiosClient = new Jt(e, t, n);
|
|
1027
1032
|
}
|
|
1028
1033
|
setAppId(e) {
|
|
1029
1034
|
this.axiosClient.setAppId(e);
|
|
@@ -1035,24 +1040,24 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1035
1040
|
try {
|
|
1036
1041
|
return await this.axiosClient.post(R.antiBotChallenge, e);
|
|
1037
1042
|
} catch (e) {
|
|
1038
|
-
throw
|
|
1043
|
+
throw tn(e, R.antiBotChallenge, "error.anti_bot.challenge", en);
|
|
1039
1044
|
}
|
|
1040
1045
|
}
|
|
1041
1046
|
async deviceAntiBotChallenge(e, t) {
|
|
1042
1047
|
try {
|
|
1043
|
-
return await this.axiosClient.post(R.deviceAntiBotChallenge, e, { headers: { [
|
|
1048
|
+
return await this.axiosClient.post(R.deviceAntiBotChallenge, e, { headers: { [Qt]: t } });
|
|
1044
1049
|
} catch (e) {
|
|
1045
|
-
throw
|
|
1050
|
+
throw tn(e, R.deviceAntiBotChallenge, "error.anti_bot.challenge", en);
|
|
1046
1051
|
}
|
|
1047
1052
|
}
|
|
1048
1053
|
federatedStart(e, t, n) {
|
|
1049
|
-
return this.axiosClient.post(`${R.signInWithProvider}${e}`, t, B(
|
|
1054
|
+
return this.axiosClient.post(`${R.signInWithProvider}${e}`, t, B(Xt, "federated.start", void 0, n));
|
|
1050
1055
|
}
|
|
1051
1056
|
enterpriseResolve(e) {
|
|
1052
1057
|
return this.axiosClient.post(R.enterpriseResolve, { email: e });
|
|
1053
1058
|
}
|
|
1054
1059
|
enterpriseStart(e, t) {
|
|
1055
|
-
return this.axiosClient.post(R.enterpriseStart, e, B(
|
|
1060
|
+
return this.axiosClient.post(R.enterpriseStart, e, B(Xt, "federated.start", e.email, t));
|
|
1056
1061
|
}
|
|
1057
1062
|
refreshToken(e, t, n, r) {
|
|
1058
1063
|
let i = {
|
|
@@ -1068,7 +1073,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1068
1073
|
device: t,
|
|
1069
1074
|
os: n
|
|
1070
1075
|
};
|
|
1071
|
-
return this.axiosClient.post(R.signin, i, B(
|
|
1076
|
+
return this.axiosClient.post(R.signin, i, B(Xt, "sign-in", e.email ?? e.phone ?? e.username, r));
|
|
1072
1077
|
}
|
|
1073
1078
|
signUp(e, t) {
|
|
1074
1079
|
let { create_tenant: n, anonymous: r } = e, i = {
|
|
@@ -1076,16 +1081,16 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1076
1081
|
create_tenant: n ?? !1,
|
|
1077
1082
|
anonymous: r ?? !1
|
|
1078
1083
|
};
|
|
1079
|
-
return this.axiosClient.post(R.signup, i, B(
|
|
1084
|
+
return this.axiosClient.post(R.signup, i, B(Xt, "sign-up", e.user.email ?? e.user.phone_number ?? e.user.username, t));
|
|
1080
1085
|
}
|
|
1081
1086
|
async pkceExchange(e, t) {
|
|
1082
1087
|
try {
|
|
1083
1088
|
return await this.axiosClient.post(R.pkceExchange, {
|
|
1084
1089
|
authz_code: e,
|
|
1085
1090
|
verifier: t
|
|
1086
|
-
},
|
|
1091
|
+
}, Xt);
|
|
1087
1092
|
} catch (e) {
|
|
1088
|
-
throw
|
|
1093
|
+
throw tn(e, R.pkceExchange, "error.pkce.exchange", $t);
|
|
1089
1094
|
}
|
|
1090
1095
|
}
|
|
1091
1096
|
async passwordlessSignIn(e, t, n, r) {
|
|
@@ -1098,53 +1103,53 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1098
1103
|
try {
|
|
1099
1104
|
return await this.axiosClient.post(R.passwordless, a, B(void 0, "passwordless.start", e.email ?? e.phone, r));
|
|
1100
1105
|
} catch (e) {
|
|
1101
|
-
throw
|
|
1106
|
+
throw tn(e, R.passwordless, "error.passwordless.start", en);
|
|
1102
1107
|
}
|
|
1103
1108
|
}
|
|
1104
1109
|
async passwordlessSignInComplete(e, t) {
|
|
1105
1110
|
try {
|
|
1106
|
-
return await this.axiosClient.post(R.passwordlessComplete, e, B(
|
|
1111
|
+
return await this.axiosClient.post(R.passwordlessComplete, e, B(Xt, void 0, void 0, t));
|
|
1107
1112
|
} catch (e) {
|
|
1108
|
-
throw
|
|
1113
|
+
throw tn(e, R.passwordlessComplete, "error.passwordless.complete", en);
|
|
1109
1114
|
}
|
|
1110
1115
|
}
|
|
1111
1116
|
async passwordlessStatus(e, t) {
|
|
1112
1117
|
try {
|
|
1113
1118
|
return await this.axiosClient.post(R.passwordlessStatus, e, {
|
|
1114
|
-
...
|
|
1115
|
-
timeout:
|
|
1119
|
+
...Xt,
|
|
1120
|
+
timeout: Zt,
|
|
1116
1121
|
signal: t?.signal
|
|
1117
1122
|
});
|
|
1118
1123
|
} catch (e) {
|
|
1119
|
-
throw
|
|
1124
|
+
throw tn(e, R.passwordlessStatus, "error.passwordless.status", $t);
|
|
1120
1125
|
}
|
|
1121
1126
|
}
|
|
1122
1127
|
async checkRedirectUrl(e) {
|
|
1123
1128
|
try {
|
|
1124
1129
|
return (await this.axiosClient.post(R.redirectCheck, { redirect_url: e })).redirect_url;
|
|
1125
1130
|
} catch (e) {
|
|
1126
|
-
throw
|
|
1131
|
+
throw tn(e, R.redirectCheck, "error.redirect.check", en);
|
|
1127
1132
|
}
|
|
1128
1133
|
}
|
|
1129
1134
|
async passwordlessApprovalInfo(e) {
|
|
1130
1135
|
try {
|
|
1131
1136
|
return await this.axiosClient.post(R.passwordlessApprovalInfo, e);
|
|
1132
1137
|
} catch (e) {
|
|
1133
|
-
throw
|
|
1138
|
+
throw tn(e, R.passwordlessApprovalInfo, "error.passwordless.approval", en);
|
|
1134
1139
|
}
|
|
1135
1140
|
}
|
|
1136
1141
|
async passwordlessApprovalDecide(e) {
|
|
1137
1142
|
try {
|
|
1138
1143
|
return await this.axiosClient.post(R.passwordlessApprovalDecide, e);
|
|
1139
1144
|
} catch (e) {
|
|
1140
|
-
throw
|
|
1145
|
+
throw tn(e, R.passwordlessApprovalDecide, "error.passwordless.approval", en);
|
|
1141
1146
|
}
|
|
1142
1147
|
}
|
|
1143
1148
|
validateEmailCode(e) {
|
|
1144
1149
|
return this.axiosClient.post(R.passkeyValidate, {
|
|
1145
1150
|
challenge_id: e.challenge_id,
|
|
1146
1151
|
otp: e.otp
|
|
1147
|
-
},
|
|
1152
|
+
}, Xt);
|
|
1148
1153
|
}
|
|
1149
1154
|
logOut(e, t, n = !1) {
|
|
1150
1155
|
let r = n ? void 0 : {
|
|
@@ -1185,7 +1190,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1185
1190
|
device: t,
|
|
1186
1191
|
passkey_data: e
|
|
1187
1192
|
}, o = r ? Ve.passkeyRegisterComplete : R.passkeyRegisterComplete;
|
|
1188
|
-
return this.axiosClient.post(o, a, B(
|
|
1193
|
+
return this.axiosClient.post(o, a, B(Xt, void 0, void 0, i));
|
|
1189
1194
|
}
|
|
1190
1195
|
passkeyAuthenticateStart(e, t, n, r = !1, i) {
|
|
1191
1196
|
let a = {
|
|
@@ -1202,7 +1207,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1202
1207
|
device: t,
|
|
1203
1208
|
passkey_data: e
|
|
1204
1209
|
}, o = r ? Ve.passkeyAuthenticateComplete : R.passkeyAuthenticateComplete;
|
|
1205
|
-
return this.axiosClient.post(o, a, B(
|
|
1210
|
+
return this.axiosClient.post(o, a, B(Xt, void 0, void 0, i));
|
|
1206
1211
|
}
|
|
1207
1212
|
passkeyValidate(e, t, n, r = !1, i) {
|
|
1208
1213
|
let a = {
|
|
@@ -1214,9 +1219,9 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1214
1219
|
let s = i ? { [l]: i } : {};
|
|
1215
1220
|
return this.axiosClient.post(o, a, { headers: s });
|
|
1216
1221
|
}
|
|
1217
|
-
},
|
|
1222
|
+
}, rn = class {
|
|
1218
1223
|
constructor(e, t, n) {
|
|
1219
|
-
this.axiosClient = new
|
|
1224
|
+
this.axiosClient = new Jt(e, t, n);
|
|
1220
1225
|
}
|
|
1221
1226
|
setAppId(e) {
|
|
1222
1227
|
this.axiosClient.setAppId(e);
|
|
@@ -1228,9 +1233,9 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1228
1233
|
completeCLIAuth(e) {
|
|
1229
1234
|
return this.axiosClient.post(R.cliAuthComplete, e);
|
|
1230
1235
|
}
|
|
1231
|
-
},
|
|
1236
|
+
}, an = class {
|
|
1232
1237
|
constructor(e, t, n) {
|
|
1233
|
-
this.axiosClient = new
|
|
1238
|
+
this.axiosClient = new Jt(e, t, n);
|
|
1234
1239
|
}
|
|
1235
1240
|
setAppId(e) {
|
|
1236
1241
|
this.axiosClient.setAppId(e);
|
|
@@ -1259,9 +1264,9 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1259
1264
|
let t = yt(R.invitationGetLink, { invitationID: e });
|
|
1260
1265
|
return this.axiosClient.get(t);
|
|
1261
1266
|
}
|
|
1262
|
-
},
|
|
1267
|
+
}, on = class {
|
|
1263
1268
|
constructor(e, t, n) {
|
|
1264
|
-
this.axiosClient = new
|
|
1269
|
+
this.axiosClient = new Jt(e, t, n);
|
|
1265
1270
|
}
|
|
1266
1271
|
setAppId(e) {
|
|
1267
1272
|
this.axiosClient.setAppId(e);
|
|
@@ -1275,9 +1280,9 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1275
1280
|
getPasskeySettings() {
|
|
1276
1281
|
return this.axiosClient.get(R.settingsPasskey);
|
|
1277
1282
|
}
|
|
1278
|
-
},
|
|
1283
|
+
}, sn = class {
|
|
1279
1284
|
constructor(e, t, n) {
|
|
1280
|
-
this.axiosClient = new
|
|
1285
|
+
this.axiosClient = new Jt(e, t, n);
|
|
1281
1286
|
}
|
|
1282
1287
|
setAppId(e) {
|
|
1283
1288
|
this.axiosClient.setAppId(e);
|
|
@@ -1391,20 +1396,20 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1391
1396
|
let r = `${R.tenantPath}/${e}/group/${t}/invite/email/${n}`;
|
|
1392
1397
|
return this.axiosClient.delete(r);
|
|
1393
1398
|
}
|
|
1394
|
-
},
|
|
1399
|
+
}, cn = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, ln = (e) => ({
|
|
1395
1400
|
withCredentials: !0,
|
|
1396
|
-
...
|
|
1397
|
-
}),
|
|
1401
|
+
...cn(e)
|
|
1402
|
+
}), un = ({ qr_code_image: e, qr_code: t, ...n }) => ({
|
|
1398
1403
|
...n,
|
|
1399
1404
|
qr_code: (t ?? e ?? "").replace(/^data:image\/png;base64,/, "")
|
|
1400
|
-
}),
|
|
1405
|
+
}), dn = {
|
|
1401
1406
|
"error.2fa.setup.token.expired": "EXPIRED_TOKEN",
|
|
1402
1407
|
"error.2fa.setup.token.revoked": "REVOKED_TOKEN",
|
|
1403
1408
|
"error.2fa.setup.token.already_used": "ALREADY_USED",
|
|
1404
1409
|
"error.2fa.setup.token.rate.limit.exceeded": "RATE_LIMITED"
|
|
1405
|
-
},
|
|
1410
|
+
}, fn = class {
|
|
1406
1411
|
constructor(e, t, n) {
|
|
1407
|
-
this.axiosClient = new
|
|
1412
|
+
this.axiosClient = new Jt(e, t, n);
|
|
1408
1413
|
}
|
|
1409
1414
|
setAppId(e) {
|
|
1410
1415
|
this.axiosClient.setAppId(e);
|
|
@@ -1413,7 +1418,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1413
1418
|
return this.axiosClient.get(R.twoFactorStatus, Bt(e));
|
|
1414
1419
|
}
|
|
1415
1420
|
async beginSetup(e) {
|
|
1416
|
-
return
|
|
1421
|
+
return un(await this.axiosClient.post(R.twoFactorSetupBegin, {}, Bt(e)));
|
|
1417
1422
|
}
|
|
1418
1423
|
confirmSetup(e, t) {
|
|
1419
1424
|
return this.axiosClient.post(R.twoFactorSetupConfirm, e, Bt(t));
|
|
@@ -1425,7 +1430,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1425
1430
|
return this.axiosClient.post(R.twoFactorEnrollmentEmailLink, void 0, Bt(e));
|
|
1426
1431
|
}
|
|
1427
1432
|
async beginEnrollment(e) {
|
|
1428
|
-
return
|
|
1433
|
+
return un(await this.axiosClient.post(R.twoFactorEnrollmentBegin, void 0, Bt(e)));
|
|
1429
1434
|
}
|
|
1430
1435
|
confirmEnrollment(e, t) {
|
|
1431
1436
|
return this.axiosClient.post(R.twoFactorEnrollmentConfirm, t, Bt(e));
|
|
@@ -1435,14 +1440,14 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1435
1440
|
return this.axiosClient.post(R.twoFactorVerify, {
|
|
1436
1441
|
code: n,
|
|
1437
1442
|
...r ? { trust_device: !0 } : {}
|
|
1438
|
-
},
|
|
1443
|
+
}, ln(t));
|
|
1439
1444
|
}
|
|
1440
1445
|
useRecoveryCode(e) {
|
|
1441
1446
|
let { tfa_token: t, recovery_code: n, trust_device: r } = e;
|
|
1442
1447
|
return this.axiosClient.post(R.twoFactorRecovery, {
|
|
1443
1448
|
recovery_code: n,
|
|
1444
1449
|
...r ? { trust_device: !0 } : {}
|
|
1445
|
-
},
|
|
1450
|
+
}, ln(t));
|
|
1446
1451
|
}
|
|
1447
1452
|
disable(e) {
|
|
1448
1453
|
return this.axiosClient.delete(R.twoFactor, { data: e });
|
|
@@ -1472,7 +1477,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1472
1477
|
if (e instanceof z) return {
|
|
1473
1478
|
success: !1,
|
|
1474
1479
|
error: {
|
|
1475
|
-
code:
|
|
1480
|
+
code: dn[e.id] ?? this.mapStatusToErrorCode(e.status),
|
|
1476
1481
|
message: e.message || this.getDefaultErrorMessage(e.status)
|
|
1477
1482
|
}
|
|
1478
1483
|
};
|
|
@@ -1551,17 +1556,17 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1551
1556
|
return this.axiosClient.delete(t);
|
|
1552
1557
|
}
|
|
1553
1558
|
requestChallenge(e, t) {
|
|
1554
|
-
return this.axiosClient.post(R.TwoFactorChallenge, e, Ut(
|
|
1559
|
+
return this.axiosClient.post(R.TwoFactorChallenge, e, Ut(cn(t)));
|
|
1555
1560
|
}
|
|
1556
1561
|
verifyV2(e, t) {
|
|
1557
1562
|
let { trust_device: n, ...r } = e;
|
|
1558
1563
|
return this.axiosClient.post(R.TwoFactorVerifyV2, {
|
|
1559
1564
|
...r,
|
|
1560
1565
|
...n ? { trust_device: !0 } : {}
|
|
1561
|
-
},
|
|
1566
|
+
}, ln(t));
|
|
1562
1567
|
}
|
|
1563
1568
|
switchToAlternative(e, t) {
|
|
1564
|
-
return this.axiosClient.post(R.TwoFactorAlternative, e, Ut(
|
|
1569
|
+
return this.axiosClient.post(R.TwoFactorAlternative, e, Ut(cn(t)));
|
|
1565
1570
|
}
|
|
1566
1571
|
async getTrustedDevices() {
|
|
1567
1572
|
return (await this.axiosClient.get(R.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
|
|
@@ -1579,9 +1584,9 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1579
1584
|
async clearPreferredMethod() {
|
|
1580
1585
|
await this.axiosClient.delete(R.TwoFactorPreferredMethod);
|
|
1581
1586
|
}
|
|
1582
|
-
},
|
|
1587
|
+
}, pn = class {
|
|
1583
1588
|
constructor(e, t, n) {
|
|
1584
|
-
this.axiosClient = new
|
|
1589
|
+
this.axiosClient = new Jt(e, t, n);
|
|
1585
1590
|
}
|
|
1586
1591
|
setAppId(e) {
|
|
1587
1592
|
this.axiosClient.setAppId(e);
|
|
@@ -1595,9 +1600,9 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1595
1600
|
async commitHostedUpgrade(e) {
|
|
1596
1601
|
await this.axiosClient.post(R.hostedUpgrade, e, { withCredentials: !0 });
|
|
1597
1602
|
}
|
|
1598
|
-
},
|
|
1603
|
+
}, mn = class {
|
|
1599
1604
|
constructor(e, t, n) {
|
|
1600
|
-
this.axiosClient = new
|
|
1605
|
+
this.axiosClient = new Jt(e, t, n);
|
|
1601
1606
|
}
|
|
1602
1607
|
setAppId(e) {
|
|
1603
1608
|
this.axiosClient.setAppId(e);
|
|
@@ -1646,48 +1651,48 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1646
1651
|
...t ? { proof: t } : {}
|
|
1647
1652
|
}, Ut());
|
|
1648
1653
|
}
|
|
1649
|
-
},
|
|
1654
|
+
}, hn = 10, gn = 20, _n = class extends Error {
|
|
1650
1655
|
constructor(e) {
|
|
1651
1656
|
super(`Passflow fetch middleware '${e}' resolved without calling next(). Every registered middleware must delegate exactly once; swallowing a request would drop a caller's fetch inside the Passflow wrapper.`), this.name = "FetchMiddlewareContractError", this.middlewareName = e;
|
|
1652
1657
|
}
|
|
1653
|
-
},
|
|
1658
|
+
}, vn = [], yn = 0, bn = !1, xn, Sn, Cn = (e, t) => e.priority - t.priority || e.seq - t.seq, wn = () => typeof globalThis > "u" ? void 0 : globalThis, Tn = async (e, t, n, r) => {
|
|
1654
1659
|
if (t >= e.length) {
|
|
1655
|
-
let e =
|
|
1660
|
+
let e = xn;
|
|
1656
1661
|
if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
|
|
1657
1662
|
return e(n, r);
|
|
1658
1663
|
}
|
|
1659
1664
|
let i = e[t];
|
|
1660
|
-
if (!i) return
|
|
1661
|
-
let a = !1, o = await i.middleware((n, r) => (a = !0,
|
|
1662
|
-
if (!a) throw new
|
|
1665
|
+
if (!i) return Tn(e, e.length, n, r);
|
|
1666
|
+
let a = !1, o = await i.middleware((n, r) => (a = !0, Tn(e, t + 1, n, r)), n, r);
|
|
1667
|
+
if (!a) throw new _n(i.name);
|
|
1663
1668
|
return o;
|
|
1664
|
-
}, Tn = () => {
|
|
1665
|
-
let e = Cn();
|
|
1666
|
-
if (!e || typeof e.fetch != "function") return !1;
|
|
1667
|
-
let t = e.fetch.bind(e), n = (e, t) => wn([..._n].sort(Sn), 0, e, t);
|
|
1668
|
-
return bn = t, xn = n, e.fetch = n, yn = !0, !0;
|
|
1669
1669
|
}, En = () => {
|
|
1670
|
-
let e =
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1670
|
+
let e = wn();
|
|
1671
|
+
if (!e || typeof e.fetch != "function") return !1;
|
|
1672
|
+
let t = e.fetch.bind(e), n = (e, t) => Tn([...vn].sort(Cn), 0, e, t);
|
|
1673
|
+
return xn = t, Sn = n, e.fetch = n, bn = !0, !0;
|
|
1674
|
+
}, Dn = () => {
|
|
1675
|
+
let e = wn();
|
|
1676
|
+
e && Sn && e.fetch === Sn && (xn && (e.fetch = xn), bn = !1, Sn = void 0, xn = void 0);
|
|
1677
|
+
}, On = (e, t) => {
|
|
1678
|
+
if (!bn && !En()) return () => {};
|
|
1674
1679
|
let n = {
|
|
1675
1680
|
middleware: e,
|
|
1676
1681
|
name: t.name,
|
|
1677
1682
|
priority: t.priority,
|
|
1678
|
-
seq:
|
|
1683
|
+
seq: yn++
|
|
1679
1684
|
};
|
|
1680
|
-
|
|
1685
|
+
vn.push(n);
|
|
1681
1686
|
let r = !1;
|
|
1682
1687
|
return () => {
|
|
1683
|
-
r || (r = !0,
|
|
1688
|
+
r || (r = !0, vn = vn.filter((e) => e !== n), vn.length === 0 && Dn());
|
|
1684
1689
|
};
|
|
1685
|
-
},
|
|
1686
|
-
let e =
|
|
1690
|
+
}, kn = () => {
|
|
1691
|
+
let e = wn();
|
|
1687
1692
|
return {
|
|
1688
|
-
installed:
|
|
1689
|
-
names: [...
|
|
1690
|
-
foreignPatch:
|
|
1693
|
+
installed: bn,
|
|
1694
|
+
names: [...vn].sort(Cn).map((e) => e.name),
|
|
1695
|
+
foreignPatch: bn && !!e && !!Sn && e.fetch !== Sn
|
|
1691
1696
|
};
|
|
1692
1697
|
}, V = class e extends Error {
|
|
1693
1698
|
constructor(t) {
|
|
@@ -1758,7 +1763,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1758
1763
|
let e = `M2MError [${this.code}]: ${this.message}`;
|
|
1759
1764
|
return this.status && (e += ` (HTTP ${this.status})`), e;
|
|
1760
1765
|
}
|
|
1761
|
-
},
|
|
1766
|
+
}, An = class extends V {
|
|
1762
1767
|
constructor(e, t) {
|
|
1763
1768
|
super({
|
|
1764
1769
|
code: "temporarily_unavailable",
|
|
@@ -1767,7 +1772,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1767
1772
|
cause: t
|
|
1768
1773
|
}), this.name = "M2MNetworkError";
|
|
1769
1774
|
}
|
|
1770
|
-
},
|
|
1775
|
+
}, jn = class extends V {
|
|
1771
1776
|
constructor(e, t) {
|
|
1772
1777
|
super({
|
|
1773
1778
|
code: "invalid_request",
|
|
@@ -1776,7 +1781,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1776
1781
|
cause: t
|
|
1777
1782
|
}), this.name = "M2MTokenParseError";
|
|
1778
1783
|
}
|
|
1779
|
-
},
|
|
1784
|
+
}, Mn = class extends V {
|
|
1780
1785
|
constructor(e) {
|
|
1781
1786
|
super({
|
|
1782
1787
|
code: "invalid_request",
|
|
@@ -1784,7 +1789,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1784
1789
|
status: 400
|
|
1785
1790
|
}), this.name = "M2MConfigError";
|
|
1786
1791
|
}
|
|
1787
|
-
},
|
|
1792
|
+
}, Nn = {
|
|
1788
1793
|
InvalidRequest: "invalid_request",
|
|
1789
1794
|
InvalidClient: "invalid_client",
|
|
1790
1795
|
InvalidGrant: "invalid_grant",
|
|
@@ -1794,14 +1799,14 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1794
1799
|
RateLimitExceeded: "rate_limit_exceeded",
|
|
1795
1800
|
ServerError: "server_error",
|
|
1796
1801
|
TemporarilyUnavailable: "temporarily_unavailable"
|
|
1797
|
-
},
|
|
1802
|
+
}, Pn = {
|
|
1798
1803
|
TOKEN_ENDPOINT: "/oauth2/token",
|
|
1799
1804
|
TIMEOUT: 1e4,
|
|
1800
1805
|
RETRIES: 3,
|
|
1801
1806
|
RETRY_DELAY: 1e3,
|
|
1802
1807
|
REFRESH_THRESHOLD: 30,
|
|
1803
1808
|
CONTENT_TYPE: "application/x-www-form-urlencoded"
|
|
1804
|
-
},
|
|
1809
|
+
}, Fn = class {
|
|
1805
1810
|
constructor() {
|
|
1806
1811
|
this.cache = /* @__PURE__ */ new Map();
|
|
1807
1812
|
}
|
|
@@ -1818,18 +1823,18 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1818
1823
|
delete(e) {
|
|
1819
1824
|
return this.cache.delete(e), Promise.resolve();
|
|
1820
1825
|
}
|
|
1821
|
-
},
|
|
1826
|
+
}, In = {
|
|
1822
1827
|
shouldRetry(e, t) {
|
|
1823
1828
|
return t >= 3 ? !1 : e.code === "server_error" || e.code === "temporarily_unavailable" || e.code === "rate_limit_exceeded" || e.status !== void 0 && e.status >= 500;
|
|
1824
1829
|
},
|
|
1825
1830
|
getDelay(e) {
|
|
1826
1831
|
return 2 ** (e - 1) * 1e3;
|
|
1827
1832
|
}
|
|
1828
|
-
},
|
|
1833
|
+
}, Ln = class {
|
|
1829
1834
|
constructor(e) {
|
|
1830
|
-
if (!e.url) throw new
|
|
1831
|
-
if (!e.clientId) throw new
|
|
1832
|
-
if (!e.clientSecret) throw new
|
|
1835
|
+
if (!e.url) throw new Mn("M2M client requires a URL");
|
|
1836
|
+
if (!e.clientId) throw new Mn("M2M client requires a clientId");
|
|
1837
|
+
if (!e.clientSecret) throw new Mn("M2M client requires a clientSecret");
|
|
1833
1838
|
let t = e.url.replace(/\/$/, "");
|
|
1834
1839
|
this.config = {
|
|
1835
1840
|
url: t,
|
|
@@ -1838,16 +1843,16 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1838
1843
|
scopes: e.scopes,
|
|
1839
1844
|
audience: e.audience,
|
|
1840
1845
|
autoRefresh: e.autoRefresh ?? !1,
|
|
1841
|
-
refreshThreshold: e.refreshThreshold ??
|
|
1842
|
-
timeout: e.timeout ??
|
|
1843
|
-
retries: e.retries ??
|
|
1844
|
-
retryDelay: e.retryDelay ??
|
|
1846
|
+
refreshThreshold: e.refreshThreshold ?? Pn.REFRESH_THRESHOLD,
|
|
1847
|
+
timeout: e.timeout ?? Pn.TIMEOUT,
|
|
1848
|
+
retries: e.retries ?? Pn.RETRIES,
|
|
1849
|
+
retryDelay: e.retryDelay ?? Pn.RETRY_DELAY,
|
|
1845
1850
|
retryStrategy: e.retryStrategy,
|
|
1846
1851
|
cache: e.cache,
|
|
1847
1852
|
onTokenRequest: e.onTokenRequest,
|
|
1848
1853
|
onTokenResponse: e.onTokenResponse,
|
|
1849
1854
|
onError: e.onError
|
|
1850
|
-
}, this.cache = e.cache ?? new
|
|
1855
|
+
}, this.cache = e.cache ?? new Fn(), this.retryStrategy = e.retryStrategy ?? In, this.tokenEndpoint = `${t}${Pn.TOKEN_ENDPOINT}`;
|
|
1851
1856
|
}
|
|
1852
1857
|
getCacheKey(e, t) {
|
|
1853
1858
|
let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
|
|
@@ -1892,7 +1897,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1892
1897
|
let e = await fetch(this.tokenEndpoint, {
|
|
1893
1898
|
method: "POST",
|
|
1894
1899
|
headers: {
|
|
1895
|
-
"Content-Type":
|
|
1900
|
+
"Content-Type": Pn.CONTENT_TYPE,
|
|
1896
1901
|
Accept: "application/json"
|
|
1897
1902
|
},
|
|
1898
1903
|
body: t.toString(),
|
|
@@ -1917,7 +1922,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1917
1922
|
}
|
|
1918
1923
|
return a;
|
|
1919
1924
|
} catch (e) {
|
|
1920
|
-
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new
|
|
1925
|
+
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new An(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new An(`Network error: ${e.message}`, e) : e instanceof V ? e : V.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1921
1926
|
}
|
|
1922
1927
|
}
|
|
1923
1928
|
async executeWithRetry(e) {
|
|
@@ -1960,13 +1965,13 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1960
1965
|
parseToken(e) {
|
|
1961
1966
|
try {
|
|
1962
1967
|
let t = e.split(".");
|
|
1963
|
-
if (t.length !== 3) throw new
|
|
1968
|
+
if (t.length !== 3) throw new jn("Invalid JWT format: expected 3 parts");
|
|
1964
1969
|
let n = t[1];
|
|
1965
|
-
if (!n) throw new
|
|
1970
|
+
if (!n) throw new jn("Invalid JWT format: missing payload");
|
|
1966
1971
|
let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
|
|
1967
1972
|
return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
|
|
1968
1973
|
} catch (e) {
|
|
1969
|
-
throw e instanceof
|
|
1974
|
+
throw e instanceof jn ? e : new jn(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
1970
1975
|
}
|
|
1971
1976
|
}
|
|
1972
1977
|
clearCache() {
|
|
@@ -1981,7 +1986,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
1981
1986
|
try {
|
|
1982
1987
|
let e = await fetch(t, {
|
|
1983
1988
|
method: "POST",
|
|
1984
|
-
headers: { "Content-Type":
|
|
1989
|
+
headers: { "Content-Type": Pn.CONTENT_TYPE },
|
|
1985
1990
|
body: n.toString()
|
|
1986
1991
|
});
|
|
1987
1992
|
if (!e.ok && e.status !== 200) {
|
|
@@ -2008,50 +2013,50 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
2008
2013
|
get audience() {
|
|
2009
2014
|
return this.config.audience;
|
|
2010
2015
|
}
|
|
2011
|
-
},
|
|
2016
|
+
}, Rn = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", zn = 32, Bn = (e) => {
|
|
2012
2017
|
let t = "";
|
|
2013
2018
|
for (let n = 0; n < e.length; n += 3) {
|
|
2014
2019
|
let r = e[n], i = e[n + 1], a = e[n + 2];
|
|
2015
|
-
t +=
|
|
2020
|
+
t += Rn.charAt(r >> 2), t += Rn.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += Rn.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += Rn.charAt(a & 63));
|
|
2016
2021
|
}
|
|
2017
2022
|
return t;
|
|
2018
|
-
},
|
|
2023
|
+
}, Vn = () => {
|
|
2019
2024
|
let e = globalThis.crypto;
|
|
2020
2025
|
if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
2021
2026
|
return e;
|
|
2022
|
-
},
|
|
2023
|
-
let t = await
|
|
2024
|
-
return
|
|
2025
|
-
},
|
|
2026
|
-
let e =
|
|
2027
|
+
}, Hn = async (e) => {
|
|
2028
|
+
let t = await Vn().subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
2029
|
+
return Bn(new Uint8Array(t));
|
|
2030
|
+
}, Un = (e = zn) => Bn(Vn().getRandomValues(new Uint8Array(e))), Wn = async () => {
|
|
2031
|
+
let e = Un(zn);
|
|
2027
2032
|
return {
|
|
2028
2033
|
verifier: e,
|
|
2029
|
-
challenge: await
|
|
2034
|
+
challenge: await Hn(e)
|
|
2030
2035
|
};
|
|
2031
|
-
},
|
|
2036
|
+
}, Gn = () => !!globalThis.crypto?.subtle, H = class extends Error {
|
|
2032
2037
|
constructor(e, t) {
|
|
2033
2038
|
super(t), this.code = e, this.name = "PassflowOidcError";
|
|
2034
2039
|
}
|
|
2035
|
-
},
|
|
2040
|
+
}, Kn = "Sign in again.", qn = (e) => `This app is type ${e} and is a confidential client (it has a secret). For a browser app set its type to SPA; a server-side app redeems the code on its server with the secret.`, Jn = "This app is a confidential client. For a browser app set its type to SPA (or token_endpoint_auth_method to none); a server-side app must redeem the code on its server with the client secret.", Yn = () => new H("TOKENS_IN_URL_NOT_ALLOWED", "Tokens in the URL are accepted only for apps in Simple mode"), Xn = "passflow_oidc_pkce", Zn = 6e5, Qn = (e) => {
|
|
2036
2041
|
try {
|
|
2037
2042
|
let t = new URL(e);
|
|
2038
2043
|
return `${t.protocol}//${t.host}${t.pathname.replace(/\/+$/, "")}`;
|
|
2039
2044
|
} catch {
|
|
2040
2045
|
return e;
|
|
2041
2046
|
}
|
|
2042
|
-
},
|
|
2043
|
-
if (!
|
|
2044
|
-
let t =
|
|
2047
|
+
}, $n = (e) => !e.includes("openid") && (e.includes("id") || e.includes("oidc")) ? [...e, "openid"] : [...e], er = async (e) => {
|
|
2048
|
+
if (!Gn()) throw new H("SECURE_CONTEXT_REQUIRED", "Sign-in needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
2049
|
+
let t = $n(e.scopes), n = await Wn(), r = {
|
|
2045
2050
|
verifier: n.verifier,
|
|
2046
|
-
state:
|
|
2047
|
-
...t.includes("openid") ? { nonce:
|
|
2051
|
+
state: Un(),
|
|
2052
|
+
...t.includes("openid") ? { nonce: Un() } : {},
|
|
2048
2053
|
clientId: e.clientId,
|
|
2049
2054
|
redirectUri: e.redirectUri,
|
|
2050
2055
|
scopes: t,
|
|
2051
|
-
expiresAt: Date.now() +
|
|
2056
|
+
expiresAt: Date.now() + Zn
|
|
2052
2057
|
};
|
|
2053
2058
|
try {
|
|
2054
|
-
sessionStorage.setItem(
|
|
2059
|
+
sessionStorage.setItem(Xn, JSON.stringify(r));
|
|
2055
2060
|
} catch {
|
|
2056
2061
|
throw new H("STORAGE_UNAVAILABLE", "Sign-in needs sessionStorage, which cannot be written here");
|
|
2057
2062
|
}
|
|
@@ -2066,37 +2071,37 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
2066
2071
|
code_challenge_method: "S256",
|
|
2067
2072
|
...r.nonce ? { nonce: r.nonce } : {}
|
|
2068
2073
|
}).toString(), i.toString();
|
|
2069
|
-
},
|
|
2074
|
+
}, tr = (e) => {
|
|
2070
2075
|
let t = e;
|
|
2071
2076
|
return typeof t == "object" && !!t && typeof t.verifier == "string" && typeof t.state == "string" && typeof t.clientId == "string" && typeof t.redirectUri == "string" && Array.isArray(t.scopes) && typeof t.expiresAt == "number";
|
|
2072
|
-
},
|
|
2077
|
+
}, nr = () => {
|
|
2073
2078
|
let e;
|
|
2074
2079
|
try {
|
|
2075
|
-
e = sessionStorage.getItem(
|
|
2080
|
+
e = sessionStorage.getItem(Xn);
|
|
2076
2081
|
} catch {
|
|
2077
2082
|
return { status: "none" };
|
|
2078
2083
|
}
|
|
2079
2084
|
if (!e) return { status: "none" };
|
|
2080
2085
|
try {
|
|
2081
2086
|
let t = JSON.parse(e);
|
|
2082
|
-
if (
|
|
2087
|
+
if (tr(t) && Date.now() < t.expiresAt) return {
|
|
2083
2088
|
status: "live",
|
|
2084
2089
|
slot: t
|
|
2085
2090
|
};
|
|
2086
2091
|
} catch {}
|
|
2087
2092
|
return { status: "unusable" };
|
|
2088
|
-
},
|
|
2093
|
+
}, rr = () => {
|
|
2089
2094
|
try {
|
|
2090
|
-
sessionStorage.removeItem(
|
|
2095
|
+
sessionStorage.removeItem(Xn);
|
|
2091
2096
|
} catch {}
|
|
2092
|
-
},
|
|
2097
|
+
}, ir = async (e) => {
|
|
2093
2098
|
try {
|
|
2094
2099
|
let t = await e.json();
|
|
2095
2100
|
return typeof t == "object" && t ? t : void 0;
|
|
2096
2101
|
} catch {
|
|
2097
2102
|
return;
|
|
2098
2103
|
}
|
|
2099
|
-
},
|
|
2104
|
+
}, ar = async (e, t, n) => {
|
|
2100
2105
|
let r;
|
|
2101
2106
|
try {
|
|
2102
2107
|
r = await fetch(`${e.replace(/\/+$/, "")}/oidc/token`, {
|
|
@@ -2111,11 +2116,11 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
2111
2116
|
}).toString()
|
|
2112
2117
|
});
|
|
2113
2118
|
} catch {
|
|
2114
|
-
throw new H("TOKEN_EXCHANGE_FAILED",
|
|
2119
|
+
throw new H("TOKEN_EXCHANGE_FAILED", Kn);
|
|
2115
2120
|
}
|
|
2116
|
-
let i = await
|
|
2117
|
-
if (!r.ok) throw i?.error === "invalid_client" ? new H("invalid_client",
|
|
2118
|
-
if (typeof i?.access_token != "string") throw new H("TOKEN_EXCHANGE_FAILED",
|
|
2121
|
+
let i = await ir(r);
|
|
2122
|
+
if (!r.ok) throw i?.error === "invalid_client" ? new H("invalid_client", Jn) : i?.error === "invalid_grant" ? new H("invalid_grant", Kn) : new H("TOKEN_EXCHANGE_FAILED", Kn);
|
|
2123
|
+
if (typeof i?.access_token != "string") throw new H("TOKEN_EXCHANGE_FAILED", Kn);
|
|
2119
2124
|
let a = typeof i.id_token == "string" ? i.id_token : void 0;
|
|
2120
2125
|
if (n.scopes.includes("openid")) {
|
|
2121
2126
|
let e;
|
|
@@ -2124,7 +2129,7 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
2124
2129
|
} catch {
|
|
2125
2130
|
e = void 0;
|
|
2126
2131
|
}
|
|
2127
|
-
if (!a || e !== n.nonce) throw new H("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${
|
|
2132
|
+
if (!a || e !== n.nonce) throw new H("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${Kn}`);
|
|
2128
2133
|
}
|
|
2129
2134
|
return {
|
|
2130
2135
|
access_token: i.access_token,
|
|
@@ -2132,13 +2137,13 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
2132
2137
|
...a ? { id_token: a } : {},
|
|
2133
2138
|
scopes: n.scopes
|
|
2134
2139
|
};
|
|
2135
|
-
},
|
|
2140
|
+
}, or = "error", sr = /* @__PURE__ */ new WeakMap(), cr = (e, t) => {
|
|
2136
2141
|
if (typeof t != "object" && typeof t != "function" || t === null) return !0;
|
|
2137
|
-
let n =
|
|
2138
|
-
return n || (n = /* @__PURE__ */ new WeakSet(),
|
|
2139
|
-
}, U = (e, t) =>
|
|
2142
|
+
let n = sr.get(e);
|
|
2143
|
+
return n || (n = /* @__PURE__ */ new WeakSet(), sr.set(e, n)), !n.has(t) && (n.add(t), !0);
|
|
2144
|
+
}, U = (e, t) => cr(e, t.originalError) ? (e.notify(or, t), !0) : !1, W = /* @__PURE__ */ function(e) {
|
|
2140
2145
|
return e.SignIn = "signin", e.SignInStart = "signin:start", e.Register = "register", e.RegisterStart = "register:start", e.EmailVerificationRequired = "email-verification:required", e.SignOut = "signout", e.SessionRestored = "session:restored", e.SessionExpired = "session:expired", e.Error = "error", e.Refresh = "refresh", e.RefreshStart = "refresh:start", e.TokenCacheExpired = "token-cache-expired", e.TwoFactorRequired = "2fa:required", e.TwoFactorSetupStarted = "2fa:setup_started", e.TwoFactorEnabled = "2fa:enabled", e.TwoFactorDisabled = "2fa:disabled", e.TwoFactorVerified = "2fa:verified", e.TwoFactorRecoveryUsed = "2fa:recovery_used", e.TwoFactorRecoveryCodesLow = "2fa:recovery_low", e.TwoFactorRecoveryCodesExhausted = "2fa:recovery_exhausted", e.TwoFactorSetupMagicLinkValidated = "2fa:magic_link_validated", e.TwoFactorSetupMagicLinkFailed = "2fa:magic_link_failed", e.TwoFactorChallengeReceived = "two_factor_challenge_received", e.TwoFactorMethodSwitched = "two_factor_method_switched", e.TwoFactorDeviceTrusted = "two_factor_device_trusted", e.RefreshFailing = "refresh:failing", e.RefreshRecovered = "refresh:recovered", e.AntiBotSolving = "anti-bot:solving", e.AntiBotSolved = "anti-bot:solved", e;
|
|
2141
|
-
}({}),
|
|
2146
|
+
}({}), lr = class {
|
|
2142
2147
|
constructor() {
|
|
2143
2148
|
this.subscribers = /* @__PURE__ */ new Map();
|
|
2144
2149
|
}
|
|
@@ -2157,40 +2162,40 @@ var bt = /* @__PURE__ */ function(e) {
|
|
|
2157
2162
|
n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
|
|
2158
2163
|
}
|
|
2159
2164
|
notify(e, t) {
|
|
2160
|
-
e === "error" &&
|
|
2165
|
+
e === "error" && cr(this, t?.originalError), this.subscribers.forEach((n, r) => {
|
|
2161
2166
|
(!n || n.has(e)) && r.onAuthChange?.(e, t);
|
|
2162
2167
|
});
|
|
2163
2168
|
}
|
|
2164
2169
|
notifyError(e) {
|
|
2165
2170
|
return U(this, e);
|
|
2166
2171
|
}
|
|
2167
|
-
},
|
|
2172
|
+
}, ur = 256, dr = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), fr = (e) => {
|
|
2168
2173
|
let t = new Uint8Array(e), n = "";
|
|
2169
|
-
for (let e of t) n +=
|
|
2174
|
+
for (let e of t) n += dr[e];
|
|
2170
2175
|
return n;
|
|
2171
|
-
},
|
|
2172
|
-
async function
|
|
2176
|
+
}, pr = class extends Error {};
|
|
2177
|
+
async function mr(e, t, n, r = Infinity) {
|
|
2173
2178
|
let i = globalThis.crypto?.subtle;
|
|
2174
2179
|
if (!i) throw Error("Web Crypto unavailable");
|
|
2175
2180
|
let a = t.toLowerCase(), o = new TextEncoder();
|
|
2176
|
-
for (let t = 0; t <= n; t +=
|
|
2177
|
-
if (Date.now() > r) throw new
|
|
2178
|
-
let s = Math.min(t +
|
|
2181
|
+
for (let t = 0; t <= n; t += ur) {
|
|
2182
|
+
if (Date.now() > r) throw new pr("Solve timed out");
|
|
2183
|
+
let s = Math.min(t + ur - 1, n), c = [];
|
|
2179
2184
|
for (let n = t; n <= s; n++) c.push(i.digest("SHA-256", o.encode(`${e}:${n}`)));
|
|
2180
2185
|
let l = await Promise.all(c);
|
|
2181
|
-
for (let e = 0; e < l.length; e++) if (
|
|
2186
|
+
for (let e = 0; e < l.length; e++) if (fr(l[e]) === a) return t + e;
|
|
2182
2187
|
}
|
|
2183
2188
|
return null;
|
|
2184
2189
|
}
|
|
2185
2190
|
// lib/anti-bot/solve.ts
|
|
2186
|
-
var
|
|
2191
|
+
var hr = "The browser check could not be completed. Try again later.", gr = "Verification failed. Try again.", _r = 6e4, vr = class extends Error {}, yr = (e, t, n, r) => new z({
|
|
2187
2192
|
id: e,
|
|
2188
2193
|
message: t,
|
|
2189
2194
|
status: 0,
|
|
2190
2195
|
location: n,
|
|
2191
2196
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2192
|
-
}, r === void 0 ? void 0 : { cause: r }),
|
|
2193
|
-
let i = new Worker(e), a = setTimeout(() => o(() => r(new
|
|
2197
|
+
}, r === void 0 ? void 0 : { cause: r }), br = (e, t) => new Promise((n, r) => {
|
|
2198
|
+
let i = new Worker(e), a = setTimeout(() => o(() => r(new vr())), _r), o = (e) => {
|
|
2194
2199
|
clearTimeout(a), i.terminate(), e();
|
|
2195
2200
|
};
|
|
2196
2201
|
i.addEventListener("message", (e) => {
|
|
@@ -2198,23 +2203,23 @@ var mr = "The browser check could not be completed. Try again later.", hr = "Ver
|
|
|
2198
2203
|
t && "error" in t ? o(() => r(Error(t.error))) : o(() => n(t?.number ?? null));
|
|
2199
2204
|
}), i.addEventListener("error", () => o(() => r(/* @__PURE__ */ Error("Anti-bot worker failed")))), i.addEventListener("messageerror", () => o(() => r(/* @__PURE__ */ Error("Anti-bot worker message failed")))), i.postMessage(t);
|
|
2200
2205
|
});
|
|
2201
|
-
async function
|
|
2202
|
-
if (e.algorithm !== "SHA-256") throw
|
|
2203
|
-
if (!Number.isSafeInteger(e.max) || e.max < 0 || e.max > 5e6) throw
|
|
2206
|
+
async function xr(e, t, n = "anti-bot") {
|
|
2207
|
+
if (e.algorithm !== "SHA-256") throw yr(Qe, hr, n);
|
|
2208
|
+
if (!Number.isSafeInteger(e.max) || e.max < 0 || e.max > 5e6) throw yr(Qe, gr, n);
|
|
2204
2209
|
let r = {
|
|
2205
2210
|
salt: e.salt,
|
|
2206
2211
|
challenge: e.challenge,
|
|
2207
2212
|
max: e.max
|
|
2208
2213
|
}, i;
|
|
2209
2214
|
try {
|
|
2210
|
-
i = t && typeof Worker < "u" ? await
|
|
2215
|
+
i = t && typeof Worker < "u" ? await br(t, r) : await mr(r.salt, r.challenge, r.max, Date.now() + _r);
|
|
2211
2216
|
} catch (e) {
|
|
2212
|
-
throw
|
|
2217
|
+
throw yr(Qe, e instanceof vr || e instanceof pr ? gr : hr, n, e);
|
|
2213
2218
|
}
|
|
2214
|
-
if (i === null) throw
|
|
2219
|
+
if (i === null) throw yr(Qe, hr, n);
|
|
2215
2220
|
return i;
|
|
2216
2221
|
}
|
|
2217
|
-
function
|
|
2222
|
+
function Sr(e, t) {
|
|
2218
2223
|
let n = {
|
|
2219
2224
|
app: e.app,
|
|
2220
2225
|
exp: e.exp,
|
|
@@ -2227,8 +2232,8 @@ function xr(e, t) {
|
|
|
2227
2232
|
return btoa(JSON.stringify(n));
|
|
2228
2233
|
}
|
|
2229
2234
|
// lib/anti-bot/anti-bot.ts
|
|
2230
|
-
var
|
|
2231
|
-
function
|
|
2235
|
+
var Cr = "This app requires a verification token. Call setAntiBotTokenProvider() before signing in.", wr = "The verification could not be completed. Try again.";
|
|
2236
|
+
function Tr(e) {
|
|
2232
2237
|
let t, n = async (e, t) => {
|
|
2233
2238
|
let n;
|
|
2234
2239
|
try {
|
|
@@ -2237,16 +2242,16 @@ function wr(e) {
|
|
|
2237
2242
|
operation: t.operation
|
|
2238
2243
|
});
|
|
2239
2244
|
} catch (e) {
|
|
2240
|
-
throw
|
|
2245
|
+
throw yr(Ze, wr, t.operation, e);
|
|
2241
2246
|
}
|
|
2242
|
-
if (typeof n != "string" || n === "") throw
|
|
2247
|
+
if (typeof n != "string" || n === "") throw yr(Ze, wr, t.operation);
|
|
2243
2248
|
return n;
|
|
2244
2249
|
}, r = async (t) => {
|
|
2245
2250
|
let n = await e.fetchChallenge({
|
|
2246
2251
|
...t.identifier ? { identifier: t.identifier } : {},
|
|
2247
2252
|
...t.device ? { device: t.device } : {}
|
|
2248
2253
|
});
|
|
2249
|
-
return
|
|
2254
|
+
return Sr(n, await xr(n, e.workerUrl, t.operation));
|
|
2250
2255
|
};
|
|
2251
2256
|
return {
|
|
2252
2257
|
setTokenProvider(e) {
|
|
@@ -2264,7 +2269,7 @@ function wr(e) {
|
|
|
2264
2269
|
if (s) c = await r(i);
|
|
2265
2270
|
else {
|
|
2266
2271
|
let e = t;
|
|
2267
|
-
if (!e) throw
|
|
2272
|
+
if (!e) throw yr(Xe, Cr, i.operation);
|
|
2268
2273
|
c = await n(e, i);
|
|
2269
2274
|
}
|
|
2270
2275
|
return e.store.notify(W.AntiBotSolved, {
|
|
@@ -2278,97 +2283,97 @@ function wr(e) {
|
|
|
2278
2283
|
};
|
|
2279
2284
|
}
|
|
2280
2285
|
// lib/refresh/constants.ts
|
|
2281
|
-
var
|
|
2286
|
+
var Er = "passflow-refresh", Dr = "passflow-refresh-takeover", Or = "passflow-auth", kr = Object.freeze([
|
|
2282
2287
|
1e3,
|
|
2283
2288
|
3e3,
|
|
2284
2289
|
1e4,
|
|
2285
2290
|
3e4,
|
|
2286
2291
|
6e4
|
|
2287
|
-
]),
|
|
2292
|
+
]), Ar = .2, jr = 6e5, Mr = 5e3, G = 2e4, Nr = 2e4, Pr = 1e3, Fr = 2e3, Ir = 1e3, Lr = 1e4, Rr = 5e3;
|
|
2288
2293
|
// lib/refresh/protocol.ts
|
|
2289
|
-
function
|
|
2294
|
+
function zr(e) {
|
|
2290
2295
|
let t = e ? `:${e}` : "";
|
|
2291
2296
|
return {
|
|
2292
|
-
lock: `${
|
|
2293
|
-
takeoverLock: `${
|
|
2294
|
-
channel: `${
|
|
2297
|
+
lock: `${Er}${t}`,
|
|
2298
|
+
takeoverLock: `${Dr}${t}`,
|
|
2299
|
+
channel: `${Or}${t}`
|
|
2295
2300
|
};
|
|
2296
2301
|
}
|
|
2297
2302
|
function K(e) {
|
|
2298
2303
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2299
2304
|
}
|
|
2300
|
-
function
|
|
2305
|
+
function Br(e) {
|
|
2301
2306
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
2302
2307
|
}
|
|
2303
|
-
function
|
|
2308
|
+
function Vr(e) {
|
|
2304
2309
|
return typeof e == "object" && !!e;
|
|
2305
2310
|
}
|
|
2306
|
-
function
|
|
2311
|
+
function Hr(e, t) {
|
|
2307
2312
|
for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
|
|
2308
2313
|
return e;
|
|
2309
2314
|
}
|
|
2310
|
-
function
|
|
2311
|
-
if (!
|
|
2315
|
+
function Ur(e) {
|
|
2316
|
+
if (!Vr(e)) return null;
|
|
2312
2317
|
let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
|
|
2313
|
-
return
|
|
2318
|
+
return Hr({}, {
|
|
2314
2319
|
access_token: K(e.access_token),
|
|
2315
2320
|
refresh_token: K(e.refresh_token),
|
|
2316
2321
|
id_token: K(e.id_token),
|
|
2317
2322
|
scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
|
|
2318
2323
|
});
|
|
2319
2324
|
}
|
|
2320
|
-
function
|
|
2321
|
-
if (!
|
|
2325
|
+
function Wr(e) {
|
|
2326
|
+
if (!Vr(e)) return null;
|
|
2322
2327
|
let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
|
|
2323
|
-
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 ||
|
|
2328
|
+
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || Br(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Hr({
|
|
2324
2329
|
kind: t,
|
|
2325
2330
|
attempt: n,
|
|
2326
2331
|
nextAt: r,
|
|
2327
2332
|
strikes: i
|
|
2328
2333
|
}, {
|
|
2329
2334
|
from: K(e.from),
|
|
2330
|
-
failingSince:
|
|
2335
|
+
failingSince: Br(e.failingSince)
|
|
2331
2336
|
});
|
|
2332
2337
|
}
|
|
2333
|
-
function
|
|
2334
|
-
return
|
|
2338
|
+
function Gr(e) {
|
|
2339
|
+
return Hr({}, {
|
|
2335
2340
|
fp: K(e.fp),
|
|
2336
2341
|
sub: K(e.sub),
|
|
2337
2342
|
sid: K(e.sid),
|
|
2338
|
-
iat:
|
|
2343
|
+
iat: Br(e.iat)
|
|
2339
2344
|
});
|
|
2340
2345
|
}
|
|
2341
|
-
function
|
|
2342
|
-
if (!
|
|
2346
|
+
function Kr(e) {
|
|
2347
|
+
if (!Vr(e)) return null;
|
|
2343
2348
|
let t = e;
|
|
2344
2349
|
if (t.v !== void 0 && t.v !== 1) return null;
|
|
2345
2350
|
let n = K(t.tabId);
|
|
2346
2351
|
if (!n) return null;
|
|
2347
2352
|
switch (t.type) {
|
|
2348
2353
|
case "tokens-refreshed": {
|
|
2349
|
-
let e =
|
|
2350
|
-
return !e || !r || !i ? null :
|
|
2354
|
+
let e = Ur(t.tokens), r = K(t.from), i = K(t.to);
|
|
2355
|
+
return !e || !r || !i ? null : Hr({
|
|
2351
2356
|
type: t.type,
|
|
2352
2357
|
tabId: n,
|
|
2353
2358
|
tokens: e,
|
|
2354
2359
|
from: r,
|
|
2355
2360
|
to: i
|
|
2356
2361
|
}, {
|
|
2357
|
-
fromIat:
|
|
2362
|
+
fromIat: Br(t.fromIat),
|
|
2358
2363
|
fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
|
|
2359
|
-
sentAt:
|
|
2364
|
+
sentAt: Br(t.sentAt)
|
|
2360
2365
|
});
|
|
2361
2366
|
}
|
|
2362
2367
|
case "session-refreshed": {
|
|
2363
|
-
let e =
|
|
2364
|
-
return e === void 0 ? null :
|
|
2368
|
+
let e = Br(t.at);
|
|
2369
|
+
return e === void 0 ? null : Hr({
|
|
2365
2370
|
type: t.type,
|
|
2366
2371
|
tabId: n,
|
|
2367
2372
|
at: e
|
|
2368
2373
|
}, { sub: K(t.sub) });
|
|
2369
2374
|
}
|
|
2370
2375
|
case "still-refreshing": {
|
|
2371
|
-
let e = t.retry === void 0 ? null :
|
|
2376
|
+
let e = t.retry === void 0 ? null : Wr(t.retry);
|
|
2372
2377
|
return e ? {
|
|
2373
2378
|
type: t.type,
|
|
2374
2379
|
tabId: n,
|
|
@@ -2379,7 +2384,7 @@ function Gr(e) {
|
|
|
2379
2384
|
};
|
|
2380
2385
|
}
|
|
2381
2386
|
case "retry-scheduled": {
|
|
2382
|
-
let e =
|
|
2387
|
+
let e = Wr(t);
|
|
2383
2388
|
return e ? {
|
|
2384
2389
|
type: t.type,
|
|
2385
2390
|
tabId: n,
|
|
@@ -2400,10 +2405,10 @@ function Gr(e) {
|
|
|
2400
2405
|
case "signed-out": return {
|
|
2401
2406
|
type: t.type,
|
|
2402
2407
|
tabId: n,
|
|
2403
|
-
...
|
|
2408
|
+
...Gr(t)
|
|
2404
2409
|
};
|
|
2405
2410
|
case "rate-limited": {
|
|
2406
|
-
let e =
|
|
2411
|
+
let e = Br(t.until);
|
|
2407
2412
|
return e === void 0 ? null : {
|
|
2408
2413
|
type: t.type,
|
|
2409
2414
|
tabId: n,
|
|
@@ -2422,22 +2427,22 @@ function Gr(e) {
|
|
|
2422
2427
|
default: return null;
|
|
2423
2428
|
}
|
|
2424
2429
|
}
|
|
2425
|
-
function
|
|
2430
|
+
function qr(e, t) {
|
|
2426
2431
|
let n = {
|
|
2427
2432
|
v: 1,
|
|
2428
2433
|
tabId: e
|
|
2429
2434
|
};
|
|
2430
2435
|
if (t.type === "retry-scheduled") {
|
|
2431
2436
|
let { retry: e, ...r } = t;
|
|
2432
|
-
return
|
|
2437
|
+
return Hr(n, {
|
|
2433
2438
|
...r,
|
|
2434
2439
|
...e
|
|
2435
2440
|
});
|
|
2436
2441
|
}
|
|
2437
|
-
return
|
|
2442
|
+
return Hr(n, { ...t });
|
|
2438
2443
|
}
|
|
2439
2444
|
// lib/refresh/resolve.ts
|
|
2440
|
-
var
|
|
2445
|
+
var Jr = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", Yr = {
|
|
2441
2446
|
now: () => Date.now(),
|
|
2442
2447
|
random: () => Math.random(),
|
|
2443
2448
|
setTimeout: (e, t) => {
|
|
@@ -2445,28 +2450,28 @@ var qr = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
|
|
|
2445
2450
|
return n.unref?.(), () => clearTimeout(n);
|
|
2446
2451
|
}
|
|
2447
2452
|
};
|
|
2448
|
-
function
|
|
2453
|
+
function Xr() {
|
|
2449
2454
|
let e = globalThis.crypto;
|
|
2450
2455
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
2451
2456
|
}
|
|
2452
|
-
function
|
|
2457
|
+
function Zr(e) {
|
|
2453
2458
|
return e ? {
|
|
2454
2459
|
now: () => e.now(),
|
|
2455
2460
|
setTimeout: (t, n) => e.setTimeout(t, n),
|
|
2456
|
-
random: e.random ? () => e.random?.() ?? Math.random() :
|
|
2457
|
-
} :
|
|
2461
|
+
random: e.random ? () => e.random?.() ?? Math.random() : Yr.random
|
|
2462
|
+
} : Yr;
|
|
2458
2463
|
}
|
|
2459
|
-
function
|
|
2464
|
+
function Qr(e) {
|
|
2460
2465
|
return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
|
|
2461
2466
|
}
|
|
2462
|
-
function
|
|
2467
|
+
function $r(e) {
|
|
2463
2468
|
try {
|
|
2464
2469
|
return e.storageSharedAcrossTabs === !0;
|
|
2465
2470
|
} catch {
|
|
2466
2471
|
return !1;
|
|
2467
2472
|
}
|
|
2468
2473
|
}
|
|
2469
|
-
function
|
|
2474
|
+
function ei() {
|
|
2470
2475
|
try {
|
|
2471
2476
|
let e = globalThis.navigator?.locks;
|
|
2472
2477
|
return e && typeof e.request == "function" ? e : void 0;
|
|
@@ -2474,7 +2479,7 @@ function $r() {
|
|
|
2474
2479
|
return;
|
|
2475
2480
|
}
|
|
2476
2481
|
}
|
|
2477
|
-
function
|
|
2482
|
+
function ti(e) {
|
|
2478
2483
|
return (t) => {
|
|
2479
2484
|
let n = (n) => {
|
|
2480
2485
|
let r = n.key;
|
|
@@ -2483,20 +2488,20 @@ function ei(e) {
|
|
|
2483
2488
|
return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
|
|
2484
2489
|
};
|
|
2485
2490
|
}
|
|
2486
|
-
function
|
|
2491
|
+
function ni(e) {
|
|
2487
2492
|
return {
|
|
2488
2493
|
transports: null,
|
|
2489
|
-
names:
|
|
2490
|
-
clock:
|
|
2494
|
+
names: zr(e),
|
|
2495
|
+
clock: Yr,
|
|
2491
2496
|
warnOnFirstCycle: !1
|
|
2492
2497
|
};
|
|
2493
2498
|
}
|
|
2494
|
-
function
|
|
2495
|
-
let i =
|
|
2499
|
+
function ri(e, t, n, r) {
|
|
2500
|
+
let i = zr(n), a = Qr(t), o = a ? ti(r.tokenKeys) : void 0, s = (e) => {
|
|
2496
2501
|
let t = {
|
|
2497
2502
|
transports: null,
|
|
2498
2503
|
names: i,
|
|
2499
|
-
clock:
|
|
2504
|
+
clock: Yr,
|
|
2500
2505
|
warnOnFirstCycle: e
|
|
2501
2506
|
};
|
|
2502
2507
|
return o && (t.onStorageChange = o), t;
|
|
@@ -2506,16 +2511,16 @@ function ni(e, t, n, r) {
|
|
|
2506
2511
|
transports: {
|
|
2507
2512
|
locks: e.locks,
|
|
2508
2513
|
channel: e.channel,
|
|
2509
|
-
tabId: e.tabId ??
|
|
2514
|
+
tabId: e.tabId ?? Xr()
|
|
2510
2515
|
},
|
|
2511
2516
|
names: i,
|
|
2512
|
-
clock:
|
|
2517
|
+
clock: Zr(e.clock),
|
|
2513
2518
|
warnOnFirstCycle: !1
|
|
2514
2519
|
};
|
|
2515
2520
|
return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
|
|
2516
2521
|
}
|
|
2517
|
-
if (e === "none" || !a ||
|
|
2518
|
-
let c =
|
|
2522
|
+
if (e === "none" || !a || !$r(t)) return s(!1);
|
|
2523
|
+
let c = ei();
|
|
2519
2524
|
if (!c || typeof BroadcastChannel != "function") return s(!0);
|
|
2520
2525
|
let l;
|
|
2521
2526
|
try {
|
|
@@ -2527,16 +2532,16 @@ function ni(e, t, n, r) {
|
|
|
2527
2532
|
transports: {
|
|
2528
2533
|
locks: c,
|
|
2529
2534
|
channel: l,
|
|
2530
|
-
tabId:
|
|
2535
|
+
tabId: Xr()
|
|
2531
2536
|
},
|
|
2532
2537
|
names: i,
|
|
2533
|
-
clock:
|
|
2538
|
+
clock: Yr,
|
|
2534
2539
|
warnOnFirstCycle: !1
|
|
2535
2540
|
};
|
|
2536
2541
|
return o && (u.onStorageChange = o), u;
|
|
2537
2542
|
}
|
|
2538
2543
|
// lib/services/logger.ts
|
|
2539
|
-
var
|
|
2544
|
+
var ii = class {
|
|
2540
2545
|
error(e, ...t) {
|
|
2541
2546
|
console.error(e, ...t);
|
|
2542
2547
|
}
|
|
@@ -2550,10 +2555,10 @@ var ri = class {
|
|
|
2550
2555
|
console.debug(e, ...t);
|
|
2551
2556
|
}
|
|
2552
2557
|
};
|
|
2553
|
-
function
|
|
2554
|
-
return new
|
|
2558
|
+
function ai() {
|
|
2559
|
+
return new ii();
|
|
2555
2560
|
}
|
|
2556
|
-
var
|
|
2561
|
+
var oi = Object.freeze([
|
|
2557
2562
|
"error.token.invalid.error",
|
|
2558
2563
|
"error.api.token.parse.error",
|
|
2559
2564
|
"error.api.user.blocked",
|
|
@@ -2561,25 +2566,25 @@ var ai = Object.freeze([
|
|
|
2561
2566
|
"error.validation.token.invalid.subject",
|
|
2562
2567
|
"error.not.found"
|
|
2563
2568
|
]);
|
|
2564
|
-
function
|
|
2569
|
+
function si(e) {
|
|
2565
2570
|
if (typeof e != "object" || !e) return;
|
|
2566
2571
|
let t = e;
|
|
2567
2572
|
return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
|
|
2568
2573
|
}
|
|
2569
|
-
function
|
|
2570
|
-
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(
|
|
2574
|
+
function ci(e, t) {
|
|
2575
|
+
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(jr, Math.floor(e) * 1e3);
|
|
2571
2576
|
if (typeof e != "string") return;
|
|
2572
2577
|
let n = e.trim();
|
|
2573
2578
|
if (n === "") return;
|
|
2574
|
-
if (/^\d+$/.test(n)) return Math.min(
|
|
2579
|
+
if (/^\d+$/.test(n)) return Math.min(jr, Number.parseInt(n, 10) * 1e3);
|
|
2575
2580
|
if (!/[a-z]/i.test(n)) return;
|
|
2576
2581
|
let r = Date.parse(n);
|
|
2577
|
-
if (!Number.isNaN(r)) return Math.min(
|
|
2582
|
+
if (!Number.isNaN(r)) return Math.min(jr, Math.max(0, r - t));
|
|
2578
2583
|
}
|
|
2579
|
-
function
|
|
2584
|
+
function li(e) {
|
|
2580
2585
|
return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
|
|
2581
2586
|
}
|
|
2582
|
-
function
|
|
2587
|
+
function ui(e) {
|
|
2583
2588
|
if (typeof e.id == "string" && e.id !== "") return e.id;
|
|
2584
2589
|
let t = e.response?.data;
|
|
2585
2590
|
if (typeof t != "object" || !t) return;
|
|
@@ -2588,14 +2593,14 @@ function li(e) {
|
|
|
2588
2593
|
let r = n.id;
|
|
2589
2594
|
return typeof r == "string" && r !== "" ? r : void 0;
|
|
2590
2595
|
}
|
|
2591
|
-
function
|
|
2596
|
+
function di(e, t = Date.now()) {
|
|
2592
2597
|
if (typeof e != "object" || !e) return { kind: "transient" };
|
|
2593
|
-
let n = e, r =
|
|
2598
|
+
let n = e, r = ui(n), i = li(n.response?.status) ?? li(n.status), a = {};
|
|
2594
2599
|
if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
|
|
2595
2600
|
kind: "blocked",
|
|
2596
2601
|
...a
|
|
2597
2602
|
};
|
|
2598
|
-
if (r !== void 0 &&
|
|
2603
|
+
if (r !== void 0 && oi.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
|
|
2599
2604
|
kind: "auth",
|
|
2600
2605
|
...a
|
|
2601
2606
|
};
|
|
@@ -2603,7 +2608,7 @@ function ui(e, t = Date.now()) {
|
|
|
2603
2608
|
kind: "transient",
|
|
2604
2609
|
...a
|
|
2605
2610
|
};
|
|
2606
|
-
let o =
|
|
2611
|
+
let o = ci(n.retryAfter ?? si(n.response?.headers), t);
|
|
2607
2612
|
return o === void 0 ? {
|
|
2608
2613
|
kind: "transient",
|
|
2609
2614
|
...a
|
|
@@ -2613,19 +2618,19 @@ function ui(e, t = Date.now()) {
|
|
|
2613
2618
|
retryAfterMs: o
|
|
2614
2619
|
};
|
|
2615
2620
|
}
|
|
2616
|
-
function
|
|
2617
|
-
let r =
|
|
2618
|
-
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0),
|
|
2621
|
+
function fi(e, t, n) {
|
|
2622
|
+
let r = kr.length, i = kr[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? kr[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * Ar * a);
|
|
2623
|
+
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), jr) : 0);
|
|
2619
2624
|
}
|
|
2620
2625
|
// lib/refresh/coordinator.ts
|
|
2621
|
-
var
|
|
2626
|
+
var pi = {
|
|
2622
2627
|
onGranted: () => !1,
|
|
2623
2628
|
onLockLost: () => void 0,
|
|
2624
2629
|
onMessage: () => void 0
|
|
2625
2630
|
};
|
|
2626
|
-
function
|
|
2627
|
-
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o =
|
|
2628
|
-
g || n.postMessage(
|
|
2631
|
+
function mi(e) {
|
|
2632
|
+
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = pi, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
|
|
2633
|
+
g || n.postMessage(qr(r, e));
|
|
2629
2634
|
}, v = () => s !== null && c === null, y = () => {
|
|
2630
2635
|
f?.(), f = null;
|
|
2631
2636
|
}, b = (e) => {
|
|
@@ -2640,7 +2645,7 @@ function pi(e) {
|
|
|
2640
2645
|
type: "still-refreshing",
|
|
2641
2646
|
retry: m
|
|
2642
2647
|
} : { type: "still-refreshing" }), ee());
|
|
2643
|
-
},
|
|
2648
|
+
}, Mr);
|
|
2644
2649
|
}, S = () => {
|
|
2645
2650
|
y(), x(), u?.(), u = null;
|
|
2646
2651
|
let e = s;
|
|
@@ -2691,7 +2696,7 @@ function pi(e) {
|
|
|
2691
2696
|
});
|
|
2692
2697
|
}, D = (e) => {
|
|
2693
2698
|
if (g) return;
|
|
2694
|
-
let t =
|
|
2699
|
+
let t = Kr(e.data);
|
|
2695
2700
|
if (t && t.tabId !== r) {
|
|
2696
2701
|
switch (t.type) {
|
|
2697
2702
|
case "still-refreshing":
|
|
@@ -2734,8 +2739,8 @@ function pi(e) {
|
|
|
2734
2739
|
}
|
|
2735
2740
|
};
|
|
2736
2741
|
}
|
|
2737
|
-
function
|
|
2738
|
-
let t =
|
|
2742
|
+
function hi(e = "local") {
|
|
2743
|
+
let t = pi, n = !1, r = !1, i = 0, a = !1, o = () => {
|
|
2739
2744
|
n = !1, r = !1, i += 1;
|
|
2740
2745
|
};
|
|
2741
2746
|
return {
|
|
@@ -2783,7 +2788,7 @@ var q = {
|
|
|
2783
2788
|
successorTimeout: "error.refresh.successor_timeout",
|
|
2784
2789
|
identityChanged: "error.refresh.identity_changed",
|
|
2785
2790
|
disposed: "error.refresh.disposed"
|
|
2786
|
-
},
|
|
2791
|
+
}, gi = {
|
|
2787
2792
|
"error.refresh.unavailable": 503,
|
|
2788
2793
|
"error.refresh.auth_retry": 401,
|
|
2789
2794
|
"error.refresh.session_ended": 401,
|
|
@@ -2791,7 +2796,7 @@ var q = {
|
|
|
2791
2796
|
"error.refresh.successor_timeout": 401,
|
|
2792
2797
|
"error.refresh.identity_changed": 401,
|
|
2793
2798
|
"error.refresh.disposed": 499
|
|
2794
|
-
},
|
|
2799
|
+
}, _i = {
|
|
2795
2800
|
"error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
|
|
2796
2801
|
"error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
|
|
2797
2802
|
"error.refresh.session_ended": "The session has ended",
|
|
@@ -2803,13 +2808,13 @@ var q = {
|
|
|
2803
2808
|
constructor(e, t = {}) {
|
|
2804
2809
|
super({
|
|
2805
2810
|
id: e,
|
|
2806
|
-
message: t.message ??
|
|
2807
|
-
status:
|
|
2811
|
+
message: t.message ?? _i[e],
|
|
2812
|
+
status: gi[e],
|
|
2808
2813
|
location: "/auth/refresh",
|
|
2809
2814
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2810
2815
|
}), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
|
|
2811
2816
|
}
|
|
2812
|
-
},
|
|
2817
|
+
}, vi = class extends Error {
|
|
2813
2818
|
constructor(e, t) {
|
|
2814
2819
|
super(t ?? (e === "lock-timeout" ? "Step-up commit could not take the refresh lock in time" : "Step-up commit answer arrived after the stored session moved on")), this.name = "UpgradeCommitInterruptedError", this.reason = e;
|
|
2815
2820
|
}
|
|
@@ -2824,7 +2829,7 @@ function Y(e) {
|
|
|
2824
2829
|
}
|
|
2825
2830
|
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);
|
|
2826
2831
|
}
|
|
2827
|
-
function
|
|
2832
|
+
function yi(e) {
|
|
2828
2833
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2829
2834
|
}
|
|
2830
2835
|
function X(e) {
|
|
@@ -2835,13 +2840,13 @@ function X(e) {
|
|
|
2835
2840
|
let t = j(e);
|
|
2836
2841
|
typeof t == "object" && t && (n = t);
|
|
2837
2842
|
} catch {}
|
|
2838
|
-
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a =
|
|
2843
|
+
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = yi(n.sub), o = yi(n.sid);
|
|
2839
2844
|
return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
|
|
2840
2845
|
}
|
|
2841
|
-
var
|
|
2842
|
-
function
|
|
2846
|
+
var bi = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
|
|
2847
|
+
function xi(e = (e) => ai().warn(e)) {
|
|
2843
2848
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
|
|
2844
|
-
a || (a = !0, e(
|
|
2849
|
+
a || (a = !0, e(bi));
|
|
2845
2850
|
}, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
|
|
2846
2851
|
if (!e) return;
|
|
2847
2852
|
if (e.iat === void 0) {
|
|
@@ -2882,16 +2887,16 @@ function bi(e = (e) => ii().warn(e)) {
|
|
|
2882
2887
|
};
|
|
2883
2888
|
}
|
|
2884
2889
|
// lib/refresh/fence.ts
|
|
2885
|
-
var
|
|
2890
|
+
var Si = class extends Error {
|
|
2886
2891
|
constructor(e) {
|
|
2887
2892
|
super(e === "emptied" ? "The shared token storage was emptied" : "The stored refresh token belongs to an ended session"), this.name = "SessionEnded", this.cause = e;
|
|
2888
2893
|
}
|
|
2889
|
-
},
|
|
2894
|
+
}, Ci = class extends Error {
|
|
2890
2895
|
constructor() {
|
|
2891
2896
|
super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
|
|
2892
2897
|
}
|
|
2893
2898
|
};
|
|
2894
|
-
function
|
|
2899
|
+
function wi(e) {
|
|
2895
2900
|
if (e) try {
|
|
2896
2901
|
let t = j(e).sub;
|
|
2897
2902
|
return typeof t == "string" && t !== "" ? t : void 0;
|
|
@@ -2900,16 +2905,16 @@ function Ci(e) {
|
|
|
2900
2905
|
}
|
|
2901
2906
|
}
|
|
2902
2907
|
function Z(e) {
|
|
2903
|
-
return
|
|
2908
|
+
return wi(e?.access_token) ?? wi(e?.refresh_token) ?? wi(e?.id_token);
|
|
2904
2909
|
}
|
|
2905
|
-
function
|
|
2910
|
+
function Ti(e, t) {
|
|
2906
2911
|
return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
|
|
2907
2912
|
}
|
|
2908
|
-
function
|
|
2913
|
+
function Ei(e) {
|
|
2909
2914
|
return typeof e == "object" && !!e;
|
|
2910
2915
|
}
|
|
2911
|
-
function
|
|
2912
|
-
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) =>
|
|
2916
|
+
function Di(e) {
|
|
2917
|
+
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => ai().warn(e)), o = e.lineage ?? xi(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
|
|
2913
2918
|
let e = t.getTokens(), n = e?.refresh_token;
|
|
2914
2919
|
if (!n) return p = l, e;
|
|
2915
2920
|
p !== void 0 && (f = Math.max(f, p, m), p = void 0);
|
|
@@ -2948,7 +2953,7 @@ function Ei(e) {
|
|
|
2948
2953
|
h = void 0;
|
|
2949
2954
|
let e = y();
|
|
2950
2955
|
e?.refresh_token || C(e) ? se() : D(!0) === "end" && s?.("emptied");
|
|
2951
|
-
},
|
|
2956
|
+
}, Fr));
|
|
2952
2957
|
let n = t === "keep" ? T() : void 0;
|
|
2953
2958
|
return n && (m = Math.max(m, n.seq)), n && g !== n.fp && (g = n.fp, a(`[passflow] The shared token storage was emptied by the end of the session of ${n.fp}, a refresh token the ${b()?.fp ?? "(none)"} this tab holds is ahead of: keeping it. Nothing is refreshed until the storage holds a token again.`)), t;
|
|
2954
2959
|
}, O = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, ne = (e) => {
|
|
@@ -2972,7 +2977,7 @@ function Ei(e) {
|
|
|
2972
2977
|
kind: "superseded",
|
|
2973
2978
|
adopted: !1
|
|
2974
2979
|
};
|
|
2975
|
-
let r =
|
|
2980
|
+
let r = wi(t.access_token) ?? wi(n);
|
|
2976
2981
|
if (e.sub && r && e.sub !== r) return {
|
|
2977
2982
|
kind: "identity-changed",
|
|
2978
2983
|
saved: !1
|
|
@@ -3013,22 +3018,22 @@ function Ei(e) {
|
|
|
3013
3018
|
let e = y();
|
|
3014
3019
|
if (C(e)) return "held";
|
|
3015
3020
|
if (!e?.refresh_token) {
|
|
3016
|
-
if (D() === "end") throw new
|
|
3021
|
+
if (D() === "end") throw new Si("emptied");
|
|
3017
3022
|
return "held";
|
|
3018
3023
|
}
|
|
3019
3024
|
let t = n.getTokens();
|
|
3020
3025
|
if (e.refresh_token === t?.refresh_token) return "send";
|
|
3021
3026
|
let r = i() ?? Z(t), a = Z(e);
|
|
3022
|
-
if (r && a && r !== a) throw new
|
|
3027
|
+
if (r && a && r !== a) throw new Ci();
|
|
3023
3028
|
let s = X(e.refresh_token);
|
|
3024
3029
|
if (o.isEnded(s)) {
|
|
3025
3030
|
if (s && S(s)) return "held";
|
|
3026
|
-
throw new
|
|
3031
|
+
throw new Si("ended");
|
|
3027
3032
|
}
|
|
3028
3033
|
let c = X(t?.refresh_token);
|
|
3029
3034
|
return ie(s, c) ? (ae(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && ne(s) ? "held" : "send";
|
|
3030
3035
|
}, ce = (e) => {
|
|
3031
|
-
let t = i(), r =
|
|
3036
|
+
let t = i(), r = wi(e);
|
|
3032
3037
|
if (t && r && t !== r) return { kind: "identity-changed" };
|
|
3033
3038
|
let a = X(e) ?? { fp: e };
|
|
3034
3039
|
if (o.isEnded(a)) return S(a) ? { kind: "superseded" } : { kind: "ended" };
|
|
@@ -3036,7 +3041,7 @@ function Ei(e) {
|
|
|
3036
3041
|
let s = {
|
|
3037
3042
|
refreshToken: e,
|
|
3038
3043
|
order: a
|
|
3039
|
-
}, c = t ?? r ??
|
|
3044
|
+
}, c = t ?? r ?? wi(n.getTokens()?.access_token);
|
|
3040
3045
|
return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
|
|
3041
3046
|
kind: "send",
|
|
3042
3047
|
sent: s
|
|
@@ -3055,7 +3060,7 @@ function Ei(e) {
|
|
|
3055
3060
|
saved: !0
|
|
3056
3061
|
};
|
|
3057
3062
|
let c = X(r.refresh_token);
|
|
3058
|
-
return c && (
|
|
3063
|
+
return c && (Ti(c, e.order) || Ti(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.`), {
|
|
3059
3064
|
kind: "superseded",
|
|
3060
3065
|
adopted: !1
|
|
3061
3066
|
}) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
|
|
@@ -3067,7 +3072,7 @@ function Ei(e) {
|
|
|
3067
3072
|
kind: "superseded",
|
|
3068
3073
|
adopted: !1
|
|
3069
3074
|
};
|
|
3070
|
-
let r =
|
|
3075
|
+
let r = di(t), i = r.kind === "blocked" || r.kind === "auth";
|
|
3071
3076
|
return O(e) && i ? (o.retire(e.order), _ = e.order, {
|
|
3072
3077
|
kind: "own",
|
|
3073
3078
|
failure: r,
|
|
@@ -3078,9 +3083,9 @@ function Ei(e) {
|
|
|
3078
3083
|
heldRefused: !1
|
|
3079
3084
|
});
|
|
3080
3085
|
}, I = (e) => {
|
|
3081
|
-
if (!
|
|
3086
|
+
if (!Ei(e)) return !1;
|
|
3082
3087
|
let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
|
|
3083
|
-
if (typeof t != "string" || typeof c != "string" || !
|
|
3088
|
+
if (typeof t != "string" || typeof c != "string" || !Ei(l)) return !1;
|
|
3084
3089
|
let u = l;
|
|
3085
3090
|
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || Y(u.refresh_token) !== c) return !1;
|
|
3086
3091
|
let d = y();
|
|
@@ -3165,7 +3170,7 @@ function Ei(e) {
|
|
|
3165
3170
|
};
|
|
3166
3171
|
}
|
|
3167
3172
|
// lib/refresh/controller.ts
|
|
3168
|
-
function
|
|
3173
|
+
function Oi() {
|
|
3169
3174
|
let e, t, n = new Promise((n, r) => {
|
|
3170
3175
|
e = n, t = r;
|
|
3171
3176
|
});
|
|
@@ -3175,7 +3180,7 @@ function Di() {
|
|
|
3175
3180
|
reject: t
|
|
3176
3181
|
};
|
|
3177
3182
|
}
|
|
3178
|
-
var
|
|
3183
|
+
var ki = {
|
|
3179
3184
|
strikes: q.sessionEnded,
|
|
3180
3185
|
"session-ended": q.sessionEnded,
|
|
3181
3186
|
"stored-ended": q.sessionEnded,
|
|
@@ -3186,42 +3191,42 @@ var Oi = {
|
|
|
3186
3191
|
"identity-changed": q.identityChanged,
|
|
3187
3192
|
disposed: q.disposed
|
|
3188
3193
|
};
|
|
3189
|
-
function
|
|
3194
|
+
function Ai(e) {
|
|
3190
3195
|
throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
|
|
3191
3196
|
}
|
|
3192
|
-
function
|
|
3197
|
+
function ji(e) {
|
|
3193
3198
|
if (e === void 0 || !Number.isFinite(e)) return 3;
|
|
3194
3199
|
let t = Math.floor(e);
|
|
3195
3200
|
return t >= 1 ? t : 3;
|
|
3196
3201
|
}
|
|
3197
|
-
function
|
|
3202
|
+
function Mi(e, t) {
|
|
3198
3203
|
return e instanceof Error && e.message ? e.message : t;
|
|
3199
3204
|
}
|
|
3200
|
-
function
|
|
3205
|
+
function Ni(e) {
|
|
3201
3206
|
if (typeof e != "object" || !e) return;
|
|
3202
3207
|
let t = e.id;
|
|
3203
3208
|
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
3204
3209
|
}
|
|
3205
|
-
function
|
|
3210
|
+
function Pi(e) {
|
|
3206
3211
|
let t = {};
|
|
3207
3212
|
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;
|
|
3208
3213
|
}
|
|
3209
|
-
function
|
|
3214
|
+
function Fi(e, t) {
|
|
3210
3215
|
let n = {};
|
|
3211
3216
|
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);
|
|
3212
3217
|
let r = t?.scopes ?? e.scopes;
|
|
3213
3218
|
return r && (n.scopes = r), n;
|
|
3214
3219
|
}
|
|
3215
|
-
function
|
|
3216
|
-
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ??
|
|
3220
|
+
function Ii(e) {
|
|
3221
|
+
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? ai(), c = ji(e.strikes), l = a.transports ? mi({
|
|
3217
3222
|
locks: a.transports.locks,
|
|
3218
3223
|
channel: a.transports.channel,
|
|
3219
3224
|
tabId: a.transports.tabId,
|
|
3220
3225
|
names: a.names,
|
|
3221
3226
|
clock: o
|
|
3222
|
-
}) :
|
|
3227
|
+
}) : hi(), u = { kind: "idle" }, d = 0, f = !1, p = !a.warnOnFirstCycle, m = 0, h = 0, g, _, v, y, b, x, ee, S, C = !1, w = () => o.now(), T = () => i.mode(), E = () => Y(r.getTokens()?.refresh_token), te = () => ({ ...r.getTokens() ?? {} }), D = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, O = () => (ee === void 0 && (ee = Z(r.getTokens() ?? n.getTokens())), ee), ne = /* @__PURE__ */ new Set(), re = /* @__PURE__ */ new Set(), ie = (e) => () => {
|
|
3223
3228
|
for (let t of Array.from(e)) t();
|
|
3224
|
-
}, ae = a.onStorageChange?.(ie(ne)), oe = e.platform?.onForeground(ie(re)), k =
|
|
3229
|
+
}, ae = a.onStorageChange?.(ie(ne)), oe = e.platform?.onForeground(ie(re)), k = Di({
|
|
3225
3230
|
storage: n,
|
|
3226
3231
|
cache: r,
|
|
3227
3232
|
identity: O,
|
|
@@ -3236,13 +3241,13 @@ function Fi(e) {
|
|
|
3236
3241
|
}), se = (e) => ({
|
|
3237
3242
|
trigger: e,
|
|
3238
3243
|
startedAt: w(),
|
|
3239
|
-
plain:
|
|
3244
|
+
plain: Oi(),
|
|
3240
3245
|
fresh: []
|
|
3241
3246
|
}), A = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, j = (e, t) => {
|
|
3242
3247
|
if (t === void 0) return e.plain.promise;
|
|
3243
3248
|
let n = {
|
|
3244
3249
|
callTime: t,
|
|
3245
|
-
deferred:
|
|
3250
|
+
deferred: Oi()
|
|
3246
3251
|
};
|
|
3247
3252
|
return e.fresh.push(n), n.deferred.promise;
|
|
3248
3253
|
}, M = (e, t, n = !1) => {
|
|
@@ -3261,11 +3266,11 @@ function Fi(e) {
|
|
|
3261
3266
|
}
|
|
3262
3267
|
}, P = (e, n, r, i) => {
|
|
3263
3268
|
let a = {
|
|
3264
|
-
message:
|
|
3269
|
+
message: Mi(r, "Token refresh failed"),
|
|
3265
3270
|
originalError: r,
|
|
3266
3271
|
operation: e,
|
|
3267
3272
|
source: n
|
|
3268
|
-
}, o =
|
|
3273
|
+
}, o = Ni(r);
|
|
3269
3274
|
o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
|
|
3270
3275
|
}, F = (e, t) => {
|
|
3271
3276
|
let n = {
|
|
@@ -3298,7 +3303,7 @@ function Fi(e) {
|
|
|
3298
3303
|
let n = r.getTokens(), i = Y(n?.refresh_token);
|
|
3299
3304
|
e.fp && i && l.post({
|
|
3300
3305
|
type: "tokens-refreshed",
|
|
3301
|
-
tokens:
|
|
3306
|
+
tokens: Pi(n),
|
|
3302
3307
|
from: e.fp,
|
|
3303
3308
|
...e.iat === void 0 ? {} : { fromIat: e.iat },
|
|
3304
3309
|
fromSid: e.sid ?? "",
|
|
@@ -3306,7 +3311,7 @@ function Fi(e) {
|
|
|
3306
3311
|
...t === void 0 ? {} : { sentAt: t }
|
|
3307
3312
|
});
|
|
3308
3313
|
}, de = () => {
|
|
3309
|
-
p || (p = !0, s.warn(
|
|
3314
|
+
p || (p = !0, s.warn(Jr));
|
|
3310
3315
|
}, fe = (e) => {
|
|
3311
3316
|
(e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
|
|
3312
3317
|
}, L = (e, n) => {
|
|
@@ -3320,7 +3325,7 @@ function Fi(e) {
|
|
|
3320
3325
|
}, e !== "disposed" && k.dropSession(), (e === "strikes" || e === "successor-timeout") && T() !== "json" && i.invalidate(), u = {
|
|
3321
3326
|
kind: "ended",
|
|
3322
3327
|
cause: e
|
|
3323
|
-
}, ce(r, n ?? new J(
|
|
3328
|
+
}, ce(r, n ?? new J(ki[e])), e) {
|
|
3324
3329
|
case "strikes":
|
|
3325
3330
|
t("session:expired", {
|
|
3326
3331
|
reason: "refresh_failed",
|
|
@@ -3355,7 +3360,7 @@ function Fi(e) {
|
|
|
3355
3360
|
break;
|
|
3356
3361
|
case "signed-out-here":
|
|
3357
3362
|
case "disposed": break;
|
|
3358
|
-
default:
|
|
3363
|
+
default: Ai(e);
|
|
3359
3364
|
}
|
|
3360
3365
|
}, pe = () => {
|
|
3361
3366
|
if (u.kind !== "ended" || u.cause === "disposed" || f || T() !== "json") return;
|
|
@@ -3372,7 +3377,7 @@ function Fi(e) {
|
|
|
3372
3377
|
}, me = (e) => {
|
|
3373
3378
|
u.kind === "ended" || f || T() === "json" && (L(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && pe());
|
|
3374
3379
|
}, he = (e) => {
|
|
3375
|
-
e instanceof
|
|
3380
|
+
e instanceof Ci ? (L("identity-changed"), pe()) : e instanceof Si ? L(e.cause === "emptied" ? "emptied" : "stored-ended") : L("stored-ended", e);
|
|
3376
3381
|
}, ge = () => {
|
|
3377
3382
|
u = { kind: "idle" }, C || l.release();
|
|
3378
3383
|
}, _e = (e) => !e.from || T() !== "json" || e.from === E() || e.from === Y(n.getTokens()?.refresh_token), ve = (e) => {
|
|
@@ -3441,14 +3446,14 @@ function Fi(e) {
|
|
|
3441
3446
|
case "ended": return k.endHeldSend(), L("stored-ended"), !1;
|
|
3442
3447
|
case "identity-changed": return k.endHeldSend(), L("identity-changed"), pe(), !1;
|
|
3443
3448
|
case "send": return we(e, t, a.sent, r);
|
|
3444
|
-
default: return
|
|
3449
|
+
default: return Ai(a);
|
|
3445
3450
|
}
|
|
3446
3451
|
}, we = (e, n, r, a) => {
|
|
3447
3452
|
let o = {
|
|
3448
3453
|
generation: d,
|
|
3449
3454
|
sentAt: w(),
|
|
3450
3455
|
trigger: n,
|
|
3451
|
-
settled:
|
|
3456
|
+
settled: Oi()
|
|
3452
3457
|
};
|
|
3453
3458
|
r ? o.sent = r : o.marker = D(), a && (o.stored = a), u = {
|
|
3454
3459
|
kind: "refreshing",
|
|
@@ -3485,7 +3490,7 @@ function Fi(e) {
|
|
|
3485
3490
|
if (!Te(e)) return;
|
|
3486
3491
|
r.setTokensCache({
|
|
3487
3492
|
...n.getTokens() ?? {},
|
|
3488
|
-
...
|
|
3493
|
+
...Fi(t, void 0)
|
|
3489
3494
|
}), I("refresh", "this-tab");
|
|
3490
3495
|
let c = O();
|
|
3491
3496
|
l.post(c === void 0 ? {
|
|
@@ -3498,7 +3503,7 @@ function Fi(e) {
|
|
|
3498
3503
|
}), ge(), M(a, e.sentAt);
|
|
3499
3504
|
return;
|
|
3500
3505
|
}
|
|
3501
|
-
let o = E(), s = k.commitSave(e.sent,
|
|
3506
|
+
let o = E(), s = k.commitSave(e.sent, Fi(t, e.stored));
|
|
3502
3507
|
switch (s.kind) {
|
|
3503
3508
|
case "saved":
|
|
3504
3509
|
I("refresh", "this-tab"), ue(e.sent.order, e.sentAt), ge(), M(a, e.sentAt);
|
|
@@ -3516,7 +3521,7 @@ function Fi(e) {
|
|
|
3516
3521
|
P("refresh", e.trigger, t, F("auth")), L("identity-changed", t), pe();
|
|
3517
3522
|
return;
|
|
3518
3523
|
}
|
|
3519
|
-
default:
|
|
3524
|
+
default: Ai(s);
|
|
3520
3525
|
}
|
|
3521
3526
|
}, De = (e, t) => {
|
|
3522
3527
|
if (e.sent?.held && k.endHeldSend(), !Te(e) || u.kind !== "refreshing") return;
|
|
@@ -3536,9 +3541,9 @@ function Fi(e) {
|
|
|
3536
3541
|
case "own":
|
|
3537
3542
|
r = o.failure, i = o.heldRefused;
|
|
3538
3543
|
break;
|
|
3539
|
-
default:
|
|
3544
|
+
default: Ai(o);
|
|
3540
3545
|
}
|
|
3541
|
-
} else r =
|
|
3546
|
+
} else r = di(t, w());
|
|
3542
3547
|
if (i) P("refresh", e.trigger, t, F(r.kind)), I("adopted", "other-tab"), ge(), M(n, void 0, !0);
|
|
3543
3548
|
else switch (r.kind) {
|
|
3544
3549
|
case "blocked":
|
|
@@ -3554,10 +3559,10 @@ function Fi(e) {
|
|
|
3554
3559
|
case "transient":
|
|
3555
3560
|
m += 1, Oe(e, n, t, r);
|
|
3556
3561
|
return;
|
|
3557
|
-
default:
|
|
3562
|
+
default: Ai(r.kind);
|
|
3558
3563
|
}
|
|
3559
3564
|
}, Oe = (e, t, n, r) => {
|
|
3560
|
-
let i = w() +
|
|
3565
|
+
let i = w() + fi(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
|
|
3561
3566
|
P("refresh", e.trigger, n, F(a, i)), a === "transient" && le(w(), i, "this-tab");
|
|
3562
3567
|
let s = {
|
|
3563
3568
|
kind: a,
|
|
@@ -3567,7 +3572,7 @@ function Fi(e) {
|
|
|
3567
3572
|
}, c = e.sent?.order.fp;
|
|
3568
3573
|
c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
|
|
3569
3574
|
type: "retry-scheduled",
|
|
3570
|
-
message:
|
|
3575
|
+
message: Mi(n, "Token refresh failed"),
|
|
3571
3576
|
retry: s
|
|
3572
3577
|
}), ve(se("retry")), N(t, n, e.sentAt);
|
|
3573
3578
|
}, ke = (e, t) => {
|
|
@@ -3580,8 +3585,8 @@ function Fi(e) {
|
|
|
3580
3585
|
fp: i.fp
|
|
3581
3586
|
})), r && k.deleteIfStillDead(r), L("strikes", t);
|
|
3582
3587
|
}, Ae = (e, t, n, r) => {
|
|
3583
|
-
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${
|
|
3584
|
-
let i = d, a = w() +
|
|
3588
|
+
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${Mi(n, "blocked")}`);
|
|
3589
|
+
let i = d, a = w() + Nr, c = {
|
|
3585
3590
|
kind: "blocked-wait",
|
|
3586
3591
|
pending: e,
|
|
3587
3592
|
deadline: a,
|
|
@@ -3594,9 +3599,9 @@ function Fi(e) {
|
|
|
3594
3599
|
i === d && u === c && (je() || (f ? (e.cookieRetried = !0, u = {
|
|
3595
3600
|
kind: "waiting",
|
|
3596
3601
|
pending: e
|
|
3597
|
-
}, l.request()) : w() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), L("successor-timeout")) : c.cancel = o.setTimeout(p,
|
|
3602
|
+
}, l.request()) : w() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), L("successor-timeout")) : c.cancel = o.setTimeout(p, Pr)));
|
|
3598
3603
|
};
|
|
3599
|
-
c.cancel = o.setTimeout(p, f ?
|
|
3604
|
+
c.cancel = o.setTimeout(p, f ? Ir : Pr);
|
|
3600
3605
|
}, je = () => {
|
|
3601
3606
|
if (u.kind !== "blocked-wait") return !1;
|
|
3602
3607
|
let e = u;
|
|
@@ -3640,7 +3645,7 @@ function Fi(e) {
|
|
|
3640
3645
|
case "idle":
|
|
3641
3646
|
case "refreshing":
|
|
3642
3647
|
case "ended": return;
|
|
3643
|
-
default:
|
|
3648
|
+
default: Ai(u);
|
|
3644
3649
|
}
|
|
3645
3650
|
}, Ie = (e) => {
|
|
3646
3651
|
let t = {};
|
|
@@ -3704,7 +3709,7 @@ function Fi(e) {
|
|
|
3704
3709
|
return;
|
|
3705
3710
|
case "takeover":
|
|
3706
3711
|
case "rate-limited": return;
|
|
3707
|
-
default:
|
|
3712
|
+
default: Ai(e);
|
|
3708
3713
|
}
|
|
3709
3714
|
}, Re = () => {
|
|
3710
3715
|
S && !l.holding && l.post({
|
|
@@ -3769,7 +3774,7 @@ function Fi(e) {
|
|
|
3769
3774
|
case "refreshing":
|
|
3770
3775
|
case "backoff":
|
|
3771
3776
|
case "blocked-wait": return j(u.pending, t);
|
|
3772
|
-
default: return
|
|
3777
|
+
default: return Ai(u);
|
|
3773
3778
|
}
|
|
3774
3779
|
}, R = (e) => {
|
|
3775
3780
|
if (f) return Promise.reject(new J(q.disposed));
|
|
@@ -3820,9 +3825,9 @@ function Fi(e) {
|
|
|
3820
3825
|
}, Ge = async (e, t) => {
|
|
3821
3826
|
if (f) throw new J(q.disposed);
|
|
3822
3827
|
de();
|
|
3823
|
-
let n = w() +
|
|
3828
|
+
let n = w() + Lr;
|
|
3824
3829
|
if (await Ue(n - w()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await He("commit", n - w())) === "timeout") {
|
|
3825
|
-
let e = new
|
|
3830
|
+
let e = new vi("lock-timeout");
|
|
3826
3831
|
throw P("upgrade.commit", "upgrade", e), e;
|
|
3827
3832
|
}
|
|
3828
3833
|
C = !0;
|
|
@@ -3868,12 +3873,12 @@ function Fi(e) {
|
|
|
3868
3873
|
}
|
|
3869
3874
|
if (!o) {
|
|
3870
3875
|
if (u !== d) {
|
|
3871
|
-
let e = new
|
|
3876
|
+
let e = new vi("superseded");
|
|
3872
3877
|
throw P("upgrade.commit", "upgrade", e), e;
|
|
3873
3878
|
}
|
|
3874
3879
|
await i.applyOpaque(f), r.setTokensCache({
|
|
3875
3880
|
...n.getTokens() ?? {},
|
|
3876
|
-
...
|
|
3881
|
+
...Fi(f, void 0)
|
|
3877
3882
|
}), Ke(c);
|
|
3878
3883
|
let e = O();
|
|
3879
3884
|
return l.post(e === void 0 ? {
|
|
@@ -3885,9 +3890,9 @@ function Fi(e) {
|
|
|
3885
3890
|
sub: e
|
|
3886
3891
|
}), te();
|
|
3887
3892
|
}
|
|
3888
|
-
let p = k.commitSave(o,
|
|
3893
|
+
let p = k.commitSave(o, Fi(f, s));
|
|
3889
3894
|
if (p.kind === "saved") return Ke(c), ue(o.order, c), te();
|
|
3890
|
-
let m = new
|
|
3895
|
+
let m = new vi("superseded");
|
|
3891
3896
|
throw P("upgrade.commit", "upgrade", m), p.kind === "superseded" && p.adopted && I("adopted", "other-tab"), m;
|
|
3892
3897
|
}, Ke = (e) => {
|
|
3893
3898
|
if (I("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
|
|
@@ -3913,7 +3918,7 @@ function Fi(e) {
|
|
|
3913
3918
|
commitUpgrade: Ge,
|
|
3914
3919
|
signOut: async (e) => {
|
|
3915
3920
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3916
|
-
let t = w() +
|
|
3921
|
+
let t = w() + Rr;
|
|
3917
3922
|
Je(), await Ue(t - w()), Je(), l.coordinated && !l.holding && await He("logout", t - w());
|
|
3918
3923
|
try {
|
|
3919
3924
|
qe(), await e(n.getTokens()?.refresh_token);
|
|
@@ -3959,7 +3964,7 @@ function Fi(e) {
|
|
|
3959
3964
|
};
|
|
3960
3965
|
}
|
|
3961
3966
|
// lib/token/verify.ts
|
|
3962
|
-
var
|
|
3967
|
+
var Li = {
|
|
3963
3968
|
ES256: {
|
|
3964
3969
|
kty: "EC",
|
|
3965
3970
|
key: (e) => ({
|
|
@@ -3990,34 +3995,34 @@ var Ii = {
|
|
|
3990
3995
|
},
|
|
3991
3996
|
signature: { name: "RSASSA-PKCS1-v1_5" }
|
|
3992
3997
|
}
|
|
3993
|
-
},
|
|
3998
|
+
}, Ri = (e) => {
|
|
3994
3999
|
let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = globalThis.atob(t + "=".repeat((4 - t.length % 4) % 4));
|
|
3995
4000
|
return Uint8Array.from(n, (e) => e.charCodeAt(0));
|
|
3996
|
-
},
|
|
4001
|
+
}, zi = () => {
|
|
3997
4002
|
let e = globalThis.crypto;
|
|
3998
4003
|
if (!e?.subtle) throw Error("Verifying tokens needs the Web Crypto API, available only in a secure context (https or localhost)");
|
|
3999
4004
|
return e;
|
|
4000
4005
|
};
|
|
4001
|
-
async function
|
|
4002
|
-
let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(
|
|
4006
|
+
async function Bi(e, t, n, r, i) {
|
|
4007
|
+
let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(Ri(a))), l = c.alg === "ES256" || c.alg === "RS256" ? Li[c.alg] : void 0;
|
|
4003
4008
|
if (!l) throw Error(`Token signing algorithm ${String(c.alg)} is not accepted`);
|
|
4004
4009
|
let u = t.find((e) => e.kid === c.kid && e.kty === l.kty && (e.kty !== "EC" || e.crv === "P-256"));
|
|
4005
4010
|
if (!u) throw Error("Token signing key is not published by the server");
|
|
4006
|
-
let d =
|
|
4007
|
-
if (!await d.verify(l.signature, f,
|
|
4011
|
+
let d = zi().subtle, f = await d.importKey("jwk", l.key(u), l.imported, !1, ["verify"]), p = new TextEncoder().encode(`${a}.${o}`);
|
|
4012
|
+
if (!await d.verify(l.signature, f, Ri(s), p)) throw Error("Token signature is not valid");
|
|
4008
4013
|
let m = j(e), h = Array.isArray(m.aud) ? m.aud : [m.aud];
|
|
4009
4014
|
if (m.iss !== n) throw Error("Token issuer does not match the server");
|
|
4010
4015
|
if (!h.includes(r)) throw Error("Token is not issued for this app");
|
|
4011
4016
|
if (typeof m.exp != "number" || A(m, 0)) throw Error("Token has expired");
|
|
4012
4017
|
if (i && m.type !== i) throw Error("Token type is not valid");
|
|
4013
4018
|
}
|
|
4014
|
-
async function
|
|
4019
|
+
async function Vi(t, n, r) {
|
|
4015
4020
|
if (!n) throw Error("An app id is required to accept tokens from the URL");
|
|
4016
4021
|
if (!r.access_token) throw Error("No access token received");
|
|
4017
|
-
|
|
4022
|
+
zi();
|
|
4018
4023
|
let i = t.replace(/\/+$/, ""), [a, o] = await Promise.all([e.get(`${i}/.well-known/openid-configuration`), e.get(`${i}/.well-known/jwks.json`)]), s = a.data?.issuer, c = o.data?.keys ?? [];
|
|
4019
4024
|
if (!s) throw Error("The server did not publish an issuer");
|
|
4020
|
-
await
|
|
4025
|
+
await Bi(r.access_token, c, s, n, M.access_token), r.refresh_token && await Bi(r.refresh_token, c, s, n, M.refresh_token), r.id_token && await Bi(r.id_token, c, s, n);
|
|
4021
4026
|
}
|
|
4022
4027
|
// lib/upgrade/errors.ts
|
|
4023
4028
|
var Q = {
|
|
@@ -4037,23 +4042,23 @@ var Q = {
|
|
|
4037
4042
|
grantPredatesCredentialReset: "error.grant.predates_credential_reset",
|
|
4038
4043
|
tokenAccessEnded: "error.token.access_ended",
|
|
4039
4044
|
userNotFound: "error.user.not_found"
|
|
4040
|
-
},
|
|
4045
|
+
}, Hi = Object.freeze([
|
|
4041
4046
|
Q.twoFactorCodeInvalid,
|
|
4042
4047
|
Q.twoFactorNotEnabled,
|
|
4043
4048
|
Q.challengeInvalid,
|
|
4044
4049
|
Q.challengeSessionMismatch,
|
|
4045
4050
|
Q.challengeTooManyAttempts
|
|
4046
|
-
]),
|
|
4051
|
+
]), Ui = Object.freeze([
|
|
4047
4052
|
Q.tokenInvalid,
|
|
4048
4053
|
Q.grantPredatesCredentialReset,
|
|
4049
4054
|
Q.tokenAccessEnded,
|
|
4050
4055
|
Q.userNotFound
|
|
4051
|
-
]),
|
|
4056
|
+
]), Wi = Object.freeze([
|
|
4052
4057
|
"wrong_code",
|
|
4053
4058
|
"challenge_spent",
|
|
4054
4059
|
"not_registered",
|
|
4055
4060
|
"prepare_not_required"
|
|
4056
|
-
]),
|
|
4061
|
+
]), Gi = (e) => Wi.includes(e), Ki = {
|
|
4057
4062
|
wrong_code: "That code was not accepted. Try again.",
|
|
4058
4063
|
challenge_spent: "That verification challenge is no longer valid. Start again.",
|
|
4059
4064
|
exhausted: "Too many attempts. Try again later.",
|
|
@@ -4068,9 +4073,9 @@ var Q = {
|
|
|
4068
4073
|
session_changed: "The session ended during verification."
|
|
4069
4074
|
}, $ = class extends Error {
|
|
4070
4075
|
constructor(e) {
|
|
4071
|
-
super(e.message ||
|
|
4076
|
+
super(e.message || Ki[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, e.retryAfter !== void 0 && (this.retryAfter = e.retryAfter), this.retryable = Gi(e.kind), e.cause !== void 0 && (this.cause = e.cause);
|
|
4072
4077
|
}
|
|
4073
|
-
},
|
|
4078
|
+
}, qi = Object.freeze([
|
|
4074
4079
|
"upgrade_transport",
|
|
4075
4080
|
"upgrade_insufficient",
|
|
4076
4081
|
"upgrade_unavailable",
|
|
@@ -4078,14 +4083,14 @@ var Q = {
|
|
|
4078
4083
|
"upgrade_cancelled",
|
|
4079
4084
|
"upgrade_unsatisfiable",
|
|
4080
4085
|
"upgrade_sign_in_required"
|
|
4081
|
-
]),
|
|
4086
|
+
]), Ji = (e) => typeof e == "object" && !!e && typeof e.code == "string" && qi.includes(e.code), Yi = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", Xi = (e) => {
|
|
4082
4087
|
let t = e?.error, n = typeof t == "string" ? t : t?.message;
|
|
4083
4088
|
if (typeof n == "string" && n && !n.startsWith("localized error:")) return n;
|
|
4084
|
-
},
|
|
4089
|
+
}, Zi = (e) => {
|
|
4085
4090
|
if (!e || typeof e != "object") return;
|
|
4086
4091
|
let t = e["retry-after"];
|
|
4087
4092
|
return typeof t == "string" && /^\d+$/.test(t.trim()) ? Number(t.trim()) : void 0;
|
|
4088
|
-
},
|
|
4093
|
+
}, Qi = (e) => {
|
|
4089
4094
|
if (typeof e != "object" || !e) return {
|
|
4090
4095
|
hasResponse: !1,
|
|
4091
4096
|
message: typeof e == "string" ? e : void 0
|
|
@@ -4096,10 +4101,10 @@ var Q = {
|
|
|
4096
4101
|
errorId: typeof t.id == "string" ? t.id : i,
|
|
4097
4102
|
message: typeof t.message == "string" ? t.message : void 0,
|
|
4098
4103
|
hasResponse: n !== void 0 || typeof t.status == "number",
|
|
4099
|
-
serverText:
|
|
4100
|
-
retryAfter:
|
|
4104
|
+
serverText: Xi(n?.data),
|
|
4105
|
+
retryAfter: Zi(n?.headers)
|
|
4101
4106
|
};
|
|
4102
|
-
},
|
|
4107
|
+
}, $i = (e, t) => {
|
|
4103
4108
|
switch (e) {
|
|
4104
4109
|
case Q.twoFactorCodeInvalid: return "wrong_code";
|
|
4105
4110
|
case Q.challengeInvalid:
|
|
@@ -4117,15 +4122,15 @@ var Q = {
|
|
|
4117
4122
|
case "error.service.unavailable": return "network";
|
|
4118
4123
|
default: return;
|
|
4119
4124
|
}
|
|
4120
|
-
},
|
|
4125
|
+
}, ea = (e, t) => e === void 0 ? "network" : e === 501 ? "unavailable" : e === 400 ? "fatal" : e === 429 ? "rate_limited" : e === 401 || e === 403 ? t === "start" ? "challenge_spent" : "session_changed" : e >= 500 ? "network" : "fatal", ta = (e, t) => {
|
|
4121
4126
|
if (e instanceof $) return e;
|
|
4122
|
-
let n =
|
|
4127
|
+
let n = Qi(e);
|
|
4123
4128
|
if (!n.hasResponse) return new $({
|
|
4124
4129
|
kind: "network",
|
|
4125
4130
|
message: n.message,
|
|
4126
4131
|
cause: e
|
|
4127
4132
|
});
|
|
4128
|
-
let r =
|
|
4133
|
+
let r = $i(n.errorId, t) ?? ea(n.status, t);
|
|
4129
4134
|
return r === "rate_limited" ? new $({
|
|
4130
4135
|
kind: r,
|
|
4131
4136
|
message: n.serverText,
|
|
@@ -4140,61 +4145,61 @@ var Q = {
|
|
|
4140
4145
|
errorId: n.errorId,
|
|
4141
4146
|
cause: e
|
|
4142
4147
|
});
|
|
4143
|
-
},
|
|
4148
|
+
}, na = (e) => e.errorId !== void 0 && Hi.includes(e.errorId), ra = (e) => e.errorId !== void 0 && Ui.includes(e.errorId), ia = class extends Error {
|
|
4144
4149
|
constructor(e, t, n) {
|
|
4145
4150
|
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;
|
|
4146
4151
|
}
|
|
4147
|
-
},
|
|
4152
|
+
}, aa = class extends Error {
|
|
4148
4153
|
constructor(e = "Step-up verification is not available on this deployment") {
|
|
4149
4154
|
super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
|
|
4150
4155
|
}
|
|
4151
|
-
},
|
|
4156
|
+
}, oa = class extends Error {
|
|
4152
4157
|
constructor(e = "The session changed during verification") {
|
|
4153
4158
|
super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
|
|
4154
4159
|
}
|
|
4155
|
-
},
|
|
4160
|
+
}, sa = (e) => {
|
|
4156
4161
|
if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
|
|
4157
4162
|
sub: e.sub,
|
|
4158
4163
|
sid: e.sid
|
|
4159
4164
|
} : { sub: e.sub };
|
|
4160
|
-
},
|
|
4165
|
+
}, ca = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
|
|
4161
4166
|
// lib/utils/validation.ts
|
|
4162
|
-
function
|
|
4167
|
+
function la(e) {
|
|
4163
4168
|
if (!e || typeof e != "string") return !1;
|
|
4164
4169
|
let t = e.split(".");
|
|
4165
4170
|
if (t.length !== 3) return !1;
|
|
4166
4171
|
let n = /^[A-Za-z0-9_-]+$/;
|
|
4167
4172
|
return t.every((e) => n.test(e) && e.length > 0);
|
|
4168
4173
|
}
|
|
4169
|
-
function
|
|
4174
|
+
function ua(e) {
|
|
4170
4175
|
return e.replace(/<[^>]*>/g, "").substring(0, 200);
|
|
4171
4176
|
}
|
|
4172
|
-
function
|
|
4177
|
+
function da(e) {
|
|
4173
4178
|
if (!e || typeof e != "string") return !1;
|
|
4174
4179
|
let t = e.trim();
|
|
4175
4180
|
return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
|
|
4176
4181
|
}
|
|
4177
|
-
function
|
|
4182
|
+
function fa(e) {
|
|
4178
4183
|
if (!e || typeof e != "string") return !1;
|
|
4179
4184
|
let t = e.trim();
|
|
4180
4185
|
return /^\+[1-9]\d{1,14}$/.test(t);
|
|
4181
4186
|
}
|
|
4182
|
-
function
|
|
4187
|
+
function pa(e) {
|
|
4183
4188
|
if (!e || typeof e != "string") return !1;
|
|
4184
4189
|
let t = e.trim();
|
|
4185
4190
|
return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
|
|
4186
4191
|
}
|
|
4187
|
-
function
|
|
4192
|
+
function ma(e, t = 6) {
|
|
4188
4193
|
return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
|
|
4189
4194
|
}
|
|
4190
|
-
function
|
|
4195
|
+
function ha(e) {
|
|
4191
4196
|
if (!e || typeof e != "string") return null;
|
|
4192
4197
|
let t = e.toUpperCase().replace(/\s+/g, "");
|
|
4193
4198
|
return t.length > 64 || !/^[A-Z0-9-]+$/.test(t) || t.replace(/-/g, "") === "" ? null : t;
|
|
4194
4199
|
}
|
|
4195
4200
|
// lib/services/auth-service.ts
|
|
4196
|
-
var
|
|
4197
|
-
function
|
|
4201
|
+
var ga = (e) => e ? [e] : [], _a = "passflow_2fa_pkce", va = 3e5, ya = "passflow_pwless_pending", ba = 3e3, xa = "passflow_federated_pkce", Sa = 6e5, Ca = "AppId is required for federated auth";
|
|
4202
|
+
function wa(e) {
|
|
4198
4203
|
let t;
|
|
4199
4204
|
try {
|
|
4200
4205
|
t = new URL(e).protocol;
|
|
@@ -4204,11 +4209,11 @@ function Ca(e) {
|
|
|
4204
4209
|
if (t !== "https:" && t !== "http:") throw Error("The federated start returned an address that is not http or https");
|
|
4205
4210
|
return e;
|
|
4206
4211
|
}
|
|
4207
|
-
function
|
|
4212
|
+
function Ta(e) {
|
|
4208
4213
|
let t = {};
|
|
4209
4214
|
return e.connection_id !== void 0 && (t.connection_id = e.connection_id), e.email !== void 0 && (t.email = e.email), t;
|
|
4210
4215
|
}
|
|
4211
|
-
var
|
|
4216
|
+
var Ea = 10, Da = "The sign-in answered with a PKCE code, but its verifier is gone", Oa = (e, t) => new Promise((n, r) => {
|
|
4212
4217
|
if (t?.aborted) {
|
|
4213
4218
|
r(t.reason);
|
|
4214
4219
|
return;
|
|
@@ -4219,21 +4224,21 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4219
4224
|
t?.removeEventListener("abort", i), n();
|
|
4220
4225
|
}, e);
|
|
4221
4226
|
t?.addEventListener("abort", i, { once: !0 });
|
|
4222
|
-
}),
|
|
4227
|
+
}), ka = (e) => {
|
|
4223
4228
|
if (!e) return;
|
|
4224
4229
|
let t = new URLSearchParams(e.search).get("token");
|
|
4225
4230
|
if (t) return t;
|
|
4226
4231
|
let n = e.hash.indexOf("?");
|
|
4227
4232
|
return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
|
|
4228
|
-
},
|
|
4233
|
+
}, Aa = (e) => {
|
|
4229
4234
|
if (e) try {
|
|
4230
4235
|
return j(e).email;
|
|
4231
4236
|
} catch {
|
|
4232
4237
|
return;
|
|
4233
4238
|
}
|
|
4234
|
-
},
|
|
4235
|
-
constructor(e, t, n, r, i, a, o, s, c, l, u, d = me, f, p = { coordination:
|
|
4236
|
-
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.readAppSettings = m, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new P(n), this.setBffModeIfConfigured(), this.refresh =
|
|
4239
|
+
}, ja = class {
|
|
4240
|
+
constructor(e, t, n, r, i, a, o, s, c, l, u, d = me, f, p = { coordination: ni() }, m) {
|
|
4241
|
+
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.readAppSettings = m, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new P(n), this.setBffModeIfConfigured(), this.refresh = Ii({
|
|
4237
4242
|
emit: this.createRefreshEmit(),
|
|
4238
4243
|
storage: n,
|
|
4239
4244
|
cache: i,
|
|
@@ -4241,7 +4246,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4241
4246
|
coordination: p.coordination,
|
|
4242
4247
|
platform: d,
|
|
4243
4248
|
...p.strikes === void 0 ? {} : { strikes: p.strikes },
|
|
4244
|
-
logger:
|
|
4249
|
+
logger: ai()
|
|
4245
4250
|
}), this.initializeSession();
|
|
4246
4251
|
}
|
|
4247
4252
|
setAppId(e) {
|
|
@@ -4332,7 +4337,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4332
4337
|
rememberEmailChallenge(e, t) {
|
|
4333
4338
|
this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
|
|
4334
4339
|
for (let e of this.emailChallenges.keys()) {
|
|
4335
|
-
if (this.emailChallenges.size <=
|
|
4340
|
+
if (this.emailChallenges.size <= Ea) break;
|
|
4336
4341
|
this.emailChallenges.delete(e);
|
|
4337
4342
|
}
|
|
4338
4343
|
}
|
|
@@ -4340,14 +4345,14 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4340
4345
|
if (this.pendingPkce = {
|
|
4341
4346
|
verifier: e,
|
|
4342
4347
|
scopes: t,
|
|
4343
|
-
expiresAt: Date.now() +
|
|
4348
|
+
expiresAt: Date.now() + va
|
|
4344
4349
|
}, typeof sessionStorage < "u") try {
|
|
4345
|
-
sessionStorage.setItem(
|
|
4350
|
+
sessionStorage.setItem(_a, JSON.stringify(this.pendingPkce));
|
|
4346
4351
|
} catch {}
|
|
4347
4352
|
}
|
|
4348
4353
|
readPendingPkce() {
|
|
4349
4354
|
if (!this.pendingPkce && typeof sessionStorage < "u") try {
|
|
4350
|
-
let e = sessionStorage.getItem(
|
|
4355
|
+
let e = sessionStorage.getItem(_a);
|
|
4351
4356
|
this.pendingPkce = e ? JSON.parse(e) : void 0;
|
|
4352
4357
|
} catch {
|
|
4353
4358
|
this.pendingPkce = void 0;
|
|
@@ -4359,17 +4364,17 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4359
4364
|
}
|
|
4360
4365
|
forgetPkceSignIn() {
|
|
4361
4366
|
if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
|
|
4362
|
-
sessionStorage.removeItem(
|
|
4367
|
+
sessionStorage.removeItem(_a);
|
|
4363
4368
|
} catch {}
|
|
4364
4369
|
}
|
|
4365
4370
|
rememberPendingPasswordless(e) {
|
|
4366
4371
|
if (this.pendingPasswordless = e, typeof sessionStorage < "u") try {
|
|
4367
|
-
sessionStorage.setItem(
|
|
4372
|
+
sessionStorage.setItem(ya, JSON.stringify(e));
|
|
4368
4373
|
} catch {}
|
|
4369
4374
|
}
|
|
4370
4375
|
readPendingPasswordless() {
|
|
4371
4376
|
if (!this.pendingPasswordless && typeof sessionStorage < "u") try {
|
|
4372
|
-
let e = sessionStorage.getItem(
|
|
4377
|
+
let e = sessionStorage.getItem(ya);
|
|
4373
4378
|
this.pendingPasswordless = e ? JSON.parse(e) : void 0;
|
|
4374
4379
|
} catch {
|
|
4375
4380
|
this.pendingPasswordless = void 0;
|
|
@@ -4378,21 +4383,21 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4378
4383
|
}
|
|
4379
4384
|
forgetPendingPasswordless() {
|
|
4380
4385
|
if (this.pendingPasswordless = void 0, typeof sessionStorage < "u") try {
|
|
4381
|
-
sessionStorage.removeItem(
|
|
4386
|
+
sessionStorage.removeItem(ya);
|
|
4382
4387
|
} catch {}
|
|
4383
4388
|
}
|
|
4384
4389
|
rememberFederatedSlot(e, t) {
|
|
4385
4390
|
if (this.federatedSlot = {
|
|
4386
4391
|
verifier: e,
|
|
4387
4392
|
scopes: t,
|
|
4388
|
-
expiresAt: Date.now() +
|
|
4393
|
+
expiresAt: Date.now() + Sa
|
|
4389
4394
|
}, typeof sessionStorage < "u") try {
|
|
4390
|
-
sessionStorage.setItem(
|
|
4395
|
+
sessionStorage.setItem(xa, JSON.stringify(this.federatedSlot));
|
|
4391
4396
|
} catch {}
|
|
4392
4397
|
}
|
|
4393
4398
|
readFederatedSlot() {
|
|
4394
4399
|
if (!this.federatedSlot && typeof sessionStorage < "u") try {
|
|
4395
|
-
let e = sessionStorage.getItem(
|
|
4400
|
+
let e = sessionStorage.getItem(xa);
|
|
4396
4401
|
this.federatedSlot = e ? JSON.parse(e) : void 0;
|
|
4397
4402
|
} catch {
|
|
4398
4403
|
this.federatedSlot = void 0;
|
|
@@ -4401,7 +4406,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4401
4406
|
}
|
|
4402
4407
|
forgetFederatedSlot() {
|
|
4403
4408
|
if (this.federatedSlot = void 0, typeof sessionStorage < "u") try {
|
|
4404
|
-
sessionStorage.removeItem(
|
|
4409
|
+
sessionStorage.removeItem(xa);
|
|
4405
4410
|
} catch {}
|
|
4406
4411
|
}
|
|
4407
4412
|
async startPkce() {
|
|
@@ -4409,17 +4414,17 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4409
4414
|
try {
|
|
4410
4415
|
e = await this.readPkceEnabled?.() ?? !1;
|
|
4411
4416
|
} catch (e) {
|
|
4412
|
-
|
|
4417
|
+
ai().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
|
|
4413
4418
|
return;
|
|
4414
4419
|
}
|
|
4415
|
-
return e ?
|
|
4420
|
+
return e ? Wn() : void 0;
|
|
4416
4421
|
}
|
|
4417
4422
|
async exchangeCode(e, t) {
|
|
4418
4423
|
return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
|
|
4419
4424
|
}
|
|
4420
4425
|
async completePkceSignIn(e) {
|
|
4421
4426
|
let t = this.readPendingPkce();
|
|
4422
|
-
if (!t) throw Error(
|
|
4427
|
+
if (!t) throw Error(Da);
|
|
4423
4428
|
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
4424
4429
|
return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
|
|
4425
4430
|
}
|
|
@@ -4449,7 +4454,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4449
4454
|
if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
|
|
4450
4455
|
}
|
|
4451
4456
|
async signIn(e, t) {
|
|
4452
|
-
if ("email" in e && e.email && !
|
|
4457
|
+
if ("email" in e && e.email && !da(e.email)) {
|
|
4453
4458
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4454
4459
|
operation: "sign-in",
|
|
4455
4460
|
message: "Invalid email format",
|
|
@@ -4458,7 +4463,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4458
4463
|
};
|
|
4459
4464
|
throw U(this.subscribeStore, t), e;
|
|
4460
4465
|
}
|
|
4461
|
-
if ("username" in e && e.username && !
|
|
4466
|
+
if ("username" in e && e.username && !pa(e.username)) {
|
|
4462
4467
|
let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
|
|
4463
4468
|
operation: "sign-in",
|
|
4464
4469
|
message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
|
|
@@ -4467,7 +4472,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4467
4472
|
};
|
|
4468
4473
|
throw U(this.subscribeStore, t), e;
|
|
4469
4474
|
}
|
|
4470
|
-
if ("phone" in e && e.phone && !
|
|
4475
|
+
if ("phone" in e && e.phone && !fa(e.phone)) {
|
|
4471
4476
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4472
4477
|
operation: "sign-in",
|
|
4473
4478
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4483,7 +4488,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4483
4488
|
let i = await this.startPkce(), a = await this.authApi.signIn(i ? {
|
|
4484
4489
|
...e,
|
|
4485
4490
|
code_challenge: i.challenge
|
|
4486
|
-
} : e, n, r, ...
|
|
4491
|
+
} : e, n, r, ...ga(t));
|
|
4487
4492
|
if (this.handleEmailVerificationStep(a, "sign-in", e.email, i, e.scopes) || this.handlePendingSecondFactor(a, e.email, i, e.scopes)) return a;
|
|
4488
4493
|
let o = await this.exchangeCode(a, i);
|
|
4489
4494
|
return this.handlePendingSecondFactor(o, e.email) || (await this.processAuthResponse(o, e.scopes), this.subscribeStore.notify(W.SignIn, {
|
|
@@ -4501,7 +4506,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4501
4506
|
}
|
|
4502
4507
|
}
|
|
4503
4508
|
async signUp(e, t) {
|
|
4504
|
-
if (e.user.email && !
|
|
4509
|
+
if (e.user.email && !da(e.user.email)) {
|
|
4505
4510
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4506
4511
|
operation: "sign-up",
|
|
4507
4512
|
message: "Invalid email format",
|
|
@@ -4510,7 +4515,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4510
4515
|
};
|
|
4511
4516
|
throw U(this.subscribeStore, t), e;
|
|
4512
4517
|
}
|
|
4513
|
-
if (e.user.phone_number && !
|
|
4518
|
+
if (e.user.phone_number && !fa(e.user.phone_number)) {
|
|
4514
4519
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4515
4520
|
operation: "sign-up",
|
|
4516
4521
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4524,7 +4529,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4524
4529
|
let n = await this.startPkce(), r = await this.authApi.signUp(n ? {
|
|
4525
4530
|
...e,
|
|
4526
4531
|
code_challenge: n.challenge
|
|
4527
|
-
} : e, ...
|
|
4532
|
+
} : e, ...ga(t));
|
|
4528
4533
|
if (this.handleEmailVerificationStep(r, "sign-up", e.user.email, n, e.scopes) || this.handlePendingSecondFactor(r, e.user.email, n, e.scopes)) return r;
|
|
4529
4534
|
let i = await this.exchangeCode(r, n);
|
|
4530
4535
|
return this.handlePendingSecondFactor(i, e.user.email) || (await this.processAuthResponse(i, e.scopes), this.notifyRegisteredAndSignedIn(i), await this.submitSessionCheck()), i;
|
|
@@ -4539,7 +4544,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4539
4544
|
}
|
|
4540
4545
|
}
|
|
4541
4546
|
async passwordlessSignIn(e, t) {
|
|
4542
|
-
if (e.email && !
|
|
4547
|
+
if (e.email && !da(e.email)) {
|
|
4543
4548
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4544
4549
|
operation: "passwordless.start",
|
|
4545
4550
|
message: "Invalid email format",
|
|
@@ -4548,7 +4553,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4548
4553
|
};
|
|
4549
4554
|
throw U(this.subscribeStore, t), e;
|
|
4550
4555
|
}
|
|
4551
|
-
if (e.phone && !
|
|
4556
|
+
if (e.phone && !fa(e.phone)) {
|
|
4552
4557
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4553
4558
|
operation: "passwordless.start",
|
|
4554
4559
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4564,7 +4569,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4564
4569
|
...e,
|
|
4565
4570
|
scopes: n,
|
|
4566
4571
|
...a ? { code_challenge: a.challenge } : {}
|
|
4567
|
-
}, r, i, ...
|
|
4572
|
+
}, r, i, ...ga(t));
|
|
4568
4573
|
return a && o.challenge_id ? this.rememberPendingPasswordless({
|
|
4569
4574
|
challengeId: o.challenge_id,
|
|
4570
4575
|
verifier: a.verifier,
|
|
@@ -4588,11 +4593,11 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4588
4593
|
this.subscribeStore.notify(W.SignInStart, {}), e.scopes = e.scopes ?? this.scopes, e.device = this.deviceService.getDeviceId();
|
|
4589
4594
|
let n = this.readPendingPasswordless(), r = n?.challengeId === e.challenge_id ? n : void 0, i = !1;
|
|
4590
4595
|
try {
|
|
4591
|
-
let n = await this.authApi.passwordlessSignInComplete(e, ...
|
|
4596
|
+
let n = await this.authApi.passwordlessSignInComplete(e, ...ga(t));
|
|
4592
4597
|
if (i = !0, this.handlePendingSecondFactor(n, r?.email, r && { verifier: r.verifier }, r?.scopes)) return this.forgetPendingPasswordless(), n;
|
|
4593
4598
|
let a = n;
|
|
4594
4599
|
if (n.code) {
|
|
4595
|
-
if (!r) throw Error(
|
|
4600
|
+
if (!r) throw Error(Da);
|
|
4596
4601
|
if (a = await this.authApi.pkceExchange(n.code, r.verifier), this.handlePendingSecondFactor(a)) return this.forgetPendingPasswordless(), {
|
|
4597
4602
|
...a,
|
|
4598
4603
|
redirect_url: n.redirect_url ?? ""
|
|
@@ -4624,11 +4629,11 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4624
4629
|
let n = t?.signal;
|
|
4625
4630
|
try {
|
|
4626
4631
|
let t = this.readPendingPasswordless();
|
|
4627
|
-
if (t?.challengeId !== e) throw Error(
|
|
4632
|
+
if (t?.challengeId !== e) throw Error(Da);
|
|
4628
4633
|
for (;;) {
|
|
4629
4634
|
if (n?.aborted) throw n.reason;
|
|
4630
4635
|
if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
|
|
4631
|
-
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(
|
|
4636
|
+
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(Da);
|
|
4632
4637
|
let r;
|
|
4633
4638
|
try {
|
|
4634
4639
|
r = await this.authApi.passwordlessStatus({
|
|
@@ -4646,7 +4651,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4646
4651
|
status: "signed-in",
|
|
4647
4652
|
tokens: { redirect_url: r.redirect_url }
|
|
4648
4653
|
};
|
|
4649
|
-
await
|
|
4654
|
+
await Oa(ba, n);
|
|
4650
4655
|
}
|
|
4651
4656
|
} catch (e) {
|
|
4652
4657
|
if (n?.aborted && e === n.reason) throw e;
|
|
@@ -4715,14 +4720,14 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4715
4720
|
let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
|
|
4716
4721
|
try {
|
|
4717
4722
|
let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
|
|
4718
|
-
if (t?.pkce && !r) throw Error(
|
|
4723
|
+
if (t?.pkce && !r) throw Error(Da);
|
|
4719
4724
|
let i = await this.authApi.validateEmailCode(e);
|
|
4720
4725
|
this.emailChallenges.delete(e.challenge_id);
|
|
4721
4726
|
let a = r?.scopes ?? t?.scopes ?? this.scopes;
|
|
4722
4727
|
if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
|
|
4723
4728
|
let o = i;
|
|
4724
4729
|
if (i.code) {
|
|
4725
|
-
if (!r) throw Error(
|
|
4730
|
+
if (!r) throw Error(Da);
|
|
4726
4731
|
if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
|
|
4727
4732
|
}
|
|
4728
4733
|
let s = i.redirect_url ? {
|
|
@@ -4784,13 +4789,13 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4784
4789
|
readSessionPin() {
|
|
4785
4790
|
try {
|
|
4786
4791
|
let e = this.storageManager.getToken(M.access_token);
|
|
4787
|
-
return e ?
|
|
4792
|
+
return e ? sa(j(e)) : void 0;
|
|
4788
4793
|
} catch {
|
|
4789
4794
|
return;
|
|
4790
4795
|
}
|
|
4791
4796
|
}
|
|
4792
4797
|
assertSessionPin(e) {
|
|
4793
|
-
if (e && !
|
|
4798
|
+
if (e && !ca(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 oa("The session changed during verification, so the elevated tokens were discarded");
|
|
4794
4799
|
}
|
|
4795
4800
|
refreshMode() {
|
|
4796
4801
|
return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
|
|
@@ -4838,7 +4843,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4838
4843
|
case "signout":
|
|
4839
4844
|
n.notify(W.SignOut, t);
|
|
4840
4845
|
return;
|
|
4841
|
-
default:
|
|
4846
|
+
default: ai().warn(`[passflow] Unknown refresh event: ${String(e)}`);
|
|
4842
4847
|
}
|
|
4843
4848
|
};
|
|
4844
4849
|
}
|
|
@@ -4911,7 +4916,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4911
4916
|
}
|
|
4912
4917
|
async sendPasswordResetEmail(e, t) {
|
|
4913
4918
|
try {
|
|
4914
|
-
return await this.authApi.sendPasswordResetEmail(e, ...
|
|
4919
|
+
return await this.authApi.sendPasswordResetEmail(e, ...ga(t));
|
|
4915
4920
|
} catch (e) {
|
|
4916
4921
|
let t = {
|
|
4917
4922
|
operation: "password-reset.send",
|
|
@@ -4924,10 +4929,10 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4924
4929
|
}
|
|
4925
4930
|
async resetPassword(e, t, n) {
|
|
4926
4931
|
this.subscribeStore.notify(W.SignInStart, {});
|
|
4927
|
-
let r = n ??
|
|
4932
|
+
let r = n ?? ka(this.platform.getCurrentUrl()), i = t ?? this.scopes;
|
|
4928
4933
|
try {
|
|
4929
4934
|
let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
|
|
4930
|
-
if (this.handleEmailVerificationStep(n, "reset-password",
|
|
4935
|
+
if (this.handleEmailVerificationStep(n, "reset-password", Aa(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
|
|
4931
4936
|
let a = await this.exchangeCode(n, t);
|
|
4932
4937
|
if (this.handlePendingSecondFactor(a)) return a;
|
|
4933
4938
|
let o = n.redirect_url ? {
|
|
@@ -4957,11 +4962,11 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4957
4962
|
let i = await this.startPkce(), { challenge_id: a, publicKey: o } = await this.authApi.passkeyRegisterStart(i ? {
|
|
4958
4963
|
...e,
|
|
4959
4964
|
code_challenge: i.challenge
|
|
4960
|
-
} : e, n, r, !this.appId, ...
|
|
4965
|
+
} : e, n, r, !this.appId, ...ga(t));
|
|
4961
4966
|
o.user.id = this.platform.btoa(o.user.id);
|
|
4962
4967
|
let s = await this.platform.passkeys.startRegistration(o);
|
|
4963
4968
|
if (!s) throw Error("Passkey registration was not completed");
|
|
4964
|
-
let c = await this.authApi.passkeyRegisterComplete(s, n, a, !this.appId, ...
|
|
4969
|
+
let c = await this.authApi.passkeyRegisterComplete(s, n, a, !this.appId, ...ga(t));
|
|
4965
4970
|
if (this.handlePendingSecondFactor(c, void 0, i, e.scopes)) return c;
|
|
4966
4971
|
let l = await this.exchangeCode(c, i);
|
|
4967
4972
|
return this.handlePendingSecondFactor(l) || (await this.processAuthResponse(l, e.scopes), this.notifyRegisteredAndSignedIn(l), await this.submitSessionCheck()), l;
|
|
@@ -4984,9 +4989,9 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4984
4989
|
let i = await this.startPkce(), { challenge_id: a, publicKey: o } = await this.authApi.passkeyAuthenticateStart(i ? {
|
|
4985
4990
|
...e,
|
|
4986
4991
|
code_challenge: i.challenge
|
|
4987
|
-
} : e, n, r, !this.appId, ...
|
|
4992
|
+
} : e, n, r, !this.appId, ...ga(t)), s = await this.platform.passkeys.startAuthentication(o);
|
|
4988
4993
|
if (!s) throw Error("Passkey authentication was not completed");
|
|
4989
|
-
let c = await this.authApi.passkeyAuthenticateComplete(s, n, a, !this.appId, ...
|
|
4994
|
+
let c = await this.authApi.passkeyAuthenticateComplete(s, n, a, !this.appId, ...ga(t));
|
|
4990
4995
|
if (this.handlePendingSecondFactor(c, void 0, i, e.scopes)) return c;
|
|
4991
4996
|
let l = await this.exchangeCode(c, i);
|
|
4992
4997
|
return this.handlePendingSecondFactor(l) || "access_token" in l && (await this.processAuthResponse(l, e.scopes), this.subscribeStore.notify(W.SignIn, {
|
|
@@ -5025,7 +5030,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5025
5030
|
};
|
|
5026
5031
|
}
|
|
5027
5032
|
createFederatedAuthUrl(e) {
|
|
5028
|
-
if (!this.appId) throw Error(
|
|
5033
|
+
if (!this.appId) throw Error(Ca);
|
|
5029
5034
|
let t = new URL(`/auth/federated/start/${e.provider}`, this.url);
|
|
5030
5035
|
return t.search = new URLSearchParams(this.federatedStartQuery(e, e.scopes ?? this.scopes, this.appId)).toString(), t.toString();
|
|
5031
5036
|
}
|
|
@@ -5044,10 +5049,10 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5044
5049
|
};
|
|
5045
5050
|
}
|
|
5046
5051
|
createEnterpriseAuthUrl(e) {
|
|
5047
|
-
if (!this.appId) throw Error(
|
|
5052
|
+
if (!this.appId) throw Error(Ca);
|
|
5048
5053
|
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId(), r = new URL(R.enterpriseStart, this.url);
|
|
5049
5054
|
return r.search = new URLSearchParams({
|
|
5050
|
-
...
|
|
5055
|
+
...Ta(e),
|
|
5051
5056
|
...this.federatedStartQuery({
|
|
5052
5057
|
...e,
|
|
5053
5058
|
device: n
|
|
@@ -5056,8 +5061,8 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5056
5061
|
}
|
|
5057
5062
|
async enterpriseStart(e, t) {
|
|
5058
5063
|
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
|
|
5059
|
-
return { auth_url:
|
|
5060
|
-
...
|
|
5064
|
+
return { auth_url: wa((await this.authApi.enterpriseStart({
|
|
5065
|
+
...Ta(e),
|
|
5061
5066
|
...this.federatedStartBody({
|
|
5062
5067
|
...e,
|
|
5063
5068
|
device: r
|
|
@@ -5065,7 +5070,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5065
5070
|
}, t)).auth_url) };
|
|
5066
5071
|
}
|
|
5067
5072
|
async federatedAuthWithPopup(e, t) {
|
|
5068
|
-
if (this.subscribeStore.notify(W.SignInStart, { provider: e.provider }), !this.appId) throw Error(
|
|
5073
|
+
if (this.subscribeStore.notify(W.SignInStart, { provider: e.provider }), !this.appId) throw Error(Ca);
|
|
5069
5074
|
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
|
|
5070
5075
|
try {
|
|
5071
5076
|
this.forgetFederatedSlot();
|
|
@@ -5083,7 +5088,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5083
5088
|
} : {}
|
|
5084
5089
|
};
|
|
5085
5090
|
return {
|
|
5086
|
-
url: await this.usesFederatedPost(t) ?
|
|
5091
|
+
url: await this.usesFederatedPost(t) ? wa((await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url) : this.createFederatedAuthUrl(a),
|
|
5087
5092
|
pkce: i
|
|
5088
5093
|
};
|
|
5089
5094
|
})(), o, s = (e) => {
|
|
@@ -5105,11 +5110,11 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5105
5110
|
scopes: n
|
|
5106
5111
|
};
|
|
5107
5112
|
if (o) {
|
|
5108
|
-
if (!f) throw
|
|
5113
|
+
if (!f) throw Yn();
|
|
5109
5114
|
if (_ = await this.authApi.pkceExchange(f, o.verifier), this.handlePendingSecondFactor(_)) return;
|
|
5110
5115
|
} else {
|
|
5111
|
-
if (!await this.isSimpleModeApp()) throw
|
|
5112
|
-
await
|
|
5116
|
+
if (!await this.isSimpleModeApp()) throw Yn();
|
|
5117
|
+
await Vi(this.url, this.appId, _);
|
|
5113
5118
|
}
|
|
5114
5119
|
await this.processAuthResponse(_, n), this.subscribeStore.notify(W.SignIn, {
|
|
5115
5120
|
tokens: _,
|
|
@@ -5135,7 +5140,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5135
5140
|
}
|
|
5136
5141
|
}
|
|
5137
5142
|
federatedAuthWithRedirect(e, t) {
|
|
5138
|
-
if (this.subscribeStore.notify(W.SignInStart, { provider: e.provider }), !this.appId) throw Error(
|
|
5143
|
+
if (this.subscribeStore.notify(W.SignInStart, { provider: e.provider }), !this.appId) throw Error(Ca);
|
|
5139
5144
|
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
|
|
5140
5145
|
this.startPkce().then(async (i) => {
|
|
5141
5146
|
let a = {
|
|
@@ -5146,7 +5151,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5146
5151
|
code_challenge: i.challenge,
|
|
5147
5152
|
code_challenge_method: "S256"
|
|
5148
5153
|
} : {}
|
|
5149
|
-
}, o = await this.usesFederatedPost(t) ?
|
|
5154
|
+
}, o = await this.usesFederatedPost(t) ? wa((await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url) : this.createFederatedAuthUrl(a);
|
|
5150
5155
|
i ? this.rememberFederatedSlot(i.verifier, n) : this.forgetFederatedSlot(), this.platform.navigateTo(o);
|
|
5151
5156
|
}).catch((e) => this.reportFederatedRedirectFailure(e));
|
|
5152
5157
|
}
|
|
@@ -5199,7 +5204,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5199
5204
|
async authRedirect(e = {}) {
|
|
5200
5205
|
try {
|
|
5201
5206
|
let { url: t, appId: n, redirectUrl: r, scopes: i, state: a } = e;
|
|
5202
|
-
if (t !== void 0 &&
|
|
5207
|
+
if (t !== void 0 && Qn(t) !== Qn(this.url) || n !== void 0 && n !== (this.appId ?? "")) throw new H("OVERRIDE_NOT_SUPPORTED", "authRedirect() signs in to this instance's url and appId; create a Passflow instance for another server or app");
|
|
5203
5208
|
let o = await this.readAppSettings?.();
|
|
5204
5209
|
if (o?.pkce_enabled !== !0) {
|
|
5205
5210
|
let e = this.authRedirectUrl({
|
|
@@ -5209,8 +5214,8 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5209
5214
|
this.platform.navigateTo(a ? `${e}&${new URLSearchParams({ state: a })}` : e);
|
|
5210
5215
|
return;
|
|
5211
5216
|
}
|
|
5212
|
-
if (o.public_client === !1) throw new H("CONFIDENTIAL_CLIENT",
|
|
5213
|
-
let s = this.platform.getCurrentUrl(), c = await
|
|
5217
|
+
if (o.public_client === !1) throw new H("CONFIDENTIAL_CLIENT", qn(o.type));
|
|
5218
|
+
let s = this.platform.getCurrentUrl(), c = await er({
|
|
5214
5219
|
url: this.url,
|
|
5215
5220
|
clientId: this.appId ?? "",
|
|
5216
5221
|
redirectUri: r ?? (s ? s.origin + s.pathname : ""),
|
|
@@ -5231,9 +5236,9 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5231
5236
|
if (!this.appId) return !1;
|
|
5232
5237
|
let t = new URLSearchParams(e.search), n = t.get("code"), r = t.get("state"), i = t.get("error"), a = t.get("error_description");
|
|
5233
5238
|
if (t.get("user_state") || r === null || !n && !i) return !1;
|
|
5234
|
-
let o =
|
|
5239
|
+
let o = nr();
|
|
5235
5240
|
if (o.status === "none") return !1;
|
|
5236
|
-
|
|
5241
|
+
rr();
|
|
5237
5242
|
for (let e of [
|
|
5238
5243
|
"code",
|
|
5239
5244
|
"state",
|
|
@@ -5245,9 +5250,9 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5245
5250
|
return this.platform.replaceUrl(e.pathname + (s ? `?${s}` : "") + e.hash), this.finishOidcLanding(async () => {
|
|
5246
5251
|
if (o.status === "unusable") throw new H("VERIFIER_MISSING", "This sign-in has expired or its proof key is gone. Sign in again.");
|
|
5247
5252
|
if (o.slot.state !== r) throw new H("STATE_MISMATCH", "The sign-in answer does not belong to this sign-in. Sign in again.");
|
|
5248
|
-
if (i || !n) throw new H(i ?? "TOKEN_EXCHANGE_FAILED",
|
|
5253
|
+
if (i || !n) throw new H(i ?? "TOKEN_EXCHANGE_FAILED", ua(a || i || "Sign in again."));
|
|
5249
5254
|
return {
|
|
5250
|
-
tokens: await
|
|
5255
|
+
tokens: await ar(this.url, n, o.slot),
|
|
5251
5256
|
scopes: o.slot.scopes,
|
|
5252
5257
|
returnUrl: o.slot.redirectUri
|
|
5253
5258
|
};
|
|
@@ -5336,7 +5341,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5336
5341
|
return;
|
|
5337
5342
|
}
|
|
5338
5343
|
}
|
|
5339
|
-
},
|
|
5344
|
+
}, Ma = class {
|
|
5340
5345
|
constructor(e) {
|
|
5341
5346
|
this.invitationApi = e;
|
|
5342
5347
|
}
|
|
@@ -5355,7 +5360,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5355
5360
|
getInvitationLink(e) {
|
|
5356
5361
|
return this.invitationApi.getInvitationLink(e);
|
|
5357
5362
|
}
|
|
5358
|
-
},
|
|
5363
|
+
}, Na = class {
|
|
5359
5364
|
constructor(e) {
|
|
5360
5365
|
this.data = this.normalize(e);
|
|
5361
5366
|
}
|
|
@@ -5412,9 +5417,9 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5412
5417
|
getData() {
|
|
5413
5418
|
return this.data;
|
|
5414
5419
|
}
|
|
5415
|
-
},
|
|
5420
|
+
}, Pa = class {
|
|
5416
5421
|
constructor(e, t, n) {
|
|
5417
|
-
this.tenantApi = e, this.scopes = t, this.logger = n ||
|
|
5422
|
+
this.tenantApi = e, this.scopes = t, this.logger = n || ai();
|
|
5418
5423
|
}
|
|
5419
5424
|
handlePassflowError(t, n) {
|
|
5420
5425
|
if (e.isAxiosError(t) && t.response?.data) {
|
|
@@ -5450,7 +5455,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5450
5455
|
}
|
|
5451
5456
|
async getTenantUserMembership(e) {
|
|
5452
5457
|
try {
|
|
5453
|
-
return new
|
|
5458
|
+
return new Na(await this.tenantApi.getTenantDetails(e));
|
|
5454
5459
|
} catch (t) {
|
|
5455
5460
|
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
5456
5461
|
}
|
|
@@ -5595,7 +5600,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5595
5600
|
this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
|
|
5596
5601
|
}
|
|
5597
5602
|
}
|
|
5598
|
-
},
|
|
5603
|
+
}, Fa = class {
|
|
5599
5604
|
constructor(e, t, n, r = me) {
|
|
5600
5605
|
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();
|
|
5601
5606
|
}
|
|
@@ -5675,7 +5680,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5675
5680
|
isExpired() {
|
|
5676
5681
|
return this.tokensCache ? this.tokensCache.access_token ? A(j(this.tokensCache.access_token)) : !1 : !0;
|
|
5677
5682
|
}
|
|
5678
|
-
},
|
|
5683
|
+
}, Ia = class {
|
|
5679
5684
|
constructor(e, t, n) {
|
|
5680
5685
|
this.twoFactorApi = e, this.subscribeStore = t, this.signInCompleter = n, this.PARTIAL_AUTH_TIMEOUT_MS = 3e5, this.SESSION_STORAGE_KEY = "passflow_2fa_challenge", this.subscribeStore.subscribe({ onAuthChange: (e, t) => {
|
|
5681
5686
|
if (e === W.TwoFactorRequired) {
|
|
@@ -5755,8 +5760,8 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5755
5760
|
assertTotpCode(e) {
|
|
5756
5761
|
let t = this.totpDigits;
|
|
5757
5762
|
if (t) {
|
|
5758
|
-
if (!
|
|
5759
|
-
} else if (!
|
|
5763
|
+
if (!ma(e, t)) throw Error(`Invalid TOTP code format. Code must be exactly ${t} digits.`);
|
|
5764
|
+
} else if (!ma(e, 6) && !ma(e, 8)) throw Error("Invalid TOTP code format. Code must be 6 or 8 digits.");
|
|
5760
5765
|
}
|
|
5761
5766
|
requirePendingTfaToken() {
|
|
5762
5767
|
let e = this.pendingTfaToken();
|
|
@@ -5794,7 +5799,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5794
5799
|
}
|
|
5795
5800
|
async useRecoveryCode(e, t) {
|
|
5796
5801
|
try {
|
|
5797
|
-
let n =
|
|
5802
|
+
let n = ha(e);
|
|
5798
5803
|
if (!n) throw Error("Invalid recovery code format. Expected letters, digits and dashes, such as XXXX-XXXX-XXXX.");
|
|
5799
5804
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
5800
5805
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
@@ -6043,7 +6048,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6043
6048
|
this.emitErrorAndThrow(e, "2fa.preferred-method.clear", "Clear preferred 2FA method");
|
|
6044
6049
|
}
|
|
6045
6050
|
}
|
|
6046
|
-
},
|
|
6051
|
+
}, La = class {
|
|
6047
6052
|
constructor(e, t, n = me) {
|
|
6048
6053
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
6049
6054
|
}
|
|
@@ -6085,77 +6090,77 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6085
6090
|
updateProfile(e, t) {
|
|
6086
6091
|
return this.userAPI.updateProfile(e, t);
|
|
6087
6092
|
}
|
|
6088
|
-
},
|
|
6093
|
+
}, Ra = class extends Error {
|
|
6089
6094
|
constructor(e, t, n = !1) {
|
|
6090
6095
|
super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
|
|
6091
6096
|
}
|
|
6092
|
-
},
|
|
6097
|
+
}, za = (e, t) => {
|
|
6093
6098
|
let n = t?.trim();
|
|
6094
|
-
if (!n) throw new
|
|
6099
|
+
if (!n) throw new Ra(e, "A verification code is required");
|
|
6095
6100
|
return n;
|
|
6096
|
-
},
|
|
6101
|
+
}, Ba = {
|
|
6097
6102
|
type: "totp",
|
|
6098
6103
|
requiresPrepare: !1,
|
|
6099
6104
|
input: "code",
|
|
6100
|
-
assert: async ({ code: e }) => ({ code:
|
|
6101
|
-
},
|
|
6105
|
+
assert: async ({ code: e }) => ({ code: za("totp", e) })
|
|
6106
|
+
}, Va = {
|
|
6102
6107
|
type: "recovery_codes",
|
|
6103
6108
|
requiresPrepare: !1,
|
|
6104
6109
|
input: "code",
|
|
6105
|
-
assert: async ({ code: e }) => ({ code:
|
|
6106
|
-
},
|
|
6110
|
+
assert: async ({ code: e }) => ({ code: za("recovery_codes", e) })
|
|
6111
|
+
}, Ha = {
|
|
6107
6112
|
type: "passkey",
|
|
6108
6113
|
requiresPrepare: !0,
|
|
6109
6114
|
input: "none",
|
|
6110
6115
|
assert: async ({ prepared: e, platform: t }) => {
|
|
6111
|
-
if (!e?.webauthn) throw new
|
|
6116
|
+
if (!e?.webauthn) throw new Ra("passkey", "The upgrade challenge carried no WebAuthn options");
|
|
6112
6117
|
let n = t.passkeys;
|
|
6113
|
-
if (!n) throw new
|
|
6118
|
+
if (!n) throw new Ra("passkey", "This platform does not support passkeys");
|
|
6114
6119
|
let r;
|
|
6115
6120
|
try {
|
|
6116
6121
|
r = await n.startAuthentication(e.webauthn);
|
|
6117
6122
|
} catch (e) {
|
|
6118
|
-
throw new
|
|
6123
|
+
throw new Ra("passkey", e?.message || "Passkey verification was cancelled", !0);
|
|
6119
6124
|
}
|
|
6120
|
-
if (!r) throw new
|
|
6125
|
+
if (!r) throw new Ra("passkey", "Passkey verification was cancelled", !0);
|
|
6121
6126
|
return {
|
|
6122
6127
|
challenge_id: e.challengeId,
|
|
6123
6128
|
credential: r
|
|
6124
6129
|
};
|
|
6125
6130
|
}
|
|
6126
|
-
},
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
]),
|
|
6131
|
+
}, Ua = Object.freeze([
|
|
6132
|
+
Ba,
|
|
6133
|
+
Ha,
|
|
6134
|
+
Va
|
|
6135
|
+
]), Wa = (e = Ua) => new Map(e.map((e) => [e.type, e])), Ga = 3, Ka = {
|
|
6131
6136
|
totp: 0,
|
|
6132
6137
|
passkey: 1,
|
|
6133
6138
|
email_otp: 2,
|
|
6134
6139
|
sms_otp: 3,
|
|
6135
6140
|
recovery_codes: 9
|
|
6136
|
-
},
|
|
6137
|
-
let n =
|
|
6141
|
+
}, qa = (e) => e.requiredLevel ?? ye(e.acrValues), Ja = (e, t) => {
|
|
6142
|
+
let n = Ka[e.type] ?? 5, r = t !== void 0 && t >= Ga, i = e.type === "passkey";
|
|
6138
6143
|
return (r && !i ? 100 : 0) + n;
|
|
6139
|
-
},
|
|
6144
|
+
}, Ya = (e, t) => {
|
|
6140
6145
|
if (t.availableFactors) return t.availableFactors.flatMap((t) => e.find((e) => e.type === t) ?? []);
|
|
6141
|
-
let n =
|
|
6142
|
-
return [...e].sort((e, t) =>
|
|
6143
|
-
},
|
|
6146
|
+
let n = qa(t);
|
|
6147
|
+
return [...e].sort((e, t) => Ja(e, n) - Ja(t, n));
|
|
6148
|
+
}, Xa = class extends Error {
|
|
6144
6149
|
constructor(e) {
|
|
6145
6150
|
super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
|
|
6146
6151
|
}
|
|
6147
|
-
},
|
|
6152
|
+
}, Za = class extends Error {
|
|
6148
6153
|
constructor(e = "Only a fresh sign-in can meet this challenge") {
|
|
6149
6154
|
super(e), this.code = "upgrade_sign_in_required", this.name = "UpgradeSignInRequiredError";
|
|
6150
6155
|
}
|
|
6151
|
-
},
|
|
6152
|
-
if (
|
|
6153
|
-
if (
|
|
6154
|
-
},
|
|
6156
|
+
}, Qa = (e) => e?.signInRequired === !0 || e?.signInRequired === void 0 && e?.availableFactors?.length === 0, $a = (e) => e?.signInRequired === !1 && e.availableFactors?.length === 0, eo = "This account has no factor that reaches the required level (it may need a device-bound passkey)", to = (e) => {
|
|
6157
|
+
if (Qa(e)) return new Za();
|
|
6158
|
+
if ($a(e)) return new no(eo);
|
|
6159
|
+
}, no = class extends Error {
|
|
6155
6160
|
constructor(e = "No available authentication factor can satisfy this challenge") {
|
|
6156
6161
|
super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
|
|
6157
6162
|
}
|
|
6158
|
-
},
|
|
6163
|
+
}, ro = 4, io = 3e4, ao = () => {
|
|
6159
6164
|
let e = () => void 0, t = () => void 0;
|
|
6160
6165
|
return {
|
|
6161
6166
|
promise: new Promise((n, r) => {
|
|
@@ -6164,12 +6169,12 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6164
6169
|
resolve: e,
|
|
6165
6170
|
reject: t
|
|
6166
6171
|
};
|
|
6167
|
-
},
|
|
6172
|
+
}, oo = (e) => ({
|
|
6168
6173
|
acrValues: e.acrValues,
|
|
6169
6174
|
level: e.requiredLevel,
|
|
6170
6175
|
maxAge: e.maxAge
|
|
6171
|
-
}),
|
|
6172
|
-
let n = e.requiredLevel === void 0 ? t.requiredLevel : t.requiredLevel === void 0 ? e.requiredLevel : Math.max(e.requiredLevel, t.requiredLevel), r = n === void 0 ? e.acrValues ?? t.acrValues : n === e.requiredLevel ? e.acrValues : t.acrValues, i = e.maxAge === void 0 ? t.maxAge : t.maxAge === void 0 ? e.maxAge : Math.min(e.maxAge, t.maxAge), a = Array.from(/* @__PURE__ */ new Set([...e.channels ?? [], ...t.channels ?? []])), { availableFactors: o, signInRequired: s } =
|
|
6176
|
+
}), so = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, co = (e, t) => {
|
|
6177
|
+
let n = e.requiredLevel === void 0 ? t.requiredLevel : t.requiredLevel === void 0 ? e.requiredLevel : Math.max(e.requiredLevel, t.requiredLevel), r = n === void 0 ? e.acrValues ?? t.acrValues : n === e.requiredLevel ? e.acrValues : t.acrValues, i = e.maxAge === void 0 ? t.maxAge : t.maxAge === void 0 ? e.maxAge : Math.min(e.maxAge, t.maxAge), a = Array.from(/* @__PURE__ */ new Set([...e.channels ?? [], ...t.channels ?? []])), { availableFactors: o, signInRequired: s } = lo(t, e) && !lo(e, t) || !t.availableFactors ? e : t;
|
|
6173
6178
|
return {
|
|
6174
6179
|
acrValues: r,
|
|
6175
6180
|
requiredLevel: n,
|
|
@@ -6179,12 +6184,12 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6179
6184
|
...o ? { availableFactors: o } : {},
|
|
6180
6185
|
...s === void 0 ? {} : { signInRequired: s }
|
|
6181
6186
|
};
|
|
6182
|
-
},
|
|
6187
|
+
}, lo = (e, t) => {
|
|
6183
6188
|
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);
|
|
6184
6189
|
return n || r;
|
|
6185
|
-
},
|
|
6190
|
+
}, uo = class {
|
|
6186
6191
|
constructor(e) {
|
|
6187
|
-
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 ??
|
|
6192
|
+
this.state = "idle", this.inFlight = null, this.requirement = null, this.selected = null, this.rankedRequirement = null, this.registrations = [], this.proof = null, this.pruned = /* @__PURE__ */ new Set(), this.openPrompt = null, this.transport = e.transport, this.prompt = e.prompt, this.platform = e.platform, this.available = e.factors ?? Ua, this.registry = Wa(this.available), this.maxAttempts = e.maxAttempts ?? ro, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? io;
|
|
6188
6193
|
}
|
|
6189
6194
|
get currentState() {
|
|
6190
6195
|
return this.state;
|
|
@@ -6204,9 +6209,9 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6204
6209
|
}
|
|
6205
6210
|
register(e, t) {
|
|
6206
6211
|
let n = t.kind === "imperative" && t.requested !== void 0, r = {
|
|
6207
|
-
demanded: t.kind === "imperative" && t.requested ? t.requested :
|
|
6212
|
+
demanded: t.kind === "imperative" && t.requested ? t.requested : oo(e),
|
|
6208
6213
|
statedBar: n,
|
|
6209
|
-
settlement:
|
|
6214
|
+
settlement: ao(),
|
|
6210
6215
|
reported: !1,
|
|
6211
6216
|
entry: {
|
|
6212
6217
|
...t,
|
|
@@ -6222,15 +6227,15 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6222
6227
|
this.requirement = e;
|
|
6223
6228
|
return;
|
|
6224
6229
|
}
|
|
6225
|
-
let n =
|
|
6226
|
-
this.requirement =
|
|
6230
|
+
let n = lo(t, e);
|
|
6231
|
+
this.requirement = co(t, e), to(this.requirement) ? this.state === "collecting" && this.selected === null && (this.openPrompt?.onClosed?.(), this.closeOpenPrompt?.()) : n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
|
|
6227
6232
|
challenge: this.requirement,
|
|
6228
6233
|
factors: this.offeredFactors()
|
|
6229
6234
|
});
|
|
6230
6235
|
}
|
|
6231
6236
|
offeredFactors() {
|
|
6232
6237
|
let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
|
|
6233
|
-
return t ?
|
|
6238
|
+
return t ? Ya(e, t) : e;
|
|
6234
6239
|
}
|
|
6235
6240
|
receiveReport(e, t) {
|
|
6236
6241
|
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());
|
|
@@ -6265,12 +6270,12 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6265
6270
|
}
|
|
6266
6271
|
release(e, t) {
|
|
6267
6272
|
if (e.entry.kind === "imperative") {
|
|
6268
|
-
if (e.statedBar && !
|
|
6273
|
+
if (e.statedBar && !so(t, e.demanded)) {
|
|
6269
6274
|
this.receiveReport(e, {
|
|
6270
6275
|
outcome: "insufficient",
|
|
6271
6276
|
obtained: t,
|
|
6272
6277
|
required: e.demanded
|
|
6273
|
-
}), e.settlement.reject(new
|
|
6278
|
+
}), e.settlement.reject(new ia(t, e.demanded));
|
|
6274
6279
|
return;
|
|
6275
6280
|
}
|
|
6276
6281
|
this.receiveReport(e, {
|
|
@@ -6340,7 +6345,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6340
6345
|
async prove() {
|
|
6341
6346
|
let e;
|
|
6342
6347
|
for (let t = 0; t < this.maxAttempts; t++) {
|
|
6343
|
-
let t =
|
|
6348
|
+
let t = to(this.requirement);
|
|
6344
6349
|
if (t) return {
|
|
6345
6350
|
status: "failed",
|
|
6346
6351
|
reason: t
|
|
@@ -6348,7 +6353,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6348
6353
|
let n = this.offeredFactors();
|
|
6349
6354
|
if (n.length === 0) return {
|
|
6350
6355
|
status: "failed",
|
|
6351
|
-
reason: new
|
|
6356
|
+
reason: new no()
|
|
6352
6357
|
};
|
|
6353
6358
|
let r = this.requirement, i;
|
|
6354
6359
|
try {
|
|
@@ -6356,29 +6361,29 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6356
6361
|
} catch (e) {
|
|
6357
6362
|
return {
|
|
6358
6363
|
status: "failed",
|
|
6359
|
-
reason: new
|
|
6364
|
+
reason: new Xa(e)
|
|
6360
6365
|
};
|
|
6361
6366
|
}
|
|
6362
|
-
let a =
|
|
6367
|
+
let a = to(this.requirement);
|
|
6363
6368
|
if (a) return {
|
|
6364
6369
|
status: "failed",
|
|
6365
6370
|
reason: a
|
|
6366
6371
|
};
|
|
6367
6372
|
if (i.type === "cancel") return {
|
|
6368
6373
|
status: "failed",
|
|
6369
|
-
reason: new
|
|
6374
|
+
reason: new Xa()
|
|
6370
6375
|
};
|
|
6371
6376
|
let o = this.registry.get(i.factor);
|
|
6372
|
-
if (!o) e = new
|
|
6377
|
+
if (!o) e = new no(`Unknown authentication factor: ${i.factor}`), this.state = "collecting", this.selected = null;
|
|
6373
6378
|
else try {
|
|
6374
6379
|
return await this.proveAndCommit(o, i.code), {
|
|
6375
6380
|
status: "proven",
|
|
6376
|
-
obtained: this.readObtainedBar?.() ??
|
|
6381
|
+
obtained: this.readObtainedBar?.() ?? oo(this.rankedRequirement ?? r)
|
|
6377
6382
|
};
|
|
6378
6383
|
} catch (t) {
|
|
6379
|
-
if (t instanceof
|
|
6384
|
+
if (t instanceof Ra && t.cancelled) return {
|
|
6380
6385
|
status: "failed",
|
|
6381
|
-
reason: new
|
|
6386
|
+
reason: new Xa()
|
|
6382
6387
|
};
|
|
6383
6388
|
let n = this.classifyProofFailure(t);
|
|
6384
6389
|
if (n) return {
|
|
@@ -6414,16 +6419,16 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6414
6419
|
});
|
|
6415
6420
|
}
|
|
6416
6421
|
classifyProofFailure(e) {
|
|
6417
|
-
if (e instanceof
|
|
6422
|
+
if (e instanceof ia || e instanceof aa || e instanceof oa) return e;
|
|
6418
6423
|
if (e instanceof $) switch (e.kind) {
|
|
6419
|
-
case "unavailable": return new
|
|
6424
|
+
case "unavailable": return new aa(e.message);
|
|
6420
6425
|
case "exhausted":
|
|
6421
6426
|
case "attempts_exhausted":
|
|
6422
6427
|
case "rate_limited":
|
|
6423
6428
|
case "fatal":
|
|
6424
6429
|
case "protocol":
|
|
6425
6430
|
case "network": return e;
|
|
6426
|
-
case "session_changed": return new
|
|
6431
|
+
case "session_changed": return new oa(e.message);
|
|
6427
6432
|
default: return;
|
|
6428
6433
|
}
|
|
6429
6434
|
}
|
|
@@ -6435,28 +6440,28 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6435
6440
|
});
|
|
6436
6441
|
await this.transport.commit(e.type, r);
|
|
6437
6442
|
}
|
|
6438
|
-
},
|
|
6443
|
+
}, fo = (e) => typeof e == "function" ? e() : e, po = (e) => {
|
|
6439
6444
|
try {
|
|
6440
6445
|
return new URL(e);
|
|
6441
6446
|
} catch {
|
|
6442
6447
|
return;
|
|
6443
6448
|
}
|
|
6444
|
-
},
|
|
6449
|
+
}, mo = (e, t) => {
|
|
6445
6450
|
if (!t || t === "/") return !0;
|
|
6446
6451
|
let n = t.replace(/\/+$/, "");
|
|
6447
6452
|
return e === n || e.startsWith(`${n}/`);
|
|
6448
|
-
},
|
|
6453
|
+
}, ho = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && mo(e.pathname, t.pathPrefix), go = (e, t) => {
|
|
6449
6454
|
for (let n of t) {
|
|
6450
6455
|
if (n === "") continue;
|
|
6451
6456
|
if (n.startsWith("/")) {
|
|
6452
|
-
if (e.relativeToBase &&
|
|
6457
|
+
if (e.relativeToBase && mo(e.pathname, n)) return !0;
|
|
6453
6458
|
continue;
|
|
6454
6459
|
}
|
|
6455
|
-
let t =
|
|
6456
|
-
if (t && e.origin !== void 0 && e.origin === t.origin &&
|
|
6460
|
+
let t = po(n) ?? po(`https://${n}`);
|
|
6461
|
+
if (t && e.origin !== void 0 && e.origin === t.origin && mo(e.pathname, t.pathname)) return !0;
|
|
6457
6462
|
}
|
|
6458
6463
|
return !1;
|
|
6459
|
-
},
|
|
6464
|
+
}, _o = (e, t, n) => ho(e, t.passflow) || go(e, t.backend) ? !n || n(e.href) !== !1 : !1, vo = (e) => {
|
|
6460
6465
|
let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
|
|
6461
6466
|
console.warn(n, {
|
|
6462
6467
|
status: e.status,
|
|
@@ -6464,8 +6469,8 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6464
6469
|
reason: e.reason,
|
|
6465
6470
|
detail: t
|
|
6466
6471
|
});
|
|
6467
|
-
},
|
|
6468
|
-
let n = t.onUpgradeDiagnostic ??
|
|
6472
|
+
}, yo = (e, t) => {
|
|
6473
|
+
let n = t.onUpgradeDiagnostic ?? vo;
|
|
6469
6474
|
return (t, r) => {
|
|
6470
6475
|
n({
|
|
6471
6476
|
status: e.status,
|
|
@@ -6477,8 +6482,8 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6477
6482
|
}
|
|
6478
6483
|
});
|
|
6479
6484
|
};
|
|
6480
|
-
},
|
|
6481
|
-
let r = n.onUpgradeDiagnostic ??
|
|
6485
|
+
}, bo = (e, t, n) => {
|
|
6486
|
+
let r = n.onUpgradeDiagnostic ?? vo;
|
|
6482
6487
|
for (let n of e) r({
|
|
6483
6488
|
...n,
|
|
6484
6489
|
url: t.request.href,
|
|
@@ -6487,8 +6492,8 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6487
6492
|
...n.detail ?? {}
|
|
6488
6493
|
}
|
|
6489
6494
|
});
|
|
6490
|
-
},
|
|
6491
|
-
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n &&
|
|
6495
|
+
}, xo = /\bjson\b/i, So = async (e, t) => {
|
|
6496
|
+
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && xo.test(r), a;
|
|
6492
6497
|
if (i) try {
|
|
6493
6498
|
a = await e.readBody();
|
|
6494
6499
|
} catch {
|
|
@@ -6502,13 +6507,13 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6502
6507
|
status: e.status,
|
|
6503
6508
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
6504
6509
|
}, { requireChallengeChannel: t.requireChallengeChannel });
|
|
6505
|
-
},
|
|
6510
|
+
}, Co = (e) => je({
|
|
6506
6511
|
status: e.status,
|
|
6507
6512
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
6508
|
-
}, { requireChallengeChannel: "header" }).challenge,
|
|
6513
|
+
}, { requireChallengeChannel: "header" }).challenge, wo = (e, t) => t.passflow === null ? `[passflow] a 401/403 from ${e} carried an upgrade challenge, but no Passflow endpoint is configured — set \`url\` on the Passflow config.` : `[passflow] a 401/403 from ${e} carried an upgrade challenge, but that URL is not covered by the provider's \`backend\` prop — add it there to enable step-up for this API.`, To = (e, t) => e instanceof Xa ? { kind: "cancelled" } : e instanceof Za ? { kind: "sign-in-required" } : e instanceof no ? {
|
|
6509
6514
|
kind: "unsatisfiable",
|
|
6510
6515
|
error: e
|
|
6511
|
-
} : e instanceof
|
|
6516
|
+
} : e instanceof aa ? { kind: "unavailable" } : e instanceof oa ? { kind: "session-changed" } : e instanceof ia ? {
|
|
6512
6517
|
kind: "insufficient",
|
|
6513
6518
|
obtained: e.obtained,
|
|
6514
6519
|
required: e.required
|
|
@@ -6524,26 +6529,26 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6524
6529
|
kind: "transport-failure",
|
|
6525
6530
|
retryable: !1,
|
|
6526
6531
|
error: e instanceof Error ? e : Error(String(e))
|
|
6527
|
-
},
|
|
6532
|
+
}, Eo = async (e, t, n, r) => {
|
|
6528
6533
|
if (e.status !== 401 && e.status !== 403) return {
|
|
6529
6534
|
kind: "replayed",
|
|
6530
6535
|
response: e
|
|
6531
6536
|
};
|
|
6532
|
-
let { challenge: i, diagnostics: a } = await
|
|
6533
|
-
if (
|
|
6537
|
+
let { challenge: i, diagnostics: a } = await So(e, t);
|
|
6538
|
+
if (bo(a, e, t), !i) return {
|
|
6534
6539
|
kind: "replayed",
|
|
6535
6540
|
response: e
|
|
6536
6541
|
};
|
|
6537
|
-
if (
|
|
6542
|
+
if (Qa(i)) return {
|
|
6538
6543
|
kind: "sign-in-required",
|
|
6539
6544
|
response: e
|
|
6540
6545
|
};
|
|
6541
|
-
if (
|
|
6546
|
+
if ($a(i)) return {
|
|
6542
6547
|
kind: "unsatisfiable",
|
|
6543
|
-
error:
|
|
6548
|
+
error: to(i),
|
|
6544
6549
|
response: e
|
|
6545
6550
|
};
|
|
6546
|
-
let o =
|
|
6551
|
+
let o = oo(i);
|
|
6547
6552
|
return r("elevated-insufficient", {
|
|
6548
6553
|
obtained: n,
|
|
6549
6554
|
required: o
|
|
@@ -6553,7 +6558,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6553
6558
|
required: o,
|
|
6554
6559
|
response: e
|
|
6555
6560
|
};
|
|
6556
|
-
},
|
|
6561
|
+
}, Do = async (e, t) => {
|
|
6557
6562
|
if (!t) return {
|
|
6558
6563
|
aborted: !1,
|
|
6559
6564
|
value: await e
|
|
@@ -6580,14 +6585,14 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6580
6585
|
} finally {
|
|
6581
6586
|
n && t.removeEventListener?.("abort", n);
|
|
6582
6587
|
}
|
|
6583
|
-
},
|
|
6588
|
+
}, Oo = async (e, t) => {
|
|
6584
6589
|
if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
|
|
6585
|
-
let n =
|
|
6590
|
+
let n = yo(e, t);
|
|
6586
6591
|
if (e.markers.replayed) {
|
|
6587
|
-
if (!
|
|
6588
|
-
let { challenge: r, diagnostics: i } = await
|
|
6589
|
-
if (
|
|
6590
|
-
let a = t.readObtainedBar?.() ?? {}, o =
|
|
6592
|
+
if (!_o(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
|
|
6593
|
+
let { challenge: r, diagnostics: i } = await So(e, t);
|
|
6594
|
+
if (bo(i, e, t), !r) return { kind: "not-a-challenge" };
|
|
6595
|
+
let a = t.readObtainedBar?.() ?? {}, o = oo(r);
|
|
6591
6596
|
return n("elevated-insufficient", {
|
|
6592
6597
|
obtained: a,
|
|
6593
6598
|
required: o
|
|
@@ -6598,12 +6603,12 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6598
6603
|
response: e
|
|
6599
6604
|
};
|
|
6600
6605
|
}
|
|
6601
|
-
if (!
|
|
6606
|
+
if (!_o(e.request, t.scope, t.shouldIntercept)) return Co(e) ? (n("challenge-out-of-scope", {
|
|
6602
6607
|
header: e.getHeader("www-authenticate") ?? void 0,
|
|
6603
|
-
message:
|
|
6608
|
+
message: wo(e.request.href, t.scope)
|
|
6604
6609
|
}), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
|
|
6605
|
-
let { challenge: r, diagnostics: i } = await
|
|
6606
|
-
if (
|
|
6610
|
+
let { challenge: r, diagnostics: i } = await So(e, t);
|
|
6611
|
+
if (bo(i, e, t), !r) {
|
|
6607
6612
|
let r = e.getHeader("www-authenticate");
|
|
6608
6613
|
return t.requireChallengeChannel !== "header" && n("no-channel", {
|
|
6609
6614
|
...r ? { header: r } : {},
|
|
@@ -6617,9 +6622,9 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6617
6622
|
method: e.request.method
|
|
6618
6623
|
}, s, c;
|
|
6619
6624
|
try {
|
|
6620
|
-
s = Promise.resolve(t.elevate(r, o)), c = await
|
|
6625
|
+
s = Promise.resolve(t.elevate(r, o)), c = await Do(s, e.signal);
|
|
6621
6626
|
} catch (e) {
|
|
6622
|
-
return
|
|
6627
|
+
return To(e, void 0);
|
|
6623
6628
|
}
|
|
6624
6629
|
if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
|
|
6625
6630
|
kind: "aborted",
|
|
@@ -6630,7 +6635,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6630
6635
|
kind: "aborted",
|
|
6631
6636
|
reason: e.signal.reason
|
|
6632
6637
|
};
|
|
6633
|
-
let u = l?.obtained ?? t.readObtainedBar?.() ??
|
|
6638
|
+
let u = l?.obtained ?? t.readObtainedBar?.() ?? oo(r), d = t.authorizationSwap?.(), f = d ? {
|
|
6634
6639
|
from: a?.from ?? d.from,
|
|
6635
6640
|
to: d.to
|
|
6636
6641
|
} : void 0;
|
|
@@ -6639,7 +6644,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6639
6644
|
try {
|
|
6640
6645
|
p = await e.replay(f ? { authorizationSwap: f } : void 0);
|
|
6641
6646
|
} catch (t) {
|
|
6642
|
-
if (t instanceof
|
|
6647
|
+
if (t instanceof ia) return l?.waiter.report({
|
|
6643
6648
|
outcome: "insufficient",
|
|
6644
6649
|
obtained: t.obtained,
|
|
6645
6650
|
required: t.required
|
|
@@ -6657,7 +6662,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6657
6662
|
};
|
|
6658
6663
|
throw t;
|
|
6659
6664
|
}
|
|
6660
|
-
let m = await
|
|
6665
|
+
let m = await Eo(p, t, u, n);
|
|
6661
6666
|
return m.kind === "insufficient" ? l?.waiter.report({
|
|
6662
6667
|
outcome: "insufficient",
|
|
6663
6668
|
obtained: m.obtained,
|
|
@@ -6666,19 +6671,19 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6666
6671
|
outcome: "replayed",
|
|
6667
6672
|
obtained: u
|
|
6668
6673
|
}), m;
|
|
6669
|
-
},
|
|
6674
|
+
}, ko = (e) => {
|
|
6670
6675
|
switch (e.kind) {
|
|
6671
|
-
case "cancelled": return new
|
|
6672
|
-
case "unsatisfiable": return e.error ?? new
|
|
6673
|
-
case "sign-in-required": return new
|
|
6674
|
-
case "unavailable": return new
|
|
6675
|
-
case "session-changed": return new
|
|
6676
|
-
case "insufficient": return new
|
|
6676
|
+
case "cancelled": return new Xa();
|
|
6677
|
+
case "unsatisfiable": return e.error ?? new no();
|
|
6678
|
+
case "sign-in-required": return new Za();
|
|
6679
|
+
case "unavailable": return new aa();
|
|
6680
|
+
case "session-changed": return new oa();
|
|
6681
|
+
case "insufficient": return new ia(e.obtained, e.required);
|
|
6677
6682
|
case "exhausted": return e.error;
|
|
6678
6683
|
case "transport-failure": return e.error;
|
|
6679
6684
|
default: return;
|
|
6680
6685
|
}
|
|
6681
|
-
},
|
|
6686
|
+
}, Ao = (e, t, n) => {
|
|
6682
6687
|
switch (e.kind) {
|
|
6683
6688
|
case "replayed": return {
|
|
6684
6689
|
settle: "resolve",
|
|
@@ -6696,26 +6701,26 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6696
6701
|
};
|
|
6697
6702
|
case "cancelled": return n.onCancel === "reject" ? {
|
|
6698
6703
|
settle: "reject",
|
|
6699
|
-
error: new
|
|
6704
|
+
error: new Xa()
|
|
6700
6705
|
} : {
|
|
6701
6706
|
settle: "resolve",
|
|
6702
|
-
value:
|
|
6707
|
+
value: Bo(t, e)
|
|
6703
6708
|
};
|
|
6704
6709
|
case "unsatisfiable":
|
|
6705
6710
|
case "sign-in-required": return {
|
|
6706
6711
|
settle: "resolve",
|
|
6707
|
-
value:
|
|
6712
|
+
value: Bo(e.response?.raw ?? t, e)
|
|
6708
6713
|
};
|
|
6709
6714
|
case "insufficient": return {
|
|
6710
6715
|
settle: "resolve",
|
|
6711
|
-
value:
|
|
6716
|
+
value: Bo(e.response?.raw ?? t, e)
|
|
6712
6717
|
};
|
|
6713
6718
|
default: return {
|
|
6714
6719
|
settle: "resolve",
|
|
6715
|
-
value:
|
|
6720
|
+
value: Bo(t, e)
|
|
6716
6721
|
};
|
|
6717
6722
|
}
|
|
6718
|
-
},
|
|
6723
|
+
}, jo = (e, t) => {
|
|
6719
6724
|
switch (e.kind) {
|
|
6720
6725
|
case "replayed": return e.response.rejected ? {
|
|
6721
6726
|
settle: "reject",
|
|
@@ -6730,42 +6735,42 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6730
6735
|
};
|
|
6731
6736
|
default: return {
|
|
6732
6737
|
settle: "reject",
|
|
6733
|
-
error:
|
|
6738
|
+
error: ko(e) ?? t
|
|
6734
6739
|
};
|
|
6735
6740
|
}
|
|
6736
|
-
},
|
|
6741
|
+
}, Mo = /* @__PURE__ */ new WeakSet(), No = /* @__PURE__ */ new WeakSet(), Po = /* @__PURE__ */ new WeakSet(), Fo = /* @__PURE__ */ new WeakSet(), Io = /* @__PURE__ */ new WeakSet(), Lo = /* @__PURE__ */ new WeakSet(), Ro = /* @__PURE__ */ new WeakSet(), zo = /* @__PURE__ */ new WeakSet(), Bo = (e, t) => {
|
|
6737
6742
|
switch (t.kind) {
|
|
6738
6743
|
case "cancelled":
|
|
6739
|
-
|
|
6744
|
+
Mo.add(e);
|
|
6740
6745
|
break;
|
|
6741
6746
|
case "exhausted":
|
|
6742
|
-
|
|
6747
|
+
No.add(e);
|
|
6743
6748
|
break;
|
|
6744
6749
|
case "insufficient":
|
|
6745
|
-
|
|
6750
|
+
Po.add(e);
|
|
6746
6751
|
break;
|
|
6747
6752
|
case "unsatisfiable":
|
|
6748
|
-
|
|
6753
|
+
Fo.add(e);
|
|
6749
6754
|
break;
|
|
6750
6755
|
case "sign-in-required":
|
|
6751
|
-
|
|
6756
|
+
Io.add(e);
|
|
6752
6757
|
break;
|
|
6753
6758
|
case "unavailable":
|
|
6754
|
-
|
|
6759
|
+
Lo.add(e);
|
|
6755
6760
|
break;
|
|
6756
6761
|
case "session-changed":
|
|
6757
|
-
|
|
6762
|
+
Ro.add(e);
|
|
6758
6763
|
break;
|
|
6759
|
-
case "transport-failure":
|
|
6764
|
+
case "transport-failure": zo.add(e);
|
|
6760
6765
|
}
|
|
6761
6766
|
return e;
|
|
6762
|
-
},
|
|
6767
|
+
}, Vo = (e) => Mo.has(e), Ho = (e) => No.has(e), Uo = (e) => Po.has(e), Wo = (e) => Fo.has(e), Go = (e) => Io.has(e), Ko = (e) => Lo.has(e), qo = (e) => Ro.has(e), Jo = (e) => zo.has(e), Yo = "https://passflow-relative.invalid", Xo = () => {
|
|
6763
6768
|
let e = globalThis, t = e.document?.baseURI;
|
|
6764
6769
|
if (typeof t == "string" && t !== "") return t;
|
|
6765
6770
|
let n = e.location?.href;
|
|
6766
|
-
return typeof n == "string" && n !== "" && n !== "about:blank" ? n :
|
|
6767
|
-
},
|
|
6768
|
-
let n = t ===
|
|
6771
|
+
return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Yo;
|
|
6772
|
+
}, Zo = (e, t = Xo()) => {
|
|
6773
|
+
let n = t === Yo, r;
|
|
6769
6774
|
try {
|
|
6770
6775
|
r = new URL(t).origin;
|
|
6771
6776
|
} catch {
|
|
@@ -6791,28 +6796,28 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6791
6796
|
relativeToBase: !1,
|
|
6792
6797
|
sentinelBase: n
|
|
6793
6798
|
};
|
|
6794
|
-
},
|
|
6799
|
+
}, Qo = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, $o = (e) => {
|
|
6795
6800
|
let t = [];
|
|
6796
6801
|
if (e == null) return Object.freeze(t);
|
|
6797
6802
|
let n = e;
|
|
6798
6803
|
if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
|
|
6799
|
-
let r =
|
|
6804
|
+
let r = Qo(n, e);
|
|
6800
6805
|
r && t.push(r);
|
|
6801
6806
|
}), Object.freeze(t);
|
|
6802
6807
|
if (Array.isArray(e)) {
|
|
6803
6808
|
for (let n of e) if (Array.isArray(n) && n.length >= 2) {
|
|
6804
|
-
let e =
|
|
6809
|
+
let e = Qo(String(n[0]), n[1]);
|
|
6805
6810
|
e && t.push(e);
|
|
6806
6811
|
}
|
|
6807
6812
|
return Object.freeze(t);
|
|
6808
6813
|
}
|
|
6809
6814
|
if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
|
|
6810
|
-
let e =
|
|
6815
|
+
let e = Qo(n, Array.isArray(r) ? r.join(", ") : r);
|
|
6811
6816
|
e && t.push(e);
|
|
6812
6817
|
}
|
|
6813
6818
|
return Object.freeze(t);
|
|
6814
|
-
},
|
|
6815
|
-
let t = e.base === void 0 ?
|
|
6819
|
+
}, es = (e) => {
|
|
6820
|
+
let t = e.base === void 0 ? Zo(e.url) : Zo(e.url, e.base), n = {
|
|
6816
6821
|
raw: e.url,
|
|
6817
6822
|
href: t.href,
|
|
6818
6823
|
dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
|
|
@@ -6821,29 +6826,29 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6821
6826
|
resolved: t.resolved,
|
|
6822
6827
|
relativeToBase: t.relativeToBase,
|
|
6823
6828
|
method: (e.method ?? "GET").toUpperCase(),
|
|
6824
|
-
headers:
|
|
6829
|
+
headers: $o(e.headers),
|
|
6825
6830
|
bodyKind: e.bodyKind,
|
|
6826
6831
|
..."body" in e ? { body: e.body } : {}
|
|
6827
6832
|
};
|
|
6828
6833
|
return Object.freeze(n);
|
|
6829
|
-
},
|
|
6834
|
+
}, ts = (e, t) => {
|
|
6830
6835
|
if (!t || t.from === t.to) return e;
|
|
6831
6836
|
let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
|
|
6832
6837
|
return n ? Object.freeze(r) : e;
|
|
6833
|
-
},
|
|
6838
|
+
}, ns = (e) => {
|
|
6834
6839
|
let t = {};
|
|
6835
6840
|
for (let [n, r] of e) t[n] = r;
|
|
6836
6841
|
return t;
|
|
6837
|
-
},
|
|
6842
|
+
}, rs = /* @__PURE__ */ new Set([
|
|
6838
6843
|
"GET",
|
|
6839
6844
|
"HEAD",
|
|
6840
6845
|
"OPTIONS"
|
|
6841
|
-
]),
|
|
6846
|
+
]), is = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, as = (e) => typeof e == "string" ? e : is(e) ? e.url : String(e), os = (e, t) => (t?.method ?? (is(e) ? e.method : void 0) ?? "GET").toUpperCase(), ss = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", cs = (e) => {
|
|
6842
6847
|
if (typeof e == "string") return e.length;
|
|
6843
6848
|
let t = e;
|
|
6844
6849
|
if (typeof t?.size == "number") return t.size;
|
|
6845
6850
|
if (typeof t?.byteLength == "number") return t.byteLength;
|
|
6846
|
-
},
|
|
6851
|
+
}, ls = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? rs.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), us = (e, t, n, r, i) => ({
|
|
6847
6852
|
replayable: !1,
|
|
6848
6853
|
bodyKind: e,
|
|
6849
6854
|
reason: t,
|
|
@@ -6851,11 +6856,11 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6851
6856
|
forwardInit: i,
|
|
6852
6857
|
snapshot: r,
|
|
6853
6858
|
replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
|
|
6854
|
-
}),
|
|
6859
|
+
}), ds = (e, t) => ns(ts(e.headers, t?.authorizationSwap)), fs = (e) => {
|
|
6855
6860
|
if (!e || !("headers" in e)) return e;
|
|
6856
6861
|
let { headers: t, ...n } = e;
|
|
6857
6862
|
return n;
|
|
6858
|
-
},
|
|
6863
|
+
}, ps = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : is(e) ? e.headers : void 0, ms = (e) => {
|
|
6859
6864
|
if (e === null || typeof e == "string") return e;
|
|
6860
6865
|
if (typeof FormData < "u" && e instanceof FormData) {
|
|
6861
6866
|
let t = new FormData();
|
|
@@ -6863,18 +6868,18 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6863
6868
|
return t;
|
|
6864
6869
|
}
|
|
6865
6870
|
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;
|
|
6866
|
-
},
|
|
6867
|
-
let r =
|
|
6871
|
+
}, hs = (e, t, n) => new Request(e, { headers: ds(t, n) }), gs = (e, t, n) => {
|
|
6872
|
+
let r = as(e), i = os(e, t), a = ps(e, t), o = (e, t) => es({
|
|
6868
6873
|
url: r,
|
|
6869
6874
|
method: i,
|
|
6870
6875
|
headers: a,
|
|
6871
6876
|
bodyKind: e,
|
|
6872
6877
|
...t === void 0 ? {} : { body: t }
|
|
6873
6878
|
});
|
|
6874
|
-
if (
|
|
6879
|
+
if (is(e)) {
|
|
6875
6880
|
if (e.body === null || e.body === void 0) {
|
|
6876
6881
|
let a = o("none");
|
|
6877
|
-
return
|
|
6882
|
+
return ls(n, {
|
|
6878
6883
|
url: r,
|
|
6879
6884
|
method: i,
|
|
6880
6885
|
bodyKind: "none"
|
|
@@ -6884,20 +6889,20 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6884
6889
|
forwardInput: e,
|
|
6885
6890
|
forwardInit: t,
|
|
6886
6891
|
snapshot: a,
|
|
6887
|
-
replay: (n, r) => n(
|
|
6888
|
-
} :
|
|
6892
|
+
replay: (n, r) => n(hs(e, a, r), fs(t))
|
|
6893
|
+
} : us("none", "the replay policy refused this request", e, a, t);
|
|
6889
6894
|
}
|
|
6890
6895
|
let a = o("request-clone");
|
|
6891
|
-
if (!
|
|
6896
|
+
if (!ls(n, {
|
|
6892
6897
|
url: r,
|
|
6893
6898
|
method: i,
|
|
6894
6899
|
bodyKind: "request-clone"
|
|
6895
|
-
})) return
|
|
6900
|
+
})) return us("request-clone", "the replay policy refused this request", e, a, t);
|
|
6896
6901
|
let s;
|
|
6897
6902
|
try {
|
|
6898
6903
|
s = e.clone();
|
|
6899
6904
|
} catch {
|
|
6900
|
-
return
|
|
6905
|
+
return us("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
|
|
6901
6906
|
}
|
|
6902
6907
|
return {
|
|
6903
6908
|
replayable: !0,
|
|
@@ -6905,17 +6910,17 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6905
6910
|
forwardInput: e,
|
|
6906
6911
|
forwardInit: t,
|
|
6907
6912
|
snapshot: a,
|
|
6908
|
-
replay: (e, n) => e(
|
|
6913
|
+
replay: (e, n) => e(hs(s, a, n), fs(t))
|
|
6909
6914
|
};
|
|
6910
6915
|
}
|
|
6911
|
-
let s =
|
|
6912
|
-
if (s === "one-shot") return
|
|
6913
|
-
if (!
|
|
6916
|
+
let s = ss(t?.body);
|
|
6917
|
+
if (s === "one-shot") return us("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
|
|
6918
|
+
if (!ls(n, {
|
|
6914
6919
|
url: r,
|
|
6915
6920
|
method: i,
|
|
6916
6921
|
bodyKind: s
|
|
6917
|
-
},
|
|
6918
|
-
let c = t && "body" in t ?
|
|
6922
|
+
}, cs(t?.body))) return us(s, "the replay policy refused this request", e, o(s), t);
|
|
6923
|
+
let c = t && "body" in t ? ms(t.body ?? null) : void 0, l = o(s, c);
|
|
6919
6924
|
return {
|
|
6920
6925
|
replayable: !0,
|
|
6921
6926
|
bodyKind: s,
|
|
@@ -6923,21 +6928,21 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6923
6928
|
forwardInit: t,
|
|
6924
6929
|
snapshot: l,
|
|
6925
6930
|
replay: (e, n) => e(l.dispatchUrl, {
|
|
6926
|
-
...
|
|
6931
|
+
...fs(t),
|
|
6927
6932
|
...c === void 0 ? {} : { body: c },
|
|
6928
|
-
headers:
|
|
6933
|
+
headers: ds(l, n),
|
|
6929
6934
|
method: l.method
|
|
6930
6935
|
})
|
|
6931
6936
|
};
|
|
6932
|
-
},
|
|
6933
|
-
if (!
|
|
6937
|
+
}, _s = (e) => typeof e == "object" && !!e, vs = (e) => (t) => {
|
|
6938
|
+
if (!_s(e)) return;
|
|
6934
6939
|
let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
|
|
6935
6940
|
return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
|
|
6936
|
-
},
|
|
6941
|
+
}, ys = (e) => {
|
|
6937
6942
|
let t = e?.url ?? "", n = e?.baseURL;
|
|
6938
6943
|
return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
6939
|
-
},
|
|
6940
|
-
let r = ts(
|
|
6944
|
+
}, bs = (e) => (e?.method ?? "GET").toUpperCase(), xs = (e) => e == null ? "none" : _s(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", Ss = (e, t, n) => {
|
|
6945
|
+
let r = ns(ts(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
|
|
6941
6946
|
return {
|
|
6942
6947
|
...e,
|
|
6943
6948
|
...i ? { baseURL: void 0 } : {},
|
|
@@ -6946,10 +6951,10 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6946
6951
|
headers: r,
|
|
6947
6952
|
..."body" in t ? { data: t.body } : {}
|
|
6948
6953
|
};
|
|
6949
|
-
},
|
|
6950
|
-
let o = t ?? e?.config, s =
|
|
6951
|
-
url:
|
|
6952
|
-
method:
|
|
6954
|
+
}, Cs = (e, t, n, r, i, a) => {
|
|
6955
|
+
let o = t ?? e?.config, s = xs(o?.data), c = a ?? es({
|
|
6956
|
+
url: ys(o),
|
|
6957
|
+
method: bs(o),
|
|
6953
6958
|
headers: o?.headers,
|
|
6954
6959
|
bodyKind: s,
|
|
6955
6960
|
body: o?.data
|
|
@@ -6957,22 +6962,22 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6957
6962
|
url: c.href,
|
|
6958
6963
|
method: c.method,
|
|
6959
6964
|
bodyKind: s
|
|
6960
|
-
}, u = s !== "one-shot" &&
|
|
6965
|
+
}, u = s !== "one-shot" && ls(i.replay, l);
|
|
6961
6966
|
return {
|
|
6962
6967
|
status: e?.status ?? 0,
|
|
6963
|
-
getHeader:
|
|
6968
|
+
getHeader: vs(e?.headers),
|
|
6964
6969
|
readBody: async () => e?.data,
|
|
6965
6970
|
request: c,
|
|
6966
6971
|
replay: async (e) => {
|
|
6967
|
-
let t = Re(
|
|
6972
|
+
let t = Re(Ss(o ?? {}, c, e));
|
|
6968
6973
|
try {
|
|
6969
6974
|
let e = await r(t);
|
|
6970
|
-
return
|
|
6975
|
+
return Cs(e, e?.config ?? t, e, r, i, c);
|
|
6971
6976
|
} catch (e) {
|
|
6972
|
-
let n =
|
|
6973
|
-
if (!n.response || typeof n.response.status != "number" ||
|
|
6977
|
+
let n = _s(e) ? e : {};
|
|
6978
|
+
if (!n.response || typeof n.response.status != "number" || Ji(e)) throw e;
|
|
6974
6979
|
return {
|
|
6975
|
-
...
|
|
6980
|
+
...Cs(n.response, n.config ?? t, e, r, i, c),
|
|
6976
6981
|
rejected: !0
|
|
6977
6982
|
};
|
|
6978
6983
|
}
|
|
@@ -6986,30 +6991,30 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6986
6991
|
replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
|
|
6987
6992
|
signal: o?.signal
|
|
6988
6993
|
};
|
|
6989
|
-
},
|
|
6990
|
-
let r =
|
|
6994
|
+
}, ws = (e, t) => async (n) => {
|
|
6995
|
+
let r = fo(e), i = _s(n) ? n : {}, a = jo(await Oo(Cs(i.response, i.config, i.response, t, r), r), n);
|
|
6991
6996
|
if (a.settle === "reject") throw a.error;
|
|
6992
6997
|
return a.value;
|
|
6993
|
-
},
|
|
6994
|
-
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,
|
|
6998
|
+
}, Ts = (e, t, n) => {
|
|
6999
|
+
let r = e.request, i = n ?? (typeof r == "function" ? (t) => r.call(e, t) : () => Promise.reject(/* @__PURE__ */ Error("Passflow: this client exposes no request() to replay through."))), a = e.interceptors.response.use(void 0, ws(t, i)), o = !1;
|
|
6995
7000
|
return () => {
|
|
6996
7001
|
o || (o = !0, e.interceptors.response.eject(a));
|
|
6997
7002
|
};
|
|
6998
|
-
},
|
|
7003
|
+
}, Es = (t, n) => {
|
|
6999
7004
|
let r = e.create(t);
|
|
7000
7005
|
return n(r), r;
|
|
7001
|
-
},
|
|
7006
|
+
}, Ds = () => {
|
|
7002
7007
|
let e = typeof location > "u" ? void 0 : location.origin;
|
|
7003
7008
|
return e && e !== "null" ? e : void 0;
|
|
7004
|
-
},
|
|
7009
|
+
}, Os = (e) => {
|
|
7005
7010
|
let t = new URL(e).origin;
|
|
7006
7011
|
if (t === "null") throw Error(`Passflow: "${e}" has no origin a request can be matched against; list http(s) origins only.`);
|
|
7007
7012
|
return t;
|
|
7008
|
-
},
|
|
7009
|
-
let n = (t?.origins ?? []).map(
|
|
7013
|
+
}, ks = (e, t) => {
|
|
7014
|
+
let n = (t?.origins ?? []).map(Os);
|
|
7010
7015
|
return (t, r) => {
|
|
7011
7016
|
if (r) return Promise.resolve(void 0);
|
|
7012
|
-
let i =
|
|
7017
|
+
let i = Ds(), a;
|
|
7013
7018
|
try {
|
|
7014
7019
|
a = new URL(t, i).origin;
|
|
7015
7020
|
} catch {
|
|
@@ -7017,22 +7022,22 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7017
7022
|
}
|
|
7018
7023
|
return a !== i && !n.includes(a) ? Promise.resolve(void 0) : e();
|
|
7019
7024
|
};
|
|
7020
|
-
},
|
|
7021
|
-
let r =
|
|
7025
|
+
}, As = (e) => typeof Request < "u" && e instanceof Request, js = (e, t) => new Headers(t?.headers === void 0 ? As(e) ? e.headers : void 0 : t.headers), Ms = (e, t, n) => {
|
|
7026
|
+
let r = ks(t, n);
|
|
7022
7027
|
return async (t, n) => {
|
|
7023
|
-
let i =
|
|
7028
|
+
let i = As(t) ? t.url : t instanceof URL ? t.href : String(t), a = js(t, n), o = await r(i, a.has("authorization"));
|
|
7024
7029
|
return o ? (a.set("authorization", `Bearer ${o}`), e(t, {
|
|
7025
7030
|
...n,
|
|
7026
7031
|
headers: a
|
|
7027
7032
|
})) : e(t, n);
|
|
7028
7033
|
};
|
|
7029
|
-
},
|
|
7034
|
+
}, Ns = (e) => {
|
|
7030
7035
|
let t = e.url ?? "", n = /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
|
|
7031
7036
|
return !e.baseURL || n && e.allowAbsoluteUrls !== !1 ? t : t ? `${e.baseURL.replace(/\/?\/$/, "")}/${t.replace(/^\/+/, "")}` : e.baseURL;
|
|
7032
|
-
},
|
|
7033
|
-
let n =
|
|
7037
|
+
}, Ps = (e) => e ? typeof e.has == "function" ? e.has("Authorization") : Object.keys(e).some((t) => t.toLowerCase() === "authorization" && e[t] != null) : !1, Fs = (e, t) => {
|
|
7038
|
+
let n = ks(e, t);
|
|
7034
7039
|
return async (e) => {
|
|
7035
|
-
let t = e.headers, r = await n(
|
|
7040
|
+
let t = e.headers, r = await n(Ns(e), Ps(t));
|
|
7036
7041
|
if (!r) return e;
|
|
7037
7042
|
let i = `Bearer ${r}`;
|
|
7038
7043
|
return t && typeof t.set == "function" ? t.set("Authorization", i) : e.headers = {
|
|
@@ -7040,7 +7045,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7040
7045
|
Authorization: i
|
|
7041
7046
|
}, e;
|
|
7042
7047
|
};
|
|
7043
|
-
},
|
|
7048
|
+
}, Is = 0, Ls = (e, t) => {
|
|
7044
7049
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
7045
7050
|
if (n) return {
|
|
7046
7051
|
get aborted() {
|
|
@@ -7054,34 +7059,34 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7054
7059
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
7055
7060
|
} : {}
|
|
7056
7061
|
};
|
|
7057
|
-
},
|
|
7062
|
+
}, Rs = (e) => (t) => e.headers?.get(t), zs = (e, t, n, r, i) => ({
|
|
7058
7063
|
status: e.status,
|
|
7059
|
-
getHeader:
|
|
7064
|
+
getHeader: Rs(e),
|
|
7060
7065
|
readBody: () => e.clone().json(),
|
|
7061
7066
|
request: t.snapshot,
|
|
7062
|
-
replay: async (e) =>
|
|
7067
|
+
replay: async (e) => zs(await t.replay(n, e), t, n, r, i),
|
|
7063
7068
|
markers: r,
|
|
7064
7069
|
raw: e,
|
|
7065
7070
|
replayable: t.replayable,
|
|
7066
7071
|
replayUnsupportedReason: t.reason,
|
|
7067
7072
|
signal: i,
|
|
7068
7073
|
responseType: e.type
|
|
7069
|
-
}),
|
|
7074
|
+
}), Bs = (e, t) => {
|
|
7070
7075
|
let n = (t, n) => {
|
|
7071
|
-
|
|
7076
|
+
Is += 1;
|
|
7072
7077
|
try {
|
|
7073
7078
|
return e(t, n);
|
|
7074
7079
|
} finally {
|
|
7075
|
-
--
|
|
7080
|
+
--Is;
|
|
7076
7081
|
}
|
|
7077
7082
|
};
|
|
7078
7083
|
return async (e, r) => {
|
|
7079
|
-
if (
|
|
7080
|
-
let i =
|
|
7084
|
+
if (Is > 0) return n(e, r);
|
|
7085
|
+
let i = fo(t), a = gs(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = Ao(await Oo(zs(o, a, n, {}, Ls(e, r)), i), o, i);
|
|
7081
7086
|
if (s.settle === "reject") throw s.error;
|
|
7082
7087
|
return s.value;
|
|
7083
7088
|
};
|
|
7084
|
-
},
|
|
7089
|
+
}, Vs = new Set(Ua.filter((e) => !e.requiresPrepare).map((e) => e.type)), Hs = (e) => {
|
|
7085
7090
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
7086
7091
|
kind: "protocol",
|
|
7087
7092
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -7093,17 +7098,17 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7093
7098
|
webauthn: e.webauthn,
|
|
7094
7099
|
codeSentTo: e.code_sent_to
|
|
7095
7100
|
};
|
|
7096
|
-
},
|
|
7101
|
+
}, Us = (e) => Ji(e) && !Yi(e), Ws = (e) => ({
|
|
7097
7102
|
async prepare(t) {
|
|
7098
|
-
if (!
|
|
7103
|
+
if (!Vs.has(t)) try {
|
|
7099
7104
|
let n = e.relyingPartyId?.();
|
|
7100
|
-
return
|
|
7105
|
+
return Hs(await e.startUpgrade(n ? {
|
|
7101
7106
|
method: t,
|
|
7102
7107
|
relying_party_id: n
|
|
7103
7108
|
} : { method: t }));
|
|
7104
7109
|
} catch (e) {
|
|
7105
|
-
if (
|
|
7106
|
-
let t =
|
|
7110
|
+
if (Us(e)) throw e;
|
|
7111
|
+
let t = ta(e, "start");
|
|
7107
7112
|
if (t.kind === "prepare_not_required") return;
|
|
7108
7113
|
throw t;
|
|
7109
7114
|
}
|
|
@@ -7120,17 +7125,17 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7120
7125
|
assertion: n
|
|
7121
7126
|
});
|
|
7122
7127
|
} catch (t) {
|
|
7123
|
-
if (
|
|
7124
|
-
let n =
|
|
7125
|
-
throw n.status === 401 &&
|
|
7128
|
+
if (Us(t)) throw t;
|
|
7129
|
+
let n = ta(t, "refresh");
|
|
7130
|
+
throw n.status === 401 && ra(n) && e.markSessionInvalid?.(), n;
|
|
7126
7131
|
}
|
|
7127
7132
|
}
|
|
7128
|
-
}),
|
|
7133
|
+
}), Gs = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Ks = (e) => {
|
|
7129
7134
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
7130
7135
|
let i = () => {
|
|
7131
7136
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
7132
7137
|
};
|
|
7133
|
-
return
|
|
7138
|
+
return Ws({
|
|
7134
7139
|
...e,
|
|
7135
7140
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
7136
7141
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -7141,7 +7146,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7141
7146
|
});
|
|
7142
7147
|
}, i = (t, n) => {
|
|
7143
7148
|
let i = {}, a = {
|
|
7144
|
-
controller: new
|
|
7149
|
+
controller: new uo({
|
|
7145
7150
|
transport: r(() => i.current),
|
|
7146
7151
|
prompt: t.prompt,
|
|
7147
7152
|
platform: e.platform,
|
|
@@ -7153,7 +7158,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7153
7158
|
options: t,
|
|
7154
7159
|
scope: {
|
|
7155
7160
|
passflow: e.passflowDomain,
|
|
7156
|
-
backend:
|
|
7161
|
+
backend: Gs(t.backend)
|
|
7157
7162
|
},
|
|
7158
7163
|
generation: n
|
|
7159
7164
|
};
|
|
@@ -7163,17 +7168,17 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7163
7168
|
s = void 0;
|
|
7164
7169
|
});
|
|
7165
7170
|
let c = (e) => {
|
|
7166
|
-
if (!s ||
|
|
7171
|
+
if (!s || lo(s.challenge, e)) return;
|
|
7167
7172
|
let t = Math.min(o, e.maxAge === void 0 ? o : e.maxAge * 1e3);
|
|
7168
7173
|
if (!(Date.now() - s.at > t)) return s.challenge;
|
|
7169
7174
|
}, l = async (r, i) => {
|
|
7170
7175
|
let o = t;
|
|
7171
|
-
if (!o) throw new
|
|
7176
|
+
if (!o) throw new aa("Step-up verification is not enabled on this Passflow instance");
|
|
7172
7177
|
let l = e.stopRepeatedElevation ? c(r) : void 0;
|
|
7173
|
-
if (l) throw new
|
|
7178
|
+
if (l) throw new ia(oo(l), oo(r), "This requirement was already proved and the server still refused it: sign the user in again");
|
|
7174
7179
|
o.controller.active || (o.pin = e.readSessionPin?.());
|
|
7175
7180
|
let u = await o.controller.elevate(r, i);
|
|
7176
|
-
if (!n(o)) throw new
|
|
7181
|
+
if (!n(o)) throw new oa();
|
|
7177
7182
|
return e.stopRepeatedElevation && (s = {
|
|
7178
7183
|
challenge: r,
|
|
7179
7184
|
at: a ?? Date.now()
|
|
@@ -7220,9 +7225,9 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7220
7225
|
let r = [];
|
|
7221
7226
|
if (e.attachInternalSeam) {
|
|
7222
7227
|
let t = e.attachInternalSeam;
|
|
7223
|
-
t((e) =>
|
|
7228
|
+
t((e) => ws(u, e)), r.push(() => t(void 0));
|
|
7224
7229
|
}
|
|
7225
|
-
n.interceptFetch && r.push(
|
|
7230
|
+
n.interceptFetch && r.push(On((e, t, n) => Bs(e, u)(t, n), {
|
|
7226
7231
|
priority: 20,
|
|
7227
7232
|
name: "passflow-upgrade"
|
|
7228
7233
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -7254,8 +7259,8 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7254
7259
|
enumerable: !0,
|
|
7255
7260
|
value: (t, n) => {
|
|
7256
7261
|
let r = (t) => {
|
|
7257
|
-
let r =
|
|
7258
|
-
return e.readAccessToken ?
|
|
7262
|
+
let r = Bs(t, u);
|
|
7263
|
+
return e.readAccessToken ? Ms(r, e.readAccessToken, n) : r;
|
|
7259
7264
|
};
|
|
7260
7265
|
if (t) return r(t);
|
|
7261
7266
|
let i = typeof globalThis > "u" ? void 0 : globalThis;
|
|
@@ -7266,14 +7271,14 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7266
7271
|
attachAuth: {
|
|
7267
7272
|
enumerable: !0,
|
|
7268
7273
|
value: (t, n) => {
|
|
7269
|
-
let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(
|
|
7274
|
+
let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(Fs(e.readAccessToken, n)), a = Ts(t, u);
|
|
7270
7275
|
return () => {
|
|
7271
7276
|
a(), r && i !== void 0 && r.eject(i);
|
|
7272
7277
|
};
|
|
7273
7278
|
}
|
|
7274
7279
|
}
|
|
7275
7280
|
});
|
|
7276
|
-
},
|
|
7281
|
+
}, qs, Js = class {
|
|
7277
7282
|
get origin() {
|
|
7278
7283
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
7279
7284
|
}
|
|
@@ -7286,9 +7291,9 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7286
7291
|
prefix: e.keyStoragePrefix ?? "",
|
|
7287
7292
|
storage: this.platform.storage,
|
|
7288
7293
|
appId: n
|
|
7289
|
-
}), this.deviceService = new fe(this.storageManager), this.authApi = new
|
|
7290
|
-
let i =
|
|
7291
|
-
this.authService = new
|
|
7294
|
+
}), this.deviceService = new fe(this.storageManager), this.authApi = new nn(e, this.storageManager, this.deviceService), this.appApi = new Yt(e, this.storageManager, this.deviceService), this.userApi = new mn(e, this.storageManager, this.deviceService), this.settingApi = new on(e, this.storageManager, this.deviceService), this.tenantApi = new sn(e, this.storageManager, this.deviceService), this.invitationApi = new an(e, this.storageManager, this.deviceService), this.twoFactorApi = new fn(e, this.storageManager, this.deviceService), this.upgradeApi = new pn(e, this.storageManager, this.deviceService), this.upgradeDomain = He(e.url), this.subscribeStore = new lr(), this.tokenCacheService = new Fa(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? v, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
|
|
7295
|
+
let i = ri(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
|
|
7296
|
+
this.authService = new ja(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
|
|
7292
7297
|
createSession: async (e) => {
|
|
7293
7298
|
await this.createSessionCallback?.(e);
|
|
7294
7299
|
},
|
|
@@ -7298,7 +7303,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7298
7303
|
}, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
|
|
7299
7304
|
coordination: i,
|
|
7300
7305
|
...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
|
|
7301
|
-
}, () => this.readAppSettings()), this.antiBot =
|
|
7306
|
+
}, () => this.readAppSettings()), this.antiBot = Tr({
|
|
7302
7307
|
readSettings: () => this.readAppSettings(),
|
|
7303
7308
|
fetchChallenge: ({ identifier: e, device: t }) => t ? this.authApi.deviceAntiBotChallenge({
|
|
7304
7309
|
user_code: t.userCode,
|
|
@@ -7308,7 +7313,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7308
7313
|
...e.antiBotWorkerUrl ? { workerUrl: e.antiBotWorkerUrl } : {}
|
|
7309
7314
|
}), this.authApi.setAntiBotHandler((e) => this.antiBot.headerFor(e)), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
7310
7315
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
7311
|
-
this.userService = new
|
|
7316
|
+
this.userService = new La(this.userApi, this.deviceService, this.platform), this.tenantService = new Pa(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new Ma(this.invitationApi), this.twoFactorService = new Ia(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Ks({
|
|
7312
7317
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
7313
7318
|
commitRefresh: async (e, t) => {
|
|
7314
7319
|
await this.authService.refreshToken(e, t);
|
|
@@ -7337,7 +7342,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7337
7342
|
let e = (await this.getTokens(!0))?.access_token;
|
|
7338
7343
|
return e && !A(j(e)) ? e : void 0;
|
|
7339
7344
|
}
|
|
7340
|
-
}), this.hostedUpgrade =
|
|
7345
|
+
}), this.hostedUpgrade = Ks({
|
|
7341
7346
|
startUpgrade: (e) => this.upgradeApi.startHostedUpgrade(e),
|
|
7342
7347
|
commitRefresh: (e) => this.upgradeApi.commitHostedUpgrade(e),
|
|
7343
7348
|
canCommit: () => ({ ok: !0 }),
|
|
@@ -7374,7 +7379,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7374
7379
|
return this.upgrade.attachAuth(e, t);
|
|
7375
7380
|
}
|
|
7376
7381
|
createClient(e, t) {
|
|
7377
|
-
return
|
|
7382
|
+
return Es(e, (e) => this.upgrade.attachAuth(e, t));
|
|
7378
7383
|
}
|
|
7379
7384
|
readAssuranceBar() {
|
|
7380
7385
|
let e = this.storageManager.getToken(M.access_token);
|
|
@@ -7457,7 +7462,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7457
7462
|
}
|
|
7458
7463
|
let n = t.get("access_token"), r = t.get("refresh_token"), i = t.get("id_token"), a = t.get("state") ?? void 0, o = t.get("scopes")?.split(",") ?? this.scopes;
|
|
7459
7464
|
if (n) {
|
|
7460
|
-
if (!
|
|
7465
|
+
if (!la(n)) {
|
|
7461
7466
|
U(this.subscribeStore, {
|
|
7462
7467
|
operation: "tokens.from-url",
|
|
7463
7468
|
message: "Invalid access token format received",
|
|
@@ -7465,7 +7470,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7465
7470
|
}), this.cleanupUrlParams(e);
|
|
7466
7471
|
return;
|
|
7467
7472
|
}
|
|
7468
|
-
if (r && !
|
|
7473
|
+
if (r && !la(r)) {
|
|
7469
7474
|
U(this.subscribeStore, {
|
|
7470
7475
|
operation: "tokens.from-url",
|
|
7471
7476
|
message: "Invalid refresh token format received",
|
|
@@ -7473,7 +7478,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7473
7478
|
}), this.cleanupUrlParams(e);
|
|
7474
7479
|
return;
|
|
7475
7480
|
}
|
|
7476
|
-
if (i && !
|
|
7481
|
+
if (i && !la(i)) {
|
|
7477
7482
|
U(this.subscribeStore, {
|
|
7478
7483
|
operation: "tokens.from-url",
|
|
7479
7484
|
message: "Invalid ID token format received",
|
|
@@ -7488,8 +7493,8 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7488
7493
|
scopes: o
|
|
7489
7494
|
};
|
|
7490
7495
|
this.cleanupUrlParams(e), this.error = void 0, this.readAppSettings().catch(() => void 0).then((e) => {
|
|
7491
|
-
if (e?.pkce_enabled !== !1) throw
|
|
7492
|
-
return
|
|
7496
|
+
if (e?.pkce_enabled !== !1) throw Yn();
|
|
7497
|
+
return Vi(this.url, this.appId, t);
|
|
7493
7498
|
}).then(() => {
|
|
7494
7499
|
this.storageManager.clearDeliveryMode(), this.storageManager.saveTokens(t, void 0, { replace: !0 }), e && this.storageManager.setHostedSignIn(e.origin + e.pathname), this.tokenCacheService.setTokensCache(t), this.authService.refresh.sessionStarted();
|
|
7495
7500
|
}).then(() => (this.subscribeStore.notify(W.SignIn, {
|
|
@@ -7524,7 +7529,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7524
7529
|
if (!n) return !1;
|
|
7525
7530
|
t.delete("tfa_token");
|
|
7526
7531
|
let r = t.toString();
|
|
7527
|
-
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")),
|
|
7532
|
+
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), la(n) ? (this.subscribeStore.notify(W.TwoFactorRequired, {
|
|
7528
7533
|
email: "",
|
|
7529
7534
|
challengeId: "",
|
|
7530
7535
|
tfaToken: n
|
|
@@ -7537,7 +7542,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7537
7542
|
checkErrorsFromURL() {
|
|
7538
7543
|
let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
|
|
7539
7544
|
if (e) {
|
|
7540
|
-
let t =
|
|
7545
|
+
let t = ua(e);
|
|
7541
7546
|
return Error(t);
|
|
7542
7547
|
}
|
|
7543
7548
|
}
|
|
@@ -7549,22 +7554,19 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7549
7554
|
"id_token"
|
|
7550
7555
|
], n = new URLSearchParams(e.search), r = new URLSearchParams(e.hash?.substring(1)), i = t.some((e) => n.get(e)), a = t.some((e) => r.get(e));
|
|
7551
7556
|
if (!a && !i) return;
|
|
7552
|
-
|
|
7557
|
+
let o = [
|
|
7553
7558
|
...t,
|
|
7554
7559
|
"client_challenge",
|
|
7555
|
-
|
|
7556
|
-
]
|
|
7557
|
-
let
|
|
7560
|
+
"user_state"
|
|
7561
|
+
];
|
|
7562
|
+
for (let e of [...o, ...i ? ["state"] : []]) n.delete(e);
|
|
7563
|
+
let s = n.toString(), c = e.hash ?? "";
|
|
7558
7564
|
if (a) {
|
|
7559
|
-
for (let e of [
|
|
7560
|
-
...t,
|
|
7561
|
-
"client_challenge",
|
|
7562
|
-
"state"
|
|
7563
|
-
]) r.delete(e);
|
|
7565
|
+
for (let e of [...o, "state"]) r.delete(e);
|
|
7564
7566
|
let e = r.toString();
|
|
7565
|
-
|
|
7567
|
+
c = e ? `#${e}` : "";
|
|
7566
7568
|
}
|
|
7567
|
-
this.platform.replaceUrl(e.pathname + (
|
|
7569
|
+
this.platform.replaceUrl(e.pathname + (s ? `?${s}` : "") + c);
|
|
7568
7570
|
}
|
|
7569
7571
|
setTokensToCacheFromLocalStorage() {
|
|
7570
7572
|
let e = this.storageManager.getTokens();
|
|
@@ -8042,7 +8044,7 @@ var Ta = 10, Ea = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
8042
8044
|
this.twoFactorService.clearMagicLinkSession();
|
|
8043
8045
|
}
|
|
8044
8046
|
};
|
|
8045
|
-
|
|
8046
|
-
export { st as ADDRESS_CHANGE_PROOF_REQUIRED_ERROR_ID, m as AGENT_TOOL_HEADER_KEY, h as ANTI_BOT_ACTION, Je as ANTI_BOT_FAILED_ERROR_ID, p as ANTI_BOT_HEADER_KEY, Ze as ANTI_BOT_PROVIDER_FAILED_ERROR_ID, Xe as ANTI_BOT_PROVIDER_MISSING_ERROR_ID, qe as ANTI_BOT_REQUIRED_ERROR_ID, Qe as ANTI_BOT_SOLVE_FAILED_ERROR_ID, Ye as ANTI_BOT_UNAVAILABLE_ERROR_ID, l as APP_ID_HEADER_KEY, pt as APP_SECRET_NAMES, u as AUTHORIZATION_HEADER_KEY,
|
|
8047
|
+
qs = Js, qs.version = g;
|
|
8048
|
+
export { st as ADDRESS_CHANGE_PROOF_REQUIRED_ERROR_ID, m as AGENT_TOOL_HEADER_KEY, h as ANTI_BOT_ACTION, Je as ANTI_BOT_FAILED_ERROR_ID, p as ANTI_BOT_HEADER_KEY, Ze as ANTI_BOT_PROVIDER_FAILED_ERROR_ID, Xe as ANTI_BOT_PROVIDER_MISSING_ERROR_ID, qe as ANTI_BOT_REQUIRED_ERROR_ID, Qe as ANTI_BOT_SOLVE_FAILED_ERROR_ID, Ye as ANTI_BOT_UNAVAILABLE_ERROR_ID, l as APP_ID_HEADER_KEY, pt as APP_SECRET_NAMES, u as AUTHORIZATION_HEADER_KEY, Yt as AppAPI, nn as AuthAPI, ja as AuthService, rn as CLIAuthAPI, b as DEFAULT_GROUP_NAME, v as DEFAULT_SCOPES, Ua as DEFAULT_UPGRADE_FACTORS, d as DEVICE_ID_HEADER_KEY, f as DEVICE_TYPE_HEADER_KEY, nt as ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID, $e as ENTERPRISE_EMAIL_INVALID_ERROR_ID, tt as ENTERPRISE_NO_CONNECTION_ERROR_ID, et as ENTERPRISE_START_INPUT_ERROR_ID, te as ERROR_MESSAGE_MAX_LENGTH, hn as FETCH_PRIORITY_OIDC, gn as FETCH_PRIORITY_UPGRADE, _n as FetchMiddlewareContractError, be as INSUFFICIENT_USER_AUTHENTICATION, an as InvitationAPI, Ma as InvitationService, Ln as M2MClient, Mn as M2MConfigError, V as M2MError, Nn as M2MErrorCodes, An as M2MNetworkError, jn as M2MTokenParseError, Pn as M2M_DEFAULTS, mt as MASKED_SECRET_PREFIX, _ as MINIMAL_DEFAULT_SCOPES, _t as OS, y as PASSFLOW_CLOUD_URL, Ke as PASSWORD_CHANGE_REQUIRED_ERROR_ID, ee as POPUP_HEIGHT, S as POPUP_POLL_INTERVAL_MS, C as POPUP_TIMEOUT_MS, x as POPUP_WIDTH, Js as Passflow, dt as PassflowAddressChangeProofRequiredError, Ve as PassflowAdminEndpointPaths, R as PassflowEndpointPaths, z as PassflowError, W as PassflowEvent, H as PassflowOidcError, rt as PassflowPasswordChangeRequiredError, ut as PassflowRecoveryCodesStepUpRequiredError, J as PassflowRefreshError, lt as PassflowSendLimitError, ct as PassflowSmsQuotaExceededError, L as PopupClosedError, ft as Providers, Hi as RECOVERABLE_COMMIT_ERROR_IDS, ot as RECOVERY_CODES_STEP_UP_REQUIRED_ERROR_ID, oi as REFRESH_AUTH_FAILURE_IDS, q as RefreshErrorId, Be as RequestMethod, g as SDK_VERSION, We as SERVICE_UNAVAILABLE_ERROR_ID, Ge as SERVICE_UNAVAILABLE_MESSAGE, Ui as SESSION_INVALIDATING_COMMIT_ERROR_IDS, ht as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, ce as SessionState, on as SettingAPI, w as TOKEN_EXPIRY_BUFFER_SECONDS, at as TWO_FACTOR_SEND_LIMIT_ERROR_ID, it as TWO_FACTOR_SMS_QUOTA_EXCEEDED_ERROR_ID, sn as TenantAPI, Pa as TenantService, Na as TenantUserMembership, Fa as TokenCacheService, N as TokenDeliveryMode, M as TokenType, fn as TwoFactorApiClient, bt as TwoFactorPolicy, Ia as TwoFactorService, xe as UPGRADE_REQUIRED, E as USERNAME_MAX_LENGTH, T as USERNAME_MIN_LENGTH, pn as UpgradeAPI, Xa as UpgradeCancelledError, vi as UpgradeCommitInterruptedError, uo as UpgradeController, Q as UpgradeErrorIds, Ra as UpgradeFactorError, ia as UpgradeInsufficientError, oa as UpgradeSessionChangedError, Za as UpgradeSignInRequiredError, $ as UpgradeTransportError, aa as UpgradeUnavailableError, no as UpgradeUnsatisfiableError, mn as UserAPI, La as UserService, pe as WebAdapter, ta as classifyUpgradeError, Wa as factorRegistry, kn as fetchRegistryState, vt as getOSFromDeviceType, ra as invalidatesSessionOnCommit, Ue as isEmailVerificationStep, gt as isMaskedSecret, na as isRecoverableCommitFailure, Gi as isRetryableUpgradeKind, A as isTokenExpired, Vo as isUpgradeCancelled, Ho as isUpgradeExhausted, Uo as isUpgradeInsufficient, qo as isUpgradeSessionChanged, Go as isUpgradeSignInRequired, Yi as isUpgradeTransportError, Jo as isUpgradeTransportFailure, Ko as isUpgradeUnavailable, Wo as isUpgradeUnsatisfiable, da as isValidEmail, la as isValidJWTFormat, fa as isValidPhoneNumber, pa as isValidUsername, Oe as parseChallengeBody, De as parseChallengeHeader, j as parseToken, Me as parseUpgradeChallenge, Ha as passkeyFactor, yt as pathWithParams, Va as recoveryCodesFactor, On as registerFetchMiddleware, ye as requiredAcrLevel, He as resolveUpgradeDomain, ua as sanitizeErrorMessage, Ya as selectFactors, Ba as totpFactor, me as webAdapter };
|
|
8047
8049
|
|
|
8048
8050
|
//# sourceMappingURL=index.mjs.map
|