@passflow/core 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -1
- package/dist/index.d.ts +53 -1
- package/dist/index.mjs +653 -649
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import e from "axios";
|
|
2
2
|
import { startAuthentication as t, startRegistration as n } from "@simplewebauthn/browser";
|
|
3
3
|
// package.json
|
|
4
|
-
var r = "0.
|
|
4
|
+
var r = "0.23.0", i = "X-Passflow-Clientid", a = "Authorization", o = "X-Passflow-DeviceId", s = "X-Passflow-DeviceType", c = r, l = [
|
|
5
5
|
"id",
|
|
6
6
|
"offline",
|
|
7
7
|
"openid"
|
|
@@ -587,24 +587,28 @@ var j = /* @__PURE__ */ function(e) {
|
|
|
587
587
|
}
|
|
588
588
|
}, je = /* @__PURE__ */ function(e) {
|
|
589
589
|
return e.google = "google", e.facebook = "facebook", e;
|
|
590
|
-
}({}), Me =
|
|
590
|
+
}({}), Me = Object.freeze([
|
|
591
|
+
"debug_otp_code_for_registration",
|
|
592
|
+
"fcm_server_key",
|
|
593
|
+
"webpush_vapid_private_key"
|
|
594
|
+
]), Ne = "mask://", Pe = "error.server.update.settings.masked.value.unknown", Fe = (e) => typeof e == "string" && e.startsWith("mask://"), Ie = /* @__PURE__ */ function(e) {
|
|
591
595
|
return e.web = "web", e.ios = "ios", e.android = "android", e;
|
|
592
596
|
}({});
|
|
593
|
-
function
|
|
597
|
+
function Le(e) {
|
|
594
598
|
return e;
|
|
595
599
|
}
|
|
596
|
-
function
|
|
600
|
+
function V(e, t) {
|
|
597
601
|
let n = e;
|
|
598
602
|
return Object.entries(t).forEach(([e, t]) => {
|
|
599
603
|
n = n.replace(`:${e}`, t);
|
|
600
604
|
}), n;
|
|
601
605
|
}
|
|
602
|
-
var
|
|
606
|
+
var Re = /* @__PURE__ */ function(e) {
|
|
603
607
|
return e.Disabled = "disabled", e.Optional = "optional", e.Required = "required", e;
|
|
604
|
-
}({}),
|
|
608
|
+
}({}), ze = 3, Be = 1e3, Ve = (e) => (t) => {
|
|
605
609
|
let n = e.headers?.[t] ?? e.headers?.[t.toLowerCase()];
|
|
606
610
|
return Array.isArray(n) ? n.join(", ") : n;
|
|
607
|
-
},
|
|
611
|
+
}, He = (e) => ye(e.status, Ve(e), e.data), Ue = (e) => He(e) !== void 0, We = (e) => e?.includes(z.refresh) ?? !1, Ge = (e) => e?.includes("logout") ?? !1, H = class {
|
|
608
612
|
get origin() {
|
|
609
613
|
return this._platform.getCurrentUrl()?.origin ?? "";
|
|
610
614
|
}
|
|
@@ -641,11 +645,11 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
641
645
|
let t = this.storageManager.getCsrfToken();
|
|
642
646
|
return t && (e.headers["X-CSRF-Token"] = t), e;
|
|
643
647
|
}
|
|
644
|
-
if (
|
|
648
|
+
if (We(e.url)) return e;
|
|
645
649
|
let t = this.storageManager.getTokens();
|
|
646
650
|
if (!t?.access_token) return e;
|
|
647
651
|
let n = t.access_token;
|
|
648
|
-
if (this.refreshHandler && t.refresh_token && !
|
|
652
|
+
if (this.refreshHandler && t.refresh_token && !Ge(e.url)) {
|
|
649
653
|
let e = A(t.access_token);
|
|
650
654
|
if (k(e, 30)) {
|
|
651
655
|
let t = !k(e, 0);
|
|
@@ -661,8 +665,8 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
661
665
|
}
|
|
662
666
|
return e.headers[a] = `Bearer ${n}`, e;
|
|
663
667
|
}), this.instance.interceptors.response.use((e) => e, async (e) => {
|
|
664
|
-
if (e.response?.status === 401 && !
|
|
665
|
-
let t =
|
|
668
|
+
if (e.response?.status === 401 && !We(e.config?.url) && !this.isUpgradeTransactionError(e) && this.tokenDeliveryManager.setSessionInvalid(), e.response && this.upgradeHandler) {
|
|
669
|
+
let t = He(e.response);
|
|
666
670
|
if (t) try {
|
|
667
671
|
return await this.upgradeHandler(e, t);
|
|
668
672
|
} catch (t) {
|
|
@@ -673,7 +677,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
673
677
|
});
|
|
674
678
|
}
|
|
675
679
|
isUpgradeTransactionError(e) {
|
|
676
|
-
return we(e.config) || e.response !== void 0 &&
|
|
680
|
+
return we(e.config) || e.response !== void 0 && Ue(e.response);
|
|
677
681
|
}
|
|
678
682
|
setUpgradeInterceptor(e) {
|
|
679
683
|
this.upgradeHandler = e;
|
|
@@ -695,7 +699,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
695
699
|
}
|
|
696
700
|
async handleRateLimitError(e) {
|
|
697
701
|
let t = e.config;
|
|
698
|
-
if (!t ||
|
|
702
|
+
if (!t || We(t.url)) return Promise.reject(e);
|
|
699
703
|
let n = t.method?.toUpperCase();
|
|
700
704
|
if (![
|
|
701
705
|
"GET",
|
|
@@ -703,8 +707,8 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
703
707
|
"OPTIONS"
|
|
704
708
|
].includes(n || "")) return Promise.reject(e);
|
|
705
709
|
let r = t._retryCount || 0;
|
|
706
|
-
if (r >=
|
|
707
|
-
let i =
|
|
710
|
+
if (r >= ze) return Promise.reject(e);
|
|
711
|
+
let i = Be * 2 ** r, a = e.response?.headers?.["retry-after"];
|
|
708
712
|
if (a) {
|
|
709
713
|
let e = Number.parseInt(a, 10);
|
|
710
714
|
if (!Number.isNaN(e)) i = e * 1e3;
|
|
@@ -767,9 +771,9 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
767
771
|
[i]: e
|
|
768
772
|
}, this.instance.defaults.headers.common[i] = e;
|
|
769
773
|
}
|
|
770
|
-
},
|
|
774
|
+
}, Ke = class {
|
|
771
775
|
constructor(e, t, n) {
|
|
772
|
-
this.axiosClient = new
|
|
776
|
+
this.axiosClient = new H(e, t, n);
|
|
773
777
|
}
|
|
774
778
|
setAppId(e) {
|
|
775
779
|
this.axiosClient.setAppId(e);
|
|
@@ -777,9 +781,9 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
777
781
|
getAppSettings() {
|
|
778
782
|
return this.axiosClient.get(z.appSettings);
|
|
779
783
|
}
|
|
780
|
-
},
|
|
784
|
+
}, qe = { withCredentials: !0 }, Je = class {
|
|
781
785
|
constructor(e, t, n) {
|
|
782
|
-
this.axiosClient = new
|
|
786
|
+
this.axiosClient = new H(e, t, n);
|
|
783
787
|
}
|
|
784
788
|
setAppId(e) {
|
|
785
789
|
this.axiosClient.setAppId(e);
|
|
@@ -798,7 +802,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
798
802
|
device: t,
|
|
799
803
|
os: n
|
|
800
804
|
};
|
|
801
|
-
return this.axiosClient.post(z.signin, r,
|
|
805
|
+
return this.axiosClient.post(z.signin, r, qe);
|
|
802
806
|
}
|
|
803
807
|
signUp(e) {
|
|
804
808
|
let { create_tenant: t, anonymous: n } = e, r = {
|
|
@@ -806,13 +810,13 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
806
810
|
create_tenant: t ?? !1,
|
|
807
811
|
anonymous: n ?? !1
|
|
808
812
|
};
|
|
809
|
-
return this.axiosClient.post(z.signup, r,
|
|
813
|
+
return this.axiosClient.post(z.signup, r, qe);
|
|
810
814
|
}
|
|
811
815
|
pkceExchange(e, t) {
|
|
812
816
|
return this.axiosClient.post(z.pkceExchange, {
|
|
813
817
|
authz_code: e,
|
|
814
818
|
verifier: t
|
|
815
|
-
},
|
|
819
|
+
}, qe);
|
|
816
820
|
}
|
|
817
821
|
passwordlessSignIn(e, t, n) {
|
|
818
822
|
let { create_tenant: r } = e, i = {
|
|
@@ -824,13 +828,13 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
824
828
|
return this.axiosClient.post(z.passwordless, i);
|
|
825
829
|
}
|
|
826
830
|
passwordlessSignInComplete(e) {
|
|
827
|
-
return this.axiosClient.post(z.passwordlessComplete, e,
|
|
831
|
+
return this.axiosClient.post(z.passwordlessComplete, e, qe);
|
|
828
832
|
}
|
|
829
833
|
validateEmailCode(e) {
|
|
830
834
|
return this.axiosClient.post(z.passkeyValidate, {
|
|
831
835
|
challenge_id: e.challenge_id,
|
|
832
836
|
otp: e.otp
|
|
833
|
-
},
|
|
837
|
+
}, qe);
|
|
834
838
|
}
|
|
835
839
|
logOut(e, t, n = !1) {
|
|
836
840
|
let r = n ? void 0 : {
|
|
@@ -871,7 +875,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
871
875
|
device: t,
|
|
872
876
|
passkey_data: e
|
|
873
877
|
}, a = r ? Oe.passkeyRegisterComplete : z.passkeyRegisterComplete;
|
|
874
|
-
return this.axiosClient.post(a, i,
|
|
878
|
+
return this.axiosClient.post(a, i, qe);
|
|
875
879
|
}
|
|
876
880
|
passkeyAuthenticateStart(e, t, n, r = !1) {
|
|
877
881
|
let i = {
|
|
@@ -888,7 +892,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
888
892
|
device: t,
|
|
889
893
|
passkey_data: e
|
|
890
894
|
}, a = r ? Oe.passkeyAuthenticateComplete : z.passkeyAuthenticateComplete;
|
|
891
|
-
return this.axiosClient.post(a, i,
|
|
895
|
+
return this.axiosClient.post(a, i, qe);
|
|
892
896
|
}
|
|
893
897
|
passkeyValidate(e, t, n, r = !1, a) {
|
|
894
898
|
let o = {
|
|
@@ -900,23 +904,23 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
900
904
|
let c = a ? { [i]: a } : {};
|
|
901
905
|
return this.axiosClient.post(s, o, { headers: c });
|
|
902
906
|
}
|
|
903
|
-
},
|
|
907
|
+
}, Ye = class {
|
|
904
908
|
constructor(e, t, n) {
|
|
905
|
-
this.axiosClient = new
|
|
909
|
+
this.axiosClient = new H(e, t, n);
|
|
906
910
|
}
|
|
907
911
|
setAppId(e) {
|
|
908
912
|
this.axiosClient.setAppId(e);
|
|
909
913
|
}
|
|
910
914
|
getCLIAuthStatus(e) {
|
|
911
|
-
let t =
|
|
915
|
+
let t = V(z.cliAuthStatus, { sessionId: e });
|
|
912
916
|
return this.axiosClient.get(t);
|
|
913
917
|
}
|
|
914
918
|
completeCLIAuth(e) {
|
|
915
919
|
return this.axiosClient.post(z.cliAuthComplete, e);
|
|
916
920
|
}
|
|
917
|
-
},
|
|
921
|
+
}, Xe = class {
|
|
918
922
|
constructor(e, t, n) {
|
|
919
|
-
this.axiosClient = new
|
|
923
|
+
this.axiosClient = new H(e, t, n);
|
|
920
924
|
}
|
|
921
925
|
setAppId(e) {
|
|
922
926
|
this.axiosClient.setAppId(e);
|
|
@@ -927,27 +931,27 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
927
931
|
getInvitations(e) {
|
|
928
932
|
let t = {};
|
|
929
933
|
e.groupID && (t.group_id = e.groupID.toString()), e.skip !== void 0 && (t.skip = e.skip.toString()), e.limit !== void 0 && (t.limit = e.limit.toString());
|
|
930
|
-
let n =
|
|
934
|
+
let n = V(z.invitationsPath, { tenantID: e.tenantID });
|
|
931
935
|
return this.axiosClient.get(n, { params: t }).then((e) => ({
|
|
932
936
|
invites: e.invites,
|
|
933
937
|
nextPageSkip: e.next_page_skip
|
|
934
938
|
}));
|
|
935
939
|
}
|
|
936
940
|
deleteInvitation(e) {
|
|
937
|
-
let t =
|
|
941
|
+
let t = V(z.invitationDelete, { invitationID: e });
|
|
938
942
|
return this.axiosClient.delete(t);
|
|
939
943
|
}
|
|
940
944
|
resendInvitation(e) {
|
|
941
|
-
let t =
|
|
945
|
+
let t = V(z.invitationResend, { invitationID: e });
|
|
942
946
|
return this.axiosClient.post(t, {});
|
|
943
947
|
}
|
|
944
948
|
getInvitationLink(e) {
|
|
945
|
-
let t =
|
|
949
|
+
let t = V(z.invitationGetLink, { invitationID: e });
|
|
946
950
|
return this.axiosClient.get(t);
|
|
947
951
|
}
|
|
948
|
-
},
|
|
952
|
+
}, Ze = class {
|
|
949
953
|
constructor(e, t, n) {
|
|
950
|
-
this.axiosClient = new
|
|
954
|
+
this.axiosClient = new H(e, t, n);
|
|
951
955
|
}
|
|
952
956
|
setAppId(e) {
|
|
953
957
|
this.axiosClient.setAppId(e);
|
|
@@ -961,9 +965,9 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
961
965
|
getPasskeySettings() {
|
|
962
966
|
return this.axiosClient.get(z.settingsPasskey);
|
|
963
967
|
}
|
|
964
|
-
},
|
|
968
|
+
}, Qe = class {
|
|
965
969
|
constructor(e, t, n) {
|
|
966
|
-
this.axiosClient = new
|
|
970
|
+
this.axiosClient = new H(e, t, n);
|
|
967
971
|
}
|
|
968
972
|
setAppId(e) {
|
|
969
973
|
this.axiosClient.setAppId(e);
|
|
@@ -1077,12 +1081,12 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1077
1081
|
let r = `${z.tenantPath}/${e}/group/${t}/invite/email/${n}`;
|
|
1078
1082
|
return this.axiosClient.delete(r);
|
|
1079
1083
|
}
|
|
1080
|
-
},
|
|
1084
|
+
}, $e = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, et = (e) => ({
|
|
1081
1085
|
withCredentials: !0,
|
|
1082
|
-
|
|
1083
|
-
}),
|
|
1086
|
+
...$e(e)
|
|
1087
|
+
}), tt = class {
|
|
1084
1088
|
constructor(e, t, n) {
|
|
1085
|
-
this.axiosClient = new
|
|
1089
|
+
this.axiosClient = new H(e, t, n);
|
|
1086
1090
|
}
|
|
1087
1091
|
setAppId(e) {
|
|
1088
1092
|
this.axiosClient.setAppId(e);
|
|
@@ -1101,14 +1105,14 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1101
1105
|
return this.axiosClient.post(z.twoFactorVerify, {
|
|
1102
1106
|
code: n,
|
|
1103
1107
|
...r ? { trust_device: !0 } : {}
|
|
1104
|
-
},
|
|
1108
|
+
}, et(t));
|
|
1105
1109
|
}
|
|
1106
1110
|
useRecoveryCode(e) {
|
|
1107
1111
|
let { tfa_token: t, recovery_code: n, trust_device: r } = e;
|
|
1108
1112
|
return this.axiosClient.post(z.twoFactorRecovery, {
|
|
1109
1113
|
recovery_code: n,
|
|
1110
1114
|
...r ? { trust_device: !0 } : {}
|
|
1111
|
-
},
|
|
1115
|
+
}, et(t));
|
|
1112
1116
|
}
|
|
1113
1117
|
disable(e) {
|
|
1114
1118
|
return this.axiosClient.delete(z.twoFactor, { data: e });
|
|
@@ -1185,32 +1189,32 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1185
1189
|
});
|
|
1186
1190
|
}
|
|
1187
1191
|
removeMethod(e) {
|
|
1188
|
-
let t =
|
|
1192
|
+
let t = V(z.TwoFactorMethodRemove, { id: e });
|
|
1189
1193
|
return this.axiosClient.delete(t);
|
|
1190
1194
|
}
|
|
1191
1195
|
requestChallenge(e, t) {
|
|
1192
|
-
return this.axiosClient.post(z.TwoFactorChallenge, e,
|
|
1196
|
+
return this.axiosClient.post(z.TwoFactorChallenge, e, $e(t));
|
|
1193
1197
|
}
|
|
1194
1198
|
verifyV2(e, t) {
|
|
1195
1199
|
let { trust_device: n, ...r } = e;
|
|
1196
1200
|
return this.axiosClient.post(z.TwoFactorVerifyV2, {
|
|
1197
1201
|
...r,
|
|
1198
1202
|
...n ? { trust_device: !0 } : {}
|
|
1199
|
-
},
|
|
1203
|
+
}, et(t));
|
|
1200
1204
|
}
|
|
1201
1205
|
switchToAlternative(e, t) {
|
|
1202
|
-
return this.axiosClient.post(z.TwoFactorAlternative, e,
|
|
1206
|
+
return this.axiosClient.post(z.TwoFactorAlternative, e, $e(t));
|
|
1203
1207
|
}
|
|
1204
1208
|
async getTrustedDevices() {
|
|
1205
1209
|
return (await this.axiosClient.get(z.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
|
|
1206
1210
|
}
|
|
1207
1211
|
revokeTrustedDevice(e) {
|
|
1208
|
-
let t =
|
|
1212
|
+
let t = V(z.TwoFactorTrustedDeviceRevoke, { id: e });
|
|
1209
1213
|
return this.axiosClient.delete(t);
|
|
1210
1214
|
}
|
|
1211
|
-
},
|
|
1215
|
+
}, nt = class {
|
|
1212
1216
|
constructor(e, t, n) {
|
|
1213
|
-
this.axiosClient = new
|
|
1217
|
+
this.axiosClient = new H(e, t, n);
|
|
1214
1218
|
}
|
|
1215
1219
|
setAppId(e) {
|
|
1216
1220
|
this.axiosClient.setAppId(e);
|
|
@@ -1218,9 +1222,9 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1218
1222
|
startUpgrade(e) {
|
|
1219
1223
|
return this.axiosClient.post(z.upgradeStart, e, Ce({}));
|
|
1220
1224
|
}
|
|
1221
|
-
},
|
|
1225
|
+
}, rt = class {
|
|
1222
1226
|
constructor(e, t, n) {
|
|
1223
|
-
this.axiosClient = new
|
|
1227
|
+
this.axiosClient = new H(e, t, n);
|
|
1224
1228
|
}
|
|
1225
1229
|
setAppId(e) {
|
|
1226
1230
|
this.axiosClient.setAppId(e);
|
|
@@ -1251,50 +1255,50 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1251
1255
|
passkey_data: e
|
|
1252
1256
|
});
|
|
1253
1257
|
}
|
|
1254
|
-
},
|
|
1258
|
+
}, it = 10, at = 20, ot = class extends Error {
|
|
1255
1259
|
constructor(e) {
|
|
1256
1260
|
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;
|
|
1257
1261
|
}
|
|
1258
|
-
},
|
|
1262
|
+
}, st = [], ct = 0, lt = !1, ut, dt, ft = (e, t) => e.priority - t.priority || e.seq - t.seq, pt = () => typeof globalThis > "u" ? void 0 : globalThis, mt = async (e, t, n, r) => {
|
|
1259
1263
|
if (t >= e.length) {
|
|
1260
|
-
let e =
|
|
1264
|
+
let e = ut;
|
|
1261
1265
|
if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
|
|
1262
1266
|
return e(n, r);
|
|
1263
1267
|
}
|
|
1264
1268
|
let i = e[t];
|
|
1265
|
-
if (!i) return
|
|
1266
|
-
let a = !1, o = await i.middleware((n, r) => (a = !0,
|
|
1267
|
-
if (!a) throw new
|
|
1269
|
+
if (!i) return mt(e, e.length, n, r);
|
|
1270
|
+
let a = !1, o = await i.middleware((n, r) => (a = !0, mt(e, t + 1, n, r)), n, r);
|
|
1271
|
+
if (!a) throw new ot(i.name);
|
|
1268
1272
|
return o;
|
|
1269
|
-
},
|
|
1270
|
-
let e =
|
|
1273
|
+
}, ht = () => {
|
|
1274
|
+
let e = pt();
|
|
1271
1275
|
if (!e || typeof e.fetch != "function") return !1;
|
|
1272
|
-
let t = e.fetch.bind(e), n = (e, t) =>
|
|
1273
|
-
return
|
|
1274
|
-
},
|
|
1275
|
-
let e =
|
|
1276
|
-
e &&
|
|
1277
|
-
},
|
|
1278
|
-
if (!
|
|
1276
|
+
let t = e.fetch.bind(e), n = (e, t) => mt([...st].sort(ft), 0, e, t);
|
|
1277
|
+
return ut = t, dt = n, e.fetch = n, lt = !0, !0;
|
|
1278
|
+
}, gt = () => {
|
|
1279
|
+
let e = pt();
|
|
1280
|
+
e && dt && e.fetch === dt && (ut && (e.fetch = ut), lt = !1, dt = void 0, ut = void 0);
|
|
1281
|
+
}, _t = (e, t) => {
|
|
1282
|
+
if (!lt && !ht()) return () => {};
|
|
1279
1283
|
let n = {
|
|
1280
1284
|
middleware: e,
|
|
1281
1285
|
name: t.name,
|
|
1282
1286
|
priority: t.priority,
|
|
1283
|
-
seq:
|
|
1287
|
+
seq: ct++
|
|
1284
1288
|
};
|
|
1285
|
-
|
|
1289
|
+
st.push(n);
|
|
1286
1290
|
let r = !1;
|
|
1287
1291
|
return () => {
|
|
1288
|
-
r || (r = !0,
|
|
1292
|
+
r || (r = !0, st = st.filter((e) => e !== n), st.length === 0 && gt());
|
|
1289
1293
|
};
|
|
1290
|
-
},
|
|
1291
|
-
let e =
|
|
1294
|
+
}, vt = () => {
|
|
1295
|
+
let e = pt();
|
|
1292
1296
|
return {
|
|
1293
|
-
installed:
|
|
1294
|
-
names: [...
|
|
1295
|
-
foreignPatch:
|
|
1297
|
+
installed: lt,
|
|
1298
|
+
names: [...st].sort(ft).map((e) => e.name),
|
|
1299
|
+
foreignPatch: lt && !!e && !!dt && e.fetch !== dt
|
|
1296
1300
|
};
|
|
1297
|
-
},
|
|
1301
|
+
}, U = class e extends Error {
|
|
1298
1302
|
constructor(t) {
|
|
1299
1303
|
super(t.message), this.name = "M2MError", this.code = t.code, this.status = t.status ?? 400, this.errorUri = t.errorUri, this.rateLimitInfo = t.rateLimitInfo, this.headers = t.headers, this.cause = t.cause, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this, e);
|
|
1300
1304
|
}
|
|
@@ -1363,7 +1367,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1363
1367
|
let e = `M2MError [${this.code}]: ${this.message}`;
|
|
1364
1368
|
return this.status && (e += ` (HTTP ${this.status})`), e;
|
|
1365
1369
|
}
|
|
1366
|
-
},
|
|
1370
|
+
}, yt = class extends U {
|
|
1367
1371
|
constructor(e, t) {
|
|
1368
1372
|
super({
|
|
1369
1373
|
code: "temporarily_unavailable",
|
|
@@ -1372,7 +1376,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1372
1376
|
cause: t
|
|
1373
1377
|
}), this.name = "M2MNetworkError";
|
|
1374
1378
|
}
|
|
1375
|
-
},
|
|
1379
|
+
}, bt = class extends U {
|
|
1376
1380
|
constructor(e, t) {
|
|
1377
1381
|
super({
|
|
1378
1382
|
code: "invalid_request",
|
|
@@ -1381,7 +1385,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1381
1385
|
cause: t
|
|
1382
1386
|
}), this.name = "M2MTokenParseError";
|
|
1383
1387
|
}
|
|
1384
|
-
},
|
|
1388
|
+
}, xt = class extends U {
|
|
1385
1389
|
constructor(e) {
|
|
1386
1390
|
super({
|
|
1387
1391
|
code: "invalid_request",
|
|
@@ -1389,7 +1393,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1389
1393
|
status: 400
|
|
1390
1394
|
}), this.name = "M2MConfigError";
|
|
1391
1395
|
}
|
|
1392
|
-
},
|
|
1396
|
+
}, St = {
|
|
1393
1397
|
InvalidRequest: "invalid_request",
|
|
1394
1398
|
InvalidClient: "invalid_client",
|
|
1395
1399
|
InvalidGrant: "invalid_grant",
|
|
@@ -1399,14 +1403,14 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1399
1403
|
RateLimitExceeded: "rate_limit_exceeded",
|
|
1400
1404
|
ServerError: "server_error",
|
|
1401
1405
|
TemporarilyUnavailable: "temporarily_unavailable"
|
|
1402
|
-
},
|
|
1406
|
+
}, Ct = {
|
|
1403
1407
|
TOKEN_ENDPOINT: "/oauth2/token",
|
|
1404
1408
|
TIMEOUT: 1e4,
|
|
1405
1409
|
RETRIES: 3,
|
|
1406
1410
|
RETRY_DELAY: 1e3,
|
|
1407
1411
|
REFRESH_THRESHOLD: 30,
|
|
1408
1412
|
CONTENT_TYPE: "application/x-www-form-urlencoded"
|
|
1409
|
-
},
|
|
1413
|
+
}, wt = class {
|
|
1410
1414
|
constructor() {
|
|
1411
1415
|
this.cache = /* @__PURE__ */ new Map();
|
|
1412
1416
|
}
|
|
@@ -1423,18 +1427,18 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1423
1427
|
delete(e) {
|
|
1424
1428
|
return this.cache.delete(e), Promise.resolve();
|
|
1425
1429
|
}
|
|
1426
|
-
},
|
|
1430
|
+
}, Tt = {
|
|
1427
1431
|
shouldRetry(e, t) {
|
|
1428
1432
|
return t >= 3 ? !1 : e.code === "server_error" || e.code === "temporarily_unavailable" || e.code === "rate_limit_exceeded" || e.status !== void 0 && e.status >= 500;
|
|
1429
1433
|
},
|
|
1430
1434
|
getDelay(e) {
|
|
1431
1435
|
return 2 ** (e - 1) * 1e3;
|
|
1432
1436
|
}
|
|
1433
|
-
},
|
|
1437
|
+
}, Et = class {
|
|
1434
1438
|
constructor(e) {
|
|
1435
|
-
if (!e.url) throw new
|
|
1436
|
-
if (!e.clientId) throw new
|
|
1437
|
-
if (!e.clientSecret) throw new
|
|
1439
|
+
if (!e.url) throw new xt("M2M client requires a URL");
|
|
1440
|
+
if (!e.clientId) throw new xt("M2M client requires a clientId");
|
|
1441
|
+
if (!e.clientSecret) throw new xt("M2M client requires a clientSecret");
|
|
1438
1442
|
let t = e.url.replace(/\/$/, "");
|
|
1439
1443
|
this.config = {
|
|
1440
1444
|
url: t,
|
|
@@ -1443,16 +1447,16 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1443
1447
|
scopes: e.scopes,
|
|
1444
1448
|
audience: e.audience,
|
|
1445
1449
|
autoRefresh: e.autoRefresh ?? !1,
|
|
1446
|
-
refreshThreshold: e.refreshThreshold ??
|
|
1447
|
-
timeout: e.timeout ??
|
|
1448
|
-
retries: e.retries ??
|
|
1449
|
-
retryDelay: e.retryDelay ??
|
|
1450
|
+
refreshThreshold: e.refreshThreshold ?? Ct.REFRESH_THRESHOLD,
|
|
1451
|
+
timeout: e.timeout ?? Ct.TIMEOUT,
|
|
1452
|
+
retries: e.retries ?? Ct.RETRIES,
|
|
1453
|
+
retryDelay: e.retryDelay ?? Ct.RETRY_DELAY,
|
|
1450
1454
|
retryStrategy: e.retryStrategy,
|
|
1451
1455
|
cache: e.cache,
|
|
1452
1456
|
onTokenRequest: e.onTokenRequest,
|
|
1453
1457
|
onTokenResponse: e.onTokenResponse,
|
|
1454
1458
|
onError: e.onError
|
|
1455
|
-
}, this.cache = e.cache ?? new
|
|
1459
|
+
}, this.cache = e.cache ?? new wt(), this.retryStrategy = e.retryStrategy ?? Tt, this.tokenEndpoint = `${t}${Ct.TOKEN_ENDPOINT}`;
|
|
1456
1460
|
}
|
|
1457
1461
|
getCacheKey(e, t) {
|
|
1458
1462
|
let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
|
|
@@ -1497,7 +1501,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1497
1501
|
let e = await fetch(this.tokenEndpoint, {
|
|
1498
1502
|
method: "POST",
|
|
1499
1503
|
headers: {
|
|
1500
|
-
"Content-Type":
|
|
1504
|
+
"Content-Type": Ct.CONTENT_TYPE,
|
|
1501
1505
|
Accept: "application/json"
|
|
1502
1506
|
},
|
|
1503
1507
|
body: t.toString(),
|
|
@@ -1510,7 +1514,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1510
1514
|
});
|
|
1511
1515
|
let a = await e.json();
|
|
1512
1516
|
if (!e.ok) {
|
|
1513
|
-
let t =
|
|
1517
|
+
let t = U.fromOAuthError({
|
|
1514
1518
|
error: a.error || "server_error",
|
|
1515
1519
|
error_description: a.error_description || a.message,
|
|
1516
1520
|
error_uri: a.error_uri
|
|
@@ -1522,7 +1526,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1522
1526
|
}
|
|
1523
1527
|
return a;
|
|
1524
1528
|
} catch (e) {
|
|
1525
|
-
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new
|
|
1529
|
+
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new yt(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new yt(`Network error: ${e.message}`, e) : e instanceof U ? e : U.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1526
1530
|
}
|
|
1527
1531
|
}
|
|
1528
1532
|
async executeWithRetry(e) {
|
|
@@ -1530,7 +1534,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1530
1534
|
for (let n = 1; n <= this.config.retries; n++) try {
|
|
1531
1535
|
return await e();
|
|
1532
1536
|
} catch (e) {
|
|
1533
|
-
if (!(e instanceof
|
|
1537
|
+
if (!(e instanceof U)) throw e;
|
|
1534
1538
|
if (t = e, n < this.config.retries && this.retryStrategy.shouldRetry({
|
|
1535
1539
|
code: e.code,
|
|
1536
1540
|
status: e.status
|
|
@@ -1541,7 +1545,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1541
1545
|
}
|
|
1542
1546
|
throw e;
|
|
1543
1547
|
}
|
|
1544
|
-
throw t ?? new
|
|
1548
|
+
throw t ?? new U({
|
|
1545
1549
|
code: "server_error",
|
|
1546
1550
|
message: "Request failed after retries"
|
|
1547
1551
|
});
|
|
@@ -1565,13 +1569,13 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1565
1569
|
parseToken(e) {
|
|
1566
1570
|
try {
|
|
1567
1571
|
let t = e.split(".");
|
|
1568
|
-
if (t.length !== 3) throw new
|
|
1572
|
+
if (t.length !== 3) throw new bt("Invalid JWT format: expected 3 parts");
|
|
1569
1573
|
let n = t[1];
|
|
1570
|
-
if (!n) throw new
|
|
1574
|
+
if (!n) throw new bt("Invalid JWT format: missing payload");
|
|
1571
1575
|
let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
|
|
1572
1576
|
return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
|
|
1573
1577
|
} catch (e) {
|
|
1574
|
-
throw e instanceof
|
|
1578
|
+
throw e instanceof bt ? e : new bt(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
1575
1579
|
}
|
|
1576
1580
|
}
|
|
1577
1581
|
clearCache() {
|
|
@@ -1586,19 +1590,19 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1586
1590
|
try {
|
|
1587
1591
|
let e = await fetch(t, {
|
|
1588
1592
|
method: "POST",
|
|
1589
|
-
headers: { "Content-Type":
|
|
1593
|
+
headers: { "Content-Type": Ct.CONTENT_TYPE },
|
|
1590
1594
|
body: n.toString()
|
|
1591
1595
|
});
|
|
1592
1596
|
if (!e.ok && e.status !== 200) {
|
|
1593
1597
|
let t = await e.json().catch(() => ({}));
|
|
1594
|
-
throw
|
|
1598
|
+
throw U.fromOAuthError({
|
|
1595
1599
|
error: t.error || "server_error",
|
|
1596
1600
|
error_description: t.error_description || "Token revocation failed"
|
|
1597
1601
|
}, e.status);
|
|
1598
1602
|
}
|
|
1599
1603
|
this.clearCache();
|
|
1600
1604
|
} catch (e) {
|
|
1601
|
-
throw e instanceof
|
|
1605
|
+
throw e instanceof U ? e : U.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1602
1606
|
}
|
|
1603
1607
|
}
|
|
1604
1608
|
get url() {
|
|
@@ -1613,101 +1617,101 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1613
1617
|
get audience() {
|
|
1614
1618
|
return this.config.audience;
|
|
1615
1619
|
}
|
|
1616
|
-
},
|
|
1620
|
+
}, Dt = "error", Ot = /* @__PURE__ */ new WeakMap(), kt = (e, t) => {
|
|
1617
1621
|
if (typeof t != "object" && typeof t != "function" || t === null) return !0;
|
|
1618
|
-
let n =
|
|
1619
|
-
return n || (n = /* @__PURE__ */ new WeakSet(),
|
|
1620
|
-
},
|
|
1622
|
+
let n = Ot.get(e);
|
|
1623
|
+
return n || (n = /* @__PURE__ */ new WeakSet(), Ot.set(e, n)), !n.has(t) && (n.add(t), !0);
|
|
1624
|
+
}, W = (e, t) => kt(e, t.originalError) ? (e.notify(Dt, t), !0) : !1, At = "passflow-refresh", jt = "passflow-refresh-takeover", Mt = "passflow-auth", Nt = Object.freeze([
|
|
1621
1625
|
1e3,
|
|
1622
1626
|
3e3,
|
|
1623
1627
|
1e4,
|
|
1624
1628
|
3e4,
|
|
1625
1629
|
6e4
|
|
1626
|
-
]),
|
|
1630
|
+
]), Pt = .2, Ft = 6e5, It = 5e3, G = 2e4, Lt = 2e4, Rt = 1e3, zt = 2e3, Bt = 1e3, Vt = 1e4, Ht = 5e3;
|
|
1627
1631
|
// lib/refresh/protocol.ts
|
|
1628
|
-
function
|
|
1632
|
+
function Ut(e) {
|
|
1629
1633
|
let t = e ? `:${e}` : "";
|
|
1630
1634
|
return {
|
|
1631
|
-
lock: `${
|
|
1632
|
-
takeoverLock: `${
|
|
1633
|
-
channel: `${
|
|
1635
|
+
lock: `${At}${t}`,
|
|
1636
|
+
takeoverLock: `${jt}${t}`,
|
|
1637
|
+
channel: `${Mt}${t}`
|
|
1634
1638
|
};
|
|
1635
1639
|
}
|
|
1636
|
-
function
|
|
1640
|
+
function K(e) {
|
|
1637
1641
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
1638
1642
|
}
|
|
1639
|
-
function
|
|
1643
|
+
function Wt(e) {
|
|
1640
1644
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
1641
1645
|
}
|
|
1642
|
-
function
|
|
1646
|
+
function Gt(e) {
|
|
1643
1647
|
return typeof e == "object" && !!e;
|
|
1644
1648
|
}
|
|
1645
|
-
function
|
|
1649
|
+
function Kt(e, t) {
|
|
1646
1650
|
for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
|
|
1647
1651
|
return e;
|
|
1648
1652
|
}
|
|
1649
|
-
function
|
|
1650
|
-
if (!
|
|
1653
|
+
function qt(e) {
|
|
1654
|
+
if (!Gt(e)) return null;
|
|
1651
1655
|
let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
|
|
1652
|
-
return
|
|
1653
|
-
access_token:
|
|
1654
|
-
refresh_token:
|
|
1655
|
-
id_token:
|
|
1656
|
+
return Kt({}, {
|
|
1657
|
+
access_token: K(e.access_token),
|
|
1658
|
+
refresh_token: K(e.refresh_token),
|
|
1659
|
+
id_token: K(e.id_token),
|
|
1656
1660
|
scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
|
|
1657
1661
|
});
|
|
1658
1662
|
}
|
|
1659
|
-
function
|
|
1660
|
-
if (!
|
|
1663
|
+
function Jt(e) {
|
|
1664
|
+
if (!Gt(e)) return null;
|
|
1661
1665
|
let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
|
|
1662
|
-
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 ||
|
|
1666
|
+
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || Wt(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Kt({
|
|
1663
1667
|
kind: t,
|
|
1664
1668
|
attempt: n,
|
|
1665
1669
|
nextAt: r,
|
|
1666
1670
|
strikes: i
|
|
1667
1671
|
}, {
|
|
1668
|
-
from:
|
|
1669
|
-
failingSince:
|
|
1672
|
+
from: K(e.from),
|
|
1673
|
+
failingSince: Wt(e.failingSince)
|
|
1670
1674
|
});
|
|
1671
1675
|
}
|
|
1672
|
-
function
|
|
1673
|
-
return
|
|
1674
|
-
fp:
|
|
1675
|
-
sub:
|
|
1676
|
-
sid:
|
|
1677
|
-
iat:
|
|
1676
|
+
function Yt(e) {
|
|
1677
|
+
return Kt({}, {
|
|
1678
|
+
fp: K(e.fp),
|
|
1679
|
+
sub: K(e.sub),
|
|
1680
|
+
sid: K(e.sid),
|
|
1681
|
+
iat: Wt(e.iat)
|
|
1678
1682
|
});
|
|
1679
1683
|
}
|
|
1680
|
-
function
|
|
1681
|
-
if (!
|
|
1684
|
+
function Xt(e) {
|
|
1685
|
+
if (!Gt(e)) return null;
|
|
1682
1686
|
let t = e;
|
|
1683
1687
|
if (t.v !== void 0 && t.v !== 1) return null;
|
|
1684
|
-
let n =
|
|
1688
|
+
let n = K(t.tabId);
|
|
1685
1689
|
if (!n) return null;
|
|
1686
1690
|
switch (t.type) {
|
|
1687
1691
|
case "tokens-refreshed": {
|
|
1688
|
-
let e =
|
|
1689
|
-
return !e || !r || !i ? null :
|
|
1692
|
+
let e = qt(t.tokens), r = K(t.from), i = K(t.to);
|
|
1693
|
+
return !e || !r || !i ? null : Kt({
|
|
1690
1694
|
type: t.type,
|
|
1691
1695
|
tabId: n,
|
|
1692
1696
|
tokens: e,
|
|
1693
1697
|
from: r,
|
|
1694
1698
|
to: i
|
|
1695
1699
|
}, {
|
|
1696
|
-
fromIat:
|
|
1700
|
+
fromIat: Wt(t.fromIat),
|
|
1697
1701
|
fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
|
|
1698
|
-
sentAt:
|
|
1702
|
+
sentAt: Wt(t.sentAt)
|
|
1699
1703
|
});
|
|
1700
1704
|
}
|
|
1701
1705
|
case "session-refreshed": {
|
|
1702
|
-
let e =
|
|
1703
|
-
return e === void 0 ? null :
|
|
1706
|
+
let e = Wt(t.at);
|
|
1707
|
+
return e === void 0 ? null : Kt({
|
|
1704
1708
|
type: t.type,
|
|
1705
1709
|
tabId: n,
|
|
1706
1710
|
at: e
|
|
1707
|
-
}, { sub:
|
|
1711
|
+
}, { sub: K(t.sub) });
|
|
1708
1712
|
}
|
|
1709
1713
|
case "still-refreshing": {
|
|
1710
|
-
let e = t.retry === void 0 ? null :
|
|
1714
|
+
let e = t.retry === void 0 ? null : Jt(t.retry);
|
|
1711
1715
|
return e ? {
|
|
1712
1716
|
type: t.type,
|
|
1713
1717
|
tabId: n,
|
|
@@ -1718,7 +1722,7 @@ function qt(e) {
|
|
|
1718
1722
|
};
|
|
1719
1723
|
}
|
|
1720
1724
|
case "retry-scheduled": {
|
|
1721
|
-
let e =
|
|
1725
|
+
let e = Jt(t);
|
|
1722
1726
|
return e ? {
|
|
1723
1727
|
type: t.type,
|
|
1724
1728
|
tabId: n,
|
|
@@ -1739,10 +1743,10 @@ function qt(e) {
|
|
|
1739
1743
|
case "signed-out": return {
|
|
1740
1744
|
type: t.type,
|
|
1741
1745
|
tabId: n,
|
|
1742
|
-
...
|
|
1746
|
+
...Yt(t)
|
|
1743
1747
|
};
|
|
1744
1748
|
case "rate-limited": {
|
|
1745
|
-
let e =
|
|
1749
|
+
let e = Wt(t.until);
|
|
1746
1750
|
return e === void 0 ? null : {
|
|
1747
1751
|
type: t.type,
|
|
1748
1752
|
tabId: n,
|
|
@@ -1750,7 +1754,7 @@ function qt(e) {
|
|
|
1750
1754
|
};
|
|
1751
1755
|
}
|
|
1752
1756
|
case "refresh-failed": {
|
|
1753
|
-
let e =
|
|
1757
|
+
let e = K(t.from);
|
|
1754
1758
|
return e ? {
|
|
1755
1759
|
type: t.type,
|
|
1756
1760
|
tabId: n,
|
|
@@ -1761,22 +1765,22 @@ function qt(e) {
|
|
|
1761
1765
|
default: return null;
|
|
1762
1766
|
}
|
|
1763
1767
|
}
|
|
1764
|
-
function
|
|
1768
|
+
function Zt(e, t) {
|
|
1765
1769
|
let n = {
|
|
1766
1770
|
v: 1,
|
|
1767
1771
|
tabId: e
|
|
1768
1772
|
};
|
|
1769
1773
|
if (t.type === "retry-scheduled") {
|
|
1770
1774
|
let { retry: e, ...r } = t;
|
|
1771
|
-
return
|
|
1775
|
+
return Kt(n, {
|
|
1772
1776
|
...r,
|
|
1773
1777
|
...e
|
|
1774
1778
|
});
|
|
1775
1779
|
}
|
|
1776
|
-
return
|
|
1780
|
+
return Kt(n, { ...t });
|
|
1777
1781
|
}
|
|
1778
1782
|
// lib/refresh/resolve.ts
|
|
1779
|
-
var
|
|
1783
|
+
var Qt = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", $t = {
|
|
1780
1784
|
now: () => Date.now(),
|
|
1781
1785
|
random: () => Math.random(),
|
|
1782
1786
|
setTimeout: (e, t) => {
|
|
@@ -1784,28 +1788,28 @@ var Yt = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
|
|
|
1784
1788
|
return n.unref?.(), () => clearTimeout(n);
|
|
1785
1789
|
}
|
|
1786
1790
|
};
|
|
1787
|
-
function
|
|
1791
|
+
function en() {
|
|
1788
1792
|
let e = globalThis.crypto;
|
|
1789
1793
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
1790
1794
|
}
|
|
1791
|
-
function
|
|
1795
|
+
function tn(e) {
|
|
1792
1796
|
return e ? {
|
|
1793
1797
|
now: () => e.now(),
|
|
1794
1798
|
setTimeout: (t, n) => e.setTimeout(t, n),
|
|
1795
|
-
random: e.random ? () => e.random?.() ?? Math.random() :
|
|
1796
|
-
} :
|
|
1799
|
+
random: e.random ? () => e.random?.() ?? Math.random() : $t.random
|
|
1800
|
+
} : $t;
|
|
1797
1801
|
}
|
|
1798
|
-
function
|
|
1802
|
+
function nn(e) {
|
|
1799
1803
|
return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
|
|
1800
1804
|
}
|
|
1801
|
-
function
|
|
1805
|
+
function rn(e) {
|
|
1802
1806
|
try {
|
|
1803
1807
|
return e.storageSharedAcrossTabs === !0;
|
|
1804
1808
|
} catch {
|
|
1805
1809
|
return !1;
|
|
1806
1810
|
}
|
|
1807
1811
|
}
|
|
1808
|
-
function
|
|
1812
|
+
function an() {
|
|
1809
1813
|
try {
|
|
1810
1814
|
let e = globalThis.navigator?.locks;
|
|
1811
1815
|
return e && typeof e.request == "function" ? e : void 0;
|
|
@@ -1813,7 +1817,7 @@ function tn() {
|
|
|
1813
1817
|
return;
|
|
1814
1818
|
}
|
|
1815
1819
|
}
|
|
1816
|
-
function
|
|
1820
|
+
function on(e) {
|
|
1817
1821
|
return (t) => {
|
|
1818
1822
|
let n = (n) => {
|
|
1819
1823
|
let r = n.key;
|
|
@@ -1822,20 +1826,20 @@ function nn(e) {
|
|
|
1822
1826
|
return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
|
|
1823
1827
|
};
|
|
1824
1828
|
}
|
|
1825
|
-
function
|
|
1829
|
+
function sn(e) {
|
|
1826
1830
|
return {
|
|
1827
1831
|
transports: null,
|
|
1828
|
-
names:
|
|
1829
|
-
clock:
|
|
1832
|
+
names: Ut(e),
|
|
1833
|
+
clock: $t,
|
|
1830
1834
|
warnOnFirstCycle: !1
|
|
1831
1835
|
};
|
|
1832
1836
|
}
|
|
1833
|
-
function
|
|
1834
|
-
let i =
|
|
1837
|
+
function cn(e, t, n, r) {
|
|
1838
|
+
let i = Ut(n), a = nn(t), o = a ? on(r.tokenKeys) : void 0, s = (e) => {
|
|
1835
1839
|
let t = {
|
|
1836
1840
|
transports: null,
|
|
1837
1841
|
names: i,
|
|
1838
|
-
clock:
|
|
1842
|
+
clock: $t,
|
|
1839
1843
|
warnOnFirstCycle: e
|
|
1840
1844
|
};
|
|
1841
1845
|
return o && (t.onStorageChange = o), t;
|
|
@@ -1845,16 +1849,16 @@ function an(e, t, n, r) {
|
|
|
1845
1849
|
transports: {
|
|
1846
1850
|
locks: e.locks,
|
|
1847
1851
|
channel: e.channel,
|
|
1848
|
-
tabId: e.tabId ??
|
|
1852
|
+
tabId: e.tabId ?? en()
|
|
1849
1853
|
},
|
|
1850
1854
|
names: i,
|
|
1851
|
-
clock:
|
|
1855
|
+
clock: tn(e.clock),
|
|
1852
1856
|
warnOnFirstCycle: !1
|
|
1853
1857
|
};
|
|
1854
1858
|
return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
|
|
1855
1859
|
}
|
|
1856
|
-
if (e === "none" || !a || !
|
|
1857
|
-
let c =
|
|
1860
|
+
if (e === "none" || !a || !rn(t)) return s(!1);
|
|
1861
|
+
let c = an();
|
|
1858
1862
|
if (!c || typeof BroadcastChannel != "function") return s(!0);
|
|
1859
1863
|
let l;
|
|
1860
1864
|
try {
|
|
@@ -1866,36 +1870,36 @@ function an(e, t, n, r) {
|
|
|
1866
1870
|
transports: {
|
|
1867
1871
|
locks: c,
|
|
1868
1872
|
channel: l,
|
|
1869
|
-
tabId:
|
|
1873
|
+
tabId: en()
|
|
1870
1874
|
},
|
|
1871
1875
|
names: i,
|
|
1872
|
-
clock:
|
|
1876
|
+
clock: $t,
|
|
1873
1877
|
warnOnFirstCycle: !1
|
|
1874
1878
|
};
|
|
1875
1879
|
return o && (u.onStorageChange = o), u;
|
|
1876
1880
|
}
|
|
1877
1881
|
// lib/pkce.ts
|
|
1878
|
-
var
|
|
1882
|
+
var ln = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", un = 32, dn = (e) => {
|
|
1879
1883
|
let t = "";
|
|
1880
1884
|
for (let n = 0; n < e.length; n += 3) {
|
|
1881
1885
|
let r = e[n], i = e[n + 1], a = e[n + 2];
|
|
1882
|
-
t +=
|
|
1886
|
+
t += ln.charAt(r >> 2), t += ln.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += ln.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += ln.charAt(a & 63));
|
|
1883
1887
|
}
|
|
1884
1888
|
return t;
|
|
1885
|
-
},
|
|
1889
|
+
}, fn = () => {
|
|
1886
1890
|
let e = globalThis.crypto;
|
|
1887
1891
|
if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1888
1892
|
return e;
|
|
1889
|
-
},
|
|
1890
|
-
let t = await
|
|
1891
|
-
return
|
|
1892
|
-
},
|
|
1893
|
-
let e =
|
|
1893
|
+
}, pn = async (e) => {
|
|
1894
|
+
let t = await fn().subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
1895
|
+
return dn(new Uint8Array(t));
|
|
1896
|
+
}, mn = async () => {
|
|
1897
|
+
let e = dn(fn().getRandomValues(new Uint8Array(un)));
|
|
1894
1898
|
return {
|
|
1895
1899
|
verifier: e,
|
|
1896
|
-
challenge: await
|
|
1900
|
+
challenge: await pn(e)
|
|
1897
1901
|
};
|
|
1898
|
-
},
|
|
1902
|
+
}, hn = class {
|
|
1899
1903
|
error(e, ...t) {
|
|
1900
1904
|
console.error(e, ...t);
|
|
1901
1905
|
}
|
|
@@ -1909,10 +1913,10 @@ var on = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", sn
|
|
|
1909
1913
|
console.debug(e, ...t);
|
|
1910
1914
|
}
|
|
1911
1915
|
};
|
|
1912
|
-
function
|
|
1913
|
-
return new
|
|
1916
|
+
function gn() {
|
|
1917
|
+
return new hn();
|
|
1914
1918
|
}
|
|
1915
|
-
var
|
|
1919
|
+
var _n = Object.freeze([
|
|
1916
1920
|
"error.token.invalid.error",
|
|
1917
1921
|
"error.api.token.parse.error",
|
|
1918
1922
|
"error.api.user.blocked",
|
|
@@ -1920,25 +1924,25 @@ var mn = Object.freeze([
|
|
|
1920
1924
|
"error.validation.token.invalid.subject",
|
|
1921
1925
|
"error.not.found"
|
|
1922
1926
|
]);
|
|
1923
|
-
function
|
|
1927
|
+
function vn(e) {
|
|
1924
1928
|
if (typeof e != "object" || !e) return;
|
|
1925
1929
|
let t = e;
|
|
1926
1930
|
return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
|
|
1927
1931
|
}
|
|
1928
|
-
function
|
|
1929
|
-
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(
|
|
1932
|
+
function yn(e, t) {
|
|
1933
|
+
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(Ft, Math.floor(e) * 1e3);
|
|
1930
1934
|
if (typeof e != "string") return;
|
|
1931
1935
|
let n = e.trim();
|
|
1932
1936
|
if (n === "") return;
|
|
1933
|
-
if (/^\d+$/.test(n)) return Math.min(
|
|
1937
|
+
if (/^\d+$/.test(n)) return Math.min(Ft, Number.parseInt(n, 10) * 1e3);
|
|
1934
1938
|
if (!/[a-z]/i.test(n)) return;
|
|
1935
1939
|
let r = Date.parse(n);
|
|
1936
|
-
if (!Number.isNaN(r)) return Math.min(
|
|
1940
|
+
if (!Number.isNaN(r)) return Math.min(Ft, Math.max(0, r - t));
|
|
1937
1941
|
}
|
|
1938
|
-
function
|
|
1942
|
+
function bn(e) {
|
|
1939
1943
|
return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
|
|
1940
1944
|
}
|
|
1941
|
-
function
|
|
1945
|
+
function xn(e) {
|
|
1942
1946
|
if (typeof e.id == "string" && e.id !== "") return e.id;
|
|
1943
1947
|
let t = e.response?.data;
|
|
1944
1948
|
if (typeof t != "object" || !t) return;
|
|
@@ -1947,14 +1951,14 @@ function vn(e) {
|
|
|
1947
1951
|
let r = n.id;
|
|
1948
1952
|
return typeof r == "string" && r !== "" ? r : void 0;
|
|
1949
1953
|
}
|
|
1950
|
-
function
|
|
1954
|
+
function Sn(e, t = Date.now()) {
|
|
1951
1955
|
if (typeof e != "object" || !e) return { kind: "transient" };
|
|
1952
|
-
let n = e, r =
|
|
1956
|
+
let n = e, r = xn(n), i = bn(n.response?.status) ?? bn(n.status), a = {};
|
|
1953
1957
|
if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
|
|
1954
1958
|
kind: "blocked",
|
|
1955
1959
|
...a
|
|
1956
1960
|
};
|
|
1957
|
-
if (r !== void 0 &&
|
|
1961
|
+
if (r !== void 0 && _n.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
|
|
1958
1962
|
kind: "auth",
|
|
1959
1963
|
...a
|
|
1960
1964
|
};
|
|
@@ -1962,7 +1966,7 @@ function yn(e, t = Date.now()) {
|
|
|
1962
1966
|
kind: "transient",
|
|
1963
1967
|
...a
|
|
1964
1968
|
};
|
|
1965
|
-
let o =
|
|
1969
|
+
let o = yn(n.retryAfter ?? vn(n.response?.headers), t);
|
|
1966
1970
|
return o === void 0 ? {
|
|
1967
1971
|
kind: "transient",
|
|
1968
1972
|
...a
|
|
@@ -1972,19 +1976,19 @@ function yn(e, t = Date.now()) {
|
|
|
1972
1976
|
retryAfterMs: o
|
|
1973
1977
|
};
|
|
1974
1978
|
}
|
|
1975
|
-
function
|
|
1976
|
-
let r =
|
|
1977
|
-
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0),
|
|
1979
|
+
function Cn(e, t, n) {
|
|
1980
|
+
let r = Nt.length, i = Nt[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? Nt[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * Pt * a);
|
|
1981
|
+
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), Ft) : 0);
|
|
1978
1982
|
}
|
|
1979
1983
|
// lib/refresh/coordinator.ts
|
|
1980
|
-
var
|
|
1984
|
+
var wn = {
|
|
1981
1985
|
onGranted: () => !1,
|
|
1982
1986
|
onLockLost: () => void 0,
|
|
1983
1987
|
onMessage: () => void 0
|
|
1984
1988
|
};
|
|
1985
|
-
function
|
|
1986
|
-
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o =
|
|
1987
|
-
g || n.postMessage(
|
|
1989
|
+
function Tn(e) {
|
|
1990
|
+
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = wn, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
|
|
1991
|
+
g || n.postMessage(Zt(r, e));
|
|
1988
1992
|
}, v = () => s !== null && c === null, y = () => {
|
|
1989
1993
|
f?.(), f = null;
|
|
1990
1994
|
}, b = (e) => {
|
|
@@ -1999,7 +2003,7 @@ function Sn(e) {
|
|
|
1999
2003
|
type: "still-refreshing",
|
|
2000
2004
|
retry: m
|
|
2001
2005
|
} : { type: "still-refreshing" }), S());
|
|
2002
|
-
},
|
|
2006
|
+
}, It);
|
|
2003
2007
|
}, C = () => {
|
|
2004
2008
|
y(), x(), u?.(), u = null;
|
|
2005
2009
|
let e = s;
|
|
@@ -2040,29 +2044,29 @@ function Sn(e) {
|
|
|
2040
2044
|
let e = s;
|
|
2041
2045
|
t.request(i.takeoverLock, { ifAvailable: !0 }, (t) => {
|
|
2042
2046
|
if (s === e && v()) {
|
|
2043
|
-
if (t === null) b(a.now() +
|
|
2047
|
+
if (t === null) b(a.now() + G);
|
|
2044
2048
|
else return _({ type: "takeover" }), new Promise((t) => {
|
|
2045
2049
|
u = t, e && (e.dead = !0, e.abort.abort()), D(!0);
|
|
2046
2050
|
});
|
|
2047
2051
|
}
|
|
2048
2052
|
}).catch(() => {
|
|
2049
|
-
v() && b(a.now() +
|
|
2053
|
+
v() && b(a.now() + G);
|
|
2050
2054
|
});
|
|
2051
2055
|
}, ee = (e) => {
|
|
2052
2056
|
if (g) return;
|
|
2053
|
-
let t =
|
|
2057
|
+
let t = Xt(e.data);
|
|
2054
2058
|
if (t && t.tabId !== r) {
|
|
2055
2059
|
switch (t.type) {
|
|
2056
2060
|
case "still-refreshing":
|
|
2057
|
-
h = !0, v() && (b(a.now() +
|
|
2061
|
+
h = !0, v() && (b(a.now() + G), t.retry && b(t.retry.nextAt + G));
|
|
2058
2062
|
break;
|
|
2059
2063
|
case "takeover":
|
|
2060
|
-
h = !0, v() && b(a.now() +
|
|
2064
|
+
h = !0, v() && b(a.now() + G);
|
|
2061
2065
|
break;
|
|
2062
2066
|
case "retry-scheduled":
|
|
2063
|
-
h = !0, v() && b(Math.max(a.now(), t.retry.nextAt) +
|
|
2067
|
+
h = !0, v() && b(Math.max(a.now(), t.retry.nextAt) + G);
|
|
2064
2068
|
break;
|
|
2065
|
-
case "rate-limited": v() && b(t.until +
|
|
2069
|
+
case "rate-limited": v() && b(t.until + G);
|
|
2066
2070
|
}
|
|
2067
2071
|
o.onMessage(t);
|
|
2068
2072
|
}
|
|
@@ -2080,7 +2084,7 @@ function Sn(e) {
|
|
|
2080
2084
|
o = e;
|
|
2081
2085
|
},
|
|
2082
2086
|
request: (e) => {
|
|
2083
|
-
g || s || (p = 0, b(Math.max(a.now() +
|
|
2087
|
+
g || s || (p = 0, b(Math.max(a.now() + G, e ?? 0)), D(!1));
|
|
2084
2088
|
},
|
|
2085
2089
|
release: C,
|
|
2086
2090
|
post: _,
|
|
@@ -2093,8 +2097,8 @@ function Sn(e) {
|
|
|
2093
2097
|
}
|
|
2094
2098
|
};
|
|
2095
2099
|
}
|
|
2096
|
-
function
|
|
2097
|
-
let t =
|
|
2100
|
+
function En(e = "local") {
|
|
2101
|
+
let t = wn, n = !1, r = !1, i = 0, a = !1, o = () => {
|
|
2098
2102
|
n = !1, r = !1, i += 1;
|
|
2099
2103
|
};
|
|
2100
2104
|
return {
|
|
@@ -2134,7 +2138,7 @@ function Cn(e = "local") {
|
|
|
2134
2138
|
};
|
|
2135
2139
|
}
|
|
2136
2140
|
// lib/refresh/errors.ts
|
|
2137
|
-
var
|
|
2141
|
+
var q = {
|
|
2138
2142
|
unavailable: "error.refresh.unavailable",
|
|
2139
2143
|
authRetry: "error.refresh.auth_retry",
|
|
2140
2144
|
sessionEnded: "error.refresh.session_ended",
|
|
@@ -2142,7 +2146,7 @@ var K = {
|
|
|
2142
2146
|
successorTimeout: "error.refresh.successor_timeout",
|
|
2143
2147
|
identityChanged: "error.refresh.identity_changed",
|
|
2144
2148
|
disposed: "error.refresh.disposed"
|
|
2145
|
-
},
|
|
2149
|
+
}, Dn = {
|
|
2146
2150
|
"error.refresh.unavailable": 503,
|
|
2147
2151
|
"error.refresh.auth_retry": 401,
|
|
2148
2152
|
"error.refresh.session_ended": 401,
|
|
@@ -2150,7 +2154,7 @@ var K = {
|
|
|
2150
2154
|
"error.refresh.successor_timeout": 401,
|
|
2151
2155
|
"error.refresh.identity_changed": 401,
|
|
2152
2156
|
"error.refresh.disposed": 499
|
|
2153
|
-
},
|
|
2157
|
+
}, On = {
|
|
2154
2158
|
"error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
|
|
2155
2159
|
"error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
|
|
2156
2160
|
"error.refresh.session_ended": "The session has ended",
|
|
@@ -2158,23 +2162,23 @@ var K = {
|
|
|
2158
2162
|
"error.refresh.successor_timeout": "The refresh token was already used and no successor arrived",
|
|
2159
2163
|
"error.refresh.identity_changed": "Storage holds another user's tokens",
|
|
2160
2164
|
"error.refresh.disposed": "The Passflow instance was disposed"
|
|
2161
|
-
},
|
|
2165
|
+
}, J = class extends B {
|
|
2162
2166
|
constructor(e, t = {}) {
|
|
2163
2167
|
super({
|
|
2164
2168
|
id: e,
|
|
2165
|
-
message: t.message ??
|
|
2166
|
-
status:
|
|
2169
|
+
message: t.message ?? On[e],
|
|
2170
|
+
status: Dn[e],
|
|
2167
2171
|
location: "/auth/refresh",
|
|
2168
2172
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2169
2173
|
}), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
|
|
2170
2174
|
}
|
|
2171
|
-
},
|
|
2175
|
+
}, kn = class extends Error {
|
|
2172
2176
|
constructor(e, t) {
|
|
2173
2177
|
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;
|
|
2174
2178
|
}
|
|
2175
2179
|
};
|
|
2176
2180
|
// lib/refresh/lineage.ts
|
|
2177
|
-
function
|
|
2181
|
+
function An(e) {
|
|
2178
2182
|
if (!e) return;
|
|
2179
2183
|
let t = 3735928559, n = 1103547991;
|
|
2180
2184
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -2183,24 +2187,24 @@ function J(e) {
|
|
|
2183
2187
|
}
|
|
2184
2188
|
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);
|
|
2185
2189
|
}
|
|
2186
|
-
function
|
|
2190
|
+
function jn(e) {
|
|
2187
2191
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2188
2192
|
}
|
|
2189
2193
|
function Y(e) {
|
|
2190
|
-
let t =
|
|
2194
|
+
let t = An(e);
|
|
2191
2195
|
if (!e || !t) return;
|
|
2192
2196
|
let n = {};
|
|
2193
2197
|
try {
|
|
2194
2198
|
let t = A(e);
|
|
2195
2199
|
typeof t == "object" && t && (n = t);
|
|
2196
2200
|
} catch {}
|
|
2197
|
-
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a =
|
|
2201
|
+
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = jn(n.sub), o = jn(n.sid);
|
|
2198
2202
|
return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
|
|
2199
2203
|
}
|
|
2200
|
-
var
|
|
2201
|
-
function
|
|
2204
|
+
var Mn = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
|
|
2205
|
+
function Nn(e = (e) => gn().warn(e)) {
|
|
2202
2206
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
|
|
2203
|
-
a || (a = !0, e(
|
|
2207
|
+
a || (a = !0, e(Mn));
|
|
2204
2208
|
}, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
|
|
2205
2209
|
if (!e) return;
|
|
2206
2210
|
if (e.iat === void 0) {
|
|
@@ -2241,16 +2245,16 @@ function kn(e = (e) => pn().warn(e)) {
|
|
|
2241
2245
|
};
|
|
2242
2246
|
}
|
|
2243
2247
|
// lib/refresh/fence.ts
|
|
2244
|
-
var
|
|
2248
|
+
var Pn = class extends Error {
|
|
2245
2249
|
constructor(e) {
|
|
2246
2250
|
super(e === "emptied" ? "The shared token storage was emptied" : "The stored refresh token belongs to an ended session"), this.name = "SessionEnded", this.cause = e;
|
|
2247
2251
|
}
|
|
2248
|
-
},
|
|
2252
|
+
}, Fn = class extends Error {
|
|
2249
2253
|
constructor() {
|
|
2250
2254
|
super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
|
|
2251
2255
|
}
|
|
2252
2256
|
};
|
|
2253
|
-
function
|
|
2257
|
+
function In(e) {
|
|
2254
2258
|
if (e) try {
|
|
2255
2259
|
let t = A(e).sub;
|
|
2256
2260
|
return typeof t == "string" && t !== "" ? t : void 0;
|
|
@@ -2259,20 +2263,20 @@ function Mn(e) {
|
|
|
2259
2263
|
}
|
|
2260
2264
|
}
|
|
2261
2265
|
function X(e) {
|
|
2262
|
-
return
|
|
2266
|
+
return In(e?.access_token) ?? In(e?.refresh_token) ?? In(e?.id_token);
|
|
2263
2267
|
}
|
|
2264
|
-
function
|
|
2268
|
+
function Ln(e, t) {
|
|
2265
2269
|
return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
|
|
2266
2270
|
}
|
|
2267
|
-
function
|
|
2271
|
+
function Rn(e) {
|
|
2268
2272
|
return typeof e == "object" && !!e;
|
|
2269
2273
|
}
|
|
2270
|
-
function
|
|
2271
|
-
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) =>
|
|
2274
|
+
function zn(e) {
|
|
2275
|
+
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => gn().warn(e)), o = e.lineage ?? Nn(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
|
|
2272
2276
|
let e = t.getTokens(), n = e?.refresh_token;
|
|
2273
2277
|
if (!n) return p = l, e;
|
|
2274
2278
|
p !== void 0 && (f = Math.max(f, p, m), p = void 0);
|
|
2275
|
-
let r =
|
|
2279
|
+
let r = An(n) ?? "";
|
|
2276
2280
|
return r !== c?.fp && (c = {
|
|
2277
2281
|
fp: r,
|
|
2278
2282
|
seq: l
|
|
@@ -2305,7 +2309,7 @@ function Fn(e) {
|
|
|
2305
2309
|
let t = E();
|
|
2306
2310
|
t === "wait" && e && (t = "end"), t !== "wait" && D(), t === "wait" && !h && (h = r(() => {
|
|
2307
2311
|
h = void 0, y()?.refresh_token ? N() : O(!0) === "end" && s?.("emptied");
|
|
2308
|
-
},
|
|
2312
|
+
}, zt));
|
|
2309
2313
|
let n = t === "keep" ? T() : void 0;
|
|
2310
2314
|
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;
|
|
2311
2315
|
}, ee = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, k = (e) => {
|
|
@@ -2318,7 +2322,7 @@ function Fn(e) {
|
|
|
2318
2322
|
return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
|
|
2319
2323
|
}, j = (e, t) => o.isForward(e, t) ? !0 : !!e && !!t && e.iat !== void 0 && e.sid !== t.sid && o.isRetired(t) && !o.isRetired(e) && !o.isEnded(e), M = (e) => {
|
|
2320
2324
|
let t = b();
|
|
2321
|
-
t && t.fp !==
|
|
2325
|
+
t && t.fp !== An(e.refresh_token) && o.retire(t), n.setTokensCache(e);
|
|
2322
2326
|
}, te = (e) => {
|
|
2323
2327
|
let t = y(), n = t?.refresh_token;
|
|
2324
2328
|
if (n === e.refreshToken) return null;
|
|
@@ -2329,7 +2333,7 @@ function Fn(e) {
|
|
|
2329
2333
|
kind: "superseded",
|
|
2330
2334
|
adopted: !1
|
|
2331
2335
|
};
|
|
2332
|
-
let r =
|
|
2336
|
+
let r = In(t.access_token) ?? In(n);
|
|
2333
2337
|
if (e.sub && r && e.sub !== r) return {
|
|
2334
2338
|
kind: "identity-changed",
|
|
2335
2339
|
saved: !1
|
|
@@ -2369,22 +2373,22 @@ function Fn(e) {
|
|
|
2369
2373
|
}, re = !!s || !!e.onStoredSessionSeen, ie = re && e.onStorageChange ? e.onStorageChange(N) : void 0, ae = re && e.onWake ? e.onWake(N) : void 0, P = () => {
|
|
2370
2374
|
let e = y();
|
|
2371
2375
|
if (!e?.refresh_token) {
|
|
2372
|
-
if (O() === "end") throw new
|
|
2376
|
+
if (O() === "end") throw new Pn("emptied");
|
|
2373
2377
|
return "held";
|
|
2374
2378
|
}
|
|
2375
2379
|
let t = n.getTokens();
|
|
2376
2380
|
if (e.refresh_token === t?.refresh_token) return "send";
|
|
2377
2381
|
let r = i() ?? X(t), a = X(e);
|
|
2378
|
-
if (r && a && r !== a) throw new
|
|
2382
|
+
if (r && a && r !== a) throw new Fn();
|
|
2379
2383
|
let s = Y(e.refresh_token);
|
|
2380
2384
|
if (o.isEnded(s)) {
|
|
2381
2385
|
if (s && C(s)) return "held";
|
|
2382
|
-
throw new
|
|
2386
|
+
throw new Pn("ended");
|
|
2383
2387
|
}
|
|
2384
2388
|
let c = Y(t?.refresh_token);
|
|
2385
2389
|
return j(s, c) ? (M(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && k(s) ? "held" : "send";
|
|
2386
2390
|
}, oe = (e) => {
|
|
2387
|
-
let t = i(), r =
|
|
2391
|
+
let t = i(), r = In(e);
|
|
2388
2392
|
if (t && r && t !== r) return { kind: "identity-changed" };
|
|
2389
2393
|
let a = Y(e) ?? { fp: e };
|
|
2390
2394
|
if (o.isEnded(a)) return C(a) ? { kind: "superseded" } : { kind: "ended" };
|
|
@@ -2392,7 +2396,7 @@ function Fn(e) {
|
|
|
2392
2396
|
let s = {
|
|
2393
2397
|
refreshToken: e,
|
|
2394
2398
|
order: a
|
|
2395
|
-
}, c = t ?? r ??
|
|
2399
|
+
}, c = t ?? r ?? In(n.getTokens()?.access_token);
|
|
2396
2400
|
return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
|
|
2397
2401
|
kind: "send",
|
|
2398
2402
|
sent: s
|
|
@@ -2401,7 +2405,7 @@ function Fn(e) {
|
|
|
2401
2405
|
if (o.isEnded(e.order)) return ne(e.order);
|
|
2402
2406
|
let i = te(e);
|
|
2403
2407
|
if (i) return i;
|
|
2404
|
-
if (!ee(e) && A(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${
|
|
2408
|
+
if (!ee(e) && A(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${An(r.refresh_token) ?? "(no refresh token)"}, but this tab already holds ${b()?.fp ?? "(none)"}, a later successor of ${e.order.fp}. Neither saved nor adopted.`), {
|
|
2405
2409
|
kind: "superseded",
|
|
2406
2410
|
adopted: !1
|
|
2407
2411
|
};
|
|
@@ -2411,7 +2415,7 @@ function Fn(e) {
|
|
|
2411
2415
|
saved: !0
|
|
2412
2416
|
};
|
|
2413
2417
|
let c = Y(r.refresh_token);
|
|
2414
|
-
return c && (
|
|
2418
|
+
return c && (Ln(c, e.order) || Ln(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.`), {
|
|
2415
2419
|
kind: "superseded",
|
|
2416
2420
|
adopted: !1
|
|
2417
2421
|
}) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
|
|
@@ -2423,7 +2427,7 @@ function Fn(e) {
|
|
|
2423
2427
|
kind: "superseded",
|
|
2424
2428
|
adopted: !1
|
|
2425
2429
|
};
|
|
2426
|
-
let r =
|
|
2430
|
+
let r = Sn(t), i = r.kind === "blocked" || r.kind === "auth";
|
|
2427
2431
|
return ee(e) && i ? (o.retire(e.order), _ = e.order, {
|
|
2428
2432
|
kind: "own",
|
|
2429
2433
|
failure: r,
|
|
@@ -2434,11 +2438,11 @@ function Fn(e) {
|
|
|
2434
2438
|
heldRefused: !1
|
|
2435
2439
|
});
|
|
2436
2440
|
}, I = (e) => {
|
|
2437
|
-
if (!
|
|
2441
|
+
if (!Rn(e)) return !1;
|
|
2438
2442
|
let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
|
|
2439
|
-
if (typeof t != "string" || typeof c != "string" || !
|
|
2443
|
+
if (typeof t != "string" || typeof c != "string" || !Rn(l)) return !1;
|
|
2440
2444
|
let u = l;
|
|
2441
|
-
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" ||
|
|
2445
|
+
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || An(u.refresh_token) !== c) return !1;
|
|
2442
2446
|
let d = y();
|
|
2443
2447
|
if (!d?.refresh_token) return !1;
|
|
2444
2448
|
let f = n.getTokens(), p = i() ?? X(f), m = X(u);
|
|
@@ -2455,7 +2459,7 @@ function Fn(e) {
|
|
|
2455
2459
|
}
|
|
2456
2460
|
return !0;
|
|
2457
2461
|
};
|
|
2458
|
-
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t &&
|
|
2462
|
+
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && An(d.refresh_token) !== c ? !1 : (M({ ...u }), _());
|
|
2459
2463
|
}, L = (e) => {
|
|
2460
2464
|
if (!e || !_) return !1;
|
|
2461
2465
|
let t = _;
|
|
@@ -2521,7 +2525,7 @@ function Fn(e) {
|
|
|
2521
2525
|
};
|
|
2522
2526
|
}
|
|
2523
2527
|
// lib/refresh/controller.ts
|
|
2524
|
-
function
|
|
2528
|
+
function Bn() {
|
|
2525
2529
|
let e, t, n = new Promise((n, r) => {
|
|
2526
2530
|
e = n, t = r;
|
|
2527
2531
|
});
|
|
@@ -2531,53 +2535,53 @@ function In() {
|
|
|
2531
2535
|
reject: t
|
|
2532
2536
|
};
|
|
2533
2537
|
}
|
|
2534
|
-
var
|
|
2535
|
-
strikes:
|
|
2536
|
-
"session-ended":
|
|
2537
|
-
"stored-ended":
|
|
2538
|
-
"signed-out":
|
|
2539
|
-
emptied:
|
|
2540
|
-
"signed-out-here":
|
|
2541
|
-
"successor-timeout":
|
|
2542
|
-
"identity-changed":
|
|
2543
|
-
disposed:
|
|
2538
|
+
var Vn = {
|
|
2539
|
+
strikes: q.sessionEnded,
|
|
2540
|
+
"session-ended": q.sessionEnded,
|
|
2541
|
+
"stored-ended": q.sessionEnded,
|
|
2542
|
+
"signed-out": q.signedOut,
|
|
2543
|
+
emptied: q.signedOut,
|
|
2544
|
+
"signed-out-here": q.signedOut,
|
|
2545
|
+
"successor-timeout": q.successorTimeout,
|
|
2546
|
+
"identity-changed": q.identityChanged,
|
|
2547
|
+
disposed: q.disposed
|
|
2544
2548
|
};
|
|
2545
|
-
function
|
|
2549
|
+
function Hn(e) {
|
|
2546
2550
|
throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
|
|
2547
2551
|
}
|
|
2548
|
-
function
|
|
2552
|
+
function Un(e) {
|
|
2549
2553
|
if (e === void 0 || !Number.isFinite(e)) return 3;
|
|
2550
2554
|
let t = Math.floor(e);
|
|
2551
2555
|
return t >= 1 ? t : 3;
|
|
2552
2556
|
}
|
|
2553
|
-
function
|
|
2557
|
+
function Wn(e, t) {
|
|
2554
2558
|
return e instanceof Error && e.message ? e.message : t;
|
|
2555
2559
|
}
|
|
2556
|
-
function
|
|
2560
|
+
function Gn(e) {
|
|
2557
2561
|
if (typeof e != "object" || !e) return;
|
|
2558
2562
|
let t = e.id;
|
|
2559
2563
|
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
2560
2564
|
}
|
|
2561
|
-
function
|
|
2565
|
+
function Kn(e) {
|
|
2562
2566
|
let t = {};
|
|
2563
2567
|
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;
|
|
2564
2568
|
}
|
|
2565
|
-
function
|
|
2569
|
+
function qn(e, t) {
|
|
2566
2570
|
let n = {};
|
|
2567
2571
|
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);
|
|
2568
2572
|
let r = t?.scopes ?? e.scopes;
|
|
2569
2573
|
return r && (n.scopes = r), n;
|
|
2570
2574
|
}
|
|
2571
|
-
function
|
|
2572
|
-
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ??
|
|
2575
|
+
function Jn(e) {
|
|
2576
|
+
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? gn(), c = Un(e.strikes), l = a.transports ? Tn({
|
|
2573
2577
|
locks: a.transports.locks,
|
|
2574
2578
|
channel: a.transports.channel,
|
|
2575
2579
|
tabId: a.transports.tabId,
|
|
2576
2580
|
names: a.names,
|
|
2577
2581
|
clock: o
|
|
2578
|
-
}) :
|
|
2582
|
+
}) : En(), u = { kind: "idle" }, d = 0, f = !1, p = !a.warnOnFirstCycle, m = 0, h = 0, g, _, v, y, b, x, S, C, w = !1, T = () => o.now(), E = () => i.mode(), D = () => An(r.getTokens()?.refresh_token), O = () => ({ ...r.getTokens() ?? {} }), ee = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, k = () => (S === void 0 && (S = X(r.getTokens() ?? n.getTokens())), S), A = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Set(), M = (e) => () => {
|
|
2579
2583
|
for (let t of Array.from(e)) t();
|
|
2580
|
-
}, te = a.onStorageChange?.(M(A)), ne = e.platform?.onForeground(M(j)), N =
|
|
2584
|
+
}, te = a.onStorageChange?.(M(A)), ne = e.platform?.onForeground(M(j)), N = zn({
|
|
2581
2585
|
storage: n,
|
|
2582
2586
|
cache: r,
|
|
2583
2587
|
identity: k,
|
|
@@ -2592,13 +2596,13 @@ function Wn(e) {
|
|
|
2592
2596
|
}), re = (e) => ({
|
|
2593
2597
|
trigger: e,
|
|
2594
2598
|
startedAt: T(),
|
|
2595
|
-
plain:
|
|
2599
|
+
plain: Bn(),
|
|
2596
2600
|
fresh: []
|
|
2597
2601
|
}), ie = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, ae = (e, t) => {
|
|
2598
2602
|
if (t === void 0) return e.plain.promise;
|
|
2599
2603
|
let n = {
|
|
2600
2604
|
callTime: t,
|
|
2601
|
-
deferred:
|
|
2605
|
+
deferred: Bn()
|
|
2602
2606
|
};
|
|
2603
2607
|
return e.fresh.push(n), n.deferred.promise;
|
|
2604
2608
|
}, P = (e, t, n = !1) => {
|
|
@@ -2617,11 +2621,11 @@ function Wn(e) {
|
|
|
2617
2621
|
}
|
|
2618
2622
|
}, F = (e, n, r, i) => {
|
|
2619
2623
|
let a = {
|
|
2620
|
-
message:
|
|
2624
|
+
message: Wn(r, "Token refresh failed"),
|
|
2621
2625
|
originalError: r,
|
|
2622
2626
|
operation: e,
|
|
2623
2627
|
source: n
|
|
2624
|
-
}, o =
|
|
2628
|
+
}, o = Gn(r);
|
|
2625
2629
|
o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
|
|
2626
2630
|
}, I = (e, t) => {
|
|
2627
2631
|
let n = {
|
|
@@ -2651,10 +2655,10 @@ function Wn(e) {
|
|
|
2651
2655
|
};
|
|
2652
2656
|
n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
|
|
2653
2657
|
}, le = (e, t) => {
|
|
2654
|
-
let n = r.getTokens(), i =
|
|
2658
|
+
let n = r.getTokens(), i = An(n?.refresh_token);
|
|
2655
2659
|
e.fp && i && l.post({
|
|
2656
2660
|
type: "tokens-refreshed",
|
|
2657
|
-
tokens:
|
|
2661
|
+
tokens: Kn(n),
|
|
2658
2662
|
from: e.fp,
|
|
2659
2663
|
...e.iat === void 0 ? {} : { fromIat: e.iat },
|
|
2660
2664
|
fromSid: e.sid ?? "",
|
|
@@ -2662,7 +2666,7 @@ function Wn(e) {
|
|
|
2662
2666
|
...t === void 0 ? {} : { sentAt: t }
|
|
2663
2667
|
});
|
|
2664
2668
|
}, ue = () => {
|
|
2665
|
-
p || (p = !0, s.warn(
|
|
2669
|
+
p || (p = !0, s.warn(Qt));
|
|
2666
2670
|
}, de = (e) => {
|
|
2667
2671
|
(e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
|
|
2668
2672
|
}, R = (e, n) => {
|
|
@@ -2676,7 +2680,7 @@ function Wn(e) {
|
|
|
2676
2680
|
}, e !== "disposed" && N.dropSession(), (e === "strikes" || e === "successor-timeout") && E() !== "json" && i.invalidate(), u = {
|
|
2677
2681
|
kind: "ended",
|
|
2678
2682
|
cause: e
|
|
2679
|
-
}, se(r, n ?? new
|
|
2683
|
+
}, se(r, n ?? new J(Vn[e])), e) {
|
|
2680
2684
|
case "strikes":
|
|
2681
2685
|
t("session:expired", {
|
|
2682
2686
|
reason: "refresh_failed",
|
|
@@ -2711,7 +2715,7 @@ function Wn(e) {
|
|
|
2711
2715
|
break;
|
|
2712
2716
|
case "signed-out-here":
|
|
2713
2717
|
case "disposed": break;
|
|
2714
|
-
default:
|
|
2718
|
+
default: Hn(e);
|
|
2715
2719
|
}
|
|
2716
2720
|
}, fe = () => {
|
|
2717
2721
|
if (u.kind !== "ended" || u.cause === "disposed" || f || E() !== "json") return;
|
|
@@ -2728,17 +2732,17 @@ function Wn(e) {
|
|
|
2728
2732
|
}, pe = (e) => {
|
|
2729
2733
|
u.kind === "ended" || f || E() === "json" && (R(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && fe());
|
|
2730
2734
|
}, me = (e) => {
|
|
2731
|
-
e instanceof
|
|
2735
|
+
e instanceof Fn ? (R("identity-changed"), fe()) : e instanceof Pn ? R(e.cause === "emptied" ? "emptied" : "stored-ended") : R("stored-ended", e);
|
|
2732
2736
|
}, he = () => {
|
|
2733
2737
|
u = { kind: "idle" }, w || l.release();
|
|
2734
|
-
}, ge = (e) => !e.from || E() !== "json" || e.from === D() || e.from ===
|
|
2738
|
+
}, ge = (e) => !e.from || E() !== "json" || e.from === D() || e.from === An(n.getTokens()?.refresh_token), _e = (e) => {
|
|
2735
2739
|
let t = g;
|
|
2736
2740
|
if (!t) return;
|
|
2737
2741
|
if (!l.holding) {
|
|
2738
2742
|
u = {
|
|
2739
2743
|
kind: "waiting",
|
|
2740
2744
|
pending: e
|
|
2741
|
-
}, l.request(t.nextAt +
|
|
2745
|
+
}, l.request(t.nextAt + G);
|
|
2742
2746
|
return;
|
|
2743
2747
|
}
|
|
2744
2748
|
l.setRetryInfo(t);
|
|
@@ -2757,7 +2761,7 @@ function Wn(e) {
|
|
|
2757
2761
|
!l.holding || l.foreignHolderHeard() || T() - t > 2e4 ? (l.release(), u = {
|
|
2758
2762
|
kind: "waiting",
|
|
2759
2763
|
pending: e
|
|
2760
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
2764
|
+
}, l.request((g?.nextAt ?? T()) + G)) : (u = {
|
|
2761
2765
|
kind: "waiting",
|
|
2762
2766
|
pending: e
|
|
2763
2767
|
}, be() || ye());
|
|
@@ -2797,14 +2801,14 @@ function Wn(e) {
|
|
|
2797
2801
|
case "ended": return N.endHeldSend(), R("stored-ended"), !1;
|
|
2798
2802
|
case "identity-changed": return N.endHeldSend(), R("identity-changed"), fe(), !1;
|
|
2799
2803
|
case "send": return Ce(e, t, a.sent, r);
|
|
2800
|
-
default: return
|
|
2804
|
+
default: return Hn(a);
|
|
2801
2805
|
}
|
|
2802
2806
|
}, Ce = (e, n, r, a) => {
|
|
2803
2807
|
let o = {
|
|
2804
2808
|
generation: d,
|
|
2805
2809
|
sentAt: T(),
|
|
2806
2810
|
trigger: n,
|
|
2807
|
-
settled:
|
|
2811
|
+
settled: Bn()
|
|
2808
2812
|
};
|
|
2809
2813
|
r ? o.sent = r : o.marker = ee(), a && (o.stored = a), u = {
|
|
2810
2814
|
kind: "refreshing",
|
|
@@ -2828,7 +2832,7 @@ function Wn(e) {
|
|
|
2828
2832
|
if (!e.sent) {
|
|
2829
2833
|
let o = X({ ...t.id_token ? { id_token: t.id_token } : {} }), s = k();
|
|
2830
2834
|
if (o !== void 0 && s !== void 0 && o !== s) {
|
|
2831
|
-
let t = new q
|
|
2835
|
+
let t = new J(q.identityChanged);
|
|
2832
2836
|
F("refresh", e.trigger, t, I("auth")), R("identity-changed", t);
|
|
2833
2837
|
return;
|
|
2834
2838
|
}
|
|
@@ -2841,7 +2845,7 @@ function Wn(e) {
|
|
|
2841
2845
|
if (!we(e)) return;
|
|
2842
2846
|
r.setTokensCache({
|
|
2843
2847
|
...n.getTokens() ?? {},
|
|
2844
|
-
...
|
|
2848
|
+
...qn(t, void 0)
|
|
2845
2849
|
}), L("refresh", "this-tab");
|
|
2846
2850
|
let c = k();
|
|
2847
2851
|
l.post(c === void 0 ? {
|
|
@@ -2854,7 +2858,7 @@ function Wn(e) {
|
|
|
2854
2858
|
}), he(), P(a, e.sentAt);
|
|
2855
2859
|
return;
|
|
2856
2860
|
}
|
|
2857
|
-
let o = D(), s = N.commitSave(e.sent,
|
|
2861
|
+
let o = D(), s = N.commitSave(e.sent, qn(t, e.stored));
|
|
2858
2862
|
switch (s.kind) {
|
|
2859
2863
|
case "saved":
|
|
2860
2864
|
L("refresh", "this-tab"), le(e.sent.order, e.sentAt), he(), P(a, e.sentAt);
|
|
@@ -2863,16 +2867,16 @@ function Wn(e) {
|
|
|
2863
2867
|
e.outcome && D() === o || L("adopted", "other-tab"), s.adopted && le(e.sent.order), he(), P(a, e.sentAt);
|
|
2864
2868
|
return;
|
|
2865
2869
|
case "ended": {
|
|
2866
|
-
let t = new
|
|
2870
|
+
let t = new J(s.cause === "emptied" ? q.signedOut : q.sessionEnded);
|
|
2867
2871
|
F("refresh", e.trigger, t, I("auth")), R(s.cause === "emptied" ? "emptied" : "stored-ended", t);
|
|
2868
2872
|
return;
|
|
2869
2873
|
}
|
|
2870
2874
|
case "identity-changed": {
|
|
2871
|
-
let t = new q
|
|
2875
|
+
let t = new J(q.identityChanged);
|
|
2872
2876
|
F("refresh", e.trigger, t, I("auth")), R("identity-changed", t), fe();
|
|
2873
2877
|
return;
|
|
2874
2878
|
}
|
|
2875
|
-
default:
|
|
2879
|
+
default: Hn(s);
|
|
2876
2880
|
}
|
|
2877
2881
|
}, Ee = (e, t) => {
|
|
2878
2882
|
if (e.sent?.held && N.endHeldSend(), !we(e) || u.kind !== "refreshing") return;
|
|
@@ -2892,9 +2896,9 @@ function Wn(e) {
|
|
|
2892
2896
|
case "own":
|
|
2893
2897
|
r = o.failure, i = o.heldRefused;
|
|
2894
2898
|
break;
|
|
2895
|
-
default:
|
|
2899
|
+
default: Hn(o);
|
|
2896
2900
|
}
|
|
2897
|
-
} else r =
|
|
2901
|
+
} else r = Sn(t, T());
|
|
2898
2902
|
if (i) F("refresh", e.trigger, t, I(r.kind)), L("adopted", "other-tab"), he(), P(n, void 0, !0);
|
|
2899
2903
|
else switch (r.kind) {
|
|
2900
2904
|
case "blocked":
|
|
@@ -2910,10 +2914,10 @@ function Wn(e) {
|
|
|
2910
2914
|
case "transient":
|
|
2911
2915
|
m += 1, De(e, n, t, r);
|
|
2912
2916
|
return;
|
|
2913
|
-
default:
|
|
2917
|
+
default: Hn(r.kind);
|
|
2914
2918
|
}
|
|
2915
2919
|
}, De = (e, t, n, r) => {
|
|
2916
|
-
let i = T() +
|
|
2920
|
+
let i = T() + Cn(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
|
|
2917
2921
|
F("refresh", e.trigger, n, I(a, i)), a === "transient" && ce(T(), i, "this-tab");
|
|
2918
2922
|
let s = {
|
|
2919
2923
|
kind: a,
|
|
@@ -2923,7 +2927,7 @@ function Wn(e) {
|
|
|
2923
2927
|
}, c = e.sent?.order.fp;
|
|
2924
2928
|
c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
|
|
2925
2929
|
type: "retry-scheduled",
|
|
2926
|
-
message:
|
|
2930
|
+
message: Wn(n, "Token refresh failed"),
|
|
2927
2931
|
retry: s
|
|
2928
2932
|
}), _e(re("retry")), oe(t, n, e.sentAt);
|
|
2929
2933
|
}, z = (e, t) => {
|
|
@@ -2936,8 +2940,8 @@ function Wn(e) {
|
|
|
2936
2940
|
fp: i.fp
|
|
2937
2941
|
})), r && N.deleteIfStillDead(r), R("strikes", t);
|
|
2938
2942
|
}, Oe = (e, t, n, r) => {
|
|
2939
|
-
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${
|
|
2940
|
-
let i = d, a = T() +
|
|
2943
|
+
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${Wn(n, "blocked")}`);
|
|
2944
|
+
let i = d, a = T() + Lt, c = {
|
|
2941
2945
|
kind: "blocked-wait",
|
|
2942
2946
|
pending: e,
|
|
2943
2947
|
deadline: a,
|
|
@@ -2950,9 +2954,9 @@ function Wn(e) {
|
|
|
2950
2954
|
i === d && u === c && (ke() || (f ? (e.cookieRetried = !0, u = {
|
|
2951
2955
|
kind: "waiting",
|
|
2952
2956
|
pending: e
|
|
2953
|
-
}, l.request()) : T() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), R("successor-timeout")) : c.cancel = o.setTimeout(p,
|
|
2957
|
+
}, l.request()) : T() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), R("successor-timeout")) : c.cancel = o.setTimeout(p, Rt)));
|
|
2954
2958
|
};
|
|
2955
|
-
c.cancel = o.setTimeout(p, f ?
|
|
2959
|
+
c.cancel = o.setTimeout(p, f ? Bt : Rt);
|
|
2956
2960
|
}, ke = () => {
|
|
2957
2961
|
if (u.kind !== "blocked-wait") return !1;
|
|
2958
2962
|
let e = u;
|
|
@@ -2975,7 +2979,7 @@ function Wn(e) {
|
|
|
2975
2979
|
if (u.kind === "ended" || !ge(e)) return;
|
|
2976
2980
|
let r = g?.nextAt;
|
|
2977
2981
|
if (g = e, e.failingSince !== void 0 && ce(e.failingSince, e.nextAt, "other-tab"), !t || u.kind !== "waiting") return;
|
|
2978
|
-
let i = new
|
|
2982
|
+
let i = new J(e.kind === "transient" ? q.unavailable : q.authRetry, {
|
|
2979
2983
|
nextRetryAt: e.nextAt,
|
|
2980
2984
|
cause: n || void 0
|
|
2981
2985
|
}), a = u.pending;
|
|
@@ -2996,7 +3000,7 @@ function Wn(e) {
|
|
|
2996
3000
|
case "idle":
|
|
2997
3001
|
case "refreshing":
|
|
2998
3002
|
case "ended": return;
|
|
2999
|
-
default:
|
|
3003
|
+
default: Hn(u);
|
|
3000
3004
|
}
|
|
3001
3005
|
}, Ne = (e) => {
|
|
3002
3006
|
let t = {};
|
|
@@ -3039,10 +3043,10 @@ function Wn(e) {
|
|
|
3039
3043
|
je(e.retry, !0, e.message), Fe();
|
|
3040
3044
|
return;
|
|
3041
3045
|
case "refresh-failed":
|
|
3042
|
-
if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !==
|
|
3046
|
+
if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !== An(n.getTokens()?.refresh_token)) return;
|
|
3043
3047
|
if (ce(T(), void 0, "other-tab"), u.kind === "waiting") {
|
|
3044
3048
|
let t = u.pending;
|
|
3045
|
-
u.pending = re(t.trigger), oe(t, new q
|
|
3049
|
+
u.pending = re(t.trigger), oe(t, new J(q.unavailable, { cause: e.message }), void 0);
|
|
3046
3050
|
}
|
|
3047
3051
|
return;
|
|
3048
3052
|
case "lock-wanted":
|
|
@@ -3051,7 +3055,7 @@ function Wn(e) {
|
|
|
3051
3055
|
u.cancel(), l.release(), u = {
|
|
3052
3056
|
kind: "waiting",
|
|
3053
3057
|
pending: e
|
|
3054
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
3058
|
+
}, l.request((g?.nextAt ?? T()) + G);
|
|
3055
3059
|
}
|
|
3056
3060
|
return;
|
|
3057
3061
|
case "session-ended":
|
|
@@ -3060,7 +3064,7 @@ function Wn(e) {
|
|
|
3060
3064
|
return;
|
|
3061
3065
|
case "takeover":
|
|
3062
3066
|
case "rate-limited": return;
|
|
3063
|
-
default:
|
|
3067
|
+
default: Hn(e);
|
|
3064
3068
|
}
|
|
3065
3069
|
}, Fe = () => {
|
|
3066
3070
|
C && !l.holding && l.post({
|
|
@@ -3083,7 +3087,7 @@ function Wn(e) {
|
|
|
3083
3087
|
u.cancel(), u = {
|
|
3084
3088
|
kind: "waiting",
|
|
3085
3089
|
pending: e
|
|
3086
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
3090
|
+
}, l.request((g?.nextAt ?? T()) + G);
|
|
3087
3091
|
}
|
|
3088
3092
|
},
|
|
3089
3093
|
onMessage: Pe
|
|
@@ -3109,9 +3113,9 @@ function Wn(e) {
|
|
|
3109
3113
|
};
|
|
3110
3114
|
A.add(Ie), j.add(Ie);
|
|
3111
3115
|
let Le = (e, t) => {
|
|
3112
|
-
if (f) return Promise.reject(new q
|
|
3116
|
+
if (f) return Promise.reject(new J(q.disposed));
|
|
3113
3117
|
switch (u.kind) {
|
|
3114
|
-
case "ended": return Promise.reject(new q
|
|
3118
|
+
case "ended": return Promise.reject(new J(q.sessionEnded));
|
|
3115
3119
|
case "idle": {
|
|
3116
3120
|
let n = re(e);
|
|
3117
3121
|
u = {
|
|
@@ -3119,17 +3123,17 @@ function Wn(e) {
|
|
|
3119
3123
|
pending: n
|
|
3120
3124
|
};
|
|
3121
3125
|
let r = ae(n, t);
|
|
3122
|
-
return l.holding && !w ? be() || ye() : l.request(g ? g.nextAt +
|
|
3126
|
+
return l.holding && !w ? be() || ye() : l.request(g ? g.nextAt + G : void 0), r;
|
|
3123
3127
|
}
|
|
3124
3128
|
case "waiting":
|
|
3125
3129
|
case "refreshing":
|
|
3126
3130
|
case "backoff":
|
|
3127
3131
|
case "blocked-wait": return ae(u.pending, t);
|
|
3128
|
-
default: return
|
|
3132
|
+
default: return Hn(u);
|
|
3129
3133
|
}
|
|
3130
|
-
},
|
|
3131
|
-
if (f) return Promise.reject(new q
|
|
3132
|
-
if (ue(), u.kind === "ended") return Promise.reject(new q
|
|
3134
|
+
}, V = (e) => {
|
|
3135
|
+
if (f) return Promise.reject(new J(q.disposed));
|
|
3136
|
+
if (ue(), u.kind === "ended") return Promise.reject(new J(q.sessionEnded));
|
|
3133
3137
|
if (E() === "json" && !r.getTokens()?.refresh_token) {
|
|
3134
3138
|
let t = n.getTokens();
|
|
3135
3139
|
if (!t?.refresh_token) {
|
|
@@ -3138,12 +3142,12 @@ function Wn(e) {
|
|
|
3138
3142
|
}
|
|
3139
3143
|
}
|
|
3140
3144
|
return Le(e.trigger, e.fresh ? T() : void 0);
|
|
3141
|
-
},
|
|
3142
|
-
if (f) return Promise.reject(new q
|
|
3145
|
+
}, Re = (e) => {
|
|
3146
|
+
if (f) return Promise.reject(new J(q.disposed));
|
|
3143
3147
|
if (u.kind === "ended") return Promise.resolve(r.getTokens());
|
|
3144
3148
|
let t = u.kind === "backoff" || u.kind === "blocked-wait" || g !== void 0 && g.nextAt > T();
|
|
3145
|
-
return e.allowStale && t ? Promise.resolve(r.getTokens()) :
|
|
3146
|
-
},
|
|
3149
|
+
return e.allowStale && t ? Promise.resolve(r.getTokens()) : V({ trigger: e.trigger }).then(() => r.getTokens());
|
|
3150
|
+
}, ze = (e, t) => l.holding ? Promise.resolve("granted") : new Promise((n) => {
|
|
3147
3151
|
let r = () => void 0, i = {
|
|
3148
3152
|
purpose: e,
|
|
3149
3153
|
granted: () => {
|
|
@@ -3156,7 +3160,7 @@ function Wn(e) {
|
|
|
3156
3160
|
}), l.request(), r = o.setTimeout(() => {
|
|
3157
3161
|
C === i && (C = void 0, u.kind !== "waiting" && l.release(), n("timeout"));
|
|
3158
3162
|
}, Math.max(0, t));
|
|
3159
|
-
}),
|
|
3163
|
+
}), Be = async (e) => {
|
|
3160
3164
|
if (u.kind !== "refreshing") return;
|
|
3161
3165
|
let t = u.request.settled.promise;
|
|
3162
3166
|
await new Promise((n) => {
|
|
@@ -3165,7 +3169,7 @@ function Wn(e) {
|
|
|
3165
3169
|
r(), n();
|
|
3166
3170
|
});
|
|
3167
3171
|
});
|
|
3168
|
-
},
|
|
3172
|
+
}, Ve = () => {
|
|
3169
3173
|
if (w = !1, !f && l.holding) {
|
|
3170
3174
|
if (u.kind === "waiting") be() || ye();
|
|
3171
3175
|
else if (u.kind === "backoff") {
|
|
@@ -3173,19 +3177,19 @@ function Wn(e) {
|
|
|
3173
3177
|
u.cancel(), _e(e);
|
|
3174
3178
|
} else u.kind === "idle" && g && g.nextAt > T() && ge(g) ? (m = g.attempt, h = g.strikes, _e(re("retry"))) : u.kind === "idle" && l.release();
|
|
3175
3179
|
}
|
|
3176
|
-
},
|
|
3177
|
-
if (f) throw new q
|
|
3180
|
+
}, He = async (e, t) => {
|
|
3181
|
+
if (f) throw new J(q.disposed);
|
|
3178
3182
|
ue();
|
|
3179
|
-
let n = T() +
|
|
3180
|
-
if (await
|
|
3181
|
-
let e = new
|
|
3183
|
+
let n = T() + Vt;
|
|
3184
|
+
if (await Be(n - T()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await ze("commit", n - T())) === "timeout") {
|
|
3185
|
+
let e = new kn("lock-timeout");
|
|
3182
3186
|
throw F("upgrade.commit", "upgrade", e), e;
|
|
3183
3187
|
}
|
|
3184
3188
|
w = !0;
|
|
3185
3189
|
try {
|
|
3186
3190
|
return await Ue(e, t);
|
|
3187
3191
|
} finally {
|
|
3188
|
-
|
|
3192
|
+
Ve();
|
|
3189
3193
|
}
|
|
3190
3194
|
}, Ue = async (e, a) => {
|
|
3191
3195
|
let o, s;
|
|
@@ -3225,7 +3229,7 @@ function Wn(e) {
|
|
|
3225
3229
|
if (!o) {
|
|
3226
3230
|
await i.applyOpaque(u), r.setTokensCache({
|
|
3227
3231
|
...n.getTokens() ?? {},
|
|
3228
|
-
...
|
|
3232
|
+
...qn(u, void 0)
|
|
3229
3233
|
}), We(c);
|
|
3230
3234
|
let e = k();
|
|
3231
3235
|
return l.post(e === void 0 ? {
|
|
@@ -3237,9 +3241,9 @@ function Wn(e) {
|
|
|
3237
3241
|
sub: e
|
|
3238
3242
|
}), O();
|
|
3239
3243
|
}
|
|
3240
|
-
let d = N.commitSave(o,
|
|
3244
|
+
let d = N.commitSave(o, qn(u, s));
|
|
3241
3245
|
if (d.kind === "saved") return We(c), le(o.order, c), O();
|
|
3242
|
-
let f = new
|
|
3246
|
+
let f = new kn("superseded");
|
|
3243
3247
|
throw F("upgrade.commit", "upgrade", f), d.kind === "superseded" && d.adopted && L("adopted", "other-tab"), f;
|
|
3244
3248
|
}, We = (e) => {
|
|
3245
3249
|
if (L("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
|
|
@@ -3255,18 +3259,18 @@ function Wn(e) {
|
|
|
3255
3259
|
...t,
|
|
3256
3260
|
fp: t.fp
|
|
3257
3261
|
}));
|
|
3258
|
-
},
|
|
3262
|
+
}, H = () => {
|
|
3259
3263
|
let e = ie(u);
|
|
3260
|
-
se(e, new q
|
|
3264
|
+
se(e, new J(q.signedOut)), (u.kind === "backoff" || u.kind === "blocked-wait" || u.kind === "waiting") && (de(u), u = { kind: "idle" });
|
|
3261
3265
|
};
|
|
3262
3266
|
return {
|
|
3263
|
-
refresh:
|
|
3264
|
-
ensureFresh:
|
|
3265
|
-
commitUpgrade:
|
|
3267
|
+
refresh: V,
|
|
3268
|
+
ensureFresh: Re,
|
|
3269
|
+
commitUpgrade: He,
|
|
3266
3270
|
signOut: async (e) => {
|
|
3267
3271
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3268
|
-
let t = T() +
|
|
3269
|
-
|
|
3272
|
+
let t = T() + Ht;
|
|
3273
|
+
H(), await Be(t - T()), H(), l.coordinated && !l.holding && await ze("logout", t - T());
|
|
3270
3274
|
try {
|
|
3271
3275
|
Ge(), await e(n.getTokens()?.refresh_token);
|
|
3272
3276
|
} finally {
|
|
@@ -3275,7 +3279,7 @@ function Wn(e) {
|
|
|
3275
3279
|
},
|
|
3276
3280
|
signOutNow: (e) => {
|
|
3277
3281
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3278
|
-
|
|
3282
|
+
H();
|
|
3279
3283
|
try {
|
|
3280
3284
|
Ge(), e(n.getTokens()?.refresh_token);
|
|
3281
3285
|
} finally {
|
|
@@ -3303,14 +3307,14 @@ function Wn(e) {
|
|
|
3303
3307
|
de(u), f = !0, d += 1, u = {
|
|
3304
3308
|
kind: "ended",
|
|
3305
3309
|
cause: "disposed"
|
|
3306
|
-
}, se(e, new q
|
|
3310
|
+
}, se(e, new J(q.disposed)), C = void 0, N.stop(), l.dispose(), te?.(), ne?.();
|
|
3307
3311
|
}
|
|
3308
3312
|
};
|
|
3309
3313
|
}
|
|
3310
3314
|
// lib/store.ts
|
|
3311
3315
|
var Z = /* @__PURE__ */ function(e) {
|
|
3312
3316
|
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;
|
|
3313
|
-
}({}),
|
|
3317
|
+
}({}), Yn = class {
|
|
3314
3318
|
constructor() {
|
|
3315
3319
|
this.subscribers = /* @__PURE__ */ new Map();
|
|
3316
3320
|
}
|
|
@@ -3329,12 +3333,12 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3329
3333
|
n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
|
|
3330
3334
|
}
|
|
3331
3335
|
notify(e, t) {
|
|
3332
|
-
e === "error" &&
|
|
3336
|
+
e === "error" && kt(this, t?.originalError), this.subscribers.forEach((n, r) => {
|
|
3333
3337
|
(!n || n.has(e)) && r.onAuthChange?.(e, t);
|
|
3334
3338
|
});
|
|
3335
3339
|
}
|
|
3336
3340
|
notifyError(e) {
|
|
3337
|
-
return
|
|
3341
|
+
return W(this, e);
|
|
3338
3342
|
}
|
|
3339
3343
|
}, Q = {
|
|
3340
3344
|
twoFactorCodeInvalid: "error.api.request.2fa_code.invalid",
|
|
@@ -3350,18 +3354,18 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3350
3354
|
twoFactorNotEnabled: "error.2fa.not_enabled",
|
|
3351
3355
|
notImplemented: "error.not.implemented",
|
|
3352
3356
|
tokenInvalid: "error.api.request.token.invalid"
|
|
3353
|
-
},
|
|
3357
|
+
}, Xn = Object.freeze([
|
|
3354
3358
|
Q.twoFactorCodeInvalid,
|
|
3355
3359
|
Q.twoFactorNotEnabled,
|
|
3356
3360
|
Q.challengeInvalid,
|
|
3357
3361
|
Q.challengeSessionMismatch,
|
|
3358
3362
|
Q.challengeTooManyAttempts
|
|
3359
|
-
]),
|
|
3363
|
+
]), Zn = Object.freeze([Q.tokenInvalid]), Qn = Object.freeze([
|
|
3360
3364
|
"wrong_code",
|
|
3361
3365
|
"challenge_spent",
|
|
3362
3366
|
"not_registered",
|
|
3363
3367
|
"prepare_not_required"
|
|
3364
|
-
]),
|
|
3368
|
+
]), $n = (e) => Qn.includes(e), er = {
|
|
3365
3369
|
wrong_code: "That code was not accepted. Try again.",
|
|
3366
3370
|
challenge_spent: "That verification challenge is no longer valid. Start again.",
|
|
3367
3371
|
exhausted: "Too many attempts. Try again later.",
|
|
@@ -3375,16 +3379,16 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3375
3379
|
session_changed: "The session ended during verification."
|
|
3376
3380
|
}, $ = class extends Error {
|
|
3377
3381
|
constructor(e) {
|
|
3378
|
-
super(e.message ||
|
|
3382
|
+
super(e.message || er[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, this.retryable = $n(e.kind), e.cause !== void 0 && (this.cause = e.cause);
|
|
3379
3383
|
}
|
|
3380
|
-
},
|
|
3384
|
+
}, tr = Object.freeze([
|
|
3381
3385
|
"upgrade_transport",
|
|
3382
3386
|
"upgrade_insufficient",
|
|
3383
3387
|
"upgrade_unavailable",
|
|
3384
3388
|
"upgrade_session_changed",
|
|
3385
3389
|
"upgrade_cancelled",
|
|
3386
3390
|
"upgrade_unsatisfiable"
|
|
3387
|
-
]),
|
|
3391
|
+
]), nr = (e) => typeof e == "object" && !!e && typeof e.code == "string" && tr.includes(e.code), rr = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", ir = (e) => {
|
|
3388
3392
|
if (typeof e != "object" || !e) return {
|
|
3389
3393
|
hasResponse: !1,
|
|
3390
3394
|
message: typeof e == "string" ? e : void 0
|
|
@@ -3396,7 +3400,7 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3396
3400
|
message: typeof t.message == "string" ? t.message : void 0,
|
|
3397
3401
|
hasResponse: n !== void 0 || typeof t.status == "number"
|
|
3398
3402
|
};
|
|
3399
|
-
},
|
|
3403
|
+
}, ar = (e, t) => {
|
|
3400
3404
|
switch (e) {
|
|
3401
3405
|
case Q.twoFactorCodeInvalid: return "wrong_code";
|
|
3402
3406
|
case Q.challengeInvalid:
|
|
@@ -3413,11 +3417,11 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3413
3417
|
case Q.tokenInvalid: return t === "refresh" ? "session_changed" : "fatal";
|
|
3414
3418
|
default: return;
|
|
3415
3419
|
}
|
|
3416
|
-
},
|
|
3420
|
+
}, or = (e, t) => e === void 0 ? "network" : e === 501 ? "unavailable" : e === 400 ? "fatal" : e === 401 || e === 403 ? t === "start" ? "challenge_spent" : "session_changed" : e >= 500 ? "network" : "fatal", sr = (e, t) => {
|
|
3417
3421
|
if (e instanceof $) return e;
|
|
3418
|
-
let n =
|
|
3422
|
+
let n = ir(e);
|
|
3419
3423
|
return n.hasResponse ? new $({
|
|
3420
|
-
kind:
|
|
3424
|
+
kind: ar(n.errorId, t) ?? or(n.status, t),
|
|
3421
3425
|
message: n.message,
|
|
3422
3426
|
status: n.status,
|
|
3423
3427
|
errorId: n.errorId,
|
|
@@ -3427,74 +3431,74 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3427
3431
|
message: n.message,
|
|
3428
3432
|
cause: e
|
|
3429
3433
|
});
|
|
3430
|
-
},
|
|
3434
|
+
}, cr = (e) => e.errorId !== void 0 && Xn.includes(e.errorId), lr = (e) => e.errorId !== void 0 && Zn.includes(e.errorId), ur = class extends Error {
|
|
3431
3435
|
constructor(e, t, n) {
|
|
3432
3436
|
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;
|
|
3433
3437
|
}
|
|
3434
|
-
},
|
|
3438
|
+
}, dr = class extends Error {
|
|
3435
3439
|
constructor(e = "Step-up verification is not available on this deployment") {
|
|
3436
3440
|
super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
|
|
3437
3441
|
}
|
|
3438
|
-
},
|
|
3442
|
+
}, fr = class extends Error {
|
|
3439
3443
|
constructor(e = "The session changed during verification") {
|
|
3440
3444
|
super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
|
|
3441
3445
|
}
|
|
3442
|
-
},
|
|
3446
|
+
}, pr = (e) => {
|
|
3443
3447
|
if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
|
|
3444
3448
|
sub: e.sub,
|
|
3445
3449
|
sid: e.sid
|
|
3446
3450
|
} : { sub: e.sub };
|
|
3447
|
-
},
|
|
3451
|
+
}, mr = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
|
|
3448
3452
|
// lib/utils/validation.ts
|
|
3449
|
-
function
|
|
3453
|
+
function hr(e) {
|
|
3450
3454
|
if (!e || typeof e != "string") return !1;
|
|
3451
3455
|
let t = e.split(".");
|
|
3452
3456
|
if (t.length !== 3) return !1;
|
|
3453
3457
|
let n = /^[A-Za-z0-9_-]+$/;
|
|
3454
3458
|
return t.every((e) => n.test(e) && e.length > 0);
|
|
3455
3459
|
}
|
|
3456
|
-
function
|
|
3460
|
+
function gr(e) {
|
|
3457
3461
|
return e.replace(/<[^>]*>/g, "").substring(0, 200);
|
|
3458
3462
|
}
|
|
3459
|
-
function
|
|
3463
|
+
function _r(e) {
|
|
3460
3464
|
if (!e || typeof e != "string") return !1;
|
|
3461
3465
|
let t = e.trim();
|
|
3462
3466
|
return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
|
|
3463
3467
|
}
|
|
3464
|
-
function
|
|
3468
|
+
function vr(e) {
|
|
3465
3469
|
if (!e || typeof e != "string") return !1;
|
|
3466
3470
|
let t = e.trim();
|
|
3467
3471
|
return /^\+[1-9]\d{1,14}$/.test(t);
|
|
3468
3472
|
}
|
|
3469
|
-
function
|
|
3473
|
+
function yr(e) {
|
|
3470
3474
|
if (!e || typeof e != "string") return !1;
|
|
3471
3475
|
let t = e.trim();
|
|
3472
3476
|
return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
|
|
3473
3477
|
}
|
|
3474
|
-
function
|
|
3478
|
+
function br(e, t = 6) {
|
|
3475
3479
|
return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
|
|
3476
3480
|
}
|
|
3477
|
-
function
|
|
3481
|
+
function xr(e) {
|
|
3478
3482
|
if (!e || typeof e != "string") return null;
|
|
3479
3483
|
let t = e.toUpperCase().replace(/\s+/g, "");
|
|
3480
3484
|
return /^[A-Z0-9-]{4,16}$/.test(t) ? t : null;
|
|
3481
3485
|
}
|
|
3482
3486
|
// lib/services/auth-service.ts
|
|
3483
|
-
var
|
|
3487
|
+
var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with a PKCE code, but its verifier is gone", Er = (e) => {
|
|
3484
3488
|
if (!e) return;
|
|
3485
3489
|
let t = new URLSearchParams(e.search).get("token");
|
|
3486
3490
|
if (t) return t;
|
|
3487
3491
|
let n = e.hash.indexOf("?");
|
|
3488
3492
|
return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
|
|
3489
|
-
},
|
|
3493
|
+
}, Dr = (e) => {
|
|
3490
3494
|
if (e) try {
|
|
3491
3495
|
return A(e).email;
|
|
3492
3496
|
} catch {
|
|
3493
3497
|
return;
|
|
3494
3498
|
}
|
|
3495
|
-
},
|
|
3496
|
-
constructor(e, t, n, r, i, a, o, s, c, l, u, d = P, f, p = { coordination:
|
|
3497
|
-
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new ne(n), u?.enabled && this.tokenDeliveryManager.setMode(M.BFF), this.refresh =
|
|
3499
|
+
}, Or = class {
|
|
3500
|
+
constructor(e, t, n, r, i, a, o, s, c, l, u, d = P, f, p = { coordination: sn() }) {
|
|
3501
|
+
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new ne(n), u?.enabled && this.tokenDeliveryManager.setMode(M.BFF), this.refresh = Jn({
|
|
3498
3502
|
emit: this.createRefreshEmit(),
|
|
3499
3503
|
storage: n,
|
|
3500
3504
|
cache: i,
|
|
@@ -3502,7 +3506,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3502
3506
|
coordination: p.coordination,
|
|
3503
3507
|
platform: d,
|
|
3504
3508
|
...p.strikes === void 0 ? {} : { strikes: p.strikes },
|
|
3505
|
-
logger:
|
|
3509
|
+
logger: gn()
|
|
3506
3510
|
}), this.initializeSession();
|
|
3507
3511
|
}
|
|
3508
3512
|
async initializeSession() {
|
|
@@ -3557,7 +3561,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3557
3561
|
rememberEmailChallenge(e, t) {
|
|
3558
3562
|
this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
|
|
3559
3563
|
for (let e of this.emailChallenges.keys()) {
|
|
3560
|
-
if (this.emailChallenges.size <=
|
|
3564
|
+
if (this.emailChallenges.size <= wr) break;
|
|
3561
3565
|
this.emailChallenges.delete(e);
|
|
3562
3566
|
}
|
|
3563
3567
|
}
|
|
@@ -3565,14 +3569,14 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3565
3569
|
if (this.pendingPkce = {
|
|
3566
3570
|
verifier: e,
|
|
3567
3571
|
scopes: t,
|
|
3568
|
-
expiresAt: Date.now() +
|
|
3572
|
+
expiresAt: Date.now() + Cr
|
|
3569
3573
|
}, typeof sessionStorage < "u") try {
|
|
3570
|
-
sessionStorage.setItem(
|
|
3574
|
+
sessionStorage.setItem(Sr, JSON.stringify(this.pendingPkce));
|
|
3571
3575
|
} catch {}
|
|
3572
3576
|
}
|
|
3573
3577
|
readPendingPkce() {
|
|
3574
3578
|
if (!this.pendingPkce && typeof sessionStorage < "u") try {
|
|
3575
|
-
let e = sessionStorage.getItem(
|
|
3579
|
+
let e = sessionStorage.getItem(Sr);
|
|
3576
3580
|
this.pendingPkce = e ? JSON.parse(e) : void 0;
|
|
3577
3581
|
} catch {
|
|
3578
3582
|
this.pendingPkce = void 0;
|
|
@@ -3584,7 +3588,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3584
3588
|
}
|
|
3585
3589
|
forgetPkceSignIn() {
|
|
3586
3590
|
if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
|
|
3587
|
-
sessionStorage.removeItem(
|
|
3591
|
+
sessionStorage.removeItem(Sr);
|
|
3588
3592
|
} catch {}
|
|
3589
3593
|
}
|
|
3590
3594
|
async startPkce() {
|
|
@@ -3592,17 +3596,17 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3592
3596
|
try {
|
|
3593
3597
|
e = await this.readPkceEnabled?.() ?? !1;
|
|
3594
3598
|
} catch (e) {
|
|
3595
|
-
|
|
3599
|
+
gn().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
|
|
3596
3600
|
return;
|
|
3597
3601
|
}
|
|
3598
|
-
return e ?
|
|
3602
|
+
return e ? mn() : void 0;
|
|
3599
3603
|
}
|
|
3600
3604
|
async exchangeCode(e, t) {
|
|
3601
3605
|
return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
|
|
3602
3606
|
}
|
|
3603
3607
|
async completePkceSignIn(e) {
|
|
3604
3608
|
let t = this.readPendingPkce();
|
|
3605
|
-
if (!t) throw Error(
|
|
3609
|
+
if (!t) throw Error(Tr);
|
|
3606
3610
|
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
3607
3611
|
return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
|
|
3608
3612
|
}
|
|
@@ -3626,35 +3630,35 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3626
3630
|
if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
|
|
3627
3631
|
}
|
|
3628
3632
|
async signIn(e) {
|
|
3629
|
-
if ("email" in e && e.email && !
|
|
3633
|
+
if ("email" in e && e.email && !_r(e.email)) {
|
|
3630
3634
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3631
3635
|
operation: "sign-in",
|
|
3632
3636
|
message: "Invalid email format",
|
|
3633
3637
|
originalError: e,
|
|
3634
3638
|
code: "VALIDATION_ERROR"
|
|
3635
3639
|
};
|
|
3636
|
-
throw
|
|
3640
|
+
throw W(this.subscribeStore, t), e;
|
|
3637
3641
|
}
|
|
3638
|
-
if ("username" in e && e.username && !
|
|
3642
|
+
if ("username" in e && e.username && !yr(e.username)) {
|
|
3639
3643
|
let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
|
|
3640
3644
|
operation: "sign-in",
|
|
3641
3645
|
message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
|
|
3642
3646
|
originalError: e,
|
|
3643
3647
|
code: "VALIDATION_ERROR"
|
|
3644
3648
|
};
|
|
3645
|
-
throw
|
|
3649
|
+
throw W(this.subscribeStore, t), e;
|
|
3646
3650
|
}
|
|
3647
|
-
if ("phone" in e && e.phone && !
|
|
3651
|
+
if ("phone" in e && e.phone && !vr(e.phone)) {
|
|
3648
3652
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3649
3653
|
operation: "sign-in",
|
|
3650
3654
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3651
3655
|
originalError: e,
|
|
3652
3656
|
code: "VALIDATION_ERROR"
|
|
3653
3657
|
};
|
|
3654
|
-
throw
|
|
3658
|
+
throw W(this.subscribeStore, t), e;
|
|
3655
3659
|
}
|
|
3656
3660
|
this.subscribeStore.notify(Z.SignInStart, { email: e.email });
|
|
3657
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
3661
|
+
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
3658
3662
|
e.scopes = e.scopes ?? this.scopes;
|
|
3659
3663
|
try {
|
|
3660
3664
|
let r = await this.startPkce(), i = await this.authApi.signIn(r ? {
|
|
@@ -3674,27 +3678,27 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3674
3678
|
originalError: e,
|
|
3675
3679
|
code: e instanceof B ? e.id : void 0
|
|
3676
3680
|
};
|
|
3677
|
-
throw
|
|
3681
|
+
throw W(this.subscribeStore, t), e;
|
|
3678
3682
|
}
|
|
3679
3683
|
}
|
|
3680
3684
|
async signUp(e) {
|
|
3681
|
-
if (e.user.email && !
|
|
3685
|
+
if (e.user.email && !_r(e.user.email)) {
|
|
3682
3686
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3683
3687
|
operation: "sign-up",
|
|
3684
3688
|
message: "Invalid email format",
|
|
3685
3689
|
originalError: e,
|
|
3686
3690
|
code: "VALIDATION_ERROR"
|
|
3687
3691
|
};
|
|
3688
|
-
throw
|
|
3692
|
+
throw W(this.subscribeStore, t), e;
|
|
3689
3693
|
}
|
|
3690
|
-
if (e.user.phone_number && !
|
|
3694
|
+
if (e.user.phone_number && !vr(e.user.phone_number)) {
|
|
3691
3695
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3692
3696
|
operation: "sign-up",
|
|
3693
3697
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3694
3698
|
originalError: e,
|
|
3695
3699
|
code: "VALIDATION_ERROR"
|
|
3696
3700
|
};
|
|
3697
|
-
throw
|
|
3701
|
+
throw W(this.subscribeStore, t), e;
|
|
3698
3702
|
}
|
|
3699
3703
|
this.subscribeStore.notify(Z.RegisterStart, { email: e.user.email }), e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
3700
3704
|
try {
|
|
@@ -3715,30 +3719,30 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3715
3719
|
originalError: e,
|
|
3716
3720
|
code: e instanceof B ? e.id : void 0
|
|
3717
3721
|
};
|
|
3718
|
-
throw
|
|
3722
|
+
throw W(this.subscribeStore, t), e;
|
|
3719
3723
|
}
|
|
3720
3724
|
}
|
|
3721
3725
|
async passwordlessSignIn(e) {
|
|
3722
|
-
if (e.email && !
|
|
3726
|
+
if (e.email && !_r(e.email)) {
|
|
3723
3727
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3724
3728
|
operation: "passwordless.start",
|
|
3725
3729
|
message: "Invalid email format",
|
|
3726
3730
|
originalError: e,
|
|
3727
3731
|
code: "VALIDATION_ERROR"
|
|
3728
3732
|
};
|
|
3729
|
-
throw
|
|
3733
|
+
throw W(this.subscribeStore, t), e;
|
|
3730
3734
|
}
|
|
3731
|
-
if (e.phone && !
|
|
3735
|
+
if (e.phone && !vr(e.phone)) {
|
|
3732
3736
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3733
3737
|
operation: "passwordless.start",
|
|
3734
3738
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3735
3739
|
originalError: e,
|
|
3736
3740
|
code: "VALIDATION_ERROR"
|
|
3737
3741
|
};
|
|
3738
|
-
throw
|
|
3742
|
+
throw W(this.subscribeStore, t), e;
|
|
3739
3743
|
}
|
|
3740
3744
|
this.subscribeStore.notify(Z.SignInStart, { email: e.email }), e.scopes = e.scopes ?? this.scopes;
|
|
3741
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
3745
|
+
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
3742
3746
|
try {
|
|
3743
3747
|
return await this.authApi.passwordlessSignIn(e, t, n);
|
|
3744
3748
|
} catch (e) {
|
|
@@ -3748,7 +3752,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3748
3752
|
originalError: e,
|
|
3749
3753
|
code: e instanceof B ? e.id : void 0
|
|
3750
3754
|
};
|
|
3751
|
-
throw
|
|
3755
|
+
throw W(this.subscribeStore, t), e;
|
|
3752
3756
|
}
|
|
3753
3757
|
}
|
|
3754
3758
|
async passwordlessSignInComplete(e) {
|
|
@@ -3766,21 +3770,21 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3766
3770
|
originalError: e,
|
|
3767
3771
|
code: e instanceof B ? e.id : void 0
|
|
3768
3772
|
};
|
|
3769
|
-
throw
|
|
3773
|
+
throw W(this.subscribeStore, t), e;
|
|
3770
3774
|
}
|
|
3771
3775
|
}
|
|
3772
3776
|
async verifyEmailCode(e) {
|
|
3773
3777
|
let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
|
|
3774
3778
|
try {
|
|
3775
3779
|
let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
|
|
3776
|
-
if (t?.pkce && !r) throw Error(
|
|
3780
|
+
if (t?.pkce && !r) throw Error(Tr);
|
|
3777
3781
|
let i = await this.authApi.validateEmailCode(e);
|
|
3778
3782
|
this.emailChallenges.delete(e.challenge_id);
|
|
3779
3783
|
let a = r?.scopes ?? t?.scopes ?? this.scopes;
|
|
3780
3784
|
if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
|
|
3781
3785
|
let o = i;
|
|
3782
3786
|
if (i.code) {
|
|
3783
|
-
if (!r) throw Error(
|
|
3787
|
+
if (!r) throw Error(Tr);
|
|
3784
3788
|
if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
|
|
3785
3789
|
}
|
|
3786
3790
|
let s = i.redirect_url ? {
|
|
@@ -3798,7 +3802,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3798
3802
|
originalError: e,
|
|
3799
3803
|
code: e instanceof B ? e.id : void 0
|
|
3800
3804
|
};
|
|
3801
|
-
throw
|
|
3805
|
+
throw W(this.subscribeStore, t), e;
|
|
3802
3806
|
}
|
|
3803
3807
|
}
|
|
3804
3808
|
async logOut() {
|
|
@@ -3834,13 +3838,13 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3834
3838
|
readSessionPin() {
|
|
3835
3839
|
try {
|
|
3836
3840
|
let e = this.storageManager.getToken(j.access_token);
|
|
3837
|
-
return e ?
|
|
3841
|
+
return e ? pr(A(e)) : void 0;
|
|
3838
3842
|
} catch {
|
|
3839
3843
|
return;
|
|
3840
3844
|
}
|
|
3841
3845
|
}
|
|
3842
3846
|
assertSessionPin(e) {
|
|
3843
|
-
if (e && !
|
|
3847
|
+
if (e && !mr(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 fr("The session changed during verification, so the elevated tokens were discarded");
|
|
3844
3848
|
}
|
|
3845
3849
|
refreshMode() {
|
|
3846
3850
|
return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
|
|
@@ -3868,7 +3872,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3868
3872
|
return;
|
|
3869
3873
|
}
|
|
3870
3874
|
case "error":
|
|
3871
|
-
|
|
3875
|
+
W(n, t);
|
|
3872
3876
|
return;
|
|
3873
3877
|
case "refresh:start":
|
|
3874
3878
|
n.notify(Z.RefreshStart, {});
|
|
@@ -3888,7 +3892,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3888
3892
|
case "signout":
|
|
3889
3893
|
n.notify(Z.SignOut, t);
|
|
3890
3894
|
return;
|
|
3891
|
-
default:
|
|
3895
|
+
default: gn().warn(`[passflow] Unknown refresh event: ${String(e)}`);
|
|
3892
3896
|
}
|
|
3893
3897
|
};
|
|
3894
3898
|
}
|
|
@@ -3946,7 +3950,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3946
3950
|
let e = this.storageManager.getTokens();
|
|
3947
3951
|
if (!e?.refresh_token) {
|
|
3948
3952
|
let t = /* @__PURE__ */ Error(e ? "No refresh token found" : "No tokens found");
|
|
3949
|
-
throw
|
|
3953
|
+
throw W(this.subscribeStore, {
|
|
3950
3954
|
operation: "refresh",
|
|
3951
3955
|
source: "refresh-token",
|
|
3952
3956
|
message: t.message,
|
|
@@ -3969,15 +3973,15 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3969
3973
|
originalError: e,
|
|
3970
3974
|
code: e instanceof B ? e.id : void 0
|
|
3971
3975
|
};
|
|
3972
|
-
throw
|
|
3976
|
+
throw W(this.subscribeStore, t), e;
|
|
3973
3977
|
}
|
|
3974
3978
|
}
|
|
3975
3979
|
async resetPassword(e, t, n) {
|
|
3976
3980
|
this.subscribeStore.notify(Z.SignInStart, {});
|
|
3977
|
-
let r = n ??
|
|
3981
|
+
let r = n ?? Er(this.platform.getCurrentUrl()), i = t ?? this.scopes;
|
|
3978
3982
|
try {
|
|
3979
3983
|
let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
|
|
3980
|
-
if (this.handleEmailVerificationStep(n, "reset-password",
|
|
3984
|
+
if (this.handleEmailVerificationStep(n, "reset-password", Dr(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
|
|
3981
3985
|
let a = await this.exchangeCode(n, t);
|
|
3982
3986
|
if (this.handlePendingSecondFactor(a)) return a;
|
|
3983
3987
|
let o = n.redirect_url ? {
|
|
@@ -3995,13 +3999,13 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3995
3999
|
originalError: e,
|
|
3996
4000
|
code: e instanceof B ? e.id : void 0
|
|
3997
4001
|
};
|
|
3998
|
-
throw
|
|
4002
|
+
throw W(this.subscribeStore, t), e;
|
|
3999
4003
|
}
|
|
4000
4004
|
}
|
|
4001
4005
|
async passkeyRegister(e) {
|
|
4002
4006
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4003
4007
|
this.subscribeStore.notify(Z.RegisterStart, {});
|
|
4004
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
4008
|
+
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
4005
4009
|
e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
4006
4010
|
try {
|
|
4007
4011
|
let r = await this.startPkce(), { challenge_id: i, publicKey: a } = await this.authApi.passkeyRegisterStart(r ? {
|
|
@@ -4025,13 +4029,13 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4025
4029
|
originalError: e,
|
|
4026
4030
|
code: e instanceof B ? e.id : void 0
|
|
4027
4031
|
};
|
|
4028
|
-
throw
|
|
4032
|
+
throw W(this.subscribeStore, t), e;
|
|
4029
4033
|
}
|
|
4030
4034
|
}
|
|
4031
4035
|
async passkeyAuthenticate(e) {
|
|
4032
4036
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4033
4037
|
this.subscribeStore.notify(Z.SignInStart, {});
|
|
4034
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
4038
|
+
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
4035
4039
|
e.scopes = e.scopes ?? this.scopes;
|
|
4036
4040
|
try {
|
|
4037
4041
|
let r = await this.startPkce(), { challenge_id: i, publicKey: a } = await this.authApi.passkeyAuthenticateStart(r ? {
|
|
@@ -4053,7 +4057,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4053
4057
|
originalError: e,
|
|
4054
4058
|
code: e instanceof B ? e.id : void 0
|
|
4055
4059
|
};
|
|
4056
|
-
throw
|
|
4060
|
+
throw W(this.subscribeStore, t), e;
|
|
4057
4061
|
}
|
|
4058
4062
|
}
|
|
4059
4063
|
createFederatedAuthUrl(e) {
|
|
@@ -4099,7 +4103,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4099
4103
|
code: e instanceof ie ? "POPUP_CLOSED" : "AUTH_FAILED",
|
|
4100
4104
|
originalError: e
|
|
4101
4105
|
};
|
|
4102
|
-
|
|
4106
|
+
W(this.subscribeStore, t);
|
|
4103
4107
|
}
|
|
4104
4108
|
}
|
|
4105
4109
|
federatedAuthWithRedirect(e) {
|
|
@@ -4127,7 +4131,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4127
4131
|
message: e instanceof Error ? e.message : "Failed to create auth redirect URL",
|
|
4128
4132
|
originalError: e
|
|
4129
4133
|
};
|
|
4130
|
-
throw
|
|
4134
|
+
throw W(this.subscribeStore, t), e;
|
|
4131
4135
|
}
|
|
4132
4136
|
}
|
|
4133
4137
|
authRedirect(e = {}) {
|
|
@@ -4139,7 +4143,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4139
4143
|
message: e instanceof Error ? e.message : "Failed to redirect to auth page",
|
|
4140
4144
|
originalError: e
|
|
4141
4145
|
};
|
|
4142
|
-
throw
|
|
4146
|
+
throw W(this.subscribeStore, t), e;
|
|
4143
4147
|
}
|
|
4144
4148
|
}
|
|
4145
4149
|
isAuthenticated(e) {
|
|
@@ -4155,7 +4159,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4155
4159
|
message: e instanceof Error ? e.message : "Failed to check authentication status",
|
|
4156
4160
|
originalError: e
|
|
4157
4161
|
};
|
|
4158
|
-
return
|
|
4162
|
+
return W(this.subscribeStore, t), !1;
|
|
4159
4163
|
}
|
|
4160
4164
|
}
|
|
4161
4165
|
async submitSessionCheck(e = !1) {
|
|
@@ -4168,7 +4172,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4168
4172
|
message: e instanceof Error || e instanceof B ? e.message : "Session check failed",
|
|
4169
4173
|
originalError: e
|
|
4170
4174
|
};
|
|
4171
|
-
|
|
4175
|
+
W(this.subscribeStore, n), t = void 0;
|
|
4172
4176
|
}
|
|
4173
4177
|
return t && this.sessionCallbacks.createSession && await this.sessionCallbacks.createSession({
|
|
4174
4178
|
tokens: t,
|
|
@@ -4195,11 +4199,11 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4195
4199
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4196
4200
|
originalError: e
|
|
4197
4201
|
};
|
|
4198
|
-
|
|
4202
|
+
W(this.subscribeStore, t);
|
|
4199
4203
|
return;
|
|
4200
4204
|
}
|
|
4201
4205
|
}
|
|
4202
|
-
},
|
|
4206
|
+
}, kr = class {
|
|
4203
4207
|
constructor(e) {
|
|
4204
4208
|
this.invitationApi = e;
|
|
4205
4209
|
}
|
|
@@ -4218,7 +4222,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4218
4222
|
getInvitationLink(e) {
|
|
4219
4223
|
return this.invitationApi.getInvitationLink(e);
|
|
4220
4224
|
}
|
|
4221
|
-
},
|
|
4225
|
+
}, Ar = class {
|
|
4222
4226
|
constructor(e) {
|
|
4223
4227
|
this.data = this.normalize(e);
|
|
4224
4228
|
}
|
|
@@ -4275,9 +4279,9 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4275
4279
|
getData() {
|
|
4276
4280
|
return this.data;
|
|
4277
4281
|
}
|
|
4278
|
-
},
|
|
4282
|
+
}, jr = class {
|
|
4279
4283
|
constructor(e, t, n) {
|
|
4280
|
-
this.tenantApi = e, this.scopes = t, this.logger = n ||
|
|
4284
|
+
this.tenantApi = e, this.scopes = t, this.logger = n || gn();
|
|
4281
4285
|
}
|
|
4282
4286
|
handlePassflowError(t, n) {
|
|
4283
4287
|
if (e.isAxiosError(t) && t.response?.data) {
|
|
@@ -4313,7 +4317,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4313
4317
|
}
|
|
4314
4318
|
async getTenantUserMembership(e) {
|
|
4315
4319
|
try {
|
|
4316
|
-
return new
|
|
4320
|
+
return new Ar(await this.tenantApi.getTenantDetails(e));
|
|
4317
4321
|
} catch (t) {
|
|
4318
4322
|
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
4319
4323
|
}
|
|
@@ -4458,7 +4462,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4458
4462
|
this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
|
|
4459
4463
|
}
|
|
4460
4464
|
}
|
|
4461
|
-
},
|
|
4465
|
+
}, Mr = class {
|
|
4462
4466
|
constructor(e, t, n, r = P) {
|
|
4463
4467
|
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();
|
|
4464
4468
|
}
|
|
@@ -4483,7 +4487,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4483
4487
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4484
4488
|
originalError: e
|
|
4485
4489
|
};
|
|
4486
|
-
|
|
4490
|
+
W(this.subscribeStore, t), this.setTokensCache(void 0);
|
|
4487
4491
|
}
|
|
4488
4492
|
}
|
|
4489
4493
|
startTokenCheck() {
|
|
@@ -4528,7 +4532,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4528
4532
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4529
4533
|
originalError: e
|
|
4530
4534
|
};
|
|
4531
|
-
|
|
4535
|
+
W(this.subscribeStore, t);
|
|
4532
4536
|
return;
|
|
4533
4537
|
}
|
|
4534
4538
|
}
|
|
@@ -4538,7 +4542,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4538
4542
|
isExpired() {
|
|
4539
4543
|
return this.tokensCache ? this.tokensCache.access_token ? k(A(this.tokensCache.access_token)) : !1 : !0;
|
|
4540
4544
|
}
|
|
4541
|
-
},
|
|
4545
|
+
}, Nr = class {
|
|
4542
4546
|
constructor(e, t, n) {
|
|
4543
4547
|
this.twoFactorApi = e, this.subscribeStore = t, this.signInCompleter = n, this.PARTIAL_AUTH_TIMEOUT_MS = 3e5, this.SESSION_STORAGE_KEY = "passflow_2fa_challenge", this.totpDigits = 6, this.subscribeStore.subscribe({ onAuthChange: (e, t) => {
|
|
4544
4548
|
if (e === Z.TwoFactorRequired) {
|
|
@@ -4559,7 +4563,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4559
4563
|
originalError: e,
|
|
4560
4564
|
code: r?.id || void 0
|
|
4561
4565
|
};
|
|
4562
|
-
throw
|
|
4566
|
+
throw W(this.subscribeStore, i), e;
|
|
4563
4567
|
}
|
|
4564
4568
|
async getStatus() {
|
|
4565
4569
|
try {
|
|
@@ -4578,7 +4582,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4578
4582
|
}
|
|
4579
4583
|
}
|
|
4580
4584
|
async confirmSetup(e) {
|
|
4581
|
-
if (!
|
|
4585
|
+
if (!br(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4582
4586
|
try {
|
|
4583
4587
|
let t = await this.twoFactorApi.confirmSetup({ code: e });
|
|
4584
4588
|
return this.subscribeStore.notify(Z.TwoFactorEnabled, {
|
|
@@ -4592,7 +4596,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4592
4596
|
}
|
|
4593
4597
|
}
|
|
4594
4598
|
async verify(e, t) {
|
|
4595
|
-
if (!
|
|
4599
|
+
if (!br(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4596
4600
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4597
4601
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
4598
4602
|
try {
|
|
@@ -4608,7 +4612,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4608
4612
|
}
|
|
4609
4613
|
async useRecoveryCode(e, t) {
|
|
4610
4614
|
try {
|
|
4611
|
-
let n =
|
|
4615
|
+
let n = xr(e);
|
|
4612
4616
|
if (!n) throw Error("Invalid recovery code format. Expected format: XXXX-XXXX or XXXXXXXX (alphanumeric).");
|
|
4613
4617
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4614
4618
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
@@ -4629,7 +4633,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4629
4633
|
}
|
|
4630
4634
|
}
|
|
4631
4635
|
async disable(e) {
|
|
4632
|
-
if (!
|
|
4636
|
+
if (!br(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4633
4637
|
try {
|
|
4634
4638
|
let t = await this.twoFactorApi.disable({ code: e });
|
|
4635
4639
|
return this.subscribeStore.notify(Z.TwoFactorDisabled, {}), t;
|
|
@@ -4638,7 +4642,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4638
4642
|
}
|
|
4639
4643
|
}
|
|
4640
4644
|
async regenerateRecoveryCodes(e) {
|
|
4641
|
-
if (!
|
|
4645
|
+
if (!br(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4642
4646
|
try {
|
|
4643
4647
|
let t = await this.twoFactorApi.regenerateRecoveryCodes({ code: e }), n = [...t.recovery_codes];
|
|
4644
4648
|
return t.recovery_codes = [], t.recovery_codes = n, t;
|
|
@@ -4822,7 +4826,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4822
4826
|
this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
|
|
4823
4827
|
}
|
|
4824
4828
|
}
|
|
4825
|
-
},
|
|
4829
|
+
}, Pr = class {
|
|
4826
4830
|
constructor(e, t, n = P) {
|
|
4827
4831
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
4828
4832
|
}
|
|
@@ -4837,7 +4841,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4837
4841
|
}
|
|
4838
4842
|
async addUserPasskey({ relyingPartyId: e, passkeyUsername: t, passkeyDisplayName: n } = {}) {
|
|
4839
4843
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4840
|
-
let r = this.deviceService.getDeviceId(), i =
|
|
4844
|
+
let r = this.deviceService.getDeviceId(), i = Le(this.platform.getDeviceType()), { challenge_id: a, publicKey: o } = await this.userAPI.addUserPasskeyStart({
|
|
4841
4845
|
relyingPartyId: (e || this.platform.getCurrentUrl()?.hostname) ?? "",
|
|
4842
4846
|
deviceId: r,
|
|
4843
4847
|
os: i,
|
|
@@ -4849,69 +4853,69 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4849
4853
|
if (!s) throw Error("Passkey registration was not completed");
|
|
4850
4854
|
return await this.userAPI.addUserPasskeyComplete(s, r, a);
|
|
4851
4855
|
}
|
|
4852
|
-
},
|
|
4856
|
+
}, Fr = class extends Error {
|
|
4853
4857
|
constructor(e, t, n = !1) {
|
|
4854
4858
|
super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
|
|
4855
4859
|
}
|
|
4856
|
-
},
|
|
4860
|
+
}, Ir = (e, t) => {
|
|
4857
4861
|
let n = t?.trim();
|
|
4858
|
-
if (!n) throw new
|
|
4862
|
+
if (!n) throw new Fr(e, "A verification code is required");
|
|
4859
4863
|
return n;
|
|
4860
|
-
},
|
|
4864
|
+
}, Lr = {
|
|
4861
4865
|
type: "totp",
|
|
4862
4866
|
requiresPrepare: !1,
|
|
4863
4867
|
input: "code",
|
|
4864
|
-
assert: async ({ code: e }) => ({ code:
|
|
4865
|
-
},
|
|
4868
|
+
assert: async ({ code: e }) => ({ code: Ir("totp", e) })
|
|
4869
|
+
}, Rr = {
|
|
4866
4870
|
type: "recovery_codes",
|
|
4867
4871
|
requiresPrepare: !1,
|
|
4868
4872
|
input: "code",
|
|
4869
|
-
assert: async ({ code: e }) => ({ code:
|
|
4870
|
-
},
|
|
4873
|
+
assert: async ({ code: e }) => ({ code: Ir("recovery_codes", e) })
|
|
4874
|
+
}, zr = {
|
|
4871
4875
|
type: "passkey",
|
|
4872
4876
|
requiresPrepare: !0,
|
|
4873
4877
|
input: "none",
|
|
4874
4878
|
assert: async ({ prepared: e, platform: t }) => {
|
|
4875
|
-
if (!e?.webauthn) throw new
|
|
4879
|
+
if (!e?.webauthn) throw new Fr("passkey", "The upgrade challenge carried no WebAuthn options");
|
|
4876
4880
|
let n = t.passkeys;
|
|
4877
|
-
if (!n) throw new
|
|
4881
|
+
if (!n) throw new Fr("passkey", "This platform does not support passkeys");
|
|
4878
4882
|
let r;
|
|
4879
4883
|
try {
|
|
4880
4884
|
r = await n.startAuthentication(e.webauthn);
|
|
4881
4885
|
} catch (e) {
|
|
4882
|
-
throw new
|
|
4886
|
+
throw new Fr("passkey", e?.message || "Passkey verification was cancelled", !0);
|
|
4883
4887
|
}
|
|
4884
|
-
if (!r) throw new
|
|
4888
|
+
if (!r) throw new Fr("passkey", "Passkey verification was cancelled", !0);
|
|
4885
4889
|
return {
|
|
4886
4890
|
challenge_id: e.challengeId,
|
|
4887
4891
|
credential: r
|
|
4888
4892
|
};
|
|
4889
4893
|
}
|
|
4890
|
-
},
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
]),
|
|
4894
|
+
}, Br = Object.freeze([
|
|
4895
|
+
Lr,
|
|
4896
|
+
zr,
|
|
4897
|
+
Rr
|
|
4898
|
+
]), Vr = (e = Br) => new Map(e.map((e) => [e.type, e])), Hr = 3, Ur = {
|
|
4895
4899
|
passkey: 0,
|
|
4896
4900
|
totp: 1,
|
|
4897
4901
|
email_otp: 2,
|
|
4898
4902
|
sms_otp: 3,
|
|
4899
4903
|
recovery_codes: 9
|
|
4900
|
-
},
|
|
4901
|
-
let n =
|
|
4904
|
+
}, Wr = (e) => e.requiredLevel ?? L(e.acrValues), Gr = (e, t) => {
|
|
4905
|
+
let n = Ur[e.type] ?? 5, r = t !== void 0 && t >= Hr, i = e.type === "passkey";
|
|
4902
4906
|
return (r && !i ? 100 : 0) + n;
|
|
4903
|
-
},
|
|
4904
|
-
let n =
|
|
4905
|
-
return [...e].sort((e, t) =>
|
|
4906
|
-
},
|
|
4907
|
+
}, Kr = (e, t) => {
|
|
4908
|
+
let n = Wr(t);
|
|
4909
|
+
return [...e].sort((e, t) => Gr(e, n) - Gr(t, n));
|
|
4910
|
+
}, qr = class extends Error {
|
|
4907
4911
|
constructor(e) {
|
|
4908
4912
|
super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
|
|
4909
4913
|
}
|
|
4910
|
-
},
|
|
4914
|
+
}, Jr = class extends Error {
|
|
4911
4915
|
constructor(e = "No available authentication factor can satisfy this challenge") {
|
|
4912
4916
|
super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
|
|
4913
4917
|
}
|
|
4914
|
-
},
|
|
4918
|
+
}, Yr = 4, Xr = 3e4, Zr = () => {
|
|
4915
4919
|
let e = () => void 0, t = () => void 0;
|
|
4916
4920
|
return {
|
|
4917
4921
|
promise: new Promise((n, r) => {
|
|
@@ -4920,11 +4924,11 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4920
4924
|
resolve: e,
|
|
4921
4925
|
reject: t
|
|
4922
4926
|
};
|
|
4923
|
-
},
|
|
4927
|
+
}, Qr = (e) => ({
|
|
4924
4928
|
acrValues: e.acrValues,
|
|
4925
4929
|
level: e.requiredLevel,
|
|
4926
4930
|
maxAge: e.maxAge
|
|
4927
|
-
}),
|
|
4931
|
+
}), $r = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, ei = (e, t) => {
|
|
4928
4932
|
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 ?? []]));
|
|
4929
4933
|
return {
|
|
4930
4934
|
acrValues: r,
|
|
@@ -4933,12 +4937,12 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4933
4937
|
status: e.status,
|
|
4934
4938
|
...a.length > 0 ? { channels: a } : {}
|
|
4935
4939
|
};
|
|
4936
|
-
},
|
|
4940
|
+
}, ti = (e, t) => {
|
|
4937
4941
|
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);
|
|
4938
4942
|
return n || r;
|
|
4939
|
-
},
|
|
4943
|
+
}, ni = class {
|
|
4940
4944
|
constructor(e) {
|
|
4941
|
-
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 ??
|
|
4945
|
+
this.state = "idle", this.inFlight = null, this.requirement = null, this.selected = null, this.rankedRequirement = null, this.registrations = [], this.proof = null, this.pruned = /* @__PURE__ */ new Set(), this.openPrompt = null, this.transport = e.transport, this.prompt = e.prompt, this.platform = e.platform, this.available = e.factors ?? Br, this.registry = Vr(this.available), this.maxAttempts = e.maxAttempts ?? Yr, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? Xr;
|
|
4942
4946
|
}
|
|
4943
4947
|
get currentState() {
|
|
4944
4948
|
return this.state;
|
|
@@ -4958,9 +4962,9 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4958
4962
|
}
|
|
4959
4963
|
register(e, t) {
|
|
4960
4964
|
let n = t.kind === "imperative" && t.requested !== void 0, r = {
|
|
4961
|
-
demanded: t.kind === "imperative" && t.requested ? t.requested :
|
|
4965
|
+
demanded: t.kind === "imperative" && t.requested ? t.requested : Qr(e),
|
|
4962
4966
|
statedBar: n,
|
|
4963
|
-
settlement:
|
|
4967
|
+
settlement: Zr(),
|
|
4964
4968
|
reported: !1,
|
|
4965
4969
|
entry: {
|
|
4966
4970
|
...t,
|
|
@@ -4976,15 +4980,15 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4976
4980
|
this.requirement = e;
|
|
4977
4981
|
return;
|
|
4978
4982
|
}
|
|
4979
|
-
let n =
|
|
4980
|
-
this.requirement =
|
|
4983
|
+
let n = ti(t, e);
|
|
4984
|
+
this.requirement = ei(t, e), n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
|
|
4981
4985
|
challenge: this.requirement,
|
|
4982
4986
|
factors: this.offeredFactors()
|
|
4983
4987
|
});
|
|
4984
4988
|
}
|
|
4985
4989
|
offeredFactors() {
|
|
4986
4990
|
let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
|
|
4987
|
-
return t ?
|
|
4991
|
+
return t ? Kr(e, t) : e;
|
|
4988
4992
|
}
|
|
4989
4993
|
receiveReport(e, t) {
|
|
4990
4994
|
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());
|
|
@@ -5019,12 +5023,12 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5019
5023
|
}
|
|
5020
5024
|
release(e, t) {
|
|
5021
5025
|
if (e.entry.kind === "imperative") {
|
|
5022
|
-
if (e.statedBar &&
|
|
5026
|
+
if (e.statedBar && !$r(t, e.demanded)) {
|
|
5023
5027
|
this.receiveReport(e, {
|
|
5024
5028
|
outcome: "insufficient",
|
|
5025
5029
|
obtained: t,
|
|
5026
5030
|
required: e.demanded
|
|
5027
|
-
}), e.settlement.reject(new
|
|
5031
|
+
}), e.settlement.reject(new ur(t, e.demanded));
|
|
5028
5032
|
return;
|
|
5029
5033
|
}
|
|
5030
5034
|
this.receiveReport(e, {
|
|
@@ -5097,7 +5101,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5097
5101
|
let t = this.offeredFactors();
|
|
5098
5102
|
if (t.length === 0) return {
|
|
5099
5103
|
status: "failed",
|
|
5100
|
-
reason: new
|
|
5104
|
+
reason: new Jr()
|
|
5101
5105
|
};
|
|
5102
5106
|
let n = this.requirement, r;
|
|
5103
5107
|
try {
|
|
@@ -5105,24 +5109,24 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5105
5109
|
} catch (e) {
|
|
5106
5110
|
return {
|
|
5107
5111
|
status: "failed",
|
|
5108
|
-
reason: new
|
|
5112
|
+
reason: new qr(e)
|
|
5109
5113
|
};
|
|
5110
5114
|
}
|
|
5111
5115
|
if (r.type === "cancel") return {
|
|
5112
5116
|
status: "failed",
|
|
5113
|
-
reason: new
|
|
5117
|
+
reason: new qr()
|
|
5114
5118
|
};
|
|
5115
5119
|
let i = this.registry.get(r.factor);
|
|
5116
|
-
if (!i) e = new
|
|
5120
|
+
if (!i) e = new Jr(`Unknown authentication factor: ${r.factor}`), this.state = "collecting", this.selected = null;
|
|
5117
5121
|
else try {
|
|
5118
5122
|
return await this.proveAndCommit(i, r.code), {
|
|
5119
5123
|
status: "proven",
|
|
5120
|
-
obtained: this.readObtainedBar?.() ??
|
|
5124
|
+
obtained: this.readObtainedBar?.() ?? Qr(this.rankedRequirement ?? n)
|
|
5121
5125
|
};
|
|
5122
5126
|
} catch (t) {
|
|
5123
|
-
if (t instanceof
|
|
5127
|
+
if (t instanceof Fr && t.cancelled) return {
|
|
5124
5128
|
status: "failed",
|
|
5125
|
-
reason: new
|
|
5129
|
+
reason: new qr()
|
|
5126
5130
|
};
|
|
5127
5131
|
let n = this.classifyProofFailure(t);
|
|
5128
5132
|
if (n) return {
|
|
@@ -5152,15 +5156,15 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5152
5156
|
return this.openPrompt = r, this.prompt(r);
|
|
5153
5157
|
}
|
|
5154
5158
|
classifyProofFailure(e) {
|
|
5155
|
-
if (e instanceof
|
|
5159
|
+
if (e instanceof ur || e instanceof dr || e instanceof fr) return e;
|
|
5156
5160
|
if (e instanceof $) switch (e.kind) {
|
|
5157
|
-
case "unavailable": return new
|
|
5161
|
+
case "unavailable": return new dr(e.message);
|
|
5158
5162
|
case "exhausted":
|
|
5159
5163
|
case "attempts_exhausted":
|
|
5160
5164
|
case "fatal":
|
|
5161
5165
|
case "protocol":
|
|
5162
5166
|
case "network": return e;
|
|
5163
|
-
case "session_changed": return new
|
|
5167
|
+
case "session_changed": return new fr(e.message);
|
|
5164
5168
|
default: return;
|
|
5165
5169
|
}
|
|
5166
5170
|
}
|
|
@@ -5172,28 +5176,28 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5172
5176
|
});
|
|
5173
5177
|
await this.transport.commit(e.type, r);
|
|
5174
5178
|
}
|
|
5175
|
-
},
|
|
5179
|
+
}, ri = (e) => typeof e == "function" ? e() : e, ii = (e) => {
|
|
5176
5180
|
try {
|
|
5177
5181
|
return new URL(e);
|
|
5178
5182
|
} catch {
|
|
5179
5183
|
return;
|
|
5180
5184
|
}
|
|
5181
|
-
},
|
|
5185
|
+
}, ai = (e, t) => {
|
|
5182
5186
|
if (!t || t === "/") return !0;
|
|
5183
5187
|
let n = t.replace(/\/+$/, "");
|
|
5184
5188
|
return e === n || e.startsWith(`${n}/`);
|
|
5185
|
-
},
|
|
5189
|
+
}, oi = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && ai(e.pathname, t.pathPrefix), si = (e, t) => {
|
|
5186
5190
|
for (let n of t) {
|
|
5187
5191
|
if (n === "") continue;
|
|
5188
5192
|
if (n.startsWith("/")) {
|
|
5189
|
-
if (e.relativeToBase &&
|
|
5193
|
+
if (e.relativeToBase && ai(e.pathname, n)) return !0;
|
|
5190
5194
|
continue;
|
|
5191
5195
|
}
|
|
5192
|
-
let t =
|
|
5193
|
-
if (t && e.origin !== void 0 && e.origin === t.origin &&
|
|
5196
|
+
let t = ii(n) ?? ii(`https://${n}`);
|
|
5197
|
+
if (t && e.origin !== void 0 && e.origin === t.origin && ai(e.pathname, t.pathname)) return !0;
|
|
5194
5198
|
}
|
|
5195
5199
|
return !1;
|
|
5196
|
-
},
|
|
5200
|
+
}, ci = (e, t, n) => oi(e, t.passflow) || si(e, t.backend) ? !n || n(e.href) !== !1 : !1, li = (e) => {
|
|
5197
5201
|
let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
|
|
5198
5202
|
console.warn(n, {
|
|
5199
5203
|
status: e.status,
|
|
@@ -5201,8 +5205,8 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5201
5205
|
reason: e.reason,
|
|
5202
5206
|
detail: t
|
|
5203
5207
|
});
|
|
5204
|
-
},
|
|
5205
|
-
let n = t.onUpgradeDiagnostic ??
|
|
5208
|
+
}, ui = (e, t) => {
|
|
5209
|
+
let n = t.onUpgradeDiagnostic ?? li;
|
|
5206
5210
|
return (t, r) => {
|
|
5207
5211
|
n({
|
|
5208
5212
|
status: e.status,
|
|
@@ -5214,8 +5218,8 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5214
5218
|
}
|
|
5215
5219
|
});
|
|
5216
5220
|
};
|
|
5217
|
-
},
|
|
5218
|
-
let r = n.onUpgradeDiagnostic ??
|
|
5221
|
+
}, di = (e, t, n) => {
|
|
5222
|
+
let r = n.onUpgradeDiagnostic ?? li;
|
|
5219
5223
|
for (let n of e) r({
|
|
5220
5224
|
...n,
|
|
5221
5225
|
url: t.request.href,
|
|
@@ -5224,8 +5228,8 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5224
5228
|
...n.detail ?? {}
|
|
5225
5229
|
}
|
|
5226
5230
|
});
|
|
5227
|
-
},
|
|
5228
|
-
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n &&
|
|
5231
|
+
}, fi = /\bjson\b/i, pi = async (e, t) => {
|
|
5232
|
+
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && fi.test(r), a;
|
|
5229
5233
|
if (i) try {
|
|
5230
5234
|
a = await e.readBody();
|
|
5231
5235
|
} catch {
|
|
@@ -5239,10 +5243,10 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5239
5243
|
status: e.status,
|
|
5240
5244
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5241
5245
|
}, { requireChallengeChannel: t.requireChallengeChannel });
|
|
5242
|
-
},
|
|
5246
|
+
}, mi = (e) => ve({
|
|
5243
5247
|
status: e.status,
|
|
5244
5248
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5245
|
-
}, { requireChallengeChannel: "header" }).challenge,
|
|
5249
|
+
}, { requireChallengeChannel: "header" }).challenge, hi = (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.`, gi = (e, t) => e instanceof qr ? { kind: "cancelled" } : e instanceof Jr ? { kind: "unsatisfiable" } : e instanceof dr ? { kind: "unavailable" } : e instanceof fr ? { kind: "session-changed" } : e instanceof ur ? {
|
|
5246
5250
|
kind: "insufficient",
|
|
5247
5251
|
obtained: e.obtained,
|
|
5248
5252
|
required: e.required
|
|
@@ -5258,17 +5262,17 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5258
5262
|
kind: "transport-failure",
|
|
5259
5263
|
retryable: !1,
|
|
5260
5264
|
error: e instanceof Error ? e : Error(String(e))
|
|
5261
|
-
},
|
|
5265
|
+
}, _i = async (e, t, n, r) => {
|
|
5262
5266
|
if (e.status !== 401 && e.status !== 403) return {
|
|
5263
5267
|
kind: "replayed",
|
|
5264
5268
|
response: e
|
|
5265
5269
|
};
|
|
5266
|
-
let { challenge: i, diagnostics: a } = await
|
|
5267
|
-
if (
|
|
5270
|
+
let { challenge: i, diagnostics: a } = await pi(e, t);
|
|
5271
|
+
if (di(a, e, t), !i) return {
|
|
5268
5272
|
kind: "replayed",
|
|
5269
5273
|
response: e
|
|
5270
5274
|
};
|
|
5271
|
-
let o =
|
|
5275
|
+
let o = Qr(i);
|
|
5272
5276
|
return r("elevated-insufficient", {
|
|
5273
5277
|
obtained: n,
|
|
5274
5278
|
required: o
|
|
@@ -5278,7 +5282,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5278
5282
|
required: o,
|
|
5279
5283
|
response: e
|
|
5280
5284
|
};
|
|
5281
|
-
},
|
|
5285
|
+
}, vi = async (e, t) => {
|
|
5282
5286
|
if (!t) return {
|
|
5283
5287
|
aborted: !1,
|
|
5284
5288
|
value: await e
|
|
@@ -5305,14 +5309,14 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5305
5309
|
} finally {
|
|
5306
5310
|
n && t.removeEventListener?.("abort", n);
|
|
5307
5311
|
}
|
|
5308
|
-
},
|
|
5312
|
+
}, yi = async (e, t) => {
|
|
5309
5313
|
if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
|
|
5310
|
-
let n =
|
|
5314
|
+
let n = ui(e, t);
|
|
5311
5315
|
if (e.markers.replayed) {
|
|
5312
|
-
if (!
|
|
5313
|
-
let { challenge: r, diagnostics: i } = await
|
|
5314
|
-
if (
|
|
5315
|
-
let a = t.readObtainedBar?.() ?? {}, o =
|
|
5316
|
+
if (!ci(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
|
|
5317
|
+
let { challenge: r, diagnostics: i } = await pi(e, t);
|
|
5318
|
+
if (di(i, e, t), !r) return { kind: "not-a-challenge" };
|
|
5319
|
+
let a = t.readObtainedBar?.() ?? {}, o = Qr(r);
|
|
5316
5320
|
return n("elevated-insufficient", {
|
|
5317
5321
|
obtained: a,
|
|
5318
5322
|
required: o
|
|
@@ -5323,12 +5327,12 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5323
5327
|
response: e
|
|
5324
5328
|
};
|
|
5325
5329
|
}
|
|
5326
|
-
if (!
|
|
5330
|
+
if (!ci(e.request, t.scope, t.shouldIntercept)) return mi(e) ? (n("challenge-out-of-scope", {
|
|
5327
5331
|
header: e.getHeader("www-authenticate") ?? void 0,
|
|
5328
|
-
message:
|
|
5332
|
+
message: hi(e.request.href, t.scope)
|
|
5329
5333
|
}), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
|
|
5330
|
-
let { challenge: r, diagnostics: i } = await
|
|
5331
|
-
if (
|
|
5334
|
+
let { challenge: r, diagnostics: i } = await pi(e, t);
|
|
5335
|
+
if (di(i, e, t), !r) {
|
|
5332
5336
|
let r = e.getHeader("www-authenticate");
|
|
5333
5337
|
return t.requireChallengeChannel !== "header" && n("no-channel", {
|
|
5334
5338
|
...r ? { header: r } : {},
|
|
@@ -5342,9 +5346,9 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5342
5346
|
method: e.request.method
|
|
5343
5347
|
}, s, c;
|
|
5344
5348
|
try {
|
|
5345
|
-
s = Promise.resolve(t.elevate(r, o)), c = await
|
|
5349
|
+
s = Promise.resolve(t.elevate(r, o)), c = await vi(s, e.signal);
|
|
5346
5350
|
} catch (e) {
|
|
5347
|
-
return
|
|
5351
|
+
return gi(e, void 0);
|
|
5348
5352
|
}
|
|
5349
5353
|
if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
|
|
5350
5354
|
kind: "aborted",
|
|
@@ -5355,7 +5359,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5355
5359
|
kind: "aborted",
|
|
5356
5360
|
reason: e.signal.reason
|
|
5357
5361
|
};
|
|
5358
|
-
let u = l?.obtained ?? t.readObtainedBar?.() ??
|
|
5362
|
+
let u = l?.obtained ?? t.readObtainedBar?.() ?? Qr(r), d = t.authorizationSwap?.(), f = d ? {
|
|
5359
5363
|
from: a?.from ?? d.from,
|
|
5360
5364
|
to: d.to
|
|
5361
5365
|
} : void 0;
|
|
@@ -5364,7 +5368,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5364
5368
|
try {
|
|
5365
5369
|
p = await e.replay(f ? { authorizationSwap: f } : void 0);
|
|
5366
5370
|
} catch (t) {
|
|
5367
|
-
if (t instanceof
|
|
5371
|
+
if (t instanceof ur) return l?.waiter.report({
|
|
5368
5372
|
outcome: "insufficient",
|
|
5369
5373
|
obtained: t.obtained,
|
|
5370
5374
|
required: t.required
|
|
@@ -5382,7 +5386,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5382
5386
|
};
|
|
5383
5387
|
throw t;
|
|
5384
5388
|
}
|
|
5385
|
-
let m = await
|
|
5389
|
+
let m = await _i(p, t, u, n);
|
|
5386
5390
|
return m.kind === "insufficient" ? l?.waiter.report({
|
|
5387
5391
|
outcome: "insufficient",
|
|
5388
5392
|
obtained: m.obtained,
|
|
@@ -5391,18 +5395,18 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5391
5395
|
outcome: "replayed",
|
|
5392
5396
|
obtained: u
|
|
5393
5397
|
}), m;
|
|
5394
|
-
},
|
|
5398
|
+
}, bi = (e) => {
|
|
5395
5399
|
switch (e.kind) {
|
|
5396
|
-
case "cancelled": return new
|
|
5397
|
-
case "unsatisfiable": return new
|
|
5398
|
-
case "unavailable": return new
|
|
5399
|
-
case "session-changed": return new
|
|
5400
|
-
case "insufficient": return new
|
|
5400
|
+
case "cancelled": return new qr();
|
|
5401
|
+
case "unsatisfiable": return new Jr();
|
|
5402
|
+
case "unavailable": return new dr();
|
|
5403
|
+
case "session-changed": return new fr();
|
|
5404
|
+
case "insufficient": return new ur(e.obtained, e.required);
|
|
5401
5405
|
case "exhausted": return e.error;
|
|
5402
5406
|
case "transport-failure": return e.error;
|
|
5403
5407
|
default: return;
|
|
5404
5408
|
}
|
|
5405
|
-
},
|
|
5409
|
+
}, xi = (e, t, n) => {
|
|
5406
5410
|
switch (e.kind) {
|
|
5407
5411
|
case "replayed": return {
|
|
5408
5412
|
settle: "resolve",
|
|
@@ -5420,21 +5424,21 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5420
5424
|
};
|
|
5421
5425
|
case "cancelled": return n.onCancel === "reject" ? {
|
|
5422
5426
|
settle: "reject",
|
|
5423
|
-
error: new
|
|
5427
|
+
error: new qr()
|
|
5424
5428
|
} : {
|
|
5425
5429
|
settle: "resolve",
|
|
5426
|
-
value:
|
|
5430
|
+
value: Ai(t, e)
|
|
5427
5431
|
};
|
|
5428
5432
|
case "insufficient": return {
|
|
5429
5433
|
settle: "resolve",
|
|
5430
|
-
value:
|
|
5434
|
+
value: Ai(e.response?.raw ?? t, e)
|
|
5431
5435
|
};
|
|
5432
5436
|
default: return {
|
|
5433
5437
|
settle: "resolve",
|
|
5434
|
-
value:
|
|
5438
|
+
value: Ai(t, e)
|
|
5435
5439
|
};
|
|
5436
5440
|
}
|
|
5437
|
-
},
|
|
5441
|
+
}, Si = (e, t) => {
|
|
5438
5442
|
switch (e.kind) {
|
|
5439
5443
|
case "replayed": return e.response.rejected ? {
|
|
5440
5444
|
settle: "reject",
|
|
@@ -5449,39 +5453,39 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5449
5453
|
};
|
|
5450
5454
|
default: return {
|
|
5451
5455
|
settle: "reject",
|
|
5452
|
-
error:
|
|
5456
|
+
error: bi(e) ?? t
|
|
5453
5457
|
};
|
|
5454
5458
|
}
|
|
5455
|
-
},
|
|
5459
|
+
}, Ci = /* @__PURE__ */ new WeakSet(), wi = /* @__PURE__ */ new WeakSet(), Ti = /* @__PURE__ */ new WeakSet(), Ei = /* @__PURE__ */ new WeakSet(), Di = /* @__PURE__ */ new WeakSet(), Oi = /* @__PURE__ */ new WeakSet(), ki = /* @__PURE__ */ new WeakSet(), Ai = (e, t) => {
|
|
5456
5460
|
switch (t.kind) {
|
|
5457
5461
|
case "cancelled":
|
|
5458
|
-
|
|
5462
|
+
Ci.add(e);
|
|
5459
5463
|
break;
|
|
5460
5464
|
case "exhausted":
|
|
5461
|
-
|
|
5465
|
+
wi.add(e);
|
|
5462
5466
|
break;
|
|
5463
5467
|
case "insufficient":
|
|
5464
|
-
|
|
5468
|
+
Ti.add(e);
|
|
5465
5469
|
break;
|
|
5466
5470
|
case "unsatisfiable":
|
|
5467
|
-
|
|
5471
|
+
Ei.add(e);
|
|
5468
5472
|
break;
|
|
5469
5473
|
case "unavailable":
|
|
5470
|
-
|
|
5474
|
+
Di.add(e);
|
|
5471
5475
|
break;
|
|
5472
5476
|
case "session-changed":
|
|
5473
|
-
|
|
5477
|
+
Oi.add(e);
|
|
5474
5478
|
break;
|
|
5475
|
-
case "transport-failure":
|
|
5479
|
+
case "transport-failure": ki.add(e);
|
|
5476
5480
|
}
|
|
5477
5481
|
return e;
|
|
5478
|
-
},
|
|
5482
|
+
}, ji = (e) => Ci.has(e), Mi = (e) => wi.has(e), Ni = (e) => Ti.has(e), Pi = (e) => Ei.has(e), Fi = (e) => Di.has(e), Ii = (e) => Oi.has(e), Li = (e) => ki.has(e), Ri = "https://passflow-relative.invalid", zi = () => {
|
|
5479
5483
|
let e = globalThis, t = e.document?.baseURI;
|
|
5480
5484
|
if (typeof t == "string" && t !== "") return t;
|
|
5481
5485
|
let n = e.location?.href;
|
|
5482
|
-
return typeof n == "string" && n !== "" && n !== "about:blank" ? n :
|
|
5483
|
-
},
|
|
5484
|
-
let n = t ===
|
|
5486
|
+
return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Ri;
|
|
5487
|
+
}, Bi = (e, t = zi()) => {
|
|
5488
|
+
let n = t === Ri, r;
|
|
5485
5489
|
try {
|
|
5486
5490
|
r = new URL(t).origin;
|
|
5487
5491
|
} catch {
|
|
@@ -5507,28 +5511,28 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5507
5511
|
relativeToBase: !1,
|
|
5508
5512
|
sentinelBase: n
|
|
5509
5513
|
};
|
|
5510
|
-
},
|
|
5514
|
+
}, Vi = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Hi = (e) => {
|
|
5511
5515
|
let t = [];
|
|
5512
5516
|
if (e == null) return Object.freeze(t);
|
|
5513
5517
|
let n = e;
|
|
5514
5518
|
if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
|
|
5515
|
-
let r =
|
|
5519
|
+
let r = Vi(n, e);
|
|
5516
5520
|
r && t.push(r);
|
|
5517
5521
|
}), Object.freeze(t);
|
|
5518
5522
|
if (Array.isArray(e)) {
|
|
5519
5523
|
for (let n of e) if (Array.isArray(n) && n.length >= 2) {
|
|
5520
|
-
let e =
|
|
5524
|
+
let e = Vi(String(n[0]), n[1]);
|
|
5521
5525
|
e && t.push(e);
|
|
5522
5526
|
}
|
|
5523
5527
|
return Object.freeze(t);
|
|
5524
5528
|
}
|
|
5525
5529
|
if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
|
|
5526
|
-
let e =
|
|
5530
|
+
let e = Vi(n, Array.isArray(r) ? r.join(", ") : r);
|
|
5527
5531
|
e && t.push(e);
|
|
5528
5532
|
}
|
|
5529
5533
|
return Object.freeze(t);
|
|
5530
|
-
},
|
|
5531
|
-
let t = e.base === void 0 ?
|
|
5534
|
+
}, Ui = (e) => {
|
|
5535
|
+
let t = e.base === void 0 ? Bi(e.url) : Bi(e.url, e.base), n = {
|
|
5532
5536
|
raw: e.url,
|
|
5533
5537
|
href: t.href,
|
|
5534
5538
|
dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
|
|
@@ -5537,29 +5541,29 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5537
5541
|
resolved: t.resolved,
|
|
5538
5542
|
relativeToBase: t.relativeToBase,
|
|
5539
5543
|
method: (e.method ?? "GET").toUpperCase(),
|
|
5540
|
-
headers:
|
|
5544
|
+
headers: Hi(e.headers),
|
|
5541
5545
|
bodyKind: e.bodyKind,
|
|
5542
5546
|
..."body" in e ? { body: e.body } : {}
|
|
5543
5547
|
};
|
|
5544
5548
|
return Object.freeze(n);
|
|
5545
|
-
},
|
|
5549
|
+
}, Wi = (e, t) => {
|
|
5546
5550
|
if (!t || t.from === t.to) return e;
|
|
5547
5551
|
let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
|
|
5548
5552
|
return n ? Object.freeze(r) : e;
|
|
5549
|
-
},
|
|
5553
|
+
}, Gi = (e) => {
|
|
5550
5554
|
let t = {};
|
|
5551
5555
|
for (let [n, r] of e) t[n] = r;
|
|
5552
5556
|
return t;
|
|
5553
|
-
},
|
|
5557
|
+
}, Ki = /* @__PURE__ */ new Set([
|
|
5554
5558
|
"GET",
|
|
5555
5559
|
"HEAD",
|
|
5556
5560
|
"OPTIONS"
|
|
5557
|
-
]),
|
|
5561
|
+
]), qi = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, Ji = (e) => typeof e == "string" ? e : qi(e) ? e.url : String(e), Yi = (e, t) => (t?.method ?? (qi(e) ? e.method : void 0) ?? "GET").toUpperCase(), Xi = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", Zi = (e) => {
|
|
5558
5562
|
if (typeof e == "string") return e.length;
|
|
5559
5563
|
let t = e;
|
|
5560
5564
|
if (typeof t?.size == "number") return t.size;
|
|
5561
5565
|
if (typeof t?.byteLength == "number") return t.byteLength;
|
|
5562
|
-
},
|
|
5566
|
+
}, Qi = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? Ki.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), $i = (e, t, n, r, i) => ({
|
|
5563
5567
|
replayable: !1,
|
|
5564
5568
|
bodyKind: e,
|
|
5565
5569
|
reason: t,
|
|
@@ -5567,11 +5571,11 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5567
5571
|
forwardInit: i,
|
|
5568
5572
|
snapshot: r,
|
|
5569
5573
|
replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
|
|
5570
|
-
}),
|
|
5574
|
+
}), ea = (e, t) => Gi(Wi(e.headers, t?.authorizationSwap)), ta = (e) => {
|
|
5571
5575
|
if (!e || !("headers" in e)) return e;
|
|
5572
5576
|
let { headers: t, ...n } = e;
|
|
5573
5577
|
return n;
|
|
5574
|
-
},
|
|
5578
|
+
}, na = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : qi(e) ? e.headers : void 0, ra = (e) => {
|
|
5575
5579
|
if (e === null || typeof e == "string") return e;
|
|
5576
5580
|
if (typeof FormData < "u" && e instanceof FormData) {
|
|
5577
5581
|
let t = new FormData();
|
|
@@ -5579,18 +5583,18 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5579
5583
|
return t;
|
|
5580
5584
|
}
|
|
5581
5585
|
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;
|
|
5582
|
-
},
|
|
5583
|
-
let r =
|
|
5586
|
+
}, ia = (e, t, n) => new Request(e, { headers: ea(t, n) }), aa = (e, t, n) => {
|
|
5587
|
+
let r = Ji(e), i = Yi(e, t), a = na(e, t), o = (e, t) => Ui({
|
|
5584
5588
|
url: r,
|
|
5585
5589
|
method: i,
|
|
5586
5590
|
headers: a,
|
|
5587
5591
|
bodyKind: e,
|
|
5588
5592
|
...t === void 0 ? {} : { body: t }
|
|
5589
5593
|
});
|
|
5590
|
-
if (
|
|
5594
|
+
if (qi(e)) {
|
|
5591
5595
|
if (e.body === null || e.body === void 0) {
|
|
5592
5596
|
let a = o("none");
|
|
5593
|
-
return
|
|
5597
|
+
return Qi(n, {
|
|
5594
5598
|
url: r,
|
|
5595
5599
|
method: i,
|
|
5596
5600
|
bodyKind: "none"
|
|
@@ -5600,20 +5604,20 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5600
5604
|
forwardInput: e,
|
|
5601
5605
|
forwardInit: t,
|
|
5602
5606
|
snapshot: a,
|
|
5603
|
-
replay: (n, r) => n(
|
|
5604
|
-
} :
|
|
5607
|
+
replay: (n, r) => n(ia(e, a, r), ta(t))
|
|
5608
|
+
} : $i("none", "the replay policy refused this request", e, a, t);
|
|
5605
5609
|
}
|
|
5606
5610
|
let a = o("request-clone");
|
|
5607
|
-
if (!
|
|
5611
|
+
if (!Qi(n, {
|
|
5608
5612
|
url: r,
|
|
5609
5613
|
method: i,
|
|
5610
5614
|
bodyKind: "request-clone"
|
|
5611
|
-
})) return
|
|
5615
|
+
})) return $i("request-clone", "the replay policy refused this request", e, a, t);
|
|
5612
5616
|
let s;
|
|
5613
5617
|
try {
|
|
5614
5618
|
s = e.clone();
|
|
5615
5619
|
} catch {
|
|
5616
|
-
return
|
|
5620
|
+
return $i("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
|
|
5617
5621
|
}
|
|
5618
5622
|
return {
|
|
5619
5623
|
replayable: !0,
|
|
@@ -5621,17 +5625,17 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5621
5625
|
forwardInput: e,
|
|
5622
5626
|
forwardInit: t,
|
|
5623
5627
|
snapshot: a,
|
|
5624
|
-
replay: (e, n) => e(
|
|
5628
|
+
replay: (e, n) => e(ia(s, a, n), ta(t))
|
|
5625
5629
|
};
|
|
5626
5630
|
}
|
|
5627
|
-
let s =
|
|
5628
|
-
if (s === "one-shot") return
|
|
5629
|
-
if (!
|
|
5631
|
+
let s = Xi(t?.body);
|
|
5632
|
+
if (s === "one-shot") return $i("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
|
|
5633
|
+
if (!Qi(n, {
|
|
5630
5634
|
url: r,
|
|
5631
5635
|
method: i,
|
|
5632
5636
|
bodyKind: s
|
|
5633
|
-
},
|
|
5634
|
-
let c = t && "body" in t ?
|
|
5637
|
+
}, Zi(t?.body))) return $i(s, "the replay policy refused this request", e, o(s), t);
|
|
5638
|
+
let c = t && "body" in t ? ra(t.body ?? null) : void 0, l = o(s, c);
|
|
5635
5639
|
return {
|
|
5636
5640
|
replayable: !0,
|
|
5637
5641
|
bodyKind: s,
|
|
@@ -5639,21 +5643,21 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5639
5643
|
forwardInit: t,
|
|
5640
5644
|
snapshot: l,
|
|
5641
5645
|
replay: (e, n) => e(l.dispatchUrl, {
|
|
5642
|
-
...
|
|
5646
|
+
...ta(t),
|
|
5643
5647
|
...c === void 0 ? {} : { body: c },
|
|
5644
|
-
headers:
|
|
5648
|
+
headers: ea(l, n),
|
|
5645
5649
|
method: l.method
|
|
5646
5650
|
})
|
|
5647
5651
|
};
|
|
5648
|
-
},
|
|
5649
|
-
if (!
|
|
5652
|
+
}, oa = (e) => typeof e == "object" && !!e, sa = (e) => (t) => {
|
|
5653
|
+
if (!oa(e)) return;
|
|
5650
5654
|
let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
|
|
5651
5655
|
return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
|
|
5652
|
-
},
|
|
5656
|
+
}, ca = (e) => {
|
|
5653
5657
|
let t = e?.url ?? "", n = e?.baseURL;
|
|
5654
5658
|
return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
5655
|
-
},
|
|
5656
|
-
let r =
|
|
5659
|
+
}, la = (e) => (e?.method ?? "GET").toUpperCase(), ua = (e) => e == null ? "none" : oa(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", da = (e, t, n) => {
|
|
5660
|
+
let r = Gi(Wi(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
|
|
5657
5661
|
return {
|
|
5658
5662
|
...e,
|
|
5659
5663
|
...i ? { baseURL: void 0 } : {},
|
|
@@ -5662,10 +5666,10 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5662
5666
|
headers: r,
|
|
5663
5667
|
..."body" in t ? { data: t.body } : {}
|
|
5664
5668
|
};
|
|
5665
|
-
},
|
|
5666
|
-
let o = t ?? e?.config, s =
|
|
5667
|
-
url:
|
|
5668
|
-
method:
|
|
5669
|
+
}, fa = (e, t, n, r, i, a) => {
|
|
5670
|
+
let o = t ?? e?.config, s = ua(o?.data), c = a ?? Ui({
|
|
5671
|
+
url: ca(o),
|
|
5672
|
+
method: la(o),
|
|
5669
5673
|
headers: o?.headers,
|
|
5670
5674
|
bodyKind: s,
|
|
5671
5675
|
body: o?.data
|
|
@@ -5673,22 +5677,22 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5673
5677
|
url: c.href,
|
|
5674
5678
|
method: c.method,
|
|
5675
5679
|
bodyKind: s
|
|
5676
|
-
}, u = s !== "one-shot" &&
|
|
5680
|
+
}, u = s !== "one-shot" && Qi(i.replay, l);
|
|
5677
5681
|
return {
|
|
5678
5682
|
status: e?.status ?? 0,
|
|
5679
|
-
getHeader:
|
|
5683
|
+
getHeader: sa(e?.headers),
|
|
5680
5684
|
readBody: async () => e?.data,
|
|
5681
5685
|
request: c,
|
|
5682
5686
|
replay: async (e) => {
|
|
5683
|
-
let t = Te(
|
|
5687
|
+
let t = Te(da(o ?? {}, c, e));
|
|
5684
5688
|
try {
|
|
5685
5689
|
let e = await r(t);
|
|
5686
|
-
return
|
|
5690
|
+
return fa(e, e?.config ?? t, e, r, i, c);
|
|
5687
5691
|
} catch (e) {
|
|
5688
|
-
let n =
|
|
5689
|
-
if (!n.response || typeof n.response.status != "number" ||
|
|
5692
|
+
let n = oa(e) ? e : {};
|
|
5693
|
+
if (!n.response || typeof n.response.status != "number" || nr(e)) throw e;
|
|
5690
5694
|
return {
|
|
5691
|
-
...
|
|
5695
|
+
...fa(n.response, n.config ?? t, e, r, i, c),
|
|
5692
5696
|
rejected: !0
|
|
5693
5697
|
};
|
|
5694
5698
|
}
|
|
@@ -5702,19 +5706,19 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5702
5706
|
replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
|
|
5703
5707
|
signal: o?.signal
|
|
5704
5708
|
};
|
|
5705
|
-
},
|
|
5706
|
-
let r =
|
|
5709
|
+
}, pa = (e, t) => async (n) => {
|
|
5710
|
+
let r = ri(e), i = oa(n) ? n : {}, a = Si(await yi(fa(i.response, i.config, i.response, t, r), r), n);
|
|
5707
5711
|
if (a.settle === "reject") throw a.error;
|
|
5708
5712
|
return a.value;
|
|
5709
|
-
},
|
|
5710
|
-
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,
|
|
5713
|
+
}, ma = (e, t, n) => {
|
|
5714
|
+
let r = e.request, i = n ?? (typeof r == "function" ? (t) => r.call(e, t) : () => Promise.reject(/* @__PURE__ */ Error("Passflow: this client exposes no request() to replay through."))), a = e.interceptors.response.use(void 0, pa(t, i)), o = !1;
|
|
5711
5715
|
return () => {
|
|
5712
5716
|
o || (o = !0, e.interceptors.response.eject(a));
|
|
5713
5717
|
};
|
|
5714
|
-
},
|
|
5718
|
+
}, ha = (t, n) => {
|
|
5715
5719
|
let r = e.create(t);
|
|
5716
5720
|
return n(r), r;
|
|
5717
|
-
},
|
|
5721
|
+
}, ga = 0, _a = (e, t) => {
|
|
5718
5722
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
5719
5723
|
if (n) return {
|
|
5720
5724
|
get aborted() {
|
|
@@ -5728,34 +5732,34 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5728
5732
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
5729
5733
|
} : {}
|
|
5730
5734
|
};
|
|
5731
|
-
},
|
|
5735
|
+
}, va = (e) => (t) => e.headers?.get(t), ya = (e, t, n, r, i) => ({
|
|
5732
5736
|
status: e.status,
|
|
5733
|
-
getHeader:
|
|
5737
|
+
getHeader: va(e),
|
|
5734
5738
|
readBody: () => e.clone().json(),
|
|
5735
5739
|
request: t.snapshot,
|
|
5736
|
-
replay: async (e) =>
|
|
5740
|
+
replay: async (e) => ya(await t.replay(n, e), t, n, r, i),
|
|
5737
5741
|
markers: r,
|
|
5738
5742
|
raw: e,
|
|
5739
5743
|
replayable: t.replayable,
|
|
5740
5744
|
replayUnsupportedReason: t.reason,
|
|
5741
5745
|
signal: i,
|
|
5742
5746
|
responseType: e.type
|
|
5743
|
-
}),
|
|
5747
|
+
}), ba = (e, t) => {
|
|
5744
5748
|
let n = (t, n) => {
|
|
5745
|
-
|
|
5749
|
+
ga += 1;
|
|
5746
5750
|
try {
|
|
5747
5751
|
return e(t, n);
|
|
5748
5752
|
} finally {
|
|
5749
|
-
--
|
|
5753
|
+
--ga;
|
|
5750
5754
|
}
|
|
5751
5755
|
};
|
|
5752
5756
|
return async (e, r) => {
|
|
5753
|
-
if (
|
|
5754
|
-
let i =
|
|
5757
|
+
if (ga > 0) return n(e, r);
|
|
5758
|
+
let i = ri(t), a = aa(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = xi(await yi(ya(o, a, n, {}, _a(e, r)), i), o, i);
|
|
5755
5759
|
if (s.settle === "reject") throw s.error;
|
|
5756
5760
|
return s.value;
|
|
5757
5761
|
};
|
|
5758
|
-
},
|
|
5762
|
+
}, xa = new Set(Br.filter((e) => !e.requiresPrepare).map((e) => e.type)), Sa = (e) => {
|
|
5759
5763
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
5760
5764
|
kind: "protocol",
|
|
5761
5765
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -5767,17 +5771,17 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5767
5771
|
webauthn: e.webauthn,
|
|
5768
5772
|
codeSentTo: e.code_sent_to
|
|
5769
5773
|
};
|
|
5770
|
-
},
|
|
5774
|
+
}, Ca = (e) => nr(e) && !rr(e), wa = (e) => ({
|
|
5771
5775
|
async prepare(t) {
|
|
5772
|
-
if (!
|
|
5776
|
+
if (!xa.has(t)) try {
|
|
5773
5777
|
let n = e.relyingPartyId?.();
|
|
5774
|
-
return
|
|
5778
|
+
return Sa(await e.startUpgrade(n ? {
|
|
5775
5779
|
method: t,
|
|
5776
5780
|
relying_party_id: n
|
|
5777
5781
|
} : { method: t }));
|
|
5778
5782
|
} catch (e) {
|
|
5779
|
-
if (
|
|
5780
|
-
let t =
|
|
5783
|
+
if (Ca(e)) throw e;
|
|
5784
|
+
let t = sr(e, "start");
|
|
5781
5785
|
if (t.kind === "prepare_not_required") return;
|
|
5782
5786
|
throw t;
|
|
5783
5787
|
}
|
|
@@ -5794,17 +5798,17 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5794
5798
|
assertion: n
|
|
5795
5799
|
});
|
|
5796
5800
|
} catch (t) {
|
|
5797
|
-
if (
|
|
5798
|
-
let n =
|
|
5799
|
-
throw n.status === 401 &&
|
|
5801
|
+
if (Ca(t)) throw t;
|
|
5802
|
+
let n = sr(t, "refresh");
|
|
5803
|
+
throw n.status === 401 && lr(n) && e.markSessionInvalid?.(), n;
|
|
5800
5804
|
}
|
|
5801
5805
|
}
|
|
5802
|
-
}),
|
|
5806
|
+
}), Ta = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Ea = (e) => {
|
|
5803
5807
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
5804
5808
|
let i = () => {
|
|
5805
5809
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
5806
5810
|
};
|
|
5807
|
-
return
|
|
5811
|
+
return wa({
|
|
5808
5812
|
...e,
|
|
5809
5813
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
5810
5814
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -5815,7 +5819,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5815
5819
|
});
|
|
5816
5820
|
}, i = (t, n) => {
|
|
5817
5821
|
let i = {}, a = {
|
|
5818
|
-
controller: new
|
|
5822
|
+
controller: new ni({
|
|
5819
5823
|
transport: r(() => i.current),
|
|
5820
5824
|
prompt: t.prompt,
|
|
5821
5825
|
platform: e.platform,
|
|
@@ -5827,17 +5831,17 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5827
5831
|
options: t,
|
|
5828
5832
|
scope: {
|
|
5829
5833
|
passflow: e.passflowDomain,
|
|
5830
|
-
backend:
|
|
5834
|
+
backend: Ta(t.backend)
|
|
5831
5835
|
},
|
|
5832
5836
|
generation: n
|
|
5833
5837
|
};
|
|
5834
5838
|
return i.current = a, a;
|
|
5835
5839
|
}, a = async (r, i) => {
|
|
5836
5840
|
let a = t;
|
|
5837
|
-
if (!a) throw new
|
|
5841
|
+
if (!a) throw new dr("Step-up verification is not enabled on this Passflow instance");
|
|
5838
5842
|
a.controller.active || (a.pin = e.readSessionPin?.());
|
|
5839
5843
|
let o = await a.controller.elevate(r, i);
|
|
5840
|
-
if (!n(a)) throw new
|
|
5844
|
+
if (!n(a)) throw new fr();
|
|
5841
5845
|
return o;
|
|
5842
5846
|
}, o = () => {
|
|
5843
5847
|
let n = t, r = n?.scope ?? {
|
|
@@ -5881,9 +5885,9 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5881
5885
|
let r = [];
|
|
5882
5886
|
if (e.attachInternalSeam) {
|
|
5883
5887
|
let t = e.attachInternalSeam;
|
|
5884
|
-
t((e) =>
|
|
5888
|
+
t((e) => pa(o, e)), r.push(() => t(void 0));
|
|
5885
5889
|
}
|
|
5886
|
-
n.interceptFetch && r.push(
|
|
5890
|
+
n.interceptFetch && r.push(_t((e, t, n) => ba(e, o)(t, n), {
|
|
5887
5891
|
priority: 20,
|
|
5888
5892
|
name: "passflow-upgrade"
|
|
5889
5893
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -5914,18 +5918,18 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5914
5918
|
withAuth: {
|
|
5915
5919
|
enumerable: !0,
|
|
5916
5920
|
value: (e) => {
|
|
5917
|
-
if (e) return
|
|
5921
|
+
if (e) return ba(e, o);
|
|
5918
5922
|
let t = typeof globalThis > "u" ? void 0 : globalThis;
|
|
5919
5923
|
if (!t || typeof t.fetch != "function") throw Error("Passflow: withAuth() needs a fetch to wrap — this runtime has none.");
|
|
5920
|
-
return
|
|
5924
|
+
return ba(t.fetch.bind(t), o);
|
|
5921
5925
|
}
|
|
5922
5926
|
},
|
|
5923
5927
|
attachAuth: {
|
|
5924
5928
|
enumerable: !0,
|
|
5925
|
-
value: (e) =>
|
|
5929
|
+
value: (e) => ma(e, o)
|
|
5926
5930
|
}
|
|
5927
5931
|
});
|
|
5928
|
-
},
|
|
5932
|
+
}, Da, Oa = class {
|
|
5929
5933
|
get origin() {
|
|
5930
5934
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
5931
5935
|
}
|
|
@@ -5937,9 +5941,9 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5937
5941
|
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? P, this.storageManager = new N({
|
|
5938
5942
|
prefix: e.keyStoragePrefix ?? "",
|
|
5939
5943
|
storage: this.platform.storage
|
|
5940
|
-
}), this.deviceService = new re(this.storageManager), this.authApi = new
|
|
5941
|
-
let i =
|
|
5942
|
-
this.authService = new
|
|
5944
|
+
}), this.deviceService = new re(this.storageManager), this.authApi = new Je(e, this.storageManager, this.deviceService), this.appApi = new Ke(e, this.storageManager, this.deviceService), this.userApi = new rt(e, this.storageManager, this.deviceService), this.settingApi = new Ze(e, this.storageManager, this.deviceService), this.tenantApi = new Qe(e, this.storageManager, this.deviceService), this.invitationApi = new Xe(e, this.storageManager, this.deviceService), this.twoFactorApi = new tt(e, this.storageManager, this.deviceService), this.upgradeApi = new nt(e, this.storageManager, this.deviceService), this.upgradeDomain = ke(e.url), this.subscribeStore = new Yn(), this.tokenCacheService = new Mr(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? u, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
|
|
5945
|
+
let i = cn(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
|
|
5946
|
+
this.authService = new Or(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
|
|
5943
5947
|
createSession: this.createSessionCallback,
|
|
5944
5948
|
expiredSession: this.expiredSessionCallback
|
|
5945
5949
|
}, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
|
|
@@ -5947,7 +5951,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5947
5951
|
...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
|
|
5948
5952
|
}), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
5949
5953
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
5950
|
-
this.userService = new
|
|
5954
|
+
this.userService = new Pr(this.userApi, this.deviceService, this.platform), this.tenantService = new jr(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new kr(this.invitationApi), this.twoFactorService = new Nr(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Ea({
|
|
5951
5955
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
5952
5956
|
commitRefresh: async (e, t) => {
|
|
5953
5957
|
await this.authService.refreshToken(e, t);
|
|
@@ -5994,7 +5998,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5994
5998
|
return this.upgrade.attachAuth(e);
|
|
5995
5999
|
}
|
|
5996
6000
|
createClient(e) {
|
|
5997
|
-
return
|
|
6001
|
+
return ha(e, (e) => this.upgrade.attachAuth(e));
|
|
5998
6002
|
}
|
|
5999
6003
|
readAssuranceBar() {
|
|
6000
6004
|
let e = this.storageManager.getToken(j.access_token);
|
|
@@ -6046,7 +6050,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6046
6050
|
message: t instanceof Error || t instanceof B ? t.message : "Session check failed",
|
|
6047
6051
|
originalError: t
|
|
6048
6052
|
};
|
|
6049
|
-
|
|
6053
|
+
W(this.subscribeStore, n), e = void 0;
|
|
6050
6054
|
}
|
|
6051
6055
|
e && this.createSessionCallback && await this.createSessionCallback({
|
|
6052
6056
|
tokens: e,
|
|
@@ -6074,24 +6078,24 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6074
6078
|
}
|
|
6075
6079
|
let r = t.get("access_token"), i = t.get("refresh_token"), a = t.get("id_token"), o = t.get("scopes")?.split(",") ?? this.scopes, s;
|
|
6076
6080
|
if (r) {
|
|
6077
|
-
if (!
|
|
6078
|
-
|
|
6081
|
+
if (!hr(r)) {
|
|
6082
|
+
W(this.subscribeStore, {
|
|
6079
6083
|
operation: "tokens.from-url",
|
|
6080
6084
|
message: "Invalid access token format received",
|
|
6081
6085
|
code: "INVALID_TOKEN_FORMAT"
|
|
6082
6086
|
}), this.cleanupUrlParams(n, e);
|
|
6083
6087
|
return;
|
|
6084
6088
|
}
|
|
6085
|
-
if (i && !
|
|
6086
|
-
|
|
6089
|
+
if (i && !hr(i)) {
|
|
6090
|
+
W(this.subscribeStore, {
|
|
6087
6091
|
operation: "tokens.from-url",
|
|
6088
6092
|
message: "Invalid refresh token format received",
|
|
6089
6093
|
code: "INVALID_TOKEN_FORMAT"
|
|
6090
6094
|
}), this.cleanupUrlParams(n, e);
|
|
6091
6095
|
return;
|
|
6092
6096
|
}
|
|
6093
|
-
if (a && !
|
|
6094
|
-
|
|
6097
|
+
if (a && !hr(a)) {
|
|
6098
|
+
W(this.subscribeStore, {
|
|
6095
6099
|
operation: "tokens.from-url",
|
|
6096
6100
|
message: "Invalid ID token format received",
|
|
6097
6101
|
code: "INVALID_TOKEN_FORMAT"
|
|
@@ -6116,11 +6120,11 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6116
6120
|
if (!n) return !1;
|
|
6117
6121
|
t.delete("tfa_token");
|
|
6118
6122
|
let r = t.toString();
|
|
6119
|
-
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")),
|
|
6123
|
+
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), hr(n) ? (this.subscribeStore.notify(Z.TwoFactorRequired, {
|
|
6120
6124
|
email: "",
|
|
6121
6125
|
challengeId: "",
|
|
6122
6126
|
tfaToken: n
|
|
6123
|
-
}), !0) : (
|
|
6127
|
+
}), !0) : (W(this.subscribeStore, {
|
|
6124
6128
|
operation: "tokens.from-url",
|
|
6125
6129
|
message: "Invalid 2FA token format received",
|
|
6126
6130
|
code: "INVALID_TOKEN_FORMAT"
|
|
@@ -6129,7 +6133,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6129
6133
|
checkErrorsFromURL() {
|
|
6130
6134
|
let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
|
|
6131
6135
|
if (e) {
|
|
6132
|
-
let t =
|
|
6136
|
+
let t = gr(e);
|
|
6133
6137
|
return Error(t);
|
|
6134
6138
|
}
|
|
6135
6139
|
}
|
|
@@ -6200,7 +6204,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6200
6204
|
originalError: e,
|
|
6201
6205
|
code: e instanceof B ? e.id : void 0
|
|
6202
6206
|
};
|
|
6203
|
-
throw
|
|
6207
|
+
throw W(this.subscribeStore, r), e;
|
|
6204
6208
|
}
|
|
6205
6209
|
async logOut() {
|
|
6206
6210
|
try {
|
|
@@ -6224,7 +6228,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6224
6228
|
message: e,
|
|
6225
6229
|
code: "RESET_ERROR"
|
|
6226
6230
|
};
|
|
6227
|
-
throw
|
|
6231
|
+
throw W(this.subscribeStore, t), this.error;
|
|
6228
6232
|
}
|
|
6229
6233
|
}
|
|
6230
6234
|
notifySignedOut(e) {
|
|
@@ -6473,7 +6477,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6473
6477
|
this.twoFactorService.clearMagicLinkSession();
|
|
6474
6478
|
}
|
|
6475
6479
|
};
|
|
6476
|
-
|
|
6477
|
-
export { i as APP_ID_HEADER_KEY, a as AUTHORIZATION_HEADER_KEY,
|
|
6480
|
+
Da = Oa, Da.version = c;
|
|
6481
|
+
export { i as APP_ID_HEADER_KEY, Me as APP_SECRET_NAMES, a as AUTHORIZATION_HEADER_KEY, Ke as AppAPI, Je as AuthAPI, Or as AuthService, Ye as CLIAuthAPI, f as DEFAULT_GROUP_NAME, u as DEFAULT_SCOPES, Br as DEFAULT_UPGRADE_FACTORS, o as DEVICE_ID_HEADER_KEY, s as DEVICE_TYPE_HEADER_KEY, b as ERROR_MESSAGE_MAX_LENGTH, it as FETCH_PRIORITY_OIDC, at as FETCH_PRIORITY_UPGRADE, ot as FetchMiddlewareContractError, ce as INSUFFICIENT_USER_AUTHENTICATION, Xe as InvitationAPI, kr as InvitationService, Et as M2MClient, xt as M2MConfigError, U as M2MError, St as M2MErrorCodes, yt as M2MNetworkError, bt as M2MTokenParseError, Ct as M2M_DEFAULTS, Ne as MASKED_SECRET_PREFIX, l as MINIMAL_DEFAULT_SCOPES, Ie as OS, d as PASSFLOW_CLOUD_URL, m as POPUP_HEIGHT, h as POPUP_POLL_INTERVAL_MS, g as POPUP_TIMEOUT_MS, p as POPUP_WIDTH, Oa as Passflow, Oe as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, B as PassflowError, Z as PassflowEvent, J as PassflowRefreshError, ie as PopupClosedError, je as Providers, Xn as RECOVERABLE_COMMIT_ERROR_IDS, _n as REFRESH_AUTH_FAILURE_IDS, q as RefreshErrorId, De as RequestMethod, c as SDK_VERSION, Zn as SESSION_INVALIDATING_COMMIT_ERROR_IDS, Pe as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, te as SessionState, Ze as SettingAPI, _ as TOKEN_EXPIRY_BUFFER_SECONDS, Qe as TenantAPI, jr as TenantService, Ar as TenantUserMembership, Mr as TokenCacheService, M as TokenDeliveryMode, j as TokenType, tt as TwoFactorApiClient, Re as TwoFactorPolicy, Nr as TwoFactorService, le as UPGRADE_REQUIRED, y as USERNAME_MAX_LENGTH, v as USERNAME_MIN_LENGTH, nt as UpgradeAPI, qr as UpgradeCancelledError, kn as UpgradeCommitInterruptedError, ni as UpgradeController, Q as UpgradeErrorIds, Fr as UpgradeFactorError, ur as UpgradeInsufficientError, fr as UpgradeSessionChangedError, $ as UpgradeTransportError, dr as UpgradeUnavailableError, Jr as UpgradeUnsatisfiableError, rt as UserAPI, Pr as UserService, ae as WebAdapter, sr as classifyUpgradeError, Vr as factorRegistry, vt as fetchRegistryState, Le as getOSFromDeviceType, lr as invalidatesSessionOnCommit, Ae as isEmailVerificationStep, Fe as isMaskedSecret, cr as isRecoverableCommitFailure, $n as isRetryableUpgradeKind, k as isTokenExpired, ji as isUpgradeCancelled, Mi as isUpgradeExhausted, Ni as isUpgradeInsufficient, Ii as isUpgradeSessionChanged, rr as isUpgradeTransportError, Li as isUpgradeTransportFailure, Fi as isUpgradeUnavailable, Pi as isUpgradeUnsatisfiable, _r as isValidEmail, hr as isValidJWTFormat, vr as isValidPhoneNumber, yr as isValidUsername, he as parseChallengeBody, me as parseChallengeHeader, A as parseToken, ye as parseUpgradeChallenge, zr as passkeyFactor, V as pathWithParams, Rr as recoveryCodesFactor, _t as registerFetchMiddleware, L as requiredAcrLevel, ke as resolveUpgradeDomain, gr as sanitizeErrorMessage, Kr as selectFactors, Lr as totpFactor, P as webAdapter };
|
|
6478
6482
|
|
|
6479
6483
|
//# sourceMappingURL=index.mjs.map
|