@passflow/core 0.21.1 → 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 +88 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +157 -5
- package/dist/index.d.ts +157 -5
- package/dist/index.mjs +738 -658
- 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"
|
|
@@ -581,30 +581,34 @@ var j = /* @__PURE__ */ function(e) {
|
|
|
581
581
|
} catch {
|
|
582
582
|
return null;
|
|
583
583
|
}
|
|
584
|
-
}, B = class extends Error {
|
|
584
|
+
}, Ae = (e) => typeof e == "object" && !!e && e.email_verification_required === !0, B = class extends Error {
|
|
585
585
|
constructor(e) {
|
|
586
586
|
super(), this.id = e?.id ?? "unknown", this.message = e?.message ?? e ?? "Something went wrong", this.status = e?.status ?? 500, this.location = e?.location ?? "unknown", this.time = e?.time ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
587
587
|
}
|
|
588
|
-
},
|
|
588
|
+
}, je = /* @__PURE__ */ function(e) {
|
|
589
589
|
return e.google = "google", e.facebook = "facebook", e;
|
|
590
|
-
}({}),
|
|
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 Pe = /* @__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 Pe = /* @__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 Pe = /* @__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 Pe = /* @__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 Pe = /* @__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 Pe = /* @__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 Pe = /* @__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 Pe = /* @__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 Pe = /* @__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,7 +828,13 @@ var Pe = /* @__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);
|
|
832
|
+
}
|
|
833
|
+
validateEmailCode(e) {
|
|
834
|
+
return this.axiosClient.post(z.passkeyValidate, {
|
|
835
|
+
challenge_id: e.challenge_id,
|
|
836
|
+
otp: e.otp
|
|
837
|
+
}, qe);
|
|
828
838
|
}
|
|
829
839
|
logOut(e, t, n = !1) {
|
|
830
840
|
let r = n ? void 0 : {
|
|
@@ -865,7 +875,7 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
865
875
|
device: t,
|
|
866
876
|
passkey_data: e
|
|
867
877
|
}, a = r ? Oe.passkeyRegisterComplete : z.passkeyRegisterComplete;
|
|
868
|
-
return this.axiosClient.post(a, i,
|
|
878
|
+
return this.axiosClient.post(a, i, qe);
|
|
869
879
|
}
|
|
870
880
|
passkeyAuthenticateStart(e, t, n, r = !1) {
|
|
871
881
|
let i = {
|
|
@@ -882,7 +892,7 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
882
892
|
device: t,
|
|
883
893
|
passkey_data: e
|
|
884
894
|
}, a = r ? Oe.passkeyAuthenticateComplete : z.passkeyAuthenticateComplete;
|
|
885
|
-
return this.axiosClient.post(a, i,
|
|
895
|
+
return this.axiosClient.post(a, i, qe);
|
|
886
896
|
}
|
|
887
897
|
passkeyValidate(e, t, n, r = !1, a) {
|
|
888
898
|
let o = {
|
|
@@ -894,23 +904,23 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
894
904
|
let c = a ? { [i]: a } : {};
|
|
895
905
|
return this.axiosClient.post(s, o, { headers: c });
|
|
896
906
|
}
|
|
897
|
-
},
|
|
907
|
+
}, Ye = class {
|
|
898
908
|
constructor(e, t, n) {
|
|
899
|
-
this.axiosClient = new
|
|
909
|
+
this.axiosClient = new H(e, t, n);
|
|
900
910
|
}
|
|
901
911
|
setAppId(e) {
|
|
902
912
|
this.axiosClient.setAppId(e);
|
|
903
913
|
}
|
|
904
914
|
getCLIAuthStatus(e) {
|
|
905
|
-
let t =
|
|
915
|
+
let t = V(z.cliAuthStatus, { sessionId: e });
|
|
906
916
|
return this.axiosClient.get(t);
|
|
907
917
|
}
|
|
908
918
|
completeCLIAuth(e) {
|
|
909
919
|
return this.axiosClient.post(z.cliAuthComplete, e);
|
|
910
920
|
}
|
|
911
|
-
},
|
|
921
|
+
}, Xe = class {
|
|
912
922
|
constructor(e, t, n) {
|
|
913
|
-
this.axiosClient = new
|
|
923
|
+
this.axiosClient = new H(e, t, n);
|
|
914
924
|
}
|
|
915
925
|
setAppId(e) {
|
|
916
926
|
this.axiosClient.setAppId(e);
|
|
@@ -921,27 +931,27 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
921
931
|
getInvitations(e) {
|
|
922
932
|
let t = {};
|
|
923
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());
|
|
924
|
-
let n =
|
|
934
|
+
let n = V(z.invitationsPath, { tenantID: e.tenantID });
|
|
925
935
|
return this.axiosClient.get(n, { params: t }).then((e) => ({
|
|
926
936
|
invites: e.invites,
|
|
927
937
|
nextPageSkip: e.next_page_skip
|
|
928
938
|
}));
|
|
929
939
|
}
|
|
930
940
|
deleteInvitation(e) {
|
|
931
|
-
let t =
|
|
941
|
+
let t = V(z.invitationDelete, { invitationID: e });
|
|
932
942
|
return this.axiosClient.delete(t);
|
|
933
943
|
}
|
|
934
944
|
resendInvitation(e) {
|
|
935
|
-
let t =
|
|
945
|
+
let t = V(z.invitationResend, { invitationID: e });
|
|
936
946
|
return this.axiosClient.post(t, {});
|
|
937
947
|
}
|
|
938
948
|
getInvitationLink(e) {
|
|
939
|
-
let t =
|
|
949
|
+
let t = V(z.invitationGetLink, { invitationID: e });
|
|
940
950
|
return this.axiosClient.get(t);
|
|
941
951
|
}
|
|
942
|
-
},
|
|
952
|
+
}, Ze = class {
|
|
943
953
|
constructor(e, t, n) {
|
|
944
|
-
this.axiosClient = new
|
|
954
|
+
this.axiosClient = new H(e, t, n);
|
|
945
955
|
}
|
|
946
956
|
setAppId(e) {
|
|
947
957
|
this.axiosClient.setAppId(e);
|
|
@@ -955,9 +965,9 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
955
965
|
getPasskeySettings() {
|
|
956
966
|
return this.axiosClient.get(z.settingsPasskey);
|
|
957
967
|
}
|
|
958
|
-
},
|
|
968
|
+
}, Qe = class {
|
|
959
969
|
constructor(e, t, n) {
|
|
960
|
-
this.axiosClient = new
|
|
970
|
+
this.axiosClient = new H(e, t, n);
|
|
961
971
|
}
|
|
962
972
|
setAppId(e) {
|
|
963
973
|
this.axiosClient.setAppId(e);
|
|
@@ -1071,12 +1081,12 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1071
1081
|
let r = `${z.tenantPath}/${e}/group/${t}/invite/email/${n}`;
|
|
1072
1082
|
return this.axiosClient.delete(r);
|
|
1073
1083
|
}
|
|
1074
|
-
},
|
|
1084
|
+
}, $e = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, et = (e) => ({
|
|
1075
1085
|
withCredentials: !0,
|
|
1076
|
-
|
|
1077
|
-
}),
|
|
1086
|
+
...$e(e)
|
|
1087
|
+
}), tt = class {
|
|
1078
1088
|
constructor(e, t, n) {
|
|
1079
|
-
this.axiosClient = new
|
|
1089
|
+
this.axiosClient = new H(e, t, n);
|
|
1080
1090
|
}
|
|
1081
1091
|
setAppId(e) {
|
|
1082
1092
|
this.axiosClient.setAppId(e);
|
|
@@ -1095,14 +1105,14 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1095
1105
|
return this.axiosClient.post(z.twoFactorVerify, {
|
|
1096
1106
|
code: n,
|
|
1097
1107
|
...r ? { trust_device: !0 } : {}
|
|
1098
|
-
},
|
|
1108
|
+
}, et(t));
|
|
1099
1109
|
}
|
|
1100
1110
|
useRecoveryCode(e) {
|
|
1101
1111
|
let { tfa_token: t, recovery_code: n, trust_device: r } = e;
|
|
1102
1112
|
return this.axiosClient.post(z.twoFactorRecovery, {
|
|
1103
1113
|
recovery_code: n,
|
|
1104
1114
|
...r ? { trust_device: !0 } : {}
|
|
1105
|
-
},
|
|
1115
|
+
}, et(t));
|
|
1106
1116
|
}
|
|
1107
1117
|
disable(e) {
|
|
1108
1118
|
return this.axiosClient.delete(z.twoFactor, { data: e });
|
|
@@ -1179,32 +1189,32 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1179
1189
|
});
|
|
1180
1190
|
}
|
|
1181
1191
|
removeMethod(e) {
|
|
1182
|
-
let t =
|
|
1192
|
+
let t = V(z.TwoFactorMethodRemove, { id: e });
|
|
1183
1193
|
return this.axiosClient.delete(t);
|
|
1184
1194
|
}
|
|
1185
1195
|
requestChallenge(e, t) {
|
|
1186
|
-
return this.axiosClient.post(z.TwoFactorChallenge, e,
|
|
1196
|
+
return this.axiosClient.post(z.TwoFactorChallenge, e, $e(t));
|
|
1187
1197
|
}
|
|
1188
1198
|
verifyV2(e, t) {
|
|
1189
1199
|
let { trust_device: n, ...r } = e;
|
|
1190
1200
|
return this.axiosClient.post(z.TwoFactorVerifyV2, {
|
|
1191
1201
|
...r,
|
|
1192
1202
|
...n ? { trust_device: !0 } : {}
|
|
1193
|
-
},
|
|
1203
|
+
}, et(t));
|
|
1194
1204
|
}
|
|
1195
1205
|
switchToAlternative(e, t) {
|
|
1196
|
-
return this.axiosClient.post(z.TwoFactorAlternative, e,
|
|
1206
|
+
return this.axiosClient.post(z.TwoFactorAlternative, e, $e(t));
|
|
1197
1207
|
}
|
|
1198
1208
|
async getTrustedDevices() {
|
|
1199
1209
|
return (await this.axiosClient.get(z.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
|
|
1200
1210
|
}
|
|
1201
1211
|
revokeTrustedDevice(e) {
|
|
1202
|
-
let t =
|
|
1212
|
+
let t = V(z.TwoFactorTrustedDeviceRevoke, { id: e });
|
|
1203
1213
|
return this.axiosClient.delete(t);
|
|
1204
1214
|
}
|
|
1205
|
-
},
|
|
1215
|
+
}, nt = class {
|
|
1206
1216
|
constructor(e, t, n) {
|
|
1207
|
-
this.axiosClient = new
|
|
1217
|
+
this.axiosClient = new H(e, t, n);
|
|
1208
1218
|
}
|
|
1209
1219
|
setAppId(e) {
|
|
1210
1220
|
this.axiosClient.setAppId(e);
|
|
@@ -1212,9 +1222,9 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1212
1222
|
startUpgrade(e) {
|
|
1213
1223
|
return this.axiosClient.post(z.upgradeStart, e, Ce({}));
|
|
1214
1224
|
}
|
|
1215
|
-
},
|
|
1225
|
+
}, rt = class {
|
|
1216
1226
|
constructor(e, t, n) {
|
|
1217
|
-
this.axiosClient = new
|
|
1227
|
+
this.axiosClient = new H(e, t, n);
|
|
1218
1228
|
}
|
|
1219
1229
|
setAppId(e) {
|
|
1220
1230
|
this.axiosClient.setAppId(e);
|
|
@@ -1245,50 +1255,50 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1245
1255
|
passkey_data: e
|
|
1246
1256
|
});
|
|
1247
1257
|
}
|
|
1248
|
-
},
|
|
1258
|
+
}, it = 10, at = 20, ot = class extends Error {
|
|
1249
1259
|
constructor(e) {
|
|
1250
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;
|
|
1251
1261
|
}
|
|
1252
|
-
},
|
|
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) => {
|
|
1253
1263
|
if (t >= e.length) {
|
|
1254
|
-
let e =
|
|
1264
|
+
let e = ut;
|
|
1255
1265
|
if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
|
|
1256
1266
|
return e(n, r);
|
|
1257
1267
|
}
|
|
1258
1268
|
let i = e[t];
|
|
1259
|
-
if (!i) return
|
|
1260
|
-
let a = !1, o = await i.middleware((n, r) => (a = !0,
|
|
1261
|
-
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);
|
|
1262
1272
|
return o;
|
|
1263
|
-
},
|
|
1264
|
-
let e =
|
|
1273
|
+
}, ht = () => {
|
|
1274
|
+
let e = pt();
|
|
1265
1275
|
if (!e || typeof e.fetch != "function") return !1;
|
|
1266
|
-
let t = e.fetch.bind(e), n = (e, t) =>
|
|
1267
|
-
return
|
|
1268
|
-
},
|
|
1269
|
-
let e =
|
|
1270
|
-
e &&
|
|
1271
|
-
},
|
|
1272
|
-
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 () => {};
|
|
1273
1283
|
let n = {
|
|
1274
1284
|
middleware: e,
|
|
1275
1285
|
name: t.name,
|
|
1276
1286
|
priority: t.priority,
|
|
1277
|
-
seq:
|
|
1287
|
+
seq: ct++
|
|
1278
1288
|
};
|
|
1279
|
-
|
|
1289
|
+
st.push(n);
|
|
1280
1290
|
let r = !1;
|
|
1281
1291
|
return () => {
|
|
1282
|
-
r || (r = !0,
|
|
1292
|
+
r || (r = !0, st = st.filter((e) => e !== n), st.length === 0 && gt());
|
|
1283
1293
|
};
|
|
1284
|
-
},
|
|
1285
|
-
let e =
|
|
1294
|
+
}, vt = () => {
|
|
1295
|
+
let e = pt();
|
|
1286
1296
|
return {
|
|
1287
|
-
installed:
|
|
1288
|
-
names: [...
|
|
1289
|
-
foreignPatch:
|
|
1297
|
+
installed: lt,
|
|
1298
|
+
names: [...st].sort(ft).map((e) => e.name),
|
|
1299
|
+
foreignPatch: lt && !!e && !!dt && e.fetch !== dt
|
|
1290
1300
|
};
|
|
1291
|
-
},
|
|
1301
|
+
}, U = class e extends Error {
|
|
1292
1302
|
constructor(t) {
|
|
1293
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);
|
|
1294
1304
|
}
|
|
@@ -1357,7 +1367,7 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1357
1367
|
let e = `M2MError [${this.code}]: ${this.message}`;
|
|
1358
1368
|
return this.status && (e += ` (HTTP ${this.status})`), e;
|
|
1359
1369
|
}
|
|
1360
|
-
},
|
|
1370
|
+
}, yt = class extends U {
|
|
1361
1371
|
constructor(e, t) {
|
|
1362
1372
|
super({
|
|
1363
1373
|
code: "temporarily_unavailable",
|
|
@@ -1366,7 +1376,7 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1366
1376
|
cause: t
|
|
1367
1377
|
}), this.name = "M2MNetworkError";
|
|
1368
1378
|
}
|
|
1369
|
-
},
|
|
1379
|
+
}, bt = class extends U {
|
|
1370
1380
|
constructor(e, t) {
|
|
1371
1381
|
super({
|
|
1372
1382
|
code: "invalid_request",
|
|
@@ -1375,7 +1385,7 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1375
1385
|
cause: t
|
|
1376
1386
|
}), this.name = "M2MTokenParseError";
|
|
1377
1387
|
}
|
|
1378
|
-
},
|
|
1388
|
+
}, xt = class extends U {
|
|
1379
1389
|
constructor(e) {
|
|
1380
1390
|
super({
|
|
1381
1391
|
code: "invalid_request",
|
|
@@ -1383,7 +1393,7 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1383
1393
|
status: 400
|
|
1384
1394
|
}), this.name = "M2MConfigError";
|
|
1385
1395
|
}
|
|
1386
|
-
},
|
|
1396
|
+
}, St = {
|
|
1387
1397
|
InvalidRequest: "invalid_request",
|
|
1388
1398
|
InvalidClient: "invalid_client",
|
|
1389
1399
|
InvalidGrant: "invalid_grant",
|
|
@@ -1393,14 +1403,14 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1393
1403
|
RateLimitExceeded: "rate_limit_exceeded",
|
|
1394
1404
|
ServerError: "server_error",
|
|
1395
1405
|
TemporarilyUnavailable: "temporarily_unavailable"
|
|
1396
|
-
},
|
|
1406
|
+
}, Ct = {
|
|
1397
1407
|
TOKEN_ENDPOINT: "/oauth2/token",
|
|
1398
1408
|
TIMEOUT: 1e4,
|
|
1399
1409
|
RETRIES: 3,
|
|
1400
1410
|
RETRY_DELAY: 1e3,
|
|
1401
1411
|
REFRESH_THRESHOLD: 30,
|
|
1402
1412
|
CONTENT_TYPE: "application/x-www-form-urlencoded"
|
|
1403
|
-
},
|
|
1413
|
+
}, wt = class {
|
|
1404
1414
|
constructor() {
|
|
1405
1415
|
this.cache = /* @__PURE__ */ new Map();
|
|
1406
1416
|
}
|
|
@@ -1417,18 +1427,18 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1417
1427
|
delete(e) {
|
|
1418
1428
|
return this.cache.delete(e), Promise.resolve();
|
|
1419
1429
|
}
|
|
1420
|
-
},
|
|
1430
|
+
}, Tt = {
|
|
1421
1431
|
shouldRetry(e, t) {
|
|
1422
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;
|
|
1423
1433
|
},
|
|
1424
1434
|
getDelay(e) {
|
|
1425
1435
|
return 2 ** (e - 1) * 1e3;
|
|
1426
1436
|
}
|
|
1427
|
-
},
|
|
1437
|
+
}, Et = class {
|
|
1428
1438
|
constructor(e) {
|
|
1429
|
-
if (!e.url) throw new
|
|
1430
|
-
if (!e.clientId) throw new
|
|
1431
|
-
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");
|
|
1432
1442
|
let t = e.url.replace(/\/$/, "");
|
|
1433
1443
|
this.config = {
|
|
1434
1444
|
url: t,
|
|
@@ -1437,16 +1447,16 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1437
1447
|
scopes: e.scopes,
|
|
1438
1448
|
audience: e.audience,
|
|
1439
1449
|
autoRefresh: e.autoRefresh ?? !1,
|
|
1440
|
-
refreshThreshold: e.refreshThreshold ??
|
|
1441
|
-
timeout: e.timeout ??
|
|
1442
|
-
retries: e.retries ??
|
|
1443
|
-
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,
|
|
1444
1454
|
retryStrategy: e.retryStrategy,
|
|
1445
1455
|
cache: e.cache,
|
|
1446
1456
|
onTokenRequest: e.onTokenRequest,
|
|
1447
1457
|
onTokenResponse: e.onTokenResponse,
|
|
1448
1458
|
onError: e.onError
|
|
1449
|
-
}, this.cache = e.cache ?? new
|
|
1459
|
+
}, this.cache = e.cache ?? new wt(), this.retryStrategy = e.retryStrategy ?? Tt, this.tokenEndpoint = `${t}${Ct.TOKEN_ENDPOINT}`;
|
|
1450
1460
|
}
|
|
1451
1461
|
getCacheKey(e, t) {
|
|
1452
1462
|
let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
|
|
@@ -1491,7 +1501,7 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1491
1501
|
let e = await fetch(this.tokenEndpoint, {
|
|
1492
1502
|
method: "POST",
|
|
1493
1503
|
headers: {
|
|
1494
|
-
"Content-Type":
|
|
1504
|
+
"Content-Type": Ct.CONTENT_TYPE,
|
|
1495
1505
|
Accept: "application/json"
|
|
1496
1506
|
},
|
|
1497
1507
|
body: t.toString(),
|
|
@@ -1504,7 +1514,7 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1504
1514
|
});
|
|
1505
1515
|
let a = await e.json();
|
|
1506
1516
|
if (!e.ok) {
|
|
1507
|
-
let t =
|
|
1517
|
+
let t = U.fromOAuthError({
|
|
1508
1518
|
error: a.error || "server_error",
|
|
1509
1519
|
error_description: a.error_description || a.message,
|
|
1510
1520
|
error_uri: a.error_uri
|
|
@@ -1516,7 +1526,7 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1516
1526
|
}
|
|
1517
1527
|
return a;
|
|
1518
1528
|
} catch (e) {
|
|
1519
|
-
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)));
|
|
1520
1530
|
}
|
|
1521
1531
|
}
|
|
1522
1532
|
async executeWithRetry(e) {
|
|
@@ -1524,7 +1534,7 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1524
1534
|
for (let n = 1; n <= this.config.retries; n++) try {
|
|
1525
1535
|
return await e();
|
|
1526
1536
|
} catch (e) {
|
|
1527
|
-
if (!(e instanceof
|
|
1537
|
+
if (!(e instanceof U)) throw e;
|
|
1528
1538
|
if (t = e, n < this.config.retries && this.retryStrategy.shouldRetry({
|
|
1529
1539
|
code: e.code,
|
|
1530
1540
|
status: e.status
|
|
@@ -1535,7 +1545,7 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1535
1545
|
}
|
|
1536
1546
|
throw e;
|
|
1537
1547
|
}
|
|
1538
|
-
throw t ?? new
|
|
1548
|
+
throw t ?? new U({
|
|
1539
1549
|
code: "server_error",
|
|
1540
1550
|
message: "Request failed after retries"
|
|
1541
1551
|
});
|
|
@@ -1559,13 +1569,13 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1559
1569
|
parseToken(e) {
|
|
1560
1570
|
try {
|
|
1561
1571
|
let t = e.split(".");
|
|
1562
|
-
if (t.length !== 3) throw new
|
|
1572
|
+
if (t.length !== 3) throw new bt("Invalid JWT format: expected 3 parts");
|
|
1563
1573
|
let n = t[1];
|
|
1564
|
-
if (!n) throw new
|
|
1574
|
+
if (!n) throw new bt("Invalid JWT format: missing payload");
|
|
1565
1575
|
let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
|
|
1566
1576
|
return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
|
|
1567
1577
|
} catch (e) {
|
|
1568
|
-
throw e instanceof
|
|
1578
|
+
throw e instanceof bt ? e : new bt(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
1569
1579
|
}
|
|
1570
1580
|
}
|
|
1571
1581
|
clearCache() {
|
|
@@ -1580,19 +1590,19 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1580
1590
|
try {
|
|
1581
1591
|
let e = await fetch(t, {
|
|
1582
1592
|
method: "POST",
|
|
1583
|
-
headers: { "Content-Type":
|
|
1593
|
+
headers: { "Content-Type": Ct.CONTENT_TYPE },
|
|
1584
1594
|
body: n.toString()
|
|
1585
1595
|
});
|
|
1586
1596
|
if (!e.ok && e.status !== 200) {
|
|
1587
1597
|
let t = await e.json().catch(() => ({}));
|
|
1588
|
-
throw
|
|
1598
|
+
throw U.fromOAuthError({
|
|
1589
1599
|
error: t.error || "server_error",
|
|
1590
1600
|
error_description: t.error_description || "Token revocation failed"
|
|
1591
1601
|
}, e.status);
|
|
1592
1602
|
}
|
|
1593
1603
|
this.clearCache();
|
|
1594
1604
|
} catch (e) {
|
|
1595
|
-
throw e instanceof
|
|
1605
|
+
throw e instanceof U ? e : U.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1596
1606
|
}
|
|
1597
1607
|
}
|
|
1598
1608
|
get url() {
|
|
@@ -1607,101 +1617,101 @@ var Pe = /* @__PURE__ */ function(e) {
|
|
|
1607
1617
|
get audience() {
|
|
1608
1618
|
return this.config.audience;
|
|
1609
1619
|
}
|
|
1610
|
-
},
|
|
1620
|
+
}, Dt = "error", Ot = /* @__PURE__ */ new WeakMap(), kt = (e, t) => {
|
|
1611
1621
|
if (typeof t != "object" && typeof t != "function" || t === null) return !0;
|
|
1612
|
-
let n =
|
|
1613
|
-
return n || (n = /* @__PURE__ */ new WeakSet(),
|
|
1614
|
-
},
|
|
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([
|
|
1615
1625
|
1e3,
|
|
1616
1626
|
3e3,
|
|
1617
1627
|
1e4,
|
|
1618
1628
|
3e4,
|
|
1619
1629
|
6e4
|
|
1620
|
-
]),
|
|
1630
|
+
]), Pt = .2, Ft = 6e5, It = 5e3, G = 2e4, Lt = 2e4, Rt = 1e3, zt = 2e3, Bt = 1e3, Vt = 1e4, Ht = 5e3;
|
|
1621
1631
|
// lib/refresh/protocol.ts
|
|
1622
|
-
function
|
|
1632
|
+
function Ut(e) {
|
|
1623
1633
|
let t = e ? `:${e}` : "";
|
|
1624
1634
|
return {
|
|
1625
|
-
lock: `${
|
|
1626
|
-
takeoverLock: `${
|
|
1627
|
-
channel: `${
|
|
1635
|
+
lock: `${At}${t}`,
|
|
1636
|
+
takeoverLock: `${jt}${t}`,
|
|
1637
|
+
channel: `${Mt}${t}`
|
|
1628
1638
|
};
|
|
1629
1639
|
}
|
|
1630
|
-
function
|
|
1640
|
+
function K(e) {
|
|
1631
1641
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
1632
1642
|
}
|
|
1633
|
-
function
|
|
1643
|
+
function Wt(e) {
|
|
1634
1644
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
1635
1645
|
}
|
|
1636
|
-
function
|
|
1646
|
+
function Gt(e) {
|
|
1637
1647
|
return typeof e == "object" && !!e;
|
|
1638
1648
|
}
|
|
1639
|
-
function
|
|
1649
|
+
function Kt(e, t) {
|
|
1640
1650
|
for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
|
|
1641
1651
|
return e;
|
|
1642
1652
|
}
|
|
1643
|
-
function
|
|
1644
|
-
if (!
|
|
1653
|
+
function qt(e) {
|
|
1654
|
+
if (!Gt(e)) return null;
|
|
1645
1655
|
let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
|
|
1646
|
-
return
|
|
1647
|
-
access_token:
|
|
1648
|
-
refresh_token:
|
|
1649
|
-
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),
|
|
1650
1660
|
scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
|
|
1651
1661
|
});
|
|
1652
1662
|
}
|
|
1653
|
-
function
|
|
1654
|
-
if (!
|
|
1663
|
+
function Jt(e) {
|
|
1664
|
+
if (!Gt(e)) return null;
|
|
1655
1665
|
let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
|
|
1656
|
-
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({
|
|
1657
1667
|
kind: t,
|
|
1658
1668
|
attempt: n,
|
|
1659
1669
|
nextAt: r,
|
|
1660
1670
|
strikes: i
|
|
1661
1671
|
}, {
|
|
1662
|
-
from:
|
|
1663
|
-
failingSince:
|
|
1672
|
+
from: K(e.from),
|
|
1673
|
+
failingSince: Wt(e.failingSince)
|
|
1664
1674
|
});
|
|
1665
1675
|
}
|
|
1666
|
-
function
|
|
1667
|
-
return
|
|
1668
|
-
fp:
|
|
1669
|
-
sub:
|
|
1670
|
-
sid:
|
|
1671
|
-
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)
|
|
1672
1682
|
});
|
|
1673
1683
|
}
|
|
1674
|
-
function
|
|
1675
|
-
if (!
|
|
1684
|
+
function Xt(e) {
|
|
1685
|
+
if (!Gt(e)) return null;
|
|
1676
1686
|
let t = e;
|
|
1677
1687
|
if (t.v !== void 0 && t.v !== 1) return null;
|
|
1678
|
-
let n =
|
|
1688
|
+
let n = K(t.tabId);
|
|
1679
1689
|
if (!n) return null;
|
|
1680
1690
|
switch (t.type) {
|
|
1681
1691
|
case "tokens-refreshed": {
|
|
1682
|
-
let e =
|
|
1683
|
-
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({
|
|
1684
1694
|
type: t.type,
|
|
1685
1695
|
tabId: n,
|
|
1686
1696
|
tokens: e,
|
|
1687
1697
|
from: r,
|
|
1688
1698
|
to: i
|
|
1689
1699
|
}, {
|
|
1690
|
-
fromIat:
|
|
1700
|
+
fromIat: Wt(t.fromIat),
|
|
1691
1701
|
fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
|
|
1692
|
-
sentAt:
|
|
1702
|
+
sentAt: Wt(t.sentAt)
|
|
1693
1703
|
});
|
|
1694
1704
|
}
|
|
1695
1705
|
case "session-refreshed": {
|
|
1696
|
-
let e =
|
|
1697
|
-
return e === void 0 ? null :
|
|
1706
|
+
let e = Wt(t.at);
|
|
1707
|
+
return e === void 0 ? null : Kt({
|
|
1698
1708
|
type: t.type,
|
|
1699
1709
|
tabId: n,
|
|
1700
1710
|
at: e
|
|
1701
|
-
}, { sub:
|
|
1711
|
+
}, { sub: K(t.sub) });
|
|
1702
1712
|
}
|
|
1703
1713
|
case "still-refreshing": {
|
|
1704
|
-
let e = t.retry === void 0 ? null :
|
|
1714
|
+
let e = t.retry === void 0 ? null : Jt(t.retry);
|
|
1705
1715
|
return e ? {
|
|
1706
1716
|
type: t.type,
|
|
1707
1717
|
tabId: n,
|
|
@@ -1712,7 +1722,7 @@ function Kt(e) {
|
|
|
1712
1722
|
};
|
|
1713
1723
|
}
|
|
1714
1724
|
case "retry-scheduled": {
|
|
1715
|
-
let e =
|
|
1725
|
+
let e = Jt(t);
|
|
1716
1726
|
return e ? {
|
|
1717
1727
|
type: t.type,
|
|
1718
1728
|
tabId: n,
|
|
@@ -1733,10 +1743,10 @@ function Kt(e) {
|
|
|
1733
1743
|
case "signed-out": return {
|
|
1734
1744
|
type: t.type,
|
|
1735
1745
|
tabId: n,
|
|
1736
|
-
...
|
|
1746
|
+
...Yt(t)
|
|
1737
1747
|
};
|
|
1738
1748
|
case "rate-limited": {
|
|
1739
|
-
let e =
|
|
1749
|
+
let e = Wt(t.until);
|
|
1740
1750
|
return e === void 0 ? null : {
|
|
1741
1751
|
type: t.type,
|
|
1742
1752
|
tabId: n,
|
|
@@ -1744,7 +1754,7 @@ function Kt(e) {
|
|
|
1744
1754
|
};
|
|
1745
1755
|
}
|
|
1746
1756
|
case "refresh-failed": {
|
|
1747
|
-
let e =
|
|
1757
|
+
let e = K(t.from);
|
|
1748
1758
|
return e ? {
|
|
1749
1759
|
type: t.type,
|
|
1750
1760
|
tabId: n,
|
|
@@ -1755,22 +1765,22 @@ function Kt(e) {
|
|
|
1755
1765
|
default: return null;
|
|
1756
1766
|
}
|
|
1757
1767
|
}
|
|
1758
|
-
function
|
|
1768
|
+
function Zt(e, t) {
|
|
1759
1769
|
let n = {
|
|
1760
1770
|
v: 1,
|
|
1761
1771
|
tabId: e
|
|
1762
1772
|
};
|
|
1763
1773
|
if (t.type === "retry-scheduled") {
|
|
1764
1774
|
let { retry: e, ...r } = t;
|
|
1765
|
-
return
|
|
1775
|
+
return Kt(n, {
|
|
1766
1776
|
...r,
|
|
1767
1777
|
...e
|
|
1768
1778
|
});
|
|
1769
1779
|
}
|
|
1770
|
-
return
|
|
1780
|
+
return Kt(n, { ...t });
|
|
1771
1781
|
}
|
|
1772
1782
|
// lib/refresh/resolve.ts
|
|
1773
|
-
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 = {
|
|
1774
1784
|
now: () => Date.now(),
|
|
1775
1785
|
random: () => Math.random(),
|
|
1776
1786
|
setTimeout: (e, t) => {
|
|
@@ -1778,28 +1788,28 @@ var Jt = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
|
|
|
1778
1788
|
return n.unref?.(), () => clearTimeout(n);
|
|
1779
1789
|
}
|
|
1780
1790
|
};
|
|
1781
|
-
function
|
|
1791
|
+
function en() {
|
|
1782
1792
|
let e = globalThis.crypto;
|
|
1783
1793
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
1784
1794
|
}
|
|
1785
|
-
function
|
|
1795
|
+
function tn(e) {
|
|
1786
1796
|
return e ? {
|
|
1787
1797
|
now: () => e.now(),
|
|
1788
1798
|
setTimeout: (t, n) => e.setTimeout(t, n),
|
|
1789
|
-
random: e.random ? () => e.random?.() ?? Math.random() :
|
|
1790
|
-
} :
|
|
1799
|
+
random: e.random ? () => e.random?.() ?? Math.random() : $t.random
|
|
1800
|
+
} : $t;
|
|
1791
1801
|
}
|
|
1792
|
-
function
|
|
1802
|
+
function nn(e) {
|
|
1793
1803
|
return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
|
|
1794
1804
|
}
|
|
1795
|
-
function
|
|
1805
|
+
function rn(e) {
|
|
1796
1806
|
try {
|
|
1797
1807
|
return e.storageSharedAcrossTabs === !0;
|
|
1798
1808
|
} catch {
|
|
1799
1809
|
return !1;
|
|
1800
1810
|
}
|
|
1801
1811
|
}
|
|
1802
|
-
function
|
|
1812
|
+
function an() {
|
|
1803
1813
|
try {
|
|
1804
1814
|
let e = globalThis.navigator?.locks;
|
|
1805
1815
|
return e && typeof e.request == "function" ? e : void 0;
|
|
@@ -1807,7 +1817,7 @@ function en() {
|
|
|
1807
1817
|
return;
|
|
1808
1818
|
}
|
|
1809
1819
|
}
|
|
1810
|
-
function
|
|
1820
|
+
function on(e) {
|
|
1811
1821
|
return (t) => {
|
|
1812
1822
|
let n = (n) => {
|
|
1813
1823
|
let r = n.key;
|
|
@@ -1816,20 +1826,20 @@ function tn(e) {
|
|
|
1816
1826
|
return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
|
|
1817
1827
|
};
|
|
1818
1828
|
}
|
|
1819
|
-
function
|
|
1829
|
+
function sn(e) {
|
|
1820
1830
|
return {
|
|
1821
1831
|
transports: null,
|
|
1822
|
-
names:
|
|
1823
|
-
clock:
|
|
1832
|
+
names: Ut(e),
|
|
1833
|
+
clock: $t,
|
|
1824
1834
|
warnOnFirstCycle: !1
|
|
1825
1835
|
};
|
|
1826
1836
|
}
|
|
1827
|
-
function
|
|
1828
|
-
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) => {
|
|
1829
1839
|
let t = {
|
|
1830
1840
|
transports: null,
|
|
1831
1841
|
names: i,
|
|
1832
|
-
clock:
|
|
1842
|
+
clock: $t,
|
|
1833
1843
|
warnOnFirstCycle: e
|
|
1834
1844
|
};
|
|
1835
1845
|
return o && (t.onStorageChange = o), t;
|
|
@@ -1839,16 +1849,16 @@ function rn(e, t, n, r) {
|
|
|
1839
1849
|
transports: {
|
|
1840
1850
|
locks: e.locks,
|
|
1841
1851
|
channel: e.channel,
|
|
1842
|
-
tabId: e.tabId ??
|
|
1852
|
+
tabId: e.tabId ?? en()
|
|
1843
1853
|
},
|
|
1844
1854
|
names: i,
|
|
1845
|
-
clock:
|
|
1855
|
+
clock: tn(e.clock),
|
|
1846
1856
|
warnOnFirstCycle: !1
|
|
1847
1857
|
};
|
|
1848
1858
|
return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
|
|
1849
1859
|
}
|
|
1850
|
-
if (e === "none" || !a ||
|
|
1851
|
-
let c =
|
|
1860
|
+
if (e === "none" || !a || !rn(t)) return s(!1);
|
|
1861
|
+
let c = an();
|
|
1852
1862
|
if (!c || typeof BroadcastChannel != "function") return s(!0);
|
|
1853
1863
|
let l;
|
|
1854
1864
|
try {
|
|
@@ -1860,36 +1870,36 @@ function rn(e, t, n, r) {
|
|
|
1860
1870
|
transports: {
|
|
1861
1871
|
locks: c,
|
|
1862
1872
|
channel: l,
|
|
1863
|
-
tabId:
|
|
1873
|
+
tabId: en()
|
|
1864
1874
|
},
|
|
1865
1875
|
names: i,
|
|
1866
|
-
clock:
|
|
1876
|
+
clock: $t,
|
|
1867
1877
|
warnOnFirstCycle: !1
|
|
1868
1878
|
};
|
|
1869
1879
|
return o && (u.onStorageChange = o), u;
|
|
1870
1880
|
}
|
|
1871
1881
|
// lib/pkce.ts
|
|
1872
|
-
var
|
|
1882
|
+
var ln = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", un = 32, dn = (e) => {
|
|
1873
1883
|
let t = "";
|
|
1874
1884
|
for (let n = 0; n < e.length; n += 3) {
|
|
1875
1885
|
let r = e[n], i = e[n + 1], a = e[n + 2];
|
|
1876
|
-
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));
|
|
1877
1887
|
}
|
|
1878
1888
|
return t;
|
|
1879
|
-
},
|
|
1889
|
+
}, fn = () => {
|
|
1880
1890
|
let e = globalThis.crypto;
|
|
1881
1891
|
if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1882
1892
|
return e;
|
|
1883
|
-
},
|
|
1884
|
-
let t = await
|
|
1885
|
-
return
|
|
1886
|
-
},
|
|
1887
|
-
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)));
|
|
1888
1898
|
return {
|
|
1889
1899
|
verifier: e,
|
|
1890
|
-
challenge: await
|
|
1900
|
+
challenge: await pn(e)
|
|
1891
1901
|
};
|
|
1892
|
-
},
|
|
1902
|
+
}, hn = class {
|
|
1893
1903
|
error(e, ...t) {
|
|
1894
1904
|
console.error(e, ...t);
|
|
1895
1905
|
}
|
|
@@ -1903,10 +1913,10 @@ var an = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", on
|
|
|
1903
1913
|
console.debug(e, ...t);
|
|
1904
1914
|
}
|
|
1905
1915
|
};
|
|
1906
|
-
function
|
|
1907
|
-
return new
|
|
1916
|
+
function gn() {
|
|
1917
|
+
return new hn();
|
|
1908
1918
|
}
|
|
1909
|
-
var
|
|
1919
|
+
var _n = Object.freeze([
|
|
1910
1920
|
"error.token.invalid.error",
|
|
1911
1921
|
"error.api.token.parse.error",
|
|
1912
1922
|
"error.api.user.blocked",
|
|
@@ -1914,25 +1924,25 @@ var pn = Object.freeze([
|
|
|
1914
1924
|
"error.validation.token.invalid.subject",
|
|
1915
1925
|
"error.not.found"
|
|
1916
1926
|
]);
|
|
1917
|
-
function
|
|
1927
|
+
function vn(e) {
|
|
1918
1928
|
if (typeof e != "object" || !e) return;
|
|
1919
1929
|
let t = e;
|
|
1920
1930
|
return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
|
|
1921
1931
|
}
|
|
1922
|
-
function
|
|
1923
|
-
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);
|
|
1924
1934
|
if (typeof e != "string") return;
|
|
1925
1935
|
let n = e.trim();
|
|
1926
1936
|
if (n === "") return;
|
|
1927
|
-
if (/^\d+$/.test(n)) return Math.min(
|
|
1937
|
+
if (/^\d+$/.test(n)) return Math.min(Ft, Number.parseInt(n, 10) * 1e3);
|
|
1928
1938
|
if (!/[a-z]/i.test(n)) return;
|
|
1929
1939
|
let r = Date.parse(n);
|
|
1930
|
-
if (!Number.isNaN(r)) return Math.min(
|
|
1940
|
+
if (!Number.isNaN(r)) return Math.min(Ft, Math.max(0, r - t));
|
|
1931
1941
|
}
|
|
1932
|
-
function
|
|
1942
|
+
function bn(e) {
|
|
1933
1943
|
return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
|
|
1934
1944
|
}
|
|
1935
|
-
function
|
|
1945
|
+
function xn(e) {
|
|
1936
1946
|
if (typeof e.id == "string" && e.id !== "") return e.id;
|
|
1937
1947
|
let t = e.response?.data;
|
|
1938
1948
|
if (typeof t != "object" || !t) return;
|
|
@@ -1941,14 +1951,14 @@ function _n(e) {
|
|
|
1941
1951
|
let r = n.id;
|
|
1942
1952
|
return typeof r == "string" && r !== "" ? r : void 0;
|
|
1943
1953
|
}
|
|
1944
|
-
function
|
|
1954
|
+
function Sn(e, t = Date.now()) {
|
|
1945
1955
|
if (typeof e != "object" || !e) return { kind: "transient" };
|
|
1946
|
-
let n = e, r =
|
|
1956
|
+
let n = e, r = xn(n), i = bn(n.response?.status) ?? bn(n.status), a = {};
|
|
1947
1957
|
if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
|
|
1948
1958
|
kind: "blocked",
|
|
1949
1959
|
...a
|
|
1950
1960
|
};
|
|
1951
|
-
if (r !== void 0 &&
|
|
1961
|
+
if (r !== void 0 && _n.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
|
|
1952
1962
|
kind: "auth",
|
|
1953
1963
|
...a
|
|
1954
1964
|
};
|
|
@@ -1956,7 +1966,7 @@ function vn(e, t = Date.now()) {
|
|
|
1956
1966
|
kind: "transient",
|
|
1957
1967
|
...a
|
|
1958
1968
|
};
|
|
1959
|
-
let o =
|
|
1969
|
+
let o = yn(n.retryAfter ?? vn(n.response?.headers), t);
|
|
1960
1970
|
return o === void 0 ? {
|
|
1961
1971
|
kind: "transient",
|
|
1962
1972
|
...a
|
|
@@ -1966,19 +1976,19 @@ function vn(e, t = Date.now()) {
|
|
|
1966
1976
|
retryAfterMs: o
|
|
1967
1977
|
};
|
|
1968
1978
|
}
|
|
1969
|
-
function
|
|
1970
|
-
let r =
|
|
1971
|
-
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);
|
|
1972
1982
|
}
|
|
1973
1983
|
// lib/refresh/coordinator.ts
|
|
1974
|
-
var
|
|
1984
|
+
var wn = {
|
|
1975
1985
|
onGranted: () => !1,
|
|
1976
1986
|
onLockLost: () => void 0,
|
|
1977
1987
|
onMessage: () => void 0
|
|
1978
1988
|
};
|
|
1979
|
-
function
|
|
1980
|
-
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o =
|
|
1981
|
-
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));
|
|
1982
1992
|
}, v = () => s !== null && c === null, y = () => {
|
|
1983
1993
|
f?.(), f = null;
|
|
1984
1994
|
}, b = (e) => {
|
|
@@ -1993,7 +2003,7 @@ function xn(e) {
|
|
|
1993
2003
|
type: "still-refreshing",
|
|
1994
2004
|
retry: m
|
|
1995
2005
|
} : { type: "still-refreshing" }), S());
|
|
1996
|
-
},
|
|
2006
|
+
}, It);
|
|
1997
2007
|
}, C = () => {
|
|
1998
2008
|
y(), x(), u?.(), u = null;
|
|
1999
2009
|
let e = s;
|
|
@@ -2034,29 +2044,29 @@ function xn(e) {
|
|
|
2034
2044
|
let e = s;
|
|
2035
2045
|
t.request(i.takeoverLock, { ifAvailable: !0 }, (t) => {
|
|
2036
2046
|
if (s === e && v()) {
|
|
2037
|
-
if (t === null) b(a.now() +
|
|
2047
|
+
if (t === null) b(a.now() + G);
|
|
2038
2048
|
else return _({ type: "takeover" }), new Promise((t) => {
|
|
2039
2049
|
u = t, e && (e.dead = !0, e.abort.abort()), D(!0);
|
|
2040
2050
|
});
|
|
2041
2051
|
}
|
|
2042
2052
|
}).catch(() => {
|
|
2043
|
-
v() && b(a.now() +
|
|
2053
|
+
v() && b(a.now() + G);
|
|
2044
2054
|
});
|
|
2045
2055
|
}, ee = (e) => {
|
|
2046
2056
|
if (g) return;
|
|
2047
|
-
let t =
|
|
2057
|
+
let t = Xt(e.data);
|
|
2048
2058
|
if (t && t.tabId !== r) {
|
|
2049
2059
|
switch (t.type) {
|
|
2050
2060
|
case "still-refreshing":
|
|
2051
|
-
h = !0, v() && (b(a.now() +
|
|
2061
|
+
h = !0, v() && (b(a.now() + G), t.retry && b(t.retry.nextAt + G));
|
|
2052
2062
|
break;
|
|
2053
2063
|
case "takeover":
|
|
2054
|
-
h = !0, v() && b(a.now() +
|
|
2064
|
+
h = !0, v() && b(a.now() + G);
|
|
2055
2065
|
break;
|
|
2056
2066
|
case "retry-scheduled":
|
|
2057
|
-
h = !0, v() && b(Math.max(a.now(), t.retry.nextAt) +
|
|
2067
|
+
h = !0, v() && b(Math.max(a.now(), t.retry.nextAt) + G);
|
|
2058
2068
|
break;
|
|
2059
|
-
case "rate-limited": v() && b(t.until +
|
|
2069
|
+
case "rate-limited": v() && b(t.until + G);
|
|
2060
2070
|
}
|
|
2061
2071
|
o.onMessage(t);
|
|
2062
2072
|
}
|
|
@@ -2074,7 +2084,7 @@ function xn(e) {
|
|
|
2074
2084
|
o = e;
|
|
2075
2085
|
},
|
|
2076
2086
|
request: (e) => {
|
|
2077
|
-
g || s || (p = 0, b(Math.max(a.now() +
|
|
2087
|
+
g || s || (p = 0, b(Math.max(a.now() + G, e ?? 0)), D(!1));
|
|
2078
2088
|
},
|
|
2079
2089
|
release: C,
|
|
2080
2090
|
post: _,
|
|
@@ -2087,8 +2097,8 @@ function xn(e) {
|
|
|
2087
2097
|
}
|
|
2088
2098
|
};
|
|
2089
2099
|
}
|
|
2090
|
-
function
|
|
2091
|
-
let t =
|
|
2100
|
+
function En(e = "local") {
|
|
2101
|
+
let t = wn, n = !1, r = !1, i = 0, a = !1, o = () => {
|
|
2092
2102
|
n = !1, r = !1, i += 1;
|
|
2093
2103
|
};
|
|
2094
2104
|
return {
|
|
@@ -2128,7 +2138,7 @@ function Sn(e = "local") {
|
|
|
2128
2138
|
};
|
|
2129
2139
|
}
|
|
2130
2140
|
// lib/refresh/errors.ts
|
|
2131
|
-
var
|
|
2141
|
+
var q = {
|
|
2132
2142
|
unavailable: "error.refresh.unavailable",
|
|
2133
2143
|
authRetry: "error.refresh.auth_retry",
|
|
2134
2144
|
sessionEnded: "error.refresh.session_ended",
|
|
@@ -2136,7 +2146,7 @@ var K = {
|
|
|
2136
2146
|
successorTimeout: "error.refresh.successor_timeout",
|
|
2137
2147
|
identityChanged: "error.refresh.identity_changed",
|
|
2138
2148
|
disposed: "error.refresh.disposed"
|
|
2139
|
-
},
|
|
2149
|
+
}, Dn = {
|
|
2140
2150
|
"error.refresh.unavailable": 503,
|
|
2141
2151
|
"error.refresh.auth_retry": 401,
|
|
2142
2152
|
"error.refresh.session_ended": 401,
|
|
@@ -2144,7 +2154,7 @@ var K = {
|
|
|
2144
2154
|
"error.refresh.successor_timeout": 401,
|
|
2145
2155
|
"error.refresh.identity_changed": 401,
|
|
2146
2156
|
"error.refresh.disposed": 499
|
|
2147
|
-
},
|
|
2157
|
+
}, On = {
|
|
2148
2158
|
"error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
|
|
2149
2159
|
"error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
|
|
2150
2160
|
"error.refresh.session_ended": "The session has ended",
|
|
@@ -2152,23 +2162,23 @@ var K = {
|
|
|
2152
2162
|
"error.refresh.successor_timeout": "The refresh token was already used and no successor arrived",
|
|
2153
2163
|
"error.refresh.identity_changed": "Storage holds another user's tokens",
|
|
2154
2164
|
"error.refresh.disposed": "The Passflow instance was disposed"
|
|
2155
|
-
},
|
|
2165
|
+
}, J = class extends B {
|
|
2156
2166
|
constructor(e, t = {}) {
|
|
2157
2167
|
super({
|
|
2158
2168
|
id: e,
|
|
2159
|
-
message: t.message ??
|
|
2160
|
-
status:
|
|
2169
|
+
message: t.message ?? On[e],
|
|
2170
|
+
status: Dn[e],
|
|
2161
2171
|
location: "/auth/refresh",
|
|
2162
2172
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2163
2173
|
}), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
|
|
2164
2174
|
}
|
|
2165
|
-
},
|
|
2175
|
+
}, kn = class extends Error {
|
|
2166
2176
|
constructor(e, t) {
|
|
2167
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;
|
|
2168
2178
|
}
|
|
2169
2179
|
};
|
|
2170
2180
|
// lib/refresh/lineage.ts
|
|
2171
|
-
function
|
|
2181
|
+
function An(e) {
|
|
2172
2182
|
if (!e) return;
|
|
2173
2183
|
let t = 3735928559, n = 1103547991;
|
|
2174
2184
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -2177,24 +2187,24 @@ function J(e) {
|
|
|
2177
2187
|
}
|
|
2178
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);
|
|
2179
2189
|
}
|
|
2180
|
-
function
|
|
2190
|
+
function jn(e) {
|
|
2181
2191
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2182
2192
|
}
|
|
2183
2193
|
function Y(e) {
|
|
2184
|
-
let t =
|
|
2194
|
+
let t = An(e);
|
|
2185
2195
|
if (!e || !t) return;
|
|
2186
2196
|
let n = {};
|
|
2187
2197
|
try {
|
|
2188
2198
|
let t = A(e);
|
|
2189
2199
|
typeof t == "object" && t && (n = t);
|
|
2190
2200
|
} catch {}
|
|
2191
|
-
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);
|
|
2192
2202
|
return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
|
|
2193
2203
|
}
|
|
2194
|
-
var
|
|
2195
|
-
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)) {
|
|
2196
2206
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
|
|
2197
|
-
a || (a = !0, e(
|
|
2207
|
+
a || (a = !0, e(Mn));
|
|
2198
2208
|
}, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
|
|
2199
2209
|
if (!e) return;
|
|
2200
2210
|
if (e.iat === void 0) {
|
|
@@ -2235,16 +2245,16 @@ function On(e = (e) => fn().warn(e)) {
|
|
|
2235
2245
|
};
|
|
2236
2246
|
}
|
|
2237
2247
|
// lib/refresh/fence.ts
|
|
2238
|
-
var
|
|
2248
|
+
var Pn = class extends Error {
|
|
2239
2249
|
constructor(e) {
|
|
2240
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;
|
|
2241
2251
|
}
|
|
2242
|
-
},
|
|
2252
|
+
}, Fn = class extends Error {
|
|
2243
2253
|
constructor() {
|
|
2244
2254
|
super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
|
|
2245
2255
|
}
|
|
2246
2256
|
};
|
|
2247
|
-
function
|
|
2257
|
+
function In(e) {
|
|
2248
2258
|
if (e) try {
|
|
2249
2259
|
let t = A(e).sub;
|
|
2250
2260
|
return typeof t == "string" && t !== "" ? t : void 0;
|
|
@@ -2253,20 +2263,20 @@ function jn(e) {
|
|
|
2253
2263
|
}
|
|
2254
2264
|
}
|
|
2255
2265
|
function X(e) {
|
|
2256
|
-
return
|
|
2266
|
+
return In(e?.access_token) ?? In(e?.refresh_token) ?? In(e?.id_token);
|
|
2257
2267
|
}
|
|
2258
|
-
function
|
|
2268
|
+
function Ln(e, t) {
|
|
2259
2269
|
return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
|
|
2260
2270
|
}
|
|
2261
|
-
function
|
|
2271
|
+
function Rn(e) {
|
|
2262
2272
|
return typeof e == "object" && !!e;
|
|
2263
2273
|
}
|
|
2264
|
-
function
|
|
2265
|
-
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 = () => {
|
|
2266
2276
|
let e = t.getTokens(), n = e?.refresh_token;
|
|
2267
2277
|
if (!n) return p = l, e;
|
|
2268
2278
|
p !== void 0 && (f = Math.max(f, p, m), p = void 0);
|
|
2269
|
-
let r =
|
|
2279
|
+
let r = An(n) ?? "";
|
|
2270
2280
|
return r !== c?.fp && (c = {
|
|
2271
2281
|
fp: r,
|
|
2272
2282
|
seq: l
|
|
@@ -2299,7 +2309,7 @@ function Pn(e) {
|
|
|
2299
2309
|
let t = E();
|
|
2300
2310
|
t === "wait" && e && (t = "end"), t !== "wait" && D(), t === "wait" && !h && (h = r(() => {
|
|
2301
2311
|
h = void 0, y()?.refresh_token ? N() : O(!0) === "end" && s?.("emptied");
|
|
2302
|
-
},
|
|
2312
|
+
}, zt));
|
|
2303
2313
|
let n = t === "keep" ? T() : void 0;
|
|
2304
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;
|
|
2305
2315
|
}, ee = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, k = (e) => {
|
|
@@ -2312,7 +2322,7 @@ function Pn(e) {
|
|
|
2312
2322
|
return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
|
|
2313
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) => {
|
|
2314
2324
|
let t = b();
|
|
2315
|
-
t && t.fp !==
|
|
2325
|
+
t && t.fp !== An(e.refresh_token) && o.retire(t), n.setTokensCache(e);
|
|
2316
2326
|
}, te = (e) => {
|
|
2317
2327
|
let t = y(), n = t?.refresh_token;
|
|
2318
2328
|
if (n === e.refreshToken) return null;
|
|
@@ -2323,7 +2333,7 @@ function Pn(e) {
|
|
|
2323
2333
|
kind: "superseded",
|
|
2324
2334
|
adopted: !1
|
|
2325
2335
|
};
|
|
2326
|
-
let r =
|
|
2336
|
+
let r = In(t.access_token) ?? In(n);
|
|
2327
2337
|
if (e.sub && r && e.sub !== r) return {
|
|
2328
2338
|
kind: "identity-changed",
|
|
2329
2339
|
saved: !1
|
|
@@ -2363,22 +2373,22 @@ function Pn(e) {
|
|
|
2363
2373
|
}, re = !!s || !!e.onStoredSessionSeen, ie = re && e.onStorageChange ? e.onStorageChange(N) : void 0, ae = re && e.onWake ? e.onWake(N) : void 0, P = () => {
|
|
2364
2374
|
let e = y();
|
|
2365
2375
|
if (!e?.refresh_token) {
|
|
2366
|
-
if (O() === "end") throw new
|
|
2376
|
+
if (O() === "end") throw new Pn("emptied");
|
|
2367
2377
|
return "held";
|
|
2368
2378
|
}
|
|
2369
2379
|
let t = n.getTokens();
|
|
2370
2380
|
if (e.refresh_token === t?.refresh_token) return "send";
|
|
2371
2381
|
let r = i() ?? X(t), a = X(e);
|
|
2372
|
-
if (r && a && r !== a) throw new
|
|
2382
|
+
if (r && a && r !== a) throw new Fn();
|
|
2373
2383
|
let s = Y(e.refresh_token);
|
|
2374
2384
|
if (o.isEnded(s)) {
|
|
2375
2385
|
if (s && C(s)) return "held";
|
|
2376
|
-
throw new
|
|
2386
|
+
throw new Pn("ended");
|
|
2377
2387
|
}
|
|
2378
2388
|
let c = Y(t?.refresh_token);
|
|
2379
2389
|
return j(s, c) ? (M(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && k(s) ? "held" : "send";
|
|
2380
2390
|
}, oe = (e) => {
|
|
2381
|
-
let t = i(), r =
|
|
2391
|
+
let t = i(), r = In(e);
|
|
2382
2392
|
if (t && r && t !== r) return { kind: "identity-changed" };
|
|
2383
2393
|
let a = Y(e) ?? { fp: e };
|
|
2384
2394
|
if (o.isEnded(a)) return C(a) ? { kind: "superseded" } : { kind: "ended" };
|
|
@@ -2386,7 +2396,7 @@ function Pn(e) {
|
|
|
2386
2396
|
let s = {
|
|
2387
2397
|
refreshToken: e,
|
|
2388
2398
|
order: a
|
|
2389
|
-
}, c = t ?? r ??
|
|
2399
|
+
}, c = t ?? r ?? In(n.getTokens()?.access_token);
|
|
2390
2400
|
return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
|
|
2391
2401
|
kind: "send",
|
|
2392
2402
|
sent: s
|
|
@@ -2395,7 +2405,7 @@ function Pn(e) {
|
|
|
2395
2405
|
if (o.isEnded(e.order)) return ne(e.order);
|
|
2396
2406
|
let i = te(e);
|
|
2397
2407
|
if (i) return i;
|
|
2398
|
-
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.`), {
|
|
2399
2409
|
kind: "superseded",
|
|
2400
2410
|
adopted: !1
|
|
2401
2411
|
};
|
|
@@ -2405,7 +2415,7 @@ function Pn(e) {
|
|
|
2405
2415
|
saved: !0
|
|
2406
2416
|
};
|
|
2407
2417
|
let c = Y(r.refresh_token);
|
|
2408
|
-
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.`), {
|
|
2409
2419
|
kind: "superseded",
|
|
2410
2420
|
adopted: !1
|
|
2411
2421
|
}) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
|
|
@@ -2417,7 +2427,7 @@ function Pn(e) {
|
|
|
2417
2427
|
kind: "superseded",
|
|
2418
2428
|
adopted: !1
|
|
2419
2429
|
};
|
|
2420
|
-
let r =
|
|
2430
|
+
let r = Sn(t), i = r.kind === "blocked" || r.kind === "auth";
|
|
2421
2431
|
return ee(e) && i ? (o.retire(e.order), _ = e.order, {
|
|
2422
2432
|
kind: "own",
|
|
2423
2433
|
failure: r,
|
|
@@ -2428,11 +2438,11 @@ function Pn(e) {
|
|
|
2428
2438
|
heldRefused: !1
|
|
2429
2439
|
});
|
|
2430
2440
|
}, I = (e) => {
|
|
2431
|
-
if (!
|
|
2441
|
+
if (!Rn(e)) return !1;
|
|
2432
2442
|
let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
|
|
2433
|
-
if (typeof t != "string" || typeof c != "string" || !
|
|
2443
|
+
if (typeof t != "string" || typeof c != "string" || !Rn(l)) return !1;
|
|
2434
2444
|
let u = l;
|
|
2435
|
-
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;
|
|
2436
2446
|
let d = y();
|
|
2437
2447
|
if (!d?.refresh_token) return !1;
|
|
2438
2448
|
let f = n.getTokens(), p = i() ?? X(f), m = X(u);
|
|
@@ -2449,7 +2459,7 @@ function Pn(e) {
|
|
|
2449
2459
|
}
|
|
2450
2460
|
return !0;
|
|
2451
2461
|
};
|
|
2452
|
-
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 }), _());
|
|
2453
2463
|
}, L = (e) => {
|
|
2454
2464
|
if (!e || !_) return !1;
|
|
2455
2465
|
let t = _;
|
|
@@ -2515,7 +2525,7 @@ function Pn(e) {
|
|
|
2515
2525
|
};
|
|
2516
2526
|
}
|
|
2517
2527
|
// lib/refresh/controller.ts
|
|
2518
|
-
function
|
|
2528
|
+
function Bn() {
|
|
2519
2529
|
let e, t, n = new Promise((n, r) => {
|
|
2520
2530
|
e = n, t = r;
|
|
2521
2531
|
});
|
|
@@ -2525,53 +2535,53 @@ function Fn() {
|
|
|
2525
2535
|
reject: t
|
|
2526
2536
|
};
|
|
2527
2537
|
}
|
|
2528
|
-
var
|
|
2529
|
-
strikes:
|
|
2530
|
-
"session-ended":
|
|
2531
|
-
"stored-ended":
|
|
2532
|
-
"signed-out":
|
|
2533
|
-
emptied:
|
|
2534
|
-
"signed-out-here":
|
|
2535
|
-
"successor-timeout":
|
|
2536
|
-
"identity-changed":
|
|
2537
|
-
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
|
|
2538
2548
|
};
|
|
2539
|
-
function
|
|
2549
|
+
function Hn(e) {
|
|
2540
2550
|
throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
|
|
2541
2551
|
}
|
|
2542
|
-
function
|
|
2552
|
+
function Un(e) {
|
|
2543
2553
|
if (e === void 0 || !Number.isFinite(e)) return 3;
|
|
2544
2554
|
let t = Math.floor(e);
|
|
2545
2555
|
return t >= 1 ? t : 3;
|
|
2546
2556
|
}
|
|
2547
|
-
function
|
|
2557
|
+
function Wn(e, t) {
|
|
2548
2558
|
return e instanceof Error && e.message ? e.message : t;
|
|
2549
2559
|
}
|
|
2550
|
-
function
|
|
2560
|
+
function Gn(e) {
|
|
2551
2561
|
if (typeof e != "object" || !e) return;
|
|
2552
2562
|
let t = e.id;
|
|
2553
2563
|
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
2554
2564
|
}
|
|
2555
|
-
function
|
|
2565
|
+
function Kn(e) {
|
|
2556
2566
|
let t = {};
|
|
2557
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;
|
|
2558
2568
|
}
|
|
2559
|
-
function
|
|
2569
|
+
function qn(e, t) {
|
|
2560
2570
|
let n = {};
|
|
2561
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);
|
|
2562
2572
|
let r = t?.scopes ?? e.scopes;
|
|
2563
2573
|
return r && (n.scopes = r), n;
|
|
2564
2574
|
}
|
|
2565
|
-
function
|
|
2566
|
-
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({
|
|
2567
2577
|
locks: a.transports.locks,
|
|
2568
2578
|
channel: a.transports.channel,
|
|
2569
2579
|
tabId: a.transports.tabId,
|
|
2570
2580
|
names: a.names,
|
|
2571
2581
|
clock: o
|
|
2572
|
-
}) :
|
|
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) => () => {
|
|
2573
2583
|
for (let t of Array.from(e)) t();
|
|
2574
|
-
}, 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({
|
|
2575
2585
|
storage: n,
|
|
2576
2586
|
cache: r,
|
|
2577
2587
|
identity: k,
|
|
@@ -2586,13 +2596,13 @@ function Un(e) {
|
|
|
2586
2596
|
}), re = (e) => ({
|
|
2587
2597
|
trigger: e,
|
|
2588
2598
|
startedAt: T(),
|
|
2589
|
-
plain:
|
|
2599
|
+
plain: Bn(),
|
|
2590
2600
|
fresh: []
|
|
2591
2601
|
}), ie = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, ae = (e, t) => {
|
|
2592
2602
|
if (t === void 0) return e.plain.promise;
|
|
2593
2603
|
let n = {
|
|
2594
2604
|
callTime: t,
|
|
2595
|
-
deferred:
|
|
2605
|
+
deferred: Bn()
|
|
2596
2606
|
};
|
|
2597
2607
|
return e.fresh.push(n), n.deferred.promise;
|
|
2598
2608
|
}, P = (e, t, n = !1) => {
|
|
@@ -2611,11 +2621,11 @@ function Un(e) {
|
|
|
2611
2621
|
}
|
|
2612
2622
|
}, F = (e, n, r, i) => {
|
|
2613
2623
|
let a = {
|
|
2614
|
-
message:
|
|
2624
|
+
message: Wn(r, "Token refresh failed"),
|
|
2615
2625
|
originalError: r,
|
|
2616
2626
|
operation: e,
|
|
2617
2627
|
source: n
|
|
2618
|
-
}, o =
|
|
2628
|
+
}, o = Gn(r);
|
|
2619
2629
|
o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
|
|
2620
2630
|
}, I = (e, t) => {
|
|
2621
2631
|
let n = {
|
|
@@ -2645,10 +2655,10 @@ function Un(e) {
|
|
|
2645
2655
|
};
|
|
2646
2656
|
n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
|
|
2647
2657
|
}, le = (e, t) => {
|
|
2648
|
-
let n = r.getTokens(), i =
|
|
2658
|
+
let n = r.getTokens(), i = An(n?.refresh_token);
|
|
2649
2659
|
e.fp && i && l.post({
|
|
2650
2660
|
type: "tokens-refreshed",
|
|
2651
|
-
tokens:
|
|
2661
|
+
tokens: Kn(n),
|
|
2652
2662
|
from: e.fp,
|
|
2653
2663
|
...e.iat === void 0 ? {} : { fromIat: e.iat },
|
|
2654
2664
|
fromSid: e.sid ?? "",
|
|
@@ -2656,7 +2666,7 @@ function Un(e) {
|
|
|
2656
2666
|
...t === void 0 ? {} : { sentAt: t }
|
|
2657
2667
|
});
|
|
2658
2668
|
}, ue = () => {
|
|
2659
|
-
p || (p = !0, s.warn(
|
|
2669
|
+
p || (p = !0, s.warn(Qt));
|
|
2660
2670
|
}, de = (e) => {
|
|
2661
2671
|
(e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
|
|
2662
2672
|
}, R = (e, n) => {
|
|
@@ -2670,7 +2680,7 @@ function Un(e) {
|
|
|
2670
2680
|
}, e !== "disposed" && N.dropSession(), (e === "strikes" || e === "successor-timeout") && E() !== "json" && i.invalidate(), u = {
|
|
2671
2681
|
kind: "ended",
|
|
2672
2682
|
cause: e
|
|
2673
|
-
}, se(r, n ?? new
|
|
2683
|
+
}, se(r, n ?? new J(Vn[e])), e) {
|
|
2674
2684
|
case "strikes":
|
|
2675
2685
|
t("session:expired", {
|
|
2676
2686
|
reason: "refresh_failed",
|
|
@@ -2705,7 +2715,7 @@ function Un(e) {
|
|
|
2705
2715
|
break;
|
|
2706
2716
|
case "signed-out-here":
|
|
2707
2717
|
case "disposed": break;
|
|
2708
|
-
default:
|
|
2718
|
+
default: Hn(e);
|
|
2709
2719
|
}
|
|
2710
2720
|
}, fe = () => {
|
|
2711
2721
|
if (u.kind !== "ended" || u.cause === "disposed" || f || E() !== "json") return;
|
|
@@ -2722,17 +2732,17 @@ function Un(e) {
|
|
|
2722
2732
|
}, pe = (e) => {
|
|
2723
2733
|
u.kind === "ended" || f || E() === "json" && (R(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && fe());
|
|
2724
2734
|
}, me = (e) => {
|
|
2725
|
-
e instanceof
|
|
2735
|
+
e instanceof Fn ? (R("identity-changed"), fe()) : e instanceof Pn ? R(e.cause === "emptied" ? "emptied" : "stored-ended") : R("stored-ended", e);
|
|
2726
2736
|
}, he = () => {
|
|
2727
2737
|
u = { kind: "idle" }, w || l.release();
|
|
2728
|
-
}, 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) => {
|
|
2729
2739
|
let t = g;
|
|
2730
2740
|
if (!t) return;
|
|
2731
2741
|
if (!l.holding) {
|
|
2732
2742
|
u = {
|
|
2733
2743
|
kind: "waiting",
|
|
2734
2744
|
pending: e
|
|
2735
|
-
}, l.request(t.nextAt +
|
|
2745
|
+
}, l.request(t.nextAt + G);
|
|
2736
2746
|
return;
|
|
2737
2747
|
}
|
|
2738
2748
|
l.setRetryInfo(t);
|
|
@@ -2751,7 +2761,7 @@ function Un(e) {
|
|
|
2751
2761
|
!l.holding || l.foreignHolderHeard() || T() - t > 2e4 ? (l.release(), u = {
|
|
2752
2762
|
kind: "waiting",
|
|
2753
2763
|
pending: e
|
|
2754
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
2764
|
+
}, l.request((g?.nextAt ?? T()) + G)) : (u = {
|
|
2755
2765
|
kind: "waiting",
|
|
2756
2766
|
pending: e
|
|
2757
2767
|
}, be() || ye());
|
|
@@ -2791,14 +2801,14 @@ function Un(e) {
|
|
|
2791
2801
|
case "ended": return N.endHeldSend(), R("stored-ended"), !1;
|
|
2792
2802
|
case "identity-changed": return N.endHeldSend(), R("identity-changed"), fe(), !1;
|
|
2793
2803
|
case "send": return Ce(e, t, a.sent, r);
|
|
2794
|
-
default: return
|
|
2804
|
+
default: return Hn(a);
|
|
2795
2805
|
}
|
|
2796
2806
|
}, Ce = (e, n, r, a) => {
|
|
2797
2807
|
let o = {
|
|
2798
2808
|
generation: d,
|
|
2799
2809
|
sentAt: T(),
|
|
2800
2810
|
trigger: n,
|
|
2801
|
-
settled:
|
|
2811
|
+
settled: Bn()
|
|
2802
2812
|
};
|
|
2803
2813
|
r ? o.sent = r : o.marker = ee(), a && (o.stored = a), u = {
|
|
2804
2814
|
kind: "refreshing",
|
|
@@ -2822,7 +2832,7 @@ function Un(e) {
|
|
|
2822
2832
|
if (!e.sent) {
|
|
2823
2833
|
let o = X({ ...t.id_token ? { id_token: t.id_token } : {} }), s = k();
|
|
2824
2834
|
if (o !== void 0 && s !== void 0 && o !== s) {
|
|
2825
|
-
let t = new q
|
|
2835
|
+
let t = new J(q.identityChanged);
|
|
2826
2836
|
F("refresh", e.trigger, t, I("auth")), R("identity-changed", t);
|
|
2827
2837
|
return;
|
|
2828
2838
|
}
|
|
@@ -2835,7 +2845,7 @@ function Un(e) {
|
|
|
2835
2845
|
if (!we(e)) return;
|
|
2836
2846
|
r.setTokensCache({
|
|
2837
2847
|
...n.getTokens() ?? {},
|
|
2838
|
-
...
|
|
2848
|
+
...qn(t, void 0)
|
|
2839
2849
|
}), L("refresh", "this-tab");
|
|
2840
2850
|
let c = k();
|
|
2841
2851
|
l.post(c === void 0 ? {
|
|
@@ -2848,7 +2858,7 @@ function Un(e) {
|
|
|
2848
2858
|
}), he(), P(a, e.sentAt);
|
|
2849
2859
|
return;
|
|
2850
2860
|
}
|
|
2851
|
-
let o = D(), s = N.commitSave(e.sent,
|
|
2861
|
+
let o = D(), s = N.commitSave(e.sent, qn(t, e.stored));
|
|
2852
2862
|
switch (s.kind) {
|
|
2853
2863
|
case "saved":
|
|
2854
2864
|
L("refresh", "this-tab"), le(e.sent.order, e.sentAt), he(), P(a, e.sentAt);
|
|
@@ -2857,16 +2867,16 @@ function Un(e) {
|
|
|
2857
2867
|
e.outcome && D() === o || L("adopted", "other-tab"), s.adopted && le(e.sent.order), he(), P(a, e.sentAt);
|
|
2858
2868
|
return;
|
|
2859
2869
|
case "ended": {
|
|
2860
|
-
let t = new
|
|
2870
|
+
let t = new J(s.cause === "emptied" ? q.signedOut : q.sessionEnded);
|
|
2861
2871
|
F("refresh", e.trigger, t, I("auth")), R(s.cause === "emptied" ? "emptied" : "stored-ended", t);
|
|
2862
2872
|
return;
|
|
2863
2873
|
}
|
|
2864
2874
|
case "identity-changed": {
|
|
2865
|
-
let t = new q
|
|
2875
|
+
let t = new J(q.identityChanged);
|
|
2866
2876
|
F("refresh", e.trigger, t, I("auth")), R("identity-changed", t), fe();
|
|
2867
2877
|
return;
|
|
2868
2878
|
}
|
|
2869
|
-
default:
|
|
2879
|
+
default: Hn(s);
|
|
2870
2880
|
}
|
|
2871
2881
|
}, Ee = (e, t) => {
|
|
2872
2882
|
if (e.sent?.held && N.endHeldSend(), !we(e) || u.kind !== "refreshing") return;
|
|
@@ -2886,9 +2896,9 @@ function Un(e) {
|
|
|
2886
2896
|
case "own":
|
|
2887
2897
|
r = o.failure, i = o.heldRefused;
|
|
2888
2898
|
break;
|
|
2889
|
-
default:
|
|
2899
|
+
default: Hn(o);
|
|
2890
2900
|
}
|
|
2891
|
-
} else r =
|
|
2901
|
+
} else r = Sn(t, T());
|
|
2892
2902
|
if (i) F("refresh", e.trigger, t, I(r.kind)), L("adopted", "other-tab"), he(), P(n, void 0, !0);
|
|
2893
2903
|
else switch (r.kind) {
|
|
2894
2904
|
case "blocked":
|
|
@@ -2904,10 +2914,10 @@ function Un(e) {
|
|
|
2904
2914
|
case "transient":
|
|
2905
2915
|
m += 1, De(e, n, t, r);
|
|
2906
2916
|
return;
|
|
2907
|
-
default:
|
|
2917
|
+
default: Hn(r.kind);
|
|
2908
2918
|
}
|
|
2909
2919
|
}, De = (e, t, n, r) => {
|
|
2910
|
-
let i = T() +
|
|
2920
|
+
let i = T() + Cn(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
|
|
2911
2921
|
F("refresh", e.trigger, n, I(a, i)), a === "transient" && ce(T(), i, "this-tab");
|
|
2912
2922
|
let s = {
|
|
2913
2923
|
kind: a,
|
|
@@ -2917,7 +2927,7 @@ function Un(e) {
|
|
|
2917
2927
|
}, c = e.sent?.order.fp;
|
|
2918
2928
|
c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
|
|
2919
2929
|
type: "retry-scheduled",
|
|
2920
|
-
message:
|
|
2930
|
+
message: Wn(n, "Token refresh failed"),
|
|
2921
2931
|
retry: s
|
|
2922
2932
|
}), _e(re("retry")), oe(t, n, e.sentAt);
|
|
2923
2933
|
}, z = (e, t) => {
|
|
@@ -2930,8 +2940,8 @@ function Un(e) {
|
|
|
2930
2940
|
fp: i.fp
|
|
2931
2941
|
})), r && N.deleteIfStillDead(r), R("strikes", t);
|
|
2932
2942
|
}, Oe = (e, t, n, r) => {
|
|
2933
|
-
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${
|
|
2934
|
-
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 = {
|
|
2935
2945
|
kind: "blocked-wait",
|
|
2936
2946
|
pending: e,
|
|
2937
2947
|
deadline: a,
|
|
@@ -2944,9 +2954,9 @@ function Un(e) {
|
|
|
2944
2954
|
i === d && u === c && (ke() || (f ? (e.cookieRetried = !0, u = {
|
|
2945
2955
|
kind: "waiting",
|
|
2946
2956
|
pending: e
|
|
2947
|
-
}, 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)));
|
|
2948
2958
|
};
|
|
2949
|
-
c.cancel = o.setTimeout(p, f ?
|
|
2959
|
+
c.cancel = o.setTimeout(p, f ? Bt : Rt);
|
|
2950
2960
|
}, ke = () => {
|
|
2951
2961
|
if (u.kind !== "blocked-wait") return !1;
|
|
2952
2962
|
let e = u;
|
|
@@ -2958,10 +2968,10 @@ function Un(e) {
|
|
|
2958
2968
|
r.setTokensCache(n.getTokens());
|
|
2959
2969
|
}
|
|
2960
2970
|
return u === e && (e.cancel(), L("adopted", "other-tab"), u = { kind: "idle" }, P(e.pending, void 0, !0), !0);
|
|
2961
|
-
},
|
|
2971
|
+
}, Ae = (e) => {
|
|
2962
2972
|
let t = k(), n = !e.sub || !t || e.sub === t;
|
|
2963
2973
|
return E() === "json" ? !!e.fp && e.fp === D() && n : !e.fp && n;
|
|
2964
|
-
},
|
|
2974
|
+
}, B = (e, t) => {
|
|
2965
2975
|
if (e !== "signed-out" || !t.sub) return !1;
|
|
2966
2976
|
let n = k();
|
|
2967
2977
|
return n !== void 0 && t.sub === n;
|
|
@@ -2969,7 +2979,7 @@ function Un(e) {
|
|
|
2969
2979
|
if (u.kind === "ended" || !ge(e)) return;
|
|
2970
2980
|
let r = g?.nextAt;
|
|
2971
2981
|
if (g = e, e.failingSince !== void 0 && ce(e.failingSince, e.nextAt, "other-tab"), !t || u.kind !== "waiting") return;
|
|
2972
|
-
let i = new
|
|
2982
|
+
let i = new J(e.kind === "transient" ? q.unavailable : q.authRetry, {
|
|
2973
2983
|
nextRetryAt: e.nextAt,
|
|
2974
2984
|
cause: n || void 0
|
|
2975
2985
|
}), a = u.pending;
|
|
@@ -2990,12 +3000,12 @@ function Un(e) {
|
|
|
2990
3000
|
case "idle":
|
|
2991
3001
|
case "refreshing":
|
|
2992
3002
|
case "ended": return;
|
|
2993
|
-
default:
|
|
3003
|
+
default: Hn(u);
|
|
2994
3004
|
}
|
|
2995
3005
|
}, Ne = (e) => {
|
|
2996
3006
|
let t = {};
|
|
2997
3007
|
e.fp && (t.fp = e.fp), e.sub && (t.sub = e.sub), e.sid && (t.sid = e.sid), e.iat !== void 0 && (t.iat = e.iat);
|
|
2998
|
-
let n = u.kind !== "ended" && (
|
|
3008
|
+
let n = u.kind !== "ended" && (Ae(t) || B(e.type, t));
|
|
2999
3009
|
t.fp && N.endLineage({
|
|
3000
3010
|
...t,
|
|
3001
3011
|
fp: t.fp
|
|
@@ -3033,10 +3043,10 @@ function Un(e) {
|
|
|
3033
3043
|
je(e.retry, !0, e.message), Fe();
|
|
3034
3044
|
return;
|
|
3035
3045
|
case "refresh-failed":
|
|
3036
|
-
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;
|
|
3037
3047
|
if (ce(T(), void 0, "other-tab"), u.kind === "waiting") {
|
|
3038
3048
|
let t = u.pending;
|
|
3039
|
-
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);
|
|
3040
3050
|
}
|
|
3041
3051
|
return;
|
|
3042
3052
|
case "lock-wanted":
|
|
@@ -3045,7 +3055,7 @@ function Un(e) {
|
|
|
3045
3055
|
u.cancel(), l.release(), u = {
|
|
3046
3056
|
kind: "waiting",
|
|
3047
3057
|
pending: e
|
|
3048
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
3058
|
+
}, l.request((g?.nextAt ?? T()) + G);
|
|
3049
3059
|
}
|
|
3050
3060
|
return;
|
|
3051
3061
|
case "session-ended":
|
|
@@ -3054,7 +3064,7 @@ function Un(e) {
|
|
|
3054
3064
|
return;
|
|
3055
3065
|
case "takeover":
|
|
3056
3066
|
case "rate-limited": return;
|
|
3057
|
-
default:
|
|
3067
|
+
default: Hn(e);
|
|
3058
3068
|
}
|
|
3059
3069
|
}, Fe = () => {
|
|
3060
3070
|
C && !l.holding && l.post({
|
|
@@ -3077,7 +3087,7 @@ function Un(e) {
|
|
|
3077
3087
|
u.cancel(), u = {
|
|
3078
3088
|
kind: "waiting",
|
|
3079
3089
|
pending: e
|
|
3080
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
3090
|
+
}, l.request((g?.nextAt ?? T()) + G);
|
|
3081
3091
|
}
|
|
3082
3092
|
},
|
|
3083
3093
|
onMessage: Pe
|
|
@@ -3103,9 +3113,9 @@ function Un(e) {
|
|
|
3103
3113
|
};
|
|
3104
3114
|
A.add(Ie), j.add(Ie);
|
|
3105
3115
|
let Le = (e, t) => {
|
|
3106
|
-
if (f) return Promise.reject(new q
|
|
3116
|
+
if (f) return Promise.reject(new J(q.disposed));
|
|
3107
3117
|
switch (u.kind) {
|
|
3108
|
-
case "ended": return Promise.reject(new q
|
|
3118
|
+
case "ended": return Promise.reject(new J(q.sessionEnded));
|
|
3109
3119
|
case "idle": {
|
|
3110
3120
|
let n = re(e);
|
|
3111
3121
|
u = {
|
|
@@ -3113,17 +3123,17 @@ function Un(e) {
|
|
|
3113
3123
|
pending: n
|
|
3114
3124
|
};
|
|
3115
3125
|
let r = ae(n, t);
|
|
3116
|
-
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;
|
|
3117
3127
|
}
|
|
3118
3128
|
case "waiting":
|
|
3119
3129
|
case "refreshing":
|
|
3120
3130
|
case "backoff":
|
|
3121
3131
|
case "blocked-wait": return ae(u.pending, t);
|
|
3122
|
-
default: return
|
|
3132
|
+
default: return Hn(u);
|
|
3123
3133
|
}
|
|
3124
|
-
},
|
|
3125
|
-
if (f) return Promise.reject(new q
|
|
3126
|
-
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));
|
|
3127
3137
|
if (E() === "json" && !r.getTokens()?.refresh_token) {
|
|
3128
3138
|
let t = n.getTokens();
|
|
3129
3139
|
if (!t?.refresh_token) {
|
|
@@ -3132,12 +3142,12 @@ function Un(e) {
|
|
|
3132
3142
|
}
|
|
3133
3143
|
}
|
|
3134
3144
|
return Le(e.trigger, e.fresh ? T() : void 0);
|
|
3135
|
-
},
|
|
3136
|
-
if (f) return Promise.reject(new q
|
|
3145
|
+
}, Re = (e) => {
|
|
3146
|
+
if (f) return Promise.reject(new J(q.disposed));
|
|
3137
3147
|
if (u.kind === "ended") return Promise.resolve(r.getTokens());
|
|
3138
3148
|
let t = u.kind === "backoff" || u.kind === "blocked-wait" || g !== void 0 && g.nextAt > T();
|
|
3139
|
-
return e.allowStale && t ? Promise.resolve(r.getTokens()) :
|
|
3140
|
-
},
|
|
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) => {
|
|
3141
3151
|
let r = () => void 0, i = {
|
|
3142
3152
|
purpose: e,
|
|
3143
3153
|
granted: () => {
|
|
@@ -3150,7 +3160,7 @@ function Un(e) {
|
|
|
3150
3160
|
}), l.request(), r = o.setTimeout(() => {
|
|
3151
3161
|
C === i && (C = void 0, u.kind !== "waiting" && l.release(), n("timeout"));
|
|
3152
3162
|
}, Math.max(0, t));
|
|
3153
|
-
}),
|
|
3163
|
+
}), Be = async (e) => {
|
|
3154
3164
|
if (u.kind !== "refreshing") return;
|
|
3155
3165
|
let t = u.request.settled.promise;
|
|
3156
3166
|
await new Promise((n) => {
|
|
@@ -3159,7 +3169,7 @@ function Un(e) {
|
|
|
3159
3169
|
r(), n();
|
|
3160
3170
|
});
|
|
3161
3171
|
});
|
|
3162
|
-
},
|
|
3172
|
+
}, Ve = () => {
|
|
3163
3173
|
if (w = !1, !f && l.holding) {
|
|
3164
3174
|
if (u.kind === "waiting") be() || ye();
|
|
3165
3175
|
else if (u.kind === "backoff") {
|
|
@@ -3168,18 +3178,18 @@ function Un(e) {
|
|
|
3168
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();
|
|
3169
3179
|
}
|
|
3170
3180
|
}, He = async (e, t) => {
|
|
3171
|
-
if (f) throw new q
|
|
3181
|
+
if (f) throw new J(q.disposed);
|
|
3172
3182
|
ue();
|
|
3173
|
-
let n = T() +
|
|
3174
|
-
if (await
|
|
3175
|
-
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");
|
|
3176
3186
|
throw F("upgrade.commit", "upgrade", e), e;
|
|
3177
3187
|
}
|
|
3178
3188
|
w = !0;
|
|
3179
3189
|
try {
|
|
3180
3190
|
return await Ue(e, t);
|
|
3181
3191
|
} finally {
|
|
3182
|
-
|
|
3192
|
+
Ve();
|
|
3183
3193
|
}
|
|
3184
3194
|
}, Ue = async (e, a) => {
|
|
3185
3195
|
let o, s;
|
|
@@ -3219,7 +3229,7 @@ function Un(e) {
|
|
|
3219
3229
|
if (!o) {
|
|
3220
3230
|
await i.applyOpaque(u), r.setTokensCache({
|
|
3221
3231
|
...n.getTokens() ?? {},
|
|
3222
|
-
...
|
|
3232
|
+
...qn(u, void 0)
|
|
3223
3233
|
}), We(c);
|
|
3224
3234
|
let e = k();
|
|
3225
3235
|
return l.post(e === void 0 ? {
|
|
@@ -3231,9 +3241,9 @@ function Un(e) {
|
|
|
3231
3241
|
sub: e
|
|
3232
3242
|
}), O();
|
|
3233
3243
|
}
|
|
3234
|
-
let d = N.commitSave(o,
|
|
3244
|
+
let d = N.commitSave(o, qn(u, s));
|
|
3235
3245
|
if (d.kind === "saved") return We(c), le(o.order, c), O();
|
|
3236
|
-
let f = new
|
|
3246
|
+
let f = new kn("superseded");
|
|
3237
3247
|
throw F("upgrade.commit", "upgrade", f), d.kind === "superseded" && d.adopted && L("adopted", "other-tab"), f;
|
|
3238
3248
|
}, We = (e) => {
|
|
3239
3249
|
if (L("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
|
|
@@ -3249,18 +3259,18 @@ function Un(e) {
|
|
|
3249
3259
|
...t,
|
|
3250
3260
|
fp: t.fp
|
|
3251
3261
|
}));
|
|
3252
|
-
},
|
|
3262
|
+
}, H = () => {
|
|
3253
3263
|
let e = ie(u);
|
|
3254
|
-
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" });
|
|
3255
3265
|
};
|
|
3256
3266
|
return {
|
|
3257
|
-
refresh:
|
|
3258
|
-
ensureFresh:
|
|
3267
|
+
refresh: V,
|
|
3268
|
+
ensureFresh: Re,
|
|
3259
3269
|
commitUpgrade: He,
|
|
3260
3270
|
signOut: async (e) => {
|
|
3261
3271
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3262
|
-
let t = T() +
|
|
3263
|
-
|
|
3272
|
+
let t = T() + Ht;
|
|
3273
|
+
H(), await Be(t - T()), H(), l.coordinated && !l.holding && await ze("logout", t - T());
|
|
3264
3274
|
try {
|
|
3265
3275
|
Ge(), await e(n.getTokens()?.refresh_token);
|
|
3266
3276
|
} finally {
|
|
@@ -3269,7 +3279,7 @@ function Un(e) {
|
|
|
3269
3279
|
},
|
|
3270
3280
|
signOutNow: (e) => {
|
|
3271
3281
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3272
|
-
|
|
3282
|
+
H();
|
|
3273
3283
|
try {
|
|
3274
3284
|
Ge(), e(n.getTokens()?.refresh_token);
|
|
3275
3285
|
} finally {
|
|
@@ -3297,14 +3307,14 @@ function Un(e) {
|
|
|
3297
3307
|
de(u), f = !0, d += 1, u = {
|
|
3298
3308
|
kind: "ended",
|
|
3299
3309
|
cause: "disposed"
|
|
3300
|
-
}, se(e, new q
|
|
3310
|
+
}, se(e, new J(q.disposed)), C = void 0, N.stop(), l.dispose(), te?.(), ne?.();
|
|
3301
3311
|
}
|
|
3302
3312
|
};
|
|
3303
3313
|
}
|
|
3304
3314
|
// lib/store.ts
|
|
3305
3315
|
var Z = /* @__PURE__ */ function(e) {
|
|
3306
|
-
return e.SignIn = "signin", e.SignInStart = "signin:start", e.Register = "register", e.RegisterStart = "register:start", 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;
|
|
3307
|
-
}({}),
|
|
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;
|
|
3317
|
+
}({}), Yn = class {
|
|
3308
3318
|
constructor() {
|
|
3309
3319
|
this.subscribers = /* @__PURE__ */ new Map();
|
|
3310
3320
|
}
|
|
@@ -3323,12 +3333,12 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3323
3333
|
n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
|
|
3324
3334
|
}
|
|
3325
3335
|
notify(e, t) {
|
|
3326
|
-
e === "error" &&
|
|
3336
|
+
e === "error" && kt(this, t?.originalError), this.subscribers.forEach((n, r) => {
|
|
3327
3337
|
(!n || n.has(e)) && r.onAuthChange?.(e, t);
|
|
3328
3338
|
});
|
|
3329
3339
|
}
|
|
3330
3340
|
notifyError(e) {
|
|
3331
|
-
return
|
|
3341
|
+
return W(this, e);
|
|
3332
3342
|
}
|
|
3333
3343
|
}, Q = {
|
|
3334
3344
|
twoFactorCodeInvalid: "error.api.request.2fa_code.invalid",
|
|
@@ -3344,18 +3354,18 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3344
3354
|
twoFactorNotEnabled: "error.2fa.not_enabled",
|
|
3345
3355
|
notImplemented: "error.not.implemented",
|
|
3346
3356
|
tokenInvalid: "error.api.request.token.invalid"
|
|
3347
|
-
},
|
|
3357
|
+
}, Xn = Object.freeze([
|
|
3348
3358
|
Q.twoFactorCodeInvalid,
|
|
3349
3359
|
Q.twoFactorNotEnabled,
|
|
3350
3360
|
Q.challengeInvalid,
|
|
3351
3361
|
Q.challengeSessionMismatch,
|
|
3352
3362
|
Q.challengeTooManyAttempts
|
|
3353
|
-
]),
|
|
3363
|
+
]), Zn = Object.freeze([Q.tokenInvalid]), Qn = Object.freeze([
|
|
3354
3364
|
"wrong_code",
|
|
3355
3365
|
"challenge_spent",
|
|
3356
3366
|
"not_registered",
|
|
3357
3367
|
"prepare_not_required"
|
|
3358
|
-
]),
|
|
3368
|
+
]), $n = (e) => Qn.includes(e), er = {
|
|
3359
3369
|
wrong_code: "That code was not accepted. Try again.",
|
|
3360
3370
|
challenge_spent: "That verification challenge is no longer valid. Start again.",
|
|
3361
3371
|
exhausted: "Too many attempts. Try again later.",
|
|
@@ -3369,16 +3379,16 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3369
3379
|
session_changed: "The session ended during verification."
|
|
3370
3380
|
}, $ = class extends Error {
|
|
3371
3381
|
constructor(e) {
|
|
3372
|
-
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);
|
|
3373
3383
|
}
|
|
3374
|
-
},
|
|
3384
|
+
}, tr = Object.freeze([
|
|
3375
3385
|
"upgrade_transport",
|
|
3376
3386
|
"upgrade_insufficient",
|
|
3377
3387
|
"upgrade_unavailable",
|
|
3378
3388
|
"upgrade_session_changed",
|
|
3379
3389
|
"upgrade_cancelled",
|
|
3380
3390
|
"upgrade_unsatisfiable"
|
|
3381
|
-
]),
|
|
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) => {
|
|
3382
3392
|
if (typeof e != "object" || !e) return {
|
|
3383
3393
|
hasResponse: !1,
|
|
3384
3394
|
message: typeof e == "string" ? e : void 0
|
|
@@ -3390,7 +3400,7 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3390
3400
|
message: typeof t.message == "string" ? t.message : void 0,
|
|
3391
3401
|
hasResponse: n !== void 0 || typeof t.status == "number"
|
|
3392
3402
|
};
|
|
3393
|
-
},
|
|
3403
|
+
}, ar = (e, t) => {
|
|
3394
3404
|
switch (e) {
|
|
3395
3405
|
case Q.twoFactorCodeInvalid: return "wrong_code";
|
|
3396
3406
|
case Q.challengeInvalid:
|
|
@@ -3407,11 +3417,11 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3407
3417
|
case Q.tokenInvalid: return t === "refresh" ? "session_changed" : "fatal";
|
|
3408
3418
|
default: return;
|
|
3409
3419
|
}
|
|
3410
|
-
},
|
|
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) => {
|
|
3411
3421
|
if (e instanceof $) return e;
|
|
3412
|
-
let n =
|
|
3422
|
+
let n = ir(e);
|
|
3413
3423
|
return n.hasResponse ? new $({
|
|
3414
|
-
kind:
|
|
3424
|
+
kind: ar(n.errorId, t) ?? or(n.status, t),
|
|
3415
3425
|
message: n.message,
|
|
3416
3426
|
status: n.status,
|
|
3417
3427
|
errorId: n.errorId,
|
|
@@ -3421,62 +3431,74 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3421
3431
|
message: n.message,
|
|
3422
3432
|
cause: e
|
|
3423
3433
|
});
|
|
3424
|
-
},
|
|
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 {
|
|
3425
3435
|
constructor(e, t, n) {
|
|
3426
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;
|
|
3427
3437
|
}
|
|
3428
|
-
},
|
|
3438
|
+
}, dr = class extends Error {
|
|
3429
3439
|
constructor(e = "Step-up verification is not available on this deployment") {
|
|
3430
3440
|
super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
|
|
3431
3441
|
}
|
|
3432
|
-
},
|
|
3442
|
+
}, fr = class extends Error {
|
|
3433
3443
|
constructor(e = "The session changed during verification") {
|
|
3434
3444
|
super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
|
|
3435
3445
|
}
|
|
3436
|
-
},
|
|
3446
|
+
}, pr = (e) => {
|
|
3437
3447
|
if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
|
|
3438
3448
|
sub: e.sub,
|
|
3439
3449
|
sid: e.sid
|
|
3440
3450
|
} : { sub: e.sub };
|
|
3441
|
-
},
|
|
3451
|
+
}, mr = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
|
|
3442
3452
|
// lib/utils/validation.ts
|
|
3443
|
-
function
|
|
3453
|
+
function hr(e) {
|
|
3444
3454
|
if (!e || typeof e != "string") return !1;
|
|
3445
3455
|
let t = e.split(".");
|
|
3446
3456
|
if (t.length !== 3) return !1;
|
|
3447
3457
|
let n = /^[A-Za-z0-9_-]+$/;
|
|
3448
3458
|
return t.every((e) => n.test(e) && e.length > 0);
|
|
3449
3459
|
}
|
|
3450
|
-
function
|
|
3460
|
+
function gr(e) {
|
|
3451
3461
|
return e.replace(/<[^>]*>/g, "").substring(0, 200);
|
|
3452
3462
|
}
|
|
3453
|
-
function
|
|
3463
|
+
function _r(e) {
|
|
3454
3464
|
if (!e || typeof e != "string") return !1;
|
|
3455
3465
|
let t = e.trim();
|
|
3456
3466
|
return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
|
|
3457
3467
|
}
|
|
3458
|
-
function
|
|
3468
|
+
function vr(e) {
|
|
3459
3469
|
if (!e || typeof e != "string") return !1;
|
|
3460
3470
|
let t = e.trim();
|
|
3461
3471
|
return /^\+[1-9]\d{1,14}$/.test(t);
|
|
3462
3472
|
}
|
|
3463
|
-
function
|
|
3473
|
+
function yr(e) {
|
|
3464
3474
|
if (!e || typeof e != "string") return !1;
|
|
3465
3475
|
let t = e.trim();
|
|
3466
3476
|
return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
|
|
3467
3477
|
}
|
|
3468
|
-
function
|
|
3478
|
+
function br(e, t = 6) {
|
|
3469
3479
|
return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
|
|
3470
3480
|
}
|
|
3471
|
-
function
|
|
3481
|
+
function xr(e) {
|
|
3472
3482
|
if (!e || typeof e != "string") return null;
|
|
3473
3483
|
let t = e.toUpperCase().replace(/\s+/g, "");
|
|
3474
3484
|
return /^[A-Z0-9-]{4,16}$/.test(t) ? t : null;
|
|
3475
3485
|
}
|
|
3476
3486
|
// lib/services/auth-service.ts
|
|
3477
|
-
var
|
|
3478
|
-
|
|
3479
|
-
|
|
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) => {
|
|
3488
|
+
if (!e) return;
|
|
3489
|
+
let t = new URLSearchParams(e.search).get("token");
|
|
3490
|
+
if (t) return t;
|
|
3491
|
+
let n = e.hash.indexOf("?");
|
|
3492
|
+
return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
|
|
3493
|
+
}, Dr = (e) => {
|
|
3494
|
+
if (e) try {
|
|
3495
|
+
return A(e).email;
|
|
3496
|
+
} catch {
|
|
3497
|
+
return;
|
|
3498
|
+
}
|
|
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({
|
|
3480
3502
|
emit: this.createRefreshEmit(),
|
|
3481
3503
|
storage: n,
|
|
3482
3504
|
cache: i,
|
|
@@ -3484,7 +3506,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3484
3506
|
coordination: p.coordination,
|
|
3485
3507
|
platform: d,
|
|
3486
3508
|
...p.strikes === void 0 ? {} : { strikes: p.strikes },
|
|
3487
|
-
logger:
|
|
3509
|
+
logger: gn()
|
|
3488
3510
|
}), this.initializeSession();
|
|
3489
3511
|
}
|
|
3490
3512
|
async initializeSession() {
|
|
@@ -3522,18 +3544,39 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3522
3544
|
tfaToken: e.tfa_token || ""
|
|
3523
3545
|
}), !0);
|
|
3524
3546
|
}
|
|
3547
|
+
handleEmailVerificationStep(e, t, n, r, i) {
|
|
3548
|
+
if (!Ae(e)) return !1;
|
|
3549
|
+
let a = e.challenge_id || void 0;
|
|
3550
|
+
return a && r ? this.rememberPkceSignIn(r.verifier, i) : this.forgetPkceSignIn(), a && this.rememberEmailChallenge(a, {
|
|
3551
|
+
operation: t,
|
|
3552
|
+
email: n,
|
|
3553
|
+
scopes: i,
|
|
3554
|
+
pkce: r !== void 0
|
|
3555
|
+
}), this.subscribeStore.notify(Z.EmailVerificationRequired, {
|
|
3556
|
+
email: n,
|
|
3557
|
+
challengeId: a,
|
|
3558
|
+
operation: t
|
|
3559
|
+
}), !0;
|
|
3560
|
+
}
|
|
3561
|
+
rememberEmailChallenge(e, t) {
|
|
3562
|
+
this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
|
|
3563
|
+
for (let e of this.emailChallenges.keys()) {
|
|
3564
|
+
if (this.emailChallenges.size <= wr) break;
|
|
3565
|
+
this.emailChallenges.delete(e);
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3525
3568
|
rememberPkceSignIn(e, t) {
|
|
3526
3569
|
if (this.pendingPkce = {
|
|
3527
3570
|
verifier: e,
|
|
3528
3571
|
scopes: t,
|
|
3529
|
-
expiresAt: Date.now() +
|
|
3572
|
+
expiresAt: Date.now() + Cr
|
|
3530
3573
|
}, typeof sessionStorage < "u") try {
|
|
3531
|
-
sessionStorage.setItem(
|
|
3574
|
+
sessionStorage.setItem(Sr, JSON.stringify(this.pendingPkce));
|
|
3532
3575
|
} catch {}
|
|
3533
3576
|
}
|
|
3534
3577
|
readPendingPkce() {
|
|
3535
3578
|
if (!this.pendingPkce && typeof sessionStorage < "u") try {
|
|
3536
|
-
let e = sessionStorage.getItem(
|
|
3579
|
+
let e = sessionStorage.getItem(Sr);
|
|
3537
3580
|
this.pendingPkce = e ? JSON.parse(e) : void 0;
|
|
3538
3581
|
} catch {
|
|
3539
3582
|
this.pendingPkce = void 0;
|
|
@@ -3545,7 +3588,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3545
3588
|
}
|
|
3546
3589
|
forgetPkceSignIn() {
|
|
3547
3590
|
if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
|
|
3548
|
-
sessionStorage.removeItem(
|
|
3591
|
+
sessionStorage.removeItem(Sr);
|
|
3549
3592
|
} catch {}
|
|
3550
3593
|
}
|
|
3551
3594
|
async startPkce() {
|
|
@@ -3553,17 +3596,17 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3553
3596
|
try {
|
|
3554
3597
|
e = await this.readPkceEnabled?.() ?? !1;
|
|
3555
3598
|
} catch (e) {
|
|
3556
|
-
|
|
3599
|
+
gn().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
|
|
3557
3600
|
return;
|
|
3558
3601
|
}
|
|
3559
|
-
return e ?
|
|
3602
|
+
return e ? mn() : void 0;
|
|
3560
3603
|
}
|
|
3561
3604
|
async exchangeCode(e, t) {
|
|
3562
3605
|
return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
|
|
3563
3606
|
}
|
|
3564
3607
|
async completePkceSignIn(e) {
|
|
3565
3608
|
let t = this.readPendingPkce();
|
|
3566
|
-
if (!t) throw Error(
|
|
3609
|
+
if (!t) throw Error(Tr);
|
|
3567
3610
|
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
3568
3611
|
return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
|
|
3569
3612
|
}
|
|
@@ -3587,42 +3630,42 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3587
3630
|
if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
|
|
3588
3631
|
}
|
|
3589
3632
|
async signIn(e) {
|
|
3590
|
-
if ("email" in e && e.email && !
|
|
3633
|
+
if ("email" in e && e.email && !_r(e.email)) {
|
|
3591
3634
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3592
3635
|
operation: "sign-in",
|
|
3593
3636
|
message: "Invalid email format",
|
|
3594
3637
|
originalError: e,
|
|
3595
3638
|
code: "VALIDATION_ERROR"
|
|
3596
3639
|
};
|
|
3597
|
-
throw
|
|
3640
|
+
throw W(this.subscribeStore, t), e;
|
|
3598
3641
|
}
|
|
3599
|
-
if ("username" in e && e.username && !
|
|
3642
|
+
if ("username" in e && e.username && !yr(e.username)) {
|
|
3600
3643
|
let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
|
|
3601
3644
|
operation: "sign-in",
|
|
3602
3645
|
message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
|
|
3603
3646
|
originalError: e,
|
|
3604
3647
|
code: "VALIDATION_ERROR"
|
|
3605
3648
|
};
|
|
3606
|
-
throw
|
|
3649
|
+
throw W(this.subscribeStore, t), e;
|
|
3607
3650
|
}
|
|
3608
|
-
if ("phone" in e && e.phone && !
|
|
3651
|
+
if ("phone" in e && e.phone && !vr(e.phone)) {
|
|
3609
3652
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3610
3653
|
operation: "sign-in",
|
|
3611
3654
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3612
3655
|
originalError: e,
|
|
3613
3656
|
code: "VALIDATION_ERROR"
|
|
3614
3657
|
};
|
|
3615
|
-
throw
|
|
3658
|
+
throw W(this.subscribeStore, t), e;
|
|
3616
3659
|
}
|
|
3617
3660
|
this.subscribeStore.notify(Z.SignInStart, { email: e.email });
|
|
3618
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
3661
|
+
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
3619
3662
|
e.scopes = e.scopes ?? this.scopes;
|
|
3620
3663
|
try {
|
|
3621
3664
|
let r = await this.startPkce(), i = await this.authApi.signIn(r ? {
|
|
3622
3665
|
...e,
|
|
3623
3666
|
code_challenge: r.challenge
|
|
3624
3667
|
} : e, t, n);
|
|
3625
|
-
if (this.handlePendingSecondFactor(i, e.email, r, e.scopes)) return i;
|
|
3668
|
+
if (this.handleEmailVerificationStep(i, "sign-in", e.email, r, e.scopes) || this.handlePendingSecondFactor(i, e.email, r, e.scopes)) return i;
|
|
3626
3669
|
let a = await this.exchangeCode(i, r);
|
|
3627
3670
|
return this.handlePendingSecondFactor(a, e.email) || (await this.processAuthResponse(a, e.scopes), this.subscribeStore.notify(Z.SignIn, {
|
|
3628
3671
|
tokens: a,
|
|
@@ -3635,27 +3678,27 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3635
3678
|
originalError: e,
|
|
3636
3679
|
code: e instanceof B ? e.id : void 0
|
|
3637
3680
|
};
|
|
3638
|
-
throw
|
|
3681
|
+
throw W(this.subscribeStore, t), e;
|
|
3639
3682
|
}
|
|
3640
3683
|
}
|
|
3641
3684
|
async signUp(e) {
|
|
3642
|
-
if (e.user.email && !
|
|
3685
|
+
if (e.user.email && !_r(e.user.email)) {
|
|
3643
3686
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3644
3687
|
operation: "sign-up",
|
|
3645
3688
|
message: "Invalid email format",
|
|
3646
3689
|
originalError: e,
|
|
3647
3690
|
code: "VALIDATION_ERROR"
|
|
3648
3691
|
};
|
|
3649
|
-
throw
|
|
3692
|
+
throw W(this.subscribeStore, t), e;
|
|
3650
3693
|
}
|
|
3651
|
-
if (e.user.phone_number && !
|
|
3694
|
+
if (e.user.phone_number && !vr(e.user.phone_number)) {
|
|
3652
3695
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3653
3696
|
operation: "sign-up",
|
|
3654
3697
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3655
3698
|
originalError: e,
|
|
3656
3699
|
code: "VALIDATION_ERROR"
|
|
3657
3700
|
};
|
|
3658
|
-
throw
|
|
3701
|
+
throw W(this.subscribeStore, t), e;
|
|
3659
3702
|
}
|
|
3660
3703
|
this.subscribeStore.notify(Z.RegisterStart, { email: e.user.email }), e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
3661
3704
|
try {
|
|
@@ -3663,7 +3706,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3663
3706
|
...e,
|
|
3664
3707
|
code_challenge: t.challenge
|
|
3665
3708
|
} : e);
|
|
3666
|
-
if (this.handlePendingSecondFactor(n, e.user.email, t, e.scopes)) return n;
|
|
3709
|
+
if (this.handleEmailVerificationStep(n, "sign-up", e.user.email, t, e.scopes) || this.handlePendingSecondFactor(n, e.user.email, t, e.scopes)) return n;
|
|
3667
3710
|
let r = await this.exchangeCode(n, t);
|
|
3668
3711
|
return this.handlePendingSecondFactor(r, e.user.email) || (await this.processAuthResponse(r, e.scopes), this.subscribeStore.notify(Z.Register, {
|
|
3669
3712
|
tokens: r,
|
|
@@ -3676,30 +3719,30 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3676
3719
|
originalError: e,
|
|
3677
3720
|
code: e instanceof B ? e.id : void 0
|
|
3678
3721
|
};
|
|
3679
|
-
throw
|
|
3722
|
+
throw W(this.subscribeStore, t), e;
|
|
3680
3723
|
}
|
|
3681
3724
|
}
|
|
3682
3725
|
async passwordlessSignIn(e) {
|
|
3683
|
-
if (e.email && !
|
|
3726
|
+
if (e.email && !_r(e.email)) {
|
|
3684
3727
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3685
3728
|
operation: "passwordless.start",
|
|
3686
3729
|
message: "Invalid email format",
|
|
3687
3730
|
originalError: e,
|
|
3688
3731
|
code: "VALIDATION_ERROR"
|
|
3689
3732
|
};
|
|
3690
|
-
throw
|
|
3733
|
+
throw W(this.subscribeStore, t), e;
|
|
3691
3734
|
}
|
|
3692
|
-
if (e.phone && !
|
|
3735
|
+
if (e.phone && !vr(e.phone)) {
|
|
3693
3736
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3694
3737
|
operation: "passwordless.start",
|
|
3695
3738
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3696
3739
|
originalError: e,
|
|
3697
3740
|
code: "VALIDATION_ERROR"
|
|
3698
3741
|
};
|
|
3699
|
-
throw
|
|
3742
|
+
throw W(this.subscribeStore, t), e;
|
|
3700
3743
|
}
|
|
3701
3744
|
this.subscribeStore.notify(Z.SignInStart, { email: e.email }), e.scopes = e.scopes ?? this.scopes;
|
|
3702
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
3745
|
+
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
3703
3746
|
try {
|
|
3704
3747
|
return await this.authApi.passwordlessSignIn(e, t, n);
|
|
3705
3748
|
} catch (e) {
|
|
@@ -3709,7 +3752,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3709
3752
|
originalError: e,
|
|
3710
3753
|
code: e instanceof B ? e.id : void 0
|
|
3711
3754
|
};
|
|
3712
|
-
throw
|
|
3755
|
+
throw W(this.subscribeStore, t), e;
|
|
3713
3756
|
}
|
|
3714
3757
|
}
|
|
3715
3758
|
async passwordlessSignInComplete(e) {
|
|
@@ -3727,18 +3770,52 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3727
3770
|
originalError: e,
|
|
3728
3771
|
code: e instanceof B ? e.id : void 0
|
|
3729
3772
|
};
|
|
3730
|
-
throw
|
|
3773
|
+
throw W(this.subscribeStore, t), e;
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
async verifyEmailCode(e) {
|
|
3777
|
+
let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
|
|
3778
|
+
try {
|
|
3779
|
+
let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
|
|
3780
|
+
if (t?.pkce && !r) throw Error(Tr);
|
|
3781
|
+
let i = await this.authApi.validateEmailCode(e);
|
|
3782
|
+
this.emailChallenges.delete(e.challenge_id);
|
|
3783
|
+
let a = r?.scopes ?? t?.scopes ?? this.scopes;
|
|
3784
|
+
if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
|
|
3785
|
+
let o = i;
|
|
3786
|
+
if (i.code) {
|
|
3787
|
+
if (!r) throw Error(Tr);
|
|
3788
|
+
if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
|
|
3789
|
+
}
|
|
3790
|
+
let s = i.redirect_url ? {
|
|
3791
|
+
...o,
|
|
3792
|
+
redirect_url: i.redirect_url
|
|
3793
|
+
} : o;
|
|
3794
|
+
return await this.processAuthResponse(s, a), this.forgetPkceSignIn(), this.subscribeStore.notify(t?.operation === "sign-up" ? Z.Register : Z.SignIn, {
|
|
3795
|
+
tokens: s,
|
|
3796
|
+
parsedTokens: this.tokenCacheService.getParsedTokens()
|
|
3797
|
+
}), await this.submitSessionCheck(), s;
|
|
3798
|
+
} catch (e) {
|
|
3799
|
+
let t = {
|
|
3800
|
+
operation: "email-verification.complete",
|
|
3801
|
+
message: e instanceof Error ? e.message : "Email verification failed",
|
|
3802
|
+
originalError: e,
|
|
3803
|
+
code: e instanceof B ? e.id : void 0
|
|
3804
|
+
};
|
|
3805
|
+
throw W(this.subscribeStore, t), e;
|
|
3731
3806
|
}
|
|
3732
3807
|
}
|
|
3733
3808
|
async logOut() {
|
|
3734
3809
|
let e = this.refresh.identity();
|
|
3735
3810
|
return await this.refresh.signOut(async (e) => {
|
|
3736
|
-
await this.callLogoutApi(e), this.forgetPkceSignIn(), this.clearLocalSession();
|
|
3811
|
+
await this.callLogoutApi(e), this.forgetPkceSignIn(), this.emailChallenges.clear(), this.clearLocalSession();
|
|
3737
3812
|
}), e;
|
|
3738
3813
|
}
|
|
3739
3814
|
resetSession() {
|
|
3740
3815
|
let e = this.refresh.identity();
|
|
3741
|
-
return this.refresh.signOutNow(() =>
|
|
3816
|
+
return this.refresh.signOutNow(() => {
|
|
3817
|
+
this.emailChallenges.clear(), this.clearLocalSession();
|
|
3818
|
+
}), e;
|
|
3742
3819
|
}
|
|
3743
3820
|
async callLogoutApi(e) {
|
|
3744
3821
|
if (this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.logoutUrl) {
|
|
@@ -3761,13 +3838,13 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3761
3838
|
readSessionPin() {
|
|
3762
3839
|
try {
|
|
3763
3840
|
let e = this.storageManager.getToken(j.access_token);
|
|
3764
|
-
return e ?
|
|
3841
|
+
return e ? pr(A(e)) : void 0;
|
|
3765
3842
|
} catch {
|
|
3766
3843
|
return;
|
|
3767
3844
|
}
|
|
3768
3845
|
}
|
|
3769
3846
|
assertSessionPin(e) {
|
|
3770
|
-
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");
|
|
3771
3848
|
}
|
|
3772
3849
|
refreshMode() {
|
|
3773
3850
|
return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
|
|
@@ -3795,7 +3872,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3795
3872
|
return;
|
|
3796
3873
|
}
|
|
3797
3874
|
case "error":
|
|
3798
|
-
|
|
3875
|
+
W(n, t);
|
|
3799
3876
|
return;
|
|
3800
3877
|
case "refresh:start":
|
|
3801
3878
|
n.notify(Z.RefreshStart, {});
|
|
@@ -3815,7 +3892,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3815
3892
|
case "signout":
|
|
3816
3893
|
n.notify(Z.SignOut, t);
|
|
3817
3894
|
return;
|
|
3818
|
-
default:
|
|
3895
|
+
default: gn().warn(`[passflow] Unknown refresh event: ${String(e)}`);
|
|
3819
3896
|
}
|
|
3820
3897
|
};
|
|
3821
3898
|
}
|
|
@@ -3873,7 +3950,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3873
3950
|
let e = this.storageManager.getTokens();
|
|
3874
3951
|
if (!e?.refresh_token) {
|
|
3875
3952
|
let t = /* @__PURE__ */ Error(e ? "No refresh token found" : "No tokens found");
|
|
3876
|
-
throw
|
|
3953
|
+
throw W(this.subscribeStore, {
|
|
3877
3954
|
operation: "refresh",
|
|
3878
3955
|
source: "refresh-token",
|
|
3879
3956
|
message: t.message,
|
|
@@ -3896,22 +3973,22 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3896
3973
|
originalError: e,
|
|
3897
3974
|
code: e instanceof B ? e.id : void 0
|
|
3898
3975
|
};
|
|
3899
|
-
throw
|
|
3976
|
+
throw W(this.subscribeStore, t), e;
|
|
3900
3977
|
}
|
|
3901
3978
|
}
|
|
3902
|
-
async resetPassword(e, t) {
|
|
3979
|
+
async resetPassword(e, t, n) {
|
|
3903
3980
|
this.subscribeStore.notify(Z.SignInStart, {});
|
|
3904
|
-
let
|
|
3981
|
+
let r = n ?? Er(this.platform.getCurrentUrl()), i = t ?? this.scopes;
|
|
3905
3982
|
try {
|
|
3906
|
-
let t = await this.startPkce(),
|
|
3907
|
-
if (this.handlePendingSecondFactor(
|
|
3908
|
-
let a = await this.exchangeCode(
|
|
3983
|
+
let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
|
|
3984
|
+
if (this.handleEmailVerificationStep(n, "reset-password", Dr(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
|
|
3985
|
+
let a = await this.exchangeCode(n, t);
|
|
3909
3986
|
if (this.handlePendingSecondFactor(a)) return a;
|
|
3910
|
-
let o =
|
|
3987
|
+
let o = n.redirect_url ? {
|
|
3911
3988
|
...a,
|
|
3912
|
-
redirect_url:
|
|
3989
|
+
redirect_url: n.redirect_url
|
|
3913
3990
|
} : a;
|
|
3914
|
-
return await this.processAuthResponse(o,
|
|
3991
|
+
return await this.processAuthResponse(o, i), this.subscribeStore.notify(Z.SignIn, {
|
|
3915
3992
|
tokens: o,
|
|
3916
3993
|
parsedTokens: this.tokenCacheService.getParsedTokens()
|
|
3917
3994
|
}), await this.submitSessionCheck(), o;
|
|
@@ -3922,13 +3999,13 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3922
3999
|
originalError: e,
|
|
3923
4000
|
code: e instanceof B ? e.id : void 0
|
|
3924
4001
|
};
|
|
3925
|
-
throw
|
|
4002
|
+
throw W(this.subscribeStore, t), e;
|
|
3926
4003
|
}
|
|
3927
4004
|
}
|
|
3928
4005
|
async passkeyRegister(e) {
|
|
3929
4006
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
3930
4007
|
this.subscribeStore.notify(Z.RegisterStart, {});
|
|
3931
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
4008
|
+
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
3932
4009
|
e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
3933
4010
|
try {
|
|
3934
4011
|
let r = await this.startPkce(), { challenge_id: i, publicKey: a } = await this.authApi.passkeyRegisterStart(r ? {
|
|
@@ -3952,13 +4029,13 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3952
4029
|
originalError: e,
|
|
3953
4030
|
code: e instanceof B ? e.id : void 0
|
|
3954
4031
|
};
|
|
3955
|
-
throw
|
|
4032
|
+
throw W(this.subscribeStore, t), e;
|
|
3956
4033
|
}
|
|
3957
4034
|
}
|
|
3958
4035
|
async passkeyAuthenticate(e) {
|
|
3959
4036
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
3960
4037
|
this.subscribeStore.notify(Z.SignInStart, {});
|
|
3961
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
4038
|
+
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
3962
4039
|
e.scopes = e.scopes ?? this.scopes;
|
|
3963
4040
|
try {
|
|
3964
4041
|
let r = await this.startPkce(), { challenge_id: i, publicKey: a } = await this.authApi.passkeyAuthenticateStart(r ? {
|
|
@@ -3980,7 +4057,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
3980
4057
|
originalError: e,
|
|
3981
4058
|
code: e instanceof B ? e.id : void 0
|
|
3982
4059
|
};
|
|
3983
|
-
throw
|
|
4060
|
+
throw W(this.subscribeStore, t), e;
|
|
3984
4061
|
}
|
|
3985
4062
|
}
|
|
3986
4063
|
createFederatedAuthUrl(e) {
|
|
@@ -4026,7 +4103,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4026
4103
|
code: e instanceof ie ? "POPUP_CLOSED" : "AUTH_FAILED",
|
|
4027
4104
|
originalError: e
|
|
4028
4105
|
};
|
|
4029
|
-
|
|
4106
|
+
W(this.subscribeStore, t);
|
|
4030
4107
|
}
|
|
4031
4108
|
}
|
|
4032
4109
|
federatedAuthWithRedirect(e) {
|
|
@@ -4054,7 +4131,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4054
4131
|
message: e instanceof Error ? e.message : "Failed to create auth redirect URL",
|
|
4055
4132
|
originalError: e
|
|
4056
4133
|
};
|
|
4057
|
-
throw
|
|
4134
|
+
throw W(this.subscribeStore, t), e;
|
|
4058
4135
|
}
|
|
4059
4136
|
}
|
|
4060
4137
|
authRedirect(e = {}) {
|
|
@@ -4066,7 +4143,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4066
4143
|
message: e instanceof Error ? e.message : "Failed to redirect to auth page",
|
|
4067
4144
|
originalError: e
|
|
4068
4145
|
};
|
|
4069
|
-
throw
|
|
4146
|
+
throw W(this.subscribeStore, t), e;
|
|
4070
4147
|
}
|
|
4071
4148
|
}
|
|
4072
4149
|
isAuthenticated(e) {
|
|
@@ -4082,7 +4159,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4082
4159
|
message: e instanceof Error ? e.message : "Failed to check authentication status",
|
|
4083
4160
|
originalError: e
|
|
4084
4161
|
};
|
|
4085
|
-
return
|
|
4162
|
+
return W(this.subscribeStore, t), !1;
|
|
4086
4163
|
}
|
|
4087
4164
|
}
|
|
4088
4165
|
async submitSessionCheck(e = !1) {
|
|
@@ -4095,7 +4172,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4095
4172
|
message: e instanceof Error || e instanceof B ? e.message : "Session check failed",
|
|
4096
4173
|
originalError: e
|
|
4097
4174
|
};
|
|
4098
|
-
|
|
4175
|
+
W(this.subscribeStore, n), t = void 0;
|
|
4099
4176
|
}
|
|
4100
4177
|
return t && this.sessionCallbacks.createSession && await this.sessionCallbacks.createSession({
|
|
4101
4178
|
tokens: t,
|
|
@@ -4122,11 +4199,11 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4122
4199
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4123
4200
|
originalError: e
|
|
4124
4201
|
};
|
|
4125
|
-
|
|
4202
|
+
W(this.subscribeStore, t);
|
|
4126
4203
|
return;
|
|
4127
4204
|
}
|
|
4128
4205
|
}
|
|
4129
|
-
},
|
|
4206
|
+
}, kr = class {
|
|
4130
4207
|
constructor(e) {
|
|
4131
4208
|
this.invitationApi = e;
|
|
4132
4209
|
}
|
|
@@ -4145,7 +4222,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4145
4222
|
getInvitationLink(e) {
|
|
4146
4223
|
return this.invitationApi.getInvitationLink(e);
|
|
4147
4224
|
}
|
|
4148
|
-
},
|
|
4225
|
+
}, Ar = class {
|
|
4149
4226
|
constructor(e) {
|
|
4150
4227
|
this.data = this.normalize(e);
|
|
4151
4228
|
}
|
|
@@ -4202,9 +4279,9 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4202
4279
|
getData() {
|
|
4203
4280
|
return this.data;
|
|
4204
4281
|
}
|
|
4205
|
-
},
|
|
4282
|
+
}, jr = class {
|
|
4206
4283
|
constructor(e, t, n) {
|
|
4207
|
-
this.tenantApi = e, this.scopes = t, this.logger = n ||
|
|
4284
|
+
this.tenantApi = e, this.scopes = t, this.logger = n || gn();
|
|
4208
4285
|
}
|
|
4209
4286
|
handlePassflowError(t, n) {
|
|
4210
4287
|
if (e.isAxiosError(t) && t.response?.data) {
|
|
@@ -4240,7 +4317,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4240
4317
|
}
|
|
4241
4318
|
async getTenantUserMembership(e) {
|
|
4242
4319
|
try {
|
|
4243
|
-
return new
|
|
4320
|
+
return new Ar(await this.tenantApi.getTenantDetails(e));
|
|
4244
4321
|
} catch (t) {
|
|
4245
4322
|
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
4246
4323
|
}
|
|
@@ -4385,7 +4462,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4385
4462
|
this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
|
|
4386
4463
|
}
|
|
4387
4464
|
}
|
|
4388
|
-
},
|
|
4465
|
+
}, Mr = class {
|
|
4389
4466
|
constructor(e, t, n, r = P) {
|
|
4390
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();
|
|
4391
4468
|
}
|
|
@@ -4410,7 +4487,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4410
4487
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4411
4488
|
originalError: e
|
|
4412
4489
|
};
|
|
4413
|
-
|
|
4490
|
+
W(this.subscribeStore, t), this.setTokensCache(void 0);
|
|
4414
4491
|
}
|
|
4415
4492
|
}
|
|
4416
4493
|
startTokenCheck() {
|
|
@@ -4455,7 +4532,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4455
4532
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4456
4533
|
originalError: e
|
|
4457
4534
|
};
|
|
4458
|
-
|
|
4535
|
+
W(this.subscribeStore, t);
|
|
4459
4536
|
return;
|
|
4460
4537
|
}
|
|
4461
4538
|
}
|
|
@@ -4465,7 +4542,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4465
4542
|
isExpired() {
|
|
4466
4543
|
return this.tokensCache ? this.tokensCache.access_token ? k(A(this.tokensCache.access_token)) : !1 : !0;
|
|
4467
4544
|
}
|
|
4468
|
-
},
|
|
4545
|
+
}, Nr = class {
|
|
4469
4546
|
constructor(e, t, n) {
|
|
4470
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) => {
|
|
4471
4548
|
if (e === Z.TwoFactorRequired) {
|
|
@@ -4486,7 +4563,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4486
4563
|
originalError: e,
|
|
4487
4564
|
code: r?.id || void 0
|
|
4488
4565
|
};
|
|
4489
|
-
throw
|
|
4566
|
+
throw W(this.subscribeStore, i), e;
|
|
4490
4567
|
}
|
|
4491
4568
|
async getStatus() {
|
|
4492
4569
|
try {
|
|
@@ -4505,7 +4582,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4505
4582
|
}
|
|
4506
4583
|
}
|
|
4507
4584
|
async confirmSetup(e) {
|
|
4508
|
-
if (!
|
|
4585
|
+
if (!br(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4509
4586
|
try {
|
|
4510
4587
|
let t = await this.twoFactorApi.confirmSetup({ code: e });
|
|
4511
4588
|
return this.subscribeStore.notify(Z.TwoFactorEnabled, {
|
|
@@ -4519,7 +4596,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4519
4596
|
}
|
|
4520
4597
|
}
|
|
4521
4598
|
async verify(e, t) {
|
|
4522
|
-
if (!
|
|
4599
|
+
if (!br(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4523
4600
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4524
4601
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
4525
4602
|
try {
|
|
@@ -4535,7 +4612,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4535
4612
|
}
|
|
4536
4613
|
async useRecoveryCode(e, t) {
|
|
4537
4614
|
try {
|
|
4538
|
-
let n =
|
|
4615
|
+
let n = xr(e);
|
|
4539
4616
|
if (!n) throw Error("Invalid recovery code format. Expected format: XXXX-XXXX or XXXXXXXX (alphanumeric).");
|
|
4540
4617
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4541
4618
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
@@ -4556,7 +4633,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4556
4633
|
}
|
|
4557
4634
|
}
|
|
4558
4635
|
async disable(e) {
|
|
4559
|
-
if (!
|
|
4636
|
+
if (!br(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4560
4637
|
try {
|
|
4561
4638
|
let t = await this.twoFactorApi.disable({ code: e });
|
|
4562
4639
|
return this.subscribeStore.notify(Z.TwoFactorDisabled, {}), t;
|
|
@@ -4565,7 +4642,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4565
4642
|
}
|
|
4566
4643
|
}
|
|
4567
4644
|
async regenerateRecoveryCodes(e) {
|
|
4568
|
-
if (!
|
|
4645
|
+
if (!br(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4569
4646
|
try {
|
|
4570
4647
|
let t = await this.twoFactorApi.regenerateRecoveryCodes({ code: e }), n = [...t.recovery_codes];
|
|
4571
4648
|
return t.recovery_codes = [], t.recovery_codes = n, t;
|
|
@@ -4749,7 +4826,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4749
4826
|
this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
|
|
4750
4827
|
}
|
|
4751
4828
|
}
|
|
4752
|
-
},
|
|
4829
|
+
}, Pr = class {
|
|
4753
4830
|
constructor(e, t, n = P) {
|
|
4754
4831
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
4755
4832
|
}
|
|
@@ -4764,7 +4841,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4764
4841
|
}
|
|
4765
4842
|
async addUserPasskey({ relyingPartyId: e, passkeyUsername: t, passkeyDisplayName: n } = {}) {
|
|
4766
4843
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4767
|
-
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({
|
|
4768
4845
|
relyingPartyId: (e || this.platform.getCurrentUrl()?.hostname) ?? "",
|
|
4769
4846
|
deviceId: r,
|
|
4770
4847
|
os: i,
|
|
@@ -4776,69 +4853,69 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4776
4853
|
if (!s) throw Error("Passkey registration was not completed");
|
|
4777
4854
|
return await this.userAPI.addUserPasskeyComplete(s, r, a);
|
|
4778
4855
|
}
|
|
4779
|
-
},
|
|
4856
|
+
}, Fr = class extends Error {
|
|
4780
4857
|
constructor(e, t, n = !1) {
|
|
4781
4858
|
super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
|
|
4782
4859
|
}
|
|
4783
|
-
},
|
|
4860
|
+
}, Ir = (e, t) => {
|
|
4784
4861
|
let n = t?.trim();
|
|
4785
|
-
if (!n) throw new
|
|
4862
|
+
if (!n) throw new Fr(e, "A verification code is required");
|
|
4786
4863
|
return n;
|
|
4787
|
-
},
|
|
4864
|
+
}, Lr = {
|
|
4788
4865
|
type: "totp",
|
|
4789
4866
|
requiresPrepare: !1,
|
|
4790
4867
|
input: "code",
|
|
4791
|
-
assert: async ({ code: e }) => ({ code:
|
|
4792
|
-
},
|
|
4868
|
+
assert: async ({ code: e }) => ({ code: Ir("totp", e) })
|
|
4869
|
+
}, Rr = {
|
|
4793
4870
|
type: "recovery_codes",
|
|
4794
4871
|
requiresPrepare: !1,
|
|
4795
4872
|
input: "code",
|
|
4796
|
-
assert: async ({ code: e }) => ({ code:
|
|
4797
|
-
},
|
|
4873
|
+
assert: async ({ code: e }) => ({ code: Ir("recovery_codes", e) })
|
|
4874
|
+
}, zr = {
|
|
4798
4875
|
type: "passkey",
|
|
4799
4876
|
requiresPrepare: !0,
|
|
4800
4877
|
input: "none",
|
|
4801
4878
|
assert: async ({ prepared: e, platform: t }) => {
|
|
4802
|
-
if (!e?.webauthn) throw new
|
|
4879
|
+
if (!e?.webauthn) throw new Fr("passkey", "The upgrade challenge carried no WebAuthn options");
|
|
4803
4880
|
let n = t.passkeys;
|
|
4804
|
-
if (!n) throw new
|
|
4881
|
+
if (!n) throw new Fr("passkey", "This platform does not support passkeys");
|
|
4805
4882
|
let r;
|
|
4806
4883
|
try {
|
|
4807
4884
|
r = await n.startAuthentication(e.webauthn);
|
|
4808
4885
|
} catch (e) {
|
|
4809
|
-
throw new
|
|
4886
|
+
throw new Fr("passkey", e?.message || "Passkey verification was cancelled", !0);
|
|
4810
4887
|
}
|
|
4811
|
-
if (!r) throw new
|
|
4888
|
+
if (!r) throw new Fr("passkey", "Passkey verification was cancelled", !0);
|
|
4812
4889
|
return {
|
|
4813
4890
|
challenge_id: e.challengeId,
|
|
4814
4891
|
credential: r
|
|
4815
4892
|
};
|
|
4816
4893
|
}
|
|
4817
|
-
},
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
]),
|
|
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 = {
|
|
4822
4899
|
passkey: 0,
|
|
4823
4900
|
totp: 1,
|
|
4824
4901
|
email_otp: 2,
|
|
4825
4902
|
sms_otp: 3,
|
|
4826
4903
|
recovery_codes: 9
|
|
4827
|
-
},
|
|
4828
|
-
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";
|
|
4829
4906
|
return (r && !i ? 100 : 0) + n;
|
|
4830
|
-
},
|
|
4831
|
-
let n =
|
|
4832
|
-
return [...e].sort((e, t) =>
|
|
4833
|
-
},
|
|
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 {
|
|
4834
4911
|
constructor(e) {
|
|
4835
4912
|
super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
|
|
4836
4913
|
}
|
|
4837
|
-
},
|
|
4914
|
+
}, Jr = class extends Error {
|
|
4838
4915
|
constructor(e = "No available authentication factor can satisfy this challenge") {
|
|
4839
4916
|
super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
|
|
4840
4917
|
}
|
|
4841
|
-
},
|
|
4918
|
+
}, Yr = 4, Xr = 3e4, Zr = () => {
|
|
4842
4919
|
let e = () => void 0, t = () => void 0;
|
|
4843
4920
|
return {
|
|
4844
4921
|
promise: new Promise((n, r) => {
|
|
@@ -4847,11 +4924,11 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4847
4924
|
resolve: e,
|
|
4848
4925
|
reject: t
|
|
4849
4926
|
};
|
|
4850
|
-
},
|
|
4927
|
+
}, Qr = (e) => ({
|
|
4851
4928
|
acrValues: e.acrValues,
|
|
4852
4929
|
level: e.requiredLevel,
|
|
4853
4930
|
maxAge: e.maxAge
|
|
4854
|
-
}),
|
|
4931
|
+
}), $r = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, ei = (e, t) => {
|
|
4855
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 ?? []]));
|
|
4856
4933
|
return {
|
|
4857
4934
|
acrValues: r,
|
|
@@ -4860,12 +4937,12 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4860
4937
|
status: e.status,
|
|
4861
4938
|
...a.length > 0 ? { channels: a } : {}
|
|
4862
4939
|
};
|
|
4863
|
-
},
|
|
4940
|
+
}, ti = (e, t) => {
|
|
4864
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);
|
|
4865
4942
|
return n || r;
|
|
4866
|
-
},
|
|
4943
|
+
}, ni = class {
|
|
4867
4944
|
constructor(e) {
|
|
4868
|
-
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;
|
|
4869
4946
|
}
|
|
4870
4947
|
get currentState() {
|
|
4871
4948
|
return this.state;
|
|
@@ -4885,9 +4962,9 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4885
4962
|
}
|
|
4886
4963
|
register(e, t) {
|
|
4887
4964
|
let n = t.kind === "imperative" && t.requested !== void 0, r = {
|
|
4888
|
-
demanded: t.kind === "imperative" && t.requested ? t.requested :
|
|
4965
|
+
demanded: t.kind === "imperative" && t.requested ? t.requested : Qr(e),
|
|
4889
4966
|
statedBar: n,
|
|
4890
|
-
settlement:
|
|
4967
|
+
settlement: Zr(),
|
|
4891
4968
|
reported: !1,
|
|
4892
4969
|
entry: {
|
|
4893
4970
|
...t,
|
|
@@ -4903,15 +4980,15 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4903
4980
|
this.requirement = e;
|
|
4904
4981
|
return;
|
|
4905
4982
|
}
|
|
4906
|
-
let n =
|
|
4907
|
-
this.requirement =
|
|
4983
|
+
let n = ti(t, e);
|
|
4984
|
+
this.requirement = ei(t, e), n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
|
|
4908
4985
|
challenge: this.requirement,
|
|
4909
4986
|
factors: this.offeredFactors()
|
|
4910
4987
|
});
|
|
4911
4988
|
}
|
|
4912
4989
|
offeredFactors() {
|
|
4913
4990
|
let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
|
|
4914
|
-
return t ?
|
|
4991
|
+
return t ? Kr(e, t) : e;
|
|
4915
4992
|
}
|
|
4916
4993
|
receiveReport(e, t) {
|
|
4917
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());
|
|
@@ -4946,12 +5023,12 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
4946
5023
|
}
|
|
4947
5024
|
release(e, t) {
|
|
4948
5025
|
if (e.entry.kind === "imperative") {
|
|
4949
|
-
if (e.statedBar &&
|
|
5026
|
+
if (e.statedBar && !$r(t, e.demanded)) {
|
|
4950
5027
|
this.receiveReport(e, {
|
|
4951
5028
|
outcome: "insufficient",
|
|
4952
5029
|
obtained: t,
|
|
4953
5030
|
required: e.demanded
|
|
4954
|
-
}), e.settlement.reject(new
|
|
5031
|
+
}), e.settlement.reject(new ur(t, e.demanded));
|
|
4955
5032
|
return;
|
|
4956
5033
|
}
|
|
4957
5034
|
this.receiveReport(e, {
|
|
@@ -5024,7 +5101,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5024
5101
|
let t = this.offeredFactors();
|
|
5025
5102
|
if (t.length === 0) return {
|
|
5026
5103
|
status: "failed",
|
|
5027
|
-
reason: new
|
|
5104
|
+
reason: new Jr()
|
|
5028
5105
|
};
|
|
5029
5106
|
let n = this.requirement, r;
|
|
5030
5107
|
try {
|
|
@@ -5032,24 +5109,24 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5032
5109
|
} catch (e) {
|
|
5033
5110
|
return {
|
|
5034
5111
|
status: "failed",
|
|
5035
|
-
reason: new
|
|
5112
|
+
reason: new qr(e)
|
|
5036
5113
|
};
|
|
5037
5114
|
}
|
|
5038
5115
|
if (r.type === "cancel") return {
|
|
5039
5116
|
status: "failed",
|
|
5040
|
-
reason: new
|
|
5117
|
+
reason: new qr()
|
|
5041
5118
|
};
|
|
5042
5119
|
let i = this.registry.get(r.factor);
|
|
5043
|
-
if (!i) e = new
|
|
5120
|
+
if (!i) e = new Jr(`Unknown authentication factor: ${r.factor}`), this.state = "collecting", this.selected = null;
|
|
5044
5121
|
else try {
|
|
5045
5122
|
return await this.proveAndCommit(i, r.code), {
|
|
5046
5123
|
status: "proven",
|
|
5047
|
-
obtained: this.readObtainedBar?.() ??
|
|
5124
|
+
obtained: this.readObtainedBar?.() ?? Qr(this.rankedRequirement ?? n)
|
|
5048
5125
|
};
|
|
5049
5126
|
} catch (t) {
|
|
5050
|
-
if (t instanceof
|
|
5127
|
+
if (t instanceof Fr && t.cancelled) return {
|
|
5051
5128
|
status: "failed",
|
|
5052
|
-
reason: new
|
|
5129
|
+
reason: new qr()
|
|
5053
5130
|
};
|
|
5054
5131
|
let n = this.classifyProofFailure(t);
|
|
5055
5132
|
if (n) return {
|
|
@@ -5079,15 +5156,15 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5079
5156
|
return this.openPrompt = r, this.prompt(r);
|
|
5080
5157
|
}
|
|
5081
5158
|
classifyProofFailure(e) {
|
|
5082
|
-
if (e instanceof
|
|
5159
|
+
if (e instanceof ur || e instanceof dr || e instanceof fr) return e;
|
|
5083
5160
|
if (e instanceof $) switch (e.kind) {
|
|
5084
|
-
case "unavailable": return new
|
|
5161
|
+
case "unavailable": return new dr(e.message);
|
|
5085
5162
|
case "exhausted":
|
|
5086
5163
|
case "attempts_exhausted":
|
|
5087
5164
|
case "fatal":
|
|
5088
5165
|
case "protocol":
|
|
5089
5166
|
case "network": return e;
|
|
5090
|
-
case "session_changed": return new
|
|
5167
|
+
case "session_changed": return new fr(e.message);
|
|
5091
5168
|
default: return;
|
|
5092
5169
|
}
|
|
5093
5170
|
}
|
|
@@ -5099,28 +5176,28 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5099
5176
|
});
|
|
5100
5177
|
await this.transport.commit(e.type, r);
|
|
5101
5178
|
}
|
|
5102
|
-
},
|
|
5179
|
+
}, ri = (e) => typeof e == "function" ? e() : e, ii = (e) => {
|
|
5103
5180
|
try {
|
|
5104
5181
|
return new URL(e);
|
|
5105
5182
|
} catch {
|
|
5106
5183
|
return;
|
|
5107
5184
|
}
|
|
5108
|
-
},
|
|
5185
|
+
}, ai = (e, t) => {
|
|
5109
5186
|
if (!t || t === "/") return !0;
|
|
5110
5187
|
let n = t.replace(/\/+$/, "");
|
|
5111
5188
|
return e === n || e.startsWith(`${n}/`);
|
|
5112
|
-
},
|
|
5189
|
+
}, oi = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && ai(e.pathname, t.pathPrefix), si = (e, t) => {
|
|
5113
5190
|
for (let n of t) {
|
|
5114
5191
|
if (n === "") continue;
|
|
5115
5192
|
if (n.startsWith("/")) {
|
|
5116
|
-
if (e.relativeToBase &&
|
|
5193
|
+
if (e.relativeToBase && ai(e.pathname, n)) return !0;
|
|
5117
5194
|
continue;
|
|
5118
5195
|
}
|
|
5119
|
-
let t =
|
|
5120
|
-
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;
|
|
5121
5198
|
}
|
|
5122
5199
|
return !1;
|
|
5123
|
-
},
|
|
5200
|
+
}, ci = (e, t, n) => oi(e, t.passflow) || si(e, t.backend) ? !n || n(e.href) !== !1 : !1, li = (e) => {
|
|
5124
5201
|
let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
|
|
5125
5202
|
console.warn(n, {
|
|
5126
5203
|
status: e.status,
|
|
@@ -5128,8 +5205,8 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5128
5205
|
reason: e.reason,
|
|
5129
5206
|
detail: t
|
|
5130
5207
|
});
|
|
5131
|
-
},
|
|
5132
|
-
let n = t.onUpgradeDiagnostic ??
|
|
5208
|
+
}, ui = (e, t) => {
|
|
5209
|
+
let n = t.onUpgradeDiagnostic ?? li;
|
|
5133
5210
|
return (t, r) => {
|
|
5134
5211
|
n({
|
|
5135
5212
|
status: e.status,
|
|
@@ -5141,8 +5218,8 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5141
5218
|
}
|
|
5142
5219
|
});
|
|
5143
5220
|
};
|
|
5144
|
-
},
|
|
5145
|
-
let r = n.onUpgradeDiagnostic ??
|
|
5221
|
+
}, di = (e, t, n) => {
|
|
5222
|
+
let r = n.onUpgradeDiagnostic ?? li;
|
|
5146
5223
|
for (let n of e) r({
|
|
5147
5224
|
...n,
|
|
5148
5225
|
url: t.request.href,
|
|
@@ -5151,8 +5228,8 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5151
5228
|
...n.detail ?? {}
|
|
5152
5229
|
}
|
|
5153
5230
|
});
|
|
5154
|
-
},
|
|
5155
|
-
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;
|
|
5156
5233
|
if (i) try {
|
|
5157
5234
|
a = await e.readBody();
|
|
5158
5235
|
} catch {
|
|
@@ -5166,10 +5243,10 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5166
5243
|
status: e.status,
|
|
5167
5244
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5168
5245
|
}, { requireChallengeChannel: t.requireChallengeChannel });
|
|
5169
|
-
},
|
|
5246
|
+
}, mi = (e) => ve({
|
|
5170
5247
|
status: e.status,
|
|
5171
5248
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5172
|
-
}, { 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 ? {
|
|
5173
5250
|
kind: "insufficient",
|
|
5174
5251
|
obtained: e.obtained,
|
|
5175
5252
|
required: e.required
|
|
@@ -5185,17 +5262,17 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5185
5262
|
kind: "transport-failure",
|
|
5186
5263
|
retryable: !1,
|
|
5187
5264
|
error: e instanceof Error ? e : Error(String(e))
|
|
5188
|
-
},
|
|
5265
|
+
}, _i = async (e, t, n, r) => {
|
|
5189
5266
|
if (e.status !== 401 && e.status !== 403) return {
|
|
5190
5267
|
kind: "replayed",
|
|
5191
5268
|
response: e
|
|
5192
5269
|
};
|
|
5193
|
-
let { challenge: i, diagnostics: a } = await
|
|
5194
|
-
if (
|
|
5270
|
+
let { challenge: i, diagnostics: a } = await pi(e, t);
|
|
5271
|
+
if (di(a, e, t), !i) return {
|
|
5195
5272
|
kind: "replayed",
|
|
5196
5273
|
response: e
|
|
5197
5274
|
};
|
|
5198
|
-
let o =
|
|
5275
|
+
let o = Qr(i);
|
|
5199
5276
|
return r("elevated-insufficient", {
|
|
5200
5277
|
obtained: n,
|
|
5201
5278
|
required: o
|
|
@@ -5205,7 +5282,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5205
5282
|
required: o,
|
|
5206
5283
|
response: e
|
|
5207
5284
|
};
|
|
5208
|
-
},
|
|
5285
|
+
}, vi = async (e, t) => {
|
|
5209
5286
|
if (!t) return {
|
|
5210
5287
|
aborted: !1,
|
|
5211
5288
|
value: await e
|
|
@@ -5232,14 +5309,14 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5232
5309
|
} finally {
|
|
5233
5310
|
n && t.removeEventListener?.("abort", n);
|
|
5234
5311
|
}
|
|
5235
|
-
},
|
|
5312
|
+
}, yi = async (e, t) => {
|
|
5236
5313
|
if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
|
|
5237
|
-
let n =
|
|
5314
|
+
let n = ui(e, t);
|
|
5238
5315
|
if (e.markers.replayed) {
|
|
5239
|
-
if (
|
|
5240
|
-
let { challenge: r, diagnostics: i } = await
|
|
5241
|
-
if (
|
|
5242
|
-
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);
|
|
5243
5320
|
return n("elevated-insufficient", {
|
|
5244
5321
|
obtained: a,
|
|
5245
5322
|
required: o
|
|
@@ -5250,12 +5327,12 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5250
5327
|
response: e
|
|
5251
5328
|
};
|
|
5252
5329
|
}
|
|
5253
|
-
if (
|
|
5330
|
+
if (!ci(e.request, t.scope, t.shouldIntercept)) return mi(e) ? (n("challenge-out-of-scope", {
|
|
5254
5331
|
header: e.getHeader("www-authenticate") ?? void 0,
|
|
5255
|
-
message:
|
|
5332
|
+
message: hi(e.request.href, t.scope)
|
|
5256
5333
|
}), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
|
|
5257
|
-
let { challenge: r, diagnostics: i } = await
|
|
5258
|
-
if (
|
|
5334
|
+
let { challenge: r, diagnostics: i } = await pi(e, t);
|
|
5335
|
+
if (di(i, e, t), !r) {
|
|
5259
5336
|
let r = e.getHeader("www-authenticate");
|
|
5260
5337
|
return t.requireChallengeChannel !== "header" && n("no-channel", {
|
|
5261
5338
|
...r ? { header: r } : {},
|
|
@@ -5269,9 +5346,9 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5269
5346
|
method: e.request.method
|
|
5270
5347
|
}, s, c;
|
|
5271
5348
|
try {
|
|
5272
|
-
s = Promise.resolve(t.elevate(r, o)), c = await
|
|
5349
|
+
s = Promise.resolve(t.elevate(r, o)), c = await vi(s, e.signal);
|
|
5273
5350
|
} catch (e) {
|
|
5274
|
-
return
|
|
5351
|
+
return gi(e, void 0);
|
|
5275
5352
|
}
|
|
5276
5353
|
if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
|
|
5277
5354
|
kind: "aborted",
|
|
@@ -5282,7 +5359,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5282
5359
|
kind: "aborted",
|
|
5283
5360
|
reason: e.signal.reason
|
|
5284
5361
|
};
|
|
5285
|
-
let u = l?.obtained ?? t.readObtainedBar?.() ??
|
|
5362
|
+
let u = l?.obtained ?? t.readObtainedBar?.() ?? Qr(r), d = t.authorizationSwap?.(), f = d ? {
|
|
5286
5363
|
from: a?.from ?? d.from,
|
|
5287
5364
|
to: d.to
|
|
5288
5365
|
} : void 0;
|
|
@@ -5291,7 +5368,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5291
5368
|
try {
|
|
5292
5369
|
p = await e.replay(f ? { authorizationSwap: f } : void 0);
|
|
5293
5370
|
} catch (t) {
|
|
5294
|
-
if (t instanceof
|
|
5371
|
+
if (t instanceof ur) return l?.waiter.report({
|
|
5295
5372
|
outcome: "insufficient",
|
|
5296
5373
|
obtained: t.obtained,
|
|
5297
5374
|
required: t.required
|
|
@@ -5309,7 +5386,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5309
5386
|
};
|
|
5310
5387
|
throw t;
|
|
5311
5388
|
}
|
|
5312
|
-
let m = await
|
|
5389
|
+
let m = await _i(p, t, u, n);
|
|
5313
5390
|
return m.kind === "insufficient" ? l?.waiter.report({
|
|
5314
5391
|
outcome: "insufficient",
|
|
5315
5392
|
obtained: m.obtained,
|
|
@@ -5318,18 +5395,18 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5318
5395
|
outcome: "replayed",
|
|
5319
5396
|
obtained: u
|
|
5320
5397
|
}), m;
|
|
5321
|
-
},
|
|
5398
|
+
}, bi = (e) => {
|
|
5322
5399
|
switch (e.kind) {
|
|
5323
|
-
case "cancelled": return new
|
|
5324
|
-
case "unsatisfiable": return new
|
|
5325
|
-
case "unavailable": return new
|
|
5326
|
-
case "session-changed": return new
|
|
5327
|
-
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);
|
|
5328
5405
|
case "exhausted": return e.error;
|
|
5329
5406
|
case "transport-failure": return e.error;
|
|
5330
5407
|
default: return;
|
|
5331
5408
|
}
|
|
5332
|
-
},
|
|
5409
|
+
}, xi = (e, t, n) => {
|
|
5333
5410
|
switch (e.kind) {
|
|
5334
5411
|
case "replayed": return {
|
|
5335
5412
|
settle: "resolve",
|
|
@@ -5347,21 +5424,21 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5347
5424
|
};
|
|
5348
5425
|
case "cancelled": return n.onCancel === "reject" ? {
|
|
5349
5426
|
settle: "reject",
|
|
5350
|
-
error: new
|
|
5427
|
+
error: new qr()
|
|
5351
5428
|
} : {
|
|
5352
5429
|
settle: "resolve",
|
|
5353
|
-
value:
|
|
5430
|
+
value: Ai(t, e)
|
|
5354
5431
|
};
|
|
5355
5432
|
case "insufficient": return {
|
|
5356
5433
|
settle: "resolve",
|
|
5357
|
-
value:
|
|
5434
|
+
value: Ai(e.response?.raw ?? t, e)
|
|
5358
5435
|
};
|
|
5359
5436
|
default: return {
|
|
5360
5437
|
settle: "resolve",
|
|
5361
|
-
value:
|
|
5438
|
+
value: Ai(t, e)
|
|
5362
5439
|
};
|
|
5363
5440
|
}
|
|
5364
|
-
},
|
|
5441
|
+
}, Si = (e, t) => {
|
|
5365
5442
|
switch (e.kind) {
|
|
5366
5443
|
case "replayed": return e.response.rejected ? {
|
|
5367
5444
|
settle: "reject",
|
|
@@ -5376,39 +5453,39 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5376
5453
|
};
|
|
5377
5454
|
default: return {
|
|
5378
5455
|
settle: "reject",
|
|
5379
|
-
error:
|
|
5456
|
+
error: bi(e) ?? t
|
|
5380
5457
|
};
|
|
5381
5458
|
}
|
|
5382
|
-
},
|
|
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) => {
|
|
5383
5460
|
switch (t.kind) {
|
|
5384
5461
|
case "cancelled":
|
|
5385
|
-
|
|
5462
|
+
Ci.add(e);
|
|
5386
5463
|
break;
|
|
5387
5464
|
case "exhausted":
|
|
5388
|
-
|
|
5465
|
+
wi.add(e);
|
|
5389
5466
|
break;
|
|
5390
5467
|
case "insufficient":
|
|
5391
|
-
|
|
5468
|
+
Ti.add(e);
|
|
5392
5469
|
break;
|
|
5393
5470
|
case "unsatisfiable":
|
|
5394
|
-
|
|
5471
|
+
Ei.add(e);
|
|
5395
5472
|
break;
|
|
5396
5473
|
case "unavailable":
|
|
5397
|
-
|
|
5474
|
+
Di.add(e);
|
|
5398
5475
|
break;
|
|
5399
5476
|
case "session-changed":
|
|
5400
|
-
|
|
5477
|
+
Oi.add(e);
|
|
5401
5478
|
break;
|
|
5402
|
-
case "transport-failure":
|
|
5479
|
+
case "transport-failure": ki.add(e);
|
|
5403
5480
|
}
|
|
5404
5481
|
return e;
|
|
5405
|
-
},
|
|
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 = () => {
|
|
5406
5483
|
let e = globalThis, t = e.document?.baseURI;
|
|
5407
5484
|
if (typeof t == "string" && t !== "") return t;
|
|
5408
5485
|
let n = e.location?.href;
|
|
5409
|
-
return typeof n == "string" && n !== "" && n !== "about:blank" ? n :
|
|
5410
|
-
},
|
|
5411
|
-
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;
|
|
5412
5489
|
try {
|
|
5413
5490
|
r = new URL(t).origin;
|
|
5414
5491
|
} catch {
|
|
@@ -5434,28 +5511,28 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5434
5511
|
relativeToBase: !1,
|
|
5435
5512
|
sentinelBase: n
|
|
5436
5513
|
};
|
|
5437
|
-
},
|
|
5514
|
+
}, Vi = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Hi = (e) => {
|
|
5438
5515
|
let t = [];
|
|
5439
5516
|
if (e == null) return Object.freeze(t);
|
|
5440
5517
|
let n = e;
|
|
5441
5518
|
if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
|
|
5442
|
-
let r =
|
|
5519
|
+
let r = Vi(n, e);
|
|
5443
5520
|
r && t.push(r);
|
|
5444
5521
|
}), Object.freeze(t);
|
|
5445
5522
|
if (Array.isArray(e)) {
|
|
5446
5523
|
for (let n of e) if (Array.isArray(n) && n.length >= 2) {
|
|
5447
|
-
let e =
|
|
5524
|
+
let e = Vi(String(n[0]), n[1]);
|
|
5448
5525
|
e && t.push(e);
|
|
5449
5526
|
}
|
|
5450
5527
|
return Object.freeze(t);
|
|
5451
5528
|
}
|
|
5452
5529
|
if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
|
|
5453
|
-
let e =
|
|
5530
|
+
let e = Vi(n, Array.isArray(r) ? r.join(", ") : r);
|
|
5454
5531
|
e && t.push(e);
|
|
5455
5532
|
}
|
|
5456
5533
|
return Object.freeze(t);
|
|
5457
|
-
},
|
|
5458
|
-
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 = {
|
|
5459
5536
|
raw: e.url,
|
|
5460
5537
|
href: t.href,
|
|
5461
5538
|
dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
|
|
@@ -5464,29 +5541,29 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5464
5541
|
resolved: t.resolved,
|
|
5465
5542
|
relativeToBase: t.relativeToBase,
|
|
5466
5543
|
method: (e.method ?? "GET").toUpperCase(),
|
|
5467
|
-
headers:
|
|
5544
|
+
headers: Hi(e.headers),
|
|
5468
5545
|
bodyKind: e.bodyKind,
|
|
5469
5546
|
..."body" in e ? { body: e.body } : {}
|
|
5470
5547
|
};
|
|
5471
5548
|
return Object.freeze(n);
|
|
5472
|
-
},
|
|
5549
|
+
}, Wi = (e, t) => {
|
|
5473
5550
|
if (!t || t.from === t.to) return e;
|
|
5474
5551
|
let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
|
|
5475
5552
|
return n ? Object.freeze(r) : e;
|
|
5476
|
-
},
|
|
5553
|
+
}, Gi = (e) => {
|
|
5477
5554
|
let t = {};
|
|
5478
5555
|
for (let [n, r] of e) t[n] = r;
|
|
5479
5556
|
return t;
|
|
5480
|
-
},
|
|
5557
|
+
}, Ki = /* @__PURE__ */ new Set([
|
|
5481
5558
|
"GET",
|
|
5482
5559
|
"HEAD",
|
|
5483
5560
|
"OPTIONS"
|
|
5484
|
-
]),
|
|
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) => {
|
|
5485
5562
|
if (typeof e == "string") return e.length;
|
|
5486
5563
|
let t = e;
|
|
5487
5564
|
if (typeof t?.size == "number") return t.size;
|
|
5488
5565
|
if (typeof t?.byteLength == "number") return t.byteLength;
|
|
5489
|
-
},
|
|
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) => ({
|
|
5490
5567
|
replayable: !1,
|
|
5491
5568
|
bodyKind: e,
|
|
5492
5569
|
reason: t,
|
|
@@ -5494,11 +5571,11 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5494
5571
|
forwardInit: i,
|
|
5495
5572
|
snapshot: r,
|
|
5496
5573
|
replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
|
|
5497
|
-
}),
|
|
5574
|
+
}), ea = (e, t) => Gi(Wi(e.headers, t?.authorizationSwap)), ta = (e) => {
|
|
5498
5575
|
if (!e || !("headers" in e)) return e;
|
|
5499
5576
|
let { headers: t, ...n } = e;
|
|
5500
5577
|
return n;
|
|
5501
|
-
},
|
|
5578
|
+
}, na = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : qi(e) ? e.headers : void 0, ra = (e) => {
|
|
5502
5579
|
if (e === null || typeof e == "string") return e;
|
|
5503
5580
|
if (typeof FormData < "u" && e instanceof FormData) {
|
|
5504
5581
|
let t = new FormData();
|
|
@@ -5506,18 +5583,18 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5506
5583
|
return t;
|
|
5507
5584
|
}
|
|
5508
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;
|
|
5509
|
-
},
|
|
5510
|
-
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({
|
|
5511
5588
|
url: r,
|
|
5512
5589
|
method: i,
|
|
5513
5590
|
headers: a,
|
|
5514
5591
|
bodyKind: e,
|
|
5515
5592
|
...t === void 0 ? {} : { body: t }
|
|
5516
5593
|
});
|
|
5517
|
-
if (
|
|
5594
|
+
if (qi(e)) {
|
|
5518
5595
|
if (e.body === null || e.body === void 0) {
|
|
5519
5596
|
let a = o("none");
|
|
5520
|
-
return
|
|
5597
|
+
return Qi(n, {
|
|
5521
5598
|
url: r,
|
|
5522
5599
|
method: i,
|
|
5523
5600
|
bodyKind: "none"
|
|
@@ -5527,20 +5604,20 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5527
5604
|
forwardInput: e,
|
|
5528
5605
|
forwardInit: t,
|
|
5529
5606
|
snapshot: a,
|
|
5530
|
-
replay: (n, r) => n(
|
|
5531
|
-
} :
|
|
5607
|
+
replay: (n, r) => n(ia(e, a, r), ta(t))
|
|
5608
|
+
} : $i("none", "the replay policy refused this request", e, a, t);
|
|
5532
5609
|
}
|
|
5533
5610
|
let a = o("request-clone");
|
|
5534
|
-
if (!
|
|
5611
|
+
if (!Qi(n, {
|
|
5535
5612
|
url: r,
|
|
5536
5613
|
method: i,
|
|
5537
5614
|
bodyKind: "request-clone"
|
|
5538
|
-
})) return
|
|
5615
|
+
})) return $i("request-clone", "the replay policy refused this request", e, a, t);
|
|
5539
5616
|
let s;
|
|
5540
5617
|
try {
|
|
5541
5618
|
s = e.clone();
|
|
5542
5619
|
} catch {
|
|
5543
|
-
return
|
|
5620
|
+
return $i("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
|
|
5544
5621
|
}
|
|
5545
5622
|
return {
|
|
5546
5623
|
replayable: !0,
|
|
@@ -5548,17 +5625,17 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5548
5625
|
forwardInput: e,
|
|
5549
5626
|
forwardInit: t,
|
|
5550
5627
|
snapshot: a,
|
|
5551
|
-
replay: (e, n) => e(
|
|
5628
|
+
replay: (e, n) => e(ia(s, a, n), ta(t))
|
|
5552
5629
|
};
|
|
5553
5630
|
}
|
|
5554
|
-
let s =
|
|
5555
|
-
if (s === "one-shot") return
|
|
5556
|
-
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, {
|
|
5557
5634
|
url: r,
|
|
5558
5635
|
method: i,
|
|
5559
5636
|
bodyKind: s
|
|
5560
|
-
},
|
|
5561
|
-
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);
|
|
5562
5639
|
return {
|
|
5563
5640
|
replayable: !0,
|
|
5564
5641
|
bodyKind: s,
|
|
@@ -5566,21 +5643,21 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5566
5643
|
forwardInit: t,
|
|
5567
5644
|
snapshot: l,
|
|
5568
5645
|
replay: (e, n) => e(l.dispatchUrl, {
|
|
5569
|
-
...
|
|
5646
|
+
...ta(t),
|
|
5570
5647
|
...c === void 0 ? {} : { body: c },
|
|
5571
|
-
headers:
|
|
5648
|
+
headers: ea(l, n),
|
|
5572
5649
|
method: l.method
|
|
5573
5650
|
})
|
|
5574
5651
|
};
|
|
5575
|
-
},
|
|
5576
|
-
if (!
|
|
5652
|
+
}, oa = (e) => typeof e == "object" && !!e, sa = (e) => (t) => {
|
|
5653
|
+
if (!oa(e)) return;
|
|
5577
5654
|
let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
|
|
5578
5655
|
return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
|
|
5579
|
-
},
|
|
5656
|
+
}, ca = (e) => {
|
|
5580
5657
|
let t = e?.url ?? "", n = e?.baseURL;
|
|
5581
5658
|
return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
5582
|
-
},
|
|
5583
|
-
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;
|
|
5584
5661
|
return {
|
|
5585
5662
|
...e,
|
|
5586
5663
|
...i ? { baseURL: void 0 } : {},
|
|
@@ -5589,10 +5666,10 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5589
5666
|
headers: r,
|
|
5590
5667
|
..."body" in t ? { data: t.body } : {}
|
|
5591
5668
|
};
|
|
5592
|
-
},
|
|
5593
|
-
let o = t ?? e?.config, s =
|
|
5594
|
-
url:
|
|
5595
|
-
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),
|
|
5596
5673
|
headers: o?.headers,
|
|
5597
5674
|
bodyKind: s,
|
|
5598
5675
|
body: o?.data
|
|
@@ -5600,22 +5677,22 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5600
5677
|
url: c.href,
|
|
5601
5678
|
method: c.method,
|
|
5602
5679
|
bodyKind: s
|
|
5603
|
-
}, u = s !== "one-shot" &&
|
|
5680
|
+
}, u = s !== "one-shot" && Qi(i.replay, l);
|
|
5604
5681
|
return {
|
|
5605
5682
|
status: e?.status ?? 0,
|
|
5606
|
-
getHeader:
|
|
5683
|
+
getHeader: sa(e?.headers),
|
|
5607
5684
|
readBody: async () => e?.data,
|
|
5608
5685
|
request: c,
|
|
5609
5686
|
replay: async (e) => {
|
|
5610
|
-
let t = Te(
|
|
5687
|
+
let t = Te(da(o ?? {}, c, e));
|
|
5611
5688
|
try {
|
|
5612
5689
|
let e = await r(t);
|
|
5613
|
-
return
|
|
5690
|
+
return fa(e, e?.config ?? t, e, r, i, c);
|
|
5614
5691
|
} catch (e) {
|
|
5615
|
-
let n =
|
|
5616
|
-
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;
|
|
5617
5694
|
return {
|
|
5618
|
-
...
|
|
5695
|
+
...fa(n.response, n.config ?? t, e, r, i, c),
|
|
5619
5696
|
rejected: !0
|
|
5620
5697
|
};
|
|
5621
5698
|
}
|
|
@@ -5629,19 +5706,19 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5629
5706
|
replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
|
|
5630
5707
|
signal: o?.signal
|
|
5631
5708
|
};
|
|
5632
|
-
},
|
|
5633
|
-
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);
|
|
5634
5711
|
if (a.settle === "reject") throw a.error;
|
|
5635
5712
|
return a.value;
|
|
5636
|
-
},
|
|
5637
|
-
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;
|
|
5638
5715
|
return () => {
|
|
5639
5716
|
o || (o = !0, e.interceptors.response.eject(a));
|
|
5640
5717
|
};
|
|
5641
|
-
},
|
|
5718
|
+
}, ha = (t, n) => {
|
|
5642
5719
|
let r = e.create(t);
|
|
5643
5720
|
return n(r), r;
|
|
5644
|
-
},
|
|
5721
|
+
}, ga = 0, _a = (e, t) => {
|
|
5645
5722
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
5646
5723
|
if (n) return {
|
|
5647
5724
|
get aborted() {
|
|
@@ -5655,34 +5732,34 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5655
5732
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
5656
5733
|
} : {}
|
|
5657
5734
|
};
|
|
5658
|
-
},
|
|
5735
|
+
}, va = (e) => (t) => e.headers?.get(t), ya = (e, t, n, r, i) => ({
|
|
5659
5736
|
status: e.status,
|
|
5660
|
-
getHeader:
|
|
5737
|
+
getHeader: va(e),
|
|
5661
5738
|
readBody: () => e.clone().json(),
|
|
5662
5739
|
request: t.snapshot,
|
|
5663
|
-
replay: async (e) =>
|
|
5740
|
+
replay: async (e) => ya(await t.replay(n, e), t, n, r, i),
|
|
5664
5741
|
markers: r,
|
|
5665
5742
|
raw: e,
|
|
5666
5743
|
replayable: t.replayable,
|
|
5667
5744
|
replayUnsupportedReason: t.reason,
|
|
5668
5745
|
signal: i,
|
|
5669
5746
|
responseType: e.type
|
|
5670
|
-
}),
|
|
5747
|
+
}), ba = (e, t) => {
|
|
5671
5748
|
let n = (t, n) => {
|
|
5672
|
-
|
|
5749
|
+
ga += 1;
|
|
5673
5750
|
try {
|
|
5674
5751
|
return e(t, n);
|
|
5675
5752
|
} finally {
|
|
5676
|
-
--
|
|
5753
|
+
--ga;
|
|
5677
5754
|
}
|
|
5678
5755
|
};
|
|
5679
5756
|
return async (e, r) => {
|
|
5680
|
-
if (
|
|
5681
|
-
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);
|
|
5682
5759
|
if (s.settle === "reject") throw s.error;
|
|
5683
5760
|
return s.value;
|
|
5684
5761
|
};
|
|
5685
|
-
},
|
|
5762
|
+
}, xa = new Set(Br.filter((e) => !e.requiresPrepare).map((e) => e.type)), Sa = (e) => {
|
|
5686
5763
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
5687
5764
|
kind: "protocol",
|
|
5688
5765
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -5694,17 +5771,17 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5694
5771
|
webauthn: e.webauthn,
|
|
5695
5772
|
codeSentTo: e.code_sent_to
|
|
5696
5773
|
};
|
|
5697
|
-
},
|
|
5774
|
+
}, Ca = (e) => nr(e) && !rr(e), wa = (e) => ({
|
|
5698
5775
|
async prepare(t) {
|
|
5699
|
-
if (!
|
|
5776
|
+
if (!xa.has(t)) try {
|
|
5700
5777
|
let n = e.relyingPartyId?.();
|
|
5701
|
-
return
|
|
5778
|
+
return Sa(await e.startUpgrade(n ? {
|
|
5702
5779
|
method: t,
|
|
5703
5780
|
relying_party_id: n
|
|
5704
5781
|
} : { method: t }));
|
|
5705
5782
|
} catch (e) {
|
|
5706
|
-
if (
|
|
5707
|
-
let t =
|
|
5783
|
+
if (Ca(e)) throw e;
|
|
5784
|
+
let t = sr(e, "start");
|
|
5708
5785
|
if (t.kind === "prepare_not_required") return;
|
|
5709
5786
|
throw t;
|
|
5710
5787
|
}
|
|
@@ -5721,17 +5798,17 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5721
5798
|
assertion: n
|
|
5722
5799
|
});
|
|
5723
5800
|
} catch (t) {
|
|
5724
|
-
if (
|
|
5725
|
-
let n =
|
|
5726
|
-
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;
|
|
5727
5804
|
}
|
|
5728
5805
|
}
|
|
5729
|
-
}),
|
|
5806
|
+
}), Ta = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Ea = (e) => {
|
|
5730
5807
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
5731
5808
|
let i = () => {
|
|
5732
5809
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
5733
5810
|
};
|
|
5734
|
-
return
|
|
5811
|
+
return wa({
|
|
5735
5812
|
...e,
|
|
5736
5813
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
5737
5814
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -5742,7 +5819,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5742
5819
|
});
|
|
5743
5820
|
}, i = (t, n) => {
|
|
5744
5821
|
let i = {}, a = {
|
|
5745
|
-
controller: new
|
|
5822
|
+
controller: new ni({
|
|
5746
5823
|
transport: r(() => i.current),
|
|
5747
5824
|
prompt: t.prompt,
|
|
5748
5825
|
platform: e.platform,
|
|
@@ -5754,17 +5831,17 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5754
5831
|
options: t,
|
|
5755
5832
|
scope: {
|
|
5756
5833
|
passflow: e.passflowDomain,
|
|
5757
|
-
backend:
|
|
5834
|
+
backend: Ta(t.backend)
|
|
5758
5835
|
},
|
|
5759
5836
|
generation: n
|
|
5760
5837
|
};
|
|
5761
5838
|
return i.current = a, a;
|
|
5762
5839
|
}, a = async (r, i) => {
|
|
5763
5840
|
let a = t;
|
|
5764
|
-
if (!a) throw new
|
|
5841
|
+
if (!a) throw new dr("Step-up verification is not enabled on this Passflow instance");
|
|
5765
5842
|
a.controller.active || (a.pin = e.readSessionPin?.());
|
|
5766
5843
|
let o = await a.controller.elevate(r, i);
|
|
5767
|
-
if (!n(a)) throw new
|
|
5844
|
+
if (!n(a)) throw new fr();
|
|
5768
5845
|
return o;
|
|
5769
5846
|
}, o = () => {
|
|
5770
5847
|
let n = t, r = n?.scope ?? {
|
|
@@ -5808,9 +5885,9 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5808
5885
|
let r = [];
|
|
5809
5886
|
if (e.attachInternalSeam) {
|
|
5810
5887
|
let t = e.attachInternalSeam;
|
|
5811
|
-
t((e) =>
|
|
5888
|
+
t((e) => pa(o, e)), r.push(() => t(void 0));
|
|
5812
5889
|
}
|
|
5813
|
-
n.interceptFetch && r.push(
|
|
5890
|
+
n.interceptFetch && r.push(_t((e, t, n) => ba(e, o)(t, n), {
|
|
5814
5891
|
priority: 20,
|
|
5815
5892
|
name: "passflow-upgrade"
|
|
5816
5893
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -5841,18 +5918,18 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5841
5918
|
withAuth: {
|
|
5842
5919
|
enumerable: !0,
|
|
5843
5920
|
value: (e) => {
|
|
5844
|
-
if (e) return
|
|
5921
|
+
if (e) return ba(e, o);
|
|
5845
5922
|
let t = typeof globalThis > "u" ? void 0 : globalThis;
|
|
5846
5923
|
if (!t || typeof t.fetch != "function") throw Error("Passflow: withAuth() needs a fetch to wrap — this runtime has none.");
|
|
5847
|
-
return
|
|
5924
|
+
return ba(t.fetch.bind(t), o);
|
|
5848
5925
|
}
|
|
5849
5926
|
},
|
|
5850
5927
|
attachAuth: {
|
|
5851
5928
|
enumerable: !0,
|
|
5852
|
-
value: (e) =>
|
|
5929
|
+
value: (e) => ma(e, o)
|
|
5853
5930
|
}
|
|
5854
5931
|
});
|
|
5855
|
-
},
|
|
5932
|
+
}, Da, Oa = class {
|
|
5856
5933
|
get origin() {
|
|
5857
5934
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
5858
5935
|
}
|
|
@@ -5864,9 +5941,9 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5864
5941
|
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? P, this.storageManager = new N({
|
|
5865
5942
|
prefix: e.keyStoragePrefix ?? "",
|
|
5866
5943
|
storage: this.platform.storage
|
|
5867
|
-
}), this.deviceService = new re(this.storageManager), this.authApi = new
|
|
5868
|
-
let i =
|
|
5869
|
-
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, {
|
|
5870
5947
|
createSession: this.createSessionCallback,
|
|
5871
5948
|
expiredSession: this.expiredSessionCallback
|
|
5872
5949
|
}, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
|
|
@@ -5874,7 +5951,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5874
5951
|
...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
|
|
5875
5952
|
}), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
5876
5953
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
5877
|
-
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({
|
|
5878
5955
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
5879
5956
|
commitRefresh: async (e, t) => {
|
|
5880
5957
|
await this.authService.refreshToken(e, t);
|
|
@@ -5921,7 +5998,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5921
5998
|
return this.upgrade.attachAuth(e);
|
|
5922
5999
|
}
|
|
5923
6000
|
createClient(e) {
|
|
5924
|
-
return
|
|
6001
|
+
return ha(e, (e) => this.upgrade.attachAuth(e));
|
|
5925
6002
|
}
|
|
5926
6003
|
readAssuranceBar() {
|
|
5927
6004
|
let e = this.storageManager.getToken(j.access_token);
|
|
@@ -5973,7 +6050,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
5973
6050
|
message: t instanceof Error || t instanceof B ? t.message : "Session check failed",
|
|
5974
6051
|
originalError: t
|
|
5975
6052
|
};
|
|
5976
|
-
|
|
6053
|
+
W(this.subscribeStore, n), e = void 0;
|
|
5977
6054
|
}
|
|
5978
6055
|
e && this.createSessionCallback && await this.createSessionCallback({
|
|
5979
6056
|
tokens: e,
|
|
@@ -6001,24 +6078,24 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
6001
6078
|
}
|
|
6002
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;
|
|
6003
6080
|
if (r) {
|
|
6004
|
-
if (!
|
|
6005
|
-
|
|
6081
|
+
if (!hr(r)) {
|
|
6082
|
+
W(this.subscribeStore, {
|
|
6006
6083
|
operation: "tokens.from-url",
|
|
6007
6084
|
message: "Invalid access token format received",
|
|
6008
6085
|
code: "INVALID_TOKEN_FORMAT"
|
|
6009
6086
|
}), this.cleanupUrlParams(n, e);
|
|
6010
6087
|
return;
|
|
6011
6088
|
}
|
|
6012
|
-
if (i && !
|
|
6013
|
-
|
|
6089
|
+
if (i && !hr(i)) {
|
|
6090
|
+
W(this.subscribeStore, {
|
|
6014
6091
|
operation: "tokens.from-url",
|
|
6015
6092
|
message: "Invalid refresh token format received",
|
|
6016
6093
|
code: "INVALID_TOKEN_FORMAT"
|
|
6017
6094
|
}), this.cleanupUrlParams(n, e);
|
|
6018
6095
|
return;
|
|
6019
6096
|
}
|
|
6020
|
-
if (a && !
|
|
6021
|
-
|
|
6097
|
+
if (a && !hr(a)) {
|
|
6098
|
+
W(this.subscribeStore, {
|
|
6022
6099
|
operation: "tokens.from-url",
|
|
6023
6100
|
message: "Invalid ID token format received",
|
|
6024
6101
|
code: "INVALID_TOKEN_FORMAT"
|
|
@@ -6043,11 +6120,11 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
6043
6120
|
if (!n) return !1;
|
|
6044
6121
|
t.delete("tfa_token");
|
|
6045
6122
|
let r = t.toString();
|
|
6046
|
-
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, {
|
|
6047
6124
|
email: "",
|
|
6048
6125
|
challengeId: "",
|
|
6049
6126
|
tfaToken: n
|
|
6050
|
-
}), !0) : (
|
|
6127
|
+
}), !0) : (W(this.subscribeStore, {
|
|
6051
6128
|
operation: "tokens.from-url",
|
|
6052
6129
|
message: "Invalid 2FA token format received",
|
|
6053
6130
|
code: "INVALID_TOKEN_FORMAT"
|
|
@@ -6056,7 +6133,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
6056
6133
|
checkErrorsFromURL() {
|
|
6057
6134
|
let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
|
|
6058
6135
|
if (e) {
|
|
6059
|
-
let t =
|
|
6136
|
+
let t = gr(e);
|
|
6060
6137
|
return Error(t);
|
|
6061
6138
|
}
|
|
6062
6139
|
}
|
|
@@ -6117,6 +6194,9 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
6117
6194
|
async passwordlessSignInComplete(e) {
|
|
6118
6195
|
return await this.authService.passwordlessSignInComplete(e);
|
|
6119
6196
|
}
|
|
6197
|
+
async verifyEmailCode(e) {
|
|
6198
|
+
return await this.authService.verifyEmailCode(e);
|
|
6199
|
+
}
|
|
6120
6200
|
handleError(e, t, n) {
|
|
6121
6201
|
let r = {
|
|
6122
6202
|
operation: t,
|
|
@@ -6124,7 +6204,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
6124
6204
|
originalError: e,
|
|
6125
6205
|
code: e instanceof B ? e.id : void 0
|
|
6126
6206
|
};
|
|
6127
|
-
throw
|
|
6207
|
+
throw W(this.subscribeStore, r), e;
|
|
6128
6208
|
}
|
|
6129
6209
|
async logOut() {
|
|
6130
6210
|
try {
|
|
@@ -6148,7 +6228,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
6148
6228
|
message: e,
|
|
6149
6229
|
code: "RESET_ERROR"
|
|
6150
6230
|
};
|
|
6151
|
-
throw
|
|
6231
|
+
throw W(this.subscribeStore, t), this.error;
|
|
6152
6232
|
}
|
|
6153
6233
|
}
|
|
6154
6234
|
notifySignedOut(e) {
|
|
@@ -6166,8 +6246,8 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
6166
6246
|
sendPasswordResetEmail(e) {
|
|
6167
6247
|
return this.authService.sendPasswordResetEmail(e);
|
|
6168
6248
|
}
|
|
6169
|
-
async resetPassword(e, t) {
|
|
6170
|
-
return await this.authService.resetPassword(e, t);
|
|
6249
|
+
async resetPassword(e, t, n) {
|
|
6250
|
+
return await this.authService.resetPassword(e, t, n);
|
|
6171
6251
|
}
|
|
6172
6252
|
async getAppSettings() {
|
|
6173
6253
|
try {
|
|
@@ -6397,7 +6477,7 @@ var _r = "passflow_2fa_pkce", vr = 3e5, yr = class {
|
|
|
6397
6477
|
this.twoFactorService.clearMagicLinkSession();
|
|
6398
6478
|
}
|
|
6399
6479
|
};
|
|
6400
|
-
|
|
6401
|
-
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 };
|
|
6402
6482
|
|
|
6403
6483
|
//# sourceMappingURL=index.mjs.map
|