@passflow/core 0.29.0 → 0.30.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 +13 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.mjs +623 -606
- 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, { AxiosError as t } from "axios";
|
|
2
2
|
import { startAuthentication as n, startRegistration as r } from "@simplewebauthn/browser";
|
|
3
3
|
// package.json
|
|
4
|
-
var i = "0.
|
|
4
|
+
var i = "0.30.0", a = "X-Passflow-Clientid", o = "Authorization", s = "X-Passflow-DeviceId", c = "X-Passflow-DeviceType", l = i, u = [
|
|
5
5
|
"id",
|
|
6
6
|
"offline",
|
|
7
7
|
"openid"
|
|
@@ -567,7 +567,7 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
567
567
|
}), De = (e) => Ce(e, Se), Oe = /* @__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.redirectCheck = "/auth/redirect/check", 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;
|
|
570
|
+
return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.redirectCheck = "/auth/redirect/check", 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.hostedUpgradeStart = "/auth/session/upgrade/start", e.hostedUpgrade = "/auth/session/upgrade", e;
|
|
571
571
|
}({}), B = /* @__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) => {
|
|
@@ -621,10 +621,10 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
621
621
|
location: e.config?.url ?? "unknown",
|
|
622
622
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
623
623
|
}, { cause: r });
|
|
624
|
-
}, Ze = (e) => e?.includes(z.refresh) ?? !1, Qe = (e) => e?.includes("
|
|
624
|
+
}, Ze = (e) => e?.includes(z.refresh) ?? !1, Qe = (e) => e?.includes("/auth/session/") ?? !1, $e = (e) => e?.includes("logout") ?? !1, et = "__passflowOwnBearer", tt = (e) => typeof e == "object" && !!e && e[et] === !0, nt = (e) => e ? {
|
|
625
625
|
headers: { [o]: `Bearer ${e}` },
|
|
626
|
-
[
|
|
627
|
-
} : {},
|
|
626
|
+
[et]: !0
|
|
627
|
+
} : {}, rt = class {
|
|
628
628
|
get origin() {
|
|
629
629
|
return this._platform.getCurrentUrl()?.origin ?? "";
|
|
630
630
|
}
|
|
@@ -655,7 +655,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
655
655
|
baseURL: this.url,
|
|
656
656
|
headers: { ...this.defaultHeaders }
|
|
657
657
|
}), this.instance.interceptors.request.use(async (e) => {
|
|
658
|
-
if (this.isNonAuthEndpoint(e.url) ||
|
|
658
|
+
if (this.isNonAuthEndpoint(e.url) || tt(e) || Qe(e.url)) return e;
|
|
659
659
|
if (this.tokenDeliveryManager.isCookieMode()) {
|
|
660
660
|
e.withCredentials = !0;
|
|
661
661
|
let t = this.storageManager.getCsrfToken();
|
|
@@ -665,7 +665,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
665
665
|
let t = this.storageManager.getTokens();
|
|
666
666
|
if (!t?.access_token) return e;
|
|
667
667
|
let n = t.access_token;
|
|
668
|
-
if (this.refreshHandler && t.refresh_token &&
|
|
668
|
+
if (this.refreshHandler && t.refresh_token && !$e(e.url)) {
|
|
669
669
|
let e = j(t.access_token);
|
|
670
670
|
if (A(e, 30)) {
|
|
671
671
|
let t = !A(e, 0);
|
|
@@ -681,7 +681,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
681
681
|
}
|
|
682
682
|
return e.headers[o] = `Bearer ${n}`, e;
|
|
683
683
|
}), this.instance.interceptors.response.use((e) => e, async (e) => {
|
|
684
|
-
if (e.response?.status !== 401 || Ze(e.config?.url) ||
|
|
684
|
+
if (e.response?.status !== 401 || Ze(e.config?.url) || Qe(e.config?.url) || tt(e.config) || this.isUpgradeTransactionError(e) || this.tokenDeliveryManager.setSessionInvalid(), e.response && this.upgradeHandler && !Qe(e.config?.url)) {
|
|
685
685
|
let t = Ge(e.response);
|
|
686
686
|
if (t) try {
|
|
687
687
|
return await this.upgradeHandler(e, t);
|
|
@@ -790,9 +790,9 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
790
790
|
[a]: e
|
|
791
791
|
}, this.instance.defaults.headers.common[a] = e;
|
|
792
792
|
}
|
|
793
|
-
},
|
|
793
|
+
}, it = class {
|
|
794
794
|
constructor(e, t, n) {
|
|
795
|
-
this.axiosClient = new
|
|
795
|
+
this.axiosClient = new rt(e, t, n);
|
|
796
796
|
}
|
|
797
797
|
setAppId(e) {
|
|
798
798
|
this.axiosClient.setAppId(e);
|
|
@@ -800,7 +800,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
800
800
|
getAppSettings() {
|
|
801
801
|
return this.axiosClient.get(z.appSettings);
|
|
802
802
|
}
|
|
803
|
-
},
|
|
803
|
+
}, at = { withCredentials: !0 }, ot = 15e3, st = "Sign-in failed. Start again.", ct = "Something went wrong. Try again later.", lt = (e, t, n, r) => {
|
|
804
804
|
if (e instanceof V) return e;
|
|
805
805
|
let i = e?.response?.data?.error;
|
|
806
806
|
return new V({
|
|
@@ -810,9 +810,9 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
810
810
|
location: t,
|
|
811
811
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
812
812
|
});
|
|
813
|
-
},
|
|
813
|
+
}, ut = class {
|
|
814
814
|
constructor(e, t, n) {
|
|
815
|
-
this.axiosClient = new
|
|
815
|
+
this.axiosClient = new rt(e, t, n);
|
|
816
816
|
}
|
|
817
817
|
setAppId(e) {
|
|
818
818
|
this.axiosClient.setAppId(e);
|
|
@@ -831,7 +831,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
831
831
|
device: t,
|
|
832
832
|
os: n
|
|
833
833
|
};
|
|
834
|
-
return this.axiosClient.post(z.signin, r,
|
|
834
|
+
return this.axiosClient.post(z.signin, r, at);
|
|
835
835
|
}
|
|
836
836
|
signUp(e) {
|
|
837
837
|
let { create_tenant: t, anonymous: n } = e, r = {
|
|
@@ -839,16 +839,16 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
839
839
|
create_tenant: t ?? !1,
|
|
840
840
|
anonymous: n ?? !1
|
|
841
841
|
};
|
|
842
|
-
return this.axiosClient.post(z.signup, r,
|
|
842
|
+
return this.axiosClient.post(z.signup, r, at);
|
|
843
843
|
}
|
|
844
844
|
async pkceExchange(e, t) {
|
|
845
845
|
try {
|
|
846
846
|
return await this.axiosClient.post(z.pkceExchange, {
|
|
847
847
|
authz_code: e,
|
|
848
848
|
verifier: t
|
|
849
|
-
},
|
|
849
|
+
}, at);
|
|
850
850
|
} catch (e) {
|
|
851
|
-
throw
|
|
851
|
+
throw lt(e, z.pkceExchange, "error.pkce.exchange", st);
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
854
|
async passwordlessSignIn(e, t, n) {
|
|
@@ -861,53 +861,53 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
861
861
|
try {
|
|
862
862
|
return await this.axiosClient.post(z.passwordless, i);
|
|
863
863
|
} catch (e) {
|
|
864
|
-
throw
|
|
864
|
+
throw lt(e, z.passwordless, "error.passwordless.start", ct);
|
|
865
865
|
}
|
|
866
866
|
}
|
|
867
867
|
async passwordlessSignInComplete(e) {
|
|
868
868
|
try {
|
|
869
|
-
return await this.axiosClient.post(z.passwordlessComplete, e,
|
|
869
|
+
return await this.axiosClient.post(z.passwordlessComplete, e, at);
|
|
870
870
|
} catch (e) {
|
|
871
|
-
throw
|
|
871
|
+
throw lt(e, z.passwordlessComplete, "error.passwordless.complete", ct);
|
|
872
872
|
}
|
|
873
873
|
}
|
|
874
874
|
async passwordlessStatus(e, t) {
|
|
875
875
|
try {
|
|
876
876
|
return await this.axiosClient.post(z.passwordlessStatus, e, {
|
|
877
|
-
...
|
|
878
|
-
timeout:
|
|
877
|
+
...at,
|
|
878
|
+
timeout: ot,
|
|
879
879
|
signal: t?.signal
|
|
880
880
|
});
|
|
881
881
|
} catch (e) {
|
|
882
|
-
throw
|
|
882
|
+
throw lt(e, z.passwordlessStatus, "error.passwordless.status", st);
|
|
883
883
|
}
|
|
884
884
|
}
|
|
885
885
|
async checkRedirectUrl(e) {
|
|
886
886
|
try {
|
|
887
887
|
return (await this.axiosClient.post(z.redirectCheck, { redirect_url: e })).redirect_url;
|
|
888
888
|
} catch (e) {
|
|
889
|
-
throw
|
|
889
|
+
throw lt(e, z.redirectCheck, "error.redirect.check", ct);
|
|
890
890
|
}
|
|
891
891
|
}
|
|
892
892
|
async passwordlessApprovalInfo(e) {
|
|
893
893
|
try {
|
|
894
894
|
return await this.axiosClient.post(z.passwordlessApprovalInfo, e);
|
|
895
895
|
} catch (e) {
|
|
896
|
-
throw
|
|
896
|
+
throw lt(e, z.passwordlessApprovalInfo, "error.passwordless.approval", ct);
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
899
|
async passwordlessApprovalDecide(e) {
|
|
900
900
|
try {
|
|
901
901
|
return await this.axiosClient.post(z.passwordlessApprovalDecide, e);
|
|
902
902
|
} catch (e) {
|
|
903
|
-
throw
|
|
903
|
+
throw lt(e, z.passwordlessApprovalDecide, "error.passwordless.approval", ct);
|
|
904
904
|
}
|
|
905
905
|
}
|
|
906
906
|
validateEmailCode(e) {
|
|
907
907
|
return this.axiosClient.post(z.passkeyValidate, {
|
|
908
908
|
challenge_id: e.challenge_id,
|
|
909
909
|
otp: e.otp
|
|
910
|
-
},
|
|
910
|
+
}, at);
|
|
911
911
|
}
|
|
912
912
|
logOut(e, t, n = !1) {
|
|
913
913
|
let r = n ? void 0 : {
|
|
@@ -948,7 +948,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
948
948
|
device: t,
|
|
949
949
|
passkey_data: e
|
|
950
950
|
}, a = r ? B.passkeyRegisterComplete : z.passkeyRegisterComplete;
|
|
951
|
-
return this.axiosClient.post(a, i,
|
|
951
|
+
return this.axiosClient.post(a, i, at);
|
|
952
952
|
}
|
|
953
953
|
passkeyAuthenticateStart(e, t, n, r = !1) {
|
|
954
954
|
let i = {
|
|
@@ -965,7 +965,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
965
965
|
device: t,
|
|
966
966
|
passkey_data: e
|
|
967
967
|
}, a = r ? B.passkeyAuthenticateComplete : z.passkeyAuthenticateComplete;
|
|
968
|
-
return this.axiosClient.post(a, i,
|
|
968
|
+
return this.axiosClient.post(a, i, at);
|
|
969
969
|
}
|
|
970
970
|
passkeyValidate(e, t, n, r = !1, i) {
|
|
971
971
|
let o = {
|
|
@@ -977,9 +977,9 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
977
977
|
let c = i ? { [a]: i } : {};
|
|
978
978
|
return this.axiosClient.post(s, o, { headers: c });
|
|
979
979
|
}
|
|
980
|
-
},
|
|
980
|
+
}, dt = class {
|
|
981
981
|
constructor(e, t, n) {
|
|
982
|
-
this.axiosClient = new
|
|
982
|
+
this.axiosClient = new rt(e, t, n);
|
|
983
983
|
}
|
|
984
984
|
setAppId(e) {
|
|
985
985
|
this.axiosClient.setAppId(e);
|
|
@@ -991,9 +991,9 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
991
991
|
completeCLIAuth(e) {
|
|
992
992
|
return this.axiosClient.post(z.cliAuthComplete, e);
|
|
993
993
|
}
|
|
994
|
-
},
|
|
994
|
+
}, ft = class {
|
|
995
995
|
constructor(e, t, n) {
|
|
996
|
-
this.axiosClient = new
|
|
996
|
+
this.axiosClient = new rt(e, t, n);
|
|
997
997
|
}
|
|
998
998
|
setAppId(e) {
|
|
999
999
|
this.axiosClient.setAppId(e);
|
|
@@ -1022,9 +1022,9 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1022
1022
|
let t = Be(z.invitationGetLink, { invitationID: e });
|
|
1023
1023
|
return this.axiosClient.get(t);
|
|
1024
1024
|
}
|
|
1025
|
-
},
|
|
1025
|
+
}, pt = class {
|
|
1026
1026
|
constructor(e, t, n) {
|
|
1027
|
-
this.axiosClient = new
|
|
1027
|
+
this.axiosClient = new rt(e, t, n);
|
|
1028
1028
|
}
|
|
1029
1029
|
setAppId(e) {
|
|
1030
1030
|
this.axiosClient.setAppId(e);
|
|
@@ -1038,9 +1038,9 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1038
1038
|
getPasskeySettings() {
|
|
1039
1039
|
return this.axiosClient.get(z.settingsPasskey);
|
|
1040
1040
|
}
|
|
1041
|
-
},
|
|
1041
|
+
}, mt = class {
|
|
1042
1042
|
constructor(e, t, n) {
|
|
1043
|
-
this.axiosClient = new
|
|
1043
|
+
this.axiosClient = new rt(e, t, n);
|
|
1044
1044
|
}
|
|
1045
1045
|
setAppId(e) {
|
|
1046
1046
|
this.axiosClient.setAppId(e);
|
|
@@ -1154,58 +1154,58 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1154
1154
|
let r = `${z.tenantPath}/${e}/group/${t}/invite/email/${n}`;
|
|
1155
1155
|
return this.axiosClient.delete(r);
|
|
1156
1156
|
}
|
|
1157
|
-
},
|
|
1157
|
+
}, ht = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, gt = (e) => ({
|
|
1158
1158
|
withCredentials: !0,
|
|
1159
|
-
...
|
|
1160
|
-
}),
|
|
1159
|
+
...ht(e)
|
|
1160
|
+
}), _t = ({ qr_code_image: e, qr_code: t, ...n }) => ({
|
|
1161
1161
|
...n,
|
|
1162
1162
|
qr_code: (t ?? e ?? "").replace(/^data:image\/png;base64,/, "")
|
|
1163
|
-
}),
|
|
1163
|
+
}), vt = {
|
|
1164
1164
|
"error.2fa.setup.token.expired": "EXPIRED_TOKEN",
|
|
1165
1165
|
"error.2fa.setup.token.revoked": "REVOKED_TOKEN",
|
|
1166
1166
|
"error.2fa.setup.token.already_used": "ALREADY_USED",
|
|
1167
1167
|
"error.2fa.setup.token.rate.limit.exceeded": "RATE_LIMITED"
|
|
1168
|
-
},
|
|
1168
|
+
}, yt = class {
|
|
1169
1169
|
constructor(e, t, n) {
|
|
1170
|
-
this.axiosClient = new
|
|
1170
|
+
this.axiosClient = new rt(e, t, n);
|
|
1171
1171
|
}
|
|
1172
1172
|
setAppId(e) {
|
|
1173
1173
|
this.axiosClient.setAppId(e);
|
|
1174
1174
|
}
|
|
1175
1175
|
getStatus(e) {
|
|
1176
|
-
return this.axiosClient.get(z.twoFactorStatus,
|
|
1176
|
+
return this.axiosClient.get(z.twoFactorStatus, nt(e));
|
|
1177
1177
|
}
|
|
1178
1178
|
async beginSetup(e) {
|
|
1179
|
-
return
|
|
1179
|
+
return _t(await this.axiosClient.post(z.twoFactorSetupBegin, {}, nt(e)));
|
|
1180
1180
|
}
|
|
1181
1181
|
confirmSetup(e, t) {
|
|
1182
|
-
return this.axiosClient.post(z.twoFactorSetupConfirm, e,
|
|
1182
|
+
return this.axiosClient.post(z.twoFactorSetupConfirm, e, nt(t));
|
|
1183
1183
|
}
|
|
1184
1184
|
async getEnrollment(e) {
|
|
1185
|
-
return (await this.axiosClient.get(z.twoFactorEnrollment,
|
|
1185
|
+
return (await this.axiosClient.get(z.twoFactorEnrollment, nt(e))).enrollment;
|
|
1186
1186
|
}
|
|
1187
1187
|
sendSetupLink(e) {
|
|
1188
|
-
return this.axiosClient.post(z.twoFactorEnrollmentEmailLink, void 0,
|
|
1188
|
+
return this.axiosClient.post(z.twoFactorEnrollmentEmailLink, void 0, nt(e));
|
|
1189
1189
|
}
|
|
1190
1190
|
async beginEnrollment(e) {
|
|
1191
|
-
return
|
|
1191
|
+
return _t(await this.axiosClient.post(z.twoFactorEnrollmentBegin, void 0, nt(e)));
|
|
1192
1192
|
}
|
|
1193
1193
|
confirmEnrollment(e, t) {
|
|
1194
|
-
return this.axiosClient.post(z.twoFactorEnrollmentConfirm, t,
|
|
1194
|
+
return this.axiosClient.post(z.twoFactorEnrollmentConfirm, t, nt(e));
|
|
1195
1195
|
}
|
|
1196
1196
|
verify(e) {
|
|
1197
1197
|
let { tfa_token: t, code: n, trust_device: r } = e;
|
|
1198
1198
|
return this.axiosClient.post(z.twoFactorVerify, {
|
|
1199
1199
|
code: n,
|
|
1200
1200
|
...r ? { trust_device: !0 } : {}
|
|
1201
|
-
},
|
|
1201
|
+
}, gt(t));
|
|
1202
1202
|
}
|
|
1203
1203
|
useRecoveryCode(e) {
|
|
1204
1204
|
let { tfa_token: t, recovery_code: n, trust_device: r } = e;
|
|
1205
1205
|
return this.axiosClient.post(z.twoFactorRecovery, {
|
|
1206
1206
|
recovery_code: n,
|
|
1207
1207
|
...r ? { trust_device: !0 } : {}
|
|
1208
|
-
},
|
|
1208
|
+
}, gt(t));
|
|
1209
1209
|
}
|
|
1210
1210
|
disable(e) {
|
|
1211
1211
|
return this.axiosClient.delete(z.twoFactor, { data: e });
|
|
@@ -1234,7 +1234,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1234
1234
|
if (e instanceof V) return {
|
|
1235
1235
|
success: !1,
|
|
1236
1236
|
error: {
|
|
1237
|
-
code:
|
|
1237
|
+
code: vt[e.id] ?? this.mapStatusToErrorCode(e.status),
|
|
1238
1238
|
message: e.message || this.getDefaultErrorMessage(e.status)
|
|
1239
1239
|
}
|
|
1240
1240
|
};
|
|
@@ -1299,17 +1299,17 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1299
1299
|
return this.axiosClient.delete(t);
|
|
1300
1300
|
}
|
|
1301
1301
|
requestChallenge(e, t) {
|
|
1302
|
-
return this.axiosClient.post(z.TwoFactorChallenge, e,
|
|
1302
|
+
return this.axiosClient.post(z.TwoFactorChallenge, e, ht(t));
|
|
1303
1303
|
}
|
|
1304
1304
|
verifyV2(e, t) {
|
|
1305
1305
|
let { trust_device: n, ...r } = e;
|
|
1306
1306
|
return this.axiosClient.post(z.TwoFactorVerifyV2, {
|
|
1307
1307
|
...r,
|
|
1308
1308
|
...n ? { trust_device: !0 } : {}
|
|
1309
|
-
},
|
|
1309
|
+
}, gt(t));
|
|
1310
1310
|
}
|
|
1311
1311
|
switchToAlternative(e, t) {
|
|
1312
|
-
return this.axiosClient.post(z.TwoFactorAlternative, e,
|
|
1312
|
+
return this.axiosClient.post(z.TwoFactorAlternative, e, ht(t));
|
|
1313
1313
|
}
|
|
1314
1314
|
async getTrustedDevices() {
|
|
1315
1315
|
return (await this.axiosClient.get(z.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
|
|
@@ -1318,9 +1318,9 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1318
1318
|
let t = Be(z.TwoFactorTrustedDeviceRevoke, { id: e });
|
|
1319
1319
|
return this.axiosClient.delete(t);
|
|
1320
1320
|
}
|
|
1321
|
-
},
|
|
1321
|
+
}, bt = class {
|
|
1322
1322
|
constructor(e, t, n) {
|
|
1323
|
-
this.axiosClient = new
|
|
1323
|
+
this.axiosClient = new rt(e, t, n);
|
|
1324
1324
|
}
|
|
1325
1325
|
setAppId(e) {
|
|
1326
1326
|
this.axiosClient.setAppId(e);
|
|
@@ -1328,9 +1328,15 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1328
1328
|
startUpgrade(e) {
|
|
1329
1329
|
return this.axiosClient.post(z.upgradeStart, e, we({}));
|
|
1330
1330
|
}
|
|
1331
|
-
|
|
1331
|
+
startHostedUpgrade(e) {
|
|
1332
|
+
return this.axiosClient.post(z.hostedUpgradeStart, e, { withCredentials: !0 });
|
|
1333
|
+
}
|
|
1334
|
+
async commitHostedUpgrade(e) {
|
|
1335
|
+
await this.axiosClient.post(z.hostedUpgrade, e, { withCredentials: !0 });
|
|
1336
|
+
}
|
|
1337
|
+
}, xt = class {
|
|
1332
1338
|
constructor(e, t, n) {
|
|
1333
|
-
this.axiosClient = new
|
|
1339
|
+
this.axiosClient = new rt(e, t, n);
|
|
1334
1340
|
}
|
|
1335
1341
|
setAppId(e) {
|
|
1336
1342
|
this.axiosClient.setAppId(e);
|
|
@@ -1361,48 +1367,48 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1361
1367
|
passkey_data: e
|
|
1362
1368
|
});
|
|
1363
1369
|
}
|
|
1364
|
-
},
|
|
1370
|
+
}, St = 10, Ct = 20, wt = class extends Error {
|
|
1365
1371
|
constructor(e) {
|
|
1366
1372
|
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;
|
|
1367
1373
|
}
|
|
1368
|
-
},
|
|
1374
|
+
}, Tt = [], Et = 0, Dt = !1, Ot, kt, At = (e, t) => e.priority - t.priority || e.seq - t.seq, jt = () => typeof globalThis > "u" ? void 0 : globalThis, Mt = async (e, t, n, r) => {
|
|
1369
1375
|
if (t >= e.length) {
|
|
1370
|
-
let e =
|
|
1376
|
+
let e = Ot;
|
|
1371
1377
|
if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
|
|
1372
1378
|
return e(n, r);
|
|
1373
1379
|
}
|
|
1374
1380
|
let i = e[t];
|
|
1375
|
-
if (!i) return
|
|
1376
|
-
let a = !1, o = await i.middleware((n, r) => (a = !0,
|
|
1377
|
-
if (!a) throw new
|
|
1381
|
+
if (!i) return Mt(e, e.length, n, r);
|
|
1382
|
+
let a = !1, o = await i.middleware((n, r) => (a = !0, Mt(e, t + 1, n, r)), n, r);
|
|
1383
|
+
if (!a) throw new wt(i.name);
|
|
1378
1384
|
return o;
|
|
1379
|
-
}, Mt = () => {
|
|
1380
|
-
let e = At();
|
|
1381
|
-
if (!e || typeof e.fetch != "function") return !1;
|
|
1382
|
-
let t = e.fetch.bind(e), n = (e, t) => jt([...wt].sort(kt), 0, e, t);
|
|
1383
|
-
return Dt = t, Ot = n, e.fetch = n, Et = !0, !0;
|
|
1384
1385
|
}, Nt = () => {
|
|
1385
|
-
let e =
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1386
|
+
let e = jt();
|
|
1387
|
+
if (!e || typeof e.fetch != "function") return !1;
|
|
1388
|
+
let t = e.fetch.bind(e), n = (e, t) => Mt([...Tt].sort(At), 0, e, t);
|
|
1389
|
+
return Ot = t, kt = n, e.fetch = n, Dt = !0, !0;
|
|
1390
|
+
}, Pt = () => {
|
|
1391
|
+
let e = jt();
|
|
1392
|
+
e && kt && e.fetch === kt && (Ot && (e.fetch = Ot), Dt = !1, kt = void 0, Ot = void 0);
|
|
1393
|
+
}, Ft = (e, t) => {
|
|
1394
|
+
if (!Dt && !Nt()) return () => {};
|
|
1389
1395
|
let n = {
|
|
1390
1396
|
middleware: e,
|
|
1391
1397
|
name: t.name,
|
|
1392
1398
|
priority: t.priority,
|
|
1393
|
-
seq:
|
|
1399
|
+
seq: Et++
|
|
1394
1400
|
};
|
|
1395
|
-
|
|
1401
|
+
Tt.push(n);
|
|
1396
1402
|
let r = !1;
|
|
1397
1403
|
return () => {
|
|
1398
|
-
r || (r = !0,
|
|
1404
|
+
r || (r = !0, Tt = Tt.filter((e) => e !== n), Tt.length === 0 && Pt());
|
|
1399
1405
|
};
|
|
1400
|
-
},
|
|
1401
|
-
let e =
|
|
1406
|
+
}, It = () => {
|
|
1407
|
+
let e = jt();
|
|
1402
1408
|
return {
|
|
1403
|
-
installed:
|
|
1404
|
-
names: [...
|
|
1405
|
-
foreignPatch:
|
|
1409
|
+
installed: Dt,
|
|
1410
|
+
names: [...Tt].sort(At).map((e) => e.name),
|
|
1411
|
+
foreignPatch: Dt && !!e && !!kt && e.fetch !== kt
|
|
1406
1412
|
};
|
|
1407
1413
|
}, H = class e extends Error {
|
|
1408
1414
|
constructor(t) {
|
|
@@ -1473,7 +1479,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1473
1479
|
let e = `M2MError [${this.code}]: ${this.message}`;
|
|
1474
1480
|
return this.status && (e += ` (HTTP ${this.status})`), e;
|
|
1475
1481
|
}
|
|
1476
|
-
},
|
|
1482
|
+
}, Lt = class extends H {
|
|
1477
1483
|
constructor(e, t) {
|
|
1478
1484
|
super({
|
|
1479
1485
|
code: "temporarily_unavailable",
|
|
@@ -1482,7 +1488,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1482
1488
|
cause: t
|
|
1483
1489
|
}), this.name = "M2MNetworkError";
|
|
1484
1490
|
}
|
|
1485
|
-
},
|
|
1491
|
+
}, Rt = class extends H {
|
|
1486
1492
|
constructor(e, t) {
|
|
1487
1493
|
super({
|
|
1488
1494
|
code: "invalid_request",
|
|
@@ -1491,7 +1497,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1491
1497
|
cause: t
|
|
1492
1498
|
}), this.name = "M2MTokenParseError";
|
|
1493
1499
|
}
|
|
1494
|
-
},
|
|
1500
|
+
}, zt = class extends H {
|
|
1495
1501
|
constructor(e) {
|
|
1496
1502
|
super({
|
|
1497
1503
|
code: "invalid_request",
|
|
@@ -1499,7 +1505,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1499
1505
|
status: 400
|
|
1500
1506
|
}), this.name = "M2MConfigError";
|
|
1501
1507
|
}
|
|
1502
|
-
},
|
|
1508
|
+
}, Bt = {
|
|
1503
1509
|
InvalidRequest: "invalid_request",
|
|
1504
1510
|
InvalidClient: "invalid_client",
|
|
1505
1511
|
InvalidGrant: "invalid_grant",
|
|
@@ -1509,14 +1515,14 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1509
1515
|
RateLimitExceeded: "rate_limit_exceeded",
|
|
1510
1516
|
ServerError: "server_error",
|
|
1511
1517
|
TemporarilyUnavailable: "temporarily_unavailable"
|
|
1512
|
-
},
|
|
1518
|
+
}, Vt = {
|
|
1513
1519
|
TOKEN_ENDPOINT: "/oauth2/token",
|
|
1514
1520
|
TIMEOUT: 1e4,
|
|
1515
1521
|
RETRIES: 3,
|
|
1516
1522
|
RETRY_DELAY: 1e3,
|
|
1517
1523
|
REFRESH_THRESHOLD: 30,
|
|
1518
1524
|
CONTENT_TYPE: "application/x-www-form-urlencoded"
|
|
1519
|
-
},
|
|
1525
|
+
}, Ht = class {
|
|
1520
1526
|
constructor() {
|
|
1521
1527
|
this.cache = /* @__PURE__ */ new Map();
|
|
1522
1528
|
}
|
|
@@ -1533,18 +1539,18 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1533
1539
|
delete(e) {
|
|
1534
1540
|
return this.cache.delete(e), Promise.resolve();
|
|
1535
1541
|
}
|
|
1536
|
-
},
|
|
1542
|
+
}, Ut = {
|
|
1537
1543
|
shouldRetry(e, t) {
|
|
1538
1544
|
return t >= 3 ? !1 : e.code === "server_error" || e.code === "temporarily_unavailable" || e.code === "rate_limit_exceeded" || e.status !== void 0 && e.status >= 500;
|
|
1539
1545
|
},
|
|
1540
1546
|
getDelay(e) {
|
|
1541
1547
|
return 2 ** (e - 1) * 1e3;
|
|
1542
1548
|
}
|
|
1543
|
-
},
|
|
1549
|
+
}, Wt = class {
|
|
1544
1550
|
constructor(e) {
|
|
1545
|
-
if (!e.url) throw new
|
|
1546
|
-
if (!e.clientId) throw new
|
|
1547
|
-
if (!e.clientSecret) throw new
|
|
1551
|
+
if (!e.url) throw new zt("M2M client requires a URL");
|
|
1552
|
+
if (!e.clientId) throw new zt("M2M client requires a clientId");
|
|
1553
|
+
if (!e.clientSecret) throw new zt("M2M client requires a clientSecret");
|
|
1548
1554
|
let t = e.url.replace(/\/$/, "");
|
|
1549
1555
|
this.config = {
|
|
1550
1556
|
url: t,
|
|
@@ -1553,16 +1559,16 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1553
1559
|
scopes: e.scopes,
|
|
1554
1560
|
audience: e.audience,
|
|
1555
1561
|
autoRefresh: e.autoRefresh ?? !1,
|
|
1556
|
-
refreshThreshold: e.refreshThreshold ??
|
|
1557
|
-
timeout: e.timeout ??
|
|
1558
|
-
retries: e.retries ??
|
|
1559
|
-
retryDelay: e.retryDelay ??
|
|
1562
|
+
refreshThreshold: e.refreshThreshold ?? Vt.REFRESH_THRESHOLD,
|
|
1563
|
+
timeout: e.timeout ?? Vt.TIMEOUT,
|
|
1564
|
+
retries: e.retries ?? Vt.RETRIES,
|
|
1565
|
+
retryDelay: e.retryDelay ?? Vt.RETRY_DELAY,
|
|
1560
1566
|
retryStrategy: e.retryStrategy,
|
|
1561
1567
|
cache: e.cache,
|
|
1562
1568
|
onTokenRequest: e.onTokenRequest,
|
|
1563
1569
|
onTokenResponse: e.onTokenResponse,
|
|
1564
1570
|
onError: e.onError
|
|
1565
|
-
}, this.cache = e.cache ?? new
|
|
1571
|
+
}, this.cache = e.cache ?? new Ht(), this.retryStrategy = e.retryStrategy ?? Ut, this.tokenEndpoint = `${t}${Vt.TOKEN_ENDPOINT}`;
|
|
1566
1572
|
}
|
|
1567
1573
|
getCacheKey(e, t) {
|
|
1568
1574
|
let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
|
|
@@ -1607,7 +1613,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1607
1613
|
let e = await fetch(this.tokenEndpoint, {
|
|
1608
1614
|
method: "POST",
|
|
1609
1615
|
headers: {
|
|
1610
|
-
"Content-Type":
|
|
1616
|
+
"Content-Type": Vt.CONTENT_TYPE,
|
|
1611
1617
|
Accept: "application/json"
|
|
1612
1618
|
},
|
|
1613
1619
|
body: t.toString(),
|
|
@@ -1632,7 +1638,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1632
1638
|
}
|
|
1633
1639
|
return a;
|
|
1634
1640
|
} catch (e) {
|
|
1635
|
-
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new
|
|
1641
|
+
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new Lt(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new Lt(`Network error: ${e.message}`, e) : e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1636
1642
|
}
|
|
1637
1643
|
}
|
|
1638
1644
|
async executeWithRetry(e) {
|
|
@@ -1675,13 +1681,13 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1675
1681
|
parseToken(e) {
|
|
1676
1682
|
try {
|
|
1677
1683
|
let t = e.split(".");
|
|
1678
|
-
if (t.length !== 3) throw new
|
|
1684
|
+
if (t.length !== 3) throw new Rt("Invalid JWT format: expected 3 parts");
|
|
1679
1685
|
let n = t[1];
|
|
1680
|
-
if (!n) throw new
|
|
1686
|
+
if (!n) throw new Rt("Invalid JWT format: missing payload");
|
|
1681
1687
|
let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
|
|
1682
1688
|
return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
|
|
1683
1689
|
} catch (e) {
|
|
1684
|
-
throw e instanceof
|
|
1690
|
+
throw e instanceof Rt ? e : new Rt(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
1685
1691
|
}
|
|
1686
1692
|
}
|
|
1687
1693
|
clearCache() {
|
|
@@ -1696,7 +1702,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1696
1702
|
try {
|
|
1697
1703
|
let e = await fetch(t, {
|
|
1698
1704
|
method: "POST",
|
|
1699
|
-
headers: { "Content-Type":
|
|
1705
|
+
headers: { "Content-Type": Vt.CONTENT_TYPE },
|
|
1700
1706
|
body: n.toString()
|
|
1701
1707
|
});
|
|
1702
1708
|
if (!e.ok && e.status !== 200) {
|
|
@@ -1723,50 +1729,50 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1723
1729
|
get audience() {
|
|
1724
1730
|
return this.config.audience;
|
|
1725
1731
|
}
|
|
1726
|
-
},
|
|
1732
|
+
}, Gt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", Kt = 32, qt = (e) => {
|
|
1727
1733
|
let t = "";
|
|
1728
1734
|
for (let n = 0; n < e.length; n += 3) {
|
|
1729
1735
|
let r = e[n], i = e[n + 1], a = e[n + 2];
|
|
1730
|
-
t +=
|
|
1736
|
+
t += Gt.charAt(r >> 2), t += Gt.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += Gt.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += Gt.charAt(a & 63));
|
|
1731
1737
|
}
|
|
1732
1738
|
return t;
|
|
1733
|
-
},
|
|
1739
|
+
}, Jt = () => {
|
|
1734
1740
|
let e = globalThis.crypto;
|
|
1735
1741
|
if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1736
1742
|
return e;
|
|
1737
|
-
},
|
|
1738
|
-
let t = await
|
|
1739
|
-
return
|
|
1740
|
-
},
|
|
1741
|
-
let e =
|
|
1743
|
+
}, Yt = async (e) => {
|
|
1744
|
+
let t = await Jt().subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
1745
|
+
return qt(new Uint8Array(t));
|
|
1746
|
+
}, Xt = (e = Kt) => qt(Jt().getRandomValues(new Uint8Array(e))), Zt = async () => {
|
|
1747
|
+
let e = Xt(Kt);
|
|
1742
1748
|
return {
|
|
1743
1749
|
verifier: e,
|
|
1744
|
-
challenge: await
|
|
1750
|
+
challenge: await Yt(e)
|
|
1745
1751
|
};
|
|
1746
|
-
},
|
|
1752
|
+
}, Qt = () => !!globalThis.crypto?.subtle, U = class extends Error {
|
|
1747
1753
|
constructor(e, t) {
|
|
1748
1754
|
super(t), this.code = e, this.name = "PassflowOidcError";
|
|
1749
1755
|
}
|
|
1750
|
-
},
|
|
1756
|
+
}, $t = "Sign in again.", en = (e) => `This app is type ${e} and is a confidential client (it has a secret). For a browser app set its type to SPA; a server-side app redeems the code on its server with the secret.`, tn = "This app is a confidential client. For a browser app set its type to SPA (or token_endpoint_auth_method to none); a server-side app must redeem the code on its server with the client secret.", nn = () => new U("TOKENS_IN_URL_NOT_ALLOWED", "Tokens in the URL are accepted only for apps in Simple mode"), rn = "passflow_oidc_pkce", an = 6e5, on = (e) => {
|
|
1751
1757
|
try {
|
|
1752
1758
|
let t = new URL(e);
|
|
1753
1759
|
return `${t.protocol}//${t.host}${t.pathname.replace(/\/+$/, "")}`;
|
|
1754
1760
|
} catch {
|
|
1755
1761
|
return e;
|
|
1756
1762
|
}
|
|
1757
|
-
},
|
|
1758
|
-
if (!
|
|
1759
|
-
let t =
|
|
1763
|
+
}, sn = (e) => !e.includes("openid") && (e.includes("id") || e.includes("oidc")) ? [...e, "openid"] : [...e], cn = async (e) => {
|
|
1764
|
+
if (!Qt()) throw new U("SECURE_CONTEXT_REQUIRED", "Sign-in needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1765
|
+
let t = sn(e.scopes), n = await Zt(), r = {
|
|
1760
1766
|
verifier: n.verifier,
|
|
1761
|
-
state:
|
|
1762
|
-
...t.includes("openid") ? { nonce:
|
|
1767
|
+
state: Xt(),
|
|
1768
|
+
...t.includes("openid") ? { nonce: Xt() } : {},
|
|
1763
1769
|
clientId: e.clientId,
|
|
1764
1770
|
redirectUri: e.redirectUri,
|
|
1765
1771
|
scopes: t,
|
|
1766
|
-
expiresAt: Date.now() +
|
|
1772
|
+
expiresAt: Date.now() + an
|
|
1767
1773
|
};
|
|
1768
1774
|
try {
|
|
1769
|
-
sessionStorage.setItem(
|
|
1775
|
+
sessionStorage.setItem(rn, JSON.stringify(r));
|
|
1770
1776
|
} catch {
|
|
1771
1777
|
throw new U("STORAGE_UNAVAILABLE", "Sign-in needs sessionStorage, which cannot be written here");
|
|
1772
1778
|
}
|
|
@@ -1781,37 +1787,37 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1781
1787
|
code_challenge_method: "S256",
|
|
1782
1788
|
...r.nonce ? { nonce: r.nonce } : {}
|
|
1783
1789
|
}).toString(), i.toString();
|
|
1784
|
-
},
|
|
1790
|
+
}, ln = (e) => {
|
|
1785
1791
|
let t = e;
|
|
1786
1792
|
return typeof t == "object" && !!t && typeof t.verifier == "string" && typeof t.state == "string" && typeof t.clientId == "string" && typeof t.redirectUri == "string" && Array.isArray(t.scopes) && typeof t.expiresAt == "number";
|
|
1787
|
-
},
|
|
1793
|
+
}, un = () => {
|
|
1788
1794
|
let e;
|
|
1789
1795
|
try {
|
|
1790
|
-
e = sessionStorage.getItem(
|
|
1796
|
+
e = sessionStorage.getItem(rn);
|
|
1791
1797
|
} catch {
|
|
1792
1798
|
return { status: "none" };
|
|
1793
1799
|
}
|
|
1794
1800
|
if (!e) return { status: "none" };
|
|
1795
1801
|
try {
|
|
1796
1802
|
let t = JSON.parse(e);
|
|
1797
|
-
if (
|
|
1803
|
+
if (ln(t) && Date.now() < t.expiresAt) return {
|
|
1798
1804
|
status: "live",
|
|
1799
1805
|
slot: t
|
|
1800
1806
|
};
|
|
1801
1807
|
} catch {}
|
|
1802
1808
|
return { status: "unusable" };
|
|
1803
|
-
},
|
|
1809
|
+
}, dn = () => {
|
|
1804
1810
|
try {
|
|
1805
|
-
sessionStorage.removeItem(
|
|
1811
|
+
sessionStorage.removeItem(rn);
|
|
1806
1812
|
} catch {}
|
|
1807
|
-
},
|
|
1813
|
+
}, fn = async (e) => {
|
|
1808
1814
|
try {
|
|
1809
1815
|
let t = await e.json();
|
|
1810
1816
|
return typeof t == "object" && t ? t : void 0;
|
|
1811
1817
|
} catch {
|
|
1812
1818
|
return;
|
|
1813
1819
|
}
|
|
1814
|
-
},
|
|
1820
|
+
}, pn = async (e, t, n) => {
|
|
1815
1821
|
let r;
|
|
1816
1822
|
try {
|
|
1817
1823
|
r = await fetch(`${e.replace(/\/+$/, "")}/oidc/token`, {
|
|
@@ -1826,11 +1832,11 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1826
1832
|
}).toString()
|
|
1827
1833
|
});
|
|
1828
1834
|
} catch {
|
|
1829
|
-
throw new U("TOKEN_EXCHANGE_FAILED",
|
|
1835
|
+
throw new U("TOKEN_EXCHANGE_FAILED", $t);
|
|
1830
1836
|
}
|
|
1831
|
-
let i = await
|
|
1832
|
-
if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client",
|
|
1833
|
-
if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED",
|
|
1837
|
+
let i = await fn(r);
|
|
1838
|
+
if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client", tn) : i?.error === "invalid_grant" ? new U("invalid_grant", $t) : new U("TOKEN_EXCHANGE_FAILED", $t);
|
|
1839
|
+
if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED", $t);
|
|
1834
1840
|
let a = typeof i.id_token == "string" ? i.id_token : void 0;
|
|
1835
1841
|
if (n.scopes.includes("openid")) {
|
|
1836
1842
|
let e;
|
|
@@ -1839,7 +1845,7 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1839
1845
|
} catch {
|
|
1840
1846
|
e = void 0;
|
|
1841
1847
|
}
|
|
1842
|
-
if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${
|
|
1848
|
+
if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${$t}`);
|
|
1843
1849
|
}
|
|
1844
1850
|
return {
|
|
1845
1851
|
access_token: i.access_token,
|
|
@@ -1847,101 +1853,101 @@ var Ve = /* @__PURE__ */ function(e) {
|
|
|
1847
1853
|
...a ? { id_token: a } : {},
|
|
1848
1854
|
scopes: n.scopes
|
|
1849
1855
|
};
|
|
1850
|
-
},
|
|
1856
|
+
}, mn = "error", hn = /* @__PURE__ */ new WeakMap(), gn = (e, t) => {
|
|
1851
1857
|
if (typeof t != "object" && typeof t != "function" || t === null) return !0;
|
|
1852
|
-
let n =
|
|
1853
|
-
return n || (n = /* @__PURE__ */ new WeakSet(),
|
|
1854
|
-
}, W = (e, t) =>
|
|
1858
|
+
let n = hn.get(e);
|
|
1859
|
+
return n || (n = /* @__PURE__ */ new WeakSet(), hn.set(e, n)), !n.has(t) && (n.add(t), !0);
|
|
1860
|
+
}, W = (e, t) => gn(e, t.originalError) ? (e.notify(mn, t), !0) : !1, _n = "passflow-refresh", vn = "passflow-refresh-takeover", yn = "passflow-auth", bn = Object.freeze([
|
|
1855
1861
|
1e3,
|
|
1856
1862
|
3e3,
|
|
1857
1863
|
1e4,
|
|
1858
1864
|
3e4,
|
|
1859
1865
|
6e4
|
|
1860
|
-
]),
|
|
1866
|
+
]), xn = .2, Sn = 6e5, Cn = 5e3, G = 2e4, wn = 2e4, Tn = 1e3, En = 2e3, Dn = 1e3, On = 1e4, kn = 5e3;
|
|
1861
1867
|
// lib/refresh/protocol.ts
|
|
1862
|
-
function
|
|
1868
|
+
function An(e) {
|
|
1863
1869
|
let t = e ? `:${e}` : "";
|
|
1864
1870
|
return {
|
|
1865
|
-
lock: `${
|
|
1866
|
-
takeoverLock: `${
|
|
1867
|
-
channel: `${
|
|
1871
|
+
lock: `${_n}${t}`,
|
|
1872
|
+
takeoverLock: `${vn}${t}`,
|
|
1873
|
+
channel: `${yn}${t}`
|
|
1868
1874
|
};
|
|
1869
1875
|
}
|
|
1870
1876
|
function K(e) {
|
|
1871
1877
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
1872
1878
|
}
|
|
1873
|
-
function
|
|
1879
|
+
function jn(e) {
|
|
1874
1880
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
1875
1881
|
}
|
|
1876
|
-
function
|
|
1882
|
+
function Mn(e) {
|
|
1877
1883
|
return typeof e == "object" && !!e;
|
|
1878
1884
|
}
|
|
1879
|
-
function
|
|
1885
|
+
function Nn(e, t) {
|
|
1880
1886
|
for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
|
|
1881
1887
|
return e;
|
|
1882
1888
|
}
|
|
1883
|
-
function
|
|
1884
|
-
if (!
|
|
1889
|
+
function Pn(e) {
|
|
1890
|
+
if (!Mn(e)) return null;
|
|
1885
1891
|
let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
|
|
1886
|
-
return
|
|
1892
|
+
return Nn({}, {
|
|
1887
1893
|
access_token: K(e.access_token),
|
|
1888
1894
|
refresh_token: K(e.refresh_token),
|
|
1889
1895
|
id_token: K(e.id_token),
|
|
1890
1896
|
scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
|
|
1891
1897
|
});
|
|
1892
1898
|
}
|
|
1893
|
-
function
|
|
1894
|
-
if (!
|
|
1899
|
+
function Fn(e) {
|
|
1900
|
+
if (!Mn(e)) return null;
|
|
1895
1901
|
let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
|
|
1896
|
-
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 ||
|
|
1902
|
+
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || jn(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Nn({
|
|
1897
1903
|
kind: t,
|
|
1898
1904
|
attempt: n,
|
|
1899
1905
|
nextAt: r,
|
|
1900
1906
|
strikes: i
|
|
1901
1907
|
}, {
|
|
1902
1908
|
from: K(e.from),
|
|
1903
|
-
failingSince:
|
|
1909
|
+
failingSince: jn(e.failingSince)
|
|
1904
1910
|
});
|
|
1905
1911
|
}
|
|
1906
|
-
function
|
|
1907
|
-
return
|
|
1912
|
+
function In(e) {
|
|
1913
|
+
return Nn({}, {
|
|
1908
1914
|
fp: K(e.fp),
|
|
1909
1915
|
sub: K(e.sub),
|
|
1910
1916
|
sid: K(e.sid),
|
|
1911
|
-
iat:
|
|
1917
|
+
iat: jn(e.iat)
|
|
1912
1918
|
});
|
|
1913
1919
|
}
|
|
1914
|
-
function
|
|
1915
|
-
if (!
|
|
1920
|
+
function Ln(e) {
|
|
1921
|
+
if (!Mn(e)) return null;
|
|
1916
1922
|
let t = e;
|
|
1917
1923
|
if (t.v !== void 0 && t.v !== 1) return null;
|
|
1918
1924
|
let n = K(t.tabId);
|
|
1919
1925
|
if (!n) return null;
|
|
1920
1926
|
switch (t.type) {
|
|
1921
1927
|
case "tokens-refreshed": {
|
|
1922
|
-
let e =
|
|
1923
|
-
return !e || !r || !i ? null :
|
|
1928
|
+
let e = Pn(t.tokens), r = K(t.from), i = K(t.to);
|
|
1929
|
+
return !e || !r || !i ? null : Nn({
|
|
1924
1930
|
type: t.type,
|
|
1925
1931
|
tabId: n,
|
|
1926
1932
|
tokens: e,
|
|
1927
1933
|
from: r,
|
|
1928
1934
|
to: i
|
|
1929
1935
|
}, {
|
|
1930
|
-
fromIat:
|
|
1936
|
+
fromIat: jn(t.fromIat),
|
|
1931
1937
|
fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
|
|
1932
|
-
sentAt:
|
|
1938
|
+
sentAt: jn(t.sentAt)
|
|
1933
1939
|
});
|
|
1934
1940
|
}
|
|
1935
1941
|
case "session-refreshed": {
|
|
1936
|
-
let e =
|
|
1937
|
-
return e === void 0 ? null :
|
|
1942
|
+
let e = jn(t.at);
|
|
1943
|
+
return e === void 0 ? null : Nn({
|
|
1938
1944
|
type: t.type,
|
|
1939
1945
|
tabId: n,
|
|
1940
1946
|
at: e
|
|
1941
1947
|
}, { sub: K(t.sub) });
|
|
1942
1948
|
}
|
|
1943
1949
|
case "still-refreshing": {
|
|
1944
|
-
let e = t.retry === void 0 ? null :
|
|
1950
|
+
let e = t.retry === void 0 ? null : Fn(t.retry);
|
|
1945
1951
|
return e ? {
|
|
1946
1952
|
type: t.type,
|
|
1947
1953
|
tabId: n,
|
|
@@ -1952,7 +1958,7 @@ function In(e) {
|
|
|
1952
1958
|
};
|
|
1953
1959
|
}
|
|
1954
1960
|
case "retry-scheduled": {
|
|
1955
|
-
let e =
|
|
1961
|
+
let e = Fn(t);
|
|
1956
1962
|
return e ? {
|
|
1957
1963
|
type: t.type,
|
|
1958
1964
|
tabId: n,
|
|
@@ -1973,10 +1979,10 @@ function In(e) {
|
|
|
1973
1979
|
case "signed-out": return {
|
|
1974
1980
|
type: t.type,
|
|
1975
1981
|
tabId: n,
|
|
1976
|
-
...
|
|
1982
|
+
...In(t)
|
|
1977
1983
|
};
|
|
1978
1984
|
case "rate-limited": {
|
|
1979
|
-
let e =
|
|
1985
|
+
let e = jn(t.until);
|
|
1980
1986
|
return e === void 0 ? null : {
|
|
1981
1987
|
type: t.type,
|
|
1982
1988
|
tabId: n,
|
|
@@ -1995,22 +2001,22 @@ function In(e) {
|
|
|
1995
2001
|
default: return null;
|
|
1996
2002
|
}
|
|
1997
2003
|
}
|
|
1998
|
-
function
|
|
2004
|
+
function Rn(e, t) {
|
|
1999
2005
|
let n = {
|
|
2000
2006
|
v: 1,
|
|
2001
2007
|
tabId: e
|
|
2002
2008
|
};
|
|
2003
2009
|
if (t.type === "retry-scheduled") {
|
|
2004
2010
|
let { retry: e, ...r } = t;
|
|
2005
|
-
return
|
|
2011
|
+
return Nn(n, {
|
|
2006
2012
|
...r,
|
|
2007
2013
|
...e
|
|
2008
2014
|
});
|
|
2009
2015
|
}
|
|
2010
|
-
return
|
|
2016
|
+
return Nn(n, { ...t });
|
|
2011
2017
|
}
|
|
2012
2018
|
// lib/refresh/resolve.ts
|
|
2013
|
-
var
|
|
2019
|
+
var zn = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", Bn = {
|
|
2014
2020
|
now: () => Date.now(),
|
|
2015
2021
|
random: () => Math.random(),
|
|
2016
2022
|
setTimeout: (e, t) => {
|
|
@@ -2018,28 +2024,28 @@ var Rn = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
|
|
|
2018
2024
|
return n.unref?.(), () => clearTimeout(n);
|
|
2019
2025
|
}
|
|
2020
2026
|
};
|
|
2021
|
-
function
|
|
2027
|
+
function Vn() {
|
|
2022
2028
|
let e = globalThis.crypto;
|
|
2023
2029
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
2024
2030
|
}
|
|
2025
|
-
function
|
|
2031
|
+
function Hn(e) {
|
|
2026
2032
|
return e ? {
|
|
2027
2033
|
now: () => e.now(),
|
|
2028
2034
|
setTimeout: (t, n) => e.setTimeout(t, n),
|
|
2029
|
-
random: e.random ? () => e.random?.() ?? Math.random() :
|
|
2030
|
-
} :
|
|
2035
|
+
random: e.random ? () => e.random?.() ?? Math.random() : Bn.random
|
|
2036
|
+
} : Bn;
|
|
2031
2037
|
}
|
|
2032
|
-
function
|
|
2038
|
+
function Un(e) {
|
|
2033
2039
|
return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
|
|
2034
2040
|
}
|
|
2035
|
-
function
|
|
2041
|
+
function Wn(e) {
|
|
2036
2042
|
try {
|
|
2037
2043
|
return e.storageSharedAcrossTabs === !0;
|
|
2038
2044
|
} catch {
|
|
2039
2045
|
return !1;
|
|
2040
2046
|
}
|
|
2041
2047
|
}
|
|
2042
|
-
function
|
|
2048
|
+
function Gn() {
|
|
2043
2049
|
try {
|
|
2044
2050
|
let e = globalThis.navigator?.locks;
|
|
2045
2051
|
return e && typeof e.request == "function" ? e : void 0;
|
|
@@ -2047,7 +2053,7 @@ function Wn() {
|
|
|
2047
2053
|
return;
|
|
2048
2054
|
}
|
|
2049
2055
|
}
|
|
2050
|
-
function
|
|
2056
|
+
function Kn(e) {
|
|
2051
2057
|
return (t) => {
|
|
2052
2058
|
let n = (n) => {
|
|
2053
2059
|
let r = n.key;
|
|
@@ -2056,20 +2062,20 @@ function Gn(e) {
|
|
|
2056
2062
|
return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
|
|
2057
2063
|
};
|
|
2058
2064
|
}
|
|
2059
|
-
function
|
|
2065
|
+
function qn(e) {
|
|
2060
2066
|
return {
|
|
2061
2067
|
transports: null,
|
|
2062
|
-
names:
|
|
2063
|
-
clock:
|
|
2068
|
+
names: An(e),
|
|
2069
|
+
clock: Bn,
|
|
2064
2070
|
warnOnFirstCycle: !1
|
|
2065
2071
|
};
|
|
2066
2072
|
}
|
|
2067
|
-
function
|
|
2068
|
-
let i =
|
|
2073
|
+
function Jn(e, t, n, r) {
|
|
2074
|
+
let i = An(n), a = Un(t), o = a ? Kn(r.tokenKeys) : void 0, s = (e) => {
|
|
2069
2075
|
let t = {
|
|
2070
2076
|
transports: null,
|
|
2071
2077
|
names: i,
|
|
2072
|
-
clock:
|
|
2078
|
+
clock: Bn,
|
|
2073
2079
|
warnOnFirstCycle: e
|
|
2074
2080
|
};
|
|
2075
2081
|
return o && (t.onStorageChange = o), t;
|
|
@@ -2079,16 +2085,16 @@ function qn(e, t, n, r) {
|
|
|
2079
2085
|
transports: {
|
|
2080
2086
|
locks: e.locks,
|
|
2081
2087
|
channel: e.channel,
|
|
2082
|
-
tabId: e.tabId ??
|
|
2088
|
+
tabId: e.tabId ?? Vn()
|
|
2083
2089
|
},
|
|
2084
2090
|
names: i,
|
|
2085
|
-
clock:
|
|
2091
|
+
clock: Hn(e.clock),
|
|
2086
2092
|
warnOnFirstCycle: !1
|
|
2087
2093
|
};
|
|
2088
2094
|
return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
|
|
2089
2095
|
}
|
|
2090
|
-
if (e === "none" || !a || !
|
|
2091
|
-
let c =
|
|
2096
|
+
if (e === "none" || !a || !Wn(t)) return s(!1);
|
|
2097
|
+
let c = Gn();
|
|
2092
2098
|
if (!c || typeof BroadcastChannel != "function") return s(!0);
|
|
2093
2099
|
let l;
|
|
2094
2100
|
try {
|
|
@@ -2100,16 +2106,16 @@ function qn(e, t, n, r) {
|
|
|
2100
2106
|
transports: {
|
|
2101
2107
|
locks: c,
|
|
2102
2108
|
channel: l,
|
|
2103
|
-
tabId:
|
|
2109
|
+
tabId: Vn()
|
|
2104
2110
|
},
|
|
2105
2111
|
names: i,
|
|
2106
|
-
clock:
|
|
2112
|
+
clock: Bn,
|
|
2107
2113
|
warnOnFirstCycle: !1
|
|
2108
2114
|
};
|
|
2109
2115
|
return o && (u.onStorageChange = o), u;
|
|
2110
2116
|
}
|
|
2111
2117
|
// lib/services/logger.ts
|
|
2112
|
-
var
|
|
2118
|
+
var Yn = class {
|
|
2113
2119
|
error(e, ...t) {
|
|
2114
2120
|
console.error(e, ...t);
|
|
2115
2121
|
}
|
|
@@ -2123,10 +2129,10 @@ var Jn = class {
|
|
|
2123
2129
|
console.debug(e, ...t);
|
|
2124
2130
|
}
|
|
2125
2131
|
};
|
|
2126
|
-
function
|
|
2127
|
-
return new
|
|
2132
|
+
function Xn() {
|
|
2133
|
+
return new Yn();
|
|
2128
2134
|
}
|
|
2129
|
-
var
|
|
2135
|
+
var Zn = Object.freeze([
|
|
2130
2136
|
"error.token.invalid.error",
|
|
2131
2137
|
"error.api.token.parse.error",
|
|
2132
2138
|
"error.api.user.blocked",
|
|
@@ -2134,25 +2140,25 @@ var Xn = Object.freeze([
|
|
|
2134
2140
|
"error.validation.token.invalid.subject",
|
|
2135
2141
|
"error.not.found"
|
|
2136
2142
|
]);
|
|
2137
|
-
function
|
|
2143
|
+
function Qn(e) {
|
|
2138
2144
|
if (typeof e != "object" || !e) return;
|
|
2139
2145
|
let t = e;
|
|
2140
2146
|
return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
|
|
2141
2147
|
}
|
|
2142
|
-
function
|
|
2143
|
-
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(
|
|
2148
|
+
function $n(e, t) {
|
|
2149
|
+
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(Sn, Math.floor(e) * 1e3);
|
|
2144
2150
|
if (typeof e != "string") return;
|
|
2145
2151
|
let n = e.trim();
|
|
2146
2152
|
if (n === "") return;
|
|
2147
|
-
if (/^\d+$/.test(n)) return Math.min(
|
|
2153
|
+
if (/^\d+$/.test(n)) return Math.min(Sn, Number.parseInt(n, 10) * 1e3);
|
|
2148
2154
|
if (!/[a-z]/i.test(n)) return;
|
|
2149
2155
|
let r = Date.parse(n);
|
|
2150
|
-
if (!Number.isNaN(r)) return Math.min(
|
|
2156
|
+
if (!Number.isNaN(r)) return Math.min(Sn, Math.max(0, r - t));
|
|
2151
2157
|
}
|
|
2152
|
-
function
|
|
2158
|
+
function er(e) {
|
|
2153
2159
|
return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
|
|
2154
2160
|
}
|
|
2155
|
-
function
|
|
2161
|
+
function tr(e) {
|
|
2156
2162
|
if (typeof e.id == "string" && e.id !== "") return e.id;
|
|
2157
2163
|
let t = e.response?.data;
|
|
2158
2164
|
if (typeof t != "object" || !t) return;
|
|
@@ -2161,14 +2167,14 @@ function er(e) {
|
|
|
2161
2167
|
let r = n.id;
|
|
2162
2168
|
return typeof r == "string" && r !== "" ? r : void 0;
|
|
2163
2169
|
}
|
|
2164
|
-
function
|
|
2170
|
+
function nr(e, t = Date.now()) {
|
|
2165
2171
|
if (typeof e != "object" || !e) return { kind: "transient" };
|
|
2166
|
-
let n = e, r =
|
|
2172
|
+
let n = e, r = tr(n), i = er(n.response?.status) ?? er(n.status), a = {};
|
|
2167
2173
|
if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
|
|
2168
2174
|
kind: "blocked",
|
|
2169
2175
|
...a
|
|
2170
2176
|
};
|
|
2171
|
-
if (r !== void 0 &&
|
|
2177
|
+
if (r !== void 0 && Zn.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
|
|
2172
2178
|
kind: "auth",
|
|
2173
2179
|
...a
|
|
2174
2180
|
};
|
|
@@ -2176,7 +2182,7 @@ function tr(e, t = Date.now()) {
|
|
|
2176
2182
|
kind: "transient",
|
|
2177
2183
|
...a
|
|
2178
2184
|
};
|
|
2179
|
-
let o =
|
|
2185
|
+
let o = $n(n.retryAfter ?? Qn(n.response?.headers), t);
|
|
2180
2186
|
return o === void 0 ? {
|
|
2181
2187
|
kind: "transient",
|
|
2182
2188
|
...a
|
|
@@ -2186,19 +2192,19 @@ function tr(e, t = Date.now()) {
|
|
|
2186
2192
|
retryAfterMs: o
|
|
2187
2193
|
};
|
|
2188
2194
|
}
|
|
2189
|
-
function
|
|
2190
|
-
let r =
|
|
2191
|
-
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0),
|
|
2195
|
+
function rr(e, t, n) {
|
|
2196
|
+
let r = bn.length, i = bn[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? bn[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * xn * a);
|
|
2197
|
+
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), Sn) : 0);
|
|
2192
2198
|
}
|
|
2193
2199
|
// lib/refresh/coordinator.ts
|
|
2194
|
-
var
|
|
2200
|
+
var ir = {
|
|
2195
2201
|
onGranted: () => !1,
|
|
2196
2202
|
onLockLost: () => void 0,
|
|
2197
2203
|
onMessage: () => void 0
|
|
2198
2204
|
};
|
|
2199
|
-
function
|
|
2200
|
-
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o =
|
|
2201
|
-
g || n.postMessage(
|
|
2205
|
+
function ar(e) {
|
|
2206
|
+
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = ir, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
|
|
2207
|
+
g || n.postMessage(Rn(r, e));
|
|
2202
2208
|
}, v = () => s !== null && c === null, y = () => {
|
|
2203
2209
|
f?.(), f = null;
|
|
2204
2210
|
}, b = (e) => {
|
|
@@ -2213,7 +2219,7 @@ function ir(e) {
|
|
|
2213
2219
|
type: "still-refreshing",
|
|
2214
2220
|
retry: m
|
|
2215
2221
|
} : { type: "still-refreshing" }), S());
|
|
2216
|
-
},
|
|
2222
|
+
}, Cn);
|
|
2217
2223
|
}, C = () => {
|
|
2218
2224
|
y(), x(), u?.(), u = null;
|
|
2219
2225
|
let e = s;
|
|
@@ -2264,7 +2270,7 @@ function ir(e) {
|
|
|
2264
2270
|
});
|
|
2265
2271
|
}, ee = (e) => {
|
|
2266
2272
|
if (g) return;
|
|
2267
|
-
let t =
|
|
2273
|
+
let t = Ln(e.data);
|
|
2268
2274
|
if (t && t.tabId !== r) {
|
|
2269
2275
|
switch (t.type) {
|
|
2270
2276
|
case "still-refreshing":
|
|
@@ -2307,8 +2313,8 @@ function ir(e) {
|
|
|
2307
2313
|
}
|
|
2308
2314
|
};
|
|
2309
2315
|
}
|
|
2310
|
-
function
|
|
2311
|
-
let t =
|
|
2316
|
+
function or(e = "local") {
|
|
2317
|
+
let t = ir, n = !1, r = !1, i = 0, a = !1, o = () => {
|
|
2312
2318
|
n = !1, r = !1, i += 1;
|
|
2313
2319
|
};
|
|
2314
2320
|
return {
|
|
@@ -2356,7 +2362,7 @@ var q = {
|
|
|
2356
2362
|
successorTimeout: "error.refresh.successor_timeout",
|
|
2357
2363
|
identityChanged: "error.refresh.identity_changed",
|
|
2358
2364
|
disposed: "error.refresh.disposed"
|
|
2359
|
-
},
|
|
2365
|
+
}, sr = {
|
|
2360
2366
|
"error.refresh.unavailable": 503,
|
|
2361
2367
|
"error.refresh.auth_retry": 401,
|
|
2362
2368
|
"error.refresh.session_ended": 401,
|
|
@@ -2364,7 +2370,7 @@ var q = {
|
|
|
2364
2370
|
"error.refresh.successor_timeout": 401,
|
|
2365
2371
|
"error.refresh.identity_changed": 401,
|
|
2366
2372
|
"error.refresh.disposed": 499
|
|
2367
|
-
},
|
|
2373
|
+
}, cr = {
|
|
2368
2374
|
"error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
|
|
2369
2375
|
"error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
|
|
2370
2376
|
"error.refresh.session_ended": "The session has ended",
|
|
@@ -2376,19 +2382,19 @@ var q = {
|
|
|
2376
2382
|
constructor(e, t = {}) {
|
|
2377
2383
|
super({
|
|
2378
2384
|
id: e,
|
|
2379
|
-
message: t.message ??
|
|
2380
|
-
status:
|
|
2385
|
+
message: t.message ?? cr[e],
|
|
2386
|
+
status: sr[e],
|
|
2381
2387
|
location: "/auth/refresh",
|
|
2382
2388
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2383
2389
|
}), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
|
|
2384
2390
|
}
|
|
2385
|
-
},
|
|
2391
|
+
}, lr = class extends Error {
|
|
2386
2392
|
constructor(e, t) {
|
|
2387
2393
|
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;
|
|
2388
2394
|
}
|
|
2389
2395
|
};
|
|
2390
2396
|
// lib/refresh/lineage.ts
|
|
2391
|
-
function
|
|
2397
|
+
function ur(e) {
|
|
2392
2398
|
if (!e) return;
|
|
2393
2399
|
let t = 3735928559, n = 1103547991;
|
|
2394
2400
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -2397,24 +2403,24 @@ function lr(e) {
|
|
|
2397
2403
|
}
|
|
2398
2404
|
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);
|
|
2399
2405
|
}
|
|
2400
|
-
function
|
|
2406
|
+
function dr(e) {
|
|
2401
2407
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2402
2408
|
}
|
|
2403
2409
|
function Y(e) {
|
|
2404
|
-
let t =
|
|
2410
|
+
let t = ur(e);
|
|
2405
2411
|
if (!e || !t) return;
|
|
2406
2412
|
let n = {};
|
|
2407
2413
|
try {
|
|
2408
2414
|
let t = j(e);
|
|
2409
2415
|
typeof t == "object" && t && (n = t);
|
|
2410
2416
|
} catch {}
|
|
2411
|
-
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a =
|
|
2417
|
+
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = dr(n.sub), o = dr(n.sid);
|
|
2412
2418
|
return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
|
|
2413
2419
|
}
|
|
2414
|
-
var
|
|
2415
|
-
function
|
|
2420
|
+
var fr = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
|
|
2421
|
+
function pr(e = (e) => Xn().warn(e)) {
|
|
2416
2422
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
|
|
2417
|
-
a || (a = !0, e(
|
|
2423
|
+
a || (a = !0, e(fr));
|
|
2418
2424
|
}, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
|
|
2419
2425
|
if (!e) return;
|
|
2420
2426
|
if (e.iat === void 0) {
|
|
@@ -2455,16 +2461,16 @@ function fr(e = (e) => Yn().warn(e)) {
|
|
|
2455
2461
|
};
|
|
2456
2462
|
}
|
|
2457
2463
|
// lib/refresh/fence.ts
|
|
2458
|
-
var
|
|
2464
|
+
var mr = class extends Error {
|
|
2459
2465
|
constructor(e) {
|
|
2460
2466
|
super(e === "emptied" ? "The shared token storage was emptied" : "The stored refresh token belongs to an ended session"), this.name = "SessionEnded", this.cause = e;
|
|
2461
2467
|
}
|
|
2462
|
-
},
|
|
2468
|
+
}, hr = class extends Error {
|
|
2463
2469
|
constructor() {
|
|
2464
2470
|
super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
|
|
2465
2471
|
}
|
|
2466
2472
|
};
|
|
2467
|
-
function
|
|
2473
|
+
function gr(e) {
|
|
2468
2474
|
if (e) try {
|
|
2469
2475
|
let t = j(e).sub;
|
|
2470
2476
|
return typeof t == "string" && t !== "" ? t : void 0;
|
|
@@ -2473,20 +2479,20 @@ function hr(e) {
|
|
|
2473
2479
|
}
|
|
2474
2480
|
}
|
|
2475
2481
|
function X(e) {
|
|
2476
|
-
return
|
|
2482
|
+
return gr(e?.access_token) ?? gr(e?.refresh_token) ?? gr(e?.id_token);
|
|
2477
2483
|
}
|
|
2478
|
-
function
|
|
2484
|
+
function _r(e, t) {
|
|
2479
2485
|
return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
|
|
2480
2486
|
}
|
|
2481
|
-
function
|
|
2487
|
+
function vr(e) {
|
|
2482
2488
|
return typeof e == "object" && !!e;
|
|
2483
2489
|
}
|
|
2484
|
-
function
|
|
2485
|
-
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) =>
|
|
2490
|
+
function yr(e) {
|
|
2491
|
+
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => Xn().warn(e)), o = e.lineage ?? pr(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
|
|
2486
2492
|
let e = t.getTokens(), n = e?.refresh_token;
|
|
2487
2493
|
if (!n) return p = l, e;
|
|
2488
2494
|
p !== void 0 && (f = Math.max(f, p, m), p = void 0);
|
|
2489
|
-
let r =
|
|
2495
|
+
let r = ur(n) ?? "";
|
|
2490
2496
|
return r !== c?.fp && (c = {
|
|
2491
2497
|
fp: r,
|
|
2492
2498
|
seq: l
|
|
@@ -2519,7 +2525,7 @@ function vr(e) {
|
|
|
2519
2525
|
let t = E();
|
|
2520
2526
|
t === "wait" && e && (t = "end"), t !== "wait" && D(), t === "wait" && !h && (h = r(() => {
|
|
2521
2527
|
h = void 0, y()?.refresh_token ? P() : O(!0) === "end" && s?.("emptied");
|
|
2522
|
-
},
|
|
2528
|
+
}, En));
|
|
2523
2529
|
let n = t === "keep" ? T() : void 0;
|
|
2524
2530
|
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;
|
|
2525
2531
|
}, ee = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, k = (e) => {
|
|
@@ -2532,7 +2538,7 @@ function vr(e) {
|
|
|
2532
2538
|
return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
|
|
2533
2539
|
}, 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) => {
|
|
2534
2540
|
let t = b();
|
|
2535
|
-
t && t.fp !==
|
|
2541
|
+
t && t.fp !== ur(e.refresh_token) && o.retire(t), n.setTokensCache(e);
|
|
2536
2542
|
}, N = (e) => {
|
|
2537
2543
|
let t = y(), n = t?.refresh_token;
|
|
2538
2544
|
if (n === e.refreshToken) return null;
|
|
@@ -2543,7 +2549,7 @@ function vr(e) {
|
|
|
2543
2549
|
kind: "superseded",
|
|
2544
2550
|
adopted: !1
|
|
2545
2551
|
};
|
|
2546
|
-
let r =
|
|
2552
|
+
let r = gr(t.access_token) ?? gr(n);
|
|
2547
2553
|
if (e.sub && r && e.sub !== r) return {
|
|
2548
2554
|
kind: "identity-changed",
|
|
2549
2555
|
saved: !1
|
|
@@ -2583,22 +2589,22 @@ function vr(e) {
|
|
|
2583
2589
|
}, ne = !!s || !!e.onStoredSessionSeen, re = ne && e.onStorageChange ? e.onStorageChange(P) : void 0, ie = ne && e.onWake ? e.onWake(P) : void 0, F = () => {
|
|
2584
2590
|
let e = y();
|
|
2585
2591
|
if (!e?.refresh_token) {
|
|
2586
|
-
if (O() === "end") throw new
|
|
2592
|
+
if (O() === "end") throw new mr("emptied");
|
|
2587
2593
|
return "held";
|
|
2588
2594
|
}
|
|
2589
2595
|
let t = n.getTokens();
|
|
2590
2596
|
if (e.refresh_token === t?.refresh_token) return "send";
|
|
2591
2597
|
let r = i() ?? X(t), a = X(e);
|
|
2592
|
-
if (r && a && r !== a) throw new
|
|
2598
|
+
if (r && a && r !== a) throw new hr();
|
|
2593
2599
|
let s = Y(e.refresh_token);
|
|
2594
2600
|
if (o.isEnded(s)) {
|
|
2595
2601
|
if (s && C(s)) return "held";
|
|
2596
|
-
throw new
|
|
2602
|
+
throw new mr("ended");
|
|
2597
2603
|
}
|
|
2598
2604
|
let c = Y(t?.refresh_token);
|
|
2599
2605
|
return j(s, c) ? (M(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && k(s) ? "held" : "send";
|
|
2600
2606
|
}, ae = (e) => {
|
|
2601
|
-
let t = i(), r =
|
|
2607
|
+
let t = i(), r = gr(e);
|
|
2602
2608
|
if (t && r && t !== r) return { kind: "identity-changed" };
|
|
2603
2609
|
let a = Y(e) ?? { fp: e };
|
|
2604
2610
|
if (o.isEnded(a)) return C(a) ? { kind: "superseded" } : { kind: "ended" };
|
|
@@ -2606,7 +2612,7 @@ function vr(e) {
|
|
|
2606
2612
|
let s = {
|
|
2607
2613
|
refreshToken: e,
|
|
2608
2614
|
order: a
|
|
2609
|
-
}, c = t ?? r ??
|
|
2615
|
+
}, c = t ?? r ?? gr(n.getTokens()?.access_token);
|
|
2610
2616
|
return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
|
|
2611
2617
|
kind: "send",
|
|
2612
2618
|
sent: s
|
|
@@ -2615,7 +2621,7 @@ function vr(e) {
|
|
|
2615
2621
|
if (o.isEnded(e.order)) return te(e.order);
|
|
2616
2622
|
let i = N(e);
|
|
2617
2623
|
if (i) return i;
|
|
2618
|
-
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 ${
|
|
2624
|
+
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 ${ur(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.`), {
|
|
2619
2625
|
kind: "superseded",
|
|
2620
2626
|
adopted: !1
|
|
2621
2627
|
};
|
|
@@ -2625,7 +2631,7 @@ function vr(e) {
|
|
|
2625
2631
|
saved: !0
|
|
2626
2632
|
};
|
|
2627
2633
|
let c = Y(r.refresh_token);
|
|
2628
|
-
return c && (
|
|
2634
|
+
return c && (_r(c, e.order) || _r(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.`), {
|
|
2629
2635
|
kind: "superseded",
|
|
2630
2636
|
adopted: !1
|
|
2631
2637
|
}) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
|
|
@@ -2637,7 +2643,7 @@ function vr(e) {
|
|
|
2637
2643
|
kind: "superseded",
|
|
2638
2644
|
adopted: !1
|
|
2639
2645
|
};
|
|
2640
|
-
let r =
|
|
2646
|
+
let r = nr(t), i = r.kind === "blocked" || r.kind === "auth";
|
|
2641
2647
|
return ee(e) && i ? (o.retire(e.order), _ = e.order, {
|
|
2642
2648
|
kind: "own",
|
|
2643
2649
|
failure: r,
|
|
@@ -2648,11 +2654,11 @@ function vr(e) {
|
|
|
2648
2654
|
heldRefused: !1
|
|
2649
2655
|
});
|
|
2650
2656
|
}, se = (e) => {
|
|
2651
|
-
if (!
|
|
2657
|
+
if (!vr(e)) return !1;
|
|
2652
2658
|
let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
|
|
2653
|
-
if (typeof t != "string" || typeof c != "string" || !
|
|
2659
|
+
if (typeof t != "string" || typeof c != "string" || !vr(l)) return !1;
|
|
2654
2660
|
let u = l;
|
|
2655
|
-
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" ||
|
|
2661
|
+
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || ur(u.refresh_token) !== c) return !1;
|
|
2656
2662
|
let d = y();
|
|
2657
2663
|
if (!d?.refresh_token) return !1;
|
|
2658
2664
|
let f = n.getTokens(), p = i() ?? X(f), m = X(u);
|
|
@@ -2669,7 +2675,7 @@ function vr(e) {
|
|
|
2669
2675
|
}
|
|
2670
2676
|
return !0;
|
|
2671
2677
|
};
|
|
2672
|
-
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t &&
|
|
2678
|
+
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && ur(d.refresh_token) !== c ? !1 : (M({ ...u }), _());
|
|
2673
2679
|
}, L = (e) => {
|
|
2674
2680
|
if (!e || !_) return !1;
|
|
2675
2681
|
let t = _;
|
|
@@ -2735,7 +2741,7 @@ function vr(e) {
|
|
|
2735
2741
|
};
|
|
2736
2742
|
}
|
|
2737
2743
|
// lib/refresh/controller.ts
|
|
2738
|
-
function
|
|
2744
|
+
function br() {
|
|
2739
2745
|
let e, t, n = new Promise((n, r) => {
|
|
2740
2746
|
e = n, t = r;
|
|
2741
2747
|
});
|
|
@@ -2745,7 +2751,7 @@ function yr() {
|
|
|
2745
2751
|
reject: t
|
|
2746
2752
|
};
|
|
2747
2753
|
}
|
|
2748
|
-
var
|
|
2754
|
+
var xr = {
|
|
2749
2755
|
strikes: q.sessionEnded,
|
|
2750
2756
|
"session-ended": q.sessionEnded,
|
|
2751
2757
|
"stored-ended": q.sessionEnded,
|
|
@@ -2756,42 +2762,42 @@ var br = {
|
|
|
2756
2762
|
"identity-changed": q.identityChanged,
|
|
2757
2763
|
disposed: q.disposed
|
|
2758
2764
|
};
|
|
2759
|
-
function
|
|
2765
|
+
function Sr(e) {
|
|
2760
2766
|
throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
|
|
2761
2767
|
}
|
|
2762
|
-
function
|
|
2768
|
+
function Cr(e) {
|
|
2763
2769
|
if (e === void 0 || !Number.isFinite(e)) return 3;
|
|
2764
2770
|
let t = Math.floor(e);
|
|
2765
2771
|
return t >= 1 ? t : 3;
|
|
2766
2772
|
}
|
|
2767
|
-
function
|
|
2773
|
+
function wr(e, t) {
|
|
2768
2774
|
return e instanceof Error && e.message ? e.message : t;
|
|
2769
2775
|
}
|
|
2770
|
-
function
|
|
2776
|
+
function Tr(e) {
|
|
2771
2777
|
if (typeof e != "object" || !e) return;
|
|
2772
2778
|
let t = e.id;
|
|
2773
2779
|
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
2774
2780
|
}
|
|
2775
|
-
function
|
|
2781
|
+
function Er(e) {
|
|
2776
2782
|
let t = {};
|
|
2777
2783
|
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;
|
|
2778
2784
|
}
|
|
2779
|
-
function
|
|
2785
|
+
function Dr(e, t) {
|
|
2780
2786
|
let n = {};
|
|
2781
2787
|
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);
|
|
2782
2788
|
let r = t?.scopes ?? e.scopes;
|
|
2783
2789
|
return r && (n.scopes = r), n;
|
|
2784
2790
|
}
|
|
2785
|
-
function
|
|
2786
|
-
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ??
|
|
2791
|
+
function Or(e) {
|
|
2792
|
+
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? Xn(), c = Cr(e.strikes), l = a.transports ? ar({
|
|
2787
2793
|
locks: a.transports.locks,
|
|
2788
2794
|
channel: a.transports.channel,
|
|
2789
2795
|
tabId: a.transports.tabId,
|
|
2790
2796
|
names: a.names,
|
|
2791
2797
|
clock: o
|
|
2792
|
-
}) :
|
|
2798
|
+
}) : or(), 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 = () => ur(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) => () => {
|
|
2793
2799
|
for (let t of Array.from(e)) t();
|
|
2794
|
-
}, N = a.onStorageChange?.(M(A)), te = e.platform?.onForeground(M(j)), P =
|
|
2800
|
+
}, N = a.onStorageChange?.(M(A)), te = e.platform?.onForeground(M(j)), P = yr({
|
|
2795
2801
|
storage: n,
|
|
2796
2802
|
cache: r,
|
|
2797
2803
|
identity: k,
|
|
@@ -2806,13 +2812,13 @@ function Dr(e) {
|
|
|
2806
2812
|
}), ne = (e) => ({
|
|
2807
2813
|
trigger: e,
|
|
2808
2814
|
startedAt: T(),
|
|
2809
|
-
plain:
|
|
2815
|
+
plain: br(),
|
|
2810
2816
|
fresh: []
|
|
2811
2817
|
}), re = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, ie = (e, t) => {
|
|
2812
2818
|
if (t === void 0) return e.plain.promise;
|
|
2813
2819
|
let n = {
|
|
2814
2820
|
callTime: t,
|
|
2815
|
-
deferred:
|
|
2821
|
+
deferred: br()
|
|
2816
2822
|
};
|
|
2817
2823
|
return e.fresh.push(n), n.deferred.promise;
|
|
2818
2824
|
}, F = (e, t, n = !1) => {
|
|
@@ -2831,11 +2837,11 @@ function Dr(e) {
|
|
|
2831
2837
|
}
|
|
2832
2838
|
}, I = (e, n, r, i) => {
|
|
2833
2839
|
let a = {
|
|
2834
|
-
message:
|
|
2840
|
+
message: wr(r, "Token refresh failed"),
|
|
2835
2841
|
originalError: r,
|
|
2836
2842
|
operation: e,
|
|
2837
2843
|
source: n
|
|
2838
|
-
}, o =
|
|
2844
|
+
}, o = Tr(r);
|
|
2839
2845
|
o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
|
|
2840
2846
|
}, se = (e, t) => {
|
|
2841
2847
|
let n = {
|
|
@@ -2865,10 +2871,10 @@ function Dr(e) {
|
|
|
2865
2871
|
};
|
|
2866
2872
|
n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
|
|
2867
2873
|
}, le = (e, t) => {
|
|
2868
|
-
let n = r.getTokens(), i =
|
|
2874
|
+
let n = r.getTokens(), i = ur(n?.refresh_token);
|
|
2869
2875
|
e.fp && i && l.post({
|
|
2870
2876
|
type: "tokens-refreshed",
|
|
2871
|
-
tokens:
|
|
2877
|
+
tokens: Er(n),
|
|
2872
2878
|
from: e.fp,
|
|
2873
2879
|
...e.iat === void 0 ? {} : { fromIat: e.iat },
|
|
2874
2880
|
fromSid: e.sid ?? "",
|
|
@@ -2876,7 +2882,7 @@ function Dr(e) {
|
|
|
2876
2882
|
...t === void 0 ? {} : { sentAt: t }
|
|
2877
2883
|
});
|
|
2878
2884
|
}, ue = () => {
|
|
2879
|
-
p || (p = !0, s.warn(
|
|
2885
|
+
p || (p = !0, s.warn(zn));
|
|
2880
2886
|
}, de = (e) => {
|
|
2881
2887
|
(e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
|
|
2882
2888
|
}, R = (e, n) => {
|
|
@@ -2890,7 +2896,7 @@ function Dr(e) {
|
|
|
2890
2896
|
}, e !== "disposed" && P.dropSession(), (e === "strikes" || e === "successor-timeout") && E() !== "json" && i.invalidate(), u = {
|
|
2891
2897
|
kind: "ended",
|
|
2892
2898
|
cause: e
|
|
2893
|
-
}, oe(r, n ?? new J(
|
|
2899
|
+
}, oe(r, n ?? new J(xr[e])), e) {
|
|
2894
2900
|
case "strikes":
|
|
2895
2901
|
t("session:expired", {
|
|
2896
2902
|
reason: "refresh_failed",
|
|
@@ -2925,7 +2931,7 @@ function Dr(e) {
|
|
|
2925
2931
|
break;
|
|
2926
2932
|
case "signed-out-here":
|
|
2927
2933
|
case "disposed": break;
|
|
2928
|
-
default:
|
|
2934
|
+
default: Sr(e);
|
|
2929
2935
|
}
|
|
2930
2936
|
}, fe = () => {
|
|
2931
2937
|
if (u.kind !== "ended" || u.cause === "disposed" || f || E() !== "json") return;
|
|
@@ -2942,10 +2948,10 @@ function Dr(e) {
|
|
|
2942
2948
|
}, pe = (e) => {
|
|
2943
2949
|
u.kind === "ended" || f || E() === "json" && (R(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && fe());
|
|
2944
2950
|
}, me = (e) => {
|
|
2945
|
-
e instanceof
|
|
2951
|
+
e instanceof hr ? (R("identity-changed"), fe()) : e instanceof mr ? R(e.cause === "emptied" ? "emptied" : "stored-ended") : R("stored-ended", e);
|
|
2946
2952
|
}, he = () => {
|
|
2947
2953
|
u = { kind: "idle" }, w || l.release();
|
|
2948
|
-
}, ge = (e) => !e.from || E() !== "json" || e.from === D() || e.from ===
|
|
2954
|
+
}, ge = (e) => !e.from || E() !== "json" || e.from === D() || e.from === ur(n.getTokens()?.refresh_token), _e = (e) => {
|
|
2949
2955
|
let t = g;
|
|
2950
2956
|
if (!t) return;
|
|
2951
2957
|
if (!l.holding) {
|
|
@@ -3011,14 +3017,14 @@ function Dr(e) {
|
|
|
3011
3017
|
case "ended": return P.endHeldSend(), R("stored-ended"), !1;
|
|
3012
3018
|
case "identity-changed": return P.endHeldSend(), R("identity-changed"), fe(), !1;
|
|
3013
3019
|
case "send": return Ce(e, t, a.sent, r);
|
|
3014
|
-
default: return
|
|
3020
|
+
default: return Sr(a);
|
|
3015
3021
|
}
|
|
3016
3022
|
}, Ce = (e, n, r, a) => {
|
|
3017
3023
|
let o = {
|
|
3018
3024
|
generation: d,
|
|
3019
3025
|
sentAt: T(),
|
|
3020
3026
|
trigger: n,
|
|
3021
|
-
settled:
|
|
3027
|
+
settled: br()
|
|
3022
3028
|
};
|
|
3023
3029
|
r ? o.sent = r : o.marker = ee(), a && (o.stored = a), u = {
|
|
3024
3030
|
kind: "refreshing",
|
|
@@ -3055,7 +3061,7 @@ function Dr(e) {
|
|
|
3055
3061
|
if (!we(e)) return;
|
|
3056
3062
|
r.setTokensCache({
|
|
3057
3063
|
...n.getTokens() ?? {},
|
|
3058
|
-
...
|
|
3064
|
+
...Dr(t, void 0)
|
|
3059
3065
|
}), L("refresh", "this-tab");
|
|
3060
3066
|
let c = k();
|
|
3061
3067
|
l.post(c === void 0 ? {
|
|
@@ -3068,7 +3074,7 @@ function Dr(e) {
|
|
|
3068
3074
|
}), he(), F(a, e.sentAt);
|
|
3069
3075
|
return;
|
|
3070
3076
|
}
|
|
3071
|
-
let o = D(), s = P.commitSave(e.sent,
|
|
3077
|
+
let o = D(), s = P.commitSave(e.sent, Dr(t, e.stored));
|
|
3072
3078
|
switch (s.kind) {
|
|
3073
3079
|
case "saved":
|
|
3074
3080
|
L("refresh", "this-tab"), le(e.sent.order, e.sentAt), he(), F(a, e.sentAt);
|
|
@@ -3086,7 +3092,7 @@ function Dr(e) {
|
|
|
3086
3092
|
I("refresh", e.trigger, t, se("auth")), R("identity-changed", t), fe();
|
|
3087
3093
|
return;
|
|
3088
3094
|
}
|
|
3089
|
-
default:
|
|
3095
|
+
default: Sr(s);
|
|
3090
3096
|
}
|
|
3091
3097
|
}, Ee = (e, t) => {
|
|
3092
3098
|
if (e.sent?.held && P.endHeldSend(), !we(e) || u.kind !== "refreshing") return;
|
|
@@ -3106,9 +3112,9 @@ function Dr(e) {
|
|
|
3106
3112
|
case "own":
|
|
3107
3113
|
r = o.failure, i = o.heldRefused;
|
|
3108
3114
|
break;
|
|
3109
|
-
default:
|
|
3115
|
+
default: Sr(o);
|
|
3110
3116
|
}
|
|
3111
|
-
} else r =
|
|
3117
|
+
} else r = nr(t, T());
|
|
3112
3118
|
if (i) I("refresh", e.trigger, t, se(r.kind)), L("adopted", "other-tab"), he(), F(n, void 0, !0);
|
|
3113
3119
|
else switch (r.kind) {
|
|
3114
3120
|
case "blocked":
|
|
@@ -3124,10 +3130,10 @@ function Dr(e) {
|
|
|
3124
3130
|
case "transient":
|
|
3125
3131
|
m += 1, De(e, n, t, r);
|
|
3126
3132
|
return;
|
|
3127
|
-
default:
|
|
3133
|
+
default: Sr(r.kind);
|
|
3128
3134
|
}
|
|
3129
3135
|
}, De = (e, t, n, r) => {
|
|
3130
|
-
let i = T() +
|
|
3136
|
+
let i = T() + rr(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
|
|
3131
3137
|
I("refresh", e.trigger, n, se(a, i)), a === "transient" && ce(T(), i, "this-tab");
|
|
3132
3138
|
let s = {
|
|
3133
3139
|
kind: a,
|
|
@@ -3137,7 +3143,7 @@ function Dr(e) {
|
|
|
3137
3143
|
}, c = e.sent?.order.fp;
|
|
3138
3144
|
c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
|
|
3139
3145
|
type: "retry-scheduled",
|
|
3140
|
-
message:
|
|
3146
|
+
message: wr(n, "Token refresh failed"),
|
|
3141
3147
|
retry: s
|
|
3142
3148
|
}), _e(ne("retry")), ae(t, n, e.sentAt);
|
|
3143
3149
|
}, Oe = (e, t) => {
|
|
@@ -3150,8 +3156,8 @@ function Dr(e) {
|
|
|
3150
3156
|
fp: i.fp
|
|
3151
3157
|
})), r && P.deleteIfStillDead(r), R("strikes", t);
|
|
3152
3158
|
}, z = (e, t, n, r) => {
|
|
3153
|
-
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${
|
|
3154
|
-
let i = d, a = T() +
|
|
3159
|
+
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${wr(n, "blocked")}`);
|
|
3160
|
+
let i = d, a = T() + wn, c = {
|
|
3155
3161
|
kind: "blocked-wait",
|
|
3156
3162
|
pending: e,
|
|
3157
3163
|
deadline: a,
|
|
@@ -3164,9 +3170,9 @@ function Dr(e) {
|
|
|
3164
3170
|
i === d && u === c && (B() || (f ? (e.cookieRetried = !0, u = {
|
|
3165
3171
|
kind: "waiting",
|
|
3166
3172
|
pending: e
|
|
3167
|
-
}, 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,
|
|
3173
|
+
}, 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, Tn)));
|
|
3168
3174
|
};
|
|
3169
|
-
c.cancel = o.setTimeout(p, f ?
|
|
3175
|
+
c.cancel = o.setTimeout(p, f ? Dn : Tn);
|
|
3170
3176
|
}, B = () => {
|
|
3171
3177
|
if (u.kind !== "blocked-wait") return !1;
|
|
3172
3178
|
let e = u;
|
|
@@ -3210,7 +3216,7 @@ function Dr(e) {
|
|
|
3210
3216
|
case "idle":
|
|
3211
3217
|
case "refreshing":
|
|
3212
3218
|
case "ended": return;
|
|
3213
|
-
default:
|
|
3219
|
+
default: Sr(u);
|
|
3214
3220
|
}
|
|
3215
3221
|
}, V = (e) => {
|
|
3216
3222
|
let t = {};
|
|
@@ -3253,7 +3259,7 @@ function Dr(e) {
|
|
|
3253
3259
|
je(e.retry, !0, e.message), Pe();
|
|
3254
3260
|
return;
|
|
3255
3261
|
case "refresh-failed":
|
|
3256
|
-
if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !==
|
|
3262
|
+
if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !== ur(n.getTokens()?.refresh_token)) return;
|
|
3257
3263
|
if (ce(T(), void 0, "other-tab"), u.kind === "waiting") {
|
|
3258
3264
|
let t = u.pending;
|
|
3259
3265
|
u.pending = ne(t.trigger), ae(t, new J(q.unavailable, { cause: e.message }), void 0);
|
|
@@ -3274,7 +3280,7 @@ function Dr(e) {
|
|
|
3274
3280
|
return;
|
|
3275
3281
|
case "takeover":
|
|
3276
3282
|
case "rate-limited": return;
|
|
3277
|
-
default:
|
|
3283
|
+
default: Sr(e);
|
|
3278
3284
|
}
|
|
3279
3285
|
}, Pe = () => {
|
|
3280
3286
|
C && !l.holding && l.post({
|
|
@@ -3339,7 +3345,7 @@ function Dr(e) {
|
|
|
3339
3345
|
case "refreshing":
|
|
3340
3346
|
case "backoff":
|
|
3341
3347
|
case "blocked-wait": return ie(u.pending, t);
|
|
3342
|
-
default: return
|
|
3348
|
+
default: return Sr(u);
|
|
3343
3349
|
}
|
|
3344
3350
|
}, Le = (e) => {
|
|
3345
3351
|
if (f) return Promise.reject(new J(q.disposed));
|
|
@@ -3390,9 +3396,9 @@ function Dr(e) {
|
|
|
3390
3396
|
}, He = async (e, t) => {
|
|
3391
3397
|
if (f) throw new J(q.disposed);
|
|
3392
3398
|
ue();
|
|
3393
|
-
let n = T() +
|
|
3399
|
+
let n = T() + On;
|
|
3394
3400
|
if (await Be(n - T()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await ze("commit", n - T())) === "timeout") {
|
|
3395
|
-
let e = new
|
|
3401
|
+
let e = new lr("lock-timeout");
|
|
3396
3402
|
throw I("upgrade.commit", "upgrade", e), e;
|
|
3397
3403
|
}
|
|
3398
3404
|
w = !0;
|
|
@@ -3439,7 +3445,7 @@ function Dr(e) {
|
|
|
3439
3445
|
if (!o) {
|
|
3440
3446
|
await i.applyOpaque(u), r.setTokensCache({
|
|
3441
3447
|
...n.getTokens() ?? {},
|
|
3442
|
-
...
|
|
3448
|
+
...Dr(u, void 0)
|
|
3443
3449
|
}), We(c);
|
|
3444
3450
|
let e = k();
|
|
3445
3451
|
return l.post(e === void 0 ? {
|
|
@@ -3451,9 +3457,9 @@ function Dr(e) {
|
|
|
3451
3457
|
sub: e
|
|
3452
3458
|
}), O();
|
|
3453
3459
|
}
|
|
3454
|
-
let d = P.commitSave(o,
|
|
3460
|
+
let d = P.commitSave(o, Dr(u, s));
|
|
3455
3461
|
if (d.kind === "saved") return We(c), le(o.order, c), O();
|
|
3456
|
-
let f = new
|
|
3462
|
+
let f = new lr("superseded");
|
|
3457
3463
|
throw I("upgrade.commit", "upgrade", f), d.kind === "superseded" && d.adopted && L("adopted", "other-tab"), f;
|
|
3458
3464
|
}, We = (e) => {
|
|
3459
3465
|
if (L("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
|
|
@@ -3479,7 +3485,7 @@ function Dr(e) {
|
|
|
3479
3485
|
commitUpgrade: He,
|
|
3480
3486
|
signOut: async (e) => {
|
|
3481
3487
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3482
|
-
let t = T() +
|
|
3488
|
+
let t = T() + kn;
|
|
3483
3489
|
Ke(), await Be(t - T()), Ke(), l.coordinated && !l.holding && await ze("logout", t - T());
|
|
3484
3490
|
try {
|
|
3485
3491
|
Ge(), await e(n.getTokens()?.refresh_token);
|
|
@@ -3524,7 +3530,7 @@ function Dr(e) {
|
|
|
3524
3530
|
// lib/store.ts
|
|
3525
3531
|
var Z = /* @__PURE__ */ function(e) {
|
|
3526
3532
|
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;
|
|
3527
|
-
}({}),
|
|
3533
|
+
}({}), kr = class {
|
|
3528
3534
|
constructor() {
|
|
3529
3535
|
this.subscribers = /* @__PURE__ */ new Map();
|
|
3530
3536
|
}
|
|
@@ -3543,14 +3549,14 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3543
3549
|
n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
|
|
3544
3550
|
}
|
|
3545
3551
|
notify(e, t) {
|
|
3546
|
-
e === "error" &&
|
|
3552
|
+
e === "error" && gn(this, t?.originalError), this.subscribers.forEach((n, r) => {
|
|
3547
3553
|
(!n || n.has(e)) && r.onAuthChange?.(e, t);
|
|
3548
3554
|
});
|
|
3549
3555
|
}
|
|
3550
3556
|
notifyError(e) {
|
|
3551
3557
|
return W(this, e);
|
|
3552
3558
|
}
|
|
3553
|
-
},
|
|
3559
|
+
}, Ar = {
|
|
3554
3560
|
ES256: {
|
|
3555
3561
|
kty: "EC",
|
|
3556
3562
|
key: (e) => ({
|
|
@@ -3581,34 +3587,34 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3581
3587
|
},
|
|
3582
3588
|
signature: { name: "RSASSA-PKCS1-v1_5" }
|
|
3583
3589
|
}
|
|
3584
|
-
},
|
|
3590
|
+
}, jr = (e) => {
|
|
3585
3591
|
let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = globalThis.atob(t + "=".repeat((4 - t.length % 4) % 4));
|
|
3586
3592
|
return Uint8Array.from(n, (e) => e.charCodeAt(0));
|
|
3587
|
-
},
|
|
3593
|
+
}, Mr = () => {
|
|
3588
3594
|
let e = globalThis.crypto;
|
|
3589
3595
|
if (!e?.subtle) throw Error("Verifying tokens needs the Web Crypto API, available only in a secure context (https or localhost)");
|
|
3590
3596
|
return e;
|
|
3591
3597
|
};
|
|
3592
|
-
async function
|
|
3593
|
-
let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(
|
|
3598
|
+
async function Nr(e, t, n, r, i) {
|
|
3599
|
+
let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(jr(a))), l = c.alg === "ES256" || c.alg === "RS256" ? Ar[c.alg] : void 0;
|
|
3594
3600
|
if (!l) throw Error(`Token signing algorithm ${String(c.alg)} is not accepted`);
|
|
3595
3601
|
let u = t.find((e) => e.kid === c.kid && e.kty === l.kty && (e.kty !== "EC" || e.crv === "P-256"));
|
|
3596
3602
|
if (!u) throw Error("Token signing key is not published by the server");
|
|
3597
|
-
let d =
|
|
3598
|
-
if (!await d.verify(l.signature, f,
|
|
3603
|
+
let d = Mr().subtle, f = await d.importKey("jwk", l.key(u), l.imported, !1, ["verify"]), p = new TextEncoder().encode(`${a}.${o}`);
|
|
3604
|
+
if (!await d.verify(l.signature, f, jr(s), p)) throw Error("Token signature is not valid");
|
|
3599
3605
|
let m = j(e), h = Array.isArray(m.aud) ? m.aud : [m.aud];
|
|
3600
3606
|
if (m.iss !== n) throw Error("Token issuer does not match the server");
|
|
3601
3607
|
if (!h.includes(r)) throw Error("Token is not issued for this app");
|
|
3602
3608
|
if (typeof m.exp != "number" || A(m, 0)) throw Error("Token has expired");
|
|
3603
3609
|
if (i && m.type !== i) throw Error("Token type is not valid");
|
|
3604
3610
|
}
|
|
3605
|
-
async function
|
|
3611
|
+
async function Pr(t, n, r) {
|
|
3606
3612
|
if (!n) throw Error("An app id is required to accept tokens from the URL");
|
|
3607
3613
|
if (!r.access_token) throw Error("No access token received");
|
|
3608
|
-
|
|
3614
|
+
Mr();
|
|
3609
3615
|
let i = t.replace(/\/+$/, ""), [a, o] = await Promise.all([e.get(`${i}/.well-known/openid-configuration`), e.get(`${i}/.well-known/jwks.json`)]), s = a.data?.issuer, c = o.data?.keys ?? [];
|
|
3610
3616
|
if (!s) throw Error("The server did not publish an issuer");
|
|
3611
|
-
await
|
|
3617
|
+
await Nr(r.access_token, c, s, n, M.access_token), r.refresh_token && await Nr(r.refresh_token, c, s, n, M.refresh_token), r.id_token && await Nr(r.id_token, c, s, n);
|
|
3612
3618
|
}
|
|
3613
3619
|
// lib/upgrade/errors.ts
|
|
3614
3620
|
var Q = {
|
|
@@ -3625,18 +3631,18 @@ var Q = {
|
|
|
3625
3631
|
twoFactorNotEnabled: "error.2fa.not_enabled",
|
|
3626
3632
|
notImplemented: "error.not.implemented",
|
|
3627
3633
|
tokenInvalid: "error.api.request.token.invalid"
|
|
3628
|
-
},
|
|
3634
|
+
}, Fr = Object.freeze([
|
|
3629
3635
|
Q.twoFactorCodeInvalid,
|
|
3630
3636
|
Q.twoFactorNotEnabled,
|
|
3631
3637
|
Q.challengeInvalid,
|
|
3632
3638
|
Q.challengeSessionMismatch,
|
|
3633
3639
|
Q.challengeTooManyAttempts
|
|
3634
|
-
]),
|
|
3640
|
+
]), Ir = Object.freeze([Q.tokenInvalid]), Lr = Object.freeze([
|
|
3635
3641
|
"wrong_code",
|
|
3636
3642
|
"challenge_spent",
|
|
3637
3643
|
"not_registered",
|
|
3638
3644
|
"prepare_not_required"
|
|
3639
|
-
]),
|
|
3645
|
+
]), Rr = (e) => Lr.includes(e), zr = {
|
|
3640
3646
|
wrong_code: "That code was not accepted. Try again.",
|
|
3641
3647
|
challenge_spent: "That verification challenge is no longer valid. Start again.",
|
|
3642
3648
|
exhausted: "Too many attempts. Try again later.",
|
|
@@ -3650,16 +3656,16 @@ var Q = {
|
|
|
3650
3656
|
session_changed: "The session ended during verification."
|
|
3651
3657
|
}, $ = class extends Error {
|
|
3652
3658
|
constructor(e) {
|
|
3653
|
-
super(e.message ||
|
|
3659
|
+
super(e.message || zr[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, this.retryable = Rr(e.kind), e.cause !== void 0 && (this.cause = e.cause);
|
|
3654
3660
|
}
|
|
3655
|
-
},
|
|
3661
|
+
}, Br = Object.freeze([
|
|
3656
3662
|
"upgrade_transport",
|
|
3657
3663
|
"upgrade_insufficient",
|
|
3658
3664
|
"upgrade_unavailable",
|
|
3659
3665
|
"upgrade_session_changed",
|
|
3660
3666
|
"upgrade_cancelled",
|
|
3661
3667
|
"upgrade_unsatisfiable"
|
|
3662
|
-
]),
|
|
3668
|
+
]), Vr = (e) => typeof e == "object" && !!e && typeof e.code == "string" && Br.includes(e.code), Hr = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", Ur = (e) => {
|
|
3663
3669
|
if (typeof e != "object" || !e) return {
|
|
3664
3670
|
hasResponse: !1,
|
|
3665
3671
|
message: typeof e == "string" ? e : void 0
|
|
@@ -3671,7 +3677,7 @@ var Q = {
|
|
|
3671
3677
|
message: typeof t.message == "string" ? t.message : void 0,
|
|
3672
3678
|
hasResponse: n !== void 0 || typeof t.status == "number"
|
|
3673
3679
|
};
|
|
3674
|
-
},
|
|
3680
|
+
}, Wr = (e, t) => {
|
|
3675
3681
|
switch (e) {
|
|
3676
3682
|
case Q.twoFactorCodeInvalid: return "wrong_code";
|
|
3677
3683
|
case Q.challengeInvalid:
|
|
@@ -3689,11 +3695,11 @@ var Q = {
|
|
|
3689
3695
|
case "error.service.unavailable": return "network";
|
|
3690
3696
|
default: return;
|
|
3691
3697
|
}
|
|
3692
|
-
},
|
|
3698
|
+
}, Gr = (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", Kr = (e, t) => {
|
|
3693
3699
|
if (e instanceof $) return e;
|
|
3694
|
-
let n =
|
|
3700
|
+
let n = Ur(e);
|
|
3695
3701
|
return n.hasResponse ? new $({
|
|
3696
|
-
kind:
|
|
3702
|
+
kind: Wr(n.errorId, t) ?? Gr(n.status, t),
|
|
3697
3703
|
message: n.message,
|
|
3698
3704
|
status: n.status,
|
|
3699
3705
|
errorId: n.errorId,
|
|
@@ -3703,60 +3709,60 @@ var Q = {
|
|
|
3703
3709
|
message: n.message,
|
|
3704
3710
|
cause: e
|
|
3705
3711
|
});
|
|
3706
|
-
},
|
|
3712
|
+
}, qr = (e) => e.errorId !== void 0 && Fr.includes(e.errorId), Jr = (e) => e.errorId !== void 0 && Ir.includes(e.errorId), Yr = class extends Error {
|
|
3707
3713
|
constructor(e, t, n) {
|
|
3708
3714
|
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;
|
|
3709
3715
|
}
|
|
3710
|
-
},
|
|
3716
|
+
}, Xr = class extends Error {
|
|
3711
3717
|
constructor(e = "Step-up verification is not available on this deployment") {
|
|
3712
3718
|
super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
|
|
3713
3719
|
}
|
|
3714
|
-
},
|
|
3720
|
+
}, Zr = class extends Error {
|
|
3715
3721
|
constructor(e = "The session changed during verification") {
|
|
3716
3722
|
super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
|
|
3717
3723
|
}
|
|
3718
|
-
},
|
|
3724
|
+
}, Qr = (e) => {
|
|
3719
3725
|
if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
|
|
3720
3726
|
sub: e.sub,
|
|
3721
3727
|
sid: e.sid
|
|
3722
3728
|
} : { sub: e.sub };
|
|
3723
|
-
},
|
|
3729
|
+
}, $r = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
|
|
3724
3730
|
// lib/utils/validation.ts
|
|
3725
|
-
function
|
|
3731
|
+
function ei(e) {
|
|
3726
3732
|
if (!e || typeof e != "string") return !1;
|
|
3727
3733
|
let t = e.split(".");
|
|
3728
3734
|
if (t.length !== 3) return !1;
|
|
3729
3735
|
let n = /^[A-Za-z0-9_-]+$/;
|
|
3730
3736
|
return t.every((e) => n.test(e) && e.length > 0);
|
|
3731
3737
|
}
|
|
3732
|
-
function
|
|
3738
|
+
function ti(e) {
|
|
3733
3739
|
return e.replace(/<[^>]*>/g, "").substring(0, 200);
|
|
3734
3740
|
}
|
|
3735
|
-
function
|
|
3741
|
+
function ni(e) {
|
|
3736
3742
|
if (!e || typeof e != "string") return !1;
|
|
3737
3743
|
let t = e.trim();
|
|
3738
3744
|
return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
|
|
3739
3745
|
}
|
|
3740
|
-
function
|
|
3746
|
+
function ri(e) {
|
|
3741
3747
|
if (!e || typeof e != "string") return !1;
|
|
3742
3748
|
let t = e.trim();
|
|
3743
3749
|
return /^\+[1-9]\d{1,14}$/.test(t);
|
|
3744
3750
|
}
|
|
3745
|
-
function
|
|
3751
|
+
function ii(e) {
|
|
3746
3752
|
if (!e || typeof e != "string") return !1;
|
|
3747
3753
|
let t = e.trim();
|
|
3748
3754
|
return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
|
|
3749
3755
|
}
|
|
3750
|
-
function
|
|
3756
|
+
function ai(e, t = 6) {
|
|
3751
3757
|
return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
|
|
3752
3758
|
}
|
|
3753
|
-
function
|
|
3759
|
+
function oi(e) {
|
|
3754
3760
|
if (!e || typeof e != "string") return null;
|
|
3755
3761
|
let t = e.toUpperCase().replace(/\s+/g, "");
|
|
3756
3762
|
return /^[A-Z0-9-]{4,16}$/.test(t) ? t : null;
|
|
3757
3763
|
}
|
|
3758
3764
|
// lib/services/auth-service.ts
|
|
3759
|
-
var
|
|
3765
|
+
var si = "passflow_2fa_pkce", ci = 3e5, li = "passflow_pwless_pending", ui = 3e3, di = "passflow_federated_pkce", fi = 6e5, pi = "AppId is required for federated auth", mi = 10, hi = "The sign-in answered with a PKCE code, but its verifier is gone", gi = (e, t) => new Promise((n, r) => {
|
|
3760
3766
|
if (t?.aborted) {
|
|
3761
3767
|
r(t.reason);
|
|
3762
3768
|
return;
|
|
@@ -3767,21 +3773,21 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
3767
3773
|
t?.removeEventListener("abort", i), n();
|
|
3768
3774
|
}, e);
|
|
3769
3775
|
t?.addEventListener("abort", i, { once: !0 });
|
|
3770
|
-
}),
|
|
3776
|
+
}), _i = (e) => {
|
|
3771
3777
|
if (!e) return;
|
|
3772
3778
|
let t = new URLSearchParams(e.search).get("token");
|
|
3773
3779
|
if (t) return t;
|
|
3774
3780
|
let n = e.hash.indexOf("?");
|
|
3775
3781
|
return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
|
|
3776
|
-
},
|
|
3782
|
+
}, vi = (e) => {
|
|
3777
3783
|
if (e) try {
|
|
3778
3784
|
return j(e).email;
|
|
3779
3785
|
} catch {
|
|
3780
3786
|
return;
|
|
3781
3787
|
}
|
|
3782
|
-
},
|
|
3783
|
-
constructor(e, t, n, r, i, a, o, s, c, l, u, d = ae, f, p = { coordination:
|
|
3784
|
-
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.readAppSettings = m, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new P(n), u?.enabled && this.tokenDeliveryManager.setMode(N.BFF), this.refresh =
|
|
3788
|
+
}, yi = class {
|
|
3789
|
+
constructor(e, t, n, r, i, a, o, s, c, l, u, d = ae, f, p = { coordination: qn() }, m) {
|
|
3790
|
+
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.readAppSettings = m, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new P(n), u?.enabled && this.tokenDeliveryManager.setMode(N.BFF), this.refresh = Or({
|
|
3785
3791
|
emit: this.createRefreshEmit(),
|
|
3786
3792
|
storage: n,
|
|
3787
3793
|
cache: i,
|
|
@@ -3789,7 +3795,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
3789
3795
|
coordination: p.coordination,
|
|
3790
3796
|
platform: d,
|
|
3791
3797
|
...p.strikes === void 0 ? {} : { strikes: p.strikes },
|
|
3792
|
-
logger:
|
|
3798
|
+
logger: Xn()
|
|
3793
3799
|
}), this.initializeSession();
|
|
3794
3800
|
}
|
|
3795
3801
|
setAppId(e) {
|
|
@@ -3854,7 +3860,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
3854
3860
|
rememberEmailChallenge(e, t) {
|
|
3855
3861
|
this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
|
|
3856
3862
|
for (let e of this.emailChallenges.keys()) {
|
|
3857
|
-
if (this.emailChallenges.size <=
|
|
3863
|
+
if (this.emailChallenges.size <= mi) break;
|
|
3858
3864
|
this.emailChallenges.delete(e);
|
|
3859
3865
|
}
|
|
3860
3866
|
}
|
|
@@ -3862,14 +3868,14 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
3862
3868
|
if (this.pendingPkce = {
|
|
3863
3869
|
verifier: e,
|
|
3864
3870
|
scopes: t,
|
|
3865
|
-
expiresAt: Date.now() +
|
|
3871
|
+
expiresAt: Date.now() + ci
|
|
3866
3872
|
}, typeof sessionStorage < "u") try {
|
|
3867
|
-
sessionStorage.setItem(
|
|
3873
|
+
sessionStorage.setItem(si, JSON.stringify(this.pendingPkce));
|
|
3868
3874
|
} catch {}
|
|
3869
3875
|
}
|
|
3870
3876
|
readPendingPkce() {
|
|
3871
3877
|
if (!this.pendingPkce && typeof sessionStorage < "u") try {
|
|
3872
|
-
let e = sessionStorage.getItem(
|
|
3878
|
+
let e = sessionStorage.getItem(si);
|
|
3873
3879
|
this.pendingPkce = e ? JSON.parse(e) : void 0;
|
|
3874
3880
|
} catch {
|
|
3875
3881
|
this.pendingPkce = void 0;
|
|
@@ -3881,17 +3887,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
3881
3887
|
}
|
|
3882
3888
|
forgetPkceSignIn() {
|
|
3883
3889
|
if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
|
|
3884
|
-
sessionStorage.removeItem(
|
|
3890
|
+
sessionStorage.removeItem(si);
|
|
3885
3891
|
} catch {}
|
|
3886
3892
|
}
|
|
3887
3893
|
rememberPendingPasswordless(e) {
|
|
3888
3894
|
if (this.pendingPasswordless = e, typeof sessionStorage < "u") try {
|
|
3889
|
-
sessionStorage.setItem(
|
|
3895
|
+
sessionStorage.setItem(li, JSON.stringify(e));
|
|
3890
3896
|
} catch {}
|
|
3891
3897
|
}
|
|
3892
3898
|
readPendingPasswordless() {
|
|
3893
3899
|
if (!this.pendingPasswordless && typeof sessionStorage < "u") try {
|
|
3894
|
-
let e = sessionStorage.getItem(
|
|
3900
|
+
let e = sessionStorage.getItem(li);
|
|
3895
3901
|
this.pendingPasswordless = e ? JSON.parse(e) : void 0;
|
|
3896
3902
|
} catch {
|
|
3897
3903
|
this.pendingPasswordless = void 0;
|
|
@@ -3900,21 +3906,21 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
3900
3906
|
}
|
|
3901
3907
|
forgetPendingPasswordless() {
|
|
3902
3908
|
if (this.pendingPasswordless = void 0, typeof sessionStorage < "u") try {
|
|
3903
|
-
sessionStorage.removeItem(
|
|
3909
|
+
sessionStorage.removeItem(li);
|
|
3904
3910
|
} catch {}
|
|
3905
3911
|
}
|
|
3906
3912
|
rememberFederatedSlot(e, t) {
|
|
3907
3913
|
if (this.federatedSlot = {
|
|
3908
3914
|
verifier: e,
|
|
3909
3915
|
scopes: t,
|
|
3910
|
-
expiresAt: Date.now() +
|
|
3916
|
+
expiresAt: Date.now() + fi
|
|
3911
3917
|
}, typeof sessionStorage < "u") try {
|
|
3912
|
-
sessionStorage.setItem(
|
|
3918
|
+
sessionStorage.setItem(di, JSON.stringify(this.federatedSlot));
|
|
3913
3919
|
} catch {}
|
|
3914
3920
|
}
|
|
3915
3921
|
readFederatedSlot() {
|
|
3916
3922
|
if (!this.federatedSlot && typeof sessionStorage < "u") try {
|
|
3917
|
-
let e = sessionStorage.getItem(
|
|
3923
|
+
let e = sessionStorage.getItem(di);
|
|
3918
3924
|
this.federatedSlot = e ? JSON.parse(e) : void 0;
|
|
3919
3925
|
} catch {
|
|
3920
3926
|
this.federatedSlot = void 0;
|
|
@@ -3923,7 +3929,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
3923
3929
|
}
|
|
3924
3930
|
forgetFederatedSlot() {
|
|
3925
3931
|
if (this.federatedSlot = void 0, typeof sessionStorage < "u") try {
|
|
3926
|
-
sessionStorage.removeItem(
|
|
3932
|
+
sessionStorage.removeItem(di);
|
|
3927
3933
|
} catch {}
|
|
3928
3934
|
}
|
|
3929
3935
|
async startPkce() {
|
|
@@ -3931,17 +3937,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
3931
3937
|
try {
|
|
3932
3938
|
e = await this.readPkceEnabled?.() ?? !1;
|
|
3933
3939
|
} catch (e) {
|
|
3934
|
-
|
|
3940
|
+
Xn().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
|
|
3935
3941
|
return;
|
|
3936
3942
|
}
|
|
3937
|
-
return e ?
|
|
3943
|
+
return e ? Zt() : void 0;
|
|
3938
3944
|
}
|
|
3939
3945
|
async exchangeCode(e, t) {
|
|
3940
3946
|
return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
|
|
3941
3947
|
}
|
|
3942
3948
|
async completePkceSignIn(e) {
|
|
3943
3949
|
let t = this.readPendingPkce();
|
|
3944
|
-
if (!t) throw Error(
|
|
3950
|
+
if (!t) throw Error(hi);
|
|
3945
3951
|
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
3946
3952
|
return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
|
|
3947
3953
|
}
|
|
@@ -3965,7 +3971,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
3965
3971
|
if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
|
|
3966
3972
|
}
|
|
3967
3973
|
async signIn(e) {
|
|
3968
|
-
if ("email" in e && e.email && !
|
|
3974
|
+
if ("email" in e && e.email && !ni(e.email)) {
|
|
3969
3975
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3970
3976
|
operation: "sign-in",
|
|
3971
3977
|
message: "Invalid email format",
|
|
@@ -3974,7 +3980,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
3974
3980
|
};
|
|
3975
3981
|
throw W(this.subscribeStore, t), e;
|
|
3976
3982
|
}
|
|
3977
|
-
if ("username" in e && e.username && !
|
|
3983
|
+
if ("username" in e && e.username && !ii(e.username)) {
|
|
3978
3984
|
let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
|
|
3979
3985
|
operation: "sign-in",
|
|
3980
3986
|
message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
|
|
@@ -3983,7 +3989,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
3983
3989
|
};
|
|
3984
3990
|
throw W(this.subscribeStore, t), e;
|
|
3985
3991
|
}
|
|
3986
|
-
if ("phone" in e && e.phone && !
|
|
3992
|
+
if ("phone" in e && e.phone && !ri(e.phone)) {
|
|
3987
3993
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3988
3994
|
operation: "sign-in",
|
|
3989
3995
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4017,7 +4023,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4017
4023
|
}
|
|
4018
4024
|
}
|
|
4019
4025
|
async signUp(e) {
|
|
4020
|
-
if (e.user.email && !
|
|
4026
|
+
if (e.user.email && !ni(e.user.email)) {
|
|
4021
4027
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4022
4028
|
operation: "sign-up",
|
|
4023
4029
|
message: "Invalid email format",
|
|
@@ -4026,7 +4032,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4026
4032
|
};
|
|
4027
4033
|
throw W(this.subscribeStore, t), e;
|
|
4028
4034
|
}
|
|
4029
|
-
if (e.user.phone_number && !
|
|
4035
|
+
if (e.user.phone_number && !ri(e.user.phone_number)) {
|
|
4030
4036
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4031
4037
|
operation: "sign-up",
|
|
4032
4038
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4058,7 +4064,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4058
4064
|
}
|
|
4059
4065
|
}
|
|
4060
4066
|
async passwordlessSignIn(e) {
|
|
4061
|
-
if (e.email && !
|
|
4067
|
+
if (e.email && !ni(e.email)) {
|
|
4062
4068
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4063
4069
|
operation: "passwordless.start",
|
|
4064
4070
|
message: "Invalid email format",
|
|
@@ -4067,7 +4073,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4067
4073
|
};
|
|
4068
4074
|
throw W(this.subscribeStore, t), e;
|
|
4069
4075
|
}
|
|
4070
|
-
if (e.phone && !
|
|
4076
|
+
if (e.phone && !ri(e.phone)) {
|
|
4071
4077
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4072
4078
|
operation: "passwordless.start",
|
|
4073
4079
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4111,7 +4117,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4111
4117
|
if (r = !0, this.handlePendingSecondFactor(t, n?.email, n && { verifier: n.verifier }, n?.scopes)) return this.forgetPendingPasswordless(), t;
|
|
4112
4118
|
let i = t;
|
|
4113
4119
|
if (t.code) {
|
|
4114
|
-
if (!n) throw Error(
|
|
4120
|
+
if (!n) throw Error(hi);
|
|
4115
4121
|
if (i = await this.authApi.pkceExchange(t.code, n.verifier), this.handlePendingSecondFactor(i)) return this.forgetPendingPasswordless(), {
|
|
4116
4122
|
...i,
|
|
4117
4123
|
redirect_url: t.redirect_url ?? ""
|
|
@@ -4143,11 +4149,11 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4143
4149
|
let n = t?.signal;
|
|
4144
4150
|
try {
|
|
4145
4151
|
let t = this.readPendingPasswordless();
|
|
4146
|
-
if (t?.challengeId !== e) throw Error(
|
|
4152
|
+
if (t?.challengeId !== e) throw Error(hi);
|
|
4147
4153
|
for (;;) {
|
|
4148
4154
|
if (n?.aborted) throw n.reason;
|
|
4149
4155
|
if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
|
|
4150
|
-
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(
|
|
4156
|
+
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(hi);
|
|
4151
4157
|
let r;
|
|
4152
4158
|
try {
|
|
4153
4159
|
r = await this.authApi.passwordlessStatus({
|
|
@@ -4165,7 +4171,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4165
4171
|
status: "signed-in",
|
|
4166
4172
|
tokens: { redirect_url: r.redirect_url }
|
|
4167
4173
|
};
|
|
4168
|
-
await
|
|
4174
|
+
await gi(ui, n);
|
|
4169
4175
|
}
|
|
4170
4176
|
} catch (e) {
|
|
4171
4177
|
if (n?.aborted && e === n.reason) throw e;
|
|
@@ -4234,14 +4240,14 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4234
4240
|
let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
|
|
4235
4241
|
try {
|
|
4236
4242
|
let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
|
|
4237
|
-
if (t?.pkce && !r) throw Error(
|
|
4243
|
+
if (t?.pkce && !r) throw Error(hi);
|
|
4238
4244
|
let i = await this.authApi.validateEmailCode(e);
|
|
4239
4245
|
this.emailChallenges.delete(e.challenge_id);
|
|
4240
4246
|
let a = r?.scopes ?? t?.scopes ?? this.scopes;
|
|
4241
4247
|
if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
|
|
4242
4248
|
let o = i;
|
|
4243
4249
|
if (i.code) {
|
|
4244
|
-
if (!r) throw Error(
|
|
4250
|
+
if (!r) throw Error(hi);
|
|
4245
4251
|
if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
|
|
4246
4252
|
}
|
|
4247
4253
|
let s = i.redirect_url ? {
|
|
@@ -4295,13 +4301,13 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4295
4301
|
readSessionPin() {
|
|
4296
4302
|
try {
|
|
4297
4303
|
let e = this.storageManager.getToken(M.access_token);
|
|
4298
|
-
return e ?
|
|
4304
|
+
return e ? Qr(j(e)) : void 0;
|
|
4299
4305
|
} catch {
|
|
4300
4306
|
return;
|
|
4301
4307
|
}
|
|
4302
4308
|
}
|
|
4303
4309
|
assertSessionPin(e) {
|
|
4304
|
-
if (e &&
|
|
4310
|
+
if (e && !$r(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 Zr("The session changed during verification, so the elevated tokens were discarded");
|
|
4305
4311
|
}
|
|
4306
4312
|
refreshMode() {
|
|
4307
4313
|
return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
|
|
@@ -4349,7 +4355,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4349
4355
|
case "signout":
|
|
4350
4356
|
n.notify(Z.SignOut, t);
|
|
4351
4357
|
return;
|
|
4352
|
-
default:
|
|
4358
|
+
default: Xn().warn(`[passflow] Unknown refresh event: ${String(e)}`);
|
|
4353
4359
|
}
|
|
4354
4360
|
};
|
|
4355
4361
|
}
|
|
@@ -4435,10 +4441,10 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4435
4441
|
}
|
|
4436
4442
|
async resetPassword(e, t, n) {
|
|
4437
4443
|
this.subscribeStore.notify(Z.SignInStart, {});
|
|
4438
|
-
let r = n ??
|
|
4444
|
+
let r = n ?? _i(this.platform.getCurrentUrl()), i = t ?? this.scopes;
|
|
4439
4445
|
try {
|
|
4440
4446
|
let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
|
|
4441
|
-
if (this.handleEmailVerificationStep(n, "reset-password",
|
|
4447
|
+
if (this.handleEmailVerificationStep(n, "reset-password", vi(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
|
|
4442
4448
|
let a = await this.exchangeCode(n, t);
|
|
4443
4449
|
if (this.handlePendingSecondFactor(a)) return a;
|
|
4444
4450
|
let o = n.redirect_url ? {
|
|
@@ -4519,7 +4525,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4519
4525
|
}
|
|
4520
4526
|
createFederatedAuthUrl(e) {
|
|
4521
4527
|
let t = `/auth/federated/start/${e.provider}`;
|
|
4522
|
-
if (!this.appId) throw Error(
|
|
4528
|
+
if (!this.appId) throw Error(pi);
|
|
4523
4529
|
let n = {
|
|
4524
4530
|
scopes: (e.scopes ?? this.scopes).join(" "),
|
|
4525
4531
|
redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
|
|
@@ -4535,7 +4541,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4535
4541
|
return r.search = new URLSearchParams(n).toString(), r.toString();
|
|
4536
4542
|
}
|
|
4537
4543
|
async federatedAuthWithPopup(e) {
|
|
4538
|
-
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(
|
|
4544
|
+
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(pi);
|
|
4539
4545
|
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
|
|
4540
4546
|
try {
|
|
4541
4547
|
this.forgetFederatedSlot();
|
|
@@ -4563,11 +4569,11 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4563
4569
|
scopes: t
|
|
4564
4570
|
};
|
|
4565
4571
|
if (r) {
|
|
4566
|
-
if (!l) throw
|
|
4572
|
+
if (!l) throw nn();
|
|
4567
4573
|
if (m = await this.authApi.pkceExchange(l, r.verifier), this.handlePendingSecondFactor(m)) return;
|
|
4568
4574
|
} else {
|
|
4569
|
-
if (!await this.isSimpleModeApp()) throw
|
|
4570
|
-
await
|
|
4575
|
+
if (!await this.isSimpleModeApp()) throw nn();
|
|
4576
|
+
await Pr(this.url, this.appId, m);
|
|
4571
4577
|
}
|
|
4572
4578
|
await this.processAuthResponse(m, t), this.subscribeStore.notify(Z.SignIn, {
|
|
4573
4579
|
tokens: m,
|
|
@@ -4593,7 +4599,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4593
4599
|
}
|
|
4594
4600
|
}
|
|
4595
4601
|
federatedAuthWithRedirect(e) {
|
|
4596
|
-
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(
|
|
4602
|
+
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(pi);
|
|
4597
4603
|
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
|
|
4598
4604
|
this.startPkce().then((r) => {
|
|
4599
4605
|
let i = this.createFederatedAuthUrl({
|
|
@@ -4657,7 +4663,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4657
4663
|
async authRedirect(e = {}) {
|
|
4658
4664
|
try {
|
|
4659
4665
|
let { url: t, appId: n, redirectUrl: r, scopes: i, state: a } = e;
|
|
4660
|
-
if (t !== void 0 &&
|
|
4666
|
+
if (t !== void 0 && on(t) !== on(this.url) || n !== void 0 && n !== (this.appId ?? "")) throw new U("OVERRIDE_NOT_SUPPORTED", "authRedirect() signs in to this instance's url and appId; create a Passflow instance for another server or app");
|
|
4661
4667
|
let o = await this.readAppSettings?.();
|
|
4662
4668
|
if (o?.pkce_enabled !== !0) {
|
|
4663
4669
|
let e = this.authRedirectUrl({
|
|
@@ -4667,8 +4673,8 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4667
4673
|
this.platform.navigateTo(a ? `${e}&${new URLSearchParams({ state: a })}` : e);
|
|
4668
4674
|
return;
|
|
4669
4675
|
}
|
|
4670
|
-
if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT",
|
|
4671
|
-
let s = this.platform.getCurrentUrl(), c = await
|
|
4676
|
+
if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT", en(o.type));
|
|
4677
|
+
let s = this.platform.getCurrentUrl(), c = await cn({
|
|
4672
4678
|
url: this.url,
|
|
4673
4679
|
clientId: this.appId ?? "",
|
|
4674
4680
|
redirectUri: r ?? (s ? s.origin + s.pathname : ""),
|
|
@@ -4689,9 +4695,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4689
4695
|
if (!this.appId) return !1;
|
|
4690
4696
|
let t = new URLSearchParams(e.search), n = t.get("code"), r = t.get("state"), i = t.get("error"), a = t.get("error_description");
|
|
4691
4697
|
if (t.get("user_state") || r === null || !n && !i) return !1;
|
|
4692
|
-
let o =
|
|
4698
|
+
let o = un();
|
|
4693
4699
|
if (o.status === "none") return !1;
|
|
4694
|
-
|
|
4700
|
+
dn();
|
|
4695
4701
|
for (let e of [
|
|
4696
4702
|
"code",
|
|
4697
4703
|
"state",
|
|
@@ -4703,9 +4709,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4703
4709
|
return this.platform.replaceUrl(e.pathname + (s ? `?${s}` : "") + e.hash), this.finishOidcLanding(async () => {
|
|
4704
4710
|
if (o.status === "unusable") throw new U("VERIFIER_MISSING", "This sign-in has expired or its proof key is gone. Sign in again.");
|
|
4705
4711
|
if (o.slot.state !== r) throw new U("STATE_MISMATCH", "The sign-in answer does not belong to this sign-in. Sign in again.");
|
|
4706
|
-
if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED",
|
|
4712
|
+
if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED", ti(a || i || "Sign in again."));
|
|
4707
4713
|
return {
|
|
4708
|
-
tokens: await
|
|
4714
|
+
tokens: await pn(this.url, n, o.slot),
|
|
4709
4715
|
scopes: o.slot.scopes
|
|
4710
4716
|
};
|
|
4711
4717
|
}), !0;
|
|
@@ -4785,7 +4791,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4785
4791
|
return;
|
|
4786
4792
|
}
|
|
4787
4793
|
}
|
|
4788
|
-
},
|
|
4794
|
+
}, bi = class {
|
|
4789
4795
|
constructor(e) {
|
|
4790
4796
|
this.invitationApi = e;
|
|
4791
4797
|
}
|
|
@@ -4804,7 +4810,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4804
4810
|
getInvitationLink(e) {
|
|
4805
4811
|
return this.invitationApi.getInvitationLink(e);
|
|
4806
4812
|
}
|
|
4807
|
-
},
|
|
4813
|
+
}, xi = class {
|
|
4808
4814
|
constructor(e) {
|
|
4809
4815
|
this.data = this.normalize(e);
|
|
4810
4816
|
}
|
|
@@ -4861,9 +4867,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4861
4867
|
getData() {
|
|
4862
4868
|
return this.data;
|
|
4863
4869
|
}
|
|
4864
|
-
},
|
|
4870
|
+
}, Si = class {
|
|
4865
4871
|
constructor(e, t, n) {
|
|
4866
|
-
this.tenantApi = e, this.scopes = t, this.logger = n ||
|
|
4872
|
+
this.tenantApi = e, this.scopes = t, this.logger = n || Xn();
|
|
4867
4873
|
}
|
|
4868
4874
|
handlePassflowError(t, n) {
|
|
4869
4875
|
if (e.isAxiosError(t) && t.response?.data) {
|
|
@@ -4899,7 +4905,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
4899
4905
|
}
|
|
4900
4906
|
async getTenantUserMembership(e) {
|
|
4901
4907
|
try {
|
|
4902
|
-
return new
|
|
4908
|
+
return new xi(await this.tenantApi.getTenantDetails(e));
|
|
4903
4909
|
} catch (t) {
|
|
4904
4910
|
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
4905
4911
|
}
|
|
@@ -5044,7 +5050,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5044
5050
|
this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
|
|
5045
5051
|
}
|
|
5046
5052
|
}
|
|
5047
|
-
},
|
|
5053
|
+
}, Ci = class {
|
|
5048
5054
|
constructor(e, t, n, r = ae) {
|
|
5049
5055
|
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();
|
|
5050
5056
|
}
|
|
@@ -5124,7 +5130,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5124
5130
|
isExpired() {
|
|
5125
5131
|
return this.tokensCache ? this.tokensCache.access_token ? A(j(this.tokensCache.access_token)) : !1 : !0;
|
|
5126
5132
|
}
|
|
5127
|
-
},
|
|
5133
|
+
}, wi = class {
|
|
5128
5134
|
constructor(e, t, n) {
|
|
5129
5135
|
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) => {
|
|
5130
5136
|
if (e === Z.TwoFactorRequired) {
|
|
@@ -5201,7 +5207,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5201
5207
|
}
|
|
5202
5208
|
}
|
|
5203
5209
|
assertTotpCode(e) {
|
|
5204
|
-
if (!
|
|
5210
|
+
if (!ai(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
5205
5211
|
}
|
|
5206
5212
|
requirePendingTfaToken() {
|
|
5207
5213
|
let e = this.pendingTfaToken();
|
|
@@ -5220,7 +5226,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5220
5226
|
}), e;
|
|
5221
5227
|
}
|
|
5222
5228
|
async verify(e, t) {
|
|
5223
|
-
if (!
|
|
5229
|
+
if (!ai(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
5224
5230
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
5225
5231
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
5226
5232
|
try {
|
|
@@ -5236,7 +5242,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5236
5242
|
}
|
|
5237
5243
|
async useRecoveryCode(e, t) {
|
|
5238
5244
|
try {
|
|
5239
|
-
let n =
|
|
5245
|
+
let n = oi(e);
|
|
5240
5246
|
if (!n) throw Error("Invalid recovery code format. Expected format: XXXX-XXXX or XXXXXXXX (alphanumeric).");
|
|
5241
5247
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
5242
5248
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
@@ -5257,7 +5263,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5257
5263
|
}
|
|
5258
5264
|
}
|
|
5259
5265
|
async disable(e) {
|
|
5260
|
-
if (!
|
|
5266
|
+
if (!ai(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
5261
5267
|
try {
|
|
5262
5268
|
let t = await this.twoFactorApi.disable({ code: e });
|
|
5263
5269
|
return this.subscribeStore.notify(Z.TwoFactorDisabled, {}), t;
|
|
@@ -5266,7 +5272,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5266
5272
|
}
|
|
5267
5273
|
}
|
|
5268
5274
|
async regenerateRecoveryCodes(e) {
|
|
5269
|
-
if (!
|
|
5275
|
+
if (!ai(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
5270
5276
|
try {
|
|
5271
5277
|
let t = await this.twoFactorApi.regenerateRecoveryCodes({ code: e }), n = [...t.recovery_codes];
|
|
5272
5278
|
return t.recovery_codes = [], t.recovery_codes = n, t;
|
|
@@ -5450,7 +5456,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5450
5456
|
this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
|
|
5451
5457
|
}
|
|
5452
5458
|
}
|
|
5453
|
-
},
|
|
5459
|
+
}, Ti = class {
|
|
5454
5460
|
constructor(e, t, n = ae) {
|
|
5455
5461
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
5456
5462
|
}
|
|
@@ -5477,69 +5483,69 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5477
5483
|
if (!s) throw Error("Passkey registration was not completed");
|
|
5478
5484
|
return await this.userAPI.addUserPasskeyComplete(s, r, a);
|
|
5479
5485
|
}
|
|
5480
|
-
},
|
|
5486
|
+
}, Ei = class extends Error {
|
|
5481
5487
|
constructor(e, t, n = !1) {
|
|
5482
5488
|
super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
|
|
5483
5489
|
}
|
|
5484
|
-
},
|
|
5490
|
+
}, Di = (e, t) => {
|
|
5485
5491
|
let n = t?.trim();
|
|
5486
|
-
if (!n) throw new
|
|
5492
|
+
if (!n) throw new Ei(e, "A verification code is required");
|
|
5487
5493
|
return n;
|
|
5488
|
-
},
|
|
5494
|
+
}, Oi = {
|
|
5489
5495
|
type: "totp",
|
|
5490
5496
|
requiresPrepare: !1,
|
|
5491
5497
|
input: "code",
|
|
5492
|
-
assert: async ({ code: e }) => ({ code:
|
|
5493
|
-
},
|
|
5498
|
+
assert: async ({ code: e }) => ({ code: Di("totp", e) })
|
|
5499
|
+
}, ki = {
|
|
5494
5500
|
type: "recovery_codes",
|
|
5495
5501
|
requiresPrepare: !1,
|
|
5496
5502
|
input: "code",
|
|
5497
|
-
assert: async ({ code: e }) => ({ code:
|
|
5498
|
-
},
|
|
5503
|
+
assert: async ({ code: e }) => ({ code: Di("recovery_codes", e) })
|
|
5504
|
+
}, Ai = {
|
|
5499
5505
|
type: "passkey",
|
|
5500
5506
|
requiresPrepare: !0,
|
|
5501
5507
|
input: "none",
|
|
5502
5508
|
assert: async ({ prepared: e, platform: t }) => {
|
|
5503
|
-
if (!e?.webauthn) throw new
|
|
5509
|
+
if (!e?.webauthn) throw new Ei("passkey", "The upgrade challenge carried no WebAuthn options");
|
|
5504
5510
|
let n = t.passkeys;
|
|
5505
|
-
if (!n) throw new
|
|
5511
|
+
if (!n) throw new Ei("passkey", "This platform does not support passkeys");
|
|
5506
5512
|
let r;
|
|
5507
5513
|
try {
|
|
5508
5514
|
r = await n.startAuthentication(e.webauthn);
|
|
5509
5515
|
} catch (e) {
|
|
5510
|
-
throw new
|
|
5516
|
+
throw new Ei("passkey", e?.message || "Passkey verification was cancelled", !0);
|
|
5511
5517
|
}
|
|
5512
|
-
if (!r) throw new
|
|
5518
|
+
if (!r) throw new Ei("passkey", "Passkey verification was cancelled", !0);
|
|
5513
5519
|
return {
|
|
5514
5520
|
challenge_id: e.challengeId,
|
|
5515
5521
|
credential: r
|
|
5516
5522
|
};
|
|
5517
5523
|
}
|
|
5518
|
-
},
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
]),
|
|
5524
|
+
}, ji = Object.freeze([
|
|
5525
|
+
Oi,
|
|
5526
|
+
Ai,
|
|
5527
|
+
ki
|
|
5528
|
+
]), Mi = (e = ji) => new Map(e.map((e) => [e.type, e])), Ni = 3, Pi = {
|
|
5523
5529
|
passkey: 0,
|
|
5524
5530
|
totp: 1,
|
|
5525
5531
|
email_otp: 2,
|
|
5526
5532
|
sms_otp: 3,
|
|
5527
5533
|
recovery_codes: 9
|
|
5528
|
-
},
|
|
5529
|
-
let n =
|
|
5534
|
+
}, Fi = (e) => e.requiredLevel ?? ce(e.acrValues), Ii = (e, t) => {
|
|
5535
|
+
let n = Pi[e.type] ?? 5, r = t !== void 0 && t >= Ni, i = e.type === "passkey";
|
|
5530
5536
|
return (r && !i ? 100 : 0) + n;
|
|
5531
|
-
},
|
|
5532
|
-
let n =
|
|
5533
|
-
return [...e].sort((e, t) =>
|
|
5534
|
-
},
|
|
5537
|
+
}, Li = (e, t) => {
|
|
5538
|
+
let n = Fi(t);
|
|
5539
|
+
return [...e].sort((e, t) => Ii(e, n) - Ii(t, n));
|
|
5540
|
+
}, Ri = class extends Error {
|
|
5535
5541
|
constructor(e) {
|
|
5536
5542
|
super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
|
|
5537
5543
|
}
|
|
5538
|
-
},
|
|
5544
|
+
}, zi = class extends Error {
|
|
5539
5545
|
constructor(e = "No available authentication factor can satisfy this challenge") {
|
|
5540
5546
|
super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
|
|
5541
5547
|
}
|
|
5542
|
-
},
|
|
5548
|
+
}, Bi = 4, Vi = 3e4, Hi = () => {
|
|
5543
5549
|
let e = () => void 0, t = () => void 0;
|
|
5544
5550
|
return {
|
|
5545
5551
|
promise: new Promise((n, r) => {
|
|
@@ -5548,11 +5554,11 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5548
5554
|
resolve: e,
|
|
5549
5555
|
reject: t
|
|
5550
5556
|
};
|
|
5551
|
-
},
|
|
5557
|
+
}, Ui = (e) => ({
|
|
5552
5558
|
acrValues: e.acrValues,
|
|
5553
5559
|
level: e.requiredLevel,
|
|
5554
5560
|
maxAge: e.maxAge
|
|
5555
|
-
}),
|
|
5561
|
+
}), Wi = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, Gi = (e, t) => {
|
|
5556
5562
|
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 ?? []]));
|
|
5557
5563
|
return {
|
|
5558
5564
|
acrValues: r,
|
|
@@ -5561,12 +5567,12 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5561
5567
|
status: e.status,
|
|
5562
5568
|
...a.length > 0 ? { channels: a } : {}
|
|
5563
5569
|
};
|
|
5564
|
-
},
|
|
5570
|
+
}, Ki = (e, t) => {
|
|
5565
5571
|
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);
|
|
5566
5572
|
return n || r;
|
|
5567
|
-
},
|
|
5573
|
+
}, qi = class {
|
|
5568
5574
|
constructor(e) {
|
|
5569
|
-
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 ??
|
|
5575
|
+
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 ?? ji, this.registry = Mi(this.available), this.maxAttempts = e.maxAttempts ?? Bi, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? Vi;
|
|
5570
5576
|
}
|
|
5571
5577
|
get currentState() {
|
|
5572
5578
|
return this.state;
|
|
@@ -5586,9 +5592,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5586
5592
|
}
|
|
5587
5593
|
register(e, t) {
|
|
5588
5594
|
let n = t.kind === "imperative" && t.requested !== void 0, r = {
|
|
5589
|
-
demanded: t.kind === "imperative" && t.requested ? t.requested :
|
|
5595
|
+
demanded: t.kind === "imperative" && t.requested ? t.requested : Ui(e),
|
|
5590
5596
|
statedBar: n,
|
|
5591
|
-
settlement:
|
|
5597
|
+
settlement: Hi(),
|
|
5592
5598
|
reported: !1,
|
|
5593
5599
|
entry: {
|
|
5594
5600
|
...t,
|
|
@@ -5604,15 +5610,15 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5604
5610
|
this.requirement = e;
|
|
5605
5611
|
return;
|
|
5606
5612
|
}
|
|
5607
|
-
let n =
|
|
5608
|
-
this.requirement =
|
|
5613
|
+
let n = Ki(t, e);
|
|
5614
|
+
this.requirement = Gi(t, e), n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
|
|
5609
5615
|
challenge: this.requirement,
|
|
5610
5616
|
factors: this.offeredFactors()
|
|
5611
5617
|
});
|
|
5612
5618
|
}
|
|
5613
5619
|
offeredFactors() {
|
|
5614
5620
|
let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
|
|
5615
|
-
return t ?
|
|
5621
|
+
return t ? Li(e, t) : e;
|
|
5616
5622
|
}
|
|
5617
5623
|
receiveReport(e, t) {
|
|
5618
5624
|
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());
|
|
@@ -5647,12 +5653,12 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5647
5653
|
}
|
|
5648
5654
|
release(e, t) {
|
|
5649
5655
|
if (e.entry.kind === "imperative") {
|
|
5650
|
-
if (e.statedBar && !
|
|
5656
|
+
if (e.statedBar && !Wi(t, e.demanded)) {
|
|
5651
5657
|
this.receiveReport(e, {
|
|
5652
5658
|
outcome: "insufficient",
|
|
5653
5659
|
obtained: t,
|
|
5654
5660
|
required: e.demanded
|
|
5655
|
-
}), e.settlement.reject(new
|
|
5661
|
+
}), e.settlement.reject(new Yr(t, e.demanded));
|
|
5656
5662
|
return;
|
|
5657
5663
|
}
|
|
5658
5664
|
this.receiveReport(e, {
|
|
@@ -5725,7 +5731,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5725
5731
|
let t = this.offeredFactors();
|
|
5726
5732
|
if (t.length === 0) return {
|
|
5727
5733
|
status: "failed",
|
|
5728
|
-
reason: new
|
|
5734
|
+
reason: new zi()
|
|
5729
5735
|
};
|
|
5730
5736
|
let n = this.requirement, r;
|
|
5731
5737
|
try {
|
|
@@ -5733,24 +5739,24 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5733
5739
|
} catch (e) {
|
|
5734
5740
|
return {
|
|
5735
5741
|
status: "failed",
|
|
5736
|
-
reason: new
|
|
5742
|
+
reason: new Ri(e)
|
|
5737
5743
|
};
|
|
5738
5744
|
}
|
|
5739
5745
|
if (r.type === "cancel") return {
|
|
5740
5746
|
status: "failed",
|
|
5741
|
-
reason: new
|
|
5747
|
+
reason: new Ri()
|
|
5742
5748
|
};
|
|
5743
5749
|
let i = this.registry.get(r.factor);
|
|
5744
|
-
if (!i) e = new
|
|
5750
|
+
if (!i) e = new zi(`Unknown authentication factor: ${r.factor}`), this.state = "collecting", this.selected = null;
|
|
5745
5751
|
else try {
|
|
5746
5752
|
return await this.proveAndCommit(i, r.code), {
|
|
5747
5753
|
status: "proven",
|
|
5748
|
-
obtained: this.readObtainedBar?.() ??
|
|
5754
|
+
obtained: this.readObtainedBar?.() ?? Ui(this.rankedRequirement ?? n)
|
|
5749
5755
|
};
|
|
5750
5756
|
} catch (t) {
|
|
5751
|
-
if (t instanceof
|
|
5757
|
+
if (t instanceof Ei && t.cancelled) return {
|
|
5752
5758
|
status: "failed",
|
|
5753
|
-
reason: new
|
|
5759
|
+
reason: new Ri()
|
|
5754
5760
|
};
|
|
5755
5761
|
let n = this.classifyProofFailure(t);
|
|
5756
5762
|
if (n) return {
|
|
@@ -5780,15 +5786,15 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5780
5786
|
return this.openPrompt = r, this.prompt(r);
|
|
5781
5787
|
}
|
|
5782
5788
|
classifyProofFailure(e) {
|
|
5783
|
-
if (e instanceof
|
|
5789
|
+
if (e instanceof Yr || e instanceof Xr || e instanceof Zr) return e;
|
|
5784
5790
|
if (e instanceof $) switch (e.kind) {
|
|
5785
|
-
case "unavailable": return new
|
|
5791
|
+
case "unavailable": return new Xr(e.message);
|
|
5786
5792
|
case "exhausted":
|
|
5787
5793
|
case "attempts_exhausted":
|
|
5788
5794
|
case "fatal":
|
|
5789
5795
|
case "protocol":
|
|
5790
5796
|
case "network": return e;
|
|
5791
|
-
case "session_changed": return new
|
|
5797
|
+
case "session_changed": return new Zr(e.message);
|
|
5792
5798
|
default: return;
|
|
5793
5799
|
}
|
|
5794
5800
|
}
|
|
@@ -5800,28 +5806,28 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5800
5806
|
});
|
|
5801
5807
|
await this.transport.commit(e.type, r);
|
|
5802
5808
|
}
|
|
5803
|
-
},
|
|
5809
|
+
}, Ji = (e) => typeof e == "function" ? e() : e, Yi = (e) => {
|
|
5804
5810
|
try {
|
|
5805
5811
|
return new URL(e);
|
|
5806
5812
|
} catch {
|
|
5807
5813
|
return;
|
|
5808
5814
|
}
|
|
5809
|
-
},
|
|
5815
|
+
}, Xi = (e, t) => {
|
|
5810
5816
|
if (!t || t === "/") return !0;
|
|
5811
5817
|
let n = t.replace(/\/+$/, "");
|
|
5812
5818
|
return e === n || e.startsWith(`${n}/`);
|
|
5813
|
-
},
|
|
5819
|
+
}, Zi = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && Xi(e.pathname, t.pathPrefix), Qi = (e, t) => {
|
|
5814
5820
|
for (let n of t) {
|
|
5815
5821
|
if (n === "") continue;
|
|
5816
5822
|
if (n.startsWith("/")) {
|
|
5817
|
-
if (e.relativeToBase &&
|
|
5823
|
+
if (e.relativeToBase && Xi(e.pathname, n)) return !0;
|
|
5818
5824
|
continue;
|
|
5819
5825
|
}
|
|
5820
|
-
let t =
|
|
5821
|
-
if (t && e.origin !== void 0 && e.origin === t.origin &&
|
|
5826
|
+
let t = Yi(n) ?? Yi(`https://${n}`);
|
|
5827
|
+
if (t && e.origin !== void 0 && e.origin === t.origin && Xi(e.pathname, t.pathname)) return !0;
|
|
5822
5828
|
}
|
|
5823
5829
|
return !1;
|
|
5824
|
-
},
|
|
5830
|
+
}, $i = (e, t, n) => Zi(e, t.passflow) || Qi(e, t.backend) ? !n || n(e.href) !== !1 : !1, ea = (e) => {
|
|
5825
5831
|
let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
|
|
5826
5832
|
console.warn(n, {
|
|
5827
5833
|
status: e.status,
|
|
@@ -5829,8 +5835,8 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5829
5835
|
reason: e.reason,
|
|
5830
5836
|
detail: t
|
|
5831
5837
|
});
|
|
5832
|
-
},
|
|
5833
|
-
let n = t.onUpgradeDiagnostic ??
|
|
5838
|
+
}, ta = (e, t) => {
|
|
5839
|
+
let n = t.onUpgradeDiagnostic ?? ea;
|
|
5834
5840
|
return (t, r) => {
|
|
5835
5841
|
n({
|
|
5836
5842
|
status: e.status,
|
|
@@ -5842,8 +5848,8 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5842
5848
|
}
|
|
5843
5849
|
});
|
|
5844
5850
|
};
|
|
5845
|
-
},
|
|
5846
|
-
let r = n.onUpgradeDiagnostic ??
|
|
5851
|
+
}, na = (e, t, n) => {
|
|
5852
|
+
let r = n.onUpgradeDiagnostic ?? ea;
|
|
5847
5853
|
for (let n of e) r({
|
|
5848
5854
|
...n,
|
|
5849
5855
|
url: t.request.href,
|
|
@@ -5852,8 +5858,8 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5852
5858
|
...n.detail ?? {}
|
|
5853
5859
|
}
|
|
5854
5860
|
});
|
|
5855
|
-
},
|
|
5856
|
-
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n &&
|
|
5861
|
+
}, ra = /\bjson\b/i, ia = async (e, t) => {
|
|
5862
|
+
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && ra.test(r), a;
|
|
5857
5863
|
if (i) try {
|
|
5858
5864
|
a = await e.readBody();
|
|
5859
5865
|
} catch {
|
|
@@ -5867,10 +5873,10 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5867
5873
|
status: e.status,
|
|
5868
5874
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5869
5875
|
}, { requireChallengeChannel: t.requireChallengeChannel });
|
|
5870
|
-
},
|
|
5876
|
+
}, aa = (e) => ye({
|
|
5871
5877
|
status: e.status,
|
|
5872
5878
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5873
|
-
}, { requireChallengeChannel: "header" }).challenge,
|
|
5879
|
+
}, { requireChallengeChannel: "header" }).challenge, oa = (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.`, sa = (e, t) => e instanceof Ri ? { kind: "cancelled" } : e instanceof zi ? { kind: "unsatisfiable" } : e instanceof Xr ? { kind: "unavailable" } : e instanceof Zr ? { kind: "session-changed" } : e instanceof Yr ? {
|
|
5874
5880
|
kind: "insufficient",
|
|
5875
5881
|
obtained: e.obtained,
|
|
5876
5882
|
required: e.required
|
|
@@ -5886,17 +5892,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5886
5892
|
kind: "transport-failure",
|
|
5887
5893
|
retryable: !1,
|
|
5888
5894
|
error: e instanceof Error ? e : Error(String(e))
|
|
5889
|
-
},
|
|
5895
|
+
}, ca = async (e, t, n, r) => {
|
|
5890
5896
|
if (e.status !== 401 && e.status !== 403) return {
|
|
5891
5897
|
kind: "replayed",
|
|
5892
5898
|
response: e
|
|
5893
5899
|
};
|
|
5894
|
-
let { challenge: i, diagnostics: a } = await
|
|
5895
|
-
if (
|
|
5900
|
+
let { challenge: i, diagnostics: a } = await ia(e, t);
|
|
5901
|
+
if (na(a, e, t), !i) return {
|
|
5896
5902
|
kind: "replayed",
|
|
5897
5903
|
response: e
|
|
5898
5904
|
};
|
|
5899
|
-
let o =
|
|
5905
|
+
let o = Ui(i);
|
|
5900
5906
|
return r("elevated-insufficient", {
|
|
5901
5907
|
obtained: n,
|
|
5902
5908
|
required: o
|
|
@@ -5906,7 +5912,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5906
5912
|
required: o,
|
|
5907
5913
|
response: e
|
|
5908
5914
|
};
|
|
5909
|
-
},
|
|
5915
|
+
}, la = async (e, t) => {
|
|
5910
5916
|
if (!t) return {
|
|
5911
5917
|
aborted: !1,
|
|
5912
5918
|
value: await e
|
|
@@ -5933,14 +5939,14 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5933
5939
|
} finally {
|
|
5934
5940
|
n && t.removeEventListener?.("abort", n);
|
|
5935
5941
|
}
|
|
5936
|
-
},
|
|
5942
|
+
}, ua = async (e, t) => {
|
|
5937
5943
|
if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
|
|
5938
|
-
let n =
|
|
5944
|
+
let n = ta(e, t);
|
|
5939
5945
|
if (e.markers.replayed) {
|
|
5940
|
-
if (
|
|
5941
|
-
let { challenge: r, diagnostics: i } = await
|
|
5942
|
-
if (
|
|
5943
|
-
let a = t.readObtainedBar?.() ?? {}, o =
|
|
5946
|
+
if (!$i(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
|
|
5947
|
+
let { challenge: r, diagnostics: i } = await ia(e, t);
|
|
5948
|
+
if (na(i, e, t), !r) return { kind: "not-a-challenge" };
|
|
5949
|
+
let a = t.readObtainedBar?.() ?? {}, o = Ui(r);
|
|
5944
5950
|
return n("elevated-insufficient", {
|
|
5945
5951
|
obtained: a,
|
|
5946
5952
|
required: o
|
|
@@ -5951,12 +5957,12 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5951
5957
|
response: e
|
|
5952
5958
|
};
|
|
5953
5959
|
}
|
|
5954
|
-
if (
|
|
5960
|
+
if (!$i(e.request, t.scope, t.shouldIntercept)) return aa(e) ? (n("challenge-out-of-scope", {
|
|
5955
5961
|
header: e.getHeader("www-authenticate") ?? void 0,
|
|
5956
|
-
message:
|
|
5962
|
+
message: oa(e.request.href, t.scope)
|
|
5957
5963
|
}), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
|
|
5958
|
-
let { challenge: r, diagnostics: i } = await
|
|
5959
|
-
if (
|
|
5964
|
+
let { challenge: r, diagnostics: i } = await ia(e, t);
|
|
5965
|
+
if (na(i, e, t), !r) {
|
|
5960
5966
|
let r = e.getHeader("www-authenticate");
|
|
5961
5967
|
return t.requireChallengeChannel !== "header" && n("no-channel", {
|
|
5962
5968
|
...r ? { header: r } : {},
|
|
@@ -5970,9 +5976,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5970
5976
|
method: e.request.method
|
|
5971
5977
|
}, s, c;
|
|
5972
5978
|
try {
|
|
5973
|
-
s = Promise.resolve(t.elevate(r, o)), c = await
|
|
5979
|
+
s = Promise.resolve(t.elevate(r, o)), c = await la(s, e.signal);
|
|
5974
5980
|
} catch (e) {
|
|
5975
|
-
return
|
|
5981
|
+
return sa(e, void 0);
|
|
5976
5982
|
}
|
|
5977
5983
|
if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
|
|
5978
5984
|
kind: "aborted",
|
|
@@ -5983,7 +5989,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5983
5989
|
kind: "aborted",
|
|
5984
5990
|
reason: e.signal.reason
|
|
5985
5991
|
};
|
|
5986
|
-
let u = l?.obtained ?? t.readObtainedBar?.() ??
|
|
5992
|
+
let u = l?.obtained ?? t.readObtainedBar?.() ?? Ui(r), d = t.authorizationSwap?.(), f = d ? {
|
|
5987
5993
|
from: a?.from ?? d.from,
|
|
5988
5994
|
to: d.to
|
|
5989
5995
|
} : void 0;
|
|
@@ -5992,7 +5998,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
5992
5998
|
try {
|
|
5993
5999
|
p = await e.replay(f ? { authorizationSwap: f } : void 0);
|
|
5994
6000
|
} catch (t) {
|
|
5995
|
-
if (t instanceof
|
|
6001
|
+
if (t instanceof Yr) return l?.waiter.report({
|
|
5996
6002
|
outcome: "insufficient",
|
|
5997
6003
|
obtained: t.obtained,
|
|
5998
6004
|
required: t.required
|
|
@@ -6010,7 +6016,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6010
6016
|
};
|
|
6011
6017
|
throw t;
|
|
6012
6018
|
}
|
|
6013
|
-
let m = await
|
|
6019
|
+
let m = await ca(p, t, u, n);
|
|
6014
6020
|
return m.kind === "insufficient" ? l?.waiter.report({
|
|
6015
6021
|
outcome: "insufficient",
|
|
6016
6022
|
obtained: m.obtained,
|
|
@@ -6019,18 +6025,18 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6019
6025
|
outcome: "replayed",
|
|
6020
6026
|
obtained: u
|
|
6021
6027
|
}), m;
|
|
6022
|
-
},
|
|
6028
|
+
}, da = (e) => {
|
|
6023
6029
|
switch (e.kind) {
|
|
6024
|
-
case "cancelled": return new
|
|
6025
|
-
case "unsatisfiable": return new
|
|
6026
|
-
case "unavailable": return new
|
|
6027
|
-
case "session-changed": return new
|
|
6028
|
-
case "insufficient": return new
|
|
6030
|
+
case "cancelled": return new Ri();
|
|
6031
|
+
case "unsatisfiable": return new zi();
|
|
6032
|
+
case "unavailable": return new Xr();
|
|
6033
|
+
case "session-changed": return new Zr();
|
|
6034
|
+
case "insufficient": return new Yr(e.obtained, e.required);
|
|
6029
6035
|
case "exhausted": return e.error;
|
|
6030
6036
|
case "transport-failure": return e.error;
|
|
6031
6037
|
default: return;
|
|
6032
6038
|
}
|
|
6033
|
-
},
|
|
6039
|
+
}, fa = (e, t, n) => {
|
|
6034
6040
|
switch (e.kind) {
|
|
6035
6041
|
case "replayed": return {
|
|
6036
6042
|
settle: "resolve",
|
|
@@ -6048,21 +6054,21 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6048
6054
|
};
|
|
6049
6055
|
case "cancelled": return n.onCancel === "reject" ? {
|
|
6050
6056
|
settle: "reject",
|
|
6051
|
-
error: new
|
|
6057
|
+
error: new Ri()
|
|
6052
6058
|
} : {
|
|
6053
6059
|
settle: "resolve",
|
|
6054
|
-
value:
|
|
6060
|
+
value: xa(t, e)
|
|
6055
6061
|
};
|
|
6056
6062
|
case "insufficient": return {
|
|
6057
6063
|
settle: "resolve",
|
|
6058
|
-
value:
|
|
6064
|
+
value: xa(e.response?.raw ?? t, e)
|
|
6059
6065
|
};
|
|
6060
6066
|
default: return {
|
|
6061
6067
|
settle: "resolve",
|
|
6062
|
-
value:
|
|
6068
|
+
value: xa(t, e)
|
|
6063
6069
|
};
|
|
6064
6070
|
}
|
|
6065
|
-
},
|
|
6071
|
+
}, pa = (e, t) => {
|
|
6066
6072
|
switch (e.kind) {
|
|
6067
6073
|
case "replayed": return e.response.rejected ? {
|
|
6068
6074
|
settle: "reject",
|
|
@@ -6077,39 +6083,39 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6077
6083
|
};
|
|
6078
6084
|
default: return {
|
|
6079
6085
|
settle: "reject",
|
|
6080
|
-
error:
|
|
6086
|
+
error: da(e) ?? t
|
|
6081
6087
|
};
|
|
6082
6088
|
}
|
|
6083
|
-
},
|
|
6089
|
+
}, ma = /* @__PURE__ */ new WeakSet(), ha = /* @__PURE__ */ new WeakSet(), ga = /* @__PURE__ */ new WeakSet(), _a = /* @__PURE__ */ new WeakSet(), va = /* @__PURE__ */ new WeakSet(), ya = /* @__PURE__ */ new WeakSet(), ba = /* @__PURE__ */ new WeakSet(), xa = (e, t) => {
|
|
6084
6090
|
switch (t.kind) {
|
|
6085
6091
|
case "cancelled":
|
|
6086
|
-
|
|
6092
|
+
ma.add(e);
|
|
6087
6093
|
break;
|
|
6088
6094
|
case "exhausted":
|
|
6089
|
-
|
|
6095
|
+
ha.add(e);
|
|
6090
6096
|
break;
|
|
6091
6097
|
case "insufficient":
|
|
6092
|
-
|
|
6098
|
+
ga.add(e);
|
|
6093
6099
|
break;
|
|
6094
6100
|
case "unsatisfiable":
|
|
6095
|
-
|
|
6101
|
+
_a.add(e);
|
|
6096
6102
|
break;
|
|
6097
6103
|
case "unavailable":
|
|
6098
|
-
|
|
6104
|
+
va.add(e);
|
|
6099
6105
|
break;
|
|
6100
6106
|
case "session-changed":
|
|
6101
|
-
|
|
6107
|
+
ya.add(e);
|
|
6102
6108
|
break;
|
|
6103
|
-
case "transport-failure":
|
|
6109
|
+
case "transport-failure": ba.add(e);
|
|
6104
6110
|
}
|
|
6105
6111
|
return e;
|
|
6106
|
-
},
|
|
6112
|
+
}, Sa = (e) => ma.has(e), Ca = (e) => ha.has(e), wa = (e) => ga.has(e), Ta = (e) => _a.has(e), Ea = (e) => va.has(e), Da = (e) => ya.has(e), Oa = (e) => ba.has(e), ka = "https://passflow-relative.invalid", Aa = () => {
|
|
6107
6113
|
let e = globalThis, t = e.document?.baseURI;
|
|
6108
6114
|
if (typeof t == "string" && t !== "") return t;
|
|
6109
6115
|
let n = e.location?.href;
|
|
6110
|
-
return typeof n == "string" && n !== "" && n !== "about:blank" ? n :
|
|
6111
|
-
},
|
|
6112
|
-
let n = t ===
|
|
6116
|
+
return typeof n == "string" && n !== "" && n !== "about:blank" ? n : ka;
|
|
6117
|
+
}, ja = (e, t = Aa()) => {
|
|
6118
|
+
let n = t === ka, r;
|
|
6113
6119
|
try {
|
|
6114
6120
|
r = new URL(t).origin;
|
|
6115
6121
|
} catch {
|
|
@@ -6135,28 +6141,28 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6135
6141
|
relativeToBase: !1,
|
|
6136
6142
|
sentinelBase: n
|
|
6137
6143
|
};
|
|
6138
|
-
},
|
|
6144
|
+
}, Ma = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Na = (e) => {
|
|
6139
6145
|
let t = [];
|
|
6140
6146
|
if (e == null) return Object.freeze(t);
|
|
6141
6147
|
let n = e;
|
|
6142
6148
|
if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
|
|
6143
|
-
let r =
|
|
6149
|
+
let r = Ma(n, e);
|
|
6144
6150
|
r && t.push(r);
|
|
6145
6151
|
}), Object.freeze(t);
|
|
6146
6152
|
if (Array.isArray(e)) {
|
|
6147
6153
|
for (let n of e) if (Array.isArray(n) && n.length >= 2) {
|
|
6148
|
-
let e =
|
|
6154
|
+
let e = Ma(String(n[0]), n[1]);
|
|
6149
6155
|
e && t.push(e);
|
|
6150
6156
|
}
|
|
6151
6157
|
return Object.freeze(t);
|
|
6152
6158
|
}
|
|
6153
6159
|
if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
|
|
6154
|
-
let e =
|
|
6160
|
+
let e = Ma(n, Array.isArray(r) ? r.join(", ") : r);
|
|
6155
6161
|
e && t.push(e);
|
|
6156
6162
|
}
|
|
6157
6163
|
return Object.freeze(t);
|
|
6158
|
-
},
|
|
6159
|
-
let t = e.base === void 0 ?
|
|
6164
|
+
}, Pa = (e) => {
|
|
6165
|
+
let t = e.base === void 0 ? ja(e.url) : ja(e.url, e.base), n = {
|
|
6160
6166
|
raw: e.url,
|
|
6161
6167
|
href: t.href,
|
|
6162
6168
|
dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
|
|
@@ -6165,29 +6171,29 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6165
6171
|
resolved: t.resolved,
|
|
6166
6172
|
relativeToBase: t.relativeToBase,
|
|
6167
6173
|
method: (e.method ?? "GET").toUpperCase(),
|
|
6168
|
-
headers:
|
|
6174
|
+
headers: Na(e.headers),
|
|
6169
6175
|
bodyKind: e.bodyKind,
|
|
6170
6176
|
..."body" in e ? { body: e.body } : {}
|
|
6171
6177
|
};
|
|
6172
6178
|
return Object.freeze(n);
|
|
6173
|
-
},
|
|
6179
|
+
}, Fa = (e, t) => {
|
|
6174
6180
|
if (!t || t.from === t.to) return e;
|
|
6175
6181
|
let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
|
|
6176
6182
|
return n ? Object.freeze(r) : e;
|
|
6177
|
-
},
|
|
6183
|
+
}, Ia = (e) => {
|
|
6178
6184
|
let t = {};
|
|
6179
6185
|
for (let [n, r] of e) t[n] = r;
|
|
6180
6186
|
return t;
|
|
6181
|
-
},
|
|
6187
|
+
}, La = /* @__PURE__ */ new Set([
|
|
6182
6188
|
"GET",
|
|
6183
6189
|
"HEAD",
|
|
6184
6190
|
"OPTIONS"
|
|
6185
|
-
]),
|
|
6191
|
+
]), Ra = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, za = (e) => typeof e == "string" ? e : Ra(e) ? e.url : String(e), Ba = (e, t) => (t?.method ?? (Ra(e) ? e.method : void 0) ?? "GET").toUpperCase(), Va = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", Ha = (e) => {
|
|
6186
6192
|
if (typeof e == "string") return e.length;
|
|
6187
6193
|
let t = e;
|
|
6188
6194
|
if (typeof t?.size == "number") return t.size;
|
|
6189
6195
|
if (typeof t?.byteLength == "number") return t.byteLength;
|
|
6190
|
-
},
|
|
6196
|
+
}, Ua = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? La.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), Wa = (e, t, n, r, i) => ({
|
|
6191
6197
|
replayable: !1,
|
|
6192
6198
|
bodyKind: e,
|
|
6193
6199
|
reason: t,
|
|
@@ -6195,11 +6201,11 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6195
6201
|
forwardInit: i,
|
|
6196
6202
|
snapshot: r,
|
|
6197
6203
|
replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
|
|
6198
|
-
}),
|
|
6204
|
+
}), Ga = (e, t) => Ia(Fa(e.headers, t?.authorizationSwap)), Ka = (e) => {
|
|
6199
6205
|
if (!e || !("headers" in e)) return e;
|
|
6200
6206
|
let { headers: t, ...n } = e;
|
|
6201
6207
|
return n;
|
|
6202
|
-
},
|
|
6208
|
+
}, qa = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : Ra(e) ? e.headers : void 0, Ja = (e) => {
|
|
6203
6209
|
if (e === null || typeof e == "string") return e;
|
|
6204
6210
|
if (typeof FormData < "u" && e instanceof FormData) {
|
|
6205
6211
|
let t = new FormData();
|
|
@@ -6207,18 +6213,18 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6207
6213
|
return t;
|
|
6208
6214
|
}
|
|
6209
6215
|
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;
|
|
6210
|
-
},
|
|
6211
|
-
let r =
|
|
6216
|
+
}, Ya = (e, t, n) => new Request(e, { headers: Ga(t, n) }), Xa = (e, t, n) => {
|
|
6217
|
+
let r = za(e), i = Ba(e, t), a = qa(e, t), o = (e, t) => Pa({
|
|
6212
6218
|
url: r,
|
|
6213
6219
|
method: i,
|
|
6214
6220
|
headers: a,
|
|
6215
6221
|
bodyKind: e,
|
|
6216
6222
|
...t === void 0 ? {} : { body: t }
|
|
6217
6223
|
});
|
|
6218
|
-
if (
|
|
6224
|
+
if (Ra(e)) {
|
|
6219
6225
|
if (e.body === null || e.body === void 0) {
|
|
6220
6226
|
let a = o("none");
|
|
6221
|
-
return
|
|
6227
|
+
return Ua(n, {
|
|
6222
6228
|
url: r,
|
|
6223
6229
|
method: i,
|
|
6224
6230
|
bodyKind: "none"
|
|
@@ -6228,20 +6234,20 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6228
6234
|
forwardInput: e,
|
|
6229
6235
|
forwardInit: t,
|
|
6230
6236
|
snapshot: a,
|
|
6231
|
-
replay: (n, r) => n(
|
|
6232
|
-
} :
|
|
6237
|
+
replay: (n, r) => n(Ya(e, a, r), Ka(t))
|
|
6238
|
+
} : Wa("none", "the replay policy refused this request", e, a, t);
|
|
6233
6239
|
}
|
|
6234
6240
|
let a = o("request-clone");
|
|
6235
|
-
if (!
|
|
6241
|
+
if (!Ua(n, {
|
|
6236
6242
|
url: r,
|
|
6237
6243
|
method: i,
|
|
6238
6244
|
bodyKind: "request-clone"
|
|
6239
|
-
})) return
|
|
6245
|
+
})) return Wa("request-clone", "the replay policy refused this request", e, a, t);
|
|
6240
6246
|
let s;
|
|
6241
6247
|
try {
|
|
6242
6248
|
s = e.clone();
|
|
6243
6249
|
} catch {
|
|
6244
|
-
return
|
|
6250
|
+
return Wa("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
|
|
6245
6251
|
}
|
|
6246
6252
|
return {
|
|
6247
6253
|
replayable: !0,
|
|
@@ -6249,17 +6255,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6249
6255
|
forwardInput: e,
|
|
6250
6256
|
forwardInit: t,
|
|
6251
6257
|
snapshot: a,
|
|
6252
|
-
replay: (e, n) => e(
|
|
6258
|
+
replay: (e, n) => e(Ya(s, a, n), Ka(t))
|
|
6253
6259
|
};
|
|
6254
6260
|
}
|
|
6255
|
-
let s =
|
|
6256
|
-
if (s === "one-shot") return
|
|
6257
|
-
if (!
|
|
6261
|
+
let s = Va(t?.body);
|
|
6262
|
+
if (s === "one-shot") return Wa("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
|
|
6263
|
+
if (!Ua(n, {
|
|
6258
6264
|
url: r,
|
|
6259
6265
|
method: i,
|
|
6260
6266
|
bodyKind: s
|
|
6261
|
-
},
|
|
6262
|
-
let c = t && "body" in t ?
|
|
6267
|
+
}, Ha(t?.body))) return Wa(s, "the replay policy refused this request", e, o(s), t);
|
|
6268
|
+
let c = t && "body" in t ? Ja(t.body ?? null) : void 0, l = o(s, c);
|
|
6263
6269
|
return {
|
|
6264
6270
|
replayable: !0,
|
|
6265
6271
|
bodyKind: s,
|
|
@@ -6267,21 +6273,21 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6267
6273
|
forwardInit: t,
|
|
6268
6274
|
snapshot: l,
|
|
6269
6275
|
replay: (e, n) => e(l.dispatchUrl, {
|
|
6270
|
-
...
|
|
6276
|
+
...Ka(t),
|
|
6271
6277
|
...c === void 0 ? {} : { body: c },
|
|
6272
|
-
headers:
|
|
6278
|
+
headers: Ga(l, n),
|
|
6273
6279
|
method: l.method
|
|
6274
6280
|
})
|
|
6275
6281
|
};
|
|
6276
|
-
},
|
|
6277
|
-
if (!
|
|
6282
|
+
}, Za = (e) => typeof e == "object" && !!e, Qa = (e) => (t) => {
|
|
6283
|
+
if (!Za(e)) return;
|
|
6278
6284
|
let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
|
|
6279
6285
|
return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
|
|
6280
|
-
},
|
|
6286
|
+
}, $a = (e) => {
|
|
6281
6287
|
let t = e?.url ?? "", n = e?.baseURL;
|
|
6282
6288
|
return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
6283
|
-
},
|
|
6284
|
-
let r = Fa(
|
|
6289
|
+
}, eo = (e) => (e?.method ?? "GET").toUpperCase(), to = (e) => e == null ? "none" : Za(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", no = (e, t, n) => {
|
|
6290
|
+
let r = Ia(Fa(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
|
|
6285
6291
|
return {
|
|
6286
6292
|
...e,
|
|
6287
6293
|
...i ? { baseURL: void 0 } : {},
|
|
@@ -6290,10 +6296,10 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6290
6296
|
headers: r,
|
|
6291
6297
|
..."body" in t ? { data: t.body } : {}
|
|
6292
6298
|
};
|
|
6293
|
-
},
|
|
6294
|
-
let o = t ?? e?.config, s =
|
|
6295
|
-
url:
|
|
6296
|
-
method:
|
|
6299
|
+
}, ro = (e, t, n, r, i, a) => {
|
|
6300
|
+
let o = t ?? e?.config, s = to(o?.data), c = a ?? Pa({
|
|
6301
|
+
url: $a(o),
|
|
6302
|
+
method: eo(o),
|
|
6297
6303
|
headers: o?.headers,
|
|
6298
6304
|
bodyKind: s,
|
|
6299
6305
|
body: o?.data
|
|
@@ -6301,22 +6307,22 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6301
6307
|
url: c.href,
|
|
6302
6308
|
method: c.method,
|
|
6303
6309
|
bodyKind: s
|
|
6304
|
-
}, u = s !== "one-shot" &&
|
|
6310
|
+
}, u = s !== "one-shot" && Ua(i.replay, l);
|
|
6305
6311
|
return {
|
|
6306
6312
|
status: e?.status ?? 0,
|
|
6307
|
-
getHeader:
|
|
6313
|
+
getHeader: Qa(e?.headers),
|
|
6308
6314
|
readBody: async () => e?.data,
|
|
6309
6315
|
request: c,
|
|
6310
6316
|
replay: async (e) => {
|
|
6311
|
-
let t = Ee(
|
|
6317
|
+
let t = Ee(no(o ?? {}, c, e));
|
|
6312
6318
|
try {
|
|
6313
6319
|
let e = await r(t);
|
|
6314
|
-
return
|
|
6320
|
+
return ro(e, e?.config ?? t, e, r, i, c);
|
|
6315
6321
|
} catch (e) {
|
|
6316
|
-
let n =
|
|
6317
|
-
if (!n.response || typeof n.response.status != "number" ||
|
|
6322
|
+
let n = Za(e) ? e : {};
|
|
6323
|
+
if (!n.response || typeof n.response.status != "number" || Vr(e)) throw e;
|
|
6318
6324
|
return {
|
|
6319
|
-
...
|
|
6325
|
+
...ro(n.response, n.config ?? t, e, r, i, c),
|
|
6320
6326
|
rejected: !0
|
|
6321
6327
|
};
|
|
6322
6328
|
}
|
|
@@ -6330,19 +6336,19 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6330
6336
|
replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
|
|
6331
6337
|
signal: o?.signal
|
|
6332
6338
|
};
|
|
6333
|
-
},
|
|
6334
|
-
let r =
|
|
6339
|
+
}, io = (e, t) => async (n) => {
|
|
6340
|
+
let r = Ji(e), i = Za(n) ? n : {}, a = pa(await ua(ro(i.response, i.config, i.response, t, r), r), n);
|
|
6335
6341
|
if (a.settle === "reject") throw a.error;
|
|
6336
6342
|
return a.value;
|
|
6337
|
-
},
|
|
6338
|
-
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,
|
|
6343
|
+
}, ao = (e, t, n) => {
|
|
6344
|
+
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, io(t, i)), o = !1;
|
|
6339
6345
|
return () => {
|
|
6340
6346
|
o || (o = !0, e.interceptors.response.eject(a));
|
|
6341
6347
|
};
|
|
6342
|
-
},
|
|
6348
|
+
}, oo = (t, n) => {
|
|
6343
6349
|
let r = e.create(t);
|
|
6344
6350
|
return n(r), r;
|
|
6345
|
-
},
|
|
6351
|
+
}, so = 0, co = (e, t) => {
|
|
6346
6352
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
6347
6353
|
if (n) return {
|
|
6348
6354
|
get aborted() {
|
|
@@ -6356,34 +6362,34 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6356
6362
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
6357
6363
|
} : {}
|
|
6358
6364
|
};
|
|
6359
|
-
},
|
|
6365
|
+
}, lo = (e) => (t) => e.headers?.get(t), uo = (e, t, n, r, i) => ({
|
|
6360
6366
|
status: e.status,
|
|
6361
|
-
getHeader:
|
|
6367
|
+
getHeader: lo(e),
|
|
6362
6368
|
readBody: () => e.clone().json(),
|
|
6363
6369
|
request: t.snapshot,
|
|
6364
|
-
replay: async (e) =>
|
|
6370
|
+
replay: async (e) => uo(await t.replay(n, e), t, n, r, i),
|
|
6365
6371
|
markers: r,
|
|
6366
6372
|
raw: e,
|
|
6367
6373
|
replayable: t.replayable,
|
|
6368
6374
|
replayUnsupportedReason: t.reason,
|
|
6369
6375
|
signal: i,
|
|
6370
6376
|
responseType: e.type
|
|
6371
|
-
}),
|
|
6377
|
+
}), fo = (e, t) => {
|
|
6372
6378
|
let n = (t, n) => {
|
|
6373
|
-
|
|
6379
|
+
so += 1;
|
|
6374
6380
|
try {
|
|
6375
6381
|
return e(t, n);
|
|
6376
6382
|
} finally {
|
|
6377
|
-
--
|
|
6383
|
+
--so;
|
|
6378
6384
|
}
|
|
6379
6385
|
};
|
|
6380
6386
|
return async (e, r) => {
|
|
6381
|
-
if (
|
|
6382
|
-
let i =
|
|
6387
|
+
if (so > 0) return n(e, r);
|
|
6388
|
+
let i = Ji(t), a = Xa(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = fa(await ua(uo(o, a, n, {}, co(e, r)), i), o, i);
|
|
6383
6389
|
if (s.settle === "reject") throw s.error;
|
|
6384
6390
|
return s.value;
|
|
6385
6391
|
};
|
|
6386
|
-
},
|
|
6392
|
+
}, po = new Set(ji.filter((e) => !e.requiresPrepare).map((e) => e.type)), mo = (e) => {
|
|
6387
6393
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
6388
6394
|
kind: "protocol",
|
|
6389
6395
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -6395,17 +6401,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6395
6401
|
webauthn: e.webauthn,
|
|
6396
6402
|
codeSentTo: e.code_sent_to
|
|
6397
6403
|
};
|
|
6398
|
-
},
|
|
6404
|
+
}, ho = (e) => Vr(e) && !Hr(e), go = (e) => ({
|
|
6399
6405
|
async prepare(t) {
|
|
6400
|
-
if (!
|
|
6406
|
+
if (!po.has(t)) try {
|
|
6401
6407
|
let n = e.relyingPartyId?.();
|
|
6402
|
-
return
|
|
6408
|
+
return mo(await e.startUpgrade(n ? {
|
|
6403
6409
|
method: t,
|
|
6404
6410
|
relying_party_id: n
|
|
6405
6411
|
} : { method: t }));
|
|
6406
6412
|
} catch (e) {
|
|
6407
|
-
if (
|
|
6408
|
-
let t =
|
|
6413
|
+
if (ho(e)) throw e;
|
|
6414
|
+
let t = Kr(e, "start");
|
|
6409
6415
|
if (t.kind === "prepare_not_required") return;
|
|
6410
6416
|
throw t;
|
|
6411
6417
|
}
|
|
@@ -6422,17 +6428,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6422
6428
|
assertion: n
|
|
6423
6429
|
});
|
|
6424
6430
|
} catch (t) {
|
|
6425
|
-
if (
|
|
6426
|
-
let n =
|
|
6427
|
-
throw n.status === 401 &&
|
|
6431
|
+
if (ho(t)) throw t;
|
|
6432
|
+
let n = Kr(t, "refresh");
|
|
6433
|
+
throw n.status === 401 && Jr(n) && e.markSessionInvalid?.(), n;
|
|
6428
6434
|
}
|
|
6429
6435
|
}
|
|
6430
|
-
}),
|
|
6436
|
+
}), _o = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), vo = (e) => {
|
|
6431
6437
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
6432
6438
|
let i = () => {
|
|
6433
6439
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
6434
6440
|
};
|
|
6435
|
-
return
|
|
6441
|
+
return go({
|
|
6436
6442
|
...e,
|
|
6437
6443
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
6438
6444
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -6443,7 +6449,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6443
6449
|
});
|
|
6444
6450
|
}, i = (t, n) => {
|
|
6445
6451
|
let i = {}, a = {
|
|
6446
|
-
controller: new
|
|
6452
|
+
controller: new qi({
|
|
6447
6453
|
transport: r(() => i.current),
|
|
6448
6454
|
prompt: t.prompt,
|
|
6449
6455
|
platform: e.platform,
|
|
@@ -6455,17 +6461,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6455
6461
|
options: t,
|
|
6456
6462
|
scope: {
|
|
6457
6463
|
passflow: e.passflowDomain,
|
|
6458
|
-
backend:
|
|
6464
|
+
backend: _o(t.backend)
|
|
6459
6465
|
},
|
|
6460
6466
|
generation: n
|
|
6461
6467
|
};
|
|
6462
6468
|
return i.current = a, a;
|
|
6463
6469
|
}, a = async (r, i) => {
|
|
6464
6470
|
let a = t;
|
|
6465
|
-
if (!a) throw new
|
|
6471
|
+
if (!a) throw new Xr("Step-up verification is not enabled on this Passflow instance");
|
|
6466
6472
|
a.controller.active || (a.pin = e.readSessionPin?.());
|
|
6467
6473
|
let o = await a.controller.elevate(r, i);
|
|
6468
|
-
if (!n(a)) throw new
|
|
6474
|
+
if (!n(a)) throw new Zr();
|
|
6469
6475
|
return o;
|
|
6470
6476
|
}, o = () => {
|
|
6471
6477
|
let n = t, r = n?.scope ?? {
|
|
@@ -6509,9 +6515,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6509
6515
|
let r = [];
|
|
6510
6516
|
if (e.attachInternalSeam) {
|
|
6511
6517
|
let t = e.attachInternalSeam;
|
|
6512
|
-
t((e) =>
|
|
6518
|
+
t((e) => io(o, e)), r.push(() => t(void 0));
|
|
6513
6519
|
}
|
|
6514
|
-
n.interceptFetch && r.push(
|
|
6520
|
+
n.interceptFetch && r.push(Ft((e, t, n) => fo(e, o)(t, n), {
|
|
6515
6521
|
priority: 20,
|
|
6516
6522
|
name: "passflow-upgrade"
|
|
6517
6523
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -6542,18 +6548,18 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6542
6548
|
withAuth: {
|
|
6543
6549
|
enumerable: !0,
|
|
6544
6550
|
value: (e) => {
|
|
6545
|
-
if (e) return
|
|
6551
|
+
if (e) return fo(e, o);
|
|
6546
6552
|
let t = typeof globalThis > "u" ? void 0 : globalThis;
|
|
6547
6553
|
if (!t || typeof t.fetch != "function") throw Error("Passflow: withAuth() needs a fetch to wrap — this runtime has none.");
|
|
6548
|
-
return
|
|
6554
|
+
return fo(t.fetch.bind(t), o);
|
|
6549
6555
|
}
|
|
6550
6556
|
},
|
|
6551
6557
|
attachAuth: {
|
|
6552
6558
|
enumerable: !0,
|
|
6553
|
-
value: (e) =>
|
|
6559
|
+
value: (e) => ao(e, o)
|
|
6554
6560
|
}
|
|
6555
6561
|
});
|
|
6556
|
-
},
|
|
6562
|
+
}, yo, bo = class {
|
|
6557
6563
|
get origin() {
|
|
6558
6564
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
6559
6565
|
}
|
|
@@ -6565,9 +6571,9 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6565
6571
|
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? ae, this.deferFederatedLanding = e.deferFederatedLanding ?? !1, this.storageManager = new ne({
|
|
6566
6572
|
prefix: e.keyStoragePrefix ?? "",
|
|
6567
6573
|
storage: this.platform.storage
|
|
6568
|
-
}), this.deviceService = new re(this.storageManager), this.authApi = new
|
|
6569
|
-
let i =
|
|
6570
|
-
this.authService = new
|
|
6574
|
+
}), this.deviceService = new re(this.storageManager), this.authApi = new ut(e, this.storageManager, this.deviceService), this.appApi = new it(e, this.storageManager, this.deviceService), this.userApi = new xt(e, this.storageManager, this.deviceService), this.settingApi = new pt(e, this.storageManager, this.deviceService), this.tenantApi = new mt(e, this.storageManager, this.deviceService), this.invitationApi = new ft(e, this.storageManager, this.deviceService), this.twoFactorApi = new yt(e, this.storageManager, this.deviceService), this.upgradeApi = new bt(e, this.storageManager, this.deviceService), this.upgradeDomain = ke(e.url), this.subscribeStore = new kr(), this.tokenCacheService = new Ci(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? d, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
|
|
6575
|
+
let i = Jn(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
|
|
6576
|
+
this.authService = new yi(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
|
|
6571
6577
|
createSession: this.createSessionCallback,
|
|
6572
6578
|
expiredSession: this.expiredSessionCallback
|
|
6573
6579
|
}, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
|
|
@@ -6575,7 +6581,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6575
6581
|
...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
|
|
6576
6582
|
}, () => this.readAppSettings()), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
6577
6583
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
6578
|
-
this.userService = new
|
|
6584
|
+
this.userService = new Ti(this.userApi, this.deviceService, this.platform), this.tenantService = new Si(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new bi(this.invitationApi), this.twoFactorService = new wi(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = vo({
|
|
6579
6585
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
6580
6586
|
commitRefresh: async (e, t) => {
|
|
6581
6587
|
await this.authService.refreshToken(e, t);
|
|
@@ -6600,6 +6606,17 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6600
6606
|
},
|
|
6601
6607
|
attachInternalSeam: (e) => this.attachUpgradeSeam(e),
|
|
6602
6608
|
onSessionChange: (e) => this.subscribeToSessionChange(e)
|
|
6609
|
+
}), this.hostedUpgrade = vo({
|
|
6610
|
+
startUpgrade: (e) => this.upgradeApi.startHostedUpgrade(e),
|
|
6611
|
+
commitRefresh: (e) => this.upgradeApi.commitHostedUpgrade(e),
|
|
6612
|
+
canCommit: () => ({ ok: !0 }),
|
|
6613
|
+
readSessionPin: () => void 0,
|
|
6614
|
+
readObtainedBar: () => void 0,
|
|
6615
|
+
markSessionInvalid: () => {},
|
|
6616
|
+
platform: this.platform,
|
|
6617
|
+
passflowDomain: this.upgradeDomain,
|
|
6618
|
+
...e.upgrade?.factors ? { factors: e.upgrade.factors } : {},
|
|
6619
|
+
...e.upgrade?.relyingPartyId ? { relyingPartyId: () => e.upgrade?.relyingPartyId } : {}
|
|
6603
6620
|
}), e.parseQueryParams && this.checkAndSetTokens(), this.setTokensToCacheFromLocalStorage();
|
|
6604
6621
|
}
|
|
6605
6622
|
readAppSettings() {
|
|
@@ -6625,7 +6642,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6625
6642
|
return this.upgrade.attachAuth(e);
|
|
6626
6643
|
}
|
|
6627
6644
|
createClient(e) {
|
|
6628
|
-
return
|
|
6645
|
+
return oo(e, (e) => this.upgrade.attachAuth(e));
|
|
6629
6646
|
}
|
|
6630
6647
|
readAssuranceBar() {
|
|
6631
6648
|
let e = this.storageManager.getToken(M.access_token);
|
|
@@ -6708,7 +6725,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6708
6725
|
}
|
|
6709
6726
|
let n = t.get("access_token"), r = t.get("refresh_token"), i = t.get("id_token"), a = t.get("state") ?? void 0, o = t.get("scopes")?.split(",") ?? this.scopes;
|
|
6710
6727
|
if (n) {
|
|
6711
|
-
if (
|
|
6728
|
+
if (!ei(n)) {
|
|
6712
6729
|
W(this.subscribeStore, {
|
|
6713
6730
|
operation: "tokens.from-url",
|
|
6714
6731
|
message: "Invalid access token format received",
|
|
@@ -6716,7 +6733,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6716
6733
|
}), this.cleanupUrlParams(e);
|
|
6717
6734
|
return;
|
|
6718
6735
|
}
|
|
6719
|
-
if (r &&
|
|
6736
|
+
if (r && !ei(r)) {
|
|
6720
6737
|
W(this.subscribeStore, {
|
|
6721
6738
|
operation: "tokens.from-url",
|
|
6722
6739
|
message: "Invalid refresh token format received",
|
|
@@ -6724,7 +6741,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6724
6741
|
}), this.cleanupUrlParams(e);
|
|
6725
6742
|
return;
|
|
6726
6743
|
}
|
|
6727
|
-
if (i &&
|
|
6744
|
+
if (i && !ei(i)) {
|
|
6728
6745
|
W(this.subscribeStore, {
|
|
6729
6746
|
operation: "tokens.from-url",
|
|
6730
6747
|
message: "Invalid ID token format received",
|
|
@@ -6739,8 +6756,8 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6739
6756
|
scopes: o
|
|
6740
6757
|
};
|
|
6741
6758
|
this.cleanupUrlParams(e), this.error = void 0, this.readAppSettings().catch(() => void 0).then((e) => {
|
|
6742
|
-
if (e?.pkce_enabled !== !1) throw
|
|
6743
|
-
return
|
|
6759
|
+
if (e?.pkce_enabled !== !1) throw nn();
|
|
6760
|
+
return Pr(this.url, this.appId, t);
|
|
6744
6761
|
}).then(() => {
|
|
6745
6762
|
this.storageManager.clearDeliveryMode(), this.storageManager.saveTokens(t), this.tokenCacheService.setTokensCache(t), this.authService.refresh.sessionStarted();
|
|
6746
6763
|
}).then(() => (this.subscribeStore.notify(Z.SignIn, {
|
|
@@ -6775,7 +6792,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6775
6792
|
if (!n) return !1;
|
|
6776
6793
|
t.delete("tfa_token");
|
|
6777
6794
|
let r = t.toString();
|
|
6778
|
-
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")),
|
|
6795
|
+
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), ei(n) ? (this.subscribeStore.notify(Z.TwoFactorRequired, {
|
|
6779
6796
|
email: "",
|
|
6780
6797
|
challengeId: "",
|
|
6781
6798
|
tfaToken: n
|
|
@@ -6788,7 +6805,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
6788
6805
|
checkErrorsFromURL() {
|
|
6789
6806
|
let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
|
|
6790
6807
|
if (e) {
|
|
6791
|
-
let t =
|
|
6808
|
+
let t = ti(e);
|
|
6792
6809
|
return Error(t);
|
|
6793
6810
|
}
|
|
6794
6811
|
}
|
|
@@ -7194,7 +7211,7 @@ var oi = "passflow_2fa_pkce", si = 3e5, ci = "passflow_pwless_pending", li = 3e3
|
|
|
7194
7211
|
this.twoFactorService.clearMagicLinkSession();
|
|
7195
7212
|
}
|
|
7196
7213
|
};
|
|
7197
|
-
|
|
7198
|
-
export { a as APP_ID_HEADER_KEY, Pe as APP_SECRET_NAMES, o as AUTHORIZATION_HEADER_KEY,
|
|
7214
|
+
yo = bo, yo.version = l;
|
|
7215
|
+
export { a as APP_ID_HEADER_KEY, Pe as APP_SECRET_NAMES, o as AUTHORIZATION_HEADER_KEY, it as AppAPI, ut as AuthAPI, yi as AuthService, dt as CLIAuthAPI, p as DEFAULT_GROUP_NAME, d as DEFAULT_SCOPES, ji as DEFAULT_UPGRADE_FACTORS, s as DEVICE_ID_HEADER_KEY, c as DEVICE_TYPE_HEADER_KEY, x as ERROR_MESSAGE_MAX_LENGTH, St as FETCH_PRIORITY_OIDC, Ct as FETCH_PRIORITY_UPGRADE, wt as FetchMiddlewareContractError, le as INSUFFICIENT_USER_AUTHENTICATION, ft as InvitationAPI, bi as InvitationService, Wt as M2MClient, zt as M2MConfigError, H as M2MError, Bt as M2MErrorCodes, Lt as M2MNetworkError, Rt as M2MTokenParseError, Vt as M2M_DEFAULTS, Fe as MASKED_SECRET_PREFIX, u as MINIMAL_DEFAULT_SCOPES, Re as OS, f as PASSFLOW_CLOUD_URL, h as POPUP_HEIGHT, g as POPUP_POLL_INTERVAL_MS, _ as POPUP_TIMEOUT_MS, m as POPUP_WIDTH, bo as Passflow, B as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, V as PassflowError, Z as PassflowEvent, U as PassflowOidcError, J as PassflowRefreshError, ie as PopupClosedError, Ne as Providers, Fr as RECOVERABLE_COMMIT_ERROR_IDS, Zn as REFRESH_AUTH_FAILURE_IDS, q as RefreshErrorId, Oe as RequestMethod, l as SDK_VERSION, je as SERVICE_UNAVAILABLE_ERROR_ID, Me as SERVICE_UNAVAILABLE_MESSAGE, Ir as SESSION_INVALIDATING_COMMIT_ERROR_IDS, Ie as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, te as SessionState, pt as SettingAPI, v as TOKEN_EXPIRY_BUFFER_SECONDS, mt as TenantAPI, Si as TenantService, xi as TenantUserMembership, Ci as TokenCacheService, N as TokenDeliveryMode, M as TokenType, yt as TwoFactorApiClient, Ve as TwoFactorPolicy, wi as TwoFactorService, ue as UPGRADE_REQUIRED, b as USERNAME_MAX_LENGTH, y as USERNAME_MIN_LENGTH, bt as UpgradeAPI, Ri as UpgradeCancelledError, lr as UpgradeCommitInterruptedError, qi as UpgradeController, Q as UpgradeErrorIds, Ei as UpgradeFactorError, Yr as UpgradeInsufficientError, Zr as UpgradeSessionChangedError, $ as UpgradeTransportError, Xr as UpgradeUnavailableError, zi as UpgradeUnsatisfiableError, xt as UserAPI, Ti as UserService, F as WebAdapter, Kr as classifyUpgradeError, Mi as factorRegistry, It as fetchRegistryState, ze as getOSFromDeviceType, Jr as invalidatesSessionOnCommit, Ae as isEmailVerificationStep, Le as isMaskedSecret, qr as isRecoverableCommitFailure, Rr as isRetryableUpgradeKind, A as isTokenExpired, Sa as isUpgradeCancelled, Ca as isUpgradeExhausted, wa as isUpgradeInsufficient, Da as isUpgradeSessionChanged, Hr as isUpgradeTransportError, Oa as isUpgradeTransportFailure, Ea as isUpgradeUnavailable, Ta as isUpgradeUnsatisfiable, ni as isValidEmail, ei as isValidJWTFormat, ri as isValidPhoneNumber, ii as isValidUsername, ge as parseChallengeBody, he as parseChallengeHeader, j as parseToken, be as parseUpgradeChallenge, Ai as passkeyFactor, Be as pathWithParams, ki as recoveryCodesFactor, Ft as registerFetchMiddleware, ce as requiredAcrLevel, ke as resolveUpgradeDomain, ti as sanitizeErrorMessage, Li as selectFactors, Oi as totpFactor, ae as webAdapter };
|
|
7199
7216
|
|
|
7200
7217
|
//# sourceMappingURL=index.mjs.map
|