@passflow/core 0.23.0 → 0.25.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 +85 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +325 -8
- package/dist/index.d.ts +325 -8
- package/dist/index.mjs +1064 -673
- 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.25.0", i = "X-Passflow-Clientid", a = "Authorization", o = "X-Passflow-DeviceId", s = "X-Passflow-DeviceType", c = r, l = [
|
|
5
5
|
"id",
|
|
6
6
|
"offline",
|
|
7
7
|
"openid"
|
|
@@ -567,7 +567,7 @@ var j = /* @__PURE__ */ function(e) {
|
|
|
567
567
|
}), Ee = (e) => Se(e, xe), De = /* @__PURE__ */ function(e) {
|
|
568
568
|
return e.GET = "get", e.POST = "post", e.PUT = "put", e.PATCH = "patch", e.DELETE = "delete", e;
|
|
569
569
|
}({}), z = /* @__PURE__ */ function(e) {
|
|
570
|
-
return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.signInWithProvider = "/auth/federated/start/", e.passwordless = "/auth/passwordless/start", e.passwordlessComplete = "/auth/passwordless/complete", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e;
|
|
570
|
+
return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.signInWithProvider = "/auth/federated/start/", e.passwordless = "/auth/passwordless/start", e.passwordlessComplete = "/auth/passwordless/complete", e.passwordlessStatus = "/auth/passwordless/status", e.passwordlessApprovalInfo = "/auth/passwordless/approval/info", e.passwordlessApprovalDecide = "/auth/passwordless/approval/decide", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.twoFactorEnrollment = "/auth/2fa/enrollment", e.twoFactorEnrollmentEmailLink = "/auth/2fa/enrollment/email-link", e.twoFactorEnrollmentBegin = "/auth/2fa/setup/begin", e.twoFactorEnrollmentConfirm = "/auth/2fa/setup/confirm", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e;
|
|
571
571
|
}({}), Oe = /* @__PURE__ */ function(e) {
|
|
572
572
|
return e.passkeyRegisterStart = "/admin/auth/passkey/register/start", e.passkeyRegisterComplete = "/admin/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/admin/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/admin/auth/passkey/authenticate/complete", e.passkeyValidate = "/admin/auth/validate", e.logout = "/admin/auth/logout", e;
|
|
573
573
|
}({}), ke = (e) => {
|
|
@@ -608,7 +608,10 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
608
608
|
}({}), ze = 3, Be = 1e3, Ve = (e) => (t) => {
|
|
609
609
|
let n = e.headers?.[t] ?? e.headers?.[t.toLowerCase()];
|
|
610
610
|
return Array.isArray(n) ? n.join(", ") : n;
|
|
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,
|
|
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, Ke = "__passflowOwnBearer", qe = (e) => typeof e == "object" && !!e && e[Ke] === !0, Je = (e) => e ? {
|
|
612
|
+
headers: { [a]: `Bearer ${e}` },
|
|
613
|
+
[Ke]: !0
|
|
614
|
+
} : {}, Ye = class {
|
|
612
615
|
get origin() {
|
|
613
616
|
return this._platform.getCurrentUrl()?.origin ?? "";
|
|
614
617
|
}
|
|
@@ -639,7 +642,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
639
642
|
baseURL: this.url,
|
|
640
643
|
headers: { ...this.defaultHeaders }
|
|
641
644
|
}), this.instance.interceptors.request.use(async (e) => {
|
|
642
|
-
if (this.isNonAuthEndpoint(e.url)) return e;
|
|
645
|
+
if (this.isNonAuthEndpoint(e.url) || qe(e)) return e;
|
|
643
646
|
if (this.tokenDeliveryManager.isCookieMode()) {
|
|
644
647
|
e.withCredentials = !0;
|
|
645
648
|
let t = this.storageManager.getCsrfToken();
|
|
@@ -665,7 +668,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
665
668
|
}
|
|
666
669
|
return e.headers[a] = `Bearer ${n}`, e;
|
|
667
670
|
}), this.instance.interceptors.response.use((e) => e, async (e) => {
|
|
668
|
-
if (e.response?.status
|
|
671
|
+
if (e.response?.status !== 401 || We(e.config?.url) || qe(e.config) || this.isUpgradeTransactionError(e) || this.tokenDeliveryManager.setSessionInvalid(), e.response && this.upgradeHandler) {
|
|
669
672
|
let t = He(e.response);
|
|
670
673
|
if (t) try {
|
|
671
674
|
return await this.upgradeHandler(e, t);
|
|
@@ -771,9 +774,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
771
774
|
[i]: e
|
|
772
775
|
}, this.instance.defaults.headers.common[i] = e;
|
|
773
776
|
}
|
|
774
|
-
},
|
|
777
|
+
}, Xe = class {
|
|
775
778
|
constructor(e, t, n) {
|
|
776
|
-
this.axiosClient = new
|
|
779
|
+
this.axiosClient = new Ye(e, t, n);
|
|
777
780
|
}
|
|
778
781
|
setAppId(e) {
|
|
779
782
|
this.axiosClient.setAppId(e);
|
|
@@ -781,9 +784,19 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
781
784
|
getAppSettings() {
|
|
782
785
|
return this.axiosClient.get(z.appSettings);
|
|
783
786
|
}
|
|
784
|
-
},
|
|
787
|
+
}, Ze = { withCredentials: !0 }, Qe = 15e3, $e = "Sign-in failed. Start again.", et = "Something went wrong. Try again later.", tt = (e, t, n, r) => {
|
|
788
|
+
if (e instanceof B) return e;
|
|
789
|
+
let i = e?.response?.data?.error;
|
|
790
|
+
return new B({
|
|
791
|
+
id: typeof i?.id == "string" ? i.id : n,
|
|
792
|
+
message: typeof i?.message == "string" ? i.message : r,
|
|
793
|
+
status: typeof i?.status == "number" ? i.status : 0,
|
|
794
|
+
location: t,
|
|
795
|
+
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
796
|
+
});
|
|
797
|
+
}, nt = class {
|
|
785
798
|
constructor(e, t, n) {
|
|
786
|
-
this.axiosClient = new
|
|
799
|
+
this.axiosClient = new Ye(e, t, n);
|
|
787
800
|
}
|
|
788
801
|
setAppId(e) {
|
|
789
802
|
this.axiosClient.setAppId(e);
|
|
@@ -802,7 +815,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
802
815
|
device: t,
|
|
803
816
|
os: n
|
|
804
817
|
};
|
|
805
|
-
return this.axiosClient.post(z.signin, r,
|
|
818
|
+
return this.axiosClient.post(z.signin, r, Ze);
|
|
806
819
|
}
|
|
807
820
|
signUp(e) {
|
|
808
821
|
let { create_tenant: t, anonymous: n } = e, r = {
|
|
@@ -810,31 +823,68 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
810
823
|
create_tenant: t ?? !1,
|
|
811
824
|
anonymous: n ?? !1
|
|
812
825
|
};
|
|
813
|
-
return this.axiosClient.post(z.signup, r,
|
|
826
|
+
return this.axiosClient.post(z.signup, r, Ze);
|
|
814
827
|
}
|
|
815
|
-
pkceExchange(e, t) {
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
828
|
+
async pkceExchange(e, t) {
|
|
829
|
+
try {
|
|
830
|
+
return await this.axiosClient.post(z.pkceExchange, {
|
|
831
|
+
authz_code: e,
|
|
832
|
+
verifier: t
|
|
833
|
+
}, Ze);
|
|
834
|
+
} catch (e) {
|
|
835
|
+
throw tt(e, z.pkceExchange, "error.pkce.exchange", $e);
|
|
836
|
+
}
|
|
820
837
|
}
|
|
821
|
-
passwordlessSignIn(e, t, n) {
|
|
838
|
+
async passwordlessSignIn(e, t, n) {
|
|
822
839
|
let { create_tenant: r } = e, i = {
|
|
823
840
|
...e,
|
|
824
841
|
create_tenant: r ?? !1,
|
|
825
842
|
device: t,
|
|
826
843
|
os: n
|
|
827
844
|
};
|
|
828
|
-
|
|
845
|
+
try {
|
|
846
|
+
return await this.axiosClient.post(z.passwordless, i);
|
|
847
|
+
} catch (e) {
|
|
848
|
+
throw tt(e, z.passwordless, "error.passwordless.start", et);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
async passwordlessSignInComplete(e) {
|
|
852
|
+
try {
|
|
853
|
+
return await this.axiosClient.post(z.passwordlessComplete, e, Ze);
|
|
854
|
+
} catch (e) {
|
|
855
|
+
throw tt(e, z.passwordlessComplete, "error.passwordless.complete", et);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
async passwordlessStatus(e, t) {
|
|
859
|
+
try {
|
|
860
|
+
return await this.axiosClient.post(z.passwordlessStatus, e, {
|
|
861
|
+
...Ze,
|
|
862
|
+
timeout: Qe,
|
|
863
|
+
signal: t?.signal
|
|
864
|
+
});
|
|
865
|
+
} catch (e) {
|
|
866
|
+
throw tt(e, z.passwordlessStatus, "error.passwordless.status", $e);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
async passwordlessApprovalInfo(e) {
|
|
870
|
+
try {
|
|
871
|
+
return await this.axiosClient.post(z.passwordlessApprovalInfo, e);
|
|
872
|
+
} catch (e) {
|
|
873
|
+
throw tt(e, z.passwordlessApprovalInfo, "error.passwordless.approval", et);
|
|
874
|
+
}
|
|
829
875
|
}
|
|
830
|
-
|
|
831
|
-
|
|
876
|
+
async passwordlessApprovalDecide(e) {
|
|
877
|
+
try {
|
|
878
|
+
return await this.axiosClient.post(z.passwordlessApprovalDecide, e);
|
|
879
|
+
} catch (e) {
|
|
880
|
+
throw tt(e, z.passwordlessApprovalDecide, "error.passwordless.approval", et);
|
|
881
|
+
}
|
|
832
882
|
}
|
|
833
883
|
validateEmailCode(e) {
|
|
834
884
|
return this.axiosClient.post(z.passkeyValidate, {
|
|
835
885
|
challenge_id: e.challenge_id,
|
|
836
886
|
otp: e.otp
|
|
837
|
-
},
|
|
887
|
+
}, Ze);
|
|
838
888
|
}
|
|
839
889
|
logOut(e, t, n = !1) {
|
|
840
890
|
let r = n ? void 0 : {
|
|
@@ -875,7 +925,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
875
925
|
device: t,
|
|
876
926
|
passkey_data: e
|
|
877
927
|
}, a = r ? Oe.passkeyRegisterComplete : z.passkeyRegisterComplete;
|
|
878
|
-
return this.axiosClient.post(a, i,
|
|
928
|
+
return this.axiosClient.post(a, i, Ze);
|
|
879
929
|
}
|
|
880
930
|
passkeyAuthenticateStart(e, t, n, r = !1) {
|
|
881
931
|
let i = {
|
|
@@ -892,7 +942,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
892
942
|
device: t,
|
|
893
943
|
passkey_data: e
|
|
894
944
|
}, a = r ? Oe.passkeyAuthenticateComplete : z.passkeyAuthenticateComplete;
|
|
895
|
-
return this.axiosClient.post(a, i,
|
|
945
|
+
return this.axiosClient.post(a, i, Ze);
|
|
896
946
|
}
|
|
897
947
|
passkeyValidate(e, t, n, r = !1, a) {
|
|
898
948
|
let o = {
|
|
@@ -904,9 +954,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
904
954
|
let c = a ? { [i]: a } : {};
|
|
905
955
|
return this.axiosClient.post(s, o, { headers: c });
|
|
906
956
|
}
|
|
907
|
-
},
|
|
957
|
+
}, rt = class {
|
|
908
958
|
constructor(e, t, n) {
|
|
909
|
-
this.axiosClient = new
|
|
959
|
+
this.axiosClient = new Ye(e, t, n);
|
|
910
960
|
}
|
|
911
961
|
setAppId(e) {
|
|
912
962
|
this.axiosClient.setAppId(e);
|
|
@@ -918,9 +968,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
918
968
|
completeCLIAuth(e) {
|
|
919
969
|
return this.axiosClient.post(z.cliAuthComplete, e);
|
|
920
970
|
}
|
|
921
|
-
},
|
|
971
|
+
}, it = class {
|
|
922
972
|
constructor(e, t, n) {
|
|
923
|
-
this.axiosClient = new
|
|
973
|
+
this.axiosClient = new Ye(e, t, n);
|
|
924
974
|
}
|
|
925
975
|
setAppId(e) {
|
|
926
976
|
this.axiosClient.setAppId(e);
|
|
@@ -949,9 +999,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
949
999
|
let t = V(z.invitationGetLink, { invitationID: e });
|
|
950
1000
|
return this.axiosClient.get(t);
|
|
951
1001
|
}
|
|
952
|
-
},
|
|
1002
|
+
}, at = class {
|
|
953
1003
|
constructor(e, t, n) {
|
|
954
|
-
this.axiosClient = new
|
|
1004
|
+
this.axiosClient = new Ye(e, t, n);
|
|
955
1005
|
}
|
|
956
1006
|
setAppId(e) {
|
|
957
1007
|
this.axiosClient.setAppId(e);
|
|
@@ -965,9 +1015,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
965
1015
|
getPasskeySettings() {
|
|
966
1016
|
return this.axiosClient.get(z.settingsPasskey);
|
|
967
1017
|
}
|
|
968
|
-
},
|
|
1018
|
+
}, ot = class {
|
|
969
1019
|
constructor(e, t, n) {
|
|
970
|
-
this.axiosClient = new
|
|
1020
|
+
this.axiosClient = new Ye(e, t, n);
|
|
971
1021
|
}
|
|
972
1022
|
setAppId(e) {
|
|
973
1023
|
this.axiosClient.setAppId(e);
|
|
@@ -1081,38 +1131,58 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1081
1131
|
let r = `${z.tenantPath}/${e}/group/${t}/invite/email/${n}`;
|
|
1082
1132
|
return this.axiosClient.delete(r);
|
|
1083
1133
|
}
|
|
1084
|
-
},
|
|
1134
|
+
}, st = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, ct = (e) => ({
|
|
1085
1135
|
withCredentials: !0,
|
|
1086
|
-
|
|
1087
|
-
}),
|
|
1136
|
+
...st(e)
|
|
1137
|
+
}), lt = ({ qr_code_image: e, qr_code: t, ...n }) => ({
|
|
1138
|
+
...n,
|
|
1139
|
+
qr_code: (t ?? e ?? "").replace(/^data:image\/png;base64,/, "")
|
|
1140
|
+
}), ut = {
|
|
1141
|
+
"error.2fa.setup.token.expired": "EXPIRED_TOKEN",
|
|
1142
|
+
"error.2fa.setup.token.revoked": "REVOKED_TOKEN",
|
|
1143
|
+
"error.2fa.setup.token.already_used": "ALREADY_USED",
|
|
1144
|
+
"error.2fa.setup.token.rate.limit.exceeded": "RATE_LIMITED"
|
|
1145
|
+
}, dt = class {
|
|
1088
1146
|
constructor(e, t, n) {
|
|
1089
|
-
this.axiosClient = new
|
|
1147
|
+
this.axiosClient = new Ye(e, t, n);
|
|
1090
1148
|
}
|
|
1091
1149
|
setAppId(e) {
|
|
1092
1150
|
this.axiosClient.setAppId(e);
|
|
1093
1151
|
}
|
|
1094
|
-
getStatus() {
|
|
1095
|
-
return this.axiosClient.get(z.twoFactorStatus);
|
|
1152
|
+
getStatus(e) {
|
|
1153
|
+
return this.axiosClient.get(z.twoFactorStatus, Je(e));
|
|
1154
|
+
}
|
|
1155
|
+
async beginSetup(e) {
|
|
1156
|
+
return lt(await this.axiosClient.post(z.twoFactorSetupBegin, {}, Je(e)));
|
|
1157
|
+
}
|
|
1158
|
+
confirmSetup(e, t) {
|
|
1159
|
+
return this.axiosClient.post(z.twoFactorSetupConfirm, e, Je(t));
|
|
1096
1160
|
}
|
|
1097
|
-
|
|
1098
|
-
return this.axiosClient.
|
|
1161
|
+
async getEnrollment(e) {
|
|
1162
|
+
return (await this.axiosClient.get(z.twoFactorEnrollment, Je(e))).enrollment;
|
|
1099
1163
|
}
|
|
1100
|
-
|
|
1101
|
-
return this.axiosClient.post(z.
|
|
1164
|
+
sendSetupLink(e) {
|
|
1165
|
+
return this.axiosClient.post(z.twoFactorEnrollmentEmailLink, void 0, Je(e));
|
|
1166
|
+
}
|
|
1167
|
+
async beginEnrollment(e) {
|
|
1168
|
+
return lt(await this.axiosClient.post(z.twoFactorEnrollmentBegin, void 0, Je(e)));
|
|
1169
|
+
}
|
|
1170
|
+
confirmEnrollment(e, t) {
|
|
1171
|
+
return this.axiosClient.post(z.twoFactorEnrollmentConfirm, t, Je(e));
|
|
1102
1172
|
}
|
|
1103
1173
|
verify(e) {
|
|
1104
1174
|
let { tfa_token: t, code: n, trust_device: r } = e;
|
|
1105
1175
|
return this.axiosClient.post(z.twoFactorVerify, {
|
|
1106
1176
|
code: n,
|
|
1107
1177
|
...r ? { trust_device: !0 } : {}
|
|
1108
|
-
},
|
|
1178
|
+
}, ct(t));
|
|
1109
1179
|
}
|
|
1110
1180
|
useRecoveryCode(e) {
|
|
1111
1181
|
let { tfa_token: t, recovery_code: n, trust_device: r } = e;
|
|
1112
1182
|
return this.axiosClient.post(z.twoFactorRecovery, {
|
|
1113
1183
|
recovery_code: n,
|
|
1114
1184
|
...r ? { trust_device: !0 } : {}
|
|
1115
|
-
},
|
|
1185
|
+
}, ct(t));
|
|
1116
1186
|
}
|
|
1117
1187
|
disable(e) {
|
|
1118
1188
|
return this.axiosClient.delete(z.twoFactor, { data: e });
|
|
@@ -1124,7 +1194,13 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1124
1194
|
let t = `${z.twoFactorSetupMagicLink}/${e}`;
|
|
1125
1195
|
return this.axiosClient.get(t, { transformRequest: [(e, t) => (t && delete t.Authorization, e)] }).then((e) => {
|
|
1126
1196
|
let t = e;
|
|
1127
|
-
return {
|
|
1197
|
+
return t.valid === !1 ? {
|
|
1198
|
+
success: !1,
|
|
1199
|
+
error: {
|
|
1200
|
+
code: "INVALID_TOKEN",
|
|
1201
|
+
message: this.getDefaultErrorMessage(400)
|
|
1202
|
+
}
|
|
1203
|
+
} : {
|
|
1128
1204
|
success: !0,
|
|
1129
1205
|
sessionToken: t.session_token,
|
|
1130
1206
|
userId: t.user_id,
|
|
@@ -1132,6 +1208,13 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1132
1208
|
appId: t.app_id
|
|
1133
1209
|
};
|
|
1134
1210
|
}).catch((e) => {
|
|
1211
|
+
if (e instanceof B) return {
|
|
1212
|
+
success: !1,
|
|
1213
|
+
error: {
|
|
1214
|
+
code: ut[e.id] ?? this.mapStatusToErrorCode(e.status),
|
|
1215
|
+
message: e.message || this.getDefaultErrorMessage(e.status)
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1135
1218
|
if (e.response) {
|
|
1136
1219
|
let t = e.response.status, n = e.response.data || {}, r = e.response.headers?.["retry-after"] ? parseInt(e.response.headers["retry-after"], 10) : void 0;
|
|
1137
1220
|
return {
|
|
@@ -1193,17 +1276,17 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1193
1276
|
return this.axiosClient.delete(t);
|
|
1194
1277
|
}
|
|
1195
1278
|
requestChallenge(e, t) {
|
|
1196
|
-
return this.axiosClient.post(z.TwoFactorChallenge, e,
|
|
1279
|
+
return this.axiosClient.post(z.TwoFactorChallenge, e, st(t));
|
|
1197
1280
|
}
|
|
1198
1281
|
verifyV2(e, t) {
|
|
1199
1282
|
let { trust_device: n, ...r } = e;
|
|
1200
1283
|
return this.axiosClient.post(z.TwoFactorVerifyV2, {
|
|
1201
1284
|
...r,
|
|
1202
1285
|
...n ? { trust_device: !0 } : {}
|
|
1203
|
-
},
|
|
1286
|
+
}, ct(t));
|
|
1204
1287
|
}
|
|
1205
1288
|
switchToAlternative(e, t) {
|
|
1206
|
-
return this.axiosClient.post(z.TwoFactorAlternative, e,
|
|
1289
|
+
return this.axiosClient.post(z.TwoFactorAlternative, e, st(t));
|
|
1207
1290
|
}
|
|
1208
1291
|
async getTrustedDevices() {
|
|
1209
1292
|
return (await this.axiosClient.get(z.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
|
|
@@ -1212,9 +1295,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1212
1295
|
let t = V(z.TwoFactorTrustedDeviceRevoke, { id: e });
|
|
1213
1296
|
return this.axiosClient.delete(t);
|
|
1214
1297
|
}
|
|
1215
|
-
},
|
|
1298
|
+
}, ft = class {
|
|
1216
1299
|
constructor(e, t, n) {
|
|
1217
|
-
this.axiosClient = new
|
|
1300
|
+
this.axiosClient = new Ye(e, t, n);
|
|
1218
1301
|
}
|
|
1219
1302
|
setAppId(e) {
|
|
1220
1303
|
this.axiosClient.setAppId(e);
|
|
@@ -1222,9 +1305,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1222
1305
|
startUpgrade(e) {
|
|
1223
1306
|
return this.axiosClient.post(z.upgradeStart, e, Ce({}));
|
|
1224
1307
|
}
|
|
1225
|
-
},
|
|
1308
|
+
}, pt = class {
|
|
1226
1309
|
constructor(e, t, n) {
|
|
1227
|
-
this.axiosClient = new
|
|
1310
|
+
this.axiosClient = new Ye(e, t, n);
|
|
1228
1311
|
}
|
|
1229
1312
|
setAppId(e) {
|
|
1230
1313
|
this.axiosClient.setAppId(e);
|
|
@@ -1255,50 +1338,50 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1255
1338
|
passkey_data: e
|
|
1256
1339
|
});
|
|
1257
1340
|
}
|
|
1258
|
-
},
|
|
1341
|
+
}, mt = 10, ht = 20, gt = class extends Error {
|
|
1259
1342
|
constructor(e) {
|
|
1260
1343
|
super(`Passflow fetch middleware '${e}' resolved without calling next(). Every registered middleware must delegate exactly once; swallowing a request would drop a caller's fetch inside the Passflow wrapper.`), this.name = "FetchMiddlewareContractError", this.middlewareName = e;
|
|
1261
1344
|
}
|
|
1262
|
-
},
|
|
1345
|
+
}, _t = [], vt = 0, yt = !1, bt, xt, St = (e, t) => e.priority - t.priority || e.seq - t.seq, Ct = () => typeof globalThis > "u" ? void 0 : globalThis, wt = async (e, t, n, r) => {
|
|
1263
1346
|
if (t >= e.length) {
|
|
1264
|
-
let e =
|
|
1347
|
+
let e = bt;
|
|
1265
1348
|
if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
|
|
1266
1349
|
return e(n, r);
|
|
1267
1350
|
}
|
|
1268
1351
|
let i = e[t];
|
|
1269
|
-
if (!i) return
|
|
1270
|
-
let a = !1, o = await i.middleware((n, r) => (a = !0,
|
|
1271
|
-
if (!a) throw new
|
|
1352
|
+
if (!i) return wt(e, e.length, n, r);
|
|
1353
|
+
let a = !1, o = await i.middleware((n, r) => (a = !0, wt(e, t + 1, n, r)), n, r);
|
|
1354
|
+
if (!a) throw new gt(i.name);
|
|
1272
1355
|
return o;
|
|
1273
|
-
},
|
|
1274
|
-
let e =
|
|
1356
|
+
}, Tt = () => {
|
|
1357
|
+
let e = Ct();
|
|
1275
1358
|
if (!e || typeof e.fetch != "function") return !1;
|
|
1276
|
-
let t = e.fetch.bind(e), n = (e, t) =>
|
|
1277
|
-
return
|
|
1278
|
-
},
|
|
1279
|
-
let e =
|
|
1280
|
-
e &&
|
|
1281
|
-
},
|
|
1282
|
-
if (!
|
|
1359
|
+
let t = e.fetch.bind(e), n = (e, t) => wt([..._t].sort(St), 0, e, t);
|
|
1360
|
+
return bt = t, xt = n, e.fetch = n, yt = !0, !0;
|
|
1361
|
+
}, Et = () => {
|
|
1362
|
+
let e = Ct();
|
|
1363
|
+
e && xt && e.fetch === xt && (bt && (e.fetch = bt), yt = !1, xt = void 0, bt = void 0);
|
|
1364
|
+
}, Dt = (e, t) => {
|
|
1365
|
+
if (!yt && !Tt()) return () => {};
|
|
1283
1366
|
let n = {
|
|
1284
1367
|
middleware: e,
|
|
1285
1368
|
name: t.name,
|
|
1286
1369
|
priority: t.priority,
|
|
1287
|
-
seq:
|
|
1370
|
+
seq: vt++
|
|
1288
1371
|
};
|
|
1289
|
-
|
|
1372
|
+
_t.push(n);
|
|
1290
1373
|
let r = !1;
|
|
1291
1374
|
return () => {
|
|
1292
|
-
r || (r = !0,
|
|
1375
|
+
r || (r = !0, _t = _t.filter((e) => e !== n), _t.length === 0 && Et());
|
|
1293
1376
|
};
|
|
1294
|
-
},
|
|
1295
|
-
let e =
|
|
1377
|
+
}, Ot = () => {
|
|
1378
|
+
let e = Ct();
|
|
1296
1379
|
return {
|
|
1297
|
-
installed:
|
|
1298
|
-
names: [...
|
|
1299
|
-
foreignPatch:
|
|
1380
|
+
installed: yt,
|
|
1381
|
+
names: [..._t].sort(St).map((e) => e.name),
|
|
1382
|
+
foreignPatch: yt && !!e && !!xt && e.fetch !== xt
|
|
1300
1383
|
};
|
|
1301
|
-
},
|
|
1384
|
+
}, H = class e extends Error {
|
|
1302
1385
|
constructor(t) {
|
|
1303
1386
|
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);
|
|
1304
1387
|
}
|
|
@@ -1367,7 +1450,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1367
1450
|
let e = `M2MError [${this.code}]: ${this.message}`;
|
|
1368
1451
|
return this.status && (e += ` (HTTP ${this.status})`), e;
|
|
1369
1452
|
}
|
|
1370
|
-
},
|
|
1453
|
+
}, kt = class extends H {
|
|
1371
1454
|
constructor(e, t) {
|
|
1372
1455
|
super({
|
|
1373
1456
|
code: "temporarily_unavailable",
|
|
@@ -1376,7 +1459,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1376
1459
|
cause: t
|
|
1377
1460
|
}), this.name = "M2MNetworkError";
|
|
1378
1461
|
}
|
|
1379
|
-
},
|
|
1462
|
+
}, At = class extends H {
|
|
1380
1463
|
constructor(e, t) {
|
|
1381
1464
|
super({
|
|
1382
1465
|
code: "invalid_request",
|
|
@@ -1385,7 +1468,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1385
1468
|
cause: t
|
|
1386
1469
|
}), this.name = "M2MTokenParseError";
|
|
1387
1470
|
}
|
|
1388
|
-
},
|
|
1471
|
+
}, jt = class extends H {
|
|
1389
1472
|
constructor(e) {
|
|
1390
1473
|
super({
|
|
1391
1474
|
code: "invalid_request",
|
|
@@ -1393,7 +1476,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1393
1476
|
status: 400
|
|
1394
1477
|
}), this.name = "M2MConfigError";
|
|
1395
1478
|
}
|
|
1396
|
-
},
|
|
1479
|
+
}, Mt = {
|
|
1397
1480
|
InvalidRequest: "invalid_request",
|
|
1398
1481
|
InvalidClient: "invalid_client",
|
|
1399
1482
|
InvalidGrant: "invalid_grant",
|
|
@@ -1403,14 +1486,14 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1403
1486
|
RateLimitExceeded: "rate_limit_exceeded",
|
|
1404
1487
|
ServerError: "server_error",
|
|
1405
1488
|
TemporarilyUnavailable: "temporarily_unavailable"
|
|
1406
|
-
},
|
|
1489
|
+
}, Nt = {
|
|
1407
1490
|
TOKEN_ENDPOINT: "/oauth2/token",
|
|
1408
1491
|
TIMEOUT: 1e4,
|
|
1409
1492
|
RETRIES: 3,
|
|
1410
1493
|
RETRY_DELAY: 1e3,
|
|
1411
1494
|
REFRESH_THRESHOLD: 30,
|
|
1412
1495
|
CONTENT_TYPE: "application/x-www-form-urlencoded"
|
|
1413
|
-
},
|
|
1496
|
+
}, Pt = class {
|
|
1414
1497
|
constructor() {
|
|
1415
1498
|
this.cache = /* @__PURE__ */ new Map();
|
|
1416
1499
|
}
|
|
@@ -1427,18 +1510,18 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1427
1510
|
delete(e) {
|
|
1428
1511
|
return this.cache.delete(e), Promise.resolve();
|
|
1429
1512
|
}
|
|
1430
|
-
},
|
|
1513
|
+
}, Ft = {
|
|
1431
1514
|
shouldRetry(e, t) {
|
|
1432
1515
|
return t >= 3 ? !1 : e.code === "server_error" || e.code === "temporarily_unavailable" || e.code === "rate_limit_exceeded" || e.status !== void 0 && e.status >= 500;
|
|
1433
1516
|
},
|
|
1434
1517
|
getDelay(e) {
|
|
1435
1518
|
return 2 ** (e - 1) * 1e3;
|
|
1436
1519
|
}
|
|
1437
|
-
},
|
|
1520
|
+
}, It = class {
|
|
1438
1521
|
constructor(e) {
|
|
1439
|
-
if (!e.url) throw new
|
|
1440
|
-
if (!e.clientId) throw new
|
|
1441
|
-
if (!e.clientSecret) throw new
|
|
1522
|
+
if (!e.url) throw new jt("M2M client requires a URL");
|
|
1523
|
+
if (!e.clientId) throw new jt("M2M client requires a clientId");
|
|
1524
|
+
if (!e.clientSecret) throw new jt("M2M client requires a clientSecret");
|
|
1442
1525
|
let t = e.url.replace(/\/$/, "");
|
|
1443
1526
|
this.config = {
|
|
1444
1527
|
url: t,
|
|
@@ -1447,16 +1530,16 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1447
1530
|
scopes: e.scopes,
|
|
1448
1531
|
audience: e.audience,
|
|
1449
1532
|
autoRefresh: e.autoRefresh ?? !1,
|
|
1450
|
-
refreshThreshold: e.refreshThreshold ??
|
|
1451
|
-
timeout: e.timeout ??
|
|
1452
|
-
retries: e.retries ??
|
|
1453
|
-
retryDelay: e.retryDelay ??
|
|
1533
|
+
refreshThreshold: e.refreshThreshold ?? Nt.REFRESH_THRESHOLD,
|
|
1534
|
+
timeout: e.timeout ?? Nt.TIMEOUT,
|
|
1535
|
+
retries: e.retries ?? Nt.RETRIES,
|
|
1536
|
+
retryDelay: e.retryDelay ?? Nt.RETRY_DELAY,
|
|
1454
1537
|
retryStrategy: e.retryStrategy,
|
|
1455
1538
|
cache: e.cache,
|
|
1456
1539
|
onTokenRequest: e.onTokenRequest,
|
|
1457
1540
|
onTokenResponse: e.onTokenResponse,
|
|
1458
1541
|
onError: e.onError
|
|
1459
|
-
}, this.cache = e.cache ?? new
|
|
1542
|
+
}, this.cache = e.cache ?? new Pt(), this.retryStrategy = e.retryStrategy ?? Ft, this.tokenEndpoint = `${t}${Nt.TOKEN_ENDPOINT}`;
|
|
1460
1543
|
}
|
|
1461
1544
|
getCacheKey(e, t) {
|
|
1462
1545
|
let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
|
|
@@ -1501,7 +1584,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1501
1584
|
let e = await fetch(this.tokenEndpoint, {
|
|
1502
1585
|
method: "POST",
|
|
1503
1586
|
headers: {
|
|
1504
|
-
"Content-Type":
|
|
1587
|
+
"Content-Type": Nt.CONTENT_TYPE,
|
|
1505
1588
|
Accept: "application/json"
|
|
1506
1589
|
},
|
|
1507
1590
|
body: t.toString(),
|
|
@@ -1514,7 +1597,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1514
1597
|
});
|
|
1515
1598
|
let a = await e.json();
|
|
1516
1599
|
if (!e.ok) {
|
|
1517
|
-
let t =
|
|
1600
|
+
let t = H.fromOAuthError({
|
|
1518
1601
|
error: a.error || "server_error",
|
|
1519
1602
|
error_description: a.error_description || a.message,
|
|
1520
1603
|
error_uri: a.error_uri
|
|
@@ -1526,7 +1609,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1526
1609
|
}
|
|
1527
1610
|
return a;
|
|
1528
1611
|
} catch (e) {
|
|
1529
|
-
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new
|
|
1612
|
+
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new kt(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new kt(`Network error: ${e.message}`, e) : e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1530
1613
|
}
|
|
1531
1614
|
}
|
|
1532
1615
|
async executeWithRetry(e) {
|
|
@@ -1534,7 +1617,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1534
1617
|
for (let n = 1; n <= this.config.retries; n++) try {
|
|
1535
1618
|
return await e();
|
|
1536
1619
|
} catch (e) {
|
|
1537
|
-
if (!(e instanceof
|
|
1620
|
+
if (!(e instanceof H)) throw e;
|
|
1538
1621
|
if (t = e, n < this.config.retries && this.retryStrategy.shouldRetry({
|
|
1539
1622
|
code: e.code,
|
|
1540
1623
|
status: e.status
|
|
@@ -1545,7 +1628,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1545
1628
|
}
|
|
1546
1629
|
throw e;
|
|
1547
1630
|
}
|
|
1548
|
-
throw t ?? new
|
|
1631
|
+
throw t ?? new H({
|
|
1549
1632
|
code: "server_error",
|
|
1550
1633
|
message: "Request failed after retries"
|
|
1551
1634
|
});
|
|
@@ -1569,13 +1652,13 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1569
1652
|
parseToken(e) {
|
|
1570
1653
|
try {
|
|
1571
1654
|
let t = e.split(".");
|
|
1572
|
-
if (t.length !== 3) throw new
|
|
1655
|
+
if (t.length !== 3) throw new At("Invalid JWT format: expected 3 parts");
|
|
1573
1656
|
let n = t[1];
|
|
1574
|
-
if (!n) throw new
|
|
1657
|
+
if (!n) throw new At("Invalid JWT format: missing payload");
|
|
1575
1658
|
let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
|
|
1576
1659
|
return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
|
|
1577
1660
|
} catch (e) {
|
|
1578
|
-
throw e instanceof
|
|
1661
|
+
throw e instanceof At ? e : new At(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
1579
1662
|
}
|
|
1580
1663
|
}
|
|
1581
1664
|
clearCache() {
|
|
@@ -1590,19 +1673,19 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1590
1673
|
try {
|
|
1591
1674
|
let e = await fetch(t, {
|
|
1592
1675
|
method: "POST",
|
|
1593
|
-
headers: { "Content-Type":
|
|
1676
|
+
headers: { "Content-Type": Nt.CONTENT_TYPE },
|
|
1594
1677
|
body: n.toString()
|
|
1595
1678
|
});
|
|
1596
1679
|
if (!e.ok && e.status !== 200) {
|
|
1597
1680
|
let t = await e.json().catch(() => ({}));
|
|
1598
|
-
throw
|
|
1681
|
+
throw H.fromOAuthError({
|
|
1599
1682
|
error: t.error || "server_error",
|
|
1600
1683
|
error_description: t.error_description || "Token revocation failed"
|
|
1601
1684
|
}, e.status);
|
|
1602
1685
|
}
|
|
1603
1686
|
this.clearCache();
|
|
1604
1687
|
} catch (e) {
|
|
1605
|
-
throw e instanceof
|
|
1688
|
+
throw e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1606
1689
|
}
|
|
1607
1690
|
}
|
|
1608
1691
|
get url() {
|
|
@@ -1617,101 +1700,101 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1617
1700
|
get audience() {
|
|
1618
1701
|
return this.config.audience;
|
|
1619
1702
|
}
|
|
1620
|
-
},
|
|
1703
|
+
}, Lt = "error", Rt = /* @__PURE__ */ new WeakMap(), zt = (e, t) => {
|
|
1621
1704
|
if (typeof t != "object" && typeof t != "function" || t === null) return !0;
|
|
1622
|
-
let n =
|
|
1623
|
-
return n || (n = /* @__PURE__ */ new WeakSet(),
|
|
1624
|
-
},
|
|
1705
|
+
let n = Rt.get(e);
|
|
1706
|
+
return n || (n = /* @__PURE__ */ new WeakSet(), Rt.set(e, n)), !n.has(t) && (n.add(t), !0);
|
|
1707
|
+
}, U = (e, t) => zt(e, t.originalError) ? (e.notify(Lt, t), !0) : !1, Bt = "passflow-refresh", Vt = "passflow-refresh-takeover", Ht = "passflow-auth", Ut = Object.freeze([
|
|
1625
1708
|
1e3,
|
|
1626
1709
|
3e3,
|
|
1627
1710
|
1e4,
|
|
1628
1711
|
3e4,
|
|
1629
1712
|
6e4
|
|
1630
|
-
]),
|
|
1713
|
+
]), Wt = .2, Gt = 6e5, Kt = 5e3, W = 2e4, qt = 2e4, Jt = 1e3, Yt = 2e3, Xt = 1e3, Zt = 1e4, Qt = 5e3;
|
|
1631
1714
|
// lib/refresh/protocol.ts
|
|
1632
|
-
function
|
|
1715
|
+
function $t(e) {
|
|
1633
1716
|
let t = e ? `:${e}` : "";
|
|
1634
1717
|
return {
|
|
1635
|
-
lock: `${
|
|
1636
|
-
takeoverLock: `${
|
|
1637
|
-
channel: `${
|
|
1718
|
+
lock: `${Bt}${t}`,
|
|
1719
|
+
takeoverLock: `${Vt}${t}`,
|
|
1720
|
+
channel: `${Ht}${t}`
|
|
1638
1721
|
};
|
|
1639
1722
|
}
|
|
1640
|
-
function
|
|
1723
|
+
function G(e) {
|
|
1641
1724
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
1642
1725
|
}
|
|
1643
|
-
function
|
|
1726
|
+
function en(e) {
|
|
1644
1727
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
1645
1728
|
}
|
|
1646
|
-
function
|
|
1729
|
+
function tn(e) {
|
|
1647
1730
|
return typeof e == "object" && !!e;
|
|
1648
1731
|
}
|
|
1649
|
-
function
|
|
1732
|
+
function nn(e, t) {
|
|
1650
1733
|
for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
|
|
1651
1734
|
return e;
|
|
1652
1735
|
}
|
|
1653
|
-
function
|
|
1654
|
-
if (!
|
|
1736
|
+
function rn(e) {
|
|
1737
|
+
if (!tn(e)) return null;
|
|
1655
1738
|
let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
|
|
1656
|
-
return
|
|
1657
|
-
access_token:
|
|
1658
|
-
refresh_token:
|
|
1659
|
-
id_token:
|
|
1739
|
+
return nn({}, {
|
|
1740
|
+
access_token: G(e.access_token),
|
|
1741
|
+
refresh_token: G(e.refresh_token),
|
|
1742
|
+
id_token: G(e.id_token),
|
|
1660
1743
|
scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
|
|
1661
1744
|
});
|
|
1662
1745
|
}
|
|
1663
|
-
function
|
|
1664
|
-
if (!
|
|
1746
|
+
function an(e) {
|
|
1747
|
+
if (!tn(e)) return null;
|
|
1665
1748
|
let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
|
|
1666
|
-
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 ||
|
|
1749
|
+
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || en(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : nn({
|
|
1667
1750
|
kind: t,
|
|
1668
1751
|
attempt: n,
|
|
1669
1752
|
nextAt: r,
|
|
1670
1753
|
strikes: i
|
|
1671
1754
|
}, {
|
|
1672
|
-
from:
|
|
1673
|
-
failingSince:
|
|
1755
|
+
from: G(e.from),
|
|
1756
|
+
failingSince: en(e.failingSince)
|
|
1674
1757
|
});
|
|
1675
1758
|
}
|
|
1676
|
-
function
|
|
1677
|
-
return
|
|
1678
|
-
fp:
|
|
1679
|
-
sub:
|
|
1680
|
-
sid:
|
|
1681
|
-
iat:
|
|
1759
|
+
function on(e) {
|
|
1760
|
+
return nn({}, {
|
|
1761
|
+
fp: G(e.fp),
|
|
1762
|
+
sub: G(e.sub),
|
|
1763
|
+
sid: G(e.sid),
|
|
1764
|
+
iat: en(e.iat)
|
|
1682
1765
|
});
|
|
1683
1766
|
}
|
|
1684
|
-
function
|
|
1685
|
-
if (!
|
|
1767
|
+
function sn(e) {
|
|
1768
|
+
if (!tn(e)) return null;
|
|
1686
1769
|
let t = e;
|
|
1687
1770
|
if (t.v !== void 0 && t.v !== 1) return null;
|
|
1688
|
-
let n =
|
|
1771
|
+
let n = G(t.tabId);
|
|
1689
1772
|
if (!n) return null;
|
|
1690
1773
|
switch (t.type) {
|
|
1691
1774
|
case "tokens-refreshed": {
|
|
1692
|
-
let e =
|
|
1693
|
-
return !e || !r || !i ? null :
|
|
1775
|
+
let e = rn(t.tokens), r = G(t.from), i = G(t.to);
|
|
1776
|
+
return !e || !r || !i ? null : nn({
|
|
1694
1777
|
type: t.type,
|
|
1695
1778
|
tabId: n,
|
|
1696
1779
|
tokens: e,
|
|
1697
1780
|
from: r,
|
|
1698
1781
|
to: i
|
|
1699
1782
|
}, {
|
|
1700
|
-
fromIat:
|
|
1783
|
+
fromIat: en(t.fromIat),
|
|
1701
1784
|
fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
|
|
1702
|
-
sentAt:
|
|
1785
|
+
sentAt: en(t.sentAt)
|
|
1703
1786
|
});
|
|
1704
1787
|
}
|
|
1705
1788
|
case "session-refreshed": {
|
|
1706
|
-
let e =
|
|
1707
|
-
return e === void 0 ? null :
|
|
1789
|
+
let e = en(t.at);
|
|
1790
|
+
return e === void 0 ? null : nn({
|
|
1708
1791
|
type: t.type,
|
|
1709
1792
|
tabId: n,
|
|
1710
1793
|
at: e
|
|
1711
|
-
}, { sub:
|
|
1794
|
+
}, { sub: G(t.sub) });
|
|
1712
1795
|
}
|
|
1713
1796
|
case "still-refreshing": {
|
|
1714
|
-
let e = t.retry === void 0 ? null :
|
|
1797
|
+
let e = t.retry === void 0 ? null : an(t.retry);
|
|
1715
1798
|
return e ? {
|
|
1716
1799
|
type: t.type,
|
|
1717
1800
|
tabId: n,
|
|
@@ -1722,7 +1805,7 @@ function Xt(e) {
|
|
|
1722
1805
|
};
|
|
1723
1806
|
}
|
|
1724
1807
|
case "retry-scheduled": {
|
|
1725
|
-
let e =
|
|
1808
|
+
let e = an(t);
|
|
1726
1809
|
return e ? {
|
|
1727
1810
|
type: t.type,
|
|
1728
1811
|
tabId: n,
|
|
@@ -1743,10 +1826,10 @@ function Xt(e) {
|
|
|
1743
1826
|
case "signed-out": return {
|
|
1744
1827
|
type: t.type,
|
|
1745
1828
|
tabId: n,
|
|
1746
|
-
...
|
|
1829
|
+
...on(t)
|
|
1747
1830
|
};
|
|
1748
1831
|
case "rate-limited": {
|
|
1749
|
-
let e =
|
|
1832
|
+
let e = en(t.until);
|
|
1750
1833
|
return e === void 0 ? null : {
|
|
1751
1834
|
type: t.type,
|
|
1752
1835
|
tabId: n,
|
|
@@ -1754,7 +1837,7 @@ function Xt(e) {
|
|
|
1754
1837
|
};
|
|
1755
1838
|
}
|
|
1756
1839
|
case "refresh-failed": {
|
|
1757
|
-
let e =
|
|
1840
|
+
let e = G(t.from);
|
|
1758
1841
|
return e ? {
|
|
1759
1842
|
type: t.type,
|
|
1760
1843
|
tabId: n,
|
|
@@ -1765,22 +1848,22 @@ function Xt(e) {
|
|
|
1765
1848
|
default: return null;
|
|
1766
1849
|
}
|
|
1767
1850
|
}
|
|
1768
|
-
function
|
|
1851
|
+
function cn(e, t) {
|
|
1769
1852
|
let n = {
|
|
1770
1853
|
v: 1,
|
|
1771
1854
|
tabId: e
|
|
1772
1855
|
};
|
|
1773
1856
|
if (t.type === "retry-scheduled") {
|
|
1774
1857
|
let { retry: e, ...r } = t;
|
|
1775
|
-
return
|
|
1858
|
+
return nn(n, {
|
|
1776
1859
|
...r,
|
|
1777
1860
|
...e
|
|
1778
1861
|
});
|
|
1779
1862
|
}
|
|
1780
|
-
return
|
|
1863
|
+
return nn(n, { ...t });
|
|
1781
1864
|
}
|
|
1782
1865
|
// lib/refresh/resolve.ts
|
|
1783
|
-
var
|
|
1866
|
+
var ln = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", un = {
|
|
1784
1867
|
now: () => Date.now(),
|
|
1785
1868
|
random: () => Math.random(),
|
|
1786
1869
|
setTimeout: (e, t) => {
|
|
@@ -1788,28 +1871,28 @@ var Qt = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
|
|
|
1788
1871
|
return n.unref?.(), () => clearTimeout(n);
|
|
1789
1872
|
}
|
|
1790
1873
|
};
|
|
1791
|
-
function
|
|
1874
|
+
function dn() {
|
|
1792
1875
|
let e = globalThis.crypto;
|
|
1793
1876
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
1794
1877
|
}
|
|
1795
|
-
function
|
|
1878
|
+
function fn(e) {
|
|
1796
1879
|
return e ? {
|
|
1797
1880
|
now: () => e.now(),
|
|
1798
1881
|
setTimeout: (t, n) => e.setTimeout(t, n),
|
|
1799
|
-
random: e.random ? () => e.random?.() ?? Math.random() :
|
|
1800
|
-
} :
|
|
1882
|
+
random: e.random ? () => e.random?.() ?? Math.random() : un.random
|
|
1883
|
+
} : un;
|
|
1801
1884
|
}
|
|
1802
|
-
function
|
|
1885
|
+
function pn(e) {
|
|
1803
1886
|
return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
|
|
1804
1887
|
}
|
|
1805
|
-
function
|
|
1888
|
+
function mn(e) {
|
|
1806
1889
|
try {
|
|
1807
1890
|
return e.storageSharedAcrossTabs === !0;
|
|
1808
1891
|
} catch {
|
|
1809
1892
|
return !1;
|
|
1810
1893
|
}
|
|
1811
1894
|
}
|
|
1812
|
-
function
|
|
1895
|
+
function hn() {
|
|
1813
1896
|
try {
|
|
1814
1897
|
let e = globalThis.navigator?.locks;
|
|
1815
1898
|
return e && typeof e.request == "function" ? e : void 0;
|
|
@@ -1817,7 +1900,7 @@ function an() {
|
|
|
1817
1900
|
return;
|
|
1818
1901
|
}
|
|
1819
1902
|
}
|
|
1820
|
-
function
|
|
1903
|
+
function gn(e) {
|
|
1821
1904
|
return (t) => {
|
|
1822
1905
|
let n = (n) => {
|
|
1823
1906
|
let r = n.key;
|
|
@@ -1826,20 +1909,20 @@ function on(e) {
|
|
|
1826
1909
|
return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
|
|
1827
1910
|
};
|
|
1828
1911
|
}
|
|
1829
|
-
function
|
|
1912
|
+
function _n(e) {
|
|
1830
1913
|
return {
|
|
1831
1914
|
transports: null,
|
|
1832
|
-
names:
|
|
1833
|
-
clock:
|
|
1915
|
+
names: $t(e),
|
|
1916
|
+
clock: un,
|
|
1834
1917
|
warnOnFirstCycle: !1
|
|
1835
1918
|
};
|
|
1836
1919
|
}
|
|
1837
|
-
function
|
|
1838
|
-
let i =
|
|
1920
|
+
function vn(e, t, n, r) {
|
|
1921
|
+
let i = $t(n), a = pn(t), o = a ? gn(r.tokenKeys) : void 0, s = (e) => {
|
|
1839
1922
|
let t = {
|
|
1840
1923
|
transports: null,
|
|
1841
1924
|
names: i,
|
|
1842
|
-
clock:
|
|
1925
|
+
clock: un,
|
|
1843
1926
|
warnOnFirstCycle: e
|
|
1844
1927
|
};
|
|
1845
1928
|
return o && (t.onStorageChange = o), t;
|
|
@@ -1849,16 +1932,16 @@ function cn(e, t, n, r) {
|
|
|
1849
1932
|
transports: {
|
|
1850
1933
|
locks: e.locks,
|
|
1851
1934
|
channel: e.channel,
|
|
1852
|
-
tabId: e.tabId ??
|
|
1935
|
+
tabId: e.tabId ?? dn()
|
|
1853
1936
|
},
|
|
1854
1937
|
names: i,
|
|
1855
|
-
clock:
|
|
1938
|
+
clock: fn(e.clock),
|
|
1856
1939
|
warnOnFirstCycle: !1
|
|
1857
1940
|
};
|
|
1858
1941
|
return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
|
|
1859
1942
|
}
|
|
1860
|
-
if (e === "none" || !a || !
|
|
1861
|
-
let c =
|
|
1943
|
+
if (e === "none" || !a || !mn(t)) return s(!1);
|
|
1944
|
+
let c = hn();
|
|
1862
1945
|
if (!c || typeof BroadcastChannel != "function") return s(!0);
|
|
1863
1946
|
let l;
|
|
1864
1947
|
try {
|
|
@@ -1870,36 +1953,36 @@ function cn(e, t, n, r) {
|
|
|
1870
1953
|
transports: {
|
|
1871
1954
|
locks: c,
|
|
1872
1955
|
channel: l,
|
|
1873
|
-
tabId:
|
|
1956
|
+
tabId: dn()
|
|
1874
1957
|
},
|
|
1875
1958
|
names: i,
|
|
1876
|
-
clock:
|
|
1959
|
+
clock: un,
|
|
1877
1960
|
warnOnFirstCycle: !1
|
|
1878
1961
|
};
|
|
1879
1962
|
return o && (u.onStorageChange = o), u;
|
|
1880
1963
|
}
|
|
1881
1964
|
// lib/pkce.ts
|
|
1882
|
-
var
|
|
1965
|
+
var yn = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bn = 32, xn = (e) => {
|
|
1883
1966
|
let t = "";
|
|
1884
1967
|
for (let n = 0; n < e.length; n += 3) {
|
|
1885
1968
|
let r = e[n], i = e[n + 1], a = e[n + 2];
|
|
1886
|
-
t +=
|
|
1969
|
+
t += yn.charAt(r >> 2), t += yn.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += yn.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += yn.charAt(a & 63));
|
|
1887
1970
|
}
|
|
1888
1971
|
return t;
|
|
1889
|
-
},
|
|
1972
|
+
}, Sn = () => {
|
|
1890
1973
|
let e = globalThis.crypto;
|
|
1891
1974
|
if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1892
1975
|
return e;
|
|
1893
|
-
},
|
|
1894
|
-
let t = await
|
|
1895
|
-
return
|
|
1896
|
-
},
|
|
1897
|
-
let e =
|
|
1976
|
+
}, Cn = async (e) => {
|
|
1977
|
+
let t = await Sn().subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
1978
|
+
return xn(new Uint8Array(t));
|
|
1979
|
+
}, wn = async () => {
|
|
1980
|
+
let e = xn(Sn().getRandomValues(new Uint8Array(bn)));
|
|
1898
1981
|
return {
|
|
1899
1982
|
verifier: e,
|
|
1900
|
-
challenge: await
|
|
1983
|
+
challenge: await Cn(e)
|
|
1901
1984
|
};
|
|
1902
|
-
},
|
|
1985
|
+
}, Tn = class {
|
|
1903
1986
|
error(e, ...t) {
|
|
1904
1987
|
console.error(e, ...t);
|
|
1905
1988
|
}
|
|
@@ -1913,10 +1996,10 @@ var ln = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", un
|
|
|
1913
1996
|
console.debug(e, ...t);
|
|
1914
1997
|
}
|
|
1915
1998
|
};
|
|
1916
|
-
function
|
|
1917
|
-
return new
|
|
1999
|
+
function En() {
|
|
2000
|
+
return new Tn();
|
|
1918
2001
|
}
|
|
1919
|
-
var
|
|
2002
|
+
var Dn = Object.freeze([
|
|
1920
2003
|
"error.token.invalid.error",
|
|
1921
2004
|
"error.api.token.parse.error",
|
|
1922
2005
|
"error.api.user.blocked",
|
|
@@ -1924,25 +2007,25 @@ var _n = Object.freeze([
|
|
|
1924
2007
|
"error.validation.token.invalid.subject",
|
|
1925
2008
|
"error.not.found"
|
|
1926
2009
|
]);
|
|
1927
|
-
function
|
|
2010
|
+
function On(e) {
|
|
1928
2011
|
if (typeof e != "object" || !e) return;
|
|
1929
2012
|
let t = e;
|
|
1930
2013
|
return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
|
|
1931
2014
|
}
|
|
1932
|
-
function
|
|
1933
|
-
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(
|
|
2015
|
+
function kn(e, t) {
|
|
2016
|
+
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(Gt, Math.floor(e) * 1e3);
|
|
1934
2017
|
if (typeof e != "string") return;
|
|
1935
2018
|
let n = e.trim();
|
|
1936
2019
|
if (n === "") return;
|
|
1937
|
-
if (/^\d+$/.test(n)) return Math.min(
|
|
2020
|
+
if (/^\d+$/.test(n)) return Math.min(Gt, Number.parseInt(n, 10) * 1e3);
|
|
1938
2021
|
if (!/[a-z]/i.test(n)) return;
|
|
1939
2022
|
let r = Date.parse(n);
|
|
1940
|
-
if (!Number.isNaN(r)) return Math.min(
|
|
2023
|
+
if (!Number.isNaN(r)) return Math.min(Gt, Math.max(0, r - t));
|
|
1941
2024
|
}
|
|
1942
|
-
function
|
|
2025
|
+
function An(e) {
|
|
1943
2026
|
return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
|
|
1944
2027
|
}
|
|
1945
|
-
function
|
|
2028
|
+
function jn(e) {
|
|
1946
2029
|
if (typeof e.id == "string" && e.id !== "") return e.id;
|
|
1947
2030
|
let t = e.response?.data;
|
|
1948
2031
|
if (typeof t != "object" || !t) return;
|
|
@@ -1951,14 +2034,14 @@ function xn(e) {
|
|
|
1951
2034
|
let r = n.id;
|
|
1952
2035
|
return typeof r == "string" && r !== "" ? r : void 0;
|
|
1953
2036
|
}
|
|
1954
|
-
function
|
|
2037
|
+
function Mn(e, t = Date.now()) {
|
|
1955
2038
|
if (typeof e != "object" || !e) return { kind: "transient" };
|
|
1956
|
-
let n = e, r =
|
|
2039
|
+
let n = e, r = jn(n), i = An(n.response?.status) ?? An(n.status), a = {};
|
|
1957
2040
|
if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
|
|
1958
2041
|
kind: "blocked",
|
|
1959
2042
|
...a
|
|
1960
2043
|
};
|
|
1961
|
-
if (r !== void 0 &&
|
|
2044
|
+
if (r !== void 0 && Dn.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
|
|
1962
2045
|
kind: "auth",
|
|
1963
2046
|
...a
|
|
1964
2047
|
};
|
|
@@ -1966,7 +2049,7 @@ function Sn(e, t = Date.now()) {
|
|
|
1966
2049
|
kind: "transient",
|
|
1967
2050
|
...a
|
|
1968
2051
|
};
|
|
1969
|
-
let o =
|
|
2052
|
+
let o = kn(n.retryAfter ?? On(n.response?.headers), t);
|
|
1970
2053
|
return o === void 0 ? {
|
|
1971
2054
|
kind: "transient",
|
|
1972
2055
|
...a
|
|
@@ -1976,19 +2059,19 @@ function Sn(e, t = Date.now()) {
|
|
|
1976
2059
|
retryAfterMs: o
|
|
1977
2060
|
};
|
|
1978
2061
|
}
|
|
1979
|
-
function
|
|
1980
|
-
let r =
|
|
1981
|
-
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0),
|
|
2062
|
+
function Nn(e, t, n) {
|
|
2063
|
+
let r = Ut.length, i = Ut[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? Ut[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * Wt * a);
|
|
2064
|
+
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), Gt) : 0);
|
|
1982
2065
|
}
|
|
1983
2066
|
// lib/refresh/coordinator.ts
|
|
1984
|
-
var
|
|
2067
|
+
var Pn = {
|
|
1985
2068
|
onGranted: () => !1,
|
|
1986
2069
|
onLockLost: () => void 0,
|
|
1987
2070
|
onMessage: () => void 0
|
|
1988
2071
|
};
|
|
1989
|
-
function
|
|
1990
|
-
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o =
|
|
1991
|
-
g || n.postMessage(
|
|
2072
|
+
function Fn(e) {
|
|
2073
|
+
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = Pn, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
|
|
2074
|
+
g || n.postMessage(cn(r, e));
|
|
1992
2075
|
}, v = () => s !== null && c === null, y = () => {
|
|
1993
2076
|
f?.(), f = null;
|
|
1994
2077
|
}, b = (e) => {
|
|
@@ -2003,7 +2086,7 @@ function Tn(e) {
|
|
|
2003
2086
|
type: "still-refreshing",
|
|
2004
2087
|
retry: m
|
|
2005
2088
|
} : { type: "still-refreshing" }), S());
|
|
2006
|
-
},
|
|
2089
|
+
}, Kt);
|
|
2007
2090
|
}, C = () => {
|
|
2008
2091
|
y(), x(), u?.(), u = null;
|
|
2009
2092
|
let e = s;
|
|
@@ -2044,29 +2127,29 @@ function Tn(e) {
|
|
|
2044
2127
|
let e = s;
|
|
2045
2128
|
t.request(i.takeoverLock, { ifAvailable: !0 }, (t) => {
|
|
2046
2129
|
if (s === e && v()) {
|
|
2047
|
-
if (t === null) b(a.now() +
|
|
2130
|
+
if (t === null) b(a.now() + W);
|
|
2048
2131
|
else return _({ type: "takeover" }), new Promise((t) => {
|
|
2049
2132
|
u = t, e && (e.dead = !0, e.abort.abort()), D(!0);
|
|
2050
2133
|
});
|
|
2051
2134
|
}
|
|
2052
2135
|
}).catch(() => {
|
|
2053
|
-
v() && b(a.now() +
|
|
2136
|
+
v() && b(a.now() + W);
|
|
2054
2137
|
});
|
|
2055
2138
|
}, ee = (e) => {
|
|
2056
2139
|
if (g) return;
|
|
2057
|
-
let t =
|
|
2140
|
+
let t = sn(e.data);
|
|
2058
2141
|
if (t && t.tabId !== r) {
|
|
2059
2142
|
switch (t.type) {
|
|
2060
2143
|
case "still-refreshing":
|
|
2061
|
-
h = !0, v() && (b(a.now() +
|
|
2144
|
+
h = !0, v() && (b(a.now() + W), t.retry && b(t.retry.nextAt + W));
|
|
2062
2145
|
break;
|
|
2063
2146
|
case "takeover":
|
|
2064
|
-
h = !0, v() && b(a.now() +
|
|
2147
|
+
h = !0, v() && b(a.now() + W);
|
|
2065
2148
|
break;
|
|
2066
2149
|
case "retry-scheduled":
|
|
2067
|
-
h = !0, v() && b(Math.max(a.now(), t.retry.nextAt) +
|
|
2150
|
+
h = !0, v() && b(Math.max(a.now(), t.retry.nextAt) + W);
|
|
2068
2151
|
break;
|
|
2069
|
-
case "rate-limited": v() && b(t.until +
|
|
2152
|
+
case "rate-limited": v() && b(t.until + W);
|
|
2070
2153
|
}
|
|
2071
2154
|
o.onMessage(t);
|
|
2072
2155
|
}
|
|
@@ -2084,7 +2167,7 @@ function Tn(e) {
|
|
|
2084
2167
|
o = e;
|
|
2085
2168
|
},
|
|
2086
2169
|
request: (e) => {
|
|
2087
|
-
g || s || (p = 0, b(Math.max(a.now() +
|
|
2170
|
+
g || s || (p = 0, b(Math.max(a.now() + W, e ?? 0)), D(!1));
|
|
2088
2171
|
},
|
|
2089
2172
|
release: C,
|
|
2090
2173
|
post: _,
|
|
@@ -2097,8 +2180,8 @@ function Tn(e) {
|
|
|
2097
2180
|
}
|
|
2098
2181
|
};
|
|
2099
2182
|
}
|
|
2100
|
-
function
|
|
2101
|
-
let t =
|
|
2183
|
+
function In(e = "local") {
|
|
2184
|
+
let t = Pn, n = !1, r = !1, i = 0, a = !1, o = () => {
|
|
2102
2185
|
n = !1, r = !1, i += 1;
|
|
2103
2186
|
};
|
|
2104
2187
|
return {
|
|
@@ -2138,7 +2221,7 @@ function En(e = "local") {
|
|
|
2138
2221
|
};
|
|
2139
2222
|
}
|
|
2140
2223
|
// lib/refresh/errors.ts
|
|
2141
|
-
var
|
|
2224
|
+
var K = {
|
|
2142
2225
|
unavailable: "error.refresh.unavailable",
|
|
2143
2226
|
authRetry: "error.refresh.auth_retry",
|
|
2144
2227
|
sessionEnded: "error.refresh.session_ended",
|
|
@@ -2146,7 +2229,7 @@ var q = {
|
|
|
2146
2229
|
successorTimeout: "error.refresh.successor_timeout",
|
|
2147
2230
|
identityChanged: "error.refresh.identity_changed",
|
|
2148
2231
|
disposed: "error.refresh.disposed"
|
|
2149
|
-
},
|
|
2232
|
+
}, Ln = {
|
|
2150
2233
|
"error.refresh.unavailable": 503,
|
|
2151
2234
|
"error.refresh.auth_retry": 401,
|
|
2152
2235
|
"error.refresh.session_ended": 401,
|
|
@@ -2154,7 +2237,7 @@ var q = {
|
|
|
2154
2237
|
"error.refresh.successor_timeout": 401,
|
|
2155
2238
|
"error.refresh.identity_changed": 401,
|
|
2156
2239
|
"error.refresh.disposed": 499
|
|
2157
|
-
},
|
|
2240
|
+
}, Rn = {
|
|
2158
2241
|
"error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
|
|
2159
2242
|
"error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
|
|
2160
2243
|
"error.refresh.session_ended": "The session has ended",
|
|
@@ -2162,23 +2245,23 @@ var q = {
|
|
|
2162
2245
|
"error.refresh.successor_timeout": "The refresh token was already used and no successor arrived",
|
|
2163
2246
|
"error.refresh.identity_changed": "Storage holds another user's tokens",
|
|
2164
2247
|
"error.refresh.disposed": "The Passflow instance was disposed"
|
|
2165
|
-
},
|
|
2248
|
+
}, q = class extends B {
|
|
2166
2249
|
constructor(e, t = {}) {
|
|
2167
2250
|
super({
|
|
2168
2251
|
id: e,
|
|
2169
|
-
message: t.message ??
|
|
2170
|
-
status:
|
|
2252
|
+
message: t.message ?? Rn[e],
|
|
2253
|
+
status: Ln[e],
|
|
2171
2254
|
location: "/auth/refresh",
|
|
2172
2255
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2173
2256
|
}), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
|
|
2174
2257
|
}
|
|
2175
|
-
},
|
|
2258
|
+
}, zn = class extends Error {
|
|
2176
2259
|
constructor(e, t) {
|
|
2177
2260
|
super(t ?? (e === "lock-timeout" ? "Step-up commit could not take the refresh lock in time" : "Step-up commit answer arrived after the stored session moved on")), this.name = "UpgradeCommitInterruptedError", this.reason = e;
|
|
2178
2261
|
}
|
|
2179
2262
|
};
|
|
2180
2263
|
// lib/refresh/lineage.ts
|
|
2181
|
-
function
|
|
2264
|
+
function J(e) {
|
|
2182
2265
|
if (!e) return;
|
|
2183
2266
|
let t = 3735928559, n = 1103547991;
|
|
2184
2267
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -2187,24 +2270,24 @@ function An(e) {
|
|
|
2187
2270
|
}
|
|
2188
2271
|
return t = Math.imul(t ^ t >>> 16, 2246822507), t ^= Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507), n ^= Math.imul(t ^ t >>> 13, 3266489909), (4294967296 * (2097151 & n) + (t >>> 0)).toString(16);
|
|
2189
2272
|
}
|
|
2190
|
-
function
|
|
2273
|
+
function Bn(e) {
|
|
2191
2274
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2192
2275
|
}
|
|
2193
2276
|
function Y(e) {
|
|
2194
|
-
let t =
|
|
2277
|
+
let t = J(e);
|
|
2195
2278
|
if (!e || !t) return;
|
|
2196
2279
|
let n = {};
|
|
2197
2280
|
try {
|
|
2198
2281
|
let t = A(e);
|
|
2199
2282
|
typeof t == "object" && t && (n = t);
|
|
2200
2283
|
} catch {}
|
|
2201
|
-
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a =
|
|
2284
|
+
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = Bn(n.sub), o = Bn(n.sid);
|
|
2202
2285
|
return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
|
|
2203
2286
|
}
|
|
2204
|
-
var
|
|
2205
|
-
function
|
|
2287
|
+
var Vn = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
|
|
2288
|
+
function Hn(e = (e) => En().warn(e)) {
|
|
2206
2289
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
|
|
2207
|
-
a || (a = !0, e(
|
|
2290
|
+
a || (a = !0, e(Vn));
|
|
2208
2291
|
}, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
|
|
2209
2292
|
if (!e) return;
|
|
2210
2293
|
if (e.iat === void 0) {
|
|
@@ -2245,16 +2328,16 @@ function Nn(e = (e) => gn().warn(e)) {
|
|
|
2245
2328
|
};
|
|
2246
2329
|
}
|
|
2247
2330
|
// lib/refresh/fence.ts
|
|
2248
|
-
var
|
|
2331
|
+
var Un = class extends Error {
|
|
2249
2332
|
constructor(e) {
|
|
2250
2333
|
super(e === "emptied" ? "The shared token storage was emptied" : "The stored refresh token belongs to an ended session"), this.name = "SessionEnded", this.cause = e;
|
|
2251
2334
|
}
|
|
2252
|
-
},
|
|
2335
|
+
}, Wn = class extends Error {
|
|
2253
2336
|
constructor() {
|
|
2254
2337
|
super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
|
|
2255
2338
|
}
|
|
2256
2339
|
};
|
|
2257
|
-
function
|
|
2340
|
+
function Gn(e) {
|
|
2258
2341
|
if (e) try {
|
|
2259
2342
|
let t = A(e).sub;
|
|
2260
2343
|
return typeof t == "string" && t !== "" ? t : void 0;
|
|
@@ -2263,20 +2346,20 @@ function In(e) {
|
|
|
2263
2346
|
}
|
|
2264
2347
|
}
|
|
2265
2348
|
function X(e) {
|
|
2266
|
-
return
|
|
2349
|
+
return Gn(e?.access_token) ?? Gn(e?.refresh_token) ?? Gn(e?.id_token);
|
|
2267
2350
|
}
|
|
2268
|
-
function
|
|
2351
|
+
function Kn(e, t) {
|
|
2269
2352
|
return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
|
|
2270
2353
|
}
|
|
2271
|
-
function
|
|
2354
|
+
function qn(e) {
|
|
2272
2355
|
return typeof e == "object" && !!e;
|
|
2273
2356
|
}
|
|
2274
|
-
function
|
|
2275
|
-
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) =>
|
|
2357
|
+
function Jn(e) {
|
|
2358
|
+
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => En().warn(e)), o = e.lineage ?? Hn(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
|
|
2276
2359
|
let e = t.getTokens(), n = e?.refresh_token;
|
|
2277
2360
|
if (!n) return p = l, e;
|
|
2278
2361
|
p !== void 0 && (f = Math.max(f, p, m), p = void 0);
|
|
2279
|
-
let r =
|
|
2362
|
+
let r = J(n) ?? "";
|
|
2280
2363
|
return r !== c?.fp && (c = {
|
|
2281
2364
|
fp: r,
|
|
2282
2365
|
seq: l
|
|
@@ -2309,7 +2392,7 @@ function zn(e) {
|
|
|
2309
2392
|
let t = E();
|
|
2310
2393
|
t === "wait" && e && (t = "end"), t !== "wait" && D(), t === "wait" && !h && (h = r(() => {
|
|
2311
2394
|
h = void 0, y()?.refresh_token ? N() : O(!0) === "end" && s?.("emptied");
|
|
2312
|
-
},
|
|
2395
|
+
}, Yt));
|
|
2313
2396
|
let n = t === "keep" ? T() : void 0;
|
|
2314
2397
|
return n && (m = Math.max(m, n.seq)), n && g !== n.fp && (g = n.fp, a(`[passflow] The shared token storage was emptied by the end of the session of ${n.fp}, a refresh token the ${b()?.fp ?? "(none)"} this tab holds is ahead of: keeping it. Nothing is refreshed until the storage holds a token again.`)), t;
|
|
2315
2398
|
}, ee = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, k = (e) => {
|
|
@@ -2322,7 +2405,7 @@ function zn(e) {
|
|
|
2322
2405
|
return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
|
|
2323
2406
|
}, j = (e, t) => o.isForward(e, t) ? !0 : !!e && !!t && e.iat !== void 0 && e.sid !== t.sid && o.isRetired(t) && !o.isRetired(e) && !o.isEnded(e), M = (e) => {
|
|
2324
2407
|
let t = b();
|
|
2325
|
-
t && t.fp !==
|
|
2408
|
+
t && t.fp !== J(e.refresh_token) && o.retire(t), n.setTokensCache(e);
|
|
2326
2409
|
}, te = (e) => {
|
|
2327
2410
|
let t = y(), n = t?.refresh_token;
|
|
2328
2411
|
if (n === e.refreshToken) return null;
|
|
@@ -2333,7 +2416,7 @@ function zn(e) {
|
|
|
2333
2416
|
kind: "superseded",
|
|
2334
2417
|
adopted: !1
|
|
2335
2418
|
};
|
|
2336
|
-
let r =
|
|
2419
|
+
let r = Gn(t.access_token) ?? Gn(n);
|
|
2337
2420
|
if (e.sub && r && e.sub !== r) return {
|
|
2338
2421
|
kind: "identity-changed",
|
|
2339
2422
|
saved: !1
|
|
@@ -2373,22 +2456,22 @@ function zn(e) {
|
|
|
2373
2456
|
}, re = !!s || !!e.onStoredSessionSeen, ie = re && e.onStorageChange ? e.onStorageChange(N) : void 0, ae = re && e.onWake ? e.onWake(N) : void 0, P = () => {
|
|
2374
2457
|
let e = y();
|
|
2375
2458
|
if (!e?.refresh_token) {
|
|
2376
|
-
if (O() === "end") throw new
|
|
2459
|
+
if (O() === "end") throw new Un("emptied");
|
|
2377
2460
|
return "held";
|
|
2378
2461
|
}
|
|
2379
2462
|
let t = n.getTokens();
|
|
2380
2463
|
if (e.refresh_token === t?.refresh_token) return "send";
|
|
2381
2464
|
let r = i() ?? X(t), a = X(e);
|
|
2382
|
-
if (r && a && r !== a) throw new
|
|
2465
|
+
if (r && a && r !== a) throw new Wn();
|
|
2383
2466
|
let s = Y(e.refresh_token);
|
|
2384
2467
|
if (o.isEnded(s)) {
|
|
2385
2468
|
if (s && C(s)) return "held";
|
|
2386
|
-
throw new
|
|
2469
|
+
throw new Un("ended");
|
|
2387
2470
|
}
|
|
2388
2471
|
let c = Y(t?.refresh_token);
|
|
2389
2472
|
return j(s, c) ? (M(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && k(s) ? "held" : "send";
|
|
2390
2473
|
}, oe = (e) => {
|
|
2391
|
-
let t = i(), r =
|
|
2474
|
+
let t = i(), r = Gn(e);
|
|
2392
2475
|
if (t && r && t !== r) return { kind: "identity-changed" };
|
|
2393
2476
|
let a = Y(e) ?? { fp: e };
|
|
2394
2477
|
if (o.isEnded(a)) return C(a) ? { kind: "superseded" } : { kind: "ended" };
|
|
@@ -2396,7 +2479,7 @@ function zn(e) {
|
|
|
2396
2479
|
let s = {
|
|
2397
2480
|
refreshToken: e,
|
|
2398
2481
|
order: a
|
|
2399
|
-
}, c = t ?? r ??
|
|
2482
|
+
}, c = t ?? r ?? Gn(n.getTokens()?.access_token);
|
|
2400
2483
|
return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
|
|
2401
2484
|
kind: "send",
|
|
2402
2485
|
sent: s
|
|
@@ -2405,7 +2488,7 @@ function zn(e) {
|
|
|
2405
2488
|
if (o.isEnded(e.order)) return ne(e.order);
|
|
2406
2489
|
let i = te(e);
|
|
2407
2490
|
if (i) return i;
|
|
2408
|
-
if (!ee(e) && A(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${
|
|
2491
|
+
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 ${J(r.refresh_token) ?? "(no refresh token)"}, but this tab already holds ${b()?.fp ?? "(none)"}, a later successor of ${e.order.fp}. Neither saved nor adopted.`), {
|
|
2409
2492
|
kind: "superseded",
|
|
2410
2493
|
adopted: !1
|
|
2411
2494
|
};
|
|
@@ -2415,7 +2498,7 @@ function zn(e) {
|
|
|
2415
2498
|
saved: !0
|
|
2416
2499
|
};
|
|
2417
2500
|
let c = Y(r.refresh_token);
|
|
2418
|
-
return c && (
|
|
2501
|
+
return c && (Kn(c, e.order) || Kn(c, b())) ? (a(`[passflow] Refused to save a refresh result older than the token this tab holds: ${e.order.fp} was answered with ${c.fp}. Neither saved nor adopted.`), {
|
|
2419
2502
|
kind: "superseded",
|
|
2420
2503
|
adopted: !1
|
|
2421
2504
|
}) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
|
|
@@ -2427,7 +2510,7 @@ function zn(e) {
|
|
|
2427
2510
|
kind: "superseded",
|
|
2428
2511
|
adopted: !1
|
|
2429
2512
|
};
|
|
2430
|
-
let r =
|
|
2513
|
+
let r = Mn(t), i = r.kind === "blocked" || r.kind === "auth";
|
|
2431
2514
|
return ee(e) && i ? (o.retire(e.order), _ = e.order, {
|
|
2432
2515
|
kind: "own",
|
|
2433
2516
|
failure: r,
|
|
@@ -2438,11 +2521,11 @@ function zn(e) {
|
|
|
2438
2521
|
heldRefused: !1
|
|
2439
2522
|
});
|
|
2440
2523
|
}, I = (e) => {
|
|
2441
|
-
if (!
|
|
2524
|
+
if (!qn(e)) return !1;
|
|
2442
2525
|
let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
|
|
2443
|
-
if (typeof t != "string" || typeof c != "string" || !
|
|
2526
|
+
if (typeof t != "string" || typeof c != "string" || !qn(l)) return !1;
|
|
2444
2527
|
let u = l;
|
|
2445
|
-
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" ||
|
|
2528
|
+
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || J(u.refresh_token) !== c) return !1;
|
|
2446
2529
|
let d = y();
|
|
2447
2530
|
if (!d?.refresh_token) return !1;
|
|
2448
2531
|
let f = n.getTokens(), p = i() ?? X(f), m = X(u);
|
|
@@ -2459,7 +2542,7 @@ function zn(e) {
|
|
|
2459
2542
|
}
|
|
2460
2543
|
return !0;
|
|
2461
2544
|
};
|
|
2462
|
-
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t &&
|
|
2545
|
+
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && J(d.refresh_token) !== c ? !1 : (M({ ...u }), _());
|
|
2463
2546
|
}, L = (e) => {
|
|
2464
2547
|
if (!e || !_) return !1;
|
|
2465
2548
|
let t = _;
|
|
@@ -2525,7 +2608,7 @@ function zn(e) {
|
|
|
2525
2608
|
};
|
|
2526
2609
|
}
|
|
2527
2610
|
// lib/refresh/controller.ts
|
|
2528
|
-
function
|
|
2611
|
+
function Yn() {
|
|
2529
2612
|
let e, t, n = new Promise((n, r) => {
|
|
2530
2613
|
e = n, t = r;
|
|
2531
2614
|
});
|
|
@@ -2535,53 +2618,53 @@ function Bn() {
|
|
|
2535
2618
|
reject: t
|
|
2536
2619
|
};
|
|
2537
2620
|
}
|
|
2538
|
-
var
|
|
2539
|
-
strikes:
|
|
2540
|
-
"session-ended":
|
|
2541
|
-
"stored-ended":
|
|
2542
|
-
"signed-out":
|
|
2543
|
-
emptied:
|
|
2544
|
-
"signed-out-here":
|
|
2545
|
-
"successor-timeout":
|
|
2546
|
-
"identity-changed":
|
|
2547
|
-
disposed:
|
|
2621
|
+
var Xn = {
|
|
2622
|
+
strikes: K.sessionEnded,
|
|
2623
|
+
"session-ended": K.sessionEnded,
|
|
2624
|
+
"stored-ended": K.sessionEnded,
|
|
2625
|
+
"signed-out": K.signedOut,
|
|
2626
|
+
emptied: K.signedOut,
|
|
2627
|
+
"signed-out-here": K.signedOut,
|
|
2628
|
+
"successor-timeout": K.successorTimeout,
|
|
2629
|
+
"identity-changed": K.identityChanged,
|
|
2630
|
+
disposed: K.disposed
|
|
2548
2631
|
};
|
|
2549
|
-
function
|
|
2632
|
+
function Zn(e) {
|
|
2550
2633
|
throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
|
|
2551
2634
|
}
|
|
2552
|
-
function
|
|
2635
|
+
function Qn(e) {
|
|
2553
2636
|
if (e === void 0 || !Number.isFinite(e)) return 3;
|
|
2554
2637
|
let t = Math.floor(e);
|
|
2555
2638
|
return t >= 1 ? t : 3;
|
|
2556
2639
|
}
|
|
2557
|
-
function
|
|
2640
|
+
function $n(e, t) {
|
|
2558
2641
|
return e instanceof Error && e.message ? e.message : t;
|
|
2559
2642
|
}
|
|
2560
|
-
function
|
|
2643
|
+
function er(e) {
|
|
2561
2644
|
if (typeof e != "object" || !e) return;
|
|
2562
2645
|
let t = e.id;
|
|
2563
2646
|
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
2564
2647
|
}
|
|
2565
|
-
function
|
|
2648
|
+
function tr(e) {
|
|
2566
2649
|
let t = {};
|
|
2567
2650
|
return e?.access_token && (t.access_token = e.access_token), e?.refresh_token && (t.refresh_token = e.refresh_token), e?.id_token && (t.id_token = e.id_token), e?.scopes && (t.scopes = [...e.scopes]), t;
|
|
2568
2651
|
}
|
|
2569
|
-
function
|
|
2652
|
+
function nr(e, t) {
|
|
2570
2653
|
let n = {};
|
|
2571
2654
|
e.access_token && (n.access_token = e.access_token), e.refresh_token && (n.refresh_token = e.refresh_token), e.id_token && (n.id_token = e.id_token);
|
|
2572
2655
|
let r = t?.scopes ?? e.scopes;
|
|
2573
2656
|
return r && (n.scopes = r), n;
|
|
2574
2657
|
}
|
|
2575
|
-
function
|
|
2576
|
-
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ??
|
|
2658
|
+
function rr(e) {
|
|
2659
|
+
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? En(), c = Qn(e.strikes), l = a.transports ? Fn({
|
|
2577
2660
|
locks: a.transports.locks,
|
|
2578
2661
|
channel: a.transports.channel,
|
|
2579
2662
|
tabId: a.transports.tabId,
|
|
2580
2663
|
names: a.names,
|
|
2581
2664
|
clock: o
|
|
2582
|
-
}) :
|
|
2665
|
+
}) : In(), 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 = () => J(r.getTokens()?.refresh_token), O = () => ({ ...r.getTokens() ?? {} }), ee = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, k = () => (S === void 0 && (S = X(r.getTokens() ?? n.getTokens())), S), A = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Set(), M = (e) => () => {
|
|
2583
2666
|
for (let t of Array.from(e)) t();
|
|
2584
|
-
}, te = a.onStorageChange?.(M(A)), ne = e.platform?.onForeground(M(j)), N =
|
|
2667
|
+
}, te = a.onStorageChange?.(M(A)), ne = e.platform?.onForeground(M(j)), N = Jn({
|
|
2585
2668
|
storage: n,
|
|
2586
2669
|
cache: r,
|
|
2587
2670
|
identity: k,
|
|
@@ -2596,13 +2679,13 @@ function Jn(e) {
|
|
|
2596
2679
|
}), re = (e) => ({
|
|
2597
2680
|
trigger: e,
|
|
2598
2681
|
startedAt: T(),
|
|
2599
|
-
plain:
|
|
2682
|
+
plain: Yn(),
|
|
2600
2683
|
fresh: []
|
|
2601
2684
|
}), ie = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, ae = (e, t) => {
|
|
2602
2685
|
if (t === void 0) return e.plain.promise;
|
|
2603
2686
|
let n = {
|
|
2604
2687
|
callTime: t,
|
|
2605
|
-
deferred:
|
|
2688
|
+
deferred: Yn()
|
|
2606
2689
|
};
|
|
2607
2690
|
return e.fresh.push(n), n.deferred.promise;
|
|
2608
2691
|
}, P = (e, t, n = !1) => {
|
|
@@ -2621,11 +2704,11 @@ function Jn(e) {
|
|
|
2621
2704
|
}
|
|
2622
2705
|
}, F = (e, n, r, i) => {
|
|
2623
2706
|
let a = {
|
|
2624
|
-
message:
|
|
2707
|
+
message: $n(r, "Token refresh failed"),
|
|
2625
2708
|
originalError: r,
|
|
2626
2709
|
operation: e,
|
|
2627
2710
|
source: n
|
|
2628
|
-
}, o =
|
|
2711
|
+
}, o = er(r);
|
|
2629
2712
|
o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
|
|
2630
2713
|
}, I = (e, t) => {
|
|
2631
2714
|
let n = {
|
|
@@ -2655,10 +2738,10 @@ function Jn(e) {
|
|
|
2655
2738
|
};
|
|
2656
2739
|
n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
|
|
2657
2740
|
}, le = (e, t) => {
|
|
2658
|
-
let n = r.getTokens(), i =
|
|
2741
|
+
let n = r.getTokens(), i = J(n?.refresh_token);
|
|
2659
2742
|
e.fp && i && l.post({
|
|
2660
2743
|
type: "tokens-refreshed",
|
|
2661
|
-
tokens:
|
|
2744
|
+
tokens: tr(n),
|
|
2662
2745
|
from: e.fp,
|
|
2663
2746
|
...e.iat === void 0 ? {} : { fromIat: e.iat },
|
|
2664
2747
|
fromSid: e.sid ?? "",
|
|
@@ -2666,7 +2749,7 @@ function Jn(e) {
|
|
|
2666
2749
|
...t === void 0 ? {} : { sentAt: t }
|
|
2667
2750
|
});
|
|
2668
2751
|
}, ue = () => {
|
|
2669
|
-
p || (p = !0, s.warn(
|
|
2752
|
+
p || (p = !0, s.warn(ln));
|
|
2670
2753
|
}, de = (e) => {
|
|
2671
2754
|
(e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
|
|
2672
2755
|
}, R = (e, n) => {
|
|
@@ -2680,7 +2763,7 @@ function Jn(e) {
|
|
|
2680
2763
|
}, e !== "disposed" && N.dropSession(), (e === "strikes" || e === "successor-timeout") && E() !== "json" && i.invalidate(), u = {
|
|
2681
2764
|
kind: "ended",
|
|
2682
2765
|
cause: e
|
|
2683
|
-
}, se(r, n ?? new
|
|
2766
|
+
}, se(r, n ?? new q(Xn[e])), e) {
|
|
2684
2767
|
case "strikes":
|
|
2685
2768
|
t("session:expired", {
|
|
2686
2769
|
reason: "refresh_failed",
|
|
@@ -2715,7 +2798,7 @@ function Jn(e) {
|
|
|
2715
2798
|
break;
|
|
2716
2799
|
case "signed-out-here":
|
|
2717
2800
|
case "disposed": break;
|
|
2718
|
-
default:
|
|
2801
|
+
default: Zn(e);
|
|
2719
2802
|
}
|
|
2720
2803
|
}, fe = () => {
|
|
2721
2804
|
if (u.kind !== "ended" || u.cause === "disposed" || f || E() !== "json") return;
|
|
@@ -2732,17 +2815,17 @@ function Jn(e) {
|
|
|
2732
2815
|
}, pe = (e) => {
|
|
2733
2816
|
u.kind === "ended" || f || E() === "json" && (R(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && fe());
|
|
2734
2817
|
}, me = (e) => {
|
|
2735
|
-
e instanceof
|
|
2818
|
+
e instanceof Wn ? (R("identity-changed"), fe()) : e instanceof Un ? R(e.cause === "emptied" ? "emptied" : "stored-ended") : R("stored-ended", e);
|
|
2736
2819
|
}, he = () => {
|
|
2737
2820
|
u = { kind: "idle" }, w || l.release();
|
|
2738
|
-
}, ge = (e) => !e.from || E() !== "json" || e.from === D() || e.from ===
|
|
2821
|
+
}, ge = (e) => !e.from || E() !== "json" || e.from === D() || e.from === J(n.getTokens()?.refresh_token), _e = (e) => {
|
|
2739
2822
|
let t = g;
|
|
2740
2823
|
if (!t) return;
|
|
2741
2824
|
if (!l.holding) {
|
|
2742
2825
|
u = {
|
|
2743
2826
|
kind: "waiting",
|
|
2744
2827
|
pending: e
|
|
2745
|
-
}, l.request(t.nextAt +
|
|
2828
|
+
}, l.request(t.nextAt + W);
|
|
2746
2829
|
return;
|
|
2747
2830
|
}
|
|
2748
2831
|
l.setRetryInfo(t);
|
|
@@ -2761,7 +2844,7 @@ function Jn(e) {
|
|
|
2761
2844
|
!l.holding || l.foreignHolderHeard() || T() - t > 2e4 ? (l.release(), u = {
|
|
2762
2845
|
kind: "waiting",
|
|
2763
2846
|
pending: e
|
|
2764
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
2847
|
+
}, l.request((g?.nextAt ?? T()) + W)) : (u = {
|
|
2765
2848
|
kind: "waiting",
|
|
2766
2849
|
pending: e
|
|
2767
2850
|
}, be() || ye());
|
|
@@ -2801,14 +2884,14 @@ function Jn(e) {
|
|
|
2801
2884
|
case "ended": return N.endHeldSend(), R("stored-ended"), !1;
|
|
2802
2885
|
case "identity-changed": return N.endHeldSend(), R("identity-changed"), fe(), !1;
|
|
2803
2886
|
case "send": return Ce(e, t, a.sent, r);
|
|
2804
|
-
default: return
|
|
2887
|
+
default: return Zn(a);
|
|
2805
2888
|
}
|
|
2806
2889
|
}, Ce = (e, n, r, a) => {
|
|
2807
2890
|
let o = {
|
|
2808
2891
|
generation: d,
|
|
2809
2892
|
sentAt: T(),
|
|
2810
2893
|
trigger: n,
|
|
2811
|
-
settled:
|
|
2894
|
+
settled: Yn()
|
|
2812
2895
|
};
|
|
2813
2896
|
r ? o.sent = r : o.marker = ee(), a && (o.stored = a), u = {
|
|
2814
2897
|
kind: "refreshing",
|
|
@@ -2832,7 +2915,7 @@ function Jn(e) {
|
|
|
2832
2915
|
if (!e.sent) {
|
|
2833
2916
|
let o = X({ ...t.id_token ? { id_token: t.id_token } : {} }), s = k();
|
|
2834
2917
|
if (o !== void 0 && s !== void 0 && o !== s) {
|
|
2835
|
-
let t = new
|
|
2918
|
+
let t = new q(K.identityChanged);
|
|
2836
2919
|
F("refresh", e.trigger, t, I("auth")), R("identity-changed", t);
|
|
2837
2920
|
return;
|
|
2838
2921
|
}
|
|
@@ -2845,7 +2928,7 @@ function Jn(e) {
|
|
|
2845
2928
|
if (!we(e)) return;
|
|
2846
2929
|
r.setTokensCache({
|
|
2847
2930
|
...n.getTokens() ?? {},
|
|
2848
|
-
...
|
|
2931
|
+
...nr(t, void 0)
|
|
2849
2932
|
}), L("refresh", "this-tab");
|
|
2850
2933
|
let c = k();
|
|
2851
2934
|
l.post(c === void 0 ? {
|
|
@@ -2858,7 +2941,7 @@ function Jn(e) {
|
|
|
2858
2941
|
}), he(), P(a, e.sentAt);
|
|
2859
2942
|
return;
|
|
2860
2943
|
}
|
|
2861
|
-
let o = D(), s = N.commitSave(e.sent,
|
|
2944
|
+
let o = D(), s = N.commitSave(e.sent, nr(t, e.stored));
|
|
2862
2945
|
switch (s.kind) {
|
|
2863
2946
|
case "saved":
|
|
2864
2947
|
L("refresh", "this-tab"), le(e.sent.order, e.sentAt), he(), P(a, e.sentAt);
|
|
@@ -2867,16 +2950,16 @@ function Jn(e) {
|
|
|
2867
2950
|
e.outcome && D() === o || L("adopted", "other-tab"), s.adopted && le(e.sent.order), he(), P(a, e.sentAt);
|
|
2868
2951
|
return;
|
|
2869
2952
|
case "ended": {
|
|
2870
|
-
let t = new
|
|
2953
|
+
let t = new q(s.cause === "emptied" ? K.signedOut : K.sessionEnded);
|
|
2871
2954
|
F("refresh", e.trigger, t, I("auth")), R(s.cause === "emptied" ? "emptied" : "stored-ended", t);
|
|
2872
2955
|
return;
|
|
2873
2956
|
}
|
|
2874
2957
|
case "identity-changed": {
|
|
2875
|
-
let t = new
|
|
2958
|
+
let t = new q(K.identityChanged);
|
|
2876
2959
|
F("refresh", e.trigger, t, I("auth")), R("identity-changed", t), fe();
|
|
2877
2960
|
return;
|
|
2878
2961
|
}
|
|
2879
|
-
default:
|
|
2962
|
+
default: Zn(s);
|
|
2880
2963
|
}
|
|
2881
2964
|
}, Ee = (e, t) => {
|
|
2882
2965
|
if (e.sent?.held && N.endHeldSend(), !we(e) || u.kind !== "refreshing") return;
|
|
@@ -2896,9 +2979,9 @@ function Jn(e) {
|
|
|
2896
2979
|
case "own":
|
|
2897
2980
|
r = o.failure, i = o.heldRefused;
|
|
2898
2981
|
break;
|
|
2899
|
-
default:
|
|
2982
|
+
default: Zn(o);
|
|
2900
2983
|
}
|
|
2901
|
-
} else r =
|
|
2984
|
+
} else r = Mn(t, T());
|
|
2902
2985
|
if (i) F("refresh", e.trigger, t, I(r.kind)), L("adopted", "other-tab"), he(), P(n, void 0, !0);
|
|
2903
2986
|
else switch (r.kind) {
|
|
2904
2987
|
case "blocked":
|
|
@@ -2914,10 +2997,10 @@ function Jn(e) {
|
|
|
2914
2997
|
case "transient":
|
|
2915
2998
|
m += 1, De(e, n, t, r);
|
|
2916
2999
|
return;
|
|
2917
|
-
default:
|
|
3000
|
+
default: Zn(r.kind);
|
|
2918
3001
|
}
|
|
2919
3002
|
}, De = (e, t, n, r) => {
|
|
2920
|
-
let i = T() +
|
|
3003
|
+
let i = T() + Nn(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
|
|
2921
3004
|
F("refresh", e.trigger, n, I(a, i)), a === "transient" && ce(T(), i, "this-tab");
|
|
2922
3005
|
let s = {
|
|
2923
3006
|
kind: a,
|
|
@@ -2927,7 +3010,7 @@ function Jn(e) {
|
|
|
2927
3010
|
}, c = e.sent?.order.fp;
|
|
2928
3011
|
c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
|
|
2929
3012
|
type: "retry-scheduled",
|
|
2930
|
-
message:
|
|
3013
|
+
message: $n(n, "Token refresh failed"),
|
|
2931
3014
|
retry: s
|
|
2932
3015
|
}), _e(re("retry")), oe(t, n, e.sentAt);
|
|
2933
3016
|
}, z = (e, t) => {
|
|
@@ -2940,8 +3023,8 @@ function Jn(e) {
|
|
|
2940
3023
|
fp: i.fp
|
|
2941
3024
|
})), r && N.deleteIfStillDead(r), R("strikes", t);
|
|
2942
3025
|
}, Oe = (e, t, n, r) => {
|
|
2943
|
-
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${
|
|
2944
|
-
let i = d, a = T() +
|
|
3026
|
+
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${$n(n, "blocked")}`);
|
|
3027
|
+
let i = d, a = T() + qt, c = {
|
|
2945
3028
|
kind: "blocked-wait",
|
|
2946
3029
|
pending: e,
|
|
2947
3030
|
deadline: a,
|
|
@@ -2954,9 +3037,9 @@ function Jn(e) {
|
|
|
2954
3037
|
i === d && u === c && (ke() || (f ? (e.cookieRetried = !0, u = {
|
|
2955
3038
|
kind: "waiting",
|
|
2956
3039
|
pending: e
|
|
2957
|
-
}, l.request()) : T() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), R("successor-timeout")) : c.cancel = o.setTimeout(p,
|
|
3040
|
+
}, 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, Jt)));
|
|
2958
3041
|
};
|
|
2959
|
-
c.cancel = o.setTimeout(p, f ?
|
|
3042
|
+
c.cancel = o.setTimeout(p, f ? Xt : Jt);
|
|
2960
3043
|
}, ke = () => {
|
|
2961
3044
|
if (u.kind !== "blocked-wait") return !1;
|
|
2962
3045
|
let e = u;
|
|
@@ -2979,7 +3062,7 @@ function Jn(e) {
|
|
|
2979
3062
|
if (u.kind === "ended" || !ge(e)) return;
|
|
2980
3063
|
let r = g?.nextAt;
|
|
2981
3064
|
if (g = e, e.failingSince !== void 0 && ce(e.failingSince, e.nextAt, "other-tab"), !t || u.kind !== "waiting") return;
|
|
2982
|
-
let i = new
|
|
3065
|
+
let i = new q(e.kind === "transient" ? K.unavailable : K.authRetry, {
|
|
2983
3066
|
nextRetryAt: e.nextAt,
|
|
2984
3067
|
cause: n || void 0
|
|
2985
3068
|
}), a = u.pending;
|
|
@@ -3000,7 +3083,7 @@ function Jn(e) {
|
|
|
3000
3083
|
case "idle":
|
|
3001
3084
|
case "refreshing":
|
|
3002
3085
|
case "ended": return;
|
|
3003
|
-
default:
|
|
3086
|
+
default: Zn(u);
|
|
3004
3087
|
}
|
|
3005
3088
|
}, Ne = (e) => {
|
|
3006
3089
|
let t = {};
|
|
@@ -3043,10 +3126,10 @@ function Jn(e) {
|
|
|
3043
3126
|
je(e.retry, !0, e.message), Fe();
|
|
3044
3127
|
return;
|
|
3045
3128
|
case "refresh-failed":
|
|
3046
|
-
if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !==
|
|
3129
|
+
if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !== J(n.getTokens()?.refresh_token)) return;
|
|
3047
3130
|
if (ce(T(), void 0, "other-tab"), u.kind === "waiting") {
|
|
3048
3131
|
let t = u.pending;
|
|
3049
|
-
u.pending = re(t.trigger), oe(t, new
|
|
3132
|
+
u.pending = re(t.trigger), oe(t, new q(K.unavailable, { cause: e.message }), void 0);
|
|
3050
3133
|
}
|
|
3051
3134
|
return;
|
|
3052
3135
|
case "lock-wanted":
|
|
@@ -3055,7 +3138,7 @@ function Jn(e) {
|
|
|
3055
3138
|
u.cancel(), l.release(), u = {
|
|
3056
3139
|
kind: "waiting",
|
|
3057
3140
|
pending: e
|
|
3058
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
3141
|
+
}, l.request((g?.nextAt ?? T()) + W);
|
|
3059
3142
|
}
|
|
3060
3143
|
return;
|
|
3061
3144
|
case "session-ended":
|
|
@@ -3064,7 +3147,7 @@ function Jn(e) {
|
|
|
3064
3147
|
return;
|
|
3065
3148
|
case "takeover":
|
|
3066
3149
|
case "rate-limited": return;
|
|
3067
|
-
default:
|
|
3150
|
+
default: Zn(e);
|
|
3068
3151
|
}
|
|
3069
3152
|
}, Fe = () => {
|
|
3070
3153
|
C && !l.holding && l.post({
|
|
@@ -3087,7 +3170,7 @@ function Jn(e) {
|
|
|
3087
3170
|
u.cancel(), u = {
|
|
3088
3171
|
kind: "waiting",
|
|
3089
3172
|
pending: e
|
|
3090
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
3173
|
+
}, l.request((g?.nextAt ?? T()) + W);
|
|
3091
3174
|
}
|
|
3092
3175
|
},
|
|
3093
3176
|
onMessage: Pe
|
|
@@ -3113,9 +3196,9 @@ function Jn(e) {
|
|
|
3113
3196
|
};
|
|
3114
3197
|
A.add(Ie), j.add(Ie);
|
|
3115
3198
|
let Le = (e, t) => {
|
|
3116
|
-
if (f) return Promise.reject(new
|
|
3199
|
+
if (f) return Promise.reject(new q(K.disposed));
|
|
3117
3200
|
switch (u.kind) {
|
|
3118
|
-
case "ended": return Promise.reject(new
|
|
3201
|
+
case "ended": return Promise.reject(new q(K.sessionEnded));
|
|
3119
3202
|
case "idle": {
|
|
3120
3203
|
let n = re(e);
|
|
3121
3204
|
u = {
|
|
@@ -3123,17 +3206,17 @@ function Jn(e) {
|
|
|
3123
3206
|
pending: n
|
|
3124
3207
|
};
|
|
3125
3208
|
let r = ae(n, t);
|
|
3126
|
-
return l.holding && !w ? be() || ye() : l.request(g ? g.nextAt +
|
|
3209
|
+
return l.holding && !w ? be() || ye() : l.request(g ? g.nextAt + W : void 0), r;
|
|
3127
3210
|
}
|
|
3128
3211
|
case "waiting":
|
|
3129
3212
|
case "refreshing":
|
|
3130
3213
|
case "backoff":
|
|
3131
3214
|
case "blocked-wait": return ae(u.pending, t);
|
|
3132
|
-
default: return
|
|
3215
|
+
default: return Zn(u);
|
|
3133
3216
|
}
|
|
3134
3217
|
}, V = (e) => {
|
|
3135
|
-
if (f) return Promise.reject(new
|
|
3136
|
-
if (ue(), u.kind === "ended") return Promise.reject(new
|
|
3218
|
+
if (f) return Promise.reject(new q(K.disposed));
|
|
3219
|
+
if (ue(), u.kind === "ended") return Promise.reject(new q(K.sessionEnded));
|
|
3137
3220
|
if (E() === "json" && !r.getTokens()?.refresh_token) {
|
|
3138
3221
|
let t = n.getTokens();
|
|
3139
3222
|
if (!t?.refresh_token) {
|
|
@@ -3143,7 +3226,7 @@ function Jn(e) {
|
|
|
3143
3226
|
}
|
|
3144
3227
|
return Le(e.trigger, e.fresh ? T() : void 0);
|
|
3145
3228
|
}, Re = (e) => {
|
|
3146
|
-
if (f) return Promise.reject(new
|
|
3229
|
+
if (f) return Promise.reject(new q(K.disposed));
|
|
3147
3230
|
if (u.kind === "ended") return Promise.resolve(r.getTokens());
|
|
3148
3231
|
let t = u.kind === "backoff" || u.kind === "blocked-wait" || g !== void 0 && g.nextAt > T();
|
|
3149
3232
|
return e.allowStale && t ? Promise.resolve(r.getTokens()) : V({ trigger: e.trigger }).then(() => r.getTokens());
|
|
@@ -3178,11 +3261,11 @@ function Jn(e) {
|
|
|
3178
3261
|
} else u.kind === "idle" && g && g.nextAt > T() && ge(g) ? (m = g.attempt, h = g.strikes, _e(re("retry"))) : u.kind === "idle" && l.release();
|
|
3179
3262
|
}
|
|
3180
3263
|
}, He = async (e, t) => {
|
|
3181
|
-
if (f) throw new
|
|
3264
|
+
if (f) throw new q(K.disposed);
|
|
3182
3265
|
ue();
|
|
3183
|
-
let n = T() +
|
|
3266
|
+
let n = T() + Zt;
|
|
3184
3267
|
if (await Be(n - T()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await ze("commit", n - T())) === "timeout") {
|
|
3185
|
-
let e = new
|
|
3268
|
+
let e = new zn("lock-timeout");
|
|
3186
3269
|
throw F("upgrade.commit", "upgrade", e), e;
|
|
3187
3270
|
}
|
|
3188
3271
|
w = !0;
|
|
@@ -3229,7 +3312,7 @@ function Jn(e) {
|
|
|
3229
3312
|
if (!o) {
|
|
3230
3313
|
await i.applyOpaque(u), r.setTokensCache({
|
|
3231
3314
|
...n.getTokens() ?? {},
|
|
3232
|
-
...
|
|
3315
|
+
...nr(u, void 0)
|
|
3233
3316
|
}), We(c);
|
|
3234
3317
|
let e = k();
|
|
3235
3318
|
return l.post(e === void 0 ? {
|
|
@@ -3241,9 +3324,9 @@ function Jn(e) {
|
|
|
3241
3324
|
sub: e
|
|
3242
3325
|
}), O();
|
|
3243
3326
|
}
|
|
3244
|
-
let d = N.commitSave(o,
|
|
3327
|
+
let d = N.commitSave(o, nr(u, s));
|
|
3245
3328
|
if (d.kind === "saved") return We(c), le(o.order, c), O();
|
|
3246
|
-
let f = new
|
|
3329
|
+
let f = new zn("superseded");
|
|
3247
3330
|
throw F("upgrade.commit", "upgrade", f), d.kind === "superseded" && d.adopted && L("adopted", "other-tab"), f;
|
|
3248
3331
|
}, We = (e) => {
|
|
3249
3332
|
if (L("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
|
|
@@ -3259,9 +3342,9 @@ function Jn(e) {
|
|
|
3259
3342
|
...t,
|
|
3260
3343
|
fp: t.fp
|
|
3261
3344
|
}));
|
|
3262
|
-
},
|
|
3345
|
+
}, Ke = () => {
|
|
3263
3346
|
let e = ie(u);
|
|
3264
|
-
se(e, new
|
|
3347
|
+
se(e, new q(K.signedOut)), (u.kind === "backoff" || u.kind === "blocked-wait" || u.kind === "waiting") && (de(u), u = { kind: "idle" });
|
|
3265
3348
|
};
|
|
3266
3349
|
return {
|
|
3267
3350
|
refresh: V,
|
|
@@ -3269,8 +3352,8 @@ function Jn(e) {
|
|
|
3269
3352
|
commitUpgrade: He,
|
|
3270
3353
|
signOut: async (e) => {
|
|
3271
3354
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3272
|
-
let t = T() +
|
|
3273
|
-
|
|
3355
|
+
let t = T() + Qt;
|
|
3356
|
+
Ke(), await Be(t - T()), Ke(), l.coordinated && !l.holding && await ze("logout", t - T());
|
|
3274
3357
|
try {
|
|
3275
3358
|
Ge(), await e(n.getTokens()?.refresh_token);
|
|
3276
3359
|
} finally {
|
|
@@ -3279,7 +3362,7 @@ function Jn(e) {
|
|
|
3279
3362
|
},
|
|
3280
3363
|
signOutNow: (e) => {
|
|
3281
3364
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3282
|
-
|
|
3365
|
+
Ke();
|
|
3283
3366
|
try {
|
|
3284
3367
|
Ge(), e(n.getTokens()?.refresh_token);
|
|
3285
3368
|
} finally {
|
|
@@ -3307,14 +3390,14 @@ function Jn(e) {
|
|
|
3307
3390
|
de(u), f = !0, d += 1, u = {
|
|
3308
3391
|
kind: "ended",
|
|
3309
3392
|
cause: "disposed"
|
|
3310
|
-
}, se(e, new
|
|
3393
|
+
}, se(e, new q(K.disposed)), C = void 0, N.stop(), l.dispose(), te?.(), ne?.();
|
|
3311
3394
|
}
|
|
3312
3395
|
};
|
|
3313
3396
|
}
|
|
3314
3397
|
// lib/store.ts
|
|
3315
3398
|
var Z = /* @__PURE__ */ function(e) {
|
|
3316
3399
|
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
|
-
}({}),
|
|
3400
|
+
}({}), ir = class {
|
|
3318
3401
|
constructor() {
|
|
3319
3402
|
this.subscribers = /* @__PURE__ */ new Map();
|
|
3320
3403
|
}
|
|
@@ -3333,12 +3416,12 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3333
3416
|
n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
|
|
3334
3417
|
}
|
|
3335
3418
|
notify(e, t) {
|
|
3336
|
-
e === "error" &&
|
|
3419
|
+
e === "error" && zt(this, t?.originalError), this.subscribers.forEach((n, r) => {
|
|
3337
3420
|
(!n || n.has(e)) && r.onAuthChange?.(e, t);
|
|
3338
3421
|
});
|
|
3339
3422
|
}
|
|
3340
3423
|
notifyError(e) {
|
|
3341
|
-
return
|
|
3424
|
+
return U(this, e);
|
|
3342
3425
|
}
|
|
3343
3426
|
}, Q = {
|
|
3344
3427
|
twoFactorCodeInvalid: "error.api.request.2fa_code.invalid",
|
|
@@ -3354,18 +3437,18 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3354
3437
|
twoFactorNotEnabled: "error.2fa.not_enabled",
|
|
3355
3438
|
notImplemented: "error.not.implemented",
|
|
3356
3439
|
tokenInvalid: "error.api.request.token.invalid"
|
|
3357
|
-
},
|
|
3440
|
+
}, ar = Object.freeze([
|
|
3358
3441
|
Q.twoFactorCodeInvalid,
|
|
3359
3442
|
Q.twoFactorNotEnabled,
|
|
3360
3443
|
Q.challengeInvalid,
|
|
3361
3444
|
Q.challengeSessionMismatch,
|
|
3362
3445
|
Q.challengeTooManyAttempts
|
|
3363
|
-
]),
|
|
3446
|
+
]), or = Object.freeze([Q.tokenInvalid]), sr = Object.freeze([
|
|
3364
3447
|
"wrong_code",
|
|
3365
3448
|
"challenge_spent",
|
|
3366
3449
|
"not_registered",
|
|
3367
3450
|
"prepare_not_required"
|
|
3368
|
-
]),
|
|
3451
|
+
]), cr = (e) => sr.includes(e), lr = {
|
|
3369
3452
|
wrong_code: "That code was not accepted. Try again.",
|
|
3370
3453
|
challenge_spent: "That verification challenge is no longer valid. Start again.",
|
|
3371
3454
|
exhausted: "Too many attempts. Try again later.",
|
|
@@ -3379,16 +3462,16 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3379
3462
|
session_changed: "The session ended during verification."
|
|
3380
3463
|
}, $ = class extends Error {
|
|
3381
3464
|
constructor(e) {
|
|
3382
|
-
super(e.message ||
|
|
3465
|
+
super(e.message || lr[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, this.retryable = cr(e.kind), e.cause !== void 0 && (this.cause = e.cause);
|
|
3383
3466
|
}
|
|
3384
|
-
},
|
|
3467
|
+
}, ur = Object.freeze([
|
|
3385
3468
|
"upgrade_transport",
|
|
3386
3469
|
"upgrade_insufficient",
|
|
3387
3470
|
"upgrade_unavailable",
|
|
3388
3471
|
"upgrade_session_changed",
|
|
3389
3472
|
"upgrade_cancelled",
|
|
3390
3473
|
"upgrade_unsatisfiable"
|
|
3391
|
-
]),
|
|
3474
|
+
]), dr = (e) => typeof e == "object" && !!e && typeof e.code == "string" && ur.includes(e.code), fr = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", pr = (e) => {
|
|
3392
3475
|
if (typeof e != "object" || !e) return {
|
|
3393
3476
|
hasResponse: !1,
|
|
3394
3477
|
message: typeof e == "string" ? e : void 0
|
|
@@ -3400,7 +3483,7 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3400
3483
|
message: typeof t.message == "string" ? t.message : void 0,
|
|
3401
3484
|
hasResponse: n !== void 0 || typeof t.status == "number"
|
|
3402
3485
|
};
|
|
3403
|
-
},
|
|
3486
|
+
}, mr = (e, t) => {
|
|
3404
3487
|
switch (e) {
|
|
3405
3488
|
case Q.twoFactorCodeInvalid: return "wrong_code";
|
|
3406
3489
|
case Q.challengeInvalid:
|
|
@@ -3417,11 +3500,11 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3417
3500
|
case Q.tokenInvalid: return t === "refresh" ? "session_changed" : "fatal";
|
|
3418
3501
|
default: return;
|
|
3419
3502
|
}
|
|
3420
|
-
},
|
|
3503
|
+
}, hr = (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", gr = (e, t) => {
|
|
3421
3504
|
if (e instanceof $) return e;
|
|
3422
|
-
let n =
|
|
3505
|
+
let n = pr(e);
|
|
3423
3506
|
return n.hasResponse ? new $({
|
|
3424
|
-
kind:
|
|
3507
|
+
kind: mr(n.errorId, t) ?? hr(n.status, t),
|
|
3425
3508
|
message: n.message,
|
|
3426
3509
|
status: n.status,
|
|
3427
3510
|
errorId: n.errorId,
|
|
@@ -3431,74 +3514,85 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3431
3514
|
message: n.message,
|
|
3432
3515
|
cause: e
|
|
3433
3516
|
});
|
|
3434
|
-
},
|
|
3517
|
+
}, _r = (e) => e.errorId !== void 0 && ar.includes(e.errorId), vr = (e) => e.errorId !== void 0 && or.includes(e.errorId), yr = class extends Error {
|
|
3435
3518
|
constructor(e, t, n) {
|
|
3436
3519
|
super(n ?? "The session was elevated, but this action requires a higher assurance level"), this.name = "UpgradeInsufficientError", this.code = "upgrade_insufficient", this.obtained = e, this.required = t;
|
|
3437
3520
|
}
|
|
3438
|
-
},
|
|
3521
|
+
}, br = class extends Error {
|
|
3439
3522
|
constructor(e = "Step-up verification is not available on this deployment") {
|
|
3440
3523
|
super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
|
|
3441
3524
|
}
|
|
3442
|
-
},
|
|
3525
|
+
}, xr = class extends Error {
|
|
3443
3526
|
constructor(e = "The session changed during verification") {
|
|
3444
3527
|
super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
|
|
3445
3528
|
}
|
|
3446
|
-
},
|
|
3529
|
+
}, Sr = (e) => {
|
|
3447
3530
|
if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
|
|
3448
3531
|
sub: e.sub,
|
|
3449
3532
|
sid: e.sid
|
|
3450
3533
|
} : { sub: e.sub };
|
|
3451
|
-
},
|
|
3534
|
+
}, Cr = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
|
|
3452
3535
|
// lib/utils/validation.ts
|
|
3453
|
-
function
|
|
3536
|
+
function wr(e) {
|
|
3454
3537
|
if (!e || typeof e != "string") return !1;
|
|
3455
3538
|
let t = e.split(".");
|
|
3456
3539
|
if (t.length !== 3) return !1;
|
|
3457
3540
|
let n = /^[A-Za-z0-9_-]+$/;
|
|
3458
3541
|
return t.every((e) => n.test(e) && e.length > 0);
|
|
3459
3542
|
}
|
|
3460
|
-
function
|
|
3543
|
+
function Tr(e) {
|
|
3461
3544
|
return e.replace(/<[^>]*>/g, "").substring(0, 200);
|
|
3462
3545
|
}
|
|
3463
|
-
function
|
|
3546
|
+
function Er(e) {
|
|
3464
3547
|
if (!e || typeof e != "string") return !1;
|
|
3465
3548
|
let t = e.trim();
|
|
3466
3549
|
return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
|
|
3467
3550
|
}
|
|
3468
|
-
function
|
|
3551
|
+
function Dr(e) {
|
|
3469
3552
|
if (!e || typeof e != "string") return !1;
|
|
3470
3553
|
let t = e.trim();
|
|
3471
3554
|
return /^\+[1-9]\d{1,14}$/.test(t);
|
|
3472
3555
|
}
|
|
3473
|
-
function
|
|
3556
|
+
function Or(e) {
|
|
3474
3557
|
if (!e || typeof e != "string") return !1;
|
|
3475
3558
|
let t = e.trim();
|
|
3476
3559
|
return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
|
|
3477
3560
|
}
|
|
3478
|
-
function
|
|
3561
|
+
function kr(e, t = 6) {
|
|
3479
3562
|
return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
|
|
3480
3563
|
}
|
|
3481
|
-
function
|
|
3564
|
+
function Ar(e) {
|
|
3482
3565
|
if (!e || typeof e != "string") return null;
|
|
3483
3566
|
let t = e.toUpperCase().replace(/\s+/g, "");
|
|
3484
3567
|
return /^[A-Z0-9-]{4,16}$/.test(t) ? t : null;
|
|
3485
3568
|
}
|
|
3486
3569
|
// lib/services/auth-service.ts
|
|
3487
|
-
var
|
|
3570
|
+
var jr = "passflow_2fa_pkce", Mr = 3e5, Nr = "passflow_pwless_pending", Pr = 3e3, Fr = "passflow_federated_pkce", Ir = 6e5, Lr = "AppId is required for federated auth", Rr = 10, zr = "The sign-in answered with a PKCE code, but its verifier is gone", Br = (e, t) => new Promise((n, r) => {
|
|
3571
|
+
if (t?.aborted) {
|
|
3572
|
+
r(t.reason);
|
|
3573
|
+
return;
|
|
3574
|
+
}
|
|
3575
|
+
let i = () => {
|
|
3576
|
+
clearTimeout(a), r(t?.reason);
|
|
3577
|
+
}, a = setTimeout(() => {
|
|
3578
|
+
t?.removeEventListener("abort", i), n();
|
|
3579
|
+
}, e);
|
|
3580
|
+
t?.addEventListener("abort", i, { once: !0 });
|
|
3581
|
+
}), Vr = (e) => {
|
|
3488
3582
|
if (!e) return;
|
|
3489
3583
|
let t = new URLSearchParams(e.search).get("token");
|
|
3490
3584
|
if (t) return t;
|
|
3491
3585
|
let n = e.hash.indexOf("?");
|
|
3492
3586
|
return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
|
|
3493
|
-
},
|
|
3587
|
+
}, Hr = (e) => {
|
|
3494
3588
|
if (e) try {
|
|
3495
3589
|
return A(e).email;
|
|
3496
3590
|
} catch {
|
|
3497
3591
|
return;
|
|
3498
3592
|
}
|
|
3499
|
-
},
|
|
3500
|
-
constructor(e, t, n, r, i, a, o, s, c, l, u, d = P, f, p = { coordination:
|
|
3501
|
-
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new ne(n), u?.enabled && this.tokenDeliveryManager.setMode(M.BFF), this.refresh =
|
|
3593
|
+
}, Ur = class {
|
|
3594
|
+
constructor(e, t, n, r, i, a, o, s, c, l, u, d = P, f, p = { coordination: _n() }) {
|
|
3595
|
+
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 = rr({
|
|
3502
3596
|
emit: this.createRefreshEmit(),
|
|
3503
3597
|
storage: n,
|
|
3504
3598
|
cache: i,
|
|
@@ -3506,7 +3600,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3506
3600
|
coordination: p.coordination,
|
|
3507
3601
|
platform: d,
|
|
3508
3602
|
...p.strikes === void 0 ? {} : { strikes: p.strikes },
|
|
3509
|
-
logger:
|
|
3603
|
+
logger: En()
|
|
3510
3604
|
}), this.initializeSession();
|
|
3511
3605
|
}
|
|
3512
3606
|
async initializeSession() {
|
|
@@ -3561,7 +3655,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3561
3655
|
rememberEmailChallenge(e, t) {
|
|
3562
3656
|
this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
|
|
3563
3657
|
for (let e of this.emailChallenges.keys()) {
|
|
3564
|
-
if (this.emailChallenges.size <=
|
|
3658
|
+
if (this.emailChallenges.size <= Rr) break;
|
|
3565
3659
|
this.emailChallenges.delete(e);
|
|
3566
3660
|
}
|
|
3567
3661
|
}
|
|
@@ -3569,14 +3663,14 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3569
3663
|
if (this.pendingPkce = {
|
|
3570
3664
|
verifier: e,
|
|
3571
3665
|
scopes: t,
|
|
3572
|
-
expiresAt: Date.now() +
|
|
3666
|
+
expiresAt: Date.now() + Mr
|
|
3573
3667
|
}, typeof sessionStorage < "u") try {
|
|
3574
|
-
sessionStorage.setItem(
|
|
3668
|
+
sessionStorage.setItem(jr, JSON.stringify(this.pendingPkce));
|
|
3575
3669
|
} catch {}
|
|
3576
3670
|
}
|
|
3577
3671
|
readPendingPkce() {
|
|
3578
3672
|
if (!this.pendingPkce && typeof sessionStorage < "u") try {
|
|
3579
|
-
let e = sessionStorage.getItem(
|
|
3673
|
+
let e = sessionStorage.getItem(jr);
|
|
3580
3674
|
this.pendingPkce = e ? JSON.parse(e) : void 0;
|
|
3581
3675
|
} catch {
|
|
3582
3676
|
this.pendingPkce = void 0;
|
|
@@ -3588,7 +3682,49 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3588
3682
|
}
|
|
3589
3683
|
forgetPkceSignIn() {
|
|
3590
3684
|
if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
|
|
3591
|
-
sessionStorage.removeItem(
|
|
3685
|
+
sessionStorage.removeItem(jr);
|
|
3686
|
+
} catch {}
|
|
3687
|
+
}
|
|
3688
|
+
rememberPendingPasswordless(e) {
|
|
3689
|
+
if (this.pendingPasswordless = e, typeof sessionStorage < "u") try {
|
|
3690
|
+
sessionStorage.setItem(Nr, JSON.stringify(e));
|
|
3691
|
+
} catch {}
|
|
3692
|
+
}
|
|
3693
|
+
readPendingPasswordless() {
|
|
3694
|
+
if (!this.pendingPasswordless && typeof sessionStorage < "u") try {
|
|
3695
|
+
let e = sessionStorage.getItem(Nr);
|
|
3696
|
+
this.pendingPasswordless = e ? JSON.parse(e) : void 0;
|
|
3697
|
+
} catch {
|
|
3698
|
+
this.pendingPasswordless = void 0;
|
|
3699
|
+
}
|
|
3700
|
+
return this.pendingPasswordless && !(Date.now() < this.pendingPasswordless.expiresAt) && this.forgetPendingPasswordless(), this.pendingPasswordless;
|
|
3701
|
+
}
|
|
3702
|
+
forgetPendingPasswordless() {
|
|
3703
|
+
if (this.pendingPasswordless = void 0, typeof sessionStorage < "u") try {
|
|
3704
|
+
sessionStorage.removeItem(Nr);
|
|
3705
|
+
} catch {}
|
|
3706
|
+
}
|
|
3707
|
+
rememberFederatedSlot(e, t) {
|
|
3708
|
+
if (this.federatedSlot = {
|
|
3709
|
+
verifier: e,
|
|
3710
|
+
scopes: t,
|
|
3711
|
+
expiresAt: Date.now() + Ir
|
|
3712
|
+
}, typeof sessionStorage < "u") try {
|
|
3713
|
+
sessionStorage.setItem(Fr, JSON.stringify(this.federatedSlot));
|
|
3714
|
+
} catch {}
|
|
3715
|
+
}
|
|
3716
|
+
readFederatedSlot() {
|
|
3717
|
+
if (!this.federatedSlot && typeof sessionStorage < "u") try {
|
|
3718
|
+
let e = sessionStorage.getItem(Fr);
|
|
3719
|
+
this.federatedSlot = e ? JSON.parse(e) : void 0;
|
|
3720
|
+
} catch {
|
|
3721
|
+
this.federatedSlot = void 0;
|
|
3722
|
+
}
|
|
3723
|
+
return this.federatedSlot && Date.now() < this.federatedSlot.expiresAt ? this.federatedSlot : void 0;
|
|
3724
|
+
}
|
|
3725
|
+
forgetFederatedSlot() {
|
|
3726
|
+
if (this.federatedSlot = void 0, typeof sessionStorage < "u") try {
|
|
3727
|
+
sessionStorage.removeItem(Fr);
|
|
3592
3728
|
} catch {}
|
|
3593
3729
|
}
|
|
3594
3730
|
async startPkce() {
|
|
@@ -3596,17 +3732,17 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3596
3732
|
try {
|
|
3597
3733
|
e = await this.readPkceEnabled?.() ?? !1;
|
|
3598
3734
|
} catch (e) {
|
|
3599
|
-
|
|
3735
|
+
En().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
|
|
3600
3736
|
return;
|
|
3601
3737
|
}
|
|
3602
|
-
return e ?
|
|
3738
|
+
return e ? wn() : void 0;
|
|
3603
3739
|
}
|
|
3604
3740
|
async exchangeCode(e, t) {
|
|
3605
3741
|
return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
|
|
3606
3742
|
}
|
|
3607
3743
|
async completePkceSignIn(e) {
|
|
3608
3744
|
let t = this.readPendingPkce();
|
|
3609
|
-
if (!t) throw Error(
|
|
3745
|
+
if (!t) throw Error(zr);
|
|
3610
3746
|
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
3611
3747
|
return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
|
|
3612
3748
|
}
|
|
@@ -3630,32 +3766,32 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3630
3766
|
if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
|
|
3631
3767
|
}
|
|
3632
3768
|
async signIn(e) {
|
|
3633
|
-
if ("email" in e && e.email && !
|
|
3769
|
+
if ("email" in e && e.email && !Er(e.email)) {
|
|
3634
3770
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3635
3771
|
operation: "sign-in",
|
|
3636
3772
|
message: "Invalid email format",
|
|
3637
3773
|
originalError: e,
|
|
3638
3774
|
code: "VALIDATION_ERROR"
|
|
3639
3775
|
};
|
|
3640
|
-
throw
|
|
3776
|
+
throw U(this.subscribeStore, t), e;
|
|
3641
3777
|
}
|
|
3642
|
-
if ("username" in e && e.username && !
|
|
3778
|
+
if ("username" in e && e.username && !Or(e.username)) {
|
|
3643
3779
|
let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
|
|
3644
3780
|
operation: "sign-in",
|
|
3645
3781
|
message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
|
|
3646
3782
|
originalError: e,
|
|
3647
3783
|
code: "VALIDATION_ERROR"
|
|
3648
3784
|
};
|
|
3649
|
-
throw
|
|
3785
|
+
throw U(this.subscribeStore, t), e;
|
|
3650
3786
|
}
|
|
3651
|
-
if ("phone" in e && e.phone && !
|
|
3787
|
+
if ("phone" in e && e.phone && !Dr(e.phone)) {
|
|
3652
3788
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3653
3789
|
operation: "sign-in",
|
|
3654
3790
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3655
3791
|
originalError: e,
|
|
3656
3792
|
code: "VALIDATION_ERROR"
|
|
3657
3793
|
};
|
|
3658
|
-
throw
|
|
3794
|
+
throw U(this.subscribeStore, t), e;
|
|
3659
3795
|
}
|
|
3660
3796
|
this.subscribeStore.notify(Z.SignInStart, { email: e.email });
|
|
3661
3797
|
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
@@ -3678,27 +3814,27 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3678
3814
|
originalError: e,
|
|
3679
3815
|
code: e instanceof B ? e.id : void 0
|
|
3680
3816
|
};
|
|
3681
|
-
throw
|
|
3817
|
+
throw U(this.subscribeStore, t), e;
|
|
3682
3818
|
}
|
|
3683
3819
|
}
|
|
3684
3820
|
async signUp(e) {
|
|
3685
|
-
if (e.user.email && !
|
|
3821
|
+
if (e.user.email && !Er(e.user.email)) {
|
|
3686
3822
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3687
3823
|
operation: "sign-up",
|
|
3688
3824
|
message: "Invalid email format",
|
|
3689
3825
|
originalError: e,
|
|
3690
3826
|
code: "VALIDATION_ERROR"
|
|
3691
3827
|
};
|
|
3692
|
-
throw
|
|
3828
|
+
throw U(this.subscribeStore, t), e;
|
|
3693
3829
|
}
|
|
3694
|
-
if (e.user.phone_number && !
|
|
3830
|
+
if (e.user.phone_number && !Dr(e.user.phone_number)) {
|
|
3695
3831
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3696
3832
|
operation: "sign-up",
|
|
3697
3833
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3698
3834
|
originalError: e,
|
|
3699
3835
|
code: "VALIDATION_ERROR"
|
|
3700
3836
|
};
|
|
3701
|
-
throw
|
|
3837
|
+
throw U(this.subscribeStore, t), e;
|
|
3702
3838
|
}
|
|
3703
3839
|
this.subscribeStore.notify(Z.RegisterStart, { email: e.user.email }), e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
3704
3840
|
try {
|
|
@@ -3719,32 +3855,45 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3719
3855
|
originalError: e,
|
|
3720
3856
|
code: e instanceof B ? e.id : void 0
|
|
3721
3857
|
};
|
|
3722
|
-
throw
|
|
3858
|
+
throw U(this.subscribeStore, t), e;
|
|
3723
3859
|
}
|
|
3724
3860
|
}
|
|
3725
3861
|
async passwordlessSignIn(e) {
|
|
3726
|
-
if (e.email && !
|
|
3862
|
+
if (e.email && !Er(e.email)) {
|
|
3727
3863
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3728
3864
|
operation: "passwordless.start",
|
|
3729
3865
|
message: "Invalid email format",
|
|
3730
3866
|
originalError: e,
|
|
3731
3867
|
code: "VALIDATION_ERROR"
|
|
3732
3868
|
};
|
|
3733
|
-
throw
|
|
3869
|
+
throw U(this.subscribeStore, t), e;
|
|
3734
3870
|
}
|
|
3735
|
-
if (e.phone && !
|
|
3871
|
+
if (e.phone && !Dr(e.phone)) {
|
|
3736
3872
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3737
3873
|
operation: "passwordless.start",
|
|
3738
3874
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3739
3875
|
originalError: e,
|
|
3740
3876
|
code: "VALIDATION_ERROR"
|
|
3741
3877
|
};
|
|
3742
|
-
throw
|
|
3878
|
+
throw U(this.subscribeStore, t), e;
|
|
3743
3879
|
}
|
|
3744
|
-
this.subscribeStore.notify(Z.SignInStart, { email: e.email })
|
|
3745
|
-
let t = this.deviceService.getDeviceId(),
|
|
3880
|
+
this.subscribeStore.notify(Z.SignInStart, { email: e.email });
|
|
3881
|
+
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId(), r = Le(this.platform.getDeviceType());
|
|
3746
3882
|
try {
|
|
3747
|
-
|
|
3883
|
+
let i = await this.startPkce(), a = await this.authApi.passwordlessSignIn({
|
|
3884
|
+
...e,
|
|
3885
|
+
scopes: t,
|
|
3886
|
+
...i ? { code_challenge: i.challenge } : {}
|
|
3887
|
+
}, n, r);
|
|
3888
|
+
return i && a.challenge_id ? this.rememberPendingPasswordless({
|
|
3889
|
+
challengeId: a.challenge_id,
|
|
3890
|
+
verifier: i.verifier,
|
|
3891
|
+
codeChallenge: i.challenge,
|
|
3892
|
+
matchCode: a.match_code,
|
|
3893
|
+
email: e.email,
|
|
3894
|
+
scopes: t,
|
|
3895
|
+
expiresAt: new Date(a.expires_at).getTime()
|
|
3896
|
+
}) : this.forgetPendingPasswordless(), a;
|
|
3748
3897
|
} catch (e) {
|
|
3749
3898
|
let t = {
|
|
3750
3899
|
operation: "passwordless.start",
|
|
@@ -3752,39 +3901,140 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3752
3901
|
originalError: e,
|
|
3753
3902
|
code: e instanceof B ? e.id : void 0
|
|
3754
3903
|
};
|
|
3755
|
-
throw
|
|
3904
|
+
throw U(this.subscribeStore, t), e;
|
|
3756
3905
|
}
|
|
3757
3906
|
}
|
|
3758
3907
|
async passwordlessSignInComplete(e) {
|
|
3759
3908
|
this.subscribeStore.notify(Z.SignInStart, {}), e.scopes = e.scopes ?? this.scopes, e.device = this.deviceService.getDeviceId();
|
|
3909
|
+
let t = this.readPendingPasswordless(), n = t?.challengeId === e.challenge_id ? t : void 0, r = !1;
|
|
3760
3910
|
try {
|
|
3761
3911
|
let t = await this.authApi.passwordlessSignInComplete(e);
|
|
3762
|
-
|
|
3763
|
-
|
|
3912
|
+
if (r = !0, this.handlePendingSecondFactor(t, n?.email, n && { verifier: n.verifier }, n?.scopes)) return this.forgetPendingPasswordless(), t;
|
|
3913
|
+
let i = t;
|
|
3914
|
+
if (t.code) {
|
|
3915
|
+
if (!n) throw Error(zr);
|
|
3916
|
+
if (i = await this.authApi.pkceExchange(t.code, n.verifier), this.handlePendingSecondFactor(i)) return this.forgetPendingPasswordless(), {
|
|
3917
|
+
...i,
|
|
3918
|
+
redirect_url: t.redirect_url ?? ""
|
|
3919
|
+
};
|
|
3920
|
+
}
|
|
3921
|
+
let a = t.redirect_url ? {
|
|
3922
|
+
...i,
|
|
3923
|
+
redirect_url: t.redirect_url
|
|
3924
|
+
} : i;
|
|
3925
|
+
return await this.processAuthResponse(a, n?.scopes ?? e.scopes), this.forgetPendingPasswordless(), this.subscribeStore.notify(Z.SignIn, {
|
|
3926
|
+
tokens: a,
|
|
3764
3927
|
parsedTokens: this.tokenCacheService.getParsedTokens()
|
|
3765
|
-
}), await this.submitSessionCheck()
|
|
3928
|
+
}), await this.submitSessionCheck(), {
|
|
3929
|
+
...a,
|
|
3930
|
+
redirect_url: t.redirect_url ?? ""
|
|
3931
|
+
};
|
|
3766
3932
|
} catch (e) {
|
|
3933
|
+
r && this.forgetPendingPasswordless();
|
|
3767
3934
|
let t = {
|
|
3768
3935
|
operation: "passwordless.complete",
|
|
3769
3936
|
message: e instanceof Error ? e.message : "Passwordless sign in failed",
|
|
3770
3937
|
originalError: e,
|
|
3771
3938
|
code: e instanceof B ? e.id : void 0
|
|
3772
3939
|
};
|
|
3773
|
-
throw
|
|
3940
|
+
throw U(this.subscribeStore, t), e;
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
async waitForPasswordlessSignIn(e, t) {
|
|
3944
|
+
let n = t?.signal;
|
|
3945
|
+
try {
|
|
3946
|
+
let t = this.readPendingPasswordless();
|
|
3947
|
+
if (t?.challengeId !== e) throw Error(zr);
|
|
3948
|
+
for (;;) {
|
|
3949
|
+
if (n?.aborted) throw n.reason;
|
|
3950
|
+
if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
|
|
3951
|
+
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(zr);
|
|
3952
|
+
let r;
|
|
3953
|
+
try {
|
|
3954
|
+
r = await this.authApi.passwordlessStatus({
|
|
3955
|
+
challenge_id: e,
|
|
3956
|
+
code_challenge: t.codeChallenge
|
|
3957
|
+
}, { signal: n });
|
|
3958
|
+
} catch (e) {
|
|
3959
|
+
if (n?.aborted) throw n.reason;
|
|
3960
|
+
if (e instanceof B && e.status >= 400 && e.status < 500 && e.status !== 429) throw this.forgetPendingPasswordless(), e;
|
|
3961
|
+
}
|
|
3962
|
+
if (r?.status === "denied" || r?.status === "expired" || r?.status === "completed") return this.forgetPendingPasswordless(), { status: r.status };
|
|
3963
|
+
if (r?.status === "approved" && r.code) return await this.finishApprovedPasswordless(r.code, t);
|
|
3964
|
+
await Br(Pr, n);
|
|
3965
|
+
}
|
|
3966
|
+
} catch (e) {
|
|
3967
|
+
if (n?.aborted && e === n.reason) throw e;
|
|
3968
|
+
let t = {
|
|
3969
|
+
operation: "passwordless.wait",
|
|
3970
|
+
message: e instanceof Error ? e.message : "Waiting for the passwordless sign-in failed",
|
|
3971
|
+
originalError: e,
|
|
3972
|
+
code: e instanceof B ? e.id : void 0
|
|
3973
|
+
};
|
|
3974
|
+
throw U(this.subscribeStore, t), e;
|
|
3975
|
+
}
|
|
3976
|
+
}
|
|
3977
|
+
async finishApprovedPasswordless(e, t) {
|
|
3978
|
+
try {
|
|
3979
|
+
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
3980
|
+
return this.handlePendingSecondFactor(n, t.email) ? (this.forgetPendingPasswordless(), { status: "second-factor-required" }) : (await this.processAuthResponse(n, t.scopes), this.forgetPendingPasswordless(), this.subscribeStore.notify(Z.SignIn, {
|
|
3981
|
+
tokens: n,
|
|
3982
|
+
parsedTokens: this.tokenCacheService.getParsedTokens()
|
|
3983
|
+
}), await this.submitSessionCheck(), {
|
|
3984
|
+
status: "signed-in",
|
|
3985
|
+
tokens: n
|
|
3986
|
+
});
|
|
3987
|
+
} catch (e) {
|
|
3988
|
+
throw this.forgetPendingPasswordless(), e;
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3991
|
+
getPendingPasswordlessSignIn(e) {
|
|
3992
|
+
let t = this.readPendingPasswordless();
|
|
3993
|
+
if (t?.challengeId === e && t.matchCode) return {
|
|
3994
|
+
matchCode: t.matchCode,
|
|
3995
|
+
expiresAt: t.expiresAt
|
|
3996
|
+
};
|
|
3997
|
+
}
|
|
3998
|
+
async getPasswordlessApproval(e) {
|
|
3999
|
+
try {
|
|
4000
|
+
return await this.authApi.passwordlessApprovalInfo({ challenge_id: e });
|
|
4001
|
+
} catch (e) {
|
|
4002
|
+
throw this.reportApprovalFailure(e), e;
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
4005
|
+
async decidePasswordlessApproval(e, t, n, r) {
|
|
4006
|
+
try {
|
|
4007
|
+
await this.authApi.passwordlessApprovalDecide({
|
|
4008
|
+
challenge_id: e,
|
|
4009
|
+
otp: t,
|
|
4010
|
+
approve: n,
|
|
4011
|
+
match_code: r
|
|
4012
|
+
});
|
|
4013
|
+
} catch (e) {
|
|
4014
|
+
throw this.reportApprovalFailure(e), e;
|
|
3774
4015
|
}
|
|
3775
4016
|
}
|
|
4017
|
+
reportApprovalFailure(e) {
|
|
4018
|
+
let t = {
|
|
4019
|
+
operation: "passwordless.approval",
|
|
4020
|
+
message: e instanceof Error ? e.message : "Passwordless approval failed",
|
|
4021
|
+
originalError: e,
|
|
4022
|
+
code: e instanceof B ? e.id : void 0
|
|
4023
|
+
};
|
|
4024
|
+
U(this.subscribeStore, t);
|
|
4025
|
+
}
|
|
3776
4026
|
async verifyEmailCode(e) {
|
|
3777
4027
|
let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
|
|
3778
4028
|
try {
|
|
3779
4029
|
let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
|
|
3780
|
-
if (t?.pkce && !r) throw Error(
|
|
4030
|
+
if (t?.pkce && !r) throw Error(zr);
|
|
3781
4031
|
let i = await this.authApi.validateEmailCode(e);
|
|
3782
4032
|
this.emailChallenges.delete(e.challenge_id);
|
|
3783
4033
|
let a = r?.scopes ?? t?.scopes ?? this.scopes;
|
|
3784
4034
|
if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
|
|
3785
4035
|
let o = i;
|
|
3786
4036
|
if (i.code) {
|
|
3787
|
-
if (!r) throw Error(
|
|
4037
|
+
if (!r) throw Error(zr);
|
|
3788
4038
|
if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
|
|
3789
4039
|
}
|
|
3790
4040
|
let s = i.redirect_url ? {
|
|
@@ -3802,13 +4052,13 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3802
4052
|
originalError: e,
|
|
3803
4053
|
code: e instanceof B ? e.id : void 0
|
|
3804
4054
|
};
|
|
3805
|
-
throw
|
|
4055
|
+
throw U(this.subscribeStore, t), e;
|
|
3806
4056
|
}
|
|
3807
4057
|
}
|
|
3808
4058
|
async logOut() {
|
|
3809
4059
|
let e = this.refresh.identity();
|
|
3810
4060
|
return await this.refresh.signOut(async (e) => {
|
|
3811
|
-
await this.callLogoutApi(e), this.forgetPkceSignIn(), this.emailChallenges.clear(), this.clearLocalSession();
|
|
4061
|
+
await this.callLogoutApi(e), this.forgetPkceSignIn(), this.forgetPendingPasswordless(), this.emailChallenges.clear(), this.clearLocalSession();
|
|
3812
4062
|
}), e;
|
|
3813
4063
|
}
|
|
3814
4064
|
resetSession() {
|
|
@@ -3838,13 +4088,13 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3838
4088
|
readSessionPin() {
|
|
3839
4089
|
try {
|
|
3840
4090
|
let e = this.storageManager.getToken(j.access_token);
|
|
3841
|
-
return e ?
|
|
4091
|
+
return e ? Sr(A(e)) : void 0;
|
|
3842
4092
|
} catch {
|
|
3843
4093
|
return;
|
|
3844
4094
|
}
|
|
3845
4095
|
}
|
|
3846
4096
|
assertSessionPin(e) {
|
|
3847
|
-
if (e && !
|
|
4097
|
+
if (e && !Cr(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 xr("The session changed during verification, so the elevated tokens were discarded");
|
|
3848
4098
|
}
|
|
3849
4099
|
refreshMode() {
|
|
3850
4100
|
return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
|
|
@@ -3872,7 +4122,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3872
4122
|
return;
|
|
3873
4123
|
}
|
|
3874
4124
|
case "error":
|
|
3875
|
-
|
|
4125
|
+
U(n, t);
|
|
3876
4126
|
return;
|
|
3877
4127
|
case "refresh:start":
|
|
3878
4128
|
n.notify(Z.RefreshStart, {});
|
|
@@ -3892,7 +4142,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3892
4142
|
case "signout":
|
|
3893
4143
|
n.notify(Z.SignOut, t);
|
|
3894
4144
|
return;
|
|
3895
|
-
default:
|
|
4145
|
+
default: En().warn(`[passflow] Unknown refresh event: ${String(e)}`);
|
|
3896
4146
|
}
|
|
3897
4147
|
};
|
|
3898
4148
|
}
|
|
@@ -3950,7 +4200,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3950
4200
|
let e = this.storageManager.getTokens();
|
|
3951
4201
|
if (!e?.refresh_token) {
|
|
3952
4202
|
let t = /* @__PURE__ */ Error(e ? "No refresh token found" : "No tokens found");
|
|
3953
|
-
throw
|
|
4203
|
+
throw U(this.subscribeStore, {
|
|
3954
4204
|
operation: "refresh",
|
|
3955
4205
|
source: "refresh-token",
|
|
3956
4206
|
message: t.message,
|
|
@@ -3973,15 +4223,15 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3973
4223
|
originalError: e,
|
|
3974
4224
|
code: e instanceof B ? e.id : void 0
|
|
3975
4225
|
};
|
|
3976
|
-
throw
|
|
4226
|
+
throw U(this.subscribeStore, t), e;
|
|
3977
4227
|
}
|
|
3978
4228
|
}
|
|
3979
4229
|
async resetPassword(e, t, n) {
|
|
3980
4230
|
this.subscribeStore.notify(Z.SignInStart, {});
|
|
3981
|
-
let r = n ??
|
|
4231
|
+
let r = n ?? Vr(this.platform.getCurrentUrl()), i = t ?? this.scopes;
|
|
3982
4232
|
try {
|
|
3983
4233
|
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",
|
|
4234
|
+
if (this.handleEmailVerificationStep(n, "reset-password", Hr(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
|
|
3985
4235
|
let a = await this.exchangeCode(n, t);
|
|
3986
4236
|
if (this.handlePendingSecondFactor(a)) return a;
|
|
3987
4237
|
let o = n.redirect_url ? {
|
|
@@ -3999,7 +4249,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
3999
4249
|
originalError: e,
|
|
4000
4250
|
code: e instanceof B ? e.id : void 0
|
|
4001
4251
|
};
|
|
4002
|
-
throw
|
|
4252
|
+
throw U(this.subscribeStore, t), e;
|
|
4003
4253
|
}
|
|
4004
4254
|
}
|
|
4005
4255
|
async passkeyRegister(e) {
|
|
@@ -4029,7 +4279,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4029
4279
|
originalError: e,
|
|
4030
4280
|
code: e instanceof B ? e.id : void 0
|
|
4031
4281
|
};
|
|
4032
|
-
throw
|
|
4282
|
+
throw U(this.subscribeStore, t), e;
|
|
4033
4283
|
}
|
|
4034
4284
|
}
|
|
4035
4285
|
async passkeyAuthenticate(e) {
|
|
@@ -4057,63 +4307,110 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4057
4307
|
originalError: e,
|
|
4058
4308
|
code: e instanceof B ? e.id : void 0
|
|
4059
4309
|
};
|
|
4060
|
-
throw
|
|
4310
|
+
throw U(this.subscribeStore, t), e;
|
|
4061
4311
|
}
|
|
4062
4312
|
}
|
|
4063
4313
|
createFederatedAuthUrl(e) {
|
|
4064
4314
|
let t = `/auth/federated/start/${e.provider}`;
|
|
4065
|
-
if (!this.appId) throw Error(
|
|
4315
|
+
if (!this.appId) throw Error(Lr);
|
|
4066
4316
|
let n = {
|
|
4067
4317
|
scopes: (e.scopes ?? this.scopes).join(" "),
|
|
4068
4318
|
redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
|
|
4069
4319
|
appId: this.appId,
|
|
4070
4320
|
...e.invite_token ? { invite_token: e.invite_token } : {},
|
|
4071
4321
|
...e.create_tenant ? { create_tenant: e.create_tenant.toString() } : {},
|
|
4072
|
-
...e.device ? { device: e.device } : {}
|
|
4322
|
+
...e.device ? { device: e.device } : {},
|
|
4323
|
+
...e.code_challenge ? { code_challenge: e.code_challenge } : {},
|
|
4324
|
+
...e.code_challenge_method ? { code_challenge_method: e.code_challenge_method } : {}
|
|
4073
4325
|
}, r = new URL(t, this.url);
|
|
4074
4326
|
return r.search = new URLSearchParams(n).toString(), r.toString();
|
|
4075
4327
|
}
|
|
4076
4328
|
async federatedAuthWithPopup(e) {
|
|
4077
|
-
this.subscribeStore.notify(Z.SignInStart, { provider: e.provider });
|
|
4078
|
-
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId()
|
|
4079
|
-
...e,
|
|
4080
|
-
scopes: t,
|
|
4081
|
-
device: n
|
|
4082
|
-
});
|
|
4329
|
+
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(Lr);
|
|
4330
|
+
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
|
|
4083
4331
|
try {
|
|
4084
|
-
|
|
4332
|
+
this.forgetFederatedSlot();
|
|
4333
|
+
let r = await this.startPkce(), i = this.createFederatedAuthUrl({
|
|
4334
|
+
...e,
|
|
4335
|
+
scopes: t,
|
|
4336
|
+
device: n,
|
|
4337
|
+
...r ? {
|
|
4338
|
+
code_challenge: r.challenge,
|
|
4339
|
+
code_challenge_method: "S256"
|
|
4340
|
+
} : {}
|
|
4341
|
+
}), a = this.platform.openAuthUrl(i, {
|
|
4085
4342
|
mode: "popup",
|
|
4086
4343
|
expectedReturnOrigin: this.platform.getCurrentUrl()?.origin ?? ""
|
|
4087
|
-
})
|
|
4088
|
-
|
|
4089
|
-
let
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4344
|
+
});
|
|
4345
|
+
r && this.rememberFederatedSlot(r.verifier, t);
|
|
4346
|
+
let o = await a;
|
|
4347
|
+
this.forgetFederatedSlot();
|
|
4348
|
+
let s = new URLSearchParams(o.callbackHash.replace(/^#/, ""));
|
|
4349
|
+
if (this.handlePendingSecondFactor({ tfa_token: s.get("tfa_token") ?? void 0 })) return;
|
|
4350
|
+
let c = new URLSearchParams(o.callbackSearch), l = c.get("code"), u = c.get("access_token") || "", d = c.get("refresh_token") || "", f = c.get("id_token") || "", p = {
|
|
4351
|
+
access_token: u,
|
|
4352
|
+
refresh_token: d || void 0,
|
|
4353
|
+
id_token: f || void 0,
|
|
4093
4354
|
scopes: t
|
|
4094
4355
|
};
|
|
4095
|
-
await this.
|
|
4096
|
-
|
|
4356
|
+
if (l && r && (p = await this.authApi.pkceExchange(l, r.verifier), this.handlePendingSecondFactor(p))) return;
|
|
4357
|
+
await this.processAuthResponse(p, t), this.subscribeStore.notify(Z.SignIn, {
|
|
4358
|
+
tokens: p,
|
|
4097
4359
|
parsedTokens: this.tokenCacheService.getParsedTokens()
|
|
4098
4360
|
}), this.platform.navigateTo(this.platform.getCurrentUrl()?.origin ?? "");
|
|
4099
4361
|
} catch (e) {
|
|
4362
|
+
this.forgetFederatedSlot();
|
|
4100
4363
|
let t = {
|
|
4101
4364
|
operation: "federated.popup",
|
|
4102
4365
|
message: e instanceof Error ? e.message : "Authentication failed",
|
|
4103
4366
|
code: e instanceof ie ? "POPUP_CLOSED" : "AUTH_FAILED",
|
|
4104
4367
|
originalError: e
|
|
4105
4368
|
};
|
|
4106
|
-
|
|
4369
|
+
U(this.subscribeStore, t);
|
|
4107
4370
|
}
|
|
4108
4371
|
}
|
|
4109
4372
|
federatedAuthWithRedirect(e) {
|
|
4110
|
-
this.subscribeStore.notify(Z.SignInStart, { provider: e.provider });
|
|
4111
|
-
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId()
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4373
|
+
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(Lr);
|
|
4374
|
+
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
|
|
4375
|
+
this.startPkce().then((r) => {
|
|
4376
|
+
let i = this.createFederatedAuthUrl({
|
|
4377
|
+
...e,
|
|
4378
|
+
scopes: t,
|
|
4379
|
+
device: n,
|
|
4380
|
+
...r ? {
|
|
4381
|
+
code_challenge: r.challenge,
|
|
4382
|
+
code_challenge_method: "S256"
|
|
4383
|
+
} : {}
|
|
4384
|
+
});
|
|
4385
|
+
r ? this.rememberFederatedSlot(r.verifier, t) : this.forgetFederatedSlot(), this.platform.navigateTo(i);
|
|
4386
|
+
}).catch((e) => this.reportFederatedRedirectFailure(e));
|
|
4387
|
+
}
|
|
4388
|
+
handleFederatedCode(e) {
|
|
4389
|
+
if (!this.appId) return !1;
|
|
4390
|
+
let t = this.readFederatedSlot();
|
|
4391
|
+
return t ? (this.forgetFederatedSlot(), this.finishFederatedLanding(e, t), !0) : !1;
|
|
4392
|
+
}
|
|
4393
|
+
async finishFederatedLanding(e, t) {
|
|
4394
|
+
try {
|
|
4395
|
+
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
4396
|
+
if (this.handlePendingSecondFactor(n)) return;
|
|
4397
|
+
await this.processAuthResponse(n, t.scopes), this.subscribeStore.notify(Z.SignIn, {
|
|
4398
|
+
tokens: n,
|
|
4399
|
+
parsedTokens: this.tokenCacheService.getParsedTokens(),
|
|
4400
|
+
source: "federated-landing"
|
|
4401
|
+
}), await this.submitSessionCheck();
|
|
4402
|
+
} catch (e) {
|
|
4403
|
+
this.reportFederatedRedirectFailure(e);
|
|
4404
|
+
}
|
|
4405
|
+
}
|
|
4406
|
+
reportFederatedRedirectFailure(e) {
|
|
4407
|
+
let t = {
|
|
4408
|
+
operation: "federated.redirect",
|
|
4409
|
+
message: e instanceof Error ? e.message : "Federated sign-in failed",
|
|
4410
|
+
originalError: e,
|
|
4411
|
+
code: e instanceof B ? e.id : void 0
|
|
4412
|
+
};
|
|
4413
|
+
U(this.subscribeStore, t);
|
|
4117
4414
|
}
|
|
4118
4415
|
authRedirectUrl(e = {}) {
|
|
4119
4416
|
try {
|
|
@@ -4131,7 +4428,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4131
4428
|
message: e instanceof Error ? e.message : "Failed to create auth redirect URL",
|
|
4132
4429
|
originalError: e
|
|
4133
4430
|
};
|
|
4134
|
-
throw
|
|
4431
|
+
throw U(this.subscribeStore, t), e;
|
|
4135
4432
|
}
|
|
4136
4433
|
}
|
|
4137
4434
|
authRedirect(e = {}) {
|
|
@@ -4143,7 +4440,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4143
4440
|
message: e instanceof Error ? e.message : "Failed to redirect to auth page",
|
|
4144
4441
|
originalError: e
|
|
4145
4442
|
};
|
|
4146
|
-
throw
|
|
4443
|
+
throw U(this.subscribeStore, t), e;
|
|
4147
4444
|
}
|
|
4148
4445
|
}
|
|
4149
4446
|
isAuthenticated(e) {
|
|
@@ -4159,7 +4456,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4159
4456
|
message: e instanceof Error ? e.message : "Failed to check authentication status",
|
|
4160
4457
|
originalError: e
|
|
4161
4458
|
};
|
|
4162
|
-
return
|
|
4459
|
+
return U(this.subscribeStore, t), !1;
|
|
4163
4460
|
}
|
|
4164
4461
|
}
|
|
4165
4462
|
async submitSessionCheck(e = !1) {
|
|
@@ -4172,7 +4469,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4172
4469
|
message: e instanceof Error || e instanceof B ? e.message : "Session check failed",
|
|
4173
4470
|
originalError: e
|
|
4174
4471
|
};
|
|
4175
|
-
|
|
4472
|
+
U(this.subscribeStore, n), t = void 0;
|
|
4176
4473
|
}
|
|
4177
4474
|
return t && this.sessionCallbacks.createSession && await this.sessionCallbacks.createSession({
|
|
4178
4475
|
tokens: t,
|
|
@@ -4199,11 +4496,11 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4199
4496
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4200
4497
|
originalError: e
|
|
4201
4498
|
};
|
|
4202
|
-
|
|
4499
|
+
U(this.subscribeStore, t);
|
|
4203
4500
|
return;
|
|
4204
4501
|
}
|
|
4205
4502
|
}
|
|
4206
|
-
},
|
|
4503
|
+
}, Wr = class {
|
|
4207
4504
|
constructor(e) {
|
|
4208
4505
|
this.invitationApi = e;
|
|
4209
4506
|
}
|
|
@@ -4222,7 +4519,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4222
4519
|
getInvitationLink(e) {
|
|
4223
4520
|
return this.invitationApi.getInvitationLink(e);
|
|
4224
4521
|
}
|
|
4225
|
-
},
|
|
4522
|
+
}, Gr = class {
|
|
4226
4523
|
constructor(e) {
|
|
4227
4524
|
this.data = this.normalize(e);
|
|
4228
4525
|
}
|
|
@@ -4279,9 +4576,9 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4279
4576
|
getData() {
|
|
4280
4577
|
return this.data;
|
|
4281
4578
|
}
|
|
4282
|
-
},
|
|
4579
|
+
}, Kr = class {
|
|
4283
4580
|
constructor(e, t, n) {
|
|
4284
|
-
this.tenantApi = e, this.scopes = t, this.logger = n ||
|
|
4581
|
+
this.tenantApi = e, this.scopes = t, this.logger = n || En();
|
|
4285
4582
|
}
|
|
4286
4583
|
handlePassflowError(t, n) {
|
|
4287
4584
|
if (e.isAxiosError(t) && t.response?.data) {
|
|
@@ -4317,7 +4614,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4317
4614
|
}
|
|
4318
4615
|
async getTenantUserMembership(e) {
|
|
4319
4616
|
try {
|
|
4320
|
-
return new
|
|
4617
|
+
return new Gr(await this.tenantApi.getTenantDetails(e));
|
|
4321
4618
|
} catch (t) {
|
|
4322
4619
|
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
4323
4620
|
}
|
|
@@ -4462,7 +4759,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4462
4759
|
this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
|
|
4463
4760
|
}
|
|
4464
4761
|
}
|
|
4465
|
-
},
|
|
4762
|
+
}, qr = class {
|
|
4466
4763
|
constructor(e, t, n, r = P) {
|
|
4467
4764
|
this.storageManager = e, this.subscribeStore = n, this.platform = r, this.checkInterval = null, this.CHECK_INTERVAL = 6e4, this.unsubscribeForeground = null, this.unsubscribeUnload = null, this.tokenExpiredFlag = !1, this.storageManager = e, this.setupLifecycleListeners();
|
|
4468
4765
|
}
|
|
@@ -4487,7 +4784,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4487
4784
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4488
4785
|
originalError: e
|
|
4489
4786
|
};
|
|
4490
|
-
|
|
4787
|
+
U(this.subscribeStore, t), this.setTokensCache(void 0);
|
|
4491
4788
|
}
|
|
4492
4789
|
}
|
|
4493
4790
|
startTokenCheck() {
|
|
@@ -4532,7 +4829,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4532
4829
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4533
4830
|
originalError: e
|
|
4534
4831
|
};
|
|
4535
|
-
|
|
4832
|
+
U(this.subscribeStore, t);
|
|
4536
4833
|
return;
|
|
4537
4834
|
}
|
|
4538
4835
|
}
|
|
@@ -4542,14 +4839,14 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4542
4839
|
isExpired() {
|
|
4543
4840
|
return this.tokensCache ? this.tokensCache.access_token ? k(A(this.tokensCache.access_token)) : !1 : !0;
|
|
4544
4841
|
}
|
|
4545
|
-
},
|
|
4842
|
+
}, Jr = class {
|
|
4546
4843
|
constructor(e, t, n) {
|
|
4547
4844
|
this.twoFactorApi = e, this.subscribeStore = t, this.signInCompleter = n, this.PARTIAL_AUTH_TIMEOUT_MS = 3e5, this.SESSION_STORAGE_KEY = "passflow_2fa_challenge", this.totpDigits = 6, this.subscribeStore.subscribe({ onAuthChange: (e, t) => {
|
|
4548
4845
|
if (e === Z.TwoFactorRequired) {
|
|
4549
4846
|
let e = t;
|
|
4550
4847
|
this.setPartialAuthState(e.email, e.challengeId, e.tfaToken);
|
|
4551
4848
|
}
|
|
4552
|
-
(e === Z.SignIn || e === Z.Register) && this.clearPartialAuthState();
|
|
4849
|
+
(e === Z.SignIn || e === Z.Register) && (this.clearPartialAuthState(), this.clearMagicLinkSession());
|
|
4553
4850
|
} }, [
|
|
4554
4851
|
Z.TwoFactorRequired,
|
|
4555
4852
|
Z.SignIn,
|
|
@@ -4563,11 +4860,11 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4563
4860
|
originalError: e,
|
|
4564
4861
|
code: r?.id || void 0
|
|
4565
4862
|
};
|
|
4566
|
-
throw
|
|
4863
|
+
throw U(this.subscribeStore, i), e;
|
|
4567
4864
|
}
|
|
4568
4865
|
async getStatus() {
|
|
4569
4866
|
try {
|
|
4570
|
-
let e = await this.twoFactorApi.getStatus();
|
|
4867
|
+
let e = await this.twoFactorApi.getStatus(this.getMagicLinkSessionToken() ?? void 0);
|
|
4571
4868
|
return e.totp_digits && (this.totpDigits = e.totp_digits), e;
|
|
4572
4869
|
} catch (e) {
|
|
4573
4870
|
this.emitErrorAndThrow(e, "2fa.status", "Get 2FA status");
|
|
@@ -4575,28 +4872,70 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4575
4872
|
}
|
|
4576
4873
|
async beginSetup() {
|
|
4577
4874
|
try {
|
|
4578
|
-
|
|
4579
|
-
return e.totp_digits && (this.totpDigits = e.totp_digits), this.subscribeStore.notify(Z.TwoFactorSetupStarted, { secret: e.secret }), e;
|
|
4875
|
+
return this.setupStarted(await this.twoFactorApi.beginSetup(this.getMagicLinkSessionToken() ?? void 0));
|
|
4580
4876
|
} catch (e) {
|
|
4581
4877
|
this.emitErrorAndThrow(e, "2fa.setup.begin", "Begin 2FA setup");
|
|
4582
4878
|
}
|
|
4583
4879
|
}
|
|
4584
4880
|
async confirmSetup(e) {
|
|
4585
|
-
|
|
4881
|
+
this.assertTotpCode(e);
|
|
4586
4882
|
try {
|
|
4587
|
-
let t = await this.twoFactorApi.confirmSetup({ code: e });
|
|
4588
|
-
return this.
|
|
4589
|
-
recoveryCodes: t.recovery_codes,
|
|
4590
|
-
clearRecoveryCodes: () => {
|
|
4591
|
-
t.recovery_codes.length = 0;
|
|
4592
|
-
}
|
|
4593
|
-
}), t;
|
|
4883
|
+
let t = await this.twoFactorApi.confirmSetup({ code: e }, this.getMagicLinkSessionToken() ?? void 0);
|
|
4884
|
+
return this.clearMagicLinkSession(), this.setupConfirmed(t);
|
|
4594
4885
|
} catch (e) {
|
|
4595
4886
|
this.emitErrorAndThrow(e, "2fa.setup.confirm", "Confirm 2FA setup");
|
|
4596
4887
|
}
|
|
4597
4888
|
}
|
|
4889
|
+
async getEnrollment() {
|
|
4890
|
+
try {
|
|
4891
|
+
return await this.twoFactorApi.getEnrollment(this.requirePendingTfaToken());
|
|
4892
|
+
} catch (e) {
|
|
4893
|
+
this.emitErrorAndThrow(e, "2fa.enrollment.read", "Read 2FA enrollment");
|
|
4894
|
+
}
|
|
4895
|
+
}
|
|
4896
|
+
async sendSetupLink() {
|
|
4897
|
+
try {
|
|
4898
|
+
return await this.twoFactorApi.sendSetupLink(this.requirePendingTfaToken());
|
|
4899
|
+
} catch (e) {
|
|
4900
|
+
this.emitErrorAndThrow(e, "2fa.enrollment.setup-link", "Send 2FA setup link");
|
|
4901
|
+
}
|
|
4902
|
+
}
|
|
4903
|
+
async beginEnrollment() {
|
|
4904
|
+
try {
|
|
4905
|
+
return this.setupStarted(await this.twoFactorApi.beginEnrollment(this.requirePendingTfaToken()));
|
|
4906
|
+
} catch (e) {
|
|
4907
|
+
this.emitErrorAndThrow(e, "2fa.setup.begin", "Begin 2FA enrollment");
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
4910
|
+
async confirmEnrollment(e) {
|
|
4911
|
+
this.assertTotpCode(e);
|
|
4912
|
+
try {
|
|
4913
|
+
return this.setupConfirmed(await this.twoFactorApi.confirmEnrollment(this.requirePendingTfaToken(), { code: e }));
|
|
4914
|
+
} catch (e) {
|
|
4915
|
+
this.emitErrorAndThrow(e, "2fa.setup.confirm", "Confirm 2FA enrollment");
|
|
4916
|
+
}
|
|
4917
|
+
}
|
|
4918
|
+
assertTotpCode(e) {
|
|
4919
|
+
if (!kr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4920
|
+
}
|
|
4921
|
+
requirePendingTfaToken() {
|
|
4922
|
+
let e = this.pendingTfaToken();
|
|
4923
|
+
if (!e) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4924
|
+
return e;
|
|
4925
|
+
}
|
|
4926
|
+
setupStarted(e) {
|
|
4927
|
+
return e.totp_digits && (this.totpDigits = e.totp_digits), this.subscribeStore.notify(Z.TwoFactorSetupStarted, { secret: e.secret }), e;
|
|
4928
|
+
}
|
|
4929
|
+
setupConfirmed(e) {
|
|
4930
|
+
return this.subscribeStore.notify(Z.TwoFactorEnabled, {
|
|
4931
|
+
recoveryCodes: e.recovery_codes,
|
|
4932
|
+
clearRecoveryCodes: () => {
|
|
4933
|
+
e.recovery_codes.length = 0;
|
|
4934
|
+
}
|
|
4935
|
+
}), e;
|
|
4936
|
+
}
|
|
4598
4937
|
async verify(e, t) {
|
|
4599
|
-
if (!
|
|
4938
|
+
if (!kr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4600
4939
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4601
4940
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
4602
4941
|
try {
|
|
@@ -4612,7 +4951,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4612
4951
|
}
|
|
4613
4952
|
async useRecoveryCode(e, t) {
|
|
4614
4953
|
try {
|
|
4615
|
-
let n =
|
|
4954
|
+
let n = Ar(e);
|
|
4616
4955
|
if (!n) throw Error("Invalid recovery code format. Expected format: XXXX-XXXX or XXXXXXXX (alphanumeric).");
|
|
4617
4956
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4618
4957
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
@@ -4633,7 +4972,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4633
4972
|
}
|
|
4634
4973
|
}
|
|
4635
4974
|
async disable(e) {
|
|
4636
|
-
if (!
|
|
4975
|
+
if (!kr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4637
4976
|
try {
|
|
4638
4977
|
let t = await this.twoFactorApi.disable({ code: e });
|
|
4639
4978
|
return this.subscribeStore.notify(Z.TwoFactorDisabled, {}), t;
|
|
@@ -4642,7 +4981,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4642
4981
|
}
|
|
4643
4982
|
}
|
|
4644
4983
|
async regenerateRecoveryCodes(e) {
|
|
4645
|
-
if (!
|
|
4984
|
+
if (!kr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4646
4985
|
try {
|
|
4647
4986
|
let t = await this.twoFactorApi.regenerateRecoveryCodes({ code: e }), n = [...t.recovery_codes];
|
|
4648
4987
|
return t.recovery_codes = [], t.recovery_codes = n, t;
|
|
@@ -4826,7 +5165,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4826
5165
|
this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
|
|
4827
5166
|
}
|
|
4828
5167
|
}
|
|
4829
|
-
},
|
|
5168
|
+
}, Yr = class {
|
|
4830
5169
|
constructor(e, t, n = P) {
|
|
4831
5170
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
4832
5171
|
}
|
|
@@ -4853,69 +5192,69 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4853
5192
|
if (!s) throw Error("Passkey registration was not completed");
|
|
4854
5193
|
return await this.userAPI.addUserPasskeyComplete(s, r, a);
|
|
4855
5194
|
}
|
|
4856
|
-
},
|
|
5195
|
+
}, Xr = class extends Error {
|
|
4857
5196
|
constructor(e, t, n = !1) {
|
|
4858
5197
|
super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
|
|
4859
5198
|
}
|
|
4860
|
-
},
|
|
5199
|
+
}, Zr = (e, t) => {
|
|
4861
5200
|
let n = t?.trim();
|
|
4862
|
-
if (!n) throw new
|
|
5201
|
+
if (!n) throw new Xr(e, "A verification code is required");
|
|
4863
5202
|
return n;
|
|
4864
|
-
},
|
|
5203
|
+
}, Qr = {
|
|
4865
5204
|
type: "totp",
|
|
4866
5205
|
requiresPrepare: !1,
|
|
4867
5206
|
input: "code",
|
|
4868
|
-
assert: async ({ code: e }) => ({ code:
|
|
4869
|
-
},
|
|
5207
|
+
assert: async ({ code: e }) => ({ code: Zr("totp", e) })
|
|
5208
|
+
}, $r = {
|
|
4870
5209
|
type: "recovery_codes",
|
|
4871
5210
|
requiresPrepare: !1,
|
|
4872
5211
|
input: "code",
|
|
4873
|
-
assert: async ({ code: e }) => ({ code:
|
|
4874
|
-
},
|
|
5212
|
+
assert: async ({ code: e }) => ({ code: Zr("recovery_codes", e) })
|
|
5213
|
+
}, ei = {
|
|
4875
5214
|
type: "passkey",
|
|
4876
5215
|
requiresPrepare: !0,
|
|
4877
5216
|
input: "none",
|
|
4878
5217
|
assert: async ({ prepared: e, platform: t }) => {
|
|
4879
|
-
if (!e?.webauthn) throw new
|
|
5218
|
+
if (!e?.webauthn) throw new Xr("passkey", "The upgrade challenge carried no WebAuthn options");
|
|
4880
5219
|
let n = t.passkeys;
|
|
4881
|
-
if (!n) throw new
|
|
5220
|
+
if (!n) throw new Xr("passkey", "This platform does not support passkeys");
|
|
4882
5221
|
let r;
|
|
4883
5222
|
try {
|
|
4884
5223
|
r = await n.startAuthentication(e.webauthn);
|
|
4885
5224
|
} catch (e) {
|
|
4886
|
-
throw new
|
|
5225
|
+
throw new Xr("passkey", e?.message || "Passkey verification was cancelled", !0);
|
|
4887
5226
|
}
|
|
4888
|
-
if (!r) throw new
|
|
5227
|
+
if (!r) throw new Xr("passkey", "Passkey verification was cancelled", !0);
|
|
4889
5228
|
return {
|
|
4890
5229
|
challenge_id: e.challengeId,
|
|
4891
5230
|
credential: r
|
|
4892
5231
|
};
|
|
4893
5232
|
}
|
|
4894
|
-
},
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
]),
|
|
5233
|
+
}, ti = Object.freeze([
|
|
5234
|
+
Qr,
|
|
5235
|
+
ei,
|
|
5236
|
+
$r
|
|
5237
|
+
]), ni = (e = ti) => new Map(e.map((e) => [e.type, e])), ri = 3, ii = {
|
|
4899
5238
|
passkey: 0,
|
|
4900
5239
|
totp: 1,
|
|
4901
5240
|
email_otp: 2,
|
|
4902
5241
|
sms_otp: 3,
|
|
4903
5242
|
recovery_codes: 9
|
|
4904
|
-
},
|
|
4905
|
-
let n =
|
|
5243
|
+
}, ai = (e) => e.requiredLevel ?? L(e.acrValues), oi = (e, t) => {
|
|
5244
|
+
let n = ii[e.type] ?? 5, r = t !== void 0 && t >= ri, i = e.type === "passkey";
|
|
4906
5245
|
return (r && !i ? 100 : 0) + n;
|
|
4907
|
-
},
|
|
4908
|
-
let n =
|
|
4909
|
-
return [...e].sort((e, t) =>
|
|
4910
|
-
},
|
|
5246
|
+
}, si = (e, t) => {
|
|
5247
|
+
let n = ai(t);
|
|
5248
|
+
return [...e].sort((e, t) => oi(e, n) - oi(t, n));
|
|
5249
|
+
}, ci = class extends Error {
|
|
4911
5250
|
constructor(e) {
|
|
4912
5251
|
super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
|
|
4913
5252
|
}
|
|
4914
|
-
},
|
|
5253
|
+
}, li = class extends Error {
|
|
4915
5254
|
constructor(e = "No available authentication factor can satisfy this challenge") {
|
|
4916
5255
|
super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
|
|
4917
5256
|
}
|
|
4918
|
-
},
|
|
5257
|
+
}, ui = 4, di = 3e4, fi = () => {
|
|
4919
5258
|
let e = () => void 0, t = () => void 0;
|
|
4920
5259
|
return {
|
|
4921
5260
|
promise: new Promise((n, r) => {
|
|
@@ -4924,11 +5263,11 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4924
5263
|
resolve: e,
|
|
4925
5264
|
reject: t
|
|
4926
5265
|
};
|
|
4927
|
-
},
|
|
5266
|
+
}, pi = (e) => ({
|
|
4928
5267
|
acrValues: e.acrValues,
|
|
4929
5268
|
level: e.requiredLevel,
|
|
4930
5269
|
maxAge: e.maxAge
|
|
4931
|
-
}),
|
|
5270
|
+
}), mi = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, hi = (e, t) => {
|
|
4932
5271
|
let n = e.requiredLevel === void 0 ? t.requiredLevel : t.requiredLevel === void 0 ? e.requiredLevel : Math.max(e.requiredLevel, t.requiredLevel), r = n === void 0 ? e.acrValues ?? t.acrValues : n === e.requiredLevel ? e.acrValues : t.acrValues, i = e.maxAge === void 0 ? t.maxAge : t.maxAge === void 0 ? e.maxAge : Math.min(e.maxAge, t.maxAge), a = Array.from(/* @__PURE__ */ new Set([...e.channels ?? [], ...t.channels ?? []]));
|
|
4933
5272
|
return {
|
|
4934
5273
|
acrValues: r,
|
|
@@ -4937,12 +5276,12 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4937
5276
|
status: e.status,
|
|
4938
5277
|
...a.length > 0 ? { channels: a } : {}
|
|
4939
5278
|
};
|
|
4940
|
-
},
|
|
5279
|
+
}, gi = (e, t) => {
|
|
4941
5280
|
let n = t.requiredLevel !== void 0 && (e.requiredLevel === void 0 || t.requiredLevel > e.requiredLevel), r = t.maxAge !== void 0 && (e.maxAge === void 0 || t.maxAge < e.maxAge);
|
|
4942
5281
|
return n || r;
|
|
4943
|
-
},
|
|
5282
|
+
}, _i = class {
|
|
4944
5283
|
constructor(e) {
|
|
4945
|
-
this.state = "idle", this.inFlight = null, this.requirement = null, this.selected = null, this.rankedRequirement = null, this.registrations = [], this.proof = null, this.pruned = /* @__PURE__ */ new Set(), this.openPrompt = null, this.transport = e.transport, this.prompt = e.prompt, this.platform = e.platform, this.available = e.factors ??
|
|
5284
|
+
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 ?? ti, this.registry = ni(this.available), this.maxAttempts = e.maxAttempts ?? ui, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? di;
|
|
4946
5285
|
}
|
|
4947
5286
|
get currentState() {
|
|
4948
5287
|
return this.state;
|
|
@@ -4962,9 +5301,9 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4962
5301
|
}
|
|
4963
5302
|
register(e, t) {
|
|
4964
5303
|
let n = t.kind === "imperative" && t.requested !== void 0, r = {
|
|
4965
|
-
demanded: t.kind === "imperative" && t.requested ? t.requested :
|
|
5304
|
+
demanded: t.kind === "imperative" && t.requested ? t.requested : pi(e),
|
|
4966
5305
|
statedBar: n,
|
|
4967
|
-
settlement:
|
|
5306
|
+
settlement: fi(),
|
|
4968
5307
|
reported: !1,
|
|
4969
5308
|
entry: {
|
|
4970
5309
|
...t,
|
|
@@ -4980,15 +5319,15 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
4980
5319
|
this.requirement = e;
|
|
4981
5320
|
return;
|
|
4982
5321
|
}
|
|
4983
|
-
let n =
|
|
4984
|
-
this.requirement =
|
|
5322
|
+
let n = gi(t, e);
|
|
5323
|
+
this.requirement = hi(t, e), n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
|
|
4985
5324
|
challenge: this.requirement,
|
|
4986
5325
|
factors: this.offeredFactors()
|
|
4987
5326
|
});
|
|
4988
5327
|
}
|
|
4989
5328
|
offeredFactors() {
|
|
4990
5329
|
let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
|
|
4991
|
-
return t ?
|
|
5330
|
+
return t ? si(e, t) : e;
|
|
4992
5331
|
}
|
|
4993
5332
|
receiveReport(e, t) {
|
|
4994
5333
|
e.reported || (e.reported = !0, e.entry.outcome = t.outcome, t.obtained && (e.entry.obtained = t.obtained), t.required && (e.entry.required = t.required), this.notifyReportsSettled());
|
|
@@ -5023,12 +5362,12 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5023
5362
|
}
|
|
5024
5363
|
release(e, t) {
|
|
5025
5364
|
if (e.entry.kind === "imperative") {
|
|
5026
|
-
if (e.statedBar &&
|
|
5365
|
+
if (e.statedBar && !mi(t, e.demanded)) {
|
|
5027
5366
|
this.receiveReport(e, {
|
|
5028
5367
|
outcome: "insufficient",
|
|
5029
5368
|
obtained: t,
|
|
5030
5369
|
required: e.demanded
|
|
5031
|
-
}), e.settlement.reject(new
|
|
5370
|
+
}), e.settlement.reject(new yr(t, e.demanded));
|
|
5032
5371
|
return;
|
|
5033
5372
|
}
|
|
5034
5373
|
this.receiveReport(e, {
|
|
@@ -5101,7 +5440,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5101
5440
|
let t = this.offeredFactors();
|
|
5102
5441
|
if (t.length === 0) return {
|
|
5103
5442
|
status: "failed",
|
|
5104
|
-
reason: new
|
|
5443
|
+
reason: new li()
|
|
5105
5444
|
};
|
|
5106
5445
|
let n = this.requirement, r;
|
|
5107
5446
|
try {
|
|
@@ -5109,24 +5448,24 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5109
5448
|
} catch (e) {
|
|
5110
5449
|
return {
|
|
5111
5450
|
status: "failed",
|
|
5112
|
-
reason: new
|
|
5451
|
+
reason: new ci(e)
|
|
5113
5452
|
};
|
|
5114
5453
|
}
|
|
5115
5454
|
if (r.type === "cancel") return {
|
|
5116
5455
|
status: "failed",
|
|
5117
|
-
reason: new
|
|
5456
|
+
reason: new ci()
|
|
5118
5457
|
};
|
|
5119
5458
|
let i = this.registry.get(r.factor);
|
|
5120
|
-
if (!i) e = new
|
|
5459
|
+
if (!i) e = new li(`Unknown authentication factor: ${r.factor}`), this.state = "collecting", this.selected = null;
|
|
5121
5460
|
else try {
|
|
5122
5461
|
return await this.proveAndCommit(i, r.code), {
|
|
5123
5462
|
status: "proven",
|
|
5124
|
-
obtained: this.readObtainedBar?.() ??
|
|
5463
|
+
obtained: this.readObtainedBar?.() ?? pi(this.rankedRequirement ?? n)
|
|
5125
5464
|
};
|
|
5126
5465
|
} catch (t) {
|
|
5127
|
-
if (t instanceof
|
|
5466
|
+
if (t instanceof Xr && t.cancelled) return {
|
|
5128
5467
|
status: "failed",
|
|
5129
|
-
reason: new
|
|
5468
|
+
reason: new ci()
|
|
5130
5469
|
};
|
|
5131
5470
|
let n = this.classifyProofFailure(t);
|
|
5132
5471
|
if (n) return {
|
|
@@ -5156,15 +5495,15 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5156
5495
|
return this.openPrompt = r, this.prompt(r);
|
|
5157
5496
|
}
|
|
5158
5497
|
classifyProofFailure(e) {
|
|
5159
|
-
if (e instanceof
|
|
5498
|
+
if (e instanceof yr || e instanceof br || e instanceof xr) return e;
|
|
5160
5499
|
if (e instanceof $) switch (e.kind) {
|
|
5161
|
-
case "unavailable": return new
|
|
5500
|
+
case "unavailable": return new br(e.message);
|
|
5162
5501
|
case "exhausted":
|
|
5163
5502
|
case "attempts_exhausted":
|
|
5164
5503
|
case "fatal":
|
|
5165
5504
|
case "protocol":
|
|
5166
5505
|
case "network": return e;
|
|
5167
|
-
case "session_changed": return new
|
|
5506
|
+
case "session_changed": return new xr(e.message);
|
|
5168
5507
|
default: return;
|
|
5169
5508
|
}
|
|
5170
5509
|
}
|
|
@@ -5176,28 +5515,28 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5176
5515
|
});
|
|
5177
5516
|
await this.transport.commit(e.type, r);
|
|
5178
5517
|
}
|
|
5179
|
-
},
|
|
5518
|
+
}, vi = (e) => typeof e == "function" ? e() : e, yi = (e) => {
|
|
5180
5519
|
try {
|
|
5181
5520
|
return new URL(e);
|
|
5182
5521
|
} catch {
|
|
5183
5522
|
return;
|
|
5184
5523
|
}
|
|
5185
|
-
},
|
|
5524
|
+
}, bi = (e, t) => {
|
|
5186
5525
|
if (!t || t === "/") return !0;
|
|
5187
5526
|
let n = t.replace(/\/+$/, "");
|
|
5188
5527
|
return e === n || e.startsWith(`${n}/`);
|
|
5189
|
-
},
|
|
5528
|
+
}, xi = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && bi(e.pathname, t.pathPrefix), Si = (e, t) => {
|
|
5190
5529
|
for (let n of t) {
|
|
5191
5530
|
if (n === "") continue;
|
|
5192
5531
|
if (n.startsWith("/")) {
|
|
5193
|
-
if (e.relativeToBase &&
|
|
5532
|
+
if (e.relativeToBase && bi(e.pathname, n)) return !0;
|
|
5194
5533
|
continue;
|
|
5195
5534
|
}
|
|
5196
|
-
let t =
|
|
5197
|
-
if (t && e.origin !== void 0 && e.origin === t.origin &&
|
|
5535
|
+
let t = yi(n) ?? yi(`https://${n}`);
|
|
5536
|
+
if (t && e.origin !== void 0 && e.origin === t.origin && bi(e.pathname, t.pathname)) return !0;
|
|
5198
5537
|
}
|
|
5199
5538
|
return !1;
|
|
5200
|
-
},
|
|
5539
|
+
}, Ci = (e, t, n) => xi(e, t.passflow) || Si(e, t.backend) ? !n || n(e.href) !== !1 : !1, wi = (e) => {
|
|
5201
5540
|
let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
|
|
5202
5541
|
console.warn(n, {
|
|
5203
5542
|
status: e.status,
|
|
@@ -5205,8 +5544,8 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5205
5544
|
reason: e.reason,
|
|
5206
5545
|
detail: t
|
|
5207
5546
|
});
|
|
5208
|
-
},
|
|
5209
|
-
let n = t.onUpgradeDiagnostic ??
|
|
5547
|
+
}, Ti = (e, t) => {
|
|
5548
|
+
let n = t.onUpgradeDiagnostic ?? wi;
|
|
5210
5549
|
return (t, r) => {
|
|
5211
5550
|
n({
|
|
5212
5551
|
status: e.status,
|
|
@@ -5218,8 +5557,8 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5218
5557
|
}
|
|
5219
5558
|
});
|
|
5220
5559
|
};
|
|
5221
|
-
},
|
|
5222
|
-
let r = n.onUpgradeDiagnostic ??
|
|
5560
|
+
}, Ei = (e, t, n) => {
|
|
5561
|
+
let r = n.onUpgradeDiagnostic ?? wi;
|
|
5223
5562
|
for (let n of e) r({
|
|
5224
5563
|
...n,
|
|
5225
5564
|
url: t.request.href,
|
|
@@ -5228,8 +5567,8 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5228
5567
|
...n.detail ?? {}
|
|
5229
5568
|
}
|
|
5230
5569
|
});
|
|
5231
|
-
},
|
|
5232
|
-
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n &&
|
|
5570
|
+
}, Di = /\bjson\b/i, Oi = async (e, t) => {
|
|
5571
|
+
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && Di.test(r), a;
|
|
5233
5572
|
if (i) try {
|
|
5234
5573
|
a = await e.readBody();
|
|
5235
5574
|
} catch {
|
|
@@ -5243,10 +5582,10 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5243
5582
|
status: e.status,
|
|
5244
5583
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5245
5584
|
}, { requireChallengeChannel: t.requireChallengeChannel });
|
|
5246
|
-
},
|
|
5585
|
+
}, ki = (e) => ve({
|
|
5247
5586
|
status: e.status,
|
|
5248
5587
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5249
|
-
}, { requireChallengeChannel: "header" }).challenge,
|
|
5588
|
+
}, { requireChallengeChannel: "header" }).challenge, Ai = (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.`, ji = (e, t) => e instanceof ci ? { kind: "cancelled" } : e instanceof li ? { kind: "unsatisfiable" } : e instanceof br ? { kind: "unavailable" } : e instanceof xr ? { kind: "session-changed" } : e instanceof yr ? {
|
|
5250
5589
|
kind: "insufficient",
|
|
5251
5590
|
obtained: e.obtained,
|
|
5252
5591
|
required: e.required
|
|
@@ -5262,17 +5601,17 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5262
5601
|
kind: "transport-failure",
|
|
5263
5602
|
retryable: !1,
|
|
5264
5603
|
error: e instanceof Error ? e : Error(String(e))
|
|
5265
|
-
},
|
|
5604
|
+
}, Mi = async (e, t, n, r) => {
|
|
5266
5605
|
if (e.status !== 401 && e.status !== 403) return {
|
|
5267
5606
|
kind: "replayed",
|
|
5268
5607
|
response: e
|
|
5269
5608
|
};
|
|
5270
|
-
let { challenge: i, diagnostics: a } = await
|
|
5271
|
-
if (
|
|
5609
|
+
let { challenge: i, diagnostics: a } = await Oi(e, t);
|
|
5610
|
+
if (Ei(a, e, t), !i) return {
|
|
5272
5611
|
kind: "replayed",
|
|
5273
5612
|
response: e
|
|
5274
5613
|
};
|
|
5275
|
-
let o =
|
|
5614
|
+
let o = pi(i);
|
|
5276
5615
|
return r("elevated-insufficient", {
|
|
5277
5616
|
obtained: n,
|
|
5278
5617
|
required: o
|
|
@@ -5282,7 +5621,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5282
5621
|
required: o,
|
|
5283
5622
|
response: e
|
|
5284
5623
|
};
|
|
5285
|
-
},
|
|
5624
|
+
}, Ni = async (e, t) => {
|
|
5286
5625
|
if (!t) return {
|
|
5287
5626
|
aborted: !1,
|
|
5288
5627
|
value: await e
|
|
@@ -5309,14 +5648,14 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5309
5648
|
} finally {
|
|
5310
5649
|
n && t.removeEventListener?.("abort", n);
|
|
5311
5650
|
}
|
|
5312
|
-
},
|
|
5651
|
+
}, Pi = async (e, t) => {
|
|
5313
5652
|
if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
|
|
5314
|
-
let n =
|
|
5653
|
+
let n = Ti(e, t);
|
|
5315
5654
|
if (e.markers.replayed) {
|
|
5316
|
-
if (!
|
|
5317
|
-
let { challenge: r, diagnostics: i } = await
|
|
5318
|
-
if (
|
|
5319
|
-
let a = t.readObtainedBar?.() ?? {}, o =
|
|
5655
|
+
if (!Ci(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
|
|
5656
|
+
let { challenge: r, diagnostics: i } = await Oi(e, t);
|
|
5657
|
+
if (Ei(i, e, t), !r) return { kind: "not-a-challenge" };
|
|
5658
|
+
let a = t.readObtainedBar?.() ?? {}, o = pi(r);
|
|
5320
5659
|
return n("elevated-insufficient", {
|
|
5321
5660
|
obtained: a,
|
|
5322
5661
|
required: o
|
|
@@ -5327,12 +5666,12 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5327
5666
|
response: e
|
|
5328
5667
|
};
|
|
5329
5668
|
}
|
|
5330
|
-
if (!
|
|
5669
|
+
if (!Ci(e.request, t.scope, t.shouldIntercept)) return ki(e) ? (n("challenge-out-of-scope", {
|
|
5331
5670
|
header: e.getHeader("www-authenticate") ?? void 0,
|
|
5332
|
-
message:
|
|
5671
|
+
message: Ai(e.request.href, t.scope)
|
|
5333
5672
|
}), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
|
|
5334
|
-
let { challenge: r, diagnostics: i } = await
|
|
5335
|
-
if (
|
|
5673
|
+
let { challenge: r, diagnostics: i } = await Oi(e, t);
|
|
5674
|
+
if (Ei(i, e, t), !r) {
|
|
5336
5675
|
let r = e.getHeader("www-authenticate");
|
|
5337
5676
|
return t.requireChallengeChannel !== "header" && n("no-channel", {
|
|
5338
5677
|
...r ? { header: r } : {},
|
|
@@ -5346,9 +5685,9 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5346
5685
|
method: e.request.method
|
|
5347
5686
|
}, s, c;
|
|
5348
5687
|
try {
|
|
5349
|
-
s = Promise.resolve(t.elevate(r, o)), c = await
|
|
5688
|
+
s = Promise.resolve(t.elevate(r, o)), c = await Ni(s, e.signal);
|
|
5350
5689
|
} catch (e) {
|
|
5351
|
-
return
|
|
5690
|
+
return ji(e, void 0);
|
|
5352
5691
|
}
|
|
5353
5692
|
if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
|
|
5354
5693
|
kind: "aborted",
|
|
@@ -5359,7 +5698,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5359
5698
|
kind: "aborted",
|
|
5360
5699
|
reason: e.signal.reason
|
|
5361
5700
|
};
|
|
5362
|
-
let u = l?.obtained ?? t.readObtainedBar?.() ??
|
|
5701
|
+
let u = l?.obtained ?? t.readObtainedBar?.() ?? pi(r), d = t.authorizationSwap?.(), f = d ? {
|
|
5363
5702
|
from: a?.from ?? d.from,
|
|
5364
5703
|
to: d.to
|
|
5365
5704
|
} : void 0;
|
|
@@ -5368,7 +5707,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5368
5707
|
try {
|
|
5369
5708
|
p = await e.replay(f ? { authorizationSwap: f } : void 0);
|
|
5370
5709
|
} catch (t) {
|
|
5371
|
-
if (t instanceof
|
|
5710
|
+
if (t instanceof yr) return l?.waiter.report({
|
|
5372
5711
|
outcome: "insufficient",
|
|
5373
5712
|
obtained: t.obtained,
|
|
5374
5713
|
required: t.required
|
|
@@ -5386,7 +5725,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5386
5725
|
};
|
|
5387
5726
|
throw t;
|
|
5388
5727
|
}
|
|
5389
|
-
let m = await
|
|
5728
|
+
let m = await Mi(p, t, u, n);
|
|
5390
5729
|
return m.kind === "insufficient" ? l?.waiter.report({
|
|
5391
5730
|
outcome: "insufficient",
|
|
5392
5731
|
obtained: m.obtained,
|
|
@@ -5395,18 +5734,18 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5395
5734
|
outcome: "replayed",
|
|
5396
5735
|
obtained: u
|
|
5397
5736
|
}), m;
|
|
5398
|
-
},
|
|
5737
|
+
}, Fi = (e) => {
|
|
5399
5738
|
switch (e.kind) {
|
|
5400
|
-
case "cancelled": return new
|
|
5401
|
-
case "unsatisfiable": return new
|
|
5402
|
-
case "unavailable": return new
|
|
5403
|
-
case "session-changed": return new
|
|
5404
|
-
case "insufficient": return new
|
|
5739
|
+
case "cancelled": return new ci();
|
|
5740
|
+
case "unsatisfiable": return new li();
|
|
5741
|
+
case "unavailable": return new br();
|
|
5742
|
+
case "session-changed": return new xr();
|
|
5743
|
+
case "insufficient": return new yr(e.obtained, e.required);
|
|
5405
5744
|
case "exhausted": return e.error;
|
|
5406
5745
|
case "transport-failure": return e.error;
|
|
5407
5746
|
default: return;
|
|
5408
5747
|
}
|
|
5409
|
-
},
|
|
5748
|
+
}, Ii = (e, t, n) => {
|
|
5410
5749
|
switch (e.kind) {
|
|
5411
5750
|
case "replayed": return {
|
|
5412
5751
|
settle: "resolve",
|
|
@@ -5424,21 +5763,21 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5424
5763
|
};
|
|
5425
5764
|
case "cancelled": return n.onCancel === "reject" ? {
|
|
5426
5765
|
settle: "reject",
|
|
5427
|
-
error: new
|
|
5766
|
+
error: new ci()
|
|
5428
5767
|
} : {
|
|
5429
5768
|
settle: "resolve",
|
|
5430
|
-
value:
|
|
5769
|
+
value: Gi(t, e)
|
|
5431
5770
|
};
|
|
5432
5771
|
case "insufficient": return {
|
|
5433
5772
|
settle: "resolve",
|
|
5434
|
-
value:
|
|
5773
|
+
value: Gi(e.response?.raw ?? t, e)
|
|
5435
5774
|
};
|
|
5436
5775
|
default: return {
|
|
5437
5776
|
settle: "resolve",
|
|
5438
|
-
value:
|
|
5777
|
+
value: Gi(t, e)
|
|
5439
5778
|
};
|
|
5440
5779
|
}
|
|
5441
|
-
},
|
|
5780
|
+
}, Li = (e, t) => {
|
|
5442
5781
|
switch (e.kind) {
|
|
5443
5782
|
case "replayed": return e.response.rejected ? {
|
|
5444
5783
|
settle: "reject",
|
|
@@ -5453,39 +5792,39 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5453
5792
|
};
|
|
5454
5793
|
default: return {
|
|
5455
5794
|
settle: "reject",
|
|
5456
|
-
error:
|
|
5795
|
+
error: Fi(e) ?? t
|
|
5457
5796
|
};
|
|
5458
5797
|
}
|
|
5459
|
-
},
|
|
5798
|
+
}, Ri = /* @__PURE__ */ new WeakSet(), zi = /* @__PURE__ */ new WeakSet(), Bi = /* @__PURE__ */ new WeakSet(), Vi = /* @__PURE__ */ new WeakSet(), Hi = /* @__PURE__ */ new WeakSet(), Ui = /* @__PURE__ */ new WeakSet(), Wi = /* @__PURE__ */ new WeakSet(), Gi = (e, t) => {
|
|
5460
5799
|
switch (t.kind) {
|
|
5461
5800
|
case "cancelled":
|
|
5462
|
-
|
|
5801
|
+
Ri.add(e);
|
|
5463
5802
|
break;
|
|
5464
5803
|
case "exhausted":
|
|
5465
|
-
|
|
5804
|
+
zi.add(e);
|
|
5466
5805
|
break;
|
|
5467
5806
|
case "insufficient":
|
|
5468
|
-
|
|
5807
|
+
Bi.add(e);
|
|
5469
5808
|
break;
|
|
5470
5809
|
case "unsatisfiable":
|
|
5471
|
-
|
|
5810
|
+
Vi.add(e);
|
|
5472
5811
|
break;
|
|
5473
5812
|
case "unavailable":
|
|
5474
|
-
|
|
5813
|
+
Hi.add(e);
|
|
5475
5814
|
break;
|
|
5476
5815
|
case "session-changed":
|
|
5477
|
-
|
|
5816
|
+
Ui.add(e);
|
|
5478
5817
|
break;
|
|
5479
|
-
case "transport-failure":
|
|
5818
|
+
case "transport-failure": Wi.add(e);
|
|
5480
5819
|
}
|
|
5481
5820
|
return e;
|
|
5482
|
-
},
|
|
5821
|
+
}, Ki = (e) => Ri.has(e), qi = (e) => zi.has(e), Ji = (e) => Bi.has(e), Yi = (e) => Vi.has(e), Xi = (e) => Hi.has(e), Zi = (e) => Ui.has(e), Qi = (e) => Wi.has(e), $i = "https://passflow-relative.invalid", ea = () => {
|
|
5483
5822
|
let e = globalThis, t = e.document?.baseURI;
|
|
5484
5823
|
if (typeof t == "string" && t !== "") return t;
|
|
5485
5824
|
let n = e.location?.href;
|
|
5486
|
-
return typeof n == "string" && n !== "" && n !== "about:blank" ? n :
|
|
5487
|
-
},
|
|
5488
|
-
let n = t ===
|
|
5825
|
+
return typeof n == "string" && n !== "" && n !== "about:blank" ? n : $i;
|
|
5826
|
+
}, ta = (e, t = ea()) => {
|
|
5827
|
+
let n = t === $i, r;
|
|
5489
5828
|
try {
|
|
5490
5829
|
r = new URL(t).origin;
|
|
5491
5830
|
} catch {
|
|
@@ -5511,28 +5850,28 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5511
5850
|
relativeToBase: !1,
|
|
5512
5851
|
sentinelBase: n
|
|
5513
5852
|
};
|
|
5514
|
-
},
|
|
5853
|
+
}, na = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, ra = (e) => {
|
|
5515
5854
|
let t = [];
|
|
5516
5855
|
if (e == null) return Object.freeze(t);
|
|
5517
5856
|
let n = e;
|
|
5518
5857
|
if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
|
|
5519
|
-
let r =
|
|
5858
|
+
let r = na(n, e);
|
|
5520
5859
|
r && t.push(r);
|
|
5521
5860
|
}), Object.freeze(t);
|
|
5522
5861
|
if (Array.isArray(e)) {
|
|
5523
5862
|
for (let n of e) if (Array.isArray(n) && n.length >= 2) {
|
|
5524
|
-
let e =
|
|
5863
|
+
let e = na(String(n[0]), n[1]);
|
|
5525
5864
|
e && t.push(e);
|
|
5526
5865
|
}
|
|
5527
5866
|
return Object.freeze(t);
|
|
5528
5867
|
}
|
|
5529
5868
|
if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
|
|
5530
|
-
let e =
|
|
5869
|
+
let e = na(n, Array.isArray(r) ? r.join(", ") : r);
|
|
5531
5870
|
e && t.push(e);
|
|
5532
5871
|
}
|
|
5533
5872
|
return Object.freeze(t);
|
|
5534
|
-
},
|
|
5535
|
-
let t = e.base === void 0 ?
|
|
5873
|
+
}, ia = (e) => {
|
|
5874
|
+
let t = e.base === void 0 ? ta(e.url) : ta(e.url, e.base), n = {
|
|
5536
5875
|
raw: e.url,
|
|
5537
5876
|
href: t.href,
|
|
5538
5877
|
dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
|
|
@@ -5541,29 +5880,29 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5541
5880
|
resolved: t.resolved,
|
|
5542
5881
|
relativeToBase: t.relativeToBase,
|
|
5543
5882
|
method: (e.method ?? "GET").toUpperCase(),
|
|
5544
|
-
headers:
|
|
5883
|
+
headers: ra(e.headers),
|
|
5545
5884
|
bodyKind: e.bodyKind,
|
|
5546
5885
|
..."body" in e ? { body: e.body } : {}
|
|
5547
5886
|
};
|
|
5548
5887
|
return Object.freeze(n);
|
|
5549
|
-
},
|
|
5888
|
+
}, aa = (e, t) => {
|
|
5550
5889
|
if (!t || t.from === t.to) return e;
|
|
5551
5890
|
let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
|
|
5552
5891
|
return n ? Object.freeze(r) : e;
|
|
5553
|
-
},
|
|
5892
|
+
}, oa = (e) => {
|
|
5554
5893
|
let t = {};
|
|
5555
5894
|
for (let [n, r] of e) t[n] = r;
|
|
5556
5895
|
return t;
|
|
5557
|
-
},
|
|
5896
|
+
}, sa = /* @__PURE__ */ new Set([
|
|
5558
5897
|
"GET",
|
|
5559
5898
|
"HEAD",
|
|
5560
5899
|
"OPTIONS"
|
|
5561
|
-
]),
|
|
5900
|
+
]), ca = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, la = (e) => typeof e == "string" ? e : ca(e) ? e.url : String(e), ua = (e, t) => (t?.method ?? (ca(e) ? e.method : void 0) ?? "GET").toUpperCase(), da = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", fa = (e) => {
|
|
5562
5901
|
if (typeof e == "string") return e.length;
|
|
5563
5902
|
let t = e;
|
|
5564
5903
|
if (typeof t?.size == "number") return t.size;
|
|
5565
5904
|
if (typeof t?.byteLength == "number") return t.byteLength;
|
|
5566
|
-
},
|
|
5905
|
+
}, pa = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? sa.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), ma = (e, t, n, r, i) => ({
|
|
5567
5906
|
replayable: !1,
|
|
5568
5907
|
bodyKind: e,
|
|
5569
5908
|
reason: t,
|
|
@@ -5571,11 +5910,11 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5571
5910
|
forwardInit: i,
|
|
5572
5911
|
snapshot: r,
|
|
5573
5912
|
replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
|
|
5574
|
-
}),
|
|
5913
|
+
}), ha = (e, t) => oa(aa(e.headers, t?.authorizationSwap)), ga = (e) => {
|
|
5575
5914
|
if (!e || !("headers" in e)) return e;
|
|
5576
5915
|
let { headers: t, ...n } = e;
|
|
5577
5916
|
return n;
|
|
5578
|
-
},
|
|
5917
|
+
}, _a = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : ca(e) ? e.headers : void 0, va = (e) => {
|
|
5579
5918
|
if (e === null || typeof e == "string") return e;
|
|
5580
5919
|
if (typeof FormData < "u" && e instanceof FormData) {
|
|
5581
5920
|
let t = new FormData();
|
|
@@ -5583,18 +5922,18 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5583
5922
|
return t;
|
|
5584
5923
|
}
|
|
5585
5924
|
return typeof URLSearchParams < "u" && e instanceof URLSearchParams ? new URLSearchParams(e) : e instanceof ArrayBuffer ? e.slice(0) : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength).slice() : e;
|
|
5586
|
-
},
|
|
5587
|
-
let r =
|
|
5925
|
+
}, ya = (e, t, n) => new Request(e, { headers: ha(t, n) }), ba = (e, t, n) => {
|
|
5926
|
+
let r = la(e), i = ua(e, t), a = _a(e, t), o = (e, t) => ia({
|
|
5588
5927
|
url: r,
|
|
5589
5928
|
method: i,
|
|
5590
5929
|
headers: a,
|
|
5591
5930
|
bodyKind: e,
|
|
5592
5931
|
...t === void 0 ? {} : { body: t }
|
|
5593
5932
|
});
|
|
5594
|
-
if (
|
|
5933
|
+
if (ca(e)) {
|
|
5595
5934
|
if (e.body === null || e.body === void 0) {
|
|
5596
5935
|
let a = o("none");
|
|
5597
|
-
return
|
|
5936
|
+
return pa(n, {
|
|
5598
5937
|
url: r,
|
|
5599
5938
|
method: i,
|
|
5600
5939
|
bodyKind: "none"
|
|
@@ -5604,20 +5943,20 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5604
5943
|
forwardInput: e,
|
|
5605
5944
|
forwardInit: t,
|
|
5606
5945
|
snapshot: a,
|
|
5607
|
-
replay: (n, r) => n(
|
|
5608
|
-
} :
|
|
5946
|
+
replay: (n, r) => n(ya(e, a, r), ga(t))
|
|
5947
|
+
} : ma("none", "the replay policy refused this request", e, a, t);
|
|
5609
5948
|
}
|
|
5610
5949
|
let a = o("request-clone");
|
|
5611
|
-
if (!
|
|
5950
|
+
if (!pa(n, {
|
|
5612
5951
|
url: r,
|
|
5613
5952
|
method: i,
|
|
5614
5953
|
bodyKind: "request-clone"
|
|
5615
|
-
})) return
|
|
5954
|
+
})) return ma("request-clone", "the replay policy refused this request", e, a, t);
|
|
5616
5955
|
let s;
|
|
5617
5956
|
try {
|
|
5618
5957
|
s = e.clone();
|
|
5619
5958
|
} catch {
|
|
5620
|
-
return
|
|
5959
|
+
return ma("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
|
|
5621
5960
|
}
|
|
5622
5961
|
return {
|
|
5623
5962
|
replayable: !0,
|
|
@@ -5625,17 +5964,17 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5625
5964
|
forwardInput: e,
|
|
5626
5965
|
forwardInit: t,
|
|
5627
5966
|
snapshot: a,
|
|
5628
|
-
replay: (e, n) => e(
|
|
5967
|
+
replay: (e, n) => e(ya(s, a, n), ga(t))
|
|
5629
5968
|
};
|
|
5630
5969
|
}
|
|
5631
|
-
let s =
|
|
5632
|
-
if (s === "one-shot") return
|
|
5633
|
-
if (!
|
|
5970
|
+
let s = da(t?.body);
|
|
5971
|
+
if (s === "one-shot") return ma("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
|
|
5972
|
+
if (!pa(n, {
|
|
5634
5973
|
url: r,
|
|
5635
5974
|
method: i,
|
|
5636
5975
|
bodyKind: s
|
|
5637
|
-
},
|
|
5638
|
-
let c = t && "body" in t ?
|
|
5976
|
+
}, fa(t?.body))) return ma(s, "the replay policy refused this request", e, o(s), t);
|
|
5977
|
+
let c = t && "body" in t ? va(t.body ?? null) : void 0, l = o(s, c);
|
|
5639
5978
|
return {
|
|
5640
5979
|
replayable: !0,
|
|
5641
5980
|
bodyKind: s,
|
|
@@ -5643,21 +5982,21 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5643
5982
|
forwardInit: t,
|
|
5644
5983
|
snapshot: l,
|
|
5645
5984
|
replay: (e, n) => e(l.dispatchUrl, {
|
|
5646
|
-
...
|
|
5985
|
+
...ga(t),
|
|
5647
5986
|
...c === void 0 ? {} : { body: c },
|
|
5648
|
-
headers:
|
|
5987
|
+
headers: ha(l, n),
|
|
5649
5988
|
method: l.method
|
|
5650
5989
|
})
|
|
5651
5990
|
};
|
|
5652
|
-
},
|
|
5653
|
-
if (!
|
|
5991
|
+
}, xa = (e) => typeof e == "object" && !!e, Sa = (e) => (t) => {
|
|
5992
|
+
if (!xa(e)) return;
|
|
5654
5993
|
let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
|
|
5655
5994
|
return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
|
|
5656
|
-
},
|
|
5995
|
+
}, Ca = (e) => {
|
|
5657
5996
|
let t = e?.url ?? "", n = e?.baseURL;
|
|
5658
5997
|
return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
5659
|
-
},
|
|
5660
|
-
let r =
|
|
5998
|
+
}, wa = (e) => (e?.method ?? "GET").toUpperCase(), Ta = (e) => e == null ? "none" : xa(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", Ea = (e, t, n) => {
|
|
5999
|
+
let r = oa(aa(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
|
|
5661
6000
|
return {
|
|
5662
6001
|
...e,
|
|
5663
6002
|
...i ? { baseURL: void 0 } : {},
|
|
@@ -5666,10 +6005,10 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5666
6005
|
headers: r,
|
|
5667
6006
|
..."body" in t ? { data: t.body } : {}
|
|
5668
6007
|
};
|
|
5669
|
-
},
|
|
5670
|
-
let o = t ?? e?.config, s =
|
|
5671
|
-
url:
|
|
5672
|
-
method:
|
|
6008
|
+
}, Da = (e, t, n, r, i, a) => {
|
|
6009
|
+
let o = t ?? e?.config, s = Ta(o?.data), c = a ?? ia({
|
|
6010
|
+
url: Ca(o),
|
|
6011
|
+
method: wa(o),
|
|
5673
6012
|
headers: o?.headers,
|
|
5674
6013
|
bodyKind: s,
|
|
5675
6014
|
body: o?.data
|
|
@@ -5677,22 +6016,22 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5677
6016
|
url: c.href,
|
|
5678
6017
|
method: c.method,
|
|
5679
6018
|
bodyKind: s
|
|
5680
|
-
}, u = s !== "one-shot" &&
|
|
6019
|
+
}, u = s !== "one-shot" && pa(i.replay, l);
|
|
5681
6020
|
return {
|
|
5682
6021
|
status: e?.status ?? 0,
|
|
5683
|
-
getHeader:
|
|
6022
|
+
getHeader: Sa(e?.headers),
|
|
5684
6023
|
readBody: async () => e?.data,
|
|
5685
6024
|
request: c,
|
|
5686
6025
|
replay: async (e) => {
|
|
5687
|
-
let t = Te(
|
|
6026
|
+
let t = Te(Ea(o ?? {}, c, e));
|
|
5688
6027
|
try {
|
|
5689
6028
|
let e = await r(t);
|
|
5690
|
-
return
|
|
6029
|
+
return Da(e, e?.config ?? t, e, r, i, c);
|
|
5691
6030
|
} catch (e) {
|
|
5692
|
-
let n =
|
|
5693
|
-
if (!n.response || typeof n.response.status != "number" ||
|
|
6031
|
+
let n = xa(e) ? e : {};
|
|
6032
|
+
if (!n.response || typeof n.response.status != "number" || dr(e)) throw e;
|
|
5694
6033
|
return {
|
|
5695
|
-
...
|
|
6034
|
+
...Da(n.response, n.config ?? t, e, r, i, c),
|
|
5696
6035
|
rejected: !0
|
|
5697
6036
|
};
|
|
5698
6037
|
}
|
|
@@ -5706,19 +6045,19 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5706
6045
|
replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
|
|
5707
6046
|
signal: o?.signal
|
|
5708
6047
|
};
|
|
5709
|
-
},
|
|
5710
|
-
let r =
|
|
6048
|
+
}, Oa = (e, t) => async (n) => {
|
|
6049
|
+
let r = vi(e), i = xa(n) ? n : {}, a = Li(await Pi(Da(i.response, i.config, i.response, t, r), r), n);
|
|
5711
6050
|
if (a.settle === "reject") throw a.error;
|
|
5712
6051
|
return a.value;
|
|
5713
|
-
},
|
|
5714
|
-
let r = e.request, i = n ?? (typeof r == "function" ? (t) => r.call(e, t) : () => Promise.reject(/* @__PURE__ */ Error("Passflow: this client exposes no request() to replay through."))), a = e.interceptors.response.use(void 0,
|
|
6052
|
+
}, ka = (e, t, n) => {
|
|
6053
|
+
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, Oa(t, i)), o = !1;
|
|
5715
6054
|
return () => {
|
|
5716
6055
|
o || (o = !0, e.interceptors.response.eject(a));
|
|
5717
6056
|
};
|
|
5718
|
-
},
|
|
6057
|
+
}, Aa = (t, n) => {
|
|
5719
6058
|
let r = e.create(t);
|
|
5720
6059
|
return n(r), r;
|
|
5721
|
-
},
|
|
6060
|
+
}, ja = 0, Ma = (e, t) => {
|
|
5722
6061
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
5723
6062
|
if (n) return {
|
|
5724
6063
|
get aborted() {
|
|
@@ -5732,34 +6071,34 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5732
6071
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
5733
6072
|
} : {}
|
|
5734
6073
|
};
|
|
5735
|
-
},
|
|
6074
|
+
}, Na = (e) => (t) => e.headers?.get(t), Pa = (e, t, n, r, i) => ({
|
|
5736
6075
|
status: e.status,
|
|
5737
|
-
getHeader:
|
|
6076
|
+
getHeader: Na(e),
|
|
5738
6077
|
readBody: () => e.clone().json(),
|
|
5739
6078
|
request: t.snapshot,
|
|
5740
|
-
replay: async (e) =>
|
|
6079
|
+
replay: async (e) => Pa(await t.replay(n, e), t, n, r, i),
|
|
5741
6080
|
markers: r,
|
|
5742
6081
|
raw: e,
|
|
5743
6082
|
replayable: t.replayable,
|
|
5744
6083
|
replayUnsupportedReason: t.reason,
|
|
5745
6084
|
signal: i,
|
|
5746
6085
|
responseType: e.type
|
|
5747
|
-
}),
|
|
6086
|
+
}), Fa = (e, t) => {
|
|
5748
6087
|
let n = (t, n) => {
|
|
5749
|
-
|
|
6088
|
+
ja += 1;
|
|
5750
6089
|
try {
|
|
5751
6090
|
return e(t, n);
|
|
5752
6091
|
} finally {
|
|
5753
|
-
--
|
|
6092
|
+
--ja;
|
|
5754
6093
|
}
|
|
5755
6094
|
};
|
|
5756
6095
|
return async (e, r) => {
|
|
5757
|
-
if (
|
|
5758
|
-
let i =
|
|
6096
|
+
if (ja > 0) return n(e, r);
|
|
6097
|
+
let i = vi(t), a = ba(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = Ii(await Pi(Pa(o, a, n, {}, Ma(e, r)), i), o, i);
|
|
5759
6098
|
if (s.settle === "reject") throw s.error;
|
|
5760
6099
|
return s.value;
|
|
5761
6100
|
};
|
|
5762
|
-
},
|
|
6101
|
+
}, Ia = new Set(ti.filter((e) => !e.requiresPrepare).map((e) => e.type)), La = (e) => {
|
|
5763
6102
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
5764
6103
|
kind: "protocol",
|
|
5765
6104
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -5771,17 +6110,17 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5771
6110
|
webauthn: e.webauthn,
|
|
5772
6111
|
codeSentTo: e.code_sent_to
|
|
5773
6112
|
};
|
|
5774
|
-
},
|
|
6113
|
+
}, Ra = (e) => dr(e) && !fr(e), za = (e) => ({
|
|
5775
6114
|
async prepare(t) {
|
|
5776
|
-
if (!
|
|
6115
|
+
if (!Ia.has(t)) try {
|
|
5777
6116
|
let n = e.relyingPartyId?.();
|
|
5778
|
-
return
|
|
6117
|
+
return La(await e.startUpgrade(n ? {
|
|
5779
6118
|
method: t,
|
|
5780
6119
|
relying_party_id: n
|
|
5781
6120
|
} : { method: t }));
|
|
5782
6121
|
} catch (e) {
|
|
5783
|
-
if (
|
|
5784
|
-
let t =
|
|
6122
|
+
if (Ra(e)) throw e;
|
|
6123
|
+
let t = gr(e, "start");
|
|
5785
6124
|
if (t.kind === "prepare_not_required") return;
|
|
5786
6125
|
throw t;
|
|
5787
6126
|
}
|
|
@@ -5798,17 +6137,17 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5798
6137
|
assertion: n
|
|
5799
6138
|
});
|
|
5800
6139
|
} catch (t) {
|
|
5801
|
-
if (
|
|
5802
|
-
let n =
|
|
5803
|
-
throw n.status === 401 &&
|
|
6140
|
+
if (Ra(t)) throw t;
|
|
6141
|
+
let n = gr(t, "refresh");
|
|
6142
|
+
throw n.status === 401 && vr(n) && e.markSessionInvalid?.(), n;
|
|
5804
6143
|
}
|
|
5805
6144
|
}
|
|
5806
|
-
}),
|
|
6145
|
+
}), Ba = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Va = (e) => {
|
|
5807
6146
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
5808
6147
|
let i = () => {
|
|
5809
6148
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
5810
6149
|
};
|
|
5811
|
-
return
|
|
6150
|
+
return za({
|
|
5812
6151
|
...e,
|
|
5813
6152
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
5814
6153
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -5819,7 +6158,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5819
6158
|
});
|
|
5820
6159
|
}, i = (t, n) => {
|
|
5821
6160
|
let i = {}, a = {
|
|
5822
|
-
controller: new
|
|
6161
|
+
controller: new _i({
|
|
5823
6162
|
transport: r(() => i.current),
|
|
5824
6163
|
prompt: t.prompt,
|
|
5825
6164
|
platform: e.platform,
|
|
@@ -5831,17 +6170,17 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5831
6170
|
options: t,
|
|
5832
6171
|
scope: {
|
|
5833
6172
|
passflow: e.passflowDomain,
|
|
5834
|
-
backend:
|
|
6173
|
+
backend: Ba(t.backend)
|
|
5835
6174
|
},
|
|
5836
6175
|
generation: n
|
|
5837
6176
|
};
|
|
5838
6177
|
return i.current = a, a;
|
|
5839
6178
|
}, a = async (r, i) => {
|
|
5840
6179
|
let a = t;
|
|
5841
|
-
if (!a) throw new
|
|
6180
|
+
if (!a) throw new br("Step-up verification is not enabled on this Passflow instance");
|
|
5842
6181
|
a.controller.active || (a.pin = e.readSessionPin?.());
|
|
5843
6182
|
let o = await a.controller.elevate(r, i);
|
|
5844
|
-
if (!n(a)) throw new
|
|
6183
|
+
if (!n(a)) throw new xr();
|
|
5845
6184
|
return o;
|
|
5846
6185
|
}, o = () => {
|
|
5847
6186
|
let n = t, r = n?.scope ?? {
|
|
@@ -5885,9 +6224,9 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5885
6224
|
let r = [];
|
|
5886
6225
|
if (e.attachInternalSeam) {
|
|
5887
6226
|
let t = e.attachInternalSeam;
|
|
5888
|
-
t((e) =>
|
|
6227
|
+
t((e) => Oa(o, e)), r.push(() => t(void 0));
|
|
5889
6228
|
}
|
|
5890
|
-
n.interceptFetch && r.push(
|
|
6229
|
+
n.interceptFetch && r.push(Dt((e, t, n) => Fa(e, o)(t, n), {
|
|
5891
6230
|
priority: 20,
|
|
5892
6231
|
name: "passflow-upgrade"
|
|
5893
6232
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -5918,18 +6257,18 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5918
6257
|
withAuth: {
|
|
5919
6258
|
enumerable: !0,
|
|
5920
6259
|
value: (e) => {
|
|
5921
|
-
if (e) return
|
|
6260
|
+
if (e) return Fa(e, o);
|
|
5922
6261
|
let t = typeof globalThis > "u" ? void 0 : globalThis;
|
|
5923
6262
|
if (!t || typeof t.fetch != "function") throw Error("Passflow: withAuth() needs a fetch to wrap — this runtime has none.");
|
|
5924
|
-
return
|
|
6263
|
+
return Fa(t.fetch.bind(t), o);
|
|
5925
6264
|
}
|
|
5926
6265
|
},
|
|
5927
6266
|
attachAuth: {
|
|
5928
6267
|
enumerable: !0,
|
|
5929
|
-
value: (e) =>
|
|
6268
|
+
value: (e) => ka(e, o)
|
|
5930
6269
|
}
|
|
5931
6270
|
});
|
|
5932
|
-
},
|
|
6271
|
+
}, Ha, Ua = class {
|
|
5933
6272
|
get origin() {
|
|
5934
6273
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
5935
6274
|
}
|
|
@@ -5938,12 +6277,12 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5938
6277
|
this.createSessionCallback = e, this.expiredSessionCallback = t, this.doRefreshTokens = n, await this.submitSessionCheck();
|
|
5939
6278
|
};
|
|
5940
6279
|
let { url: t, appId: n, scopes: r } = e;
|
|
5941
|
-
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? P, this.storageManager = new N({
|
|
6280
|
+
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? P, this.deferFederatedLanding = e.deferFederatedLanding ?? !1, this.storageManager = new N({
|
|
5942
6281
|
prefix: e.keyStoragePrefix ?? "",
|
|
5943
6282
|
storage: this.platform.storage
|
|
5944
|
-
}), this.deviceService = new re(this.storageManager), this.authApi = new
|
|
5945
|
-
let i =
|
|
5946
|
-
this.authService = new
|
|
6283
|
+
}), this.deviceService = new re(this.storageManager), this.authApi = new nt(e, this.storageManager, this.deviceService), this.appApi = new Xe(e, this.storageManager, this.deviceService), this.userApi = new pt(e, this.storageManager, this.deviceService), this.settingApi = new at(e, this.storageManager, this.deviceService), this.tenantApi = new ot(e, this.storageManager, this.deviceService), this.invitationApi = new it(e, this.storageManager, this.deviceService), this.twoFactorApi = new dt(e, this.storageManager, this.deviceService), this.upgradeApi = new ft(e, this.storageManager, this.deviceService), this.upgradeDomain = ke(e.url), this.subscribeStore = new ir(), this.tokenCacheService = new qr(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? u, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
|
|
6284
|
+
let i = vn(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
|
|
6285
|
+
this.authService = new Ur(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
|
|
5947
6286
|
createSession: this.createSessionCallback,
|
|
5948
6287
|
expiredSession: this.expiredSessionCallback
|
|
5949
6288
|
}, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
|
|
@@ -5951,7 +6290,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5951
6290
|
...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
|
|
5952
6291
|
}), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
5953
6292
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
5954
|
-
this.userService = new
|
|
6293
|
+
this.userService = new Yr(this.userApi, this.deviceService, this.platform), this.tenantService = new Kr(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new Wr(this.invitationApi), this.twoFactorService = new Jr(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Va({
|
|
5955
6294
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
5956
6295
|
commitRefresh: async (e, t) => {
|
|
5957
6296
|
await this.authService.refreshToken(e, t);
|
|
@@ -5998,7 +6337,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
5998
6337
|
return this.upgrade.attachAuth(e);
|
|
5999
6338
|
}
|
|
6000
6339
|
createClient(e) {
|
|
6001
|
-
return
|
|
6340
|
+
return Aa(e, (e) => this.upgrade.attachAuth(e));
|
|
6002
6341
|
}
|
|
6003
6342
|
readAssuranceBar() {
|
|
6004
6343
|
let e = this.storageManager.getToken(j.access_token);
|
|
@@ -6050,7 +6389,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6050
6389
|
message: t instanceof Error || t instanceof B ? t.message : "Session check failed",
|
|
6051
6390
|
originalError: t
|
|
6052
6391
|
};
|
|
6053
|
-
|
|
6392
|
+
U(this.subscribeStore, n), e = void 0;
|
|
6054
6393
|
}
|
|
6055
6394
|
e && this.createSessionCallback && await this.createSessionCallback({
|
|
6056
6395
|
tokens: e,
|
|
@@ -6066,6 +6405,9 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6066
6405
|
handleTokensRedirect() {
|
|
6067
6406
|
return this.checkAndSetTokens();
|
|
6068
6407
|
}
|
|
6408
|
+
completeFederatedLanding() {
|
|
6409
|
+
return this.takeFederatedLanding();
|
|
6410
|
+
}
|
|
6069
6411
|
checkAndSetTokens() {
|
|
6070
6412
|
let e = this.platform.getCurrentUrl(), t = new URLSearchParams(e?.search ?? ""), n = !1;
|
|
6071
6413
|
if (!t.get("access_token") && e?.hash) {
|
|
@@ -6078,24 +6420,24 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6078
6420
|
}
|
|
6079
6421
|
let r = t.get("access_token"), i = t.get("refresh_token"), a = t.get("id_token"), o = t.get("scopes")?.split(",") ?? this.scopes, s;
|
|
6080
6422
|
if (r) {
|
|
6081
|
-
if (!
|
|
6082
|
-
|
|
6423
|
+
if (!wr(r)) {
|
|
6424
|
+
U(this.subscribeStore, {
|
|
6083
6425
|
operation: "tokens.from-url",
|
|
6084
6426
|
message: "Invalid access token format received",
|
|
6085
6427
|
code: "INVALID_TOKEN_FORMAT"
|
|
6086
6428
|
}), this.cleanupUrlParams(n, e);
|
|
6087
6429
|
return;
|
|
6088
6430
|
}
|
|
6089
|
-
if (i && !
|
|
6090
|
-
|
|
6431
|
+
if (i && !wr(i)) {
|
|
6432
|
+
U(this.subscribeStore, {
|
|
6091
6433
|
operation: "tokens.from-url",
|
|
6092
6434
|
message: "Invalid refresh token format received",
|
|
6093
6435
|
code: "INVALID_TOKEN_FORMAT"
|
|
6094
6436
|
}), this.cleanupUrlParams(n, e);
|
|
6095
6437
|
return;
|
|
6096
6438
|
}
|
|
6097
|
-
if (a && !
|
|
6098
|
-
|
|
6439
|
+
if (a && !wr(a)) {
|
|
6440
|
+
U(this.subscribeStore, {
|
|
6099
6441
|
operation: "tokens.from-url",
|
|
6100
6442
|
message: "Invalid ID token format received",
|
|
6101
6443
|
code: "INVALID_TOKEN_FORMAT"
|
|
@@ -6112,7 +6454,16 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6112
6454
|
parsedTokens: this.getParsedTokens()
|
|
6113
6455
|
}), this.submitSessionCheck(), this.cleanupUrlParams(n, e), this.error = void 0, s;
|
|
6114
6456
|
}
|
|
6115
|
-
this.error = this.checkErrorsFromURL();
|
|
6457
|
+
this.deferFederatedLanding || this.takeFederatedLanding(), this.error = this.checkErrorsFromURL();
|
|
6458
|
+
}
|
|
6459
|
+
takeFederatedLanding() {
|
|
6460
|
+
let e = this.platform.getCurrentUrl();
|
|
6461
|
+
if (!e) return !1;
|
|
6462
|
+
let t = new URLSearchParams(e.search), n = t.get("code");
|
|
6463
|
+
if (t.get("access_token") || new URLSearchParams(e.hash?.substring(1)).get("access_token") || !n || !t.get("user_state") || !this.authService.handleFederatedCode(n)) return !1;
|
|
6464
|
+
t.delete("code"), t.delete("user_state");
|
|
6465
|
+
let r = t.toString();
|
|
6466
|
+
return this.platform.replaceUrl(e.pathname + (r ? `?${r}` : "") + e.hash), !0;
|
|
6116
6467
|
}
|
|
6117
6468
|
adoptTwoFactorTokenFromUrl(e) {
|
|
6118
6469
|
if (!e?.hash) return !1;
|
|
@@ -6120,11 +6471,11 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6120
6471
|
if (!n) return !1;
|
|
6121
6472
|
t.delete("tfa_token");
|
|
6122
6473
|
let r = t.toString();
|
|
6123
|
-
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")),
|
|
6474
|
+
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), wr(n) ? (this.subscribeStore.notify(Z.TwoFactorRequired, {
|
|
6124
6475
|
email: "",
|
|
6125
6476
|
challengeId: "",
|
|
6126
6477
|
tfaToken: n
|
|
6127
|
-
}), !0) : (
|
|
6478
|
+
}), !0) : (U(this.subscribeStore, {
|
|
6128
6479
|
operation: "tokens.from-url",
|
|
6129
6480
|
message: "Invalid 2FA token format received",
|
|
6130
6481
|
code: "INVALID_TOKEN_FORMAT"
|
|
@@ -6133,7 +6484,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6133
6484
|
checkErrorsFromURL() {
|
|
6134
6485
|
let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
|
|
6135
6486
|
if (e) {
|
|
6136
|
-
let t =
|
|
6487
|
+
let t = Tr(e);
|
|
6137
6488
|
return Error(t);
|
|
6138
6489
|
}
|
|
6139
6490
|
}
|
|
@@ -6194,6 +6545,18 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6194
6545
|
async passwordlessSignInComplete(e) {
|
|
6195
6546
|
return await this.authService.passwordlessSignInComplete(e);
|
|
6196
6547
|
}
|
|
6548
|
+
waitForPasswordlessSignIn(e, t) {
|
|
6549
|
+
return this.authService.waitForPasswordlessSignIn(e, t);
|
|
6550
|
+
}
|
|
6551
|
+
getPendingPasswordlessSignIn(e) {
|
|
6552
|
+
return this.authService.getPendingPasswordlessSignIn(e);
|
|
6553
|
+
}
|
|
6554
|
+
getPasswordlessApproval(e) {
|
|
6555
|
+
return this.authService.getPasswordlessApproval(e);
|
|
6556
|
+
}
|
|
6557
|
+
decidePasswordlessApproval(e, t, n, r) {
|
|
6558
|
+
return this.authService.decidePasswordlessApproval(e, t, n, r);
|
|
6559
|
+
}
|
|
6197
6560
|
async verifyEmailCode(e) {
|
|
6198
6561
|
return await this.authService.verifyEmailCode(e);
|
|
6199
6562
|
}
|
|
@@ -6204,7 +6567,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6204
6567
|
originalError: e,
|
|
6205
6568
|
code: e instanceof B ? e.id : void 0
|
|
6206
6569
|
};
|
|
6207
|
-
throw
|
|
6570
|
+
throw U(this.subscribeStore, r), e;
|
|
6208
6571
|
}
|
|
6209
6572
|
async logOut() {
|
|
6210
6573
|
try {
|
|
@@ -6228,7 +6591,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6228
6591
|
message: e,
|
|
6229
6592
|
code: "RESET_ERROR"
|
|
6230
6593
|
};
|
|
6231
|
-
throw
|
|
6594
|
+
throw U(this.subscribeStore, t), this.error;
|
|
6232
6595
|
}
|
|
6233
6596
|
}
|
|
6234
6597
|
notifySignedOut(e) {
|
|
@@ -6408,6 +6771,34 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6408
6771
|
this.handleError(e, "2fa.setup.confirm", "Confirm 2FA setup");
|
|
6409
6772
|
}
|
|
6410
6773
|
}
|
|
6774
|
+
async getTwoFactorEnrollment() {
|
|
6775
|
+
try {
|
|
6776
|
+
return await this.twoFactorService.getEnrollment();
|
|
6777
|
+
} catch (e) {
|
|
6778
|
+
this.handleError(e, "2fa.enrollment.read", "Read 2FA enrollment");
|
|
6779
|
+
}
|
|
6780
|
+
}
|
|
6781
|
+
async sendTwoFactorSetupLink() {
|
|
6782
|
+
try {
|
|
6783
|
+
return await this.twoFactorService.sendSetupLink();
|
|
6784
|
+
} catch (e) {
|
|
6785
|
+
this.handleError(e, "2fa.enrollment.setup-link", "Send 2FA setup link");
|
|
6786
|
+
}
|
|
6787
|
+
}
|
|
6788
|
+
async beginTwoFactorEnrollment() {
|
|
6789
|
+
try {
|
|
6790
|
+
return await this.twoFactorService.beginEnrollment();
|
|
6791
|
+
} catch (e) {
|
|
6792
|
+
this.handleError(e, "2fa.setup.begin", "Begin 2FA enrollment");
|
|
6793
|
+
}
|
|
6794
|
+
}
|
|
6795
|
+
async confirmTwoFactorEnrollment(e) {
|
|
6796
|
+
try {
|
|
6797
|
+
return await this.twoFactorService.confirmEnrollment(e);
|
|
6798
|
+
} catch (e) {
|
|
6799
|
+
this.handleError(e, "2fa.setup.confirm", "Confirm 2FA enrollment");
|
|
6800
|
+
}
|
|
6801
|
+
}
|
|
6411
6802
|
async verifyTwoFactor(e, t) {
|
|
6412
6803
|
try {
|
|
6413
6804
|
let n = await this.twoFactorService.verify(e, t);
|
|
@@ -6477,7 +6868,7 @@ var Sr = "passflow_2fa_pkce", Cr = 3e5, wr = 10, Tr = "The sign-in answered with
|
|
|
6477
6868
|
this.twoFactorService.clearMagicLinkSession();
|
|
6478
6869
|
}
|
|
6479
6870
|
};
|
|
6480
|
-
|
|
6481
|
-
export { i as APP_ID_HEADER_KEY, Me as APP_SECRET_NAMES, a as AUTHORIZATION_HEADER_KEY,
|
|
6871
|
+
Ha = Ua, Ha.version = c;
|
|
6872
|
+
export { i as APP_ID_HEADER_KEY, Me as APP_SECRET_NAMES, a as AUTHORIZATION_HEADER_KEY, Xe as AppAPI, nt as AuthAPI, Ur as AuthService, rt as CLIAuthAPI, f as DEFAULT_GROUP_NAME, u as DEFAULT_SCOPES, ti as DEFAULT_UPGRADE_FACTORS, o as DEVICE_ID_HEADER_KEY, s as DEVICE_TYPE_HEADER_KEY, b as ERROR_MESSAGE_MAX_LENGTH, mt as FETCH_PRIORITY_OIDC, ht as FETCH_PRIORITY_UPGRADE, gt as FetchMiddlewareContractError, ce as INSUFFICIENT_USER_AUTHENTICATION, it as InvitationAPI, Wr as InvitationService, It as M2MClient, jt as M2MConfigError, H as M2MError, Mt as M2MErrorCodes, kt as M2MNetworkError, At as M2MTokenParseError, Nt 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, Ua as Passflow, Oe as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, B as PassflowError, Z as PassflowEvent, q as PassflowRefreshError, ie as PopupClosedError, je as Providers, ar as RECOVERABLE_COMMIT_ERROR_IDS, Dn as REFRESH_AUTH_FAILURE_IDS, K as RefreshErrorId, De as RequestMethod, c as SDK_VERSION, or as SESSION_INVALIDATING_COMMIT_ERROR_IDS, Pe as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, te as SessionState, at as SettingAPI, _ as TOKEN_EXPIRY_BUFFER_SECONDS, ot as TenantAPI, Kr as TenantService, Gr as TenantUserMembership, qr as TokenCacheService, M as TokenDeliveryMode, j as TokenType, dt as TwoFactorApiClient, Re as TwoFactorPolicy, Jr as TwoFactorService, le as UPGRADE_REQUIRED, y as USERNAME_MAX_LENGTH, v as USERNAME_MIN_LENGTH, ft as UpgradeAPI, ci as UpgradeCancelledError, zn as UpgradeCommitInterruptedError, _i as UpgradeController, Q as UpgradeErrorIds, Xr as UpgradeFactorError, yr as UpgradeInsufficientError, xr as UpgradeSessionChangedError, $ as UpgradeTransportError, br as UpgradeUnavailableError, li as UpgradeUnsatisfiableError, pt as UserAPI, Yr as UserService, ae as WebAdapter, gr as classifyUpgradeError, ni as factorRegistry, Ot as fetchRegistryState, Le as getOSFromDeviceType, vr as invalidatesSessionOnCommit, Ae as isEmailVerificationStep, Fe as isMaskedSecret, _r as isRecoverableCommitFailure, cr as isRetryableUpgradeKind, k as isTokenExpired, Ki as isUpgradeCancelled, qi as isUpgradeExhausted, Ji as isUpgradeInsufficient, Zi as isUpgradeSessionChanged, fr as isUpgradeTransportError, Qi as isUpgradeTransportFailure, Xi as isUpgradeUnavailable, Yi as isUpgradeUnsatisfiable, Er as isValidEmail, wr as isValidJWTFormat, Dr as isValidPhoneNumber, Or as isValidUsername, he as parseChallengeBody, me as parseChallengeHeader, A as parseToken, ye as parseUpgradeChallenge, ei as passkeyFactor, V as pathWithParams, $r as recoveryCodesFactor, Dt as registerFetchMiddleware, L as requiredAcrLevel, ke as resolveUpgradeDomain, Tr as sanitizeErrorMessage, si as selectFactors, Qr as totpFactor, P as webAdapter };
|
|
6482
6873
|
|
|
6483
6874
|
//# sourceMappingURL=index.mjs.map
|