@passflow/core 0.24.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 +35 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +116 -7
- package/dist/index.d.ts +116 -7
- package/dist/index.mjs +766 -660
- 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.passwordlessStatus = "/auth/passwordless/status", e.passwordlessApprovalInfo = "/auth/passwordless/approval/info", e.passwordlessApprovalDecide = "/auth/passwordless/approval/decide", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e;
|
|
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,7 +784,7 @@ 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) => {
|
|
785
788
|
if (e instanceof B) return e;
|
|
786
789
|
let i = e?.response?.data?.error;
|
|
787
790
|
return new B({
|
|
@@ -791,9 +794,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
791
794
|
location: t,
|
|
792
795
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
793
796
|
});
|
|
794
|
-
},
|
|
797
|
+
}, nt = class {
|
|
795
798
|
constructor(e, t, n) {
|
|
796
|
-
this.axiosClient = new
|
|
799
|
+
this.axiosClient = new Ye(e, t, n);
|
|
797
800
|
}
|
|
798
801
|
setAppId(e) {
|
|
799
802
|
this.axiosClient.setAppId(e);
|
|
@@ -812,7 +815,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
812
815
|
device: t,
|
|
813
816
|
os: n
|
|
814
817
|
};
|
|
815
|
-
return this.axiosClient.post(z.signin, r,
|
|
818
|
+
return this.axiosClient.post(z.signin, r, Ze);
|
|
816
819
|
}
|
|
817
820
|
signUp(e) {
|
|
818
821
|
let { create_tenant: t, anonymous: n } = e, r = {
|
|
@@ -820,16 +823,16 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
820
823
|
create_tenant: t ?? !1,
|
|
821
824
|
anonymous: n ?? !1
|
|
822
825
|
};
|
|
823
|
-
return this.axiosClient.post(z.signup, r,
|
|
826
|
+
return this.axiosClient.post(z.signup, r, Ze);
|
|
824
827
|
}
|
|
825
828
|
async pkceExchange(e, t) {
|
|
826
829
|
try {
|
|
827
830
|
return await this.axiosClient.post(z.pkceExchange, {
|
|
828
831
|
authz_code: e,
|
|
829
832
|
verifier: t
|
|
830
|
-
},
|
|
833
|
+
}, Ze);
|
|
831
834
|
} catch (e) {
|
|
832
|
-
throw
|
|
835
|
+
throw tt(e, z.pkceExchange, "error.pkce.exchange", $e);
|
|
833
836
|
}
|
|
834
837
|
}
|
|
835
838
|
async passwordlessSignIn(e, t, n) {
|
|
@@ -842,46 +845,46 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
842
845
|
try {
|
|
843
846
|
return await this.axiosClient.post(z.passwordless, i);
|
|
844
847
|
} catch (e) {
|
|
845
|
-
throw
|
|
848
|
+
throw tt(e, z.passwordless, "error.passwordless.start", et);
|
|
846
849
|
}
|
|
847
850
|
}
|
|
848
851
|
async passwordlessSignInComplete(e) {
|
|
849
852
|
try {
|
|
850
|
-
return await this.axiosClient.post(z.passwordlessComplete, e,
|
|
853
|
+
return await this.axiosClient.post(z.passwordlessComplete, e, Ze);
|
|
851
854
|
} catch (e) {
|
|
852
|
-
throw
|
|
855
|
+
throw tt(e, z.passwordlessComplete, "error.passwordless.complete", et);
|
|
853
856
|
}
|
|
854
857
|
}
|
|
855
858
|
async passwordlessStatus(e, t) {
|
|
856
859
|
try {
|
|
857
860
|
return await this.axiosClient.post(z.passwordlessStatus, e, {
|
|
858
|
-
...
|
|
859
|
-
timeout:
|
|
861
|
+
...Ze,
|
|
862
|
+
timeout: Qe,
|
|
860
863
|
signal: t?.signal
|
|
861
864
|
});
|
|
862
865
|
} catch (e) {
|
|
863
|
-
throw
|
|
866
|
+
throw tt(e, z.passwordlessStatus, "error.passwordless.status", $e);
|
|
864
867
|
}
|
|
865
868
|
}
|
|
866
869
|
async passwordlessApprovalInfo(e) {
|
|
867
870
|
try {
|
|
868
871
|
return await this.axiosClient.post(z.passwordlessApprovalInfo, e);
|
|
869
872
|
} catch (e) {
|
|
870
|
-
throw
|
|
873
|
+
throw tt(e, z.passwordlessApprovalInfo, "error.passwordless.approval", et);
|
|
871
874
|
}
|
|
872
875
|
}
|
|
873
876
|
async passwordlessApprovalDecide(e) {
|
|
874
877
|
try {
|
|
875
878
|
return await this.axiosClient.post(z.passwordlessApprovalDecide, e);
|
|
876
879
|
} catch (e) {
|
|
877
|
-
throw
|
|
880
|
+
throw tt(e, z.passwordlessApprovalDecide, "error.passwordless.approval", et);
|
|
878
881
|
}
|
|
879
882
|
}
|
|
880
883
|
validateEmailCode(e) {
|
|
881
884
|
return this.axiosClient.post(z.passkeyValidate, {
|
|
882
885
|
challenge_id: e.challenge_id,
|
|
883
886
|
otp: e.otp
|
|
884
|
-
},
|
|
887
|
+
}, Ze);
|
|
885
888
|
}
|
|
886
889
|
logOut(e, t, n = !1) {
|
|
887
890
|
let r = n ? void 0 : {
|
|
@@ -922,7 +925,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
922
925
|
device: t,
|
|
923
926
|
passkey_data: e
|
|
924
927
|
}, a = r ? Oe.passkeyRegisterComplete : z.passkeyRegisterComplete;
|
|
925
|
-
return this.axiosClient.post(a, i,
|
|
928
|
+
return this.axiosClient.post(a, i, Ze);
|
|
926
929
|
}
|
|
927
930
|
passkeyAuthenticateStart(e, t, n, r = !1) {
|
|
928
931
|
let i = {
|
|
@@ -939,7 +942,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
939
942
|
device: t,
|
|
940
943
|
passkey_data: e
|
|
941
944
|
}, a = r ? Oe.passkeyAuthenticateComplete : z.passkeyAuthenticateComplete;
|
|
942
|
-
return this.axiosClient.post(a, i,
|
|
945
|
+
return this.axiosClient.post(a, i, Ze);
|
|
943
946
|
}
|
|
944
947
|
passkeyValidate(e, t, n, r = !1, a) {
|
|
945
948
|
let o = {
|
|
@@ -951,9 +954,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
951
954
|
let c = a ? { [i]: a } : {};
|
|
952
955
|
return this.axiosClient.post(s, o, { headers: c });
|
|
953
956
|
}
|
|
954
|
-
},
|
|
957
|
+
}, rt = class {
|
|
955
958
|
constructor(e, t, n) {
|
|
956
|
-
this.axiosClient = new
|
|
959
|
+
this.axiosClient = new Ye(e, t, n);
|
|
957
960
|
}
|
|
958
961
|
setAppId(e) {
|
|
959
962
|
this.axiosClient.setAppId(e);
|
|
@@ -965,9 +968,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
965
968
|
completeCLIAuth(e) {
|
|
966
969
|
return this.axiosClient.post(z.cliAuthComplete, e);
|
|
967
970
|
}
|
|
968
|
-
},
|
|
971
|
+
}, it = class {
|
|
969
972
|
constructor(e, t, n) {
|
|
970
|
-
this.axiosClient = new
|
|
973
|
+
this.axiosClient = new Ye(e, t, n);
|
|
971
974
|
}
|
|
972
975
|
setAppId(e) {
|
|
973
976
|
this.axiosClient.setAppId(e);
|
|
@@ -996,9 +999,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
996
999
|
let t = V(z.invitationGetLink, { invitationID: e });
|
|
997
1000
|
return this.axiosClient.get(t);
|
|
998
1001
|
}
|
|
999
|
-
},
|
|
1002
|
+
}, at = class {
|
|
1000
1003
|
constructor(e, t, n) {
|
|
1001
|
-
this.axiosClient = new
|
|
1004
|
+
this.axiosClient = new Ye(e, t, n);
|
|
1002
1005
|
}
|
|
1003
1006
|
setAppId(e) {
|
|
1004
1007
|
this.axiosClient.setAppId(e);
|
|
@@ -1012,9 +1015,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1012
1015
|
getPasskeySettings() {
|
|
1013
1016
|
return this.axiosClient.get(z.settingsPasskey);
|
|
1014
1017
|
}
|
|
1015
|
-
},
|
|
1018
|
+
}, ot = class {
|
|
1016
1019
|
constructor(e, t, n) {
|
|
1017
|
-
this.axiosClient = new
|
|
1020
|
+
this.axiosClient = new Ye(e, t, n);
|
|
1018
1021
|
}
|
|
1019
1022
|
setAppId(e) {
|
|
1020
1023
|
this.axiosClient.setAppId(e);
|
|
@@ -1128,38 +1131,58 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1128
1131
|
let r = `${z.tenantPath}/${e}/group/${t}/invite/email/${n}`;
|
|
1129
1132
|
return this.axiosClient.delete(r);
|
|
1130
1133
|
}
|
|
1131
|
-
},
|
|
1134
|
+
}, st = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, ct = (e) => ({
|
|
1132
1135
|
withCredentials: !0,
|
|
1133
|
-
...
|
|
1134
|
-
}),
|
|
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 {
|
|
1135
1146
|
constructor(e, t, n) {
|
|
1136
|
-
this.axiosClient = new
|
|
1147
|
+
this.axiosClient = new Ye(e, t, n);
|
|
1137
1148
|
}
|
|
1138
1149
|
setAppId(e) {
|
|
1139
1150
|
this.axiosClient.setAppId(e);
|
|
1140
1151
|
}
|
|
1141
|
-
getStatus() {
|
|
1142
|
-
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));
|
|
1160
|
+
}
|
|
1161
|
+
async getEnrollment(e) {
|
|
1162
|
+
return (await this.axiosClient.get(z.twoFactorEnrollment, Je(e))).enrollment;
|
|
1143
1163
|
}
|
|
1144
|
-
|
|
1145
|
-
return this.axiosClient.post(z.
|
|
1164
|
+
sendSetupLink(e) {
|
|
1165
|
+
return this.axiosClient.post(z.twoFactorEnrollmentEmailLink, void 0, Je(e));
|
|
1146
1166
|
}
|
|
1147
|
-
|
|
1148
|
-
return this.axiosClient.post(z.
|
|
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));
|
|
1149
1172
|
}
|
|
1150
1173
|
verify(e) {
|
|
1151
1174
|
let { tfa_token: t, code: n, trust_device: r } = e;
|
|
1152
1175
|
return this.axiosClient.post(z.twoFactorVerify, {
|
|
1153
1176
|
code: n,
|
|
1154
1177
|
...r ? { trust_device: !0 } : {}
|
|
1155
|
-
},
|
|
1178
|
+
}, ct(t));
|
|
1156
1179
|
}
|
|
1157
1180
|
useRecoveryCode(e) {
|
|
1158
1181
|
let { tfa_token: t, recovery_code: n, trust_device: r } = e;
|
|
1159
1182
|
return this.axiosClient.post(z.twoFactorRecovery, {
|
|
1160
1183
|
recovery_code: n,
|
|
1161
1184
|
...r ? { trust_device: !0 } : {}
|
|
1162
|
-
},
|
|
1185
|
+
}, ct(t));
|
|
1163
1186
|
}
|
|
1164
1187
|
disable(e) {
|
|
1165
1188
|
return this.axiosClient.delete(z.twoFactor, { data: e });
|
|
@@ -1171,7 +1194,13 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1171
1194
|
let t = `${z.twoFactorSetupMagicLink}/${e}`;
|
|
1172
1195
|
return this.axiosClient.get(t, { transformRequest: [(e, t) => (t && delete t.Authorization, e)] }).then((e) => {
|
|
1173
1196
|
let t = e;
|
|
1174
|
-
return {
|
|
1197
|
+
return t.valid === !1 ? {
|
|
1198
|
+
success: !1,
|
|
1199
|
+
error: {
|
|
1200
|
+
code: "INVALID_TOKEN",
|
|
1201
|
+
message: this.getDefaultErrorMessage(400)
|
|
1202
|
+
}
|
|
1203
|
+
} : {
|
|
1175
1204
|
success: !0,
|
|
1176
1205
|
sessionToken: t.session_token,
|
|
1177
1206
|
userId: t.user_id,
|
|
@@ -1179,6 +1208,13 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1179
1208
|
appId: t.app_id
|
|
1180
1209
|
};
|
|
1181
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
|
+
};
|
|
1182
1218
|
if (e.response) {
|
|
1183
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;
|
|
1184
1220
|
return {
|
|
@@ -1240,17 +1276,17 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1240
1276
|
return this.axiosClient.delete(t);
|
|
1241
1277
|
}
|
|
1242
1278
|
requestChallenge(e, t) {
|
|
1243
|
-
return this.axiosClient.post(z.TwoFactorChallenge, e,
|
|
1279
|
+
return this.axiosClient.post(z.TwoFactorChallenge, e, st(t));
|
|
1244
1280
|
}
|
|
1245
1281
|
verifyV2(e, t) {
|
|
1246
1282
|
let { trust_device: n, ...r } = e;
|
|
1247
1283
|
return this.axiosClient.post(z.TwoFactorVerifyV2, {
|
|
1248
1284
|
...r,
|
|
1249
1285
|
...n ? { trust_device: !0 } : {}
|
|
1250
|
-
},
|
|
1286
|
+
}, ct(t));
|
|
1251
1287
|
}
|
|
1252
1288
|
switchToAlternative(e, t) {
|
|
1253
|
-
return this.axiosClient.post(z.TwoFactorAlternative, e,
|
|
1289
|
+
return this.axiosClient.post(z.TwoFactorAlternative, e, st(t));
|
|
1254
1290
|
}
|
|
1255
1291
|
async getTrustedDevices() {
|
|
1256
1292
|
return (await this.axiosClient.get(z.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
|
|
@@ -1259,9 +1295,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1259
1295
|
let t = V(z.TwoFactorTrustedDeviceRevoke, { id: e });
|
|
1260
1296
|
return this.axiosClient.delete(t);
|
|
1261
1297
|
}
|
|
1262
|
-
},
|
|
1298
|
+
}, ft = class {
|
|
1263
1299
|
constructor(e, t, n) {
|
|
1264
|
-
this.axiosClient = new
|
|
1300
|
+
this.axiosClient = new Ye(e, t, n);
|
|
1265
1301
|
}
|
|
1266
1302
|
setAppId(e) {
|
|
1267
1303
|
this.axiosClient.setAppId(e);
|
|
@@ -1269,9 +1305,9 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1269
1305
|
startUpgrade(e) {
|
|
1270
1306
|
return this.axiosClient.post(z.upgradeStart, e, Ce({}));
|
|
1271
1307
|
}
|
|
1272
|
-
},
|
|
1308
|
+
}, pt = class {
|
|
1273
1309
|
constructor(e, t, n) {
|
|
1274
|
-
this.axiosClient = new
|
|
1310
|
+
this.axiosClient = new Ye(e, t, n);
|
|
1275
1311
|
}
|
|
1276
1312
|
setAppId(e) {
|
|
1277
1313
|
this.axiosClient.setAppId(e);
|
|
@@ -1302,50 +1338,50 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1302
1338
|
passkey_data: e
|
|
1303
1339
|
});
|
|
1304
1340
|
}
|
|
1305
|
-
},
|
|
1341
|
+
}, mt = 10, ht = 20, gt = class extends Error {
|
|
1306
1342
|
constructor(e) {
|
|
1307
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;
|
|
1308
1344
|
}
|
|
1309
|
-
},
|
|
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) => {
|
|
1310
1346
|
if (t >= e.length) {
|
|
1311
|
-
let e =
|
|
1347
|
+
let e = bt;
|
|
1312
1348
|
if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
|
|
1313
1349
|
return e(n, r);
|
|
1314
1350
|
}
|
|
1315
1351
|
let i = e[t];
|
|
1316
|
-
if (!i) return
|
|
1317
|
-
let a = !1, o = await i.middleware((n, r) => (a = !0,
|
|
1318
|
-
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);
|
|
1319
1355
|
return o;
|
|
1320
|
-
},
|
|
1321
|
-
let e =
|
|
1356
|
+
}, Tt = () => {
|
|
1357
|
+
let e = Ct();
|
|
1322
1358
|
if (!e || typeof e.fetch != "function") return !1;
|
|
1323
|
-
let t = e.fetch.bind(e), n = (e, t) =>
|
|
1324
|
-
return
|
|
1325
|
-
},
|
|
1326
|
-
let e =
|
|
1327
|
-
e &&
|
|
1328
|
-
},
|
|
1329
|
-
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 () => {};
|
|
1330
1366
|
let n = {
|
|
1331
1367
|
middleware: e,
|
|
1332
1368
|
name: t.name,
|
|
1333
1369
|
priority: t.priority,
|
|
1334
|
-
seq:
|
|
1370
|
+
seq: vt++
|
|
1335
1371
|
};
|
|
1336
|
-
|
|
1372
|
+
_t.push(n);
|
|
1337
1373
|
let r = !1;
|
|
1338
1374
|
return () => {
|
|
1339
|
-
r || (r = !0,
|
|
1375
|
+
r || (r = !0, _t = _t.filter((e) => e !== n), _t.length === 0 && Et());
|
|
1340
1376
|
};
|
|
1341
|
-
},
|
|
1342
|
-
let e =
|
|
1377
|
+
}, Ot = () => {
|
|
1378
|
+
let e = Ct();
|
|
1343
1379
|
return {
|
|
1344
|
-
installed:
|
|
1345
|
-
names: [...
|
|
1346
|
-
foreignPatch:
|
|
1380
|
+
installed: yt,
|
|
1381
|
+
names: [..._t].sort(St).map((e) => e.name),
|
|
1382
|
+
foreignPatch: yt && !!e && !!xt && e.fetch !== xt
|
|
1347
1383
|
};
|
|
1348
|
-
},
|
|
1384
|
+
}, H = class e extends Error {
|
|
1349
1385
|
constructor(t) {
|
|
1350
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);
|
|
1351
1387
|
}
|
|
@@ -1414,7 +1450,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1414
1450
|
let e = `M2MError [${this.code}]: ${this.message}`;
|
|
1415
1451
|
return this.status && (e += ` (HTTP ${this.status})`), e;
|
|
1416
1452
|
}
|
|
1417
|
-
},
|
|
1453
|
+
}, kt = class extends H {
|
|
1418
1454
|
constructor(e, t) {
|
|
1419
1455
|
super({
|
|
1420
1456
|
code: "temporarily_unavailable",
|
|
@@ -1423,7 +1459,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1423
1459
|
cause: t
|
|
1424
1460
|
}), this.name = "M2MNetworkError";
|
|
1425
1461
|
}
|
|
1426
|
-
},
|
|
1462
|
+
}, At = class extends H {
|
|
1427
1463
|
constructor(e, t) {
|
|
1428
1464
|
super({
|
|
1429
1465
|
code: "invalid_request",
|
|
@@ -1432,7 +1468,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1432
1468
|
cause: t
|
|
1433
1469
|
}), this.name = "M2MTokenParseError";
|
|
1434
1470
|
}
|
|
1435
|
-
},
|
|
1471
|
+
}, jt = class extends H {
|
|
1436
1472
|
constructor(e) {
|
|
1437
1473
|
super({
|
|
1438
1474
|
code: "invalid_request",
|
|
@@ -1440,7 +1476,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1440
1476
|
status: 400
|
|
1441
1477
|
}), this.name = "M2MConfigError";
|
|
1442
1478
|
}
|
|
1443
|
-
},
|
|
1479
|
+
}, Mt = {
|
|
1444
1480
|
InvalidRequest: "invalid_request",
|
|
1445
1481
|
InvalidClient: "invalid_client",
|
|
1446
1482
|
InvalidGrant: "invalid_grant",
|
|
@@ -1450,14 +1486,14 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1450
1486
|
RateLimitExceeded: "rate_limit_exceeded",
|
|
1451
1487
|
ServerError: "server_error",
|
|
1452
1488
|
TemporarilyUnavailable: "temporarily_unavailable"
|
|
1453
|
-
},
|
|
1489
|
+
}, Nt = {
|
|
1454
1490
|
TOKEN_ENDPOINT: "/oauth2/token",
|
|
1455
1491
|
TIMEOUT: 1e4,
|
|
1456
1492
|
RETRIES: 3,
|
|
1457
1493
|
RETRY_DELAY: 1e3,
|
|
1458
1494
|
REFRESH_THRESHOLD: 30,
|
|
1459
1495
|
CONTENT_TYPE: "application/x-www-form-urlencoded"
|
|
1460
|
-
},
|
|
1496
|
+
}, Pt = class {
|
|
1461
1497
|
constructor() {
|
|
1462
1498
|
this.cache = /* @__PURE__ */ new Map();
|
|
1463
1499
|
}
|
|
@@ -1474,18 +1510,18 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1474
1510
|
delete(e) {
|
|
1475
1511
|
return this.cache.delete(e), Promise.resolve();
|
|
1476
1512
|
}
|
|
1477
|
-
},
|
|
1513
|
+
}, Ft = {
|
|
1478
1514
|
shouldRetry(e, t) {
|
|
1479
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;
|
|
1480
1516
|
},
|
|
1481
1517
|
getDelay(e) {
|
|
1482
1518
|
return 2 ** (e - 1) * 1e3;
|
|
1483
1519
|
}
|
|
1484
|
-
},
|
|
1520
|
+
}, It = class {
|
|
1485
1521
|
constructor(e) {
|
|
1486
|
-
if (!e.url) throw new
|
|
1487
|
-
if (!e.clientId) throw new
|
|
1488
|
-
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");
|
|
1489
1525
|
let t = e.url.replace(/\/$/, "");
|
|
1490
1526
|
this.config = {
|
|
1491
1527
|
url: t,
|
|
@@ -1494,16 +1530,16 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1494
1530
|
scopes: e.scopes,
|
|
1495
1531
|
audience: e.audience,
|
|
1496
1532
|
autoRefresh: e.autoRefresh ?? !1,
|
|
1497
|
-
refreshThreshold: e.refreshThreshold ??
|
|
1498
|
-
timeout: e.timeout ??
|
|
1499
|
-
retries: e.retries ??
|
|
1500
|
-
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,
|
|
1501
1537
|
retryStrategy: e.retryStrategy,
|
|
1502
1538
|
cache: e.cache,
|
|
1503
1539
|
onTokenRequest: e.onTokenRequest,
|
|
1504
1540
|
onTokenResponse: e.onTokenResponse,
|
|
1505
1541
|
onError: e.onError
|
|
1506
|
-
}, this.cache = e.cache ?? new
|
|
1542
|
+
}, this.cache = e.cache ?? new Pt(), this.retryStrategy = e.retryStrategy ?? Ft, this.tokenEndpoint = `${t}${Nt.TOKEN_ENDPOINT}`;
|
|
1507
1543
|
}
|
|
1508
1544
|
getCacheKey(e, t) {
|
|
1509
1545
|
let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
|
|
@@ -1548,7 +1584,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1548
1584
|
let e = await fetch(this.tokenEndpoint, {
|
|
1549
1585
|
method: "POST",
|
|
1550
1586
|
headers: {
|
|
1551
|
-
"Content-Type":
|
|
1587
|
+
"Content-Type": Nt.CONTENT_TYPE,
|
|
1552
1588
|
Accept: "application/json"
|
|
1553
1589
|
},
|
|
1554
1590
|
body: t.toString(),
|
|
@@ -1561,7 +1597,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1561
1597
|
});
|
|
1562
1598
|
let a = await e.json();
|
|
1563
1599
|
if (!e.ok) {
|
|
1564
|
-
let t =
|
|
1600
|
+
let t = H.fromOAuthError({
|
|
1565
1601
|
error: a.error || "server_error",
|
|
1566
1602
|
error_description: a.error_description || a.message,
|
|
1567
1603
|
error_uri: a.error_uri
|
|
@@ -1573,7 +1609,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1573
1609
|
}
|
|
1574
1610
|
return a;
|
|
1575
1611
|
} catch (e) {
|
|
1576
|
-
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)));
|
|
1577
1613
|
}
|
|
1578
1614
|
}
|
|
1579
1615
|
async executeWithRetry(e) {
|
|
@@ -1581,7 +1617,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1581
1617
|
for (let n = 1; n <= this.config.retries; n++) try {
|
|
1582
1618
|
return await e();
|
|
1583
1619
|
} catch (e) {
|
|
1584
|
-
if (!(e instanceof
|
|
1620
|
+
if (!(e instanceof H)) throw e;
|
|
1585
1621
|
if (t = e, n < this.config.retries && this.retryStrategy.shouldRetry({
|
|
1586
1622
|
code: e.code,
|
|
1587
1623
|
status: e.status
|
|
@@ -1592,7 +1628,7 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1592
1628
|
}
|
|
1593
1629
|
throw e;
|
|
1594
1630
|
}
|
|
1595
|
-
throw t ?? new
|
|
1631
|
+
throw t ?? new H({
|
|
1596
1632
|
code: "server_error",
|
|
1597
1633
|
message: "Request failed after retries"
|
|
1598
1634
|
});
|
|
@@ -1616,13 +1652,13 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1616
1652
|
parseToken(e) {
|
|
1617
1653
|
try {
|
|
1618
1654
|
let t = e.split(".");
|
|
1619
|
-
if (t.length !== 3) throw new
|
|
1655
|
+
if (t.length !== 3) throw new At("Invalid JWT format: expected 3 parts");
|
|
1620
1656
|
let n = t[1];
|
|
1621
|
-
if (!n) throw new
|
|
1657
|
+
if (!n) throw new At("Invalid JWT format: missing payload");
|
|
1622
1658
|
let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
|
|
1623
1659
|
return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
|
|
1624
1660
|
} catch (e) {
|
|
1625
|
-
throw e instanceof
|
|
1661
|
+
throw e instanceof At ? e : new At(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
1626
1662
|
}
|
|
1627
1663
|
}
|
|
1628
1664
|
clearCache() {
|
|
@@ -1637,19 +1673,19 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1637
1673
|
try {
|
|
1638
1674
|
let e = await fetch(t, {
|
|
1639
1675
|
method: "POST",
|
|
1640
|
-
headers: { "Content-Type":
|
|
1676
|
+
headers: { "Content-Type": Nt.CONTENT_TYPE },
|
|
1641
1677
|
body: n.toString()
|
|
1642
1678
|
});
|
|
1643
1679
|
if (!e.ok && e.status !== 200) {
|
|
1644
1680
|
let t = await e.json().catch(() => ({}));
|
|
1645
|
-
throw
|
|
1681
|
+
throw H.fromOAuthError({
|
|
1646
1682
|
error: t.error || "server_error",
|
|
1647
1683
|
error_description: t.error_description || "Token revocation failed"
|
|
1648
1684
|
}, e.status);
|
|
1649
1685
|
}
|
|
1650
1686
|
this.clearCache();
|
|
1651
1687
|
} catch (e) {
|
|
1652
|
-
throw e instanceof
|
|
1688
|
+
throw e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1653
1689
|
}
|
|
1654
1690
|
}
|
|
1655
1691
|
get url() {
|
|
@@ -1664,101 +1700,101 @@ var Re = /* @__PURE__ */ function(e) {
|
|
|
1664
1700
|
get audience() {
|
|
1665
1701
|
return this.config.audience;
|
|
1666
1702
|
}
|
|
1667
|
-
},
|
|
1703
|
+
}, Lt = "error", Rt = /* @__PURE__ */ new WeakMap(), zt = (e, t) => {
|
|
1668
1704
|
if (typeof t != "object" && typeof t != "function" || t === null) return !0;
|
|
1669
|
-
let n =
|
|
1670
|
-
return n || (n = /* @__PURE__ */ new WeakSet(),
|
|
1671
|
-
},
|
|
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([
|
|
1672
1708
|
1e3,
|
|
1673
1709
|
3e3,
|
|
1674
1710
|
1e4,
|
|
1675
1711
|
3e4,
|
|
1676
1712
|
6e4
|
|
1677
|
-
]),
|
|
1713
|
+
]), Wt = .2, Gt = 6e5, Kt = 5e3, W = 2e4, qt = 2e4, Jt = 1e3, Yt = 2e3, Xt = 1e3, Zt = 1e4, Qt = 5e3;
|
|
1678
1714
|
// lib/refresh/protocol.ts
|
|
1679
|
-
function
|
|
1715
|
+
function $t(e) {
|
|
1680
1716
|
let t = e ? `:${e}` : "";
|
|
1681
1717
|
return {
|
|
1682
|
-
lock: `${
|
|
1683
|
-
takeoverLock: `${
|
|
1684
|
-
channel: `${
|
|
1718
|
+
lock: `${Bt}${t}`,
|
|
1719
|
+
takeoverLock: `${Vt}${t}`,
|
|
1720
|
+
channel: `${Ht}${t}`
|
|
1685
1721
|
};
|
|
1686
1722
|
}
|
|
1687
|
-
function
|
|
1723
|
+
function G(e) {
|
|
1688
1724
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
1689
1725
|
}
|
|
1690
|
-
function
|
|
1726
|
+
function en(e) {
|
|
1691
1727
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
1692
1728
|
}
|
|
1693
|
-
function
|
|
1729
|
+
function tn(e) {
|
|
1694
1730
|
return typeof e == "object" && !!e;
|
|
1695
1731
|
}
|
|
1696
|
-
function
|
|
1732
|
+
function nn(e, t) {
|
|
1697
1733
|
for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
|
|
1698
1734
|
return e;
|
|
1699
1735
|
}
|
|
1700
|
-
function
|
|
1701
|
-
if (!
|
|
1736
|
+
function rn(e) {
|
|
1737
|
+
if (!tn(e)) return null;
|
|
1702
1738
|
let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
|
|
1703
|
-
return
|
|
1704
|
-
access_token:
|
|
1705
|
-
refresh_token:
|
|
1706
|
-
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),
|
|
1707
1743
|
scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
|
|
1708
1744
|
});
|
|
1709
1745
|
}
|
|
1710
|
-
function
|
|
1711
|
-
if (!
|
|
1746
|
+
function an(e) {
|
|
1747
|
+
if (!tn(e)) return null;
|
|
1712
1748
|
let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
|
|
1713
|
-
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({
|
|
1714
1750
|
kind: t,
|
|
1715
1751
|
attempt: n,
|
|
1716
1752
|
nextAt: r,
|
|
1717
1753
|
strikes: i
|
|
1718
1754
|
}, {
|
|
1719
|
-
from:
|
|
1720
|
-
failingSince:
|
|
1755
|
+
from: G(e.from),
|
|
1756
|
+
failingSince: en(e.failingSince)
|
|
1721
1757
|
});
|
|
1722
1758
|
}
|
|
1723
|
-
function
|
|
1724
|
-
return
|
|
1725
|
-
fp:
|
|
1726
|
-
sub:
|
|
1727
|
-
sid:
|
|
1728
|
-
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)
|
|
1729
1765
|
});
|
|
1730
1766
|
}
|
|
1731
|
-
function
|
|
1732
|
-
if (!
|
|
1767
|
+
function sn(e) {
|
|
1768
|
+
if (!tn(e)) return null;
|
|
1733
1769
|
let t = e;
|
|
1734
1770
|
if (t.v !== void 0 && t.v !== 1) return null;
|
|
1735
|
-
let n =
|
|
1771
|
+
let n = G(t.tabId);
|
|
1736
1772
|
if (!n) return null;
|
|
1737
1773
|
switch (t.type) {
|
|
1738
1774
|
case "tokens-refreshed": {
|
|
1739
|
-
let e =
|
|
1740
|
-
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({
|
|
1741
1777
|
type: t.type,
|
|
1742
1778
|
tabId: n,
|
|
1743
1779
|
tokens: e,
|
|
1744
1780
|
from: r,
|
|
1745
1781
|
to: i
|
|
1746
1782
|
}, {
|
|
1747
|
-
fromIat:
|
|
1783
|
+
fromIat: en(t.fromIat),
|
|
1748
1784
|
fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
|
|
1749
|
-
sentAt:
|
|
1785
|
+
sentAt: en(t.sentAt)
|
|
1750
1786
|
});
|
|
1751
1787
|
}
|
|
1752
1788
|
case "session-refreshed": {
|
|
1753
|
-
let e =
|
|
1754
|
-
return e === void 0 ? null :
|
|
1789
|
+
let e = en(t.at);
|
|
1790
|
+
return e === void 0 ? null : nn({
|
|
1755
1791
|
type: t.type,
|
|
1756
1792
|
tabId: n,
|
|
1757
1793
|
at: e
|
|
1758
|
-
}, { sub:
|
|
1794
|
+
}, { sub: G(t.sub) });
|
|
1759
1795
|
}
|
|
1760
1796
|
case "still-refreshing": {
|
|
1761
|
-
let e = t.retry === void 0 ? null :
|
|
1797
|
+
let e = t.retry === void 0 ? null : an(t.retry);
|
|
1762
1798
|
return e ? {
|
|
1763
1799
|
type: t.type,
|
|
1764
1800
|
tabId: n,
|
|
@@ -1769,7 +1805,7 @@ function en(e) {
|
|
|
1769
1805
|
};
|
|
1770
1806
|
}
|
|
1771
1807
|
case "retry-scheduled": {
|
|
1772
|
-
let e =
|
|
1808
|
+
let e = an(t);
|
|
1773
1809
|
return e ? {
|
|
1774
1810
|
type: t.type,
|
|
1775
1811
|
tabId: n,
|
|
@@ -1790,10 +1826,10 @@ function en(e) {
|
|
|
1790
1826
|
case "signed-out": return {
|
|
1791
1827
|
type: t.type,
|
|
1792
1828
|
tabId: n,
|
|
1793
|
-
|
|
1829
|
+
...on(t)
|
|
1794
1830
|
};
|
|
1795
1831
|
case "rate-limited": {
|
|
1796
|
-
let e =
|
|
1832
|
+
let e = en(t.until);
|
|
1797
1833
|
return e === void 0 ? null : {
|
|
1798
1834
|
type: t.type,
|
|
1799
1835
|
tabId: n,
|
|
@@ -1801,7 +1837,7 @@ function en(e) {
|
|
|
1801
1837
|
};
|
|
1802
1838
|
}
|
|
1803
1839
|
case "refresh-failed": {
|
|
1804
|
-
let e =
|
|
1840
|
+
let e = G(t.from);
|
|
1805
1841
|
return e ? {
|
|
1806
1842
|
type: t.type,
|
|
1807
1843
|
tabId: n,
|
|
@@ -1812,22 +1848,22 @@ function en(e) {
|
|
|
1812
1848
|
default: return null;
|
|
1813
1849
|
}
|
|
1814
1850
|
}
|
|
1815
|
-
function
|
|
1851
|
+
function cn(e, t) {
|
|
1816
1852
|
let n = {
|
|
1817
1853
|
v: 1,
|
|
1818
1854
|
tabId: e
|
|
1819
1855
|
};
|
|
1820
1856
|
if (t.type === "retry-scheduled") {
|
|
1821
1857
|
let { retry: e, ...r } = t;
|
|
1822
|
-
return
|
|
1858
|
+
return nn(n, {
|
|
1823
1859
|
...r,
|
|
1824
1860
|
...e
|
|
1825
1861
|
});
|
|
1826
1862
|
}
|
|
1827
|
-
return
|
|
1863
|
+
return nn(n, { ...t });
|
|
1828
1864
|
}
|
|
1829
1865
|
// lib/refresh/resolve.ts
|
|
1830
|
-
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 = {
|
|
1831
1867
|
now: () => Date.now(),
|
|
1832
1868
|
random: () => Math.random(),
|
|
1833
1869
|
setTimeout: (e, t) => {
|
|
@@ -1835,28 +1871,28 @@ var nn = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
|
|
|
1835
1871
|
return n.unref?.(), () => clearTimeout(n);
|
|
1836
1872
|
}
|
|
1837
1873
|
};
|
|
1838
|
-
function
|
|
1874
|
+
function dn() {
|
|
1839
1875
|
let e = globalThis.crypto;
|
|
1840
1876
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
1841
1877
|
}
|
|
1842
|
-
function
|
|
1878
|
+
function fn(e) {
|
|
1843
1879
|
return e ? {
|
|
1844
1880
|
now: () => e.now(),
|
|
1845
1881
|
setTimeout: (t, n) => e.setTimeout(t, n),
|
|
1846
|
-
random: e.random ? () => e.random?.() ?? Math.random() :
|
|
1847
|
-
} :
|
|
1882
|
+
random: e.random ? () => e.random?.() ?? Math.random() : un.random
|
|
1883
|
+
} : un;
|
|
1848
1884
|
}
|
|
1849
|
-
function
|
|
1885
|
+
function pn(e) {
|
|
1850
1886
|
return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
|
|
1851
1887
|
}
|
|
1852
|
-
function
|
|
1888
|
+
function mn(e) {
|
|
1853
1889
|
try {
|
|
1854
1890
|
return e.storageSharedAcrossTabs === !0;
|
|
1855
1891
|
} catch {
|
|
1856
1892
|
return !1;
|
|
1857
1893
|
}
|
|
1858
1894
|
}
|
|
1859
|
-
function
|
|
1895
|
+
function hn() {
|
|
1860
1896
|
try {
|
|
1861
1897
|
let e = globalThis.navigator?.locks;
|
|
1862
1898
|
return e && typeof e.request == "function" ? e : void 0;
|
|
@@ -1864,7 +1900,7 @@ function ln() {
|
|
|
1864
1900
|
return;
|
|
1865
1901
|
}
|
|
1866
1902
|
}
|
|
1867
|
-
function
|
|
1903
|
+
function gn(e) {
|
|
1868
1904
|
return (t) => {
|
|
1869
1905
|
let n = (n) => {
|
|
1870
1906
|
let r = n.key;
|
|
@@ -1873,20 +1909,20 @@ function un(e) {
|
|
|
1873
1909
|
return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
|
|
1874
1910
|
};
|
|
1875
1911
|
}
|
|
1876
|
-
function
|
|
1912
|
+
function _n(e) {
|
|
1877
1913
|
return {
|
|
1878
1914
|
transports: null,
|
|
1879
|
-
names:
|
|
1880
|
-
clock:
|
|
1915
|
+
names: $t(e),
|
|
1916
|
+
clock: un,
|
|
1881
1917
|
warnOnFirstCycle: !1
|
|
1882
1918
|
};
|
|
1883
1919
|
}
|
|
1884
|
-
function
|
|
1885
|
-
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) => {
|
|
1886
1922
|
let t = {
|
|
1887
1923
|
transports: null,
|
|
1888
1924
|
names: i,
|
|
1889
|
-
clock:
|
|
1925
|
+
clock: un,
|
|
1890
1926
|
warnOnFirstCycle: e
|
|
1891
1927
|
};
|
|
1892
1928
|
return o && (t.onStorageChange = o), t;
|
|
@@ -1896,16 +1932,16 @@ function fn(e, t, n, r) {
|
|
|
1896
1932
|
transports: {
|
|
1897
1933
|
locks: e.locks,
|
|
1898
1934
|
channel: e.channel,
|
|
1899
|
-
tabId: e.tabId ??
|
|
1935
|
+
tabId: e.tabId ?? dn()
|
|
1900
1936
|
},
|
|
1901
1937
|
names: i,
|
|
1902
|
-
clock:
|
|
1938
|
+
clock: fn(e.clock),
|
|
1903
1939
|
warnOnFirstCycle: !1
|
|
1904
1940
|
};
|
|
1905
1941
|
return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
|
|
1906
1942
|
}
|
|
1907
|
-
if (e === "none" || !a || !
|
|
1908
|
-
let c =
|
|
1943
|
+
if (e === "none" || !a || !mn(t)) return s(!1);
|
|
1944
|
+
let c = hn();
|
|
1909
1945
|
if (!c || typeof BroadcastChannel != "function") return s(!0);
|
|
1910
1946
|
let l;
|
|
1911
1947
|
try {
|
|
@@ -1917,36 +1953,36 @@ function fn(e, t, n, r) {
|
|
|
1917
1953
|
transports: {
|
|
1918
1954
|
locks: c,
|
|
1919
1955
|
channel: l,
|
|
1920
|
-
tabId:
|
|
1956
|
+
tabId: dn()
|
|
1921
1957
|
},
|
|
1922
1958
|
names: i,
|
|
1923
|
-
clock:
|
|
1959
|
+
clock: un,
|
|
1924
1960
|
warnOnFirstCycle: !1
|
|
1925
1961
|
};
|
|
1926
1962
|
return o && (u.onStorageChange = o), u;
|
|
1927
1963
|
}
|
|
1928
1964
|
// lib/pkce.ts
|
|
1929
|
-
var
|
|
1965
|
+
var yn = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bn = 32, xn = (e) => {
|
|
1930
1966
|
let t = "";
|
|
1931
1967
|
for (let n = 0; n < e.length; n += 3) {
|
|
1932
1968
|
let r = e[n], i = e[n + 1], a = e[n + 2];
|
|
1933
|
-
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));
|
|
1934
1970
|
}
|
|
1935
1971
|
return t;
|
|
1936
|
-
},
|
|
1972
|
+
}, Sn = () => {
|
|
1937
1973
|
let e = globalThis.crypto;
|
|
1938
1974
|
if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1939
1975
|
return e;
|
|
1940
|
-
},
|
|
1941
|
-
let t = await
|
|
1942
|
-
return
|
|
1943
|
-
},
|
|
1944
|
-
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)));
|
|
1945
1981
|
return {
|
|
1946
1982
|
verifier: e,
|
|
1947
|
-
challenge: await
|
|
1983
|
+
challenge: await Cn(e)
|
|
1948
1984
|
};
|
|
1949
|
-
},
|
|
1985
|
+
}, Tn = class {
|
|
1950
1986
|
error(e, ...t) {
|
|
1951
1987
|
console.error(e, ...t);
|
|
1952
1988
|
}
|
|
@@ -1960,10 +1996,10 @@ var pn = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", mn
|
|
|
1960
1996
|
console.debug(e, ...t);
|
|
1961
1997
|
}
|
|
1962
1998
|
};
|
|
1963
|
-
function
|
|
1964
|
-
return new
|
|
1999
|
+
function En() {
|
|
2000
|
+
return new Tn();
|
|
1965
2001
|
}
|
|
1966
|
-
var
|
|
2002
|
+
var Dn = Object.freeze([
|
|
1967
2003
|
"error.token.invalid.error",
|
|
1968
2004
|
"error.api.token.parse.error",
|
|
1969
2005
|
"error.api.user.blocked",
|
|
@@ -1971,25 +2007,25 @@ var xn = Object.freeze([
|
|
|
1971
2007
|
"error.validation.token.invalid.subject",
|
|
1972
2008
|
"error.not.found"
|
|
1973
2009
|
]);
|
|
1974
|
-
function
|
|
2010
|
+
function On(e) {
|
|
1975
2011
|
if (typeof e != "object" || !e) return;
|
|
1976
2012
|
let t = e;
|
|
1977
2013
|
return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
|
|
1978
2014
|
}
|
|
1979
|
-
function
|
|
1980
|
-
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);
|
|
1981
2017
|
if (typeof e != "string") return;
|
|
1982
2018
|
let n = e.trim();
|
|
1983
2019
|
if (n === "") return;
|
|
1984
|
-
if (/^\d+$/.test(n)) return Math.min(
|
|
2020
|
+
if (/^\d+$/.test(n)) return Math.min(Gt, Number.parseInt(n, 10) * 1e3);
|
|
1985
2021
|
if (!/[a-z]/i.test(n)) return;
|
|
1986
2022
|
let r = Date.parse(n);
|
|
1987
|
-
if (!Number.isNaN(r)) return Math.min(
|
|
2023
|
+
if (!Number.isNaN(r)) return Math.min(Gt, Math.max(0, r - t));
|
|
1988
2024
|
}
|
|
1989
|
-
function
|
|
2025
|
+
function An(e) {
|
|
1990
2026
|
return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
|
|
1991
2027
|
}
|
|
1992
|
-
function
|
|
2028
|
+
function jn(e) {
|
|
1993
2029
|
if (typeof e.id == "string" && e.id !== "") return e.id;
|
|
1994
2030
|
let t = e.response?.data;
|
|
1995
2031
|
if (typeof t != "object" || !t) return;
|
|
@@ -1998,14 +2034,14 @@ function Tn(e) {
|
|
|
1998
2034
|
let r = n.id;
|
|
1999
2035
|
return typeof r == "string" && r !== "" ? r : void 0;
|
|
2000
2036
|
}
|
|
2001
|
-
function
|
|
2037
|
+
function Mn(e, t = Date.now()) {
|
|
2002
2038
|
if (typeof e != "object" || !e) return { kind: "transient" };
|
|
2003
|
-
let n = e, r =
|
|
2039
|
+
let n = e, r = jn(n), i = An(n.response?.status) ?? An(n.status), a = {};
|
|
2004
2040
|
if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
|
|
2005
2041
|
kind: "blocked",
|
|
2006
2042
|
...a
|
|
2007
2043
|
};
|
|
2008
|
-
if (r !== void 0 &&
|
|
2044
|
+
if (r !== void 0 && Dn.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
|
|
2009
2045
|
kind: "auth",
|
|
2010
2046
|
...a
|
|
2011
2047
|
};
|
|
@@ -2013,7 +2049,7 @@ function En(e, t = Date.now()) {
|
|
|
2013
2049
|
kind: "transient",
|
|
2014
2050
|
...a
|
|
2015
2051
|
};
|
|
2016
|
-
let o =
|
|
2052
|
+
let o = kn(n.retryAfter ?? On(n.response?.headers), t);
|
|
2017
2053
|
return o === void 0 ? {
|
|
2018
2054
|
kind: "transient",
|
|
2019
2055
|
...a
|
|
@@ -2023,19 +2059,19 @@ function En(e, t = Date.now()) {
|
|
|
2023
2059
|
retryAfterMs: o
|
|
2024
2060
|
};
|
|
2025
2061
|
}
|
|
2026
|
-
function
|
|
2027
|
-
let r =
|
|
2028
|
-
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);
|
|
2029
2065
|
}
|
|
2030
2066
|
// lib/refresh/coordinator.ts
|
|
2031
|
-
var
|
|
2067
|
+
var Pn = {
|
|
2032
2068
|
onGranted: () => !1,
|
|
2033
2069
|
onLockLost: () => void 0,
|
|
2034
2070
|
onMessage: () => void 0
|
|
2035
2071
|
};
|
|
2036
|
-
function
|
|
2037
|
-
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o =
|
|
2038
|
-
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));
|
|
2039
2075
|
}, v = () => s !== null && c === null, y = () => {
|
|
2040
2076
|
f?.(), f = null;
|
|
2041
2077
|
}, b = (e) => {
|
|
@@ -2050,7 +2086,7 @@ function kn(e) {
|
|
|
2050
2086
|
type: "still-refreshing",
|
|
2051
2087
|
retry: m
|
|
2052
2088
|
} : { type: "still-refreshing" }), S());
|
|
2053
|
-
},
|
|
2089
|
+
}, Kt);
|
|
2054
2090
|
}, C = () => {
|
|
2055
2091
|
y(), x(), u?.(), u = null;
|
|
2056
2092
|
let e = s;
|
|
@@ -2091,29 +2127,29 @@ function kn(e) {
|
|
|
2091
2127
|
let e = s;
|
|
2092
2128
|
t.request(i.takeoverLock, { ifAvailable: !0 }, (t) => {
|
|
2093
2129
|
if (s === e && v()) {
|
|
2094
|
-
if (t === null) b(a.now() +
|
|
2130
|
+
if (t === null) b(a.now() + W);
|
|
2095
2131
|
else return _({ type: "takeover" }), new Promise((t) => {
|
|
2096
2132
|
u = t, e && (e.dead = !0, e.abort.abort()), D(!0);
|
|
2097
2133
|
});
|
|
2098
2134
|
}
|
|
2099
2135
|
}).catch(() => {
|
|
2100
|
-
v() && b(a.now() +
|
|
2136
|
+
v() && b(a.now() + W);
|
|
2101
2137
|
});
|
|
2102
2138
|
}, ee = (e) => {
|
|
2103
2139
|
if (g) return;
|
|
2104
|
-
let t =
|
|
2140
|
+
let t = sn(e.data);
|
|
2105
2141
|
if (t && t.tabId !== r) {
|
|
2106
2142
|
switch (t.type) {
|
|
2107
2143
|
case "still-refreshing":
|
|
2108
|
-
h = !0, v() && (b(a.now() +
|
|
2144
|
+
h = !0, v() && (b(a.now() + W), t.retry && b(t.retry.nextAt + W));
|
|
2109
2145
|
break;
|
|
2110
2146
|
case "takeover":
|
|
2111
|
-
h = !0, v() && b(a.now() +
|
|
2147
|
+
h = !0, v() && b(a.now() + W);
|
|
2112
2148
|
break;
|
|
2113
2149
|
case "retry-scheduled":
|
|
2114
|
-
h = !0, v() && b(Math.max(a.now(), t.retry.nextAt) +
|
|
2150
|
+
h = !0, v() && b(Math.max(a.now(), t.retry.nextAt) + W);
|
|
2115
2151
|
break;
|
|
2116
|
-
case "rate-limited": v() && b(t.until +
|
|
2152
|
+
case "rate-limited": v() && b(t.until + W);
|
|
2117
2153
|
}
|
|
2118
2154
|
o.onMessage(t);
|
|
2119
2155
|
}
|
|
@@ -2131,7 +2167,7 @@ function kn(e) {
|
|
|
2131
2167
|
o = e;
|
|
2132
2168
|
},
|
|
2133
2169
|
request: (e) => {
|
|
2134
|
-
g || s || (p = 0, b(Math.max(a.now() +
|
|
2170
|
+
g || s || (p = 0, b(Math.max(a.now() + W, e ?? 0)), D(!1));
|
|
2135
2171
|
},
|
|
2136
2172
|
release: C,
|
|
2137
2173
|
post: _,
|
|
@@ -2144,8 +2180,8 @@ function kn(e) {
|
|
|
2144
2180
|
}
|
|
2145
2181
|
};
|
|
2146
2182
|
}
|
|
2147
|
-
function
|
|
2148
|
-
let t =
|
|
2183
|
+
function In(e = "local") {
|
|
2184
|
+
let t = Pn, n = !1, r = !1, i = 0, a = !1, o = () => {
|
|
2149
2185
|
n = !1, r = !1, i += 1;
|
|
2150
2186
|
};
|
|
2151
2187
|
return {
|
|
@@ -2185,7 +2221,7 @@ function An(e = "local") {
|
|
|
2185
2221
|
};
|
|
2186
2222
|
}
|
|
2187
2223
|
// lib/refresh/errors.ts
|
|
2188
|
-
var
|
|
2224
|
+
var K = {
|
|
2189
2225
|
unavailable: "error.refresh.unavailable",
|
|
2190
2226
|
authRetry: "error.refresh.auth_retry",
|
|
2191
2227
|
sessionEnded: "error.refresh.session_ended",
|
|
@@ -2193,7 +2229,7 @@ var q = {
|
|
|
2193
2229
|
successorTimeout: "error.refresh.successor_timeout",
|
|
2194
2230
|
identityChanged: "error.refresh.identity_changed",
|
|
2195
2231
|
disposed: "error.refresh.disposed"
|
|
2196
|
-
},
|
|
2232
|
+
}, Ln = {
|
|
2197
2233
|
"error.refresh.unavailable": 503,
|
|
2198
2234
|
"error.refresh.auth_retry": 401,
|
|
2199
2235
|
"error.refresh.session_ended": 401,
|
|
@@ -2201,7 +2237,7 @@ var q = {
|
|
|
2201
2237
|
"error.refresh.successor_timeout": 401,
|
|
2202
2238
|
"error.refresh.identity_changed": 401,
|
|
2203
2239
|
"error.refresh.disposed": 499
|
|
2204
|
-
},
|
|
2240
|
+
}, Rn = {
|
|
2205
2241
|
"error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
|
|
2206
2242
|
"error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
|
|
2207
2243
|
"error.refresh.session_ended": "The session has ended",
|
|
@@ -2209,23 +2245,23 @@ var q = {
|
|
|
2209
2245
|
"error.refresh.successor_timeout": "The refresh token was already used and no successor arrived",
|
|
2210
2246
|
"error.refresh.identity_changed": "Storage holds another user's tokens",
|
|
2211
2247
|
"error.refresh.disposed": "The Passflow instance was disposed"
|
|
2212
|
-
},
|
|
2248
|
+
}, q = class extends B {
|
|
2213
2249
|
constructor(e, t = {}) {
|
|
2214
2250
|
super({
|
|
2215
2251
|
id: e,
|
|
2216
|
-
message: t.message ??
|
|
2217
|
-
status:
|
|
2252
|
+
message: t.message ?? Rn[e],
|
|
2253
|
+
status: Ln[e],
|
|
2218
2254
|
location: "/auth/refresh",
|
|
2219
2255
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2220
2256
|
}), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
|
|
2221
2257
|
}
|
|
2222
|
-
},
|
|
2258
|
+
}, zn = class extends Error {
|
|
2223
2259
|
constructor(e, t) {
|
|
2224
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;
|
|
2225
2261
|
}
|
|
2226
2262
|
};
|
|
2227
2263
|
// lib/refresh/lineage.ts
|
|
2228
|
-
function
|
|
2264
|
+
function J(e) {
|
|
2229
2265
|
if (!e) return;
|
|
2230
2266
|
let t = 3735928559, n = 1103547991;
|
|
2231
2267
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -2234,24 +2270,24 @@ function Pn(e) {
|
|
|
2234
2270
|
}
|
|
2235
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);
|
|
2236
2272
|
}
|
|
2237
|
-
function
|
|
2273
|
+
function Bn(e) {
|
|
2238
2274
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2239
2275
|
}
|
|
2240
2276
|
function Y(e) {
|
|
2241
|
-
let t =
|
|
2277
|
+
let t = J(e);
|
|
2242
2278
|
if (!e || !t) return;
|
|
2243
2279
|
let n = {};
|
|
2244
2280
|
try {
|
|
2245
2281
|
let t = A(e);
|
|
2246
2282
|
typeof t == "object" && t && (n = t);
|
|
2247
2283
|
} catch {}
|
|
2248
|
-
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);
|
|
2249
2285
|
return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
|
|
2250
2286
|
}
|
|
2251
|
-
var
|
|
2252
|
-
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)) {
|
|
2253
2289
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
|
|
2254
|
-
a || (a = !0, e(
|
|
2290
|
+
a || (a = !0, e(Vn));
|
|
2255
2291
|
}, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
|
|
2256
2292
|
if (!e) return;
|
|
2257
2293
|
if (e.iat === void 0) {
|
|
@@ -2292,16 +2328,16 @@ function Ln(e = (e) => bn().warn(e)) {
|
|
|
2292
2328
|
};
|
|
2293
2329
|
}
|
|
2294
2330
|
// lib/refresh/fence.ts
|
|
2295
|
-
var
|
|
2331
|
+
var Un = class extends Error {
|
|
2296
2332
|
constructor(e) {
|
|
2297
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;
|
|
2298
2334
|
}
|
|
2299
|
-
},
|
|
2335
|
+
}, Wn = class extends Error {
|
|
2300
2336
|
constructor() {
|
|
2301
2337
|
super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
|
|
2302
2338
|
}
|
|
2303
2339
|
};
|
|
2304
|
-
function
|
|
2340
|
+
function Gn(e) {
|
|
2305
2341
|
if (e) try {
|
|
2306
2342
|
let t = A(e).sub;
|
|
2307
2343
|
return typeof t == "string" && t !== "" ? t : void 0;
|
|
@@ -2310,20 +2346,20 @@ function Bn(e) {
|
|
|
2310
2346
|
}
|
|
2311
2347
|
}
|
|
2312
2348
|
function X(e) {
|
|
2313
|
-
return
|
|
2349
|
+
return Gn(e?.access_token) ?? Gn(e?.refresh_token) ?? Gn(e?.id_token);
|
|
2314
2350
|
}
|
|
2315
|
-
function
|
|
2351
|
+
function Kn(e, t) {
|
|
2316
2352
|
return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
|
|
2317
2353
|
}
|
|
2318
|
-
function
|
|
2354
|
+
function qn(e) {
|
|
2319
2355
|
return typeof e == "object" && !!e;
|
|
2320
2356
|
}
|
|
2321
|
-
function
|
|
2322
|
-
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 = () => {
|
|
2323
2359
|
let e = t.getTokens(), n = e?.refresh_token;
|
|
2324
2360
|
if (!n) return p = l, e;
|
|
2325
2361
|
p !== void 0 && (f = Math.max(f, p, m), p = void 0);
|
|
2326
|
-
let r =
|
|
2362
|
+
let r = J(n) ?? "";
|
|
2327
2363
|
return r !== c?.fp && (c = {
|
|
2328
2364
|
fp: r,
|
|
2329
2365
|
seq: l
|
|
@@ -2356,7 +2392,7 @@ function Un(e) {
|
|
|
2356
2392
|
let t = E();
|
|
2357
2393
|
t === "wait" && e && (t = "end"), t !== "wait" && D(), t === "wait" && !h && (h = r(() => {
|
|
2358
2394
|
h = void 0, y()?.refresh_token ? N() : O(!0) === "end" && s?.("emptied");
|
|
2359
|
-
},
|
|
2395
|
+
}, Yt));
|
|
2360
2396
|
let n = t === "keep" ? T() : void 0;
|
|
2361
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;
|
|
2362
2398
|
}, ee = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, k = (e) => {
|
|
@@ -2369,7 +2405,7 @@ function Un(e) {
|
|
|
2369
2405
|
return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
|
|
2370
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) => {
|
|
2371
2407
|
let t = b();
|
|
2372
|
-
t && t.fp !==
|
|
2408
|
+
t && t.fp !== J(e.refresh_token) && o.retire(t), n.setTokensCache(e);
|
|
2373
2409
|
}, te = (e) => {
|
|
2374
2410
|
let t = y(), n = t?.refresh_token;
|
|
2375
2411
|
if (n === e.refreshToken) return null;
|
|
@@ -2380,7 +2416,7 @@ function Un(e) {
|
|
|
2380
2416
|
kind: "superseded",
|
|
2381
2417
|
adopted: !1
|
|
2382
2418
|
};
|
|
2383
|
-
let r =
|
|
2419
|
+
let r = Gn(t.access_token) ?? Gn(n);
|
|
2384
2420
|
if (e.sub && r && e.sub !== r) return {
|
|
2385
2421
|
kind: "identity-changed",
|
|
2386
2422
|
saved: !1
|
|
@@ -2420,22 +2456,22 @@ function Un(e) {
|
|
|
2420
2456
|
}, re = !!s || !!e.onStoredSessionSeen, ie = re && e.onStorageChange ? e.onStorageChange(N) : void 0, ae = re && e.onWake ? e.onWake(N) : void 0, P = () => {
|
|
2421
2457
|
let e = y();
|
|
2422
2458
|
if (!e?.refresh_token) {
|
|
2423
|
-
if (O() === "end") throw new
|
|
2459
|
+
if (O() === "end") throw new Un("emptied");
|
|
2424
2460
|
return "held";
|
|
2425
2461
|
}
|
|
2426
2462
|
let t = n.getTokens();
|
|
2427
2463
|
if (e.refresh_token === t?.refresh_token) return "send";
|
|
2428
2464
|
let r = i() ?? X(t), a = X(e);
|
|
2429
|
-
if (r && a && r !== a) throw new
|
|
2465
|
+
if (r && a && r !== a) throw new Wn();
|
|
2430
2466
|
let s = Y(e.refresh_token);
|
|
2431
2467
|
if (o.isEnded(s)) {
|
|
2432
2468
|
if (s && C(s)) return "held";
|
|
2433
|
-
throw new
|
|
2469
|
+
throw new Un("ended");
|
|
2434
2470
|
}
|
|
2435
2471
|
let c = Y(t?.refresh_token);
|
|
2436
2472
|
return j(s, c) ? (M(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && k(s) ? "held" : "send";
|
|
2437
2473
|
}, oe = (e) => {
|
|
2438
|
-
let t = i(), r =
|
|
2474
|
+
let t = i(), r = Gn(e);
|
|
2439
2475
|
if (t && r && t !== r) return { kind: "identity-changed" };
|
|
2440
2476
|
let a = Y(e) ?? { fp: e };
|
|
2441
2477
|
if (o.isEnded(a)) return C(a) ? { kind: "superseded" } : { kind: "ended" };
|
|
@@ -2443,7 +2479,7 @@ function Un(e) {
|
|
|
2443
2479
|
let s = {
|
|
2444
2480
|
refreshToken: e,
|
|
2445
2481
|
order: a
|
|
2446
|
-
}, c = t ?? r ??
|
|
2482
|
+
}, c = t ?? r ?? Gn(n.getTokens()?.access_token);
|
|
2447
2483
|
return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
|
|
2448
2484
|
kind: "send",
|
|
2449
2485
|
sent: s
|
|
@@ -2452,7 +2488,7 @@ function Un(e) {
|
|
|
2452
2488
|
if (o.isEnded(e.order)) return ne(e.order);
|
|
2453
2489
|
let i = te(e);
|
|
2454
2490
|
if (i) return i;
|
|
2455
|
-
if (!ee(e) && A(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${
|
|
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.`), {
|
|
2456
2492
|
kind: "superseded",
|
|
2457
2493
|
adopted: !1
|
|
2458
2494
|
};
|
|
@@ -2462,7 +2498,7 @@ function Un(e) {
|
|
|
2462
2498
|
saved: !0
|
|
2463
2499
|
};
|
|
2464
2500
|
let c = Y(r.refresh_token);
|
|
2465
|
-
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.`), {
|
|
2466
2502
|
kind: "superseded",
|
|
2467
2503
|
adopted: !1
|
|
2468
2504
|
}) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
|
|
@@ -2474,7 +2510,7 @@ function Un(e) {
|
|
|
2474
2510
|
kind: "superseded",
|
|
2475
2511
|
adopted: !1
|
|
2476
2512
|
};
|
|
2477
|
-
let r =
|
|
2513
|
+
let r = Mn(t), i = r.kind === "blocked" || r.kind === "auth";
|
|
2478
2514
|
return ee(e) && i ? (o.retire(e.order), _ = e.order, {
|
|
2479
2515
|
kind: "own",
|
|
2480
2516
|
failure: r,
|
|
@@ -2485,11 +2521,11 @@ function Un(e) {
|
|
|
2485
2521
|
heldRefused: !1
|
|
2486
2522
|
});
|
|
2487
2523
|
}, I = (e) => {
|
|
2488
|
-
if (!
|
|
2524
|
+
if (!qn(e)) return !1;
|
|
2489
2525
|
let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
|
|
2490
|
-
if (typeof t != "string" || typeof c != "string" || !
|
|
2526
|
+
if (typeof t != "string" || typeof c != "string" || !qn(l)) return !1;
|
|
2491
2527
|
let u = l;
|
|
2492
|
-
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;
|
|
2493
2529
|
let d = y();
|
|
2494
2530
|
if (!d?.refresh_token) return !1;
|
|
2495
2531
|
let f = n.getTokens(), p = i() ?? X(f), m = X(u);
|
|
@@ -2506,7 +2542,7 @@ function Un(e) {
|
|
|
2506
2542
|
}
|
|
2507
2543
|
return !0;
|
|
2508
2544
|
};
|
|
2509
|
-
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 }), _());
|
|
2510
2546
|
}, L = (e) => {
|
|
2511
2547
|
if (!e || !_) return !1;
|
|
2512
2548
|
let t = _;
|
|
@@ -2572,7 +2608,7 @@ function Un(e) {
|
|
|
2572
2608
|
};
|
|
2573
2609
|
}
|
|
2574
2610
|
// lib/refresh/controller.ts
|
|
2575
|
-
function
|
|
2611
|
+
function Yn() {
|
|
2576
2612
|
let e, t, n = new Promise((n, r) => {
|
|
2577
2613
|
e = n, t = r;
|
|
2578
2614
|
});
|
|
@@ -2582,53 +2618,53 @@ function Wn() {
|
|
|
2582
2618
|
reject: t
|
|
2583
2619
|
};
|
|
2584
2620
|
}
|
|
2585
|
-
var
|
|
2586
|
-
strikes:
|
|
2587
|
-
"session-ended":
|
|
2588
|
-
"stored-ended":
|
|
2589
|
-
"signed-out":
|
|
2590
|
-
emptied:
|
|
2591
|
-
"signed-out-here":
|
|
2592
|
-
"successor-timeout":
|
|
2593
|
-
"identity-changed":
|
|
2594
|
-
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
|
|
2595
2631
|
};
|
|
2596
|
-
function
|
|
2632
|
+
function Zn(e) {
|
|
2597
2633
|
throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
|
|
2598
2634
|
}
|
|
2599
|
-
function
|
|
2635
|
+
function Qn(e) {
|
|
2600
2636
|
if (e === void 0 || !Number.isFinite(e)) return 3;
|
|
2601
2637
|
let t = Math.floor(e);
|
|
2602
2638
|
return t >= 1 ? t : 3;
|
|
2603
2639
|
}
|
|
2604
|
-
function
|
|
2640
|
+
function $n(e, t) {
|
|
2605
2641
|
return e instanceof Error && e.message ? e.message : t;
|
|
2606
2642
|
}
|
|
2607
|
-
function
|
|
2643
|
+
function er(e) {
|
|
2608
2644
|
if (typeof e != "object" || !e) return;
|
|
2609
2645
|
let t = e.id;
|
|
2610
2646
|
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
2611
2647
|
}
|
|
2612
|
-
function
|
|
2648
|
+
function tr(e) {
|
|
2613
2649
|
let t = {};
|
|
2614
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;
|
|
2615
2651
|
}
|
|
2616
|
-
function
|
|
2652
|
+
function nr(e, t) {
|
|
2617
2653
|
let n = {};
|
|
2618
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);
|
|
2619
2655
|
let r = t?.scopes ?? e.scopes;
|
|
2620
2656
|
return r && (n.scopes = r), n;
|
|
2621
2657
|
}
|
|
2622
|
-
function
|
|
2623
|
-
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({
|
|
2624
2660
|
locks: a.transports.locks,
|
|
2625
2661
|
channel: a.transports.channel,
|
|
2626
2662
|
tabId: a.transports.tabId,
|
|
2627
2663
|
names: a.names,
|
|
2628
2664
|
clock: o
|
|
2629
|
-
}) :
|
|
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) => () => {
|
|
2630
2666
|
for (let t of Array.from(e)) t();
|
|
2631
|
-
}, 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({
|
|
2632
2668
|
storage: n,
|
|
2633
2669
|
cache: r,
|
|
2634
2670
|
identity: k,
|
|
@@ -2643,13 +2679,13 @@ function Qn(e) {
|
|
|
2643
2679
|
}), re = (e) => ({
|
|
2644
2680
|
trigger: e,
|
|
2645
2681
|
startedAt: T(),
|
|
2646
|
-
plain:
|
|
2682
|
+
plain: Yn(),
|
|
2647
2683
|
fresh: []
|
|
2648
2684
|
}), ie = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, ae = (e, t) => {
|
|
2649
2685
|
if (t === void 0) return e.plain.promise;
|
|
2650
2686
|
let n = {
|
|
2651
2687
|
callTime: t,
|
|
2652
|
-
deferred:
|
|
2688
|
+
deferred: Yn()
|
|
2653
2689
|
};
|
|
2654
2690
|
return e.fresh.push(n), n.deferred.promise;
|
|
2655
2691
|
}, P = (e, t, n = !1) => {
|
|
@@ -2668,11 +2704,11 @@ function Qn(e) {
|
|
|
2668
2704
|
}
|
|
2669
2705
|
}, F = (e, n, r, i) => {
|
|
2670
2706
|
let a = {
|
|
2671
|
-
message:
|
|
2707
|
+
message: $n(r, "Token refresh failed"),
|
|
2672
2708
|
originalError: r,
|
|
2673
2709
|
operation: e,
|
|
2674
2710
|
source: n
|
|
2675
|
-
}, o =
|
|
2711
|
+
}, o = er(r);
|
|
2676
2712
|
o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
|
|
2677
2713
|
}, I = (e, t) => {
|
|
2678
2714
|
let n = {
|
|
@@ -2702,10 +2738,10 @@ function Qn(e) {
|
|
|
2702
2738
|
};
|
|
2703
2739
|
n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
|
|
2704
2740
|
}, le = (e, t) => {
|
|
2705
|
-
let n = r.getTokens(), i =
|
|
2741
|
+
let n = r.getTokens(), i = J(n?.refresh_token);
|
|
2706
2742
|
e.fp && i && l.post({
|
|
2707
2743
|
type: "tokens-refreshed",
|
|
2708
|
-
tokens:
|
|
2744
|
+
tokens: tr(n),
|
|
2709
2745
|
from: e.fp,
|
|
2710
2746
|
...e.iat === void 0 ? {} : { fromIat: e.iat },
|
|
2711
2747
|
fromSid: e.sid ?? "",
|
|
@@ -2713,7 +2749,7 @@ function Qn(e) {
|
|
|
2713
2749
|
...t === void 0 ? {} : { sentAt: t }
|
|
2714
2750
|
});
|
|
2715
2751
|
}, ue = () => {
|
|
2716
|
-
p || (p = !0, s.warn(
|
|
2752
|
+
p || (p = !0, s.warn(ln));
|
|
2717
2753
|
}, de = (e) => {
|
|
2718
2754
|
(e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
|
|
2719
2755
|
}, R = (e, n) => {
|
|
@@ -2727,7 +2763,7 @@ function Qn(e) {
|
|
|
2727
2763
|
}, e !== "disposed" && N.dropSession(), (e === "strikes" || e === "successor-timeout") && E() !== "json" && i.invalidate(), u = {
|
|
2728
2764
|
kind: "ended",
|
|
2729
2765
|
cause: e
|
|
2730
|
-
}, se(r, n ?? new
|
|
2766
|
+
}, se(r, n ?? new q(Xn[e])), e) {
|
|
2731
2767
|
case "strikes":
|
|
2732
2768
|
t("session:expired", {
|
|
2733
2769
|
reason: "refresh_failed",
|
|
@@ -2762,7 +2798,7 @@ function Qn(e) {
|
|
|
2762
2798
|
break;
|
|
2763
2799
|
case "signed-out-here":
|
|
2764
2800
|
case "disposed": break;
|
|
2765
|
-
default:
|
|
2801
|
+
default: Zn(e);
|
|
2766
2802
|
}
|
|
2767
2803
|
}, fe = () => {
|
|
2768
2804
|
if (u.kind !== "ended" || u.cause === "disposed" || f || E() !== "json") return;
|
|
@@ -2779,17 +2815,17 @@ function Qn(e) {
|
|
|
2779
2815
|
}, pe = (e) => {
|
|
2780
2816
|
u.kind === "ended" || f || E() === "json" && (R(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && fe());
|
|
2781
2817
|
}, me = (e) => {
|
|
2782
|
-
e instanceof
|
|
2818
|
+
e instanceof Wn ? (R("identity-changed"), fe()) : e instanceof Un ? R(e.cause === "emptied" ? "emptied" : "stored-ended") : R("stored-ended", e);
|
|
2783
2819
|
}, he = () => {
|
|
2784
2820
|
u = { kind: "idle" }, w || l.release();
|
|
2785
|
-
}, 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) => {
|
|
2786
2822
|
let t = g;
|
|
2787
2823
|
if (!t) return;
|
|
2788
2824
|
if (!l.holding) {
|
|
2789
2825
|
u = {
|
|
2790
2826
|
kind: "waiting",
|
|
2791
2827
|
pending: e
|
|
2792
|
-
}, l.request(t.nextAt +
|
|
2828
|
+
}, l.request(t.nextAt + W);
|
|
2793
2829
|
return;
|
|
2794
2830
|
}
|
|
2795
2831
|
l.setRetryInfo(t);
|
|
@@ -2808,7 +2844,7 @@ function Qn(e) {
|
|
|
2808
2844
|
!l.holding || l.foreignHolderHeard() || T() - t > 2e4 ? (l.release(), u = {
|
|
2809
2845
|
kind: "waiting",
|
|
2810
2846
|
pending: e
|
|
2811
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
2847
|
+
}, l.request((g?.nextAt ?? T()) + W)) : (u = {
|
|
2812
2848
|
kind: "waiting",
|
|
2813
2849
|
pending: e
|
|
2814
2850
|
}, be() || ye());
|
|
@@ -2848,14 +2884,14 @@ function Qn(e) {
|
|
|
2848
2884
|
case "ended": return N.endHeldSend(), R("stored-ended"), !1;
|
|
2849
2885
|
case "identity-changed": return N.endHeldSend(), R("identity-changed"), fe(), !1;
|
|
2850
2886
|
case "send": return Ce(e, t, a.sent, r);
|
|
2851
|
-
default: return
|
|
2887
|
+
default: return Zn(a);
|
|
2852
2888
|
}
|
|
2853
2889
|
}, Ce = (e, n, r, a) => {
|
|
2854
2890
|
let o = {
|
|
2855
2891
|
generation: d,
|
|
2856
2892
|
sentAt: T(),
|
|
2857
2893
|
trigger: n,
|
|
2858
|
-
settled:
|
|
2894
|
+
settled: Yn()
|
|
2859
2895
|
};
|
|
2860
2896
|
r ? o.sent = r : o.marker = ee(), a && (o.stored = a), u = {
|
|
2861
2897
|
kind: "refreshing",
|
|
@@ -2879,7 +2915,7 @@ function Qn(e) {
|
|
|
2879
2915
|
if (!e.sent) {
|
|
2880
2916
|
let o = X({ ...t.id_token ? { id_token: t.id_token } : {} }), s = k();
|
|
2881
2917
|
if (o !== void 0 && s !== void 0 && o !== s) {
|
|
2882
|
-
let t = new
|
|
2918
|
+
let t = new q(K.identityChanged);
|
|
2883
2919
|
F("refresh", e.trigger, t, I("auth")), R("identity-changed", t);
|
|
2884
2920
|
return;
|
|
2885
2921
|
}
|
|
@@ -2892,7 +2928,7 @@ function Qn(e) {
|
|
|
2892
2928
|
if (!we(e)) return;
|
|
2893
2929
|
r.setTokensCache({
|
|
2894
2930
|
...n.getTokens() ?? {},
|
|
2895
|
-
...
|
|
2931
|
+
...nr(t, void 0)
|
|
2896
2932
|
}), L("refresh", "this-tab");
|
|
2897
2933
|
let c = k();
|
|
2898
2934
|
l.post(c === void 0 ? {
|
|
@@ -2905,7 +2941,7 @@ function Qn(e) {
|
|
|
2905
2941
|
}), he(), P(a, e.sentAt);
|
|
2906
2942
|
return;
|
|
2907
2943
|
}
|
|
2908
|
-
let o = D(), s = N.commitSave(e.sent,
|
|
2944
|
+
let o = D(), s = N.commitSave(e.sent, nr(t, e.stored));
|
|
2909
2945
|
switch (s.kind) {
|
|
2910
2946
|
case "saved":
|
|
2911
2947
|
L("refresh", "this-tab"), le(e.sent.order, e.sentAt), he(), P(a, e.sentAt);
|
|
@@ -2914,16 +2950,16 @@ function Qn(e) {
|
|
|
2914
2950
|
e.outcome && D() === o || L("adopted", "other-tab"), s.adopted && le(e.sent.order), he(), P(a, e.sentAt);
|
|
2915
2951
|
return;
|
|
2916
2952
|
case "ended": {
|
|
2917
|
-
let t = new
|
|
2953
|
+
let t = new q(s.cause === "emptied" ? K.signedOut : K.sessionEnded);
|
|
2918
2954
|
F("refresh", e.trigger, t, I("auth")), R(s.cause === "emptied" ? "emptied" : "stored-ended", t);
|
|
2919
2955
|
return;
|
|
2920
2956
|
}
|
|
2921
2957
|
case "identity-changed": {
|
|
2922
|
-
let t = new
|
|
2958
|
+
let t = new q(K.identityChanged);
|
|
2923
2959
|
F("refresh", e.trigger, t, I("auth")), R("identity-changed", t), fe();
|
|
2924
2960
|
return;
|
|
2925
2961
|
}
|
|
2926
|
-
default:
|
|
2962
|
+
default: Zn(s);
|
|
2927
2963
|
}
|
|
2928
2964
|
}, Ee = (e, t) => {
|
|
2929
2965
|
if (e.sent?.held && N.endHeldSend(), !we(e) || u.kind !== "refreshing") return;
|
|
@@ -2943,9 +2979,9 @@ function Qn(e) {
|
|
|
2943
2979
|
case "own":
|
|
2944
2980
|
r = o.failure, i = o.heldRefused;
|
|
2945
2981
|
break;
|
|
2946
|
-
default:
|
|
2982
|
+
default: Zn(o);
|
|
2947
2983
|
}
|
|
2948
|
-
} else r =
|
|
2984
|
+
} else r = Mn(t, T());
|
|
2949
2985
|
if (i) F("refresh", e.trigger, t, I(r.kind)), L("adopted", "other-tab"), he(), P(n, void 0, !0);
|
|
2950
2986
|
else switch (r.kind) {
|
|
2951
2987
|
case "blocked":
|
|
@@ -2961,10 +2997,10 @@ function Qn(e) {
|
|
|
2961
2997
|
case "transient":
|
|
2962
2998
|
m += 1, De(e, n, t, r);
|
|
2963
2999
|
return;
|
|
2964
|
-
default:
|
|
3000
|
+
default: Zn(r.kind);
|
|
2965
3001
|
}
|
|
2966
3002
|
}, De = (e, t, n, r) => {
|
|
2967
|
-
let i = T() +
|
|
3003
|
+
let i = T() + Nn(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
|
|
2968
3004
|
F("refresh", e.trigger, n, I(a, i)), a === "transient" && ce(T(), i, "this-tab");
|
|
2969
3005
|
let s = {
|
|
2970
3006
|
kind: a,
|
|
@@ -2974,7 +3010,7 @@ function Qn(e) {
|
|
|
2974
3010
|
}, c = e.sent?.order.fp;
|
|
2975
3011
|
c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
|
|
2976
3012
|
type: "retry-scheduled",
|
|
2977
|
-
message:
|
|
3013
|
+
message: $n(n, "Token refresh failed"),
|
|
2978
3014
|
retry: s
|
|
2979
3015
|
}), _e(re("retry")), oe(t, n, e.sentAt);
|
|
2980
3016
|
}, z = (e, t) => {
|
|
@@ -2987,8 +3023,8 @@ function Qn(e) {
|
|
|
2987
3023
|
fp: i.fp
|
|
2988
3024
|
})), r && N.deleteIfStillDead(r), R("strikes", t);
|
|
2989
3025
|
}, Oe = (e, t, n, r) => {
|
|
2990
|
-
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${
|
|
2991
|
-
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 = {
|
|
2992
3028
|
kind: "blocked-wait",
|
|
2993
3029
|
pending: e,
|
|
2994
3030
|
deadline: a,
|
|
@@ -3001,9 +3037,9 @@ function Qn(e) {
|
|
|
3001
3037
|
i === d && u === c && (ke() || (f ? (e.cookieRetried = !0, u = {
|
|
3002
3038
|
kind: "waiting",
|
|
3003
3039
|
pending: e
|
|
3004
|
-
}, l.request()) : T() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), R("successor-timeout")) : c.cancel = o.setTimeout(p,
|
|
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)));
|
|
3005
3041
|
};
|
|
3006
|
-
c.cancel = o.setTimeout(p, f ?
|
|
3042
|
+
c.cancel = o.setTimeout(p, f ? Xt : Jt);
|
|
3007
3043
|
}, ke = () => {
|
|
3008
3044
|
if (u.kind !== "blocked-wait") return !1;
|
|
3009
3045
|
let e = u;
|
|
@@ -3026,7 +3062,7 @@ function Qn(e) {
|
|
|
3026
3062
|
if (u.kind === "ended" || !ge(e)) return;
|
|
3027
3063
|
let r = g?.nextAt;
|
|
3028
3064
|
if (g = e, e.failingSince !== void 0 && ce(e.failingSince, e.nextAt, "other-tab"), !t || u.kind !== "waiting") return;
|
|
3029
|
-
let i = new
|
|
3065
|
+
let i = new q(e.kind === "transient" ? K.unavailable : K.authRetry, {
|
|
3030
3066
|
nextRetryAt: e.nextAt,
|
|
3031
3067
|
cause: n || void 0
|
|
3032
3068
|
}), a = u.pending;
|
|
@@ -3047,7 +3083,7 @@ function Qn(e) {
|
|
|
3047
3083
|
case "idle":
|
|
3048
3084
|
case "refreshing":
|
|
3049
3085
|
case "ended": return;
|
|
3050
|
-
default:
|
|
3086
|
+
default: Zn(u);
|
|
3051
3087
|
}
|
|
3052
3088
|
}, Ne = (e) => {
|
|
3053
3089
|
let t = {};
|
|
@@ -3090,10 +3126,10 @@ function Qn(e) {
|
|
|
3090
3126
|
je(e.retry, !0, e.message), Fe();
|
|
3091
3127
|
return;
|
|
3092
3128
|
case "refresh-failed":
|
|
3093
|
-
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;
|
|
3094
3130
|
if (ce(T(), void 0, "other-tab"), u.kind === "waiting") {
|
|
3095
3131
|
let t = u.pending;
|
|
3096
|
-
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);
|
|
3097
3133
|
}
|
|
3098
3134
|
return;
|
|
3099
3135
|
case "lock-wanted":
|
|
@@ -3102,7 +3138,7 @@ function Qn(e) {
|
|
|
3102
3138
|
u.cancel(), l.release(), u = {
|
|
3103
3139
|
kind: "waiting",
|
|
3104
3140
|
pending: e
|
|
3105
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
3141
|
+
}, l.request((g?.nextAt ?? T()) + W);
|
|
3106
3142
|
}
|
|
3107
3143
|
return;
|
|
3108
3144
|
case "session-ended":
|
|
@@ -3111,7 +3147,7 @@ function Qn(e) {
|
|
|
3111
3147
|
return;
|
|
3112
3148
|
case "takeover":
|
|
3113
3149
|
case "rate-limited": return;
|
|
3114
|
-
default:
|
|
3150
|
+
default: Zn(e);
|
|
3115
3151
|
}
|
|
3116
3152
|
}, Fe = () => {
|
|
3117
3153
|
C && !l.holding && l.post({
|
|
@@ -3134,7 +3170,7 @@ function Qn(e) {
|
|
|
3134
3170
|
u.cancel(), u = {
|
|
3135
3171
|
kind: "waiting",
|
|
3136
3172
|
pending: e
|
|
3137
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
3173
|
+
}, l.request((g?.nextAt ?? T()) + W);
|
|
3138
3174
|
}
|
|
3139
3175
|
},
|
|
3140
3176
|
onMessage: Pe
|
|
@@ -3160,9 +3196,9 @@ function Qn(e) {
|
|
|
3160
3196
|
};
|
|
3161
3197
|
A.add(Ie), j.add(Ie);
|
|
3162
3198
|
let Le = (e, t) => {
|
|
3163
|
-
if (f) return Promise.reject(new
|
|
3199
|
+
if (f) return Promise.reject(new q(K.disposed));
|
|
3164
3200
|
switch (u.kind) {
|
|
3165
|
-
case "ended": return Promise.reject(new
|
|
3201
|
+
case "ended": return Promise.reject(new q(K.sessionEnded));
|
|
3166
3202
|
case "idle": {
|
|
3167
3203
|
let n = re(e);
|
|
3168
3204
|
u = {
|
|
@@ -3170,17 +3206,17 @@ function Qn(e) {
|
|
|
3170
3206
|
pending: n
|
|
3171
3207
|
};
|
|
3172
3208
|
let r = ae(n, t);
|
|
3173
|
-
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;
|
|
3174
3210
|
}
|
|
3175
3211
|
case "waiting":
|
|
3176
3212
|
case "refreshing":
|
|
3177
3213
|
case "backoff":
|
|
3178
3214
|
case "blocked-wait": return ae(u.pending, t);
|
|
3179
|
-
default: return
|
|
3215
|
+
default: return Zn(u);
|
|
3180
3216
|
}
|
|
3181
3217
|
}, V = (e) => {
|
|
3182
|
-
if (f) return Promise.reject(new
|
|
3183
|
-
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));
|
|
3184
3220
|
if (E() === "json" && !r.getTokens()?.refresh_token) {
|
|
3185
3221
|
let t = n.getTokens();
|
|
3186
3222
|
if (!t?.refresh_token) {
|
|
@@ -3190,7 +3226,7 @@ function Qn(e) {
|
|
|
3190
3226
|
}
|
|
3191
3227
|
return Le(e.trigger, e.fresh ? T() : void 0);
|
|
3192
3228
|
}, Re = (e) => {
|
|
3193
|
-
if (f) return Promise.reject(new
|
|
3229
|
+
if (f) return Promise.reject(new q(K.disposed));
|
|
3194
3230
|
if (u.kind === "ended") return Promise.resolve(r.getTokens());
|
|
3195
3231
|
let t = u.kind === "backoff" || u.kind === "blocked-wait" || g !== void 0 && g.nextAt > T();
|
|
3196
3232
|
return e.allowStale && t ? Promise.resolve(r.getTokens()) : V({ trigger: e.trigger }).then(() => r.getTokens());
|
|
@@ -3225,11 +3261,11 @@ function Qn(e) {
|
|
|
3225
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();
|
|
3226
3262
|
}
|
|
3227
3263
|
}, He = async (e, t) => {
|
|
3228
|
-
if (f) throw new
|
|
3264
|
+
if (f) throw new q(K.disposed);
|
|
3229
3265
|
ue();
|
|
3230
|
-
let n = T() +
|
|
3266
|
+
let n = T() + Zt;
|
|
3231
3267
|
if (await Be(n - T()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await ze("commit", n - T())) === "timeout") {
|
|
3232
|
-
let e = new
|
|
3268
|
+
let e = new zn("lock-timeout");
|
|
3233
3269
|
throw F("upgrade.commit", "upgrade", e), e;
|
|
3234
3270
|
}
|
|
3235
3271
|
w = !0;
|
|
@@ -3276,7 +3312,7 @@ function Qn(e) {
|
|
|
3276
3312
|
if (!o) {
|
|
3277
3313
|
await i.applyOpaque(u), r.setTokensCache({
|
|
3278
3314
|
...n.getTokens() ?? {},
|
|
3279
|
-
...
|
|
3315
|
+
...nr(u, void 0)
|
|
3280
3316
|
}), We(c);
|
|
3281
3317
|
let e = k();
|
|
3282
3318
|
return l.post(e === void 0 ? {
|
|
@@ -3288,9 +3324,9 @@ function Qn(e) {
|
|
|
3288
3324
|
sub: e
|
|
3289
3325
|
}), O();
|
|
3290
3326
|
}
|
|
3291
|
-
let d = N.commitSave(o,
|
|
3327
|
+
let d = N.commitSave(o, nr(u, s));
|
|
3292
3328
|
if (d.kind === "saved") return We(c), le(o.order, c), O();
|
|
3293
|
-
let f = new
|
|
3329
|
+
let f = new zn("superseded");
|
|
3294
3330
|
throw F("upgrade.commit", "upgrade", f), d.kind === "superseded" && d.adopted && L("adopted", "other-tab"), f;
|
|
3295
3331
|
}, We = (e) => {
|
|
3296
3332
|
if (L("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
|
|
@@ -3306,9 +3342,9 @@ function Qn(e) {
|
|
|
3306
3342
|
...t,
|
|
3307
3343
|
fp: t.fp
|
|
3308
3344
|
}));
|
|
3309
|
-
},
|
|
3345
|
+
}, Ke = () => {
|
|
3310
3346
|
let e = ie(u);
|
|
3311
|
-
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" });
|
|
3312
3348
|
};
|
|
3313
3349
|
return {
|
|
3314
3350
|
refresh: V,
|
|
@@ -3316,8 +3352,8 @@ function Qn(e) {
|
|
|
3316
3352
|
commitUpgrade: He,
|
|
3317
3353
|
signOut: async (e) => {
|
|
3318
3354
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3319
|
-
let t = T() +
|
|
3320
|
-
|
|
3355
|
+
let t = T() + Qt;
|
|
3356
|
+
Ke(), await Be(t - T()), Ke(), l.coordinated && !l.holding && await ze("logout", t - T());
|
|
3321
3357
|
try {
|
|
3322
3358
|
Ge(), await e(n.getTokens()?.refresh_token);
|
|
3323
3359
|
} finally {
|
|
@@ -3326,7 +3362,7 @@ function Qn(e) {
|
|
|
3326
3362
|
},
|
|
3327
3363
|
signOutNow: (e) => {
|
|
3328
3364
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3329
|
-
|
|
3365
|
+
Ke();
|
|
3330
3366
|
try {
|
|
3331
3367
|
Ge(), e(n.getTokens()?.refresh_token);
|
|
3332
3368
|
} finally {
|
|
@@ -3354,14 +3390,14 @@ function Qn(e) {
|
|
|
3354
3390
|
de(u), f = !0, d += 1, u = {
|
|
3355
3391
|
kind: "ended",
|
|
3356
3392
|
cause: "disposed"
|
|
3357
|
-
}, se(e, new
|
|
3393
|
+
}, se(e, new q(K.disposed)), C = void 0, N.stop(), l.dispose(), te?.(), ne?.();
|
|
3358
3394
|
}
|
|
3359
3395
|
};
|
|
3360
3396
|
}
|
|
3361
3397
|
// lib/store.ts
|
|
3362
3398
|
var Z = /* @__PURE__ */ function(e) {
|
|
3363
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;
|
|
3364
|
-
}({}),
|
|
3400
|
+
}({}), ir = class {
|
|
3365
3401
|
constructor() {
|
|
3366
3402
|
this.subscribers = /* @__PURE__ */ new Map();
|
|
3367
3403
|
}
|
|
@@ -3380,12 +3416,12 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3380
3416
|
n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
|
|
3381
3417
|
}
|
|
3382
3418
|
notify(e, t) {
|
|
3383
|
-
e === "error" &&
|
|
3419
|
+
e === "error" && zt(this, t?.originalError), this.subscribers.forEach((n, r) => {
|
|
3384
3420
|
(!n || n.has(e)) && r.onAuthChange?.(e, t);
|
|
3385
3421
|
});
|
|
3386
3422
|
}
|
|
3387
3423
|
notifyError(e) {
|
|
3388
|
-
return
|
|
3424
|
+
return U(this, e);
|
|
3389
3425
|
}
|
|
3390
3426
|
}, Q = {
|
|
3391
3427
|
twoFactorCodeInvalid: "error.api.request.2fa_code.invalid",
|
|
@@ -3401,18 +3437,18 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3401
3437
|
twoFactorNotEnabled: "error.2fa.not_enabled",
|
|
3402
3438
|
notImplemented: "error.not.implemented",
|
|
3403
3439
|
tokenInvalid: "error.api.request.token.invalid"
|
|
3404
|
-
},
|
|
3440
|
+
}, ar = Object.freeze([
|
|
3405
3441
|
Q.twoFactorCodeInvalid,
|
|
3406
3442
|
Q.twoFactorNotEnabled,
|
|
3407
3443
|
Q.challengeInvalid,
|
|
3408
3444
|
Q.challengeSessionMismatch,
|
|
3409
3445
|
Q.challengeTooManyAttempts
|
|
3410
|
-
]),
|
|
3446
|
+
]), or = Object.freeze([Q.tokenInvalid]), sr = Object.freeze([
|
|
3411
3447
|
"wrong_code",
|
|
3412
3448
|
"challenge_spent",
|
|
3413
3449
|
"not_registered",
|
|
3414
3450
|
"prepare_not_required"
|
|
3415
|
-
]),
|
|
3451
|
+
]), cr = (e) => sr.includes(e), lr = {
|
|
3416
3452
|
wrong_code: "That code was not accepted. Try again.",
|
|
3417
3453
|
challenge_spent: "That verification challenge is no longer valid. Start again.",
|
|
3418
3454
|
exhausted: "Too many attempts. Try again later.",
|
|
@@ -3426,16 +3462,16 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3426
3462
|
session_changed: "The session ended during verification."
|
|
3427
3463
|
}, $ = class extends Error {
|
|
3428
3464
|
constructor(e) {
|
|
3429
|
-
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);
|
|
3430
3466
|
}
|
|
3431
|
-
},
|
|
3467
|
+
}, ur = Object.freeze([
|
|
3432
3468
|
"upgrade_transport",
|
|
3433
3469
|
"upgrade_insufficient",
|
|
3434
3470
|
"upgrade_unavailable",
|
|
3435
3471
|
"upgrade_session_changed",
|
|
3436
3472
|
"upgrade_cancelled",
|
|
3437
3473
|
"upgrade_unsatisfiable"
|
|
3438
|
-
]),
|
|
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) => {
|
|
3439
3475
|
if (typeof e != "object" || !e) return {
|
|
3440
3476
|
hasResponse: !1,
|
|
3441
3477
|
message: typeof e == "string" ? e : void 0
|
|
@@ -3447,7 +3483,7 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3447
3483
|
message: typeof t.message == "string" ? t.message : void 0,
|
|
3448
3484
|
hasResponse: n !== void 0 || typeof t.status == "number"
|
|
3449
3485
|
};
|
|
3450
|
-
},
|
|
3486
|
+
}, mr = (e, t) => {
|
|
3451
3487
|
switch (e) {
|
|
3452
3488
|
case Q.twoFactorCodeInvalid: return "wrong_code";
|
|
3453
3489
|
case Q.challengeInvalid:
|
|
@@ -3464,11 +3500,11 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3464
3500
|
case Q.tokenInvalid: return t === "refresh" ? "session_changed" : "fatal";
|
|
3465
3501
|
default: return;
|
|
3466
3502
|
}
|
|
3467
|
-
},
|
|
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) => {
|
|
3468
3504
|
if (e instanceof $) return e;
|
|
3469
|
-
let n =
|
|
3505
|
+
let n = pr(e);
|
|
3470
3506
|
return n.hasResponse ? new $({
|
|
3471
|
-
kind:
|
|
3507
|
+
kind: mr(n.errorId, t) ?? hr(n.status, t),
|
|
3472
3508
|
message: n.message,
|
|
3473
3509
|
status: n.status,
|
|
3474
3510
|
errorId: n.errorId,
|
|
@@ -3478,60 +3514,60 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3478
3514
|
message: n.message,
|
|
3479
3515
|
cause: e
|
|
3480
3516
|
});
|
|
3481
|
-
},
|
|
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 {
|
|
3482
3518
|
constructor(e, t, n) {
|
|
3483
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;
|
|
3484
3520
|
}
|
|
3485
|
-
},
|
|
3521
|
+
}, br = class extends Error {
|
|
3486
3522
|
constructor(e = "Step-up verification is not available on this deployment") {
|
|
3487
3523
|
super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
|
|
3488
3524
|
}
|
|
3489
|
-
},
|
|
3525
|
+
}, xr = class extends Error {
|
|
3490
3526
|
constructor(e = "The session changed during verification") {
|
|
3491
3527
|
super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
|
|
3492
3528
|
}
|
|
3493
|
-
},
|
|
3529
|
+
}, Sr = (e) => {
|
|
3494
3530
|
if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
|
|
3495
3531
|
sub: e.sub,
|
|
3496
3532
|
sid: e.sid
|
|
3497
3533
|
} : { sub: e.sub };
|
|
3498
|
-
},
|
|
3534
|
+
}, Cr = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
|
|
3499
3535
|
// lib/utils/validation.ts
|
|
3500
|
-
function
|
|
3536
|
+
function wr(e) {
|
|
3501
3537
|
if (!e || typeof e != "string") return !1;
|
|
3502
3538
|
let t = e.split(".");
|
|
3503
3539
|
if (t.length !== 3) return !1;
|
|
3504
3540
|
let n = /^[A-Za-z0-9_-]+$/;
|
|
3505
3541
|
return t.every((e) => n.test(e) && e.length > 0);
|
|
3506
3542
|
}
|
|
3507
|
-
function
|
|
3543
|
+
function Tr(e) {
|
|
3508
3544
|
return e.replace(/<[^>]*>/g, "").substring(0, 200);
|
|
3509
3545
|
}
|
|
3510
|
-
function
|
|
3546
|
+
function Er(e) {
|
|
3511
3547
|
if (!e || typeof e != "string") return !1;
|
|
3512
3548
|
let t = e.trim();
|
|
3513
3549
|
return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
|
|
3514
3550
|
}
|
|
3515
|
-
function
|
|
3551
|
+
function Dr(e) {
|
|
3516
3552
|
if (!e || typeof e != "string") return !1;
|
|
3517
3553
|
let t = e.trim();
|
|
3518
3554
|
return /^\+[1-9]\d{1,14}$/.test(t);
|
|
3519
3555
|
}
|
|
3520
|
-
function
|
|
3556
|
+
function Or(e) {
|
|
3521
3557
|
if (!e || typeof e != "string") return !1;
|
|
3522
3558
|
let t = e.trim();
|
|
3523
3559
|
return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
|
|
3524
3560
|
}
|
|
3525
|
-
function
|
|
3561
|
+
function kr(e, t = 6) {
|
|
3526
3562
|
return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
|
|
3527
3563
|
}
|
|
3528
|
-
function
|
|
3564
|
+
function Ar(e) {
|
|
3529
3565
|
if (!e || typeof e != "string") return null;
|
|
3530
3566
|
let t = e.toUpperCase().replace(/\s+/g, "");
|
|
3531
3567
|
return /^[A-Z0-9-]{4,16}$/.test(t) ? t : null;
|
|
3532
3568
|
}
|
|
3533
3569
|
// lib/services/auth-service.ts
|
|
3534
|
-
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) => {
|
|
3535
3571
|
if (t?.aborted) {
|
|
3536
3572
|
r(t.reason);
|
|
3537
3573
|
return;
|
|
@@ -3542,21 +3578,21 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3542
3578
|
t?.removeEventListener("abort", i), n();
|
|
3543
3579
|
}, e);
|
|
3544
3580
|
t?.addEventListener("abort", i, { once: !0 });
|
|
3545
|
-
}),
|
|
3581
|
+
}), Vr = (e) => {
|
|
3546
3582
|
if (!e) return;
|
|
3547
3583
|
let t = new URLSearchParams(e.search).get("token");
|
|
3548
3584
|
if (t) return t;
|
|
3549
3585
|
let n = e.hash.indexOf("?");
|
|
3550
3586
|
return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
|
|
3551
|
-
},
|
|
3587
|
+
}, Hr = (e) => {
|
|
3552
3588
|
if (e) try {
|
|
3553
3589
|
return A(e).email;
|
|
3554
3590
|
} catch {
|
|
3555
3591
|
return;
|
|
3556
3592
|
}
|
|
3557
|
-
},
|
|
3558
|
-
constructor(e, t, n, r, i, a, o, s, c, l, u, d = P, f, p = { coordination:
|
|
3559
|
-
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new ne(n), u?.enabled && this.tokenDeliveryManager.setMode(M.BFF), this.refresh =
|
|
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({
|
|
3560
3596
|
emit: this.createRefreshEmit(),
|
|
3561
3597
|
storage: n,
|
|
3562
3598
|
cache: i,
|
|
@@ -3564,7 +3600,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3564
3600
|
coordination: p.coordination,
|
|
3565
3601
|
platform: d,
|
|
3566
3602
|
...p.strikes === void 0 ? {} : { strikes: p.strikes },
|
|
3567
|
-
logger:
|
|
3603
|
+
logger: En()
|
|
3568
3604
|
}), this.initializeSession();
|
|
3569
3605
|
}
|
|
3570
3606
|
async initializeSession() {
|
|
@@ -3619,7 +3655,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3619
3655
|
rememberEmailChallenge(e, t) {
|
|
3620
3656
|
this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
|
|
3621
3657
|
for (let e of this.emailChallenges.keys()) {
|
|
3622
|
-
if (this.emailChallenges.size <=
|
|
3658
|
+
if (this.emailChallenges.size <= Rr) break;
|
|
3623
3659
|
this.emailChallenges.delete(e);
|
|
3624
3660
|
}
|
|
3625
3661
|
}
|
|
@@ -3627,14 +3663,14 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3627
3663
|
if (this.pendingPkce = {
|
|
3628
3664
|
verifier: e,
|
|
3629
3665
|
scopes: t,
|
|
3630
|
-
expiresAt: Date.now() +
|
|
3666
|
+
expiresAt: Date.now() + Mr
|
|
3631
3667
|
}, typeof sessionStorage < "u") try {
|
|
3632
|
-
sessionStorage.setItem(
|
|
3668
|
+
sessionStorage.setItem(jr, JSON.stringify(this.pendingPkce));
|
|
3633
3669
|
} catch {}
|
|
3634
3670
|
}
|
|
3635
3671
|
readPendingPkce() {
|
|
3636
3672
|
if (!this.pendingPkce && typeof sessionStorage < "u") try {
|
|
3637
|
-
let e = sessionStorage.getItem(
|
|
3673
|
+
let e = sessionStorage.getItem(jr);
|
|
3638
3674
|
this.pendingPkce = e ? JSON.parse(e) : void 0;
|
|
3639
3675
|
} catch {
|
|
3640
3676
|
this.pendingPkce = void 0;
|
|
@@ -3646,17 +3682,17 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3646
3682
|
}
|
|
3647
3683
|
forgetPkceSignIn() {
|
|
3648
3684
|
if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
|
|
3649
|
-
sessionStorage.removeItem(
|
|
3685
|
+
sessionStorage.removeItem(jr);
|
|
3650
3686
|
} catch {}
|
|
3651
3687
|
}
|
|
3652
3688
|
rememberPendingPasswordless(e) {
|
|
3653
3689
|
if (this.pendingPasswordless = e, typeof sessionStorage < "u") try {
|
|
3654
|
-
sessionStorage.setItem(
|
|
3690
|
+
sessionStorage.setItem(Nr, JSON.stringify(e));
|
|
3655
3691
|
} catch {}
|
|
3656
3692
|
}
|
|
3657
3693
|
readPendingPasswordless() {
|
|
3658
3694
|
if (!this.pendingPasswordless && typeof sessionStorage < "u") try {
|
|
3659
|
-
let e = sessionStorage.getItem(
|
|
3695
|
+
let e = sessionStorage.getItem(Nr);
|
|
3660
3696
|
this.pendingPasswordless = e ? JSON.parse(e) : void 0;
|
|
3661
3697
|
} catch {
|
|
3662
3698
|
this.pendingPasswordless = void 0;
|
|
@@ -3665,21 +3701,21 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3665
3701
|
}
|
|
3666
3702
|
forgetPendingPasswordless() {
|
|
3667
3703
|
if (this.pendingPasswordless = void 0, typeof sessionStorage < "u") try {
|
|
3668
|
-
sessionStorage.removeItem(
|
|
3704
|
+
sessionStorage.removeItem(Nr);
|
|
3669
3705
|
} catch {}
|
|
3670
3706
|
}
|
|
3671
3707
|
rememberFederatedSlot(e, t) {
|
|
3672
3708
|
if (this.federatedSlot = {
|
|
3673
3709
|
verifier: e,
|
|
3674
3710
|
scopes: t,
|
|
3675
|
-
expiresAt: Date.now() +
|
|
3711
|
+
expiresAt: Date.now() + Ir
|
|
3676
3712
|
}, typeof sessionStorage < "u") try {
|
|
3677
|
-
sessionStorage.setItem(
|
|
3713
|
+
sessionStorage.setItem(Fr, JSON.stringify(this.federatedSlot));
|
|
3678
3714
|
} catch {}
|
|
3679
3715
|
}
|
|
3680
3716
|
readFederatedSlot() {
|
|
3681
3717
|
if (!this.federatedSlot && typeof sessionStorage < "u") try {
|
|
3682
|
-
let e = sessionStorage.getItem(
|
|
3718
|
+
let e = sessionStorage.getItem(Fr);
|
|
3683
3719
|
this.federatedSlot = e ? JSON.parse(e) : void 0;
|
|
3684
3720
|
} catch {
|
|
3685
3721
|
this.federatedSlot = void 0;
|
|
@@ -3688,7 +3724,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3688
3724
|
}
|
|
3689
3725
|
forgetFederatedSlot() {
|
|
3690
3726
|
if (this.federatedSlot = void 0, typeof sessionStorage < "u") try {
|
|
3691
|
-
sessionStorage.removeItem(
|
|
3727
|
+
sessionStorage.removeItem(Fr);
|
|
3692
3728
|
} catch {}
|
|
3693
3729
|
}
|
|
3694
3730
|
async startPkce() {
|
|
@@ -3696,17 +3732,17 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3696
3732
|
try {
|
|
3697
3733
|
e = await this.readPkceEnabled?.() ?? !1;
|
|
3698
3734
|
} catch (e) {
|
|
3699
|
-
|
|
3735
|
+
En().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
|
|
3700
3736
|
return;
|
|
3701
3737
|
}
|
|
3702
|
-
return e ?
|
|
3738
|
+
return e ? wn() : void 0;
|
|
3703
3739
|
}
|
|
3704
3740
|
async exchangeCode(e, t) {
|
|
3705
3741
|
return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
|
|
3706
3742
|
}
|
|
3707
3743
|
async completePkceSignIn(e) {
|
|
3708
3744
|
let t = this.readPendingPkce();
|
|
3709
|
-
if (!t) throw Error(
|
|
3745
|
+
if (!t) throw Error(zr);
|
|
3710
3746
|
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
3711
3747
|
return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
|
|
3712
3748
|
}
|
|
@@ -3730,32 +3766,32 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3730
3766
|
if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
|
|
3731
3767
|
}
|
|
3732
3768
|
async signIn(e) {
|
|
3733
|
-
if ("email" in e && e.email && !
|
|
3769
|
+
if ("email" in e && e.email && !Er(e.email)) {
|
|
3734
3770
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3735
3771
|
operation: "sign-in",
|
|
3736
3772
|
message: "Invalid email format",
|
|
3737
3773
|
originalError: e,
|
|
3738
3774
|
code: "VALIDATION_ERROR"
|
|
3739
3775
|
};
|
|
3740
|
-
throw
|
|
3776
|
+
throw U(this.subscribeStore, t), e;
|
|
3741
3777
|
}
|
|
3742
|
-
if ("username" in e && e.username && !
|
|
3778
|
+
if ("username" in e && e.username && !Or(e.username)) {
|
|
3743
3779
|
let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
|
|
3744
3780
|
operation: "sign-in",
|
|
3745
3781
|
message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
|
|
3746
3782
|
originalError: e,
|
|
3747
3783
|
code: "VALIDATION_ERROR"
|
|
3748
3784
|
};
|
|
3749
|
-
throw
|
|
3785
|
+
throw U(this.subscribeStore, t), e;
|
|
3750
3786
|
}
|
|
3751
|
-
if ("phone" in e && e.phone && !
|
|
3787
|
+
if ("phone" in e && e.phone && !Dr(e.phone)) {
|
|
3752
3788
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3753
3789
|
operation: "sign-in",
|
|
3754
3790
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3755
3791
|
originalError: e,
|
|
3756
3792
|
code: "VALIDATION_ERROR"
|
|
3757
3793
|
};
|
|
3758
|
-
throw
|
|
3794
|
+
throw U(this.subscribeStore, t), e;
|
|
3759
3795
|
}
|
|
3760
3796
|
this.subscribeStore.notify(Z.SignInStart, { email: e.email });
|
|
3761
3797
|
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
@@ -3778,27 +3814,27 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3778
3814
|
originalError: e,
|
|
3779
3815
|
code: e instanceof B ? e.id : void 0
|
|
3780
3816
|
};
|
|
3781
|
-
throw
|
|
3817
|
+
throw U(this.subscribeStore, t), e;
|
|
3782
3818
|
}
|
|
3783
3819
|
}
|
|
3784
3820
|
async signUp(e) {
|
|
3785
|
-
if (e.user.email && !
|
|
3821
|
+
if (e.user.email && !Er(e.user.email)) {
|
|
3786
3822
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3787
3823
|
operation: "sign-up",
|
|
3788
3824
|
message: "Invalid email format",
|
|
3789
3825
|
originalError: e,
|
|
3790
3826
|
code: "VALIDATION_ERROR"
|
|
3791
3827
|
};
|
|
3792
|
-
throw
|
|
3828
|
+
throw U(this.subscribeStore, t), e;
|
|
3793
3829
|
}
|
|
3794
|
-
if (e.user.phone_number && !
|
|
3830
|
+
if (e.user.phone_number && !Dr(e.user.phone_number)) {
|
|
3795
3831
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3796
3832
|
operation: "sign-up",
|
|
3797
3833
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3798
3834
|
originalError: e,
|
|
3799
3835
|
code: "VALIDATION_ERROR"
|
|
3800
3836
|
};
|
|
3801
|
-
throw
|
|
3837
|
+
throw U(this.subscribeStore, t), e;
|
|
3802
3838
|
}
|
|
3803
3839
|
this.subscribeStore.notify(Z.RegisterStart, { email: e.user.email }), e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
3804
3840
|
try {
|
|
@@ -3819,27 +3855,27 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3819
3855
|
originalError: e,
|
|
3820
3856
|
code: e instanceof B ? e.id : void 0
|
|
3821
3857
|
};
|
|
3822
|
-
throw
|
|
3858
|
+
throw U(this.subscribeStore, t), e;
|
|
3823
3859
|
}
|
|
3824
3860
|
}
|
|
3825
3861
|
async passwordlessSignIn(e) {
|
|
3826
|
-
if (e.email && !
|
|
3862
|
+
if (e.email && !Er(e.email)) {
|
|
3827
3863
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3828
3864
|
operation: "passwordless.start",
|
|
3829
3865
|
message: "Invalid email format",
|
|
3830
3866
|
originalError: e,
|
|
3831
3867
|
code: "VALIDATION_ERROR"
|
|
3832
3868
|
};
|
|
3833
|
-
throw
|
|
3869
|
+
throw U(this.subscribeStore, t), e;
|
|
3834
3870
|
}
|
|
3835
|
-
if (e.phone && !
|
|
3871
|
+
if (e.phone && !Dr(e.phone)) {
|
|
3836
3872
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3837
3873
|
operation: "passwordless.start",
|
|
3838
3874
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3839
3875
|
originalError: e,
|
|
3840
3876
|
code: "VALIDATION_ERROR"
|
|
3841
3877
|
};
|
|
3842
|
-
throw
|
|
3878
|
+
throw U(this.subscribeStore, t), e;
|
|
3843
3879
|
}
|
|
3844
3880
|
this.subscribeStore.notify(Z.SignInStart, { email: e.email });
|
|
3845
3881
|
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId(), r = Le(this.platform.getDeviceType());
|
|
@@ -3865,7 +3901,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3865
3901
|
originalError: e,
|
|
3866
3902
|
code: e instanceof B ? e.id : void 0
|
|
3867
3903
|
};
|
|
3868
|
-
throw
|
|
3904
|
+
throw U(this.subscribeStore, t), e;
|
|
3869
3905
|
}
|
|
3870
3906
|
}
|
|
3871
3907
|
async passwordlessSignInComplete(e) {
|
|
@@ -3876,7 +3912,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3876
3912
|
if (r = !0, this.handlePendingSecondFactor(t, n?.email, n && { verifier: n.verifier }, n?.scopes)) return this.forgetPendingPasswordless(), t;
|
|
3877
3913
|
let i = t;
|
|
3878
3914
|
if (t.code) {
|
|
3879
|
-
if (!n) throw Error(
|
|
3915
|
+
if (!n) throw Error(zr);
|
|
3880
3916
|
if (i = await this.authApi.pkceExchange(t.code, n.verifier), this.handlePendingSecondFactor(i)) return this.forgetPendingPasswordless(), {
|
|
3881
3917
|
...i,
|
|
3882
3918
|
redirect_url: t.redirect_url ?? ""
|
|
@@ -3901,18 +3937,18 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3901
3937
|
originalError: e,
|
|
3902
3938
|
code: e instanceof B ? e.id : void 0
|
|
3903
3939
|
};
|
|
3904
|
-
throw
|
|
3940
|
+
throw U(this.subscribeStore, t), e;
|
|
3905
3941
|
}
|
|
3906
3942
|
}
|
|
3907
3943
|
async waitForPasswordlessSignIn(e, t) {
|
|
3908
3944
|
let n = t?.signal;
|
|
3909
3945
|
try {
|
|
3910
3946
|
let t = this.readPendingPasswordless();
|
|
3911
|
-
if (t?.challengeId !== e) throw Error(
|
|
3947
|
+
if (t?.challengeId !== e) throw Error(zr);
|
|
3912
3948
|
for (;;) {
|
|
3913
3949
|
if (n?.aborted) throw n.reason;
|
|
3914
3950
|
if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
|
|
3915
|
-
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(
|
|
3951
|
+
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(zr);
|
|
3916
3952
|
let r;
|
|
3917
3953
|
try {
|
|
3918
3954
|
r = await this.authApi.passwordlessStatus({
|
|
@@ -3925,7 +3961,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3925
3961
|
}
|
|
3926
3962
|
if (r?.status === "denied" || r?.status === "expired" || r?.status === "completed") return this.forgetPendingPasswordless(), { status: r.status };
|
|
3927
3963
|
if (r?.status === "approved" && r.code) return await this.finishApprovedPasswordless(r.code, t);
|
|
3928
|
-
await
|
|
3964
|
+
await Br(Pr, n);
|
|
3929
3965
|
}
|
|
3930
3966
|
} catch (e) {
|
|
3931
3967
|
if (n?.aborted && e === n.reason) throw e;
|
|
@@ -3935,7 +3971,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3935
3971
|
originalError: e,
|
|
3936
3972
|
code: e instanceof B ? e.id : void 0
|
|
3937
3973
|
};
|
|
3938
|
-
throw
|
|
3974
|
+
throw U(this.subscribeStore, t), e;
|
|
3939
3975
|
}
|
|
3940
3976
|
}
|
|
3941
3977
|
async finishApprovedPasswordless(e, t) {
|
|
@@ -3985,20 +4021,20 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
3985
4021
|
originalError: e,
|
|
3986
4022
|
code: e instanceof B ? e.id : void 0
|
|
3987
4023
|
};
|
|
3988
|
-
|
|
4024
|
+
U(this.subscribeStore, t);
|
|
3989
4025
|
}
|
|
3990
4026
|
async verifyEmailCode(e) {
|
|
3991
4027
|
let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
|
|
3992
4028
|
try {
|
|
3993
4029
|
let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
|
|
3994
|
-
if (t?.pkce && !r) throw Error(
|
|
4030
|
+
if (t?.pkce && !r) throw Error(zr);
|
|
3995
4031
|
let i = await this.authApi.validateEmailCode(e);
|
|
3996
4032
|
this.emailChallenges.delete(e.challenge_id);
|
|
3997
4033
|
let a = r?.scopes ?? t?.scopes ?? this.scopes;
|
|
3998
4034
|
if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
|
|
3999
4035
|
let o = i;
|
|
4000
4036
|
if (i.code) {
|
|
4001
|
-
if (!r) throw Error(
|
|
4037
|
+
if (!r) throw Error(zr);
|
|
4002
4038
|
if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
|
|
4003
4039
|
}
|
|
4004
4040
|
let s = i.redirect_url ? {
|
|
@@ -4016,7 +4052,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4016
4052
|
originalError: e,
|
|
4017
4053
|
code: e instanceof B ? e.id : void 0
|
|
4018
4054
|
};
|
|
4019
|
-
throw
|
|
4055
|
+
throw U(this.subscribeStore, t), e;
|
|
4020
4056
|
}
|
|
4021
4057
|
}
|
|
4022
4058
|
async logOut() {
|
|
@@ -4052,13 +4088,13 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4052
4088
|
readSessionPin() {
|
|
4053
4089
|
try {
|
|
4054
4090
|
let e = this.storageManager.getToken(j.access_token);
|
|
4055
|
-
return e ?
|
|
4091
|
+
return e ? Sr(A(e)) : void 0;
|
|
4056
4092
|
} catch {
|
|
4057
4093
|
return;
|
|
4058
4094
|
}
|
|
4059
4095
|
}
|
|
4060
4096
|
assertSessionPin(e) {
|
|
4061
|
-
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");
|
|
4062
4098
|
}
|
|
4063
4099
|
refreshMode() {
|
|
4064
4100
|
return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
|
|
@@ -4086,7 +4122,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4086
4122
|
return;
|
|
4087
4123
|
}
|
|
4088
4124
|
case "error":
|
|
4089
|
-
|
|
4125
|
+
U(n, t);
|
|
4090
4126
|
return;
|
|
4091
4127
|
case "refresh:start":
|
|
4092
4128
|
n.notify(Z.RefreshStart, {});
|
|
@@ -4106,7 +4142,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4106
4142
|
case "signout":
|
|
4107
4143
|
n.notify(Z.SignOut, t);
|
|
4108
4144
|
return;
|
|
4109
|
-
default:
|
|
4145
|
+
default: En().warn(`[passflow] Unknown refresh event: ${String(e)}`);
|
|
4110
4146
|
}
|
|
4111
4147
|
};
|
|
4112
4148
|
}
|
|
@@ -4164,7 +4200,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4164
4200
|
let e = this.storageManager.getTokens();
|
|
4165
4201
|
if (!e?.refresh_token) {
|
|
4166
4202
|
let t = /* @__PURE__ */ Error(e ? "No refresh token found" : "No tokens found");
|
|
4167
|
-
throw
|
|
4203
|
+
throw U(this.subscribeStore, {
|
|
4168
4204
|
operation: "refresh",
|
|
4169
4205
|
source: "refresh-token",
|
|
4170
4206
|
message: t.message,
|
|
@@ -4187,15 +4223,15 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4187
4223
|
originalError: e,
|
|
4188
4224
|
code: e instanceof B ? e.id : void 0
|
|
4189
4225
|
};
|
|
4190
|
-
throw
|
|
4226
|
+
throw U(this.subscribeStore, t), e;
|
|
4191
4227
|
}
|
|
4192
4228
|
}
|
|
4193
4229
|
async resetPassword(e, t, n) {
|
|
4194
4230
|
this.subscribeStore.notify(Z.SignInStart, {});
|
|
4195
|
-
let r = n ??
|
|
4231
|
+
let r = n ?? Vr(this.platform.getCurrentUrl()), i = t ?? this.scopes;
|
|
4196
4232
|
try {
|
|
4197
4233
|
let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
|
|
4198
|
-
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;
|
|
4199
4235
|
let a = await this.exchangeCode(n, t);
|
|
4200
4236
|
if (this.handlePendingSecondFactor(a)) return a;
|
|
4201
4237
|
let o = n.redirect_url ? {
|
|
@@ -4213,7 +4249,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4213
4249
|
originalError: e,
|
|
4214
4250
|
code: e instanceof B ? e.id : void 0
|
|
4215
4251
|
};
|
|
4216
|
-
throw
|
|
4252
|
+
throw U(this.subscribeStore, t), e;
|
|
4217
4253
|
}
|
|
4218
4254
|
}
|
|
4219
4255
|
async passkeyRegister(e) {
|
|
@@ -4243,7 +4279,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4243
4279
|
originalError: e,
|
|
4244
4280
|
code: e instanceof B ? e.id : void 0
|
|
4245
4281
|
};
|
|
4246
|
-
throw
|
|
4282
|
+
throw U(this.subscribeStore, t), e;
|
|
4247
4283
|
}
|
|
4248
4284
|
}
|
|
4249
4285
|
async passkeyAuthenticate(e) {
|
|
@@ -4271,12 +4307,12 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4271
4307
|
originalError: e,
|
|
4272
4308
|
code: e instanceof B ? e.id : void 0
|
|
4273
4309
|
};
|
|
4274
|
-
throw
|
|
4310
|
+
throw U(this.subscribeStore, t), e;
|
|
4275
4311
|
}
|
|
4276
4312
|
}
|
|
4277
4313
|
createFederatedAuthUrl(e) {
|
|
4278
4314
|
let t = `/auth/federated/start/${e.provider}`;
|
|
4279
|
-
if (!this.appId) throw Error(
|
|
4315
|
+
if (!this.appId) throw Error(Lr);
|
|
4280
4316
|
let n = {
|
|
4281
4317
|
scopes: (e.scopes ?? this.scopes).join(" "),
|
|
4282
4318
|
redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
|
|
@@ -4290,7 +4326,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4290
4326
|
return r.search = new URLSearchParams(n).toString(), r.toString();
|
|
4291
4327
|
}
|
|
4292
4328
|
async federatedAuthWithPopup(e) {
|
|
4293
|
-
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(
|
|
4329
|
+
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(Lr);
|
|
4294
4330
|
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
|
|
4295
4331
|
try {
|
|
4296
4332
|
this.forgetFederatedSlot();
|
|
@@ -4330,11 +4366,11 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4330
4366
|
code: e instanceof ie ? "POPUP_CLOSED" : "AUTH_FAILED",
|
|
4331
4367
|
originalError: e
|
|
4332
4368
|
};
|
|
4333
|
-
|
|
4369
|
+
U(this.subscribeStore, t);
|
|
4334
4370
|
}
|
|
4335
4371
|
}
|
|
4336
4372
|
federatedAuthWithRedirect(e) {
|
|
4337
|
-
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(
|
|
4373
|
+
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(Lr);
|
|
4338
4374
|
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
|
|
4339
4375
|
this.startPkce().then((r) => {
|
|
4340
4376
|
let i = this.createFederatedAuthUrl({
|
|
@@ -4374,7 +4410,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4374
4410
|
originalError: e,
|
|
4375
4411
|
code: e instanceof B ? e.id : void 0
|
|
4376
4412
|
};
|
|
4377
|
-
|
|
4413
|
+
U(this.subscribeStore, t);
|
|
4378
4414
|
}
|
|
4379
4415
|
authRedirectUrl(e = {}) {
|
|
4380
4416
|
try {
|
|
@@ -4392,7 +4428,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4392
4428
|
message: e instanceof Error ? e.message : "Failed to create auth redirect URL",
|
|
4393
4429
|
originalError: e
|
|
4394
4430
|
};
|
|
4395
|
-
throw
|
|
4431
|
+
throw U(this.subscribeStore, t), e;
|
|
4396
4432
|
}
|
|
4397
4433
|
}
|
|
4398
4434
|
authRedirect(e = {}) {
|
|
@@ -4404,7 +4440,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4404
4440
|
message: e instanceof Error ? e.message : "Failed to redirect to auth page",
|
|
4405
4441
|
originalError: e
|
|
4406
4442
|
};
|
|
4407
|
-
throw
|
|
4443
|
+
throw U(this.subscribeStore, t), e;
|
|
4408
4444
|
}
|
|
4409
4445
|
}
|
|
4410
4446
|
isAuthenticated(e) {
|
|
@@ -4420,7 +4456,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4420
4456
|
message: e instanceof Error ? e.message : "Failed to check authentication status",
|
|
4421
4457
|
originalError: e
|
|
4422
4458
|
};
|
|
4423
|
-
return
|
|
4459
|
+
return U(this.subscribeStore, t), !1;
|
|
4424
4460
|
}
|
|
4425
4461
|
}
|
|
4426
4462
|
async submitSessionCheck(e = !1) {
|
|
@@ -4433,7 +4469,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4433
4469
|
message: e instanceof Error || e instanceof B ? e.message : "Session check failed",
|
|
4434
4470
|
originalError: e
|
|
4435
4471
|
};
|
|
4436
|
-
|
|
4472
|
+
U(this.subscribeStore, n), t = void 0;
|
|
4437
4473
|
}
|
|
4438
4474
|
return t && this.sessionCallbacks.createSession && await this.sessionCallbacks.createSession({
|
|
4439
4475
|
tokens: t,
|
|
@@ -4460,11 +4496,11 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4460
4496
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4461
4497
|
originalError: e
|
|
4462
4498
|
};
|
|
4463
|
-
|
|
4499
|
+
U(this.subscribeStore, t);
|
|
4464
4500
|
return;
|
|
4465
4501
|
}
|
|
4466
4502
|
}
|
|
4467
|
-
},
|
|
4503
|
+
}, Wr = class {
|
|
4468
4504
|
constructor(e) {
|
|
4469
4505
|
this.invitationApi = e;
|
|
4470
4506
|
}
|
|
@@ -4483,7 +4519,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4483
4519
|
getInvitationLink(e) {
|
|
4484
4520
|
return this.invitationApi.getInvitationLink(e);
|
|
4485
4521
|
}
|
|
4486
|
-
},
|
|
4522
|
+
}, Gr = class {
|
|
4487
4523
|
constructor(e) {
|
|
4488
4524
|
this.data = this.normalize(e);
|
|
4489
4525
|
}
|
|
@@ -4540,9 +4576,9 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4540
4576
|
getData() {
|
|
4541
4577
|
return this.data;
|
|
4542
4578
|
}
|
|
4543
|
-
},
|
|
4579
|
+
}, Kr = class {
|
|
4544
4580
|
constructor(e, t, n) {
|
|
4545
|
-
this.tenantApi = e, this.scopes = t, this.logger = n ||
|
|
4581
|
+
this.tenantApi = e, this.scopes = t, this.logger = n || En();
|
|
4546
4582
|
}
|
|
4547
4583
|
handlePassflowError(t, n) {
|
|
4548
4584
|
if (e.isAxiosError(t) && t.response?.data) {
|
|
@@ -4578,7 +4614,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4578
4614
|
}
|
|
4579
4615
|
async getTenantUserMembership(e) {
|
|
4580
4616
|
try {
|
|
4581
|
-
return new
|
|
4617
|
+
return new Gr(await this.tenantApi.getTenantDetails(e));
|
|
4582
4618
|
} catch (t) {
|
|
4583
4619
|
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
4584
4620
|
}
|
|
@@ -4723,7 +4759,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4723
4759
|
this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
|
|
4724
4760
|
}
|
|
4725
4761
|
}
|
|
4726
|
-
},
|
|
4762
|
+
}, qr = class {
|
|
4727
4763
|
constructor(e, t, n, r = P) {
|
|
4728
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();
|
|
4729
4765
|
}
|
|
@@ -4748,7 +4784,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4748
4784
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4749
4785
|
originalError: e
|
|
4750
4786
|
};
|
|
4751
|
-
|
|
4787
|
+
U(this.subscribeStore, t), this.setTokensCache(void 0);
|
|
4752
4788
|
}
|
|
4753
4789
|
}
|
|
4754
4790
|
startTokenCheck() {
|
|
@@ -4793,7 +4829,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4793
4829
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4794
4830
|
originalError: e
|
|
4795
4831
|
};
|
|
4796
|
-
|
|
4832
|
+
U(this.subscribeStore, t);
|
|
4797
4833
|
return;
|
|
4798
4834
|
}
|
|
4799
4835
|
}
|
|
@@ -4803,14 +4839,14 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4803
4839
|
isExpired() {
|
|
4804
4840
|
return this.tokensCache ? this.tokensCache.access_token ? k(A(this.tokensCache.access_token)) : !1 : !0;
|
|
4805
4841
|
}
|
|
4806
|
-
},
|
|
4842
|
+
}, Jr = class {
|
|
4807
4843
|
constructor(e, t, n) {
|
|
4808
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) => {
|
|
4809
4845
|
if (e === Z.TwoFactorRequired) {
|
|
4810
4846
|
let e = t;
|
|
4811
4847
|
this.setPartialAuthState(e.email, e.challengeId, e.tfaToken);
|
|
4812
4848
|
}
|
|
4813
|
-
(e === Z.SignIn || e === Z.Register) && this.clearPartialAuthState();
|
|
4849
|
+
(e === Z.SignIn || e === Z.Register) && (this.clearPartialAuthState(), this.clearMagicLinkSession());
|
|
4814
4850
|
} }, [
|
|
4815
4851
|
Z.TwoFactorRequired,
|
|
4816
4852
|
Z.SignIn,
|
|
@@ -4824,11 +4860,11 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4824
4860
|
originalError: e,
|
|
4825
4861
|
code: r?.id || void 0
|
|
4826
4862
|
};
|
|
4827
|
-
throw
|
|
4863
|
+
throw U(this.subscribeStore, i), e;
|
|
4828
4864
|
}
|
|
4829
4865
|
async getStatus() {
|
|
4830
4866
|
try {
|
|
4831
|
-
let e = await this.twoFactorApi.getStatus();
|
|
4867
|
+
let e = await this.twoFactorApi.getStatus(this.getMagicLinkSessionToken() ?? void 0);
|
|
4832
4868
|
return e.totp_digits && (this.totpDigits = e.totp_digits), e;
|
|
4833
4869
|
} catch (e) {
|
|
4834
4870
|
this.emitErrorAndThrow(e, "2fa.status", "Get 2FA status");
|
|
@@ -4836,28 +4872,70 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4836
4872
|
}
|
|
4837
4873
|
async beginSetup() {
|
|
4838
4874
|
try {
|
|
4839
|
-
|
|
4840
|
-
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));
|
|
4841
4876
|
} catch (e) {
|
|
4842
4877
|
this.emitErrorAndThrow(e, "2fa.setup.begin", "Begin 2FA setup");
|
|
4843
4878
|
}
|
|
4844
4879
|
}
|
|
4845
4880
|
async confirmSetup(e) {
|
|
4846
|
-
|
|
4881
|
+
this.assertTotpCode(e);
|
|
4847
4882
|
try {
|
|
4848
|
-
let t = await this.twoFactorApi.confirmSetup({ code: e });
|
|
4849
|
-
return this.
|
|
4850
|
-
recoveryCodes: t.recovery_codes,
|
|
4851
|
-
clearRecoveryCodes: () => {
|
|
4852
|
-
t.recovery_codes.length = 0;
|
|
4853
|
-
}
|
|
4854
|
-
}), t;
|
|
4883
|
+
let t = await this.twoFactorApi.confirmSetup({ code: e }, this.getMagicLinkSessionToken() ?? void 0);
|
|
4884
|
+
return this.clearMagicLinkSession(), this.setupConfirmed(t);
|
|
4855
4885
|
} catch (e) {
|
|
4856
4886
|
this.emitErrorAndThrow(e, "2fa.setup.confirm", "Confirm 2FA setup");
|
|
4857
4887
|
}
|
|
4858
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
|
+
}
|
|
4859
4937
|
async verify(e, t) {
|
|
4860
|
-
if (!
|
|
4938
|
+
if (!kr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4861
4939
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4862
4940
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
4863
4941
|
try {
|
|
@@ -4873,7 +4951,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4873
4951
|
}
|
|
4874
4952
|
async useRecoveryCode(e, t) {
|
|
4875
4953
|
try {
|
|
4876
|
-
let n =
|
|
4954
|
+
let n = Ar(e);
|
|
4877
4955
|
if (!n) throw Error("Invalid recovery code format. Expected format: XXXX-XXXX or XXXXXXXX (alphanumeric).");
|
|
4878
4956
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4879
4957
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
@@ -4894,7 +4972,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4894
4972
|
}
|
|
4895
4973
|
}
|
|
4896
4974
|
async disable(e) {
|
|
4897
|
-
if (!
|
|
4975
|
+
if (!kr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4898
4976
|
try {
|
|
4899
4977
|
let t = await this.twoFactorApi.disable({ code: e });
|
|
4900
4978
|
return this.subscribeStore.notify(Z.TwoFactorDisabled, {}), t;
|
|
@@ -4903,7 +4981,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
4903
4981
|
}
|
|
4904
4982
|
}
|
|
4905
4983
|
async regenerateRecoveryCodes(e) {
|
|
4906
|
-
if (!
|
|
4984
|
+
if (!kr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4907
4985
|
try {
|
|
4908
4986
|
let t = await this.twoFactorApi.regenerateRecoveryCodes({ code: e }), n = [...t.recovery_codes];
|
|
4909
4987
|
return t.recovery_codes = [], t.recovery_codes = n, t;
|
|
@@ -5087,7 +5165,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5087
5165
|
this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
|
|
5088
5166
|
}
|
|
5089
5167
|
}
|
|
5090
|
-
},
|
|
5168
|
+
}, Yr = class {
|
|
5091
5169
|
constructor(e, t, n = P) {
|
|
5092
5170
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
5093
5171
|
}
|
|
@@ -5114,69 +5192,69 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5114
5192
|
if (!s) throw Error("Passkey registration was not completed");
|
|
5115
5193
|
return await this.userAPI.addUserPasskeyComplete(s, r, a);
|
|
5116
5194
|
}
|
|
5117
|
-
},
|
|
5195
|
+
}, Xr = class extends Error {
|
|
5118
5196
|
constructor(e, t, n = !1) {
|
|
5119
5197
|
super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
|
|
5120
5198
|
}
|
|
5121
|
-
},
|
|
5199
|
+
}, Zr = (e, t) => {
|
|
5122
5200
|
let n = t?.trim();
|
|
5123
|
-
if (!n) throw new
|
|
5201
|
+
if (!n) throw new Xr(e, "A verification code is required");
|
|
5124
5202
|
return n;
|
|
5125
|
-
},
|
|
5203
|
+
}, Qr = {
|
|
5126
5204
|
type: "totp",
|
|
5127
5205
|
requiresPrepare: !1,
|
|
5128
5206
|
input: "code",
|
|
5129
|
-
assert: async ({ code: e }) => ({ code:
|
|
5130
|
-
},
|
|
5207
|
+
assert: async ({ code: e }) => ({ code: Zr("totp", e) })
|
|
5208
|
+
}, $r = {
|
|
5131
5209
|
type: "recovery_codes",
|
|
5132
5210
|
requiresPrepare: !1,
|
|
5133
5211
|
input: "code",
|
|
5134
|
-
assert: async ({ code: e }) => ({ code:
|
|
5135
|
-
},
|
|
5212
|
+
assert: async ({ code: e }) => ({ code: Zr("recovery_codes", e) })
|
|
5213
|
+
}, ei = {
|
|
5136
5214
|
type: "passkey",
|
|
5137
5215
|
requiresPrepare: !0,
|
|
5138
5216
|
input: "none",
|
|
5139
5217
|
assert: async ({ prepared: e, platform: t }) => {
|
|
5140
|
-
if (!e?.webauthn) throw new
|
|
5218
|
+
if (!e?.webauthn) throw new Xr("passkey", "The upgrade challenge carried no WebAuthn options");
|
|
5141
5219
|
let n = t.passkeys;
|
|
5142
|
-
if (!n) throw new
|
|
5220
|
+
if (!n) throw new Xr("passkey", "This platform does not support passkeys");
|
|
5143
5221
|
let r;
|
|
5144
5222
|
try {
|
|
5145
5223
|
r = await n.startAuthentication(e.webauthn);
|
|
5146
5224
|
} catch (e) {
|
|
5147
|
-
throw new
|
|
5225
|
+
throw new Xr("passkey", e?.message || "Passkey verification was cancelled", !0);
|
|
5148
5226
|
}
|
|
5149
|
-
if (!r) throw new
|
|
5227
|
+
if (!r) throw new Xr("passkey", "Passkey verification was cancelled", !0);
|
|
5150
5228
|
return {
|
|
5151
5229
|
challenge_id: e.challengeId,
|
|
5152
5230
|
credential: r
|
|
5153
5231
|
};
|
|
5154
5232
|
}
|
|
5155
|
-
},
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
]),
|
|
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 = {
|
|
5160
5238
|
passkey: 0,
|
|
5161
5239
|
totp: 1,
|
|
5162
5240
|
email_otp: 2,
|
|
5163
5241
|
sms_otp: 3,
|
|
5164
5242
|
recovery_codes: 9
|
|
5165
|
-
},
|
|
5166
|
-
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";
|
|
5167
5245
|
return (r && !i ? 100 : 0) + n;
|
|
5168
|
-
},
|
|
5169
|
-
let n =
|
|
5170
|
-
return [...e].sort((e, t) =>
|
|
5171
|
-
},
|
|
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 {
|
|
5172
5250
|
constructor(e) {
|
|
5173
5251
|
super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
|
|
5174
5252
|
}
|
|
5175
|
-
},
|
|
5253
|
+
}, li = class extends Error {
|
|
5176
5254
|
constructor(e = "No available authentication factor can satisfy this challenge") {
|
|
5177
5255
|
super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
|
|
5178
5256
|
}
|
|
5179
|
-
},
|
|
5257
|
+
}, ui = 4, di = 3e4, fi = () => {
|
|
5180
5258
|
let e = () => void 0, t = () => void 0;
|
|
5181
5259
|
return {
|
|
5182
5260
|
promise: new Promise((n, r) => {
|
|
@@ -5185,11 +5263,11 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5185
5263
|
resolve: e,
|
|
5186
5264
|
reject: t
|
|
5187
5265
|
};
|
|
5188
|
-
},
|
|
5266
|
+
}, pi = (e) => ({
|
|
5189
5267
|
acrValues: e.acrValues,
|
|
5190
5268
|
level: e.requiredLevel,
|
|
5191
5269
|
maxAge: e.maxAge
|
|
5192
|
-
}),
|
|
5270
|
+
}), mi = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, hi = (e, t) => {
|
|
5193
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 ?? []]));
|
|
5194
5272
|
return {
|
|
5195
5273
|
acrValues: r,
|
|
@@ -5198,12 +5276,12 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5198
5276
|
status: e.status,
|
|
5199
5277
|
...a.length > 0 ? { channels: a } : {}
|
|
5200
5278
|
};
|
|
5201
|
-
},
|
|
5279
|
+
}, gi = (e, t) => {
|
|
5202
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);
|
|
5203
5281
|
return n || r;
|
|
5204
|
-
},
|
|
5282
|
+
}, _i = class {
|
|
5205
5283
|
constructor(e) {
|
|
5206
|
-
this.state = "idle", this.inFlight = null, this.requirement = null, this.selected = null, this.rankedRequirement = null, this.registrations = [], this.proof = null, this.pruned = /* @__PURE__ */ new Set(), this.openPrompt = null, this.transport = e.transport, this.prompt = e.prompt, this.platform = e.platform, this.available = e.factors ??
|
|
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;
|
|
5207
5285
|
}
|
|
5208
5286
|
get currentState() {
|
|
5209
5287
|
return this.state;
|
|
@@ -5223,9 +5301,9 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5223
5301
|
}
|
|
5224
5302
|
register(e, t) {
|
|
5225
5303
|
let n = t.kind === "imperative" && t.requested !== void 0, r = {
|
|
5226
|
-
demanded: t.kind === "imperative" && t.requested ? t.requested :
|
|
5304
|
+
demanded: t.kind === "imperative" && t.requested ? t.requested : pi(e),
|
|
5227
5305
|
statedBar: n,
|
|
5228
|
-
settlement:
|
|
5306
|
+
settlement: fi(),
|
|
5229
5307
|
reported: !1,
|
|
5230
5308
|
entry: {
|
|
5231
5309
|
...t,
|
|
@@ -5241,15 +5319,15 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5241
5319
|
this.requirement = e;
|
|
5242
5320
|
return;
|
|
5243
5321
|
}
|
|
5244
|
-
let n =
|
|
5245
|
-
this.requirement =
|
|
5322
|
+
let n = gi(t, e);
|
|
5323
|
+
this.requirement = hi(t, e), n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
|
|
5246
5324
|
challenge: this.requirement,
|
|
5247
5325
|
factors: this.offeredFactors()
|
|
5248
5326
|
});
|
|
5249
5327
|
}
|
|
5250
5328
|
offeredFactors() {
|
|
5251
5329
|
let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
|
|
5252
|
-
return t ?
|
|
5330
|
+
return t ? si(e, t) : e;
|
|
5253
5331
|
}
|
|
5254
5332
|
receiveReport(e, t) {
|
|
5255
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());
|
|
@@ -5284,12 +5362,12 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5284
5362
|
}
|
|
5285
5363
|
release(e, t) {
|
|
5286
5364
|
if (e.entry.kind === "imperative") {
|
|
5287
|
-
if (e.statedBar && !
|
|
5365
|
+
if (e.statedBar && !mi(t, e.demanded)) {
|
|
5288
5366
|
this.receiveReport(e, {
|
|
5289
5367
|
outcome: "insufficient",
|
|
5290
5368
|
obtained: t,
|
|
5291
5369
|
required: e.demanded
|
|
5292
|
-
}), e.settlement.reject(new
|
|
5370
|
+
}), e.settlement.reject(new yr(t, e.demanded));
|
|
5293
5371
|
return;
|
|
5294
5372
|
}
|
|
5295
5373
|
this.receiveReport(e, {
|
|
@@ -5362,7 +5440,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5362
5440
|
let t = this.offeredFactors();
|
|
5363
5441
|
if (t.length === 0) return {
|
|
5364
5442
|
status: "failed",
|
|
5365
|
-
reason: new
|
|
5443
|
+
reason: new li()
|
|
5366
5444
|
};
|
|
5367
5445
|
let n = this.requirement, r;
|
|
5368
5446
|
try {
|
|
@@ -5370,24 +5448,24 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5370
5448
|
} catch (e) {
|
|
5371
5449
|
return {
|
|
5372
5450
|
status: "failed",
|
|
5373
|
-
reason: new
|
|
5451
|
+
reason: new ci(e)
|
|
5374
5452
|
};
|
|
5375
5453
|
}
|
|
5376
5454
|
if (r.type === "cancel") return {
|
|
5377
5455
|
status: "failed",
|
|
5378
|
-
reason: new
|
|
5456
|
+
reason: new ci()
|
|
5379
5457
|
};
|
|
5380
5458
|
let i = this.registry.get(r.factor);
|
|
5381
|
-
if (!i) e = new
|
|
5459
|
+
if (!i) e = new li(`Unknown authentication factor: ${r.factor}`), this.state = "collecting", this.selected = null;
|
|
5382
5460
|
else try {
|
|
5383
5461
|
return await this.proveAndCommit(i, r.code), {
|
|
5384
5462
|
status: "proven",
|
|
5385
|
-
obtained: this.readObtainedBar?.() ??
|
|
5463
|
+
obtained: this.readObtainedBar?.() ?? pi(this.rankedRequirement ?? n)
|
|
5386
5464
|
};
|
|
5387
5465
|
} catch (t) {
|
|
5388
|
-
if (t instanceof
|
|
5466
|
+
if (t instanceof Xr && t.cancelled) return {
|
|
5389
5467
|
status: "failed",
|
|
5390
|
-
reason: new
|
|
5468
|
+
reason: new ci()
|
|
5391
5469
|
};
|
|
5392
5470
|
let n = this.classifyProofFailure(t);
|
|
5393
5471
|
if (n) return {
|
|
@@ -5417,15 +5495,15 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5417
5495
|
return this.openPrompt = r, this.prompt(r);
|
|
5418
5496
|
}
|
|
5419
5497
|
classifyProofFailure(e) {
|
|
5420
|
-
if (e instanceof
|
|
5498
|
+
if (e instanceof yr || e instanceof br || e instanceof xr) return e;
|
|
5421
5499
|
if (e instanceof $) switch (e.kind) {
|
|
5422
|
-
case "unavailable": return new
|
|
5500
|
+
case "unavailable": return new br(e.message);
|
|
5423
5501
|
case "exhausted":
|
|
5424
5502
|
case "attempts_exhausted":
|
|
5425
5503
|
case "fatal":
|
|
5426
5504
|
case "protocol":
|
|
5427
5505
|
case "network": return e;
|
|
5428
|
-
case "session_changed": return new
|
|
5506
|
+
case "session_changed": return new xr(e.message);
|
|
5429
5507
|
default: return;
|
|
5430
5508
|
}
|
|
5431
5509
|
}
|
|
@@ -5437,28 +5515,28 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5437
5515
|
});
|
|
5438
5516
|
await this.transport.commit(e.type, r);
|
|
5439
5517
|
}
|
|
5440
|
-
},
|
|
5518
|
+
}, vi = (e) => typeof e == "function" ? e() : e, yi = (e) => {
|
|
5441
5519
|
try {
|
|
5442
5520
|
return new URL(e);
|
|
5443
5521
|
} catch {
|
|
5444
5522
|
return;
|
|
5445
5523
|
}
|
|
5446
|
-
},
|
|
5524
|
+
}, bi = (e, t) => {
|
|
5447
5525
|
if (!t || t === "/") return !0;
|
|
5448
5526
|
let n = t.replace(/\/+$/, "");
|
|
5449
5527
|
return e === n || e.startsWith(`${n}/`);
|
|
5450
|
-
},
|
|
5528
|
+
}, xi = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && bi(e.pathname, t.pathPrefix), Si = (e, t) => {
|
|
5451
5529
|
for (let n of t) {
|
|
5452
5530
|
if (n === "") continue;
|
|
5453
5531
|
if (n.startsWith("/")) {
|
|
5454
|
-
if (e.relativeToBase &&
|
|
5532
|
+
if (e.relativeToBase && bi(e.pathname, n)) return !0;
|
|
5455
5533
|
continue;
|
|
5456
5534
|
}
|
|
5457
|
-
let t =
|
|
5458
|
-
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;
|
|
5459
5537
|
}
|
|
5460
5538
|
return !1;
|
|
5461
|
-
},
|
|
5539
|
+
}, Ci = (e, t, n) => xi(e, t.passflow) || Si(e, t.backend) ? !n || n(e.href) !== !1 : !1, wi = (e) => {
|
|
5462
5540
|
let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
|
|
5463
5541
|
console.warn(n, {
|
|
5464
5542
|
status: e.status,
|
|
@@ -5466,8 +5544,8 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5466
5544
|
reason: e.reason,
|
|
5467
5545
|
detail: t
|
|
5468
5546
|
});
|
|
5469
|
-
},
|
|
5470
|
-
let n = t.onUpgradeDiagnostic ??
|
|
5547
|
+
}, Ti = (e, t) => {
|
|
5548
|
+
let n = t.onUpgradeDiagnostic ?? wi;
|
|
5471
5549
|
return (t, r) => {
|
|
5472
5550
|
n({
|
|
5473
5551
|
status: e.status,
|
|
@@ -5479,8 +5557,8 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5479
5557
|
}
|
|
5480
5558
|
});
|
|
5481
5559
|
};
|
|
5482
|
-
},
|
|
5483
|
-
let r = n.onUpgradeDiagnostic ??
|
|
5560
|
+
}, Ei = (e, t, n) => {
|
|
5561
|
+
let r = n.onUpgradeDiagnostic ?? wi;
|
|
5484
5562
|
for (let n of e) r({
|
|
5485
5563
|
...n,
|
|
5486
5564
|
url: t.request.href,
|
|
@@ -5489,8 +5567,8 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5489
5567
|
...n.detail ?? {}
|
|
5490
5568
|
}
|
|
5491
5569
|
});
|
|
5492
|
-
},
|
|
5493
|
-
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;
|
|
5494
5572
|
if (i) try {
|
|
5495
5573
|
a = await e.readBody();
|
|
5496
5574
|
} catch {
|
|
@@ -5504,10 +5582,10 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5504
5582
|
status: e.status,
|
|
5505
5583
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5506
5584
|
}, { requireChallengeChannel: t.requireChallengeChannel });
|
|
5507
|
-
},
|
|
5585
|
+
}, ki = (e) => ve({
|
|
5508
5586
|
status: e.status,
|
|
5509
5587
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5510
|
-
}, { 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 ? {
|
|
5511
5589
|
kind: "insufficient",
|
|
5512
5590
|
obtained: e.obtained,
|
|
5513
5591
|
required: e.required
|
|
@@ -5523,17 +5601,17 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5523
5601
|
kind: "transport-failure",
|
|
5524
5602
|
retryable: !1,
|
|
5525
5603
|
error: e instanceof Error ? e : Error(String(e))
|
|
5526
|
-
},
|
|
5604
|
+
}, Mi = async (e, t, n, r) => {
|
|
5527
5605
|
if (e.status !== 401 && e.status !== 403) return {
|
|
5528
5606
|
kind: "replayed",
|
|
5529
5607
|
response: e
|
|
5530
5608
|
};
|
|
5531
|
-
let { challenge: i, diagnostics: a } = await
|
|
5532
|
-
if (
|
|
5609
|
+
let { challenge: i, diagnostics: a } = await Oi(e, t);
|
|
5610
|
+
if (Ei(a, e, t), !i) return {
|
|
5533
5611
|
kind: "replayed",
|
|
5534
5612
|
response: e
|
|
5535
5613
|
};
|
|
5536
|
-
let o =
|
|
5614
|
+
let o = pi(i);
|
|
5537
5615
|
return r("elevated-insufficient", {
|
|
5538
5616
|
obtained: n,
|
|
5539
5617
|
required: o
|
|
@@ -5543,7 +5621,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5543
5621
|
required: o,
|
|
5544
5622
|
response: e
|
|
5545
5623
|
};
|
|
5546
|
-
},
|
|
5624
|
+
}, Ni = async (e, t) => {
|
|
5547
5625
|
if (!t) return {
|
|
5548
5626
|
aborted: !1,
|
|
5549
5627
|
value: await e
|
|
@@ -5570,14 +5648,14 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5570
5648
|
} finally {
|
|
5571
5649
|
n && t.removeEventListener?.("abort", n);
|
|
5572
5650
|
}
|
|
5573
|
-
},
|
|
5651
|
+
}, Pi = async (e, t) => {
|
|
5574
5652
|
if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
|
|
5575
|
-
let n =
|
|
5653
|
+
let n = Ti(e, t);
|
|
5576
5654
|
if (e.markers.replayed) {
|
|
5577
|
-
if (!
|
|
5578
|
-
let { challenge: r, diagnostics: i } = await
|
|
5579
|
-
if (
|
|
5580
|
-
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);
|
|
5581
5659
|
return n("elevated-insufficient", {
|
|
5582
5660
|
obtained: a,
|
|
5583
5661
|
required: o
|
|
@@ -5588,12 +5666,12 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5588
5666
|
response: e
|
|
5589
5667
|
};
|
|
5590
5668
|
}
|
|
5591
|
-
if (!
|
|
5669
|
+
if (!Ci(e.request, t.scope, t.shouldIntercept)) return ki(e) ? (n("challenge-out-of-scope", {
|
|
5592
5670
|
header: e.getHeader("www-authenticate") ?? void 0,
|
|
5593
|
-
message:
|
|
5671
|
+
message: Ai(e.request.href, t.scope)
|
|
5594
5672
|
}), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
|
|
5595
|
-
let { challenge: r, diagnostics: i } = await
|
|
5596
|
-
if (
|
|
5673
|
+
let { challenge: r, diagnostics: i } = await Oi(e, t);
|
|
5674
|
+
if (Ei(i, e, t), !r) {
|
|
5597
5675
|
let r = e.getHeader("www-authenticate");
|
|
5598
5676
|
return t.requireChallengeChannel !== "header" && n("no-channel", {
|
|
5599
5677
|
...r ? { header: r } : {},
|
|
@@ -5607,9 +5685,9 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5607
5685
|
method: e.request.method
|
|
5608
5686
|
}, s, c;
|
|
5609
5687
|
try {
|
|
5610
|
-
s = Promise.resolve(t.elevate(r, o)), c = await
|
|
5688
|
+
s = Promise.resolve(t.elevate(r, o)), c = await Ni(s, e.signal);
|
|
5611
5689
|
} catch (e) {
|
|
5612
|
-
return
|
|
5690
|
+
return ji(e, void 0);
|
|
5613
5691
|
}
|
|
5614
5692
|
if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
|
|
5615
5693
|
kind: "aborted",
|
|
@@ -5620,7 +5698,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5620
5698
|
kind: "aborted",
|
|
5621
5699
|
reason: e.signal.reason
|
|
5622
5700
|
};
|
|
5623
|
-
let u = l?.obtained ?? t.readObtainedBar?.() ??
|
|
5701
|
+
let u = l?.obtained ?? t.readObtainedBar?.() ?? pi(r), d = t.authorizationSwap?.(), f = d ? {
|
|
5624
5702
|
from: a?.from ?? d.from,
|
|
5625
5703
|
to: d.to
|
|
5626
5704
|
} : void 0;
|
|
@@ -5629,7 +5707,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5629
5707
|
try {
|
|
5630
5708
|
p = await e.replay(f ? { authorizationSwap: f } : void 0);
|
|
5631
5709
|
} catch (t) {
|
|
5632
|
-
if (t instanceof
|
|
5710
|
+
if (t instanceof yr) return l?.waiter.report({
|
|
5633
5711
|
outcome: "insufficient",
|
|
5634
5712
|
obtained: t.obtained,
|
|
5635
5713
|
required: t.required
|
|
@@ -5647,7 +5725,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5647
5725
|
};
|
|
5648
5726
|
throw t;
|
|
5649
5727
|
}
|
|
5650
|
-
let m = await
|
|
5728
|
+
let m = await Mi(p, t, u, n);
|
|
5651
5729
|
return m.kind === "insufficient" ? l?.waiter.report({
|
|
5652
5730
|
outcome: "insufficient",
|
|
5653
5731
|
obtained: m.obtained,
|
|
@@ -5656,18 +5734,18 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5656
5734
|
outcome: "replayed",
|
|
5657
5735
|
obtained: u
|
|
5658
5736
|
}), m;
|
|
5659
|
-
},
|
|
5737
|
+
}, Fi = (e) => {
|
|
5660
5738
|
switch (e.kind) {
|
|
5661
|
-
case "cancelled": return new
|
|
5662
|
-
case "unsatisfiable": return new
|
|
5663
|
-
case "unavailable": return new
|
|
5664
|
-
case "session-changed": return new
|
|
5665
|
-
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);
|
|
5666
5744
|
case "exhausted": return e.error;
|
|
5667
5745
|
case "transport-failure": return e.error;
|
|
5668
5746
|
default: return;
|
|
5669
5747
|
}
|
|
5670
|
-
},
|
|
5748
|
+
}, Ii = (e, t, n) => {
|
|
5671
5749
|
switch (e.kind) {
|
|
5672
5750
|
case "replayed": return {
|
|
5673
5751
|
settle: "resolve",
|
|
@@ -5685,21 +5763,21 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5685
5763
|
};
|
|
5686
5764
|
case "cancelled": return n.onCancel === "reject" ? {
|
|
5687
5765
|
settle: "reject",
|
|
5688
|
-
error: new
|
|
5766
|
+
error: new ci()
|
|
5689
5767
|
} : {
|
|
5690
5768
|
settle: "resolve",
|
|
5691
|
-
value:
|
|
5769
|
+
value: Gi(t, e)
|
|
5692
5770
|
};
|
|
5693
5771
|
case "insufficient": return {
|
|
5694
5772
|
settle: "resolve",
|
|
5695
|
-
value:
|
|
5773
|
+
value: Gi(e.response?.raw ?? t, e)
|
|
5696
5774
|
};
|
|
5697
5775
|
default: return {
|
|
5698
5776
|
settle: "resolve",
|
|
5699
|
-
value:
|
|
5777
|
+
value: Gi(t, e)
|
|
5700
5778
|
};
|
|
5701
5779
|
}
|
|
5702
|
-
},
|
|
5780
|
+
}, Li = (e, t) => {
|
|
5703
5781
|
switch (e.kind) {
|
|
5704
5782
|
case "replayed": return e.response.rejected ? {
|
|
5705
5783
|
settle: "reject",
|
|
@@ -5714,39 +5792,39 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5714
5792
|
};
|
|
5715
5793
|
default: return {
|
|
5716
5794
|
settle: "reject",
|
|
5717
|
-
error:
|
|
5795
|
+
error: Fi(e) ?? t
|
|
5718
5796
|
};
|
|
5719
5797
|
}
|
|
5720
|
-
},
|
|
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) => {
|
|
5721
5799
|
switch (t.kind) {
|
|
5722
5800
|
case "cancelled":
|
|
5723
|
-
|
|
5801
|
+
Ri.add(e);
|
|
5724
5802
|
break;
|
|
5725
5803
|
case "exhausted":
|
|
5726
|
-
|
|
5804
|
+
zi.add(e);
|
|
5727
5805
|
break;
|
|
5728
5806
|
case "insufficient":
|
|
5729
|
-
|
|
5807
|
+
Bi.add(e);
|
|
5730
5808
|
break;
|
|
5731
5809
|
case "unsatisfiable":
|
|
5732
|
-
|
|
5810
|
+
Vi.add(e);
|
|
5733
5811
|
break;
|
|
5734
5812
|
case "unavailable":
|
|
5735
|
-
|
|
5813
|
+
Hi.add(e);
|
|
5736
5814
|
break;
|
|
5737
5815
|
case "session-changed":
|
|
5738
|
-
|
|
5816
|
+
Ui.add(e);
|
|
5739
5817
|
break;
|
|
5740
|
-
case "transport-failure":
|
|
5818
|
+
case "transport-failure": Wi.add(e);
|
|
5741
5819
|
}
|
|
5742
5820
|
return e;
|
|
5743
|
-
},
|
|
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 = () => {
|
|
5744
5822
|
let e = globalThis, t = e.document?.baseURI;
|
|
5745
5823
|
if (typeof t == "string" && t !== "") return t;
|
|
5746
5824
|
let n = e.location?.href;
|
|
5747
|
-
return typeof n == "string" && n !== "" && n !== "about:blank" ? n :
|
|
5748
|
-
},
|
|
5749
|
-
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;
|
|
5750
5828
|
try {
|
|
5751
5829
|
r = new URL(t).origin;
|
|
5752
5830
|
} catch {
|
|
@@ -5772,28 +5850,28 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5772
5850
|
relativeToBase: !1,
|
|
5773
5851
|
sentinelBase: n
|
|
5774
5852
|
};
|
|
5775
|
-
},
|
|
5853
|
+
}, na = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, ra = (e) => {
|
|
5776
5854
|
let t = [];
|
|
5777
5855
|
if (e == null) return Object.freeze(t);
|
|
5778
5856
|
let n = e;
|
|
5779
5857
|
if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
|
|
5780
|
-
let r =
|
|
5858
|
+
let r = na(n, e);
|
|
5781
5859
|
r && t.push(r);
|
|
5782
5860
|
}), Object.freeze(t);
|
|
5783
5861
|
if (Array.isArray(e)) {
|
|
5784
5862
|
for (let n of e) if (Array.isArray(n) && n.length >= 2) {
|
|
5785
|
-
let e =
|
|
5863
|
+
let e = na(String(n[0]), n[1]);
|
|
5786
5864
|
e && t.push(e);
|
|
5787
5865
|
}
|
|
5788
5866
|
return Object.freeze(t);
|
|
5789
5867
|
}
|
|
5790
5868
|
if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
|
|
5791
|
-
let e =
|
|
5869
|
+
let e = na(n, Array.isArray(r) ? r.join(", ") : r);
|
|
5792
5870
|
e && t.push(e);
|
|
5793
5871
|
}
|
|
5794
5872
|
return Object.freeze(t);
|
|
5795
|
-
},
|
|
5796
|
-
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 = {
|
|
5797
5875
|
raw: e.url,
|
|
5798
5876
|
href: t.href,
|
|
5799
5877
|
dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
|
|
@@ -5802,29 +5880,29 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5802
5880
|
resolved: t.resolved,
|
|
5803
5881
|
relativeToBase: t.relativeToBase,
|
|
5804
5882
|
method: (e.method ?? "GET").toUpperCase(),
|
|
5805
|
-
headers:
|
|
5883
|
+
headers: ra(e.headers),
|
|
5806
5884
|
bodyKind: e.bodyKind,
|
|
5807
5885
|
..."body" in e ? { body: e.body } : {}
|
|
5808
5886
|
};
|
|
5809
5887
|
return Object.freeze(n);
|
|
5810
|
-
},
|
|
5888
|
+
}, aa = (e, t) => {
|
|
5811
5889
|
if (!t || t.from === t.to) return e;
|
|
5812
5890
|
let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
|
|
5813
5891
|
return n ? Object.freeze(r) : e;
|
|
5814
|
-
},
|
|
5892
|
+
}, oa = (e) => {
|
|
5815
5893
|
let t = {};
|
|
5816
5894
|
for (let [n, r] of e) t[n] = r;
|
|
5817
5895
|
return t;
|
|
5818
|
-
},
|
|
5896
|
+
}, sa = /* @__PURE__ */ new Set([
|
|
5819
5897
|
"GET",
|
|
5820
5898
|
"HEAD",
|
|
5821
5899
|
"OPTIONS"
|
|
5822
|
-
]),
|
|
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) => {
|
|
5823
5901
|
if (typeof e == "string") return e.length;
|
|
5824
5902
|
let t = e;
|
|
5825
5903
|
if (typeof t?.size == "number") return t.size;
|
|
5826
5904
|
if (typeof t?.byteLength == "number") return t.byteLength;
|
|
5827
|
-
},
|
|
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) => ({
|
|
5828
5906
|
replayable: !1,
|
|
5829
5907
|
bodyKind: e,
|
|
5830
5908
|
reason: t,
|
|
@@ -5832,11 +5910,11 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5832
5910
|
forwardInit: i,
|
|
5833
5911
|
snapshot: r,
|
|
5834
5912
|
replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
|
|
5835
|
-
}),
|
|
5913
|
+
}), ha = (e, t) => oa(aa(e.headers, t?.authorizationSwap)), ga = (e) => {
|
|
5836
5914
|
if (!e || !("headers" in e)) return e;
|
|
5837
5915
|
let { headers: t, ...n } = e;
|
|
5838
5916
|
return n;
|
|
5839
|
-
},
|
|
5917
|
+
}, _a = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : ca(e) ? e.headers : void 0, va = (e) => {
|
|
5840
5918
|
if (e === null || typeof e == "string") return e;
|
|
5841
5919
|
if (typeof FormData < "u" && e instanceof FormData) {
|
|
5842
5920
|
let t = new FormData();
|
|
@@ -5844,18 +5922,18 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5844
5922
|
return t;
|
|
5845
5923
|
}
|
|
5846
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;
|
|
5847
|
-
},
|
|
5848
|
-
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({
|
|
5849
5927
|
url: r,
|
|
5850
5928
|
method: i,
|
|
5851
5929
|
headers: a,
|
|
5852
5930
|
bodyKind: e,
|
|
5853
5931
|
...t === void 0 ? {} : { body: t }
|
|
5854
5932
|
});
|
|
5855
|
-
if (
|
|
5933
|
+
if (ca(e)) {
|
|
5856
5934
|
if (e.body === null || e.body === void 0) {
|
|
5857
5935
|
let a = o("none");
|
|
5858
|
-
return
|
|
5936
|
+
return pa(n, {
|
|
5859
5937
|
url: r,
|
|
5860
5938
|
method: i,
|
|
5861
5939
|
bodyKind: "none"
|
|
@@ -5865,20 +5943,20 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5865
5943
|
forwardInput: e,
|
|
5866
5944
|
forwardInit: t,
|
|
5867
5945
|
snapshot: a,
|
|
5868
|
-
replay: (n, r) => n(
|
|
5869
|
-
} :
|
|
5946
|
+
replay: (n, r) => n(ya(e, a, r), ga(t))
|
|
5947
|
+
} : ma("none", "the replay policy refused this request", e, a, t);
|
|
5870
5948
|
}
|
|
5871
5949
|
let a = o("request-clone");
|
|
5872
|
-
if (!
|
|
5950
|
+
if (!pa(n, {
|
|
5873
5951
|
url: r,
|
|
5874
5952
|
method: i,
|
|
5875
5953
|
bodyKind: "request-clone"
|
|
5876
|
-
})) return
|
|
5954
|
+
})) return ma("request-clone", "the replay policy refused this request", e, a, t);
|
|
5877
5955
|
let s;
|
|
5878
5956
|
try {
|
|
5879
5957
|
s = e.clone();
|
|
5880
5958
|
} catch {
|
|
5881
|
-
return
|
|
5959
|
+
return ma("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
|
|
5882
5960
|
}
|
|
5883
5961
|
return {
|
|
5884
5962
|
replayable: !0,
|
|
@@ -5886,17 +5964,17 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5886
5964
|
forwardInput: e,
|
|
5887
5965
|
forwardInit: t,
|
|
5888
5966
|
snapshot: a,
|
|
5889
|
-
replay: (e, n) => e(
|
|
5967
|
+
replay: (e, n) => e(ya(s, a, n), ga(t))
|
|
5890
5968
|
};
|
|
5891
5969
|
}
|
|
5892
|
-
let s =
|
|
5893
|
-
if (s === "one-shot") return
|
|
5894
|
-
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, {
|
|
5895
5973
|
url: r,
|
|
5896
5974
|
method: i,
|
|
5897
5975
|
bodyKind: s
|
|
5898
|
-
},
|
|
5899
|
-
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);
|
|
5900
5978
|
return {
|
|
5901
5979
|
replayable: !0,
|
|
5902
5980
|
bodyKind: s,
|
|
@@ -5904,21 +5982,21 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5904
5982
|
forwardInit: t,
|
|
5905
5983
|
snapshot: l,
|
|
5906
5984
|
replay: (e, n) => e(l.dispatchUrl, {
|
|
5907
|
-
...
|
|
5985
|
+
...ga(t),
|
|
5908
5986
|
...c === void 0 ? {} : { body: c },
|
|
5909
|
-
headers:
|
|
5987
|
+
headers: ha(l, n),
|
|
5910
5988
|
method: l.method
|
|
5911
5989
|
})
|
|
5912
5990
|
};
|
|
5913
|
-
},
|
|
5914
|
-
if (!
|
|
5991
|
+
}, xa = (e) => typeof e == "object" && !!e, Sa = (e) => (t) => {
|
|
5992
|
+
if (!xa(e)) return;
|
|
5915
5993
|
let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
|
|
5916
5994
|
return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
|
|
5917
|
-
},
|
|
5995
|
+
}, Ca = (e) => {
|
|
5918
5996
|
let t = e?.url ?? "", n = e?.baseURL;
|
|
5919
5997
|
return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
5920
|
-
},
|
|
5921
|
-
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;
|
|
5922
6000
|
return {
|
|
5923
6001
|
...e,
|
|
5924
6002
|
...i ? { baseURL: void 0 } : {},
|
|
@@ -5927,10 +6005,10 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5927
6005
|
headers: r,
|
|
5928
6006
|
..."body" in t ? { data: t.body } : {}
|
|
5929
6007
|
};
|
|
5930
|
-
},
|
|
5931
|
-
let o = t ?? e?.config, s =
|
|
5932
|
-
url:
|
|
5933
|
-
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),
|
|
5934
6012
|
headers: o?.headers,
|
|
5935
6013
|
bodyKind: s,
|
|
5936
6014
|
body: o?.data
|
|
@@ -5938,22 +6016,22 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5938
6016
|
url: c.href,
|
|
5939
6017
|
method: c.method,
|
|
5940
6018
|
bodyKind: s
|
|
5941
|
-
}, u = s !== "one-shot" &&
|
|
6019
|
+
}, u = s !== "one-shot" && pa(i.replay, l);
|
|
5942
6020
|
return {
|
|
5943
6021
|
status: e?.status ?? 0,
|
|
5944
|
-
getHeader:
|
|
6022
|
+
getHeader: Sa(e?.headers),
|
|
5945
6023
|
readBody: async () => e?.data,
|
|
5946
6024
|
request: c,
|
|
5947
6025
|
replay: async (e) => {
|
|
5948
|
-
let t = Te(
|
|
6026
|
+
let t = Te(Ea(o ?? {}, c, e));
|
|
5949
6027
|
try {
|
|
5950
6028
|
let e = await r(t);
|
|
5951
|
-
return
|
|
6029
|
+
return Da(e, e?.config ?? t, e, r, i, c);
|
|
5952
6030
|
} catch (e) {
|
|
5953
|
-
let n =
|
|
5954
|
-
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;
|
|
5955
6033
|
return {
|
|
5956
|
-
...
|
|
6034
|
+
...Da(n.response, n.config ?? t, e, r, i, c),
|
|
5957
6035
|
rejected: !0
|
|
5958
6036
|
};
|
|
5959
6037
|
}
|
|
@@ -5967,19 +6045,19 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5967
6045
|
replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
|
|
5968
6046
|
signal: o?.signal
|
|
5969
6047
|
};
|
|
5970
|
-
},
|
|
5971
|
-
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);
|
|
5972
6050
|
if (a.settle === "reject") throw a.error;
|
|
5973
6051
|
return a.value;
|
|
5974
|
-
},
|
|
5975
|
-
let r = e.request, i = n ?? (typeof r == "function" ? (t) => r.call(e, t) : () => Promise.reject(/* @__PURE__ */ Error("Passflow: this client exposes no request() to replay through."))), a = e.interceptors.response.use(void 0,
|
|
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;
|
|
5976
6054
|
return () => {
|
|
5977
6055
|
o || (o = !0, e.interceptors.response.eject(a));
|
|
5978
6056
|
};
|
|
5979
|
-
},
|
|
6057
|
+
}, Aa = (t, n) => {
|
|
5980
6058
|
let r = e.create(t);
|
|
5981
6059
|
return n(r), r;
|
|
5982
|
-
},
|
|
6060
|
+
}, ja = 0, Ma = (e, t) => {
|
|
5983
6061
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
5984
6062
|
if (n) return {
|
|
5985
6063
|
get aborted() {
|
|
@@ -5993,34 +6071,34 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
5993
6071
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
5994
6072
|
} : {}
|
|
5995
6073
|
};
|
|
5996
|
-
},
|
|
6074
|
+
}, Na = (e) => (t) => e.headers?.get(t), Pa = (e, t, n, r, i) => ({
|
|
5997
6075
|
status: e.status,
|
|
5998
|
-
getHeader:
|
|
6076
|
+
getHeader: Na(e),
|
|
5999
6077
|
readBody: () => e.clone().json(),
|
|
6000
6078
|
request: t.snapshot,
|
|
6001
|
-
replay: async (e) =>
|
|
6079
|
+
replay: async (e) => Pa(await t.replay(n, e), t, n, r, i),
|
|
6002
6080
|
markers: r,
|
|
6003
6081
|
raw: e,
|
|
6004
6082
|
replayable: t.replayable,
|
|
6005
6083
|
replayUnsupportedReason: t.reason,
|
|
6006
6084
|
signal: i,
|
|
6007
6085
|
responseType: e.type
|
|
6008
|
-
}),
|
|
6086
|
+
}), Fa = (e, t) => {
|
|
6009
6087
|
let n = (t, n) => {
|
|
6010
|
-
|
|
6088
|
+
ja += 1;
|
|
6011
6089
|
try {
|
|
6012
6090
|
return e(t, n);
|
|
6013
6091
|
} finally {
|
|
6014
|
-
--
|
|
6092
|
+
--ja;
|
|
6015
6093
|
}
|
|
6016
6094
|
};
|
|
6017
6095
|
return async (e, r) => {
|
|
6018
|
-
if (
|
|
6019
|
-
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);
|
|
6020
6098
|
if (s.settle === "reject") throw s.error;
|
|
6021
6099
|
return s.value;
|
|
6022
6100
|
};
|
|
6023
|
-
},
|
|
6101
|
+
}, Ia = new Set(ti.filter((e) => !e.requiresPrepare).map((e) => e.type)), La = (e) => {
|
|
6024
6102
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
6025
6103
|
kind: "protocol",
|
|
6026
6104
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -6032,17 +6110,17 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6032
6110
|
webauthn: e.webauthn,
|
|
6033
6111
|
codeSentTo: e.code_sent_to
|
|
6034
6112
|
};
|
|
6035
|
-
},
|
|
6113
|
+
}, Ra = (e) => dr(e) && !fr(e), za = (e) => ({
|
|
6036
6114
|
async prepare(t) {
|
|
6037
|
-
if (!
|
|
6115
|
+
if (!Ia.has(t)) try {
|
|
6038
6116
|
let n = e.relyingPartyId?.();
|
|
6039
|
-
return
|
|
6117
|
+
return La(await e.startUpgrade(n ? {
|
|
6040
6118
|
method: t,
|
|
6041
6119
|
relying_party_id: n
|
|
6042
6120
|
} : { method: t }));
|
|
6043
6121
|
} catch (e) {
|
|
6044
|
-
if (
|
|
6045
|
-
let t =
|
|
6122
|
+
if (Ra(e)) throw e;
|
|
6123
|
+
let t = gr(e, "start");
|
|
6046
6124
|
if (t.kind === "prepare_not_required") return;
|
|
6047
6125
|
throw t;
|
|
6048
6126
|
}
|
|
@@ -6059,17 +6137,17 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6059
6137
|
assertion: n
|
|
6060
6138
|
});
|
|
6061
6139
|
} catch (t) {
|
|
6062
|
-
if (
|
|
6063
|
-
let n =
|
|
6064
|
-
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;
|
|
6065
6143
|
}
|
|
6066
6144
|
}
|
|
6067
|
-
}),
|
|
6145
|
+
}), Ba = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Va = (e) => {
|
|
6068
6146
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
6069
6147
|
let i = () => {
|
|
6070
6148
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
6071
6149
|
};
|
|
6072
|
-
return
|
|
6150
|
+
return za({
|
|
6073
6151
|
...e,
|
|
6074
6152
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
6075
6153
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -6080,7 +6158,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6080
6158
|
});
|
|
6081
6159
|
}, i = (t, n) => {
|
|
6082
6160
|
let i = {}, a = {
|
|
6083
|
-
controller: new
|
|
6161
|
+
controller: new _i({
|
|
6084
6162
|
transport: r(() => i.current),
|
|
6085
6163
|
prompt: t.prompt,
|
|
6086
6164
|
platform: e.platform,
|
|
@@ -6092,17 +6170,17 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6092
6170
|
options: t,
|
|
6093
6171
|
scope: {
|
|
6094
6172
|
passflow: e.passflowDomain,
|
|
6095
|
-
backend:
|
|
6173
|
+
backend: Ba(t.backend)
|
|
6096
6174
|
},
|
|
6097
6175
|
generation: n
|
|
6098
6176
|
};
|
|
6099
6177
|
return i.current = a, a;
|
|
6100
6178
|
}, a = async (r, i) => {
|
|
6101
6179
|
let a = t;
|
|
6102
|
-
if (!a) throw new
|
|
6180
|
+
if (!a) throw new br("Step-up verification is not enabled on this Passflow instance");
|
|
6103
6181
|
a.controller.active || (a.pin = e.readSessionPin?.());
|
|
6104
6182
|
let o = await a.controller.elevate(r, i);
|
|
6105
|
-
if (!n(a)) throw new
|
|
6183
|
+
if (!n(a)) throw new xr();
|
|
6106
6184
|
return o;
|
|
6107
6185
|
}, o = () => {
|
|
6108
6186
|
let n = t, r = n?.scope ?? {
|
|
@@ -6146,9 +6224,9 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6146
6224
|
let r = [];
|
|
6147
6225
|
if (e.attachInternalSeam) {
|
|
6148
6226
|
let t = e.attachInternalSeam;
|
|
6149
|
-
t((e) =>
|
|
6227
|
+
t((e) => Oa(o, e)), r.push(() => t(void 0));
|
|
6150
6228
|
}
|
|
6151
|
-
n.interceptFetch && r.push(
|
|
6229
|
+
n.interceptFetch && r.push(Dt((e, t, n) => Fa(e, o)(t, n), {
|
|
6152
6230
|
priority: 20,
|
|
6153
6231
|
name: "passflow-upgrade"
|
|
6154
6232
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -6179,18 +6257,18 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6179
6257
|
withAuth: {
|
|
6180
6258
|
enumerable: !0,
|
|
6181
6259
|
value: (e) => {
|
|
6182
|
-
if (e) return
|
|
6260
|
+
if (e) return Fa(e, o);
|
|
6183
6261
|
let t = typeof globalThis > "u" ? void 0 : globalThis;
|
|
6184
6262
|
if (!t || typeof t.fetch != "function") throw Error("Passflow: withAuth() needs a fetch to wrap — this runtime has none.");
|
|
6185
|
-
return
|
|
6263
|
+
return Fa(t.fetch.bind(t), o);
|
|
6186
6264
|
}
|
|
6187
6265
|
},
|
|
6188
6266
|
attachAuth: {
|
|
6189
6267
|
enumerable: !0,
|
|
6190
|
-
value: (e) =>
|
|
6268
|
+
value: (e) => ka(e, o)
|
|
6191
6269
|
}
|
|
6192
6270
|
});
|
|
6193
|
-
},
|
|
6271
|
+
}, Ha, Ua = class {
|
|
6194
6272
|
get origin() {
|
|
6195
6273
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
6196
6274
|
}
|
|
@@ -6202,9 +6280,9 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6202
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({
|
|
6203
6281
|
prefix: e.keyStoragePrefix ?? "",
|
|
6204
6282
|
storage: this.platform.storage
|
|
6205
|
-
}), this.deviceService = new re(this.storageManager), this.authApi = new
|
|
6206
|
-
let i =
|
|
6207
|
-
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, {
|
|
6208
6286
|
createSession: this.createSessionCallback,
|
|
6209
6287
|
expiredSession: this.expiredSessionCallback
|
|
6210
6288
|
}, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
|
|
@@ -6212,7 +6290,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6212
6290
|
...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
|
|
6213
6291
|
}), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
6214
6292
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
6215
|
-
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({
|
|
6216
6294
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
6217
6295
|
commitRefresh: async (e, t) => {
|
|
6218
6296
|
await this.authService.refreshToken(e, t);
|
|
@@ -6259,7 +6337,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6259
6337
|
return this.upgrade.attachAuth(e);
|
|
6260
6338
|
}
|
|
6261
6339
|
createClient(e) {
|
|
6262
|
-
return
|
|
6340
|
+
return Aa(e, (e) => this.upgrade.attachAuth(e));
|
|
6263
6341
|
}
|
|
6264
6342
|
readAssuranceBar() {
|
|
6265
6343
|
let e = this.storageManager.getToken(j.access_token);
|
|
@@ -6311,7 +6389,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6311
6389
|
message: t instanceof Error || t instanceof B ? t.message : "Session check failed",
|
|
6312
6390
|
originalError: t
|
|
6313
6391
|
};
|
|
6314
|
-
|
|
6392
|
+
U(this.subscribeStore, n), e = void 0;
|
|
6315
6393
|
}
|
|
6316
6394
|
e && this.createSessionCallback && await this.createSessionCallback({
|
|
6317
6395
|
tokens: e,
|
|
@@ -6342,24 +6420,24 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6342
6420
|
}
|
|
6343
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;
|
|
6344
6422
|
if (r) {
|
|
6345
|
-
if (!
|
|
6346
|
-
|
|
6423
|
+
if (!wr(r)) {
|
|
6424
|
+
U(this.subscribeStore, {
|
|
6347
6425
|
operation: "tokens.from-url",
|
|
6348
6426
|
message: "Invalid access token format received",
|
|
6349
6427
|
code: "INVALID_TOKEN_FORMAT"
|
|
6350
6428
|
}), this.cleanupUrlParams(n, e);
|
|
6351
6429
|
return;
|
|
6352
6430
|
}
|
|
6353
|
-
if (i && !
|
|
6354
|
-
|
|
6431
|
+
if (i && !wr(i)) {
|
|
6432
|
+
U(this.subscribeStore, {
|
|
6355
6433
|
operation: "tokens.from-url",
|
|
6356
6434
|
message: "Invalid refresh token format received",
|
|
6357
6435
|
code: "INVALID_TOKEN_FORMAT"
|
|
6358
6436
|
}), this.cleanupUrlParams(n, e);
|
|
6359
6437
|
return;
|
|
6360
6438
|
}
|
|
6361
|
-
if (a && !
|
|
6362
|
-
|
|
6439
|
+
if (a && !wr(a)) {
|
|
6440
|
+
U(this.subscribeStore, {
|
|
6363
6441
|
operation: "tokens.from-url",
|
|
6364
6442
|
message: "Invalid ID token format received",
|
|
6365
6443
|
code: "INVALID_TOKEN_FORMAT"
|
|
@@ -6393,11 +6471,11 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6393
6471
|
if (!n) return !1;
|
|
6394
6472
|
t.delete("tfa_token");
|
|
6395
6473
|
let r = t.toString();
|
|
6396
|
-
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, {
|
|
6397
6475
|
email: "",
|
|
6398
6476
|
challengeId: "",
|
|
6399
6477
|
tfaToken: n
|
|
6400
|
-
}), !0) : (
|
|
6478
|
+
}), !0) : (U(this.subscribeStore, {
|
|
6401
6479
|
operation: "tokens.from-url",
|
|
6402
6480
|
message: "Invalid 2FA token format received",
|
|
6403
6481
|
code: "INVALID_TOKEN_FORMAT"
|
|
@@ -6406,7 +6484,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6406
6484
|
checkErrorsFromURL() {
|
|
6407
6485
|
let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
|
|
6408
6486
|
if (e) {
|
|
6409
|
-
let t =
|
|
6487
|
+
let t = Tr(e);
|
|
6410
6488
|
return Error(t);
|
|
6411
6489
|
}
|
|
6412
6490
|
}
|
|
@@ -6489,7 +6567,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6489
6567
|
originalError: e,
|
|
6490
6568
|
code: e instanceof B ? e.id : void 0
|
|
6491
6569
|
};
|
|
6492
|
-
throw
|
|
6570
|
+
throw U(this.subscribeStore, r), e;
|
|
6493
6571
|
}
|
|
6494
6572
|
async logOut() {
|
|
6495
6573
|
try {
|
|
@@ -6513,7 +6591,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6513
6591
|
message: e,
|
|
6514
6592
|
code: "RESET_ERROR"
|
|
6515
6593
|
};
|
|
6516
|
-
throw
|
|
6594
|
+
throw U(this.subscribeStore, t), this.error;
|
|
6517
6595
|
}
|
|
6518
6596
|
}
|
|
6519
6597
|
notifySignedOut(e) {
|
|
@@ -6693,6 +6771,34 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6693
6771
|
this.handleError(e, "2fa.setup.confirm", "Confirm 2FA setup");
|
|
6694
6772
|
}
|
|
6695
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
|
+
}
|
|
6696
6802
|
async verifyTwoFactor(e, t) {
|
|
6697
6803
|
try {
|
|
6698
6804
|
let n = await this.twoFactorService.verify(e, t);
|
|
@@ -6762,7 +6868,7 @@ var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3
|
|
|
6762
6868
|
this.twoFactorService.clearMagicLinkSession();
|
|
6763
6869
|
}
|
|
6764
6870
|
};
|
|
6765
|
-
|
|
6766
|
-
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 };
|
|
6767
6873
|
|
|
6768
6874
|
//# sourceMappingURL=index.mjs.map
|