@passflow/core 0.35.2 → 0.36.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 +122 -41
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +158 -3
- package/dist/index.d.ts +158 -3
- package/dist/index.mjs +822 -734
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ var i = "__passflowAntiBot", a = (e, t) => {
|
|
|
11
11
|
if (typeof e != "object" || !e) return;
|
|
12
12
|
let t = e[i];
|
|
13
13
|
return typeof t == "object" && t ? t : void 0;
|
|
14
|
-
}, s = "0.
|
|
14
|
+
}, s = "0.36.0", c = "X-Passflow-Clientid", l = "Authorization", u = "X-Passflow-DeviceId", d = "X-Passflow-DeviceType", f = "X-Passflow-Anti-Bot", p = "X-Passflow-Agent-Tool", m = "passflow_auth", h = s, g = [
|
|
15
15
|
"id",
|
|
16
16
|
"offline",
|
|
17
17
|
"openid"
|
|
@@ -675,7 +675,7 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
675
675
|
}), Le = (e) => Ne(e, Me), Re = /* @__PURE__ */ function(e) {
|
|
676
676
|
return e.GET = "get", e.POST = "post", e.PUT = "put", e.PATCH = "patch", e.DELETE = "delete", e;
|
|
677
677
|
}({}), z = /* @__PURE__ */ function(e) {
|
|
678
|
-
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.userSessions = "/user/sessions", e.userSessionsRevokeOthers = "/user/sessions/revoke-others", 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.antiBotChallenge = "/auth/anti-bot/challenge", e.deviceAntiBotChallenge = "/oidc/device/anti-bot/challenge", e;
|
|
678
|
+
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.userSessions = "/user/sessions", e.userSessionsRevokeOthers = "/user/sessions/revoke-others", 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.antiBotChallenge = "/auth/anti-bot/challenge", e.deviceAntiBotChallenge = "/oidc/device/anti-bot/challenge", e.enterpriseResolve = "/auth/enterprise/resolve", e.enterpriseStart = "/auth/enterprise/start", e;
|
|
679
679
|
}({}), ze = /* @__PURE__ */ function(e) {
|
|
680
680
|
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;
|
|
681
681
|
}({}), Be = (e) => {
|
|
@@ -693,41 +693,41 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
693
693
|
constructor(e, t) {
|
|
694
694
|
super(), this.name = "PassflowError", this.id = e?.id ?? "unknown", this.message = e?.message ?? e ?? "Something went wrong", this.status = e?.status ?? 500, this.location = e?.location ?? "unknown", this.time = e?.time ?? (/* @__PURE__ */ new Date()).toISOString(), t?.cause !== void 0 && (this.cause = t.cause);
|
|
695
695
|
}
|
|
696
|
-
}, We = "error.api.password.change.required", Ge = "error.api.anti_bot.required", Ke = "error.api.anti_bot.failed", qe = "error.api.anti_bot.unavailable", Je = "error.anti_bot.provider_missing", Ye = "error.anti_bot.provider_failed", Xe = "error.anti_bot.solve_failed", Ze = class extends B {
|
|
696
|
+
}, We = "error.api.password.change.required", Ge = "error.api.anti_bot.required", Ke = "error.api.anti_bot.failed", qe = "error.api.anti_bot.unavailable", Je = "error.anti_bot.provider_missing", Ye = "error.anti_bot.provider_failed", Xe = "error.anti_bot.solve_failed", Ze = "error.api.enterprise.email_invalid", Qe = "error.api.enterprise.start_input", $e = "error.api.enterprise.no_connection", et = "error.api.enterprise.connection_ambiguous", tt = class extends B {
|
|
697
697
|
constructor(e, t) {
|
|
698
698
|
super(e, t), this.name = "PassflowPasswordChangeRequiredError";
|
|
699
699
|
}
|
|
700
|
-
},
|
|
700
|
+
}, nt = /* @__PURE__ */ function(e) {
|
|
701
701
|
return e.google = "google", e.facebook = "facebook", e;
|
|
702
|
-
}({}),
|
|
702
|
+
}({}), rt = Object.freeze([
|
|
703
703
|
"debug_otp_code_for_registration",
|
|
704
704
|
"fcm_server_key",
|
|
705
705
|
"webpush_vapid_private_key"
|
|
706
|
-
]),
|
|
706
|
+
]), it = "mask://", at = "error.server.update.settings.masked.value.unknown", ot = (e) => typeof e == "string" && e.startsWith("mask://"), st = /* @__PURE__ */ function(e) {
|
|
707
707
|
return e.web = "web", e.ios = "ios", e.android = "android", e;
|
|
708
708
|
}({});
|
|
709
|
-
function
|
|
709
|
+
function ct(e) {
|
|
710
710
|
return e;
|
|
711
711
|
}
|
|
712
|
-
function
|
|
712
|
+
function lt(e, t) {
|
|
713
713
|
let n = e;
|
|
714
714
|
return Object.entries(t).forEach(([e, t]) => {
|
|
715
715
|
n = n.replace(`:${e}`, t);
|
|
716
716
|
}), n;
|
|
717
717
|
}
|
|
718
|
-
var
|
|
718
|
+
var ut = /* @__PURE__ */ function(e) {
|
|
719
719
|
return e.Disabled = "disabled", e.Optional = "optional", e.Required = "required", e;
|
|
720
|
-
}({}),
|
|
720
|
+
}({}), dt = 3, ft = 1e3, pt = (e) => (t) => {
|
|
721
721
|
let n = e.headers?.[t] ?? e.headers?.[t.toLowerCase()];
|
|
722
722
|
return Array.isArray(n) ? n.join(", ") : n;
|
|
723
|
-
},
|
|
723
|
+
}, mt = (e) => Ae(e.status, pt(e), e.data), ht = (e) => mt(e) !== void 0, gt = (e) => {
|
|
724
724
|
let t = e.response?.data?.error;
|
|
725
725
|
return typeof t?.id == "string" ? t.id : void 0;
|
|
726
|
-
},
|
|
726
|
+
}, _t = (n) => e.isAxiosError(n) && !n.response && (n.code === t.ERR_NETWORK || !n.code && n.cause instanceof TypeError), vt = [
|
|
727
727
|
502,
|
|
728
728
|
503,
|
|
729
729
|
504
|
|
730
|
-
],
|
|
730
|
+
], yt = (e) => typeof e == "object" && !!e && typeof e.error == "object" && e.error !== null, bt = (e, n) => {
|
|
731
731
|
let r = new t(e.message, e.code);
|
|
732
732
|
return e.cause instanceof TypeError && (r.cause = e.cause), new B({
|
|
733
733
|
id: He,
|
|
@@ -736,10 +736,10 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
736
736
|
location: e.config?.url ?? "unknown",
|
|
737
737
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
738
738
|
}, { cause: r });
|
|
739
|
-
},
|
|
739
|
+
}, xt = (e) => e?.includes(z.refresh) ?? !1, St = (e) => e?.includes("/auth/session/") ?? !1, Ct = (e) => e?.includes("logout") ?? !1, wt = "__passflowOwnBearer", Tt = "__passflowRefreshedAfter401", Et = (e) => typeof e == "object" && !!e && e[wt] === !0, Dt = (e) => e ? {
|
|
740
740
|
headers: { [l]: `Bearer ${e}` },
|
|
741
|
-
[
|
|
742
|
-
} : {},
|
|
741
|
+
[wt]: !0
|
|
742
|
+
} : {}, Ot = class {
|
|
743
743
|
get origin() {
|
|
744
744
|
return this._platform.getCurrentUrl()?.origin ?? "";
|
|
745
745
|
}
|
|
@@ -777,17 +777,17 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
777
777
|
let n = await this.antiBotHandler(t);
|
|
778
778
|
n && (e.headers[f] = n.value, t.builtin = n.builtin);
|
|
779
779
|
}
|
|
780
|
-
if (this.isNonAuthEndpoint(e.url) ||
|
|
781
|
-
if (this.
|
|
780
|
+
if (this.isNonAuthEndpoint(e.url) || Et(e) || St(e.url)) return e;
|
|
781
|
+
if (this.storageManager.getDeliveryMode() === N.Cookie) {
|
|
782
782
|
e.withCredentials = !0;
|
|
783
783
|
let t = this.storageManager.getCsrfToken();
|
|
784
784
|
return t && (e.headers["X-CSRF-Token"] = t), e;
|
|
785
785
|
}
|
|
786
|
-
if (
|
|
786
|
+
if (xt(e.url)) return e;
|
|
787
787
|
let n = this.storageManager.getTokens();
|
|
788
788
|
if (!n?.access_token) return e;
|
|
789
789
|
let r = n.access_token;
|
|
790
|
-
if (this.refreshHandler && n.refresh_token && !
|
|
790
|
+
if (this.refreshHandler && n.refresh_token && !Ct(e.url)) {
|
|
791
791
|
let e = j(n.access_token);
|
|
792
792
|
if (A(e, 30)) {
|
|
793
793
|
let t = !A(e, 0);
|
|
@@ -803,11 +803,14 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
803
803
|
}
|
|
804
804
|
return e.headers[l] = `Bearer ${r}`, e;
|
|
805
805
|
}), this.instance.interceptors.response.use((e) => e, async (e) => {
|
|
806
|
-
e.response?.status
|
|
806
|
+
if (e.response?.status === 401 && !xt(e.config?.url) && !St(e.config?.url) && !Et(e.config) && !this.isUpgradeTransactionError(e)) {
|
|
807
|
+
if (e.config && await this.refreshedAfterUnauthorized(e.config)) return this.instance.request(e.config);
|
|
808
|
+
this.tokenDeliveryManager.setSessionInvalid();
|
|
809
|
+
}
|
|
807
810
|
let t = o(e.config);
|
|
808
|
-
if (e.config && e.response?.status === 403 &&
|
|
809
|
-
if (e.response && this.upgradeHandler && !
|
|
810
|
-
let t =
|
|
811
|
+
if (e.config && e.response?.status === 403 && gt(e) === "error.api.anti_bot.failed" && t?.builtin && !t.retried) return t.retried = !0, this.instance.request(e.config);
|
|
812
|
+
if (e.response && this.upgradeHandler && !St(e.config?.url)) {
|
|
813
|
+
let t = mt(e.response);
|
|
811
814
|
if (t) try {
|
|
812
815
|
return await this.upgradeHandler(e, t);
|
|
813
816
|
} catch (t) {
|
|
@@ -818,7 +821,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
818
821
|
});
|
|
819
822
|
}
|
|
820
823
|
isUpgradeTransactionError(e) {
|
|
821
|
-
return Fe(e.config) || e.response !== void 0 &&
|
|
824
|
+
return Fe(e.config) || e.response !== void 0 && ht(e.response);
|
|
822
825
|
}
|
|
823
826
|
setUpgradeInterceptor(e) {
|
|
824
827
|
this.upgradeHandler = e;
|
|
@@ -835,6 +838,19 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
835
838
|
isProtectedEndpoint(e) {
|
|
836
839
|
return this.protectedEndpoints.some((t) => e?.includes(t));
|
|
837
840
|
}
|
|
841
|
+
async refreshedAfterUnauthorized(e) {
|
|
842
|
+
let t = e, n = this.storageManager.getDeliveryMode();
|
|
843
|
+
if (!this.refreshHandler || t[Tt] || n !== N.Cookie && n !== N.BFF || this.isNonAuthEndpoint(e.url) || Ct(e.url)) return !1;
|
|
844
|
+
t[Tt] = !0;
|
|
845
|
+
try {
|
|
846
|
+
return await this.refreshHandler({
|
|
847
|
+
trigger: "pre-request",
|
|
848
|
+
allowStale: !1
|
|
849
|
+
}) !== void 0;
|
|
850
|
+
} catch {
|
|
851
|
+
return !1;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
838
854
|
isNonAuthEndpoint(e) {
|
|
839
855
|
return this.nonAccessTokenEndpoints.some((t) => e?.includes(t)) && !this.isProtectedEndpoint(e);
|
|
840
856
|
}
|
|
@@ -843,7 +859,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
843
859
|
}
|
|
844
860
|
async handleRateLimitError(e) {
|
|
845
861
|
let t = e.config;
|
|
846
|
-
if (!t ||
|
|
862
|
+
if (!t || xt(t.url)) return Promise.reject(e);
|
|
847
863
|
let n = t.method?.toUpperCase();
|
|
848
864
|
if (![
|
|
849
865
|
"GET",
|
|
@@ -851,8 +867,8 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
851
867
|
"OPTIONS"
|
|
852
868
|
].includes(n || "")) return Promise.reject(e);
|
|
853
869
|
let r = t._retryCount || 0;
|
|
854
|
-
if (r >=
|
|
855
|
-
let i =
|
|
870
|
+
if (r >= dt) return Promise.reject(e);
|
|
871
|
+
let i = ft * 2 ** r, a = e.response?.headers?.["retry-after"];
|
|
856
872
|
if (a) {
|
|
857
873
|
let e = Number.parseInt(a, 10);
|
|
858
874
|
if (!Number.isNaN(e)) i = e * 1e3;
|
|
@@ -864,14 +880,14 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
864
880
|
return await new Promise((e) => setTimeout(e, i)), t._retryCount = r + 1, this.instance.request(t);
|
|
865
881
|
}
|
|
866
882
|
async handleAxiosError(e) {
|
|
867
|
-
if (
|
|
883
|
+
if (_t(e)) return Promise.reject(bt(e, 0));
|
|
868
884
|
if (!e.response) return Promise.reject(e);
|
|
869
885
|
let t = e.response.status;
|
|
870
|
-
if (
|
|
886
|
+
if (vt.includes(t) && !yt(e.response.data)) return Promise.reject(bt(e, t));
|
|
871
887
|
let n = e.response.data;
|
|
872
888
|
if ("error" in n && typeof n.error == "object" && n.error !== null) {
|
|
873
889
|
let { error: e } = n;
|
|
874
|
-
return e.id === "error.api.password.change.required" ? Promise.reject(new
|
|
890
|
+
return e.id === "error.api.password.change.required" ? Promise.reject(new tt(e)) : Promise.reject(new B(e));
|
|
875
891
|
}
|
|
876
892
|
return Promise.reject(new B({
|
|
877
893
|
id: `error.http.${t}`,
|
|
@@ -918,9 +934,9 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
918
934
|
[c]: e
|
|
919
935
|
}, this.instance.defaults.headers[c] = e;
|
|
920
936
|
}
|
|
921
|
-
},
|
|
937
|
+
}, kt = class {
|
|
922
938
|
constructor(e, t, n) {
|
|
923
|
-
this.axiosClient = new
|
|
939
|
+
this.axiosClient = new Ot(e, t, n);
|
|
924
940
|
}
|
|
925
941
|
setAppId(e) {
|
|
926
942
|
this.axiosClient.setAppId(e);
|
|
@@ -928,7 +944,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
928
944
|
getAppSettings() {
|
|
929
945
|
return this.axiosClient.get(z.appSettings);
|
|
930
946
|
}
|
|
931
|
-
},
|
|
947
|
+
}, At = { withCredentials: !0 }, jt = 15e3, Mt = "X-Passflow-CSRF", Nt = "Sign-in failed. Start again.", Pt = "Something went wrong. Try again later.", Ft = (e, t, n, r) => {
|
|
932
948
|
if (e instanceof B) return e;
|
|
933
949
|
let i = e?.response?.data?.error;
|
|
934
950
|
return new B({
|
|
@@ -945,9 +961,9 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
945
961
|
...e?.headers,
|
|
946
962
|
[p]: "1"
|
|
947
963
|
} } : {}
|
|
948
|
-
},
|
|
964
|
+
}, It = class {
|
|
949
965
|
constructor(e, t, n) {
|
|
950
|
-
this.axiosClient = new
|
|
966
|
+
this.axiosClient = new Ot(e, t, n);
|
|
951
967
|
}
|
|
952
968
|
setAppId(e) {
|
|
953
969
|
this.axiosClient.setAppId(e);
|
|
@@ -959,18 +975,24 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
959
975
|
try {
|
|
960
976
|
return await this.axiosClient.post(z.antiBotChallenge, e);
|
|
961
977
|
} catch (e) {
|
|
962
|
-
throw
|
|
978
|
+
throw Ft(e, z.antiBotChallenge, "error.anti_bot.challenge", Pt);
|
|
963
979
|
}
|
|
964
980
|
}
|
|
965
981
|
async deviceAntiBotChallenge(e, t) {
|
|
966
982
|
try {
|
|
967
|
-
return await this.axiosClient.post(z.deviceAntiBotChallenge, e, { headers: { [
|
|
983
|
+
return await this.axiosClient.post(z.deviceAntiBotChallenge, e, { headers: { [Mt]: t } });
|
|
968
984
|
} catch (e) {
|
|
969
|
-
throw
|
|
985
|
+
throw Ft(e, z.deviceAntiBotChallenge, "error.anti_bot.challenge", Pt);
|
|
970
986
|
}
|
|
971
987
|
}
|
|
972
988
|
federatedStart(e, t, n) {
|
|
973
|
-
return this.axiosClient.post(`${z.signInWithProvider}${e}`, t, V(
|
|
989
|
+
return this.axiosClient.post(`${z.signInWithProvider}${e}`, t, V(At, "federated.start", void 0, n));
|
|
990
|
+
}
|
|
991
|
+
enterpriseResolve(e) {
|
|
992
|
+
return this.axiosClient.post(z.enterpriseResolve, { email: e });
|
|
993
|
+
}
|
|
994
|
+
enterpriseStart(e, t) {
|
|
995
|
+
return this.axiosClient.post(z.enterpriseStart, e, V(At, "federated.start", e.email, t));
|
|
974
996
|
}
|
|
975
997
|
refreshToken(e, t, n, r) {
|
|
976
998
|
let i = {
|
|
@@ -986,7 +1008,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
986
1008
|
device: t,
|
|
987
1009
|
os: n
|
|
988
1010
|
};
|
|
989
|
-
return this.axiosClient.post(z.signin, i, V(
|
|
1011
|
+
return this.axiosClient.post(z.signin, i, V(At, "sign-in", e.email ?? e.phone ?? e.username, r));
|
|
990
1012
|
}
|
|
991
1013
|
signUp(e, t) {
|
|
992
1014
|
let { create_tenant: n, anonymous: r } = e, i = {
|
|
@@ -994,16 +1016,16 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
994
1016
|
create_tenant: n ?? !1,
|
|
995
1017
|
anonymous: r ?? !1
|
|
996
1018
|
};
|
|
997
|
-
return this.axiosClient.post(z.signup, i, V(
|
|
1019
|
+
return this.axiosClient.post(z.signup, i, V(At, "sign-up", e.user.email ?? e.user.phone_number ?? e.user.username, t));
|
|
998
1020
|
}
|
|
999
1021
|
async pkceExchange(e, t) {
|
|
1000
1022
|
try {
|
|
1001
1023
|
return await this.axiosClient.post(z.pkceExchange, {
|
|
1002
1024
|
authz_code: e,
|
|
1003
1025
|
verifier: t
|
|
1004
|
-
},
|
|
1026
|
+
}, At);
|
|
1005
1027
|
} catch (e) {
|
|
1006
|
-
throw
|
|
1028
|
+
throw Ft(e, z.pkceExchange, "error.pkce.exchange", Nt);
|
|
1007
1029
|
}
|
|
1008
1030
|
}
|
|
1009
1031
|
async passwordlessSignIn(e, t, n, r) {
|
|
@@ -1016,53 +1038,53 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1016
1038
|
try {
|
|
1017
1039
|
return await this.axiosClient.post(z.passwordless, a, V(void 0, "passwordless.start", e.email ?? e.phone, r));
|
|
1018
1040
|
} catch (e) {
|
|
1019
|
-
throw
|
|
1041
|
+
throw Ft(e, z.passwordless, "error.passwordless.start", Pt);
|
|
1020
1042
|
}
|
|
1021
1043
|
}
|
|
1022
1044
|
async passwordlessSignInComplete(e, t) {
|
|
1023
1045
|
try {
|
|
1024
|
-
return await this.axiosClient.post(z.passwordlessComplete, e, V(
|
|
1046
|
+
return await this.axiosClient.post(z.passwordlessComplete, e, V(At, void 0, void 0, t));
|
|
1025
1047
|
} catch (e) {
|
|
1026
|
-
throw
|
|
1048
|
+
throw Ft(e, z.passwordlessComplete, "error.passwordless.complete", Pt);
|
|
1027
1049
|
}
|
|
1028
1050
|
}
|
|
1029
1051
|
async passwordlessStatus(e, t) {
|
|
1030
1052
|
try {
|
|
1031
1053
|
return await this.axiosClient.post(z.passwordlessStatus, e, {
|
|
1032
|
-
...
|
|
1033
|
-
timeout:
|
|
1054
|
+
...At,
|
|
1055
|
+
timeout: jt,
|
|
1034
1056
|
signal: t?.signal
|
|
1035
1057
|
});
|
|
1036
1058
|
} catch (e) {
|
|
1037
|
-
throw
|
|
1059
|
+
throw Ft(e, z.passwordlessStatus, "error.passwordless.status", Nt);
|
|
1038
1060
|
}
|
|
1039
1061
|
}
|
|
1040
1062
|
async checkRedirectUrl(e) {
|
|
1041
1063
|
try {
|
|
1042
1064
|
return (await this.axiosClient.post(z.redirectCheck, { redirect_url: e })).redirect_url;
|
|
1043
1065
|
} catch (e) {
|
|
1044
|
-
throw
|
|
1066
|
+
throw Ft(e, z.redirectCheck, "error.redirect.check", Pt);
|
|
1045
1067
|
}
|
|
1046
1068
|
}
|
|
1047
1069
|
async passwordlessApprovalInfo(e) {
|
|
1048
1070
|
try {
|
|
1049
1071
|
return await this.axiosClient.post(z.passwordlessApprovalInfo, e);
|
|
1050
1072
|
} catch (e) {
|
|
1051
|
-
throw
|
|
1073
|
+
throw Ft(e, z.passwordlessApprovalInfo, "error.passwordless.approval", Pt);
|
|
1052
1074
|
}
|
|
1053
1075
|
}
|
|
1054
1076
|
async passwordlessApprovalDecide(e) {
|
|
1055
1077
|
try {
|
|
1056
1078
|
return await this.axiosClient.post(z.passwordlessApprovalDecide, e);
|
|
1057
1079
|
} catch (e) {
|
|
1058
|
-
throw
|
|
1080
|
+
throw Ft(e, z.passwordlessApprovalDecide, "error.passwordless.approval", Pt);
|
|
1059
1081
|
}
|
|
1060
1082
|
}
|
|
1061
1083
|
validateEmailCode(e) {
|
|
1062
1084
|
return this.axiosClient.post(z.passkeyValidate, {
|
|
1063
1085
|
challenge_id: e.challenge_id,
|
|
1064
1086
|
otp: e.otp
|
|
1065
|
-
},
|
|
1087
|
+
}, At);
|
|
1066
1088
|
}
|
|
1067
1089
|
logOut(e, t, n = !1) {
|
|
1068
1090
|
let r = n ? void 0 : {
|
|
@@ -1103,7 +1125,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1103
1125
|
device: t,
|
|
1104
1126
|
passkey_data: e
|
|
1105
1127
|
}, o = r ? ze.passkeyRegisterComplete : z.passkeyRegisterComplete;
|
|
1106
|
-
return this.axiosClient.post(o, a, V(
|
|
1128
|
+
return this.axiosClient.post(o, a, V(At, void 0, void 0, i));
|
|
1107
1129
|
}
|
|
1108
1130
|
passkeyAuthenticateStart(e, t, n, r = !1, i) {
|
|
1109
1131
|
let a = {
|
|
@@ -1120,7 +1142,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1120
1142
|
device: t,
|
|
1121
1143
|
passkey_data: e
|
|
1122
1144
|
}, o = r ? ze.passkeyAuthenticateComplete : z.passkeyAuthenticateComplete;
|
|
1123
|
-
return this.axiosClient.post(o, a, V(
|
|
1145
|
+
return this.axiosClient.post(o, a, V(At, void 0, void 0, i));
|
|
1124
1146
|
}
|
|
1125
1147
|
passkeyValidate(e, t, n, r = !1, i) {
|
|
1126
1148
|
let a = {
|
|
@@ -1132,23 +1154,23 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1132
1154
|
let s = i ? { [c]: i } : {};
|
|
1133
1155
|
return this.axiosClient.post(o, a, { headers: s });
|
|
1134
1156
|
}
|
|
1135
|
-
},
|
|
1157
|
+
}, Lt = class {
|
|
1136
1158
|
constructor(e, t, n) {
|
|
1137
|
-
this.axiosClient = new
|
|
1159
|
+
this.axiosClient = new Ot(e, t, n);
|
|
1138
1160
|
}
|
|
1139
1161
|
setAppId(e) {
|
|
1140
1162
|
this.axiosClient.setAppId(e);
|
|
1141
1163
|
}
|
|
1142
1164
|
getCLIAuthStatus(e) {
|
|
1143
|
-
let t =
|
|
1165
|
+
let t = lt(z.cliAuthStatus, { sessionId: e });
|
|
1144
1166
|
return this.axiosClient.get(t);
|
|
1145
1167
|
}
|
|
1146
1168
|
completeCLIAuth(e) {
|
|
1147
1169
|
return this.axiosClient.post(z.cliAuthComplete, e);
|
|
1148
1170
|
}
|
|
1149
|
-
},
|
|
1171
|
+
}, Rt = class {
|
|
1150
1172
|
constructor(e, t, n) {
|
|
1151
|
-
this.axiosClient = new
|
|
1173
|
+
this.axiosClient = new Ot(e, t, n);
|
|
1152
1174
|
}
|
|
1153
1175
|
setAppId(e) {
|
|
1154
1176
|
this.axiosClient.setAppId(e);
|
|
@@ -1159,27 +1181,27 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1159
1181
|
getInvitations(e) {
|
|
1160
1182
|
let t = {};
|
|
1161
1183
|
e.groupID && (t.group_id = e.groupID.toString()), e.skip !== void 0 && (t.skip = e.skip.toString()), e.limit !== void 0 && (t.limit = e.limit.toString());
|
|
1162
|
-
let n =
|
|
1184
|
+
let n = lt(z.invitationsPath, { tenantID: e.tenantID });
|
|
1163
1185
|
return this.axiosClient.get(n, { params: t }).then((e) => ({
|
|
1164
1186
|
invites: e.invites,
|
|
1165
1187
|
nextPageSkip: e.next_page_skip
|
|
1166
1188
|
}));
|
|
1167
1189
|
}
|
|
1168
1190
|
deleteInvitation(e) {
|
|
1169
|
-
let t =
|
|
1191
|
+
let t = lt(z.invitationDelete, { invitationID: e });
|
|
1170
1192
|
return this.axiosClient.delete(t);
|
|
1171
1193
|
}
|
|
1172
1194
|
resendInvitation(e) {
|
|
1173
|
-
let t =
|
|
1195
|
+
let t = lt(z.invitationResend, { invitationID: e });
|
|
1174
1196
|
return this.axiosClient.post(t, {});
|
|
1175
1197
|
}
|
|
1176
1198
|
getInvitationLink(e) {
|
|
1177
|
-
let t =
|
|
1199
|
+
let t = lt(z.invitationGetLink, { invitationID: e });
|
|
1178
1200
|
return this.axiosClient.get(t);
|
|
1179
1201
|
}
|
|
1180
|
-
},
|
|
1202
|
+
}, zt = class {
|
|
1181
1203
|
constructor(e, t, n) {
|
|
1182
|
-
this.axiosClient = new
|
|
1204
|
+
this.axiosClient = new Ot(e, t, n);
|
|
1183
1205
|
}
|
|
1184
1206
|
setAppId(e) {
|
|
1185
1207
|
this.axiosClient.setAppId(e);
|
|
@@ -1193,9 +1215,9 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1193
1215
|
getPasskeySettings() {
|
|
1194
1216
|
return this.axiosClient.get(z.settingsPasskey);
|
|
1195
1217
|
}
|
|
1196
|
-
},
|
|
1218
|
+
}, Bt = class {
|
|
1197
1219
|
constructor(e, t, n) {
|
|
1198
|
-
this.axiosClient = new
|
|
1220
|
+
this.axiosClient = new Ot(e, t, n);
|
|
1199
1221
|
}
|
|
1200
1222
|
setAppId(e) {
|
|
1201
1223
|
this.axiosClient.setAppId(e);
|
|
@@ -1309,58 +1331,58 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1309
1331
|
let r = `${z.tenantPath}/${e}/group/${t}/invite/email/${n}`;
|
|
1310
1332
|
return this.axiosClient.delete(r);
|
|
1311
1333
|
}
|
|
1312
|
-
},
|
|
1334
|
+
}, Vt = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, Ht = (e) => ({
|
|
1313
1335
|
withCredentials: !0,
|
|
1314
|
-
...
|
|
1315
|
-
}),
|
|
1336
|
+
...Vt(e)
|
|
1337
|
+
}), Ut = ({ qr_code_image: e, qr_code: t, ...n }) => ({
|
|
1316
1338
|
...n,
|
|
1317
1339
|
qr_code: (t ?? e ?? "").replace(/^data:image\/png;base64,/, "")
|
|
1318
|
-
}),
|
|
1340
|
+
}), Wt = {
|
|
1319
1341
|
"error.2fa.setup.token.expired": "EXPIRED_TOKEN",
|
|
1320
1342
|
"error.2fa.setup.token.revoked": "REVOKED_TOKEN",
|
|
1321
1343
|
"error.2fa.setup.token.already_used": "ALREADY_USED",
|
|
1322
1344
|
"error.2fa.setup.token.rate.limit.exceeded": "RATE_LIMITED"
|
|
1323
|
-
},
|
|
1345
|
+
}, Gt = class {
|
|
1324
1346
|
constructor(e, t, n) {
|
|
1325
|
-
this.axiosClient = new
|
|
1347
|
+
this.axiosClient = new Ot(e, t, n);
|
|
1326
1348
|
}
|
|
1327
1349
|
setAppId(e) {
|
|
1328
1350
|
this.axiosClient.setAppId(e);
|
|
1329
1351
|
}
|
|
1330
1352
|
getStatus(e) {
|
|
1331
|
-
return this.axiosClient.get(z.twoFactorStatus,
|
|
1353
|
+
return this.axiosClient.get(z.twoFactorStatus, Dt(e));
|
|
1332
1354
|
}
|
|
1333
1355
|
async beginSetup(e) {
|
|
1334
|
-
return
|
|
1356
|
+
return Ut(await this.axiosClient.post(z.twoFactorSetupBegin, {}, Dt(e)));
|
|
1335
1357
|
}
|
|
1336
1358
|
confirmSetup(e, t) {
|
|
1337
|
-
return this.axiosClient.post(z.twoFactorSetupConfirm, e,
|
|
1359
|
+
return this.axiosClient.post(z.twoFactorSetupConfirm, e, Dt(t));
|
|
1338
1360
|
}
|
|
1339
1361
|
getEnrollment(e) {
|
|
1340
|
-
return this.axiosClient.get(z.twoFactorEnrollment,
|
|
1362
|
+
return this.axiosClient.get(z.twoFactorEnrollment, Dt(e));
|
|
1341
1363
|
}
|
|
1342
1364
|
sendSetupLink(e) {
|
|
1343
|
-
return this.axiosClient.post(z.twoFactorEnrollmentEmailLink, void 0,
|
|
1365
|
+
return this.axiosClient.post(z.twoFactorEnrollmentEmailLink, void 0, Dt(e));
|
|
1344
1366
|
}
|
|
1345
1367
|
async beginEnrollment(e) {
|
|
1346
|
-
return
|
|
1368
|
+
return Ut(await this.axiosClient.post(z.twoFactorEnrollmentBegin, void 0, Dt(e)));
|
|
1347
1369
|
}
|
|
1348
1370
|
confirmEnrollment(e, t) {
|
|
1349
|
-
return this.axiosClient.post(z.twoFactorEnrollmentConfirm, t,
|
|
1371
|
+
return this.axiosClient.post(z.twoFactorEnrollmentConfirm, t, Dt(e));
|
|
1350
1372
|
}
|
|
1351
1373
|
verify(e) {
|
|
1352
1374
|
let { tfa_token: t, code: n, trust_device: r } = e;
|
|
1353
1375
|
return this.axiosClient.post(z.twoFactorVerify, {
|
|
1354
1376
|
code: n,
|
|
1355
1377
|
...r ? { trust_device: !0 } : {}
|
|
1356
|
-
},
|
|
1378
|
+
}, Ht(t));
|
|
1357
1379
|
}
|
|
1358
1380
|
useRecoveryCode(e) {
|
|
1359
1381
|
let { tfa_token: t, recovery_code: n, trust_device: r } = e;
|
|
1360
1382
|
return this.axiosClient.post(z.twoFactorRecovery, {
|
|
1361
1383
|
recovery_code: n,
|
|
1362
1384
|
...r ? { trust_device: !0 } : {}
|
|
1363
|
-
},
|
|
1385
|
+
}, Ht(t));
|
|
1364
1386
|
}
|
|
1365
1387
|
disable(e) {
|
|
1366
1388
|
return this.axiosClient.delete(z.twoFactor, { data: e });
|
|
@@ -1389,7 +1411,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1389
1411
|
if (e instanceof B) return {
|
|
1390
1412
|
success: !1,
|
|
1391
1413
|
error: {
|
|
1392
|
-
code:
|
|
1414
|
+
code: Wt[e.id] ?? this.mapStatusToErrorCode(e.status),
|
|
1393
1415
|
message: e.message || this.getDefaultErrorMessage(e.status)
|
|
1394
1416
|
}
|
|
1395
1417
|
};
|
|
@@ -1450,32 +1472,32 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1450
1472
|
});
|
|
1451
1473
|
}
|
|
1452
1474
|
removeMethod(e) {
|
|
1453
|
-
let t =
|
|
1475
|
+
let t = lt(z.TwoFactorMethodRemove, { id: e });
|
|
1454
1476
|
return this.axiosClient.delete(t);
|
|
1455
1477
|
}
|
|
1456
1478
|
requestChallenge(e, t) {
|
|
1457
|
-
return this.axiosClient.post(z.TwoFactorChallenge, e,
|
|
1479
|
+
return this.axiosClient.post(z.TwoFactorChallenge, e, Vt(t));
|
|
1458
1480
|
}
|
|
1459
1481
|
verifyV2(e, t) {
|
|
1460
1482
|
let { trust_device: n, ...r } = e;
|
|
1461
1483
|
return this.axiosClient.post(z.TwoFactorVerifyV2, {
|
|
1462
1484
|
...r,
|
|
1463
1485
|
...n ? { trust_device: !0 } : {}
|
|
1464
|
-
},
|
|
1486
|
+
}, Ht(t));
|
|
1465
1487
|
}
|
|
1466
1488
|
switchToAlternative(e, t) {
|
|
1467
|
-
return this.axiosClient.post(z.TwoFactorAlternative, e,
|
|
1489
|
+
return this.axiosClient.post(z.TwoFactorAlternative, e, Vt(t));
|
|
1468
1490
|
}
|
|
1469
1491
|
async getTrustedDevices() {
|
|
1470
1492
|
return (await this.axiosClient.get(z.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
|
|
1471
1493
|
}
|
|
1472
1494
|
revokeTrustedDevice(e) {
|
|
1473
|
-
let t =
|
|
1495
|
+
let t = lt(z.TwoFactorTrustedDeviceRevoke, { id: e });
|
|
1474
1496
|
return this.axiosClient.delete(t);
|
|
1475
1497
|
}
|
|
1476
|
-
},
|
|
1498
|
+
}, Kt = class {
|
|
1477
1499
|
constructor(e, t, n) {
|
|
1478
|
-
this.axiosClient = new
|
|
1500
|
+
this.axiosClient = new Ot(e, t, n);
|
|
1479
1501
|
}
|
|
1480
1502
|
setAppId(e) {
|
|
1481
1503
|
this.axiosClient.setAppId(e);
|
|
@@ -1489,9 +1511,9 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1489
1511
|
async commitHostedUpgrade(e) {
|
|
1490
1512
|
await this.axiosClient.post(z.hostedUpgrade, e, { withCredentials: !0 });
|
|
1491
1513
|
}
|
|
1492
|
-
},
|
|
1514
|
+
}, qt = class {
|
|
1493
1515
|
constructor(e, t, n) {
|
|
1494
|
-
this.axiosClient = new
|
|
1516
|
+
this.axiosClient = new Ot(e, t, n);
|
|
1495
1517
|
}
|
|
1496
1518
|
setAppId(e) {
|
|
1497
1519
|
this.axiosClient.setAppId(e);
|
|
@@ -1531,48 +1553,48 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1531
1553
|
revokeOtherUserSessions() {
|
|
1532
1554
|
return this.axiosClient.post(z.userSessionsRevokeOthers);
|
|
1533
1555
|
}
|
|
1534
|
-
},
|
|
1556
|
+
}, Jt = 10, Yt = 20, Xt = class extends Error {
|
|
1535
1557
|
constructor(e) {
|
|
1536
1558
|
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;
|
|
1537
1559
|
}
|
|
1538
|
-
},
|
|
1560
|
+
}, Zt = [], Qt = 0, $t = !1, en, tn, nn = (e, t) => e.priority - t.priority || e.seq - t.seq, rn = () => typeof globalThis > "u" ? void 0 : globalThis, an = async (e, t, n, r) => {
|
|
1539
1561
|
if (t >= e.length) {
|
|
1540
|
-
let e =
|
|
1562
|
+
let e = en;
|
|
1541
1563
|
if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
|
|
1542
1564
|
return e(n, r);
|
|
1543
1565
|
}
|
|
1544
1566
|
let i = e[t];
|
|
1545
|
-
if (!i) return
|
|
1546
|
-
let a = !1, o = await i.middleware((n, r) => (a = !0,
|
|
1547
|
-
if (!a) throw new
|
|
1567
|
+
if (!i) return an(e, e.length, n, r);
|
|
1568
|
+
let a = !1, o = await i.middleware((n, r) => (a = !0, an(e, t + 1, n, r)), n, r);
|
|
1569
|
+
if (!a) throw new Xt(i.name);
|
|
1548
1570
|
return o;
|
|
1549
|
-
},
|
|
1550
|
-
let e =
|
|
1571
|
+
}, on = () => {
|
|
1572
|
+
let e = rn();
|
|
1551
1573
|
if (!e || typeof e.fetch != "function") return !1;
|
|
1552
|
-
let t = e.fetch.bind(e), n = (e, t) =>
|
|
1553
|
-
return
|
|
1554
|
-
},
|
|
1555
|
-
let e =
|
|
1556
|
-
e &&
|
|
1557
|
-
},
|
|
1558
|
-
if (
|
|
1574
|
+
let t = e.fetch.bind(e), n = (e, t) => an([...Zt].sort(nn), 0, e, t);
|
|
1575
|
+
return en = t, tn = n, e.fetch = n, $t = !0, !0;
|
|
1576
|
+
}, sn = () => {
|
|
1577
|
+
let e = rn();
|
|
1578
|
+
e && tn && e.fetch === tn && (en && (e.fetch = en), $t = !1, tn = void 0, en = void 0);
|
|
1579
|
+
}, cn = (e, t) => {
|
|
1580
|
+
if (!$t && !on()) return () => {};
|
|
1559
1581
|
let n = {
|
|
1560
1582
|
middleware: e,
|
|
1561
1583
|
name: t.name,
|
|
1562
1584
|
priority: t.priority,
|
|
1563
|
-
seq:
|
|
1585
|
+
seq: Qt++
|
|
1564
1586
|
};
|
|
1565
|
-
|
|
1587
|
+
Zt.push(n);
|
|
1566
1588
|
let r = !1;
|
|
1567
1589
|
return () => {
|
|
1568
|
-
r || (r = !0,
|
|
1590
|
+
r || (r = !0, Zt = Zt.filter((e) => e !== n), Zt.length === 0 && sn());
|
|
1569
1591
|
};
|
|
1570
|
-
},
|
|
1571
|
-
let e =
|
|
1592
|
+
}, ln = () => {
|
|
1593
|
+
let e = rn();
|
|
1572
1594
|
return {
|
|
1573
|
-
installed:
|
|
1574
|
-
names: [...
|
|
1575
|
-
foreignPatch:
|
|
1595
|
+
installed: $t,
|
|
1596
|
+
names: [...Zt].sort(nn).map((e) => e.name),
|
|
1597
|
+
foreignPatch: $t && !!e && !!tn && e.fetch !== tn
|
|
1576
1598
|
};
|
|
1577
1599
|
}, H = class e extends Error {
|
|
1578
1600
|
constructor(t) {
|
|
@@ -1643,7 +1665,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1643
1665
|
let e = `M2MError [${this.code}]: ${this.message}`;
|
|
1644
1666
|
return this.status && (e += ` (HTTP ${this.status})`), e;
|
|
1645
1667
|
}
|
|
1646
|
-
},
|
|
1668
|
+
}, un = class extends H {
|
|
1647
1669
|
constructor(e, t) {
|
|
1648
1670
|
super({
|
|
1649
1671
|
code: "temporarily_unavailable",
|
|
@@ -1652,7 +1674,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1652
1674
|
cause: t
|
|
1653
1675
|
}), this.name = "M2MNetworkError";
|
|
1654
1676
|
}
|
|
1655
|
-
},
|
|
1677
|
+
}, dn = class extends H {
|
|
1656
1678
|
constructor(e, t) {
|
|
1657
1679
|
super({
|
|
1658
1680
|
code: "invalid_request",
|
|
@@ -1661,7 +1683,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1661
1683
|
cause: t
|
|
1662
1684
|
}), this.name = "M2MTokenParseError";
|
|
1663
1685
|
}
|
|
1664
|
-
},
|
|
1686
|
+
}, fn = class extends H {
|
|
1665
1687
|
constructor(e) {
|
|
1666
1688
|
super({
|
|
1667
1689
|
code: "invalid_request",
|
|
@@ -1669,7 +1691,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1669
1691
|
status: 400
|
|
1670
1692
|
}), this.name = "M2MConfigError";
|
|
1671
1693
|
}
|
|
1672
|
-
},
|
|
1694
|
+
}, pn = {
|
|
1673
1695
|
InvalidRequest: "invalid_request",
|
|
1674
1696
|
InvalidClient: "invalid_client",
|
|
1675
1697
|
InvalidGrant: "invalid_grant",
|
|
@@ -1679,14 +1701,14 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1679
1701
|
RateLimitExceeded: "rate_limit_exceeded",
|
|
1680
1702
|
ServerError: "server_error",
|
|
1681
1703
|
TemporarilyUnavailable: "temporarily_unavailable"
|
|
1682
|
-
},
|
|
1704
|
+
}, mn = {
|
|
1683
1705
|
TOKEN_ENDPOINT: "/oauth2/token",
|
|
1684
1706
|
TIMEOUT: 1e4,
|
|
1685
1707
|
RETRIES: 3,
|
|
1686
1708
|
RETRY_DELAY: 1e3,
|
|
1687
1709
|
REFRESH_THRESHOLD: 30,
|
|
1688
1710
|
CONTENT_TYPE: "application/x-www-form-urlencoded"
|
|
1689
|
-
},
|
|
1711
|
+
}, hn = class {
|
|
1690
1712
|
constructor() {
|
|
1691
1713
|
this.cache = /* @__PURE__ */ new Map();
|
|
1692
1714
|
}
|
|
@@ -1703,18 +1725,18 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1703
1725
|
delete(e) {
|
|
1704
1726
|
return this.cache.delete(e), Promise.resolve();
|
|
1705
1727
|
}
|
|
1706
|
-
},
|
|
1728
|
+
}, gn = {
|
|
1707
1729
|
shouldRetry(e, t) {
|
|
1708
1730
|
return t >= 3 ? !1 : e.code === "server_error" || e.code === "temporarily_unavailable" || e.code === "rate_limit_exceeded" || e.status !== void 0 && e.status >= 500;
|
|
1709
1731
|
},
|
|
1710
1732
|
getDelay(e) {
|
|
1711
1733
|
return 2 ** (e - 1) * 1e3;
|
|
1712
1734
|
}
|
|
1713
|
-
},
|
|
1735
|
+
}, _n = class {
|
|
1714
1736
|
constructor(e) {
|
|
1715
|
-
if (!e.url) throw new
|
|
1716
|
-
if (!e.clientId) throw new
|
|
1717
|
-
if (!e.clientSecret) throw new
|
|
1737
|
+
if (!e.url) throw new fn("M2M client requires a URL");
|
|
1738
|
+
if (!e.clientId) throw new fn("M2M client requires a clientId");
|
|
1739
|
+
if (!e.clientSecret) throw new fn("M2M client requires a clientSecret");
|
|
1718
1740
|
let t = e.url.replace(/\/$/, "");
|
|
1719
1741
|
this.config = {
|
|
1720
1742
|
url: t,
|
|
@@ -1723,16 +1745,16 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1723
1745
|
scopes: e.scopes,
|
|
1724
1746
|
audience: e.audience,
|
|
1725
1747
|
autoRefresh: e.autoRefresh ?? !1,
|
|
1726
|
-
refreshThreshold: e.refreshThreshold ??
|
|
1727
|
-
timeout: e.timeout ??
|
|
1728
|
-
retries: e.retries ??
|
|
1729
|
-
retryDelay: e.retryDelay ??
|
|
1748
|
+
refreshThreshold: e.refreshThreshold ?? mn.REFRESH_THRESHOLD,
|
|
1749
|
+
timeout: e.timeout ?? mn.TIMEOUT,
|
|
1750
|
+
retries: e.retries ?? mn.RETRIES,
|
|
1751
|
+
retryDelay: e.retryDelay ?? mn.RETRY_DELAY,
|
|
1730
1752
|
retryStrategy: e.retryStrategy,
|
|
1731
1753
|
cache: e.cache,
|
|
1732
1754
|
onTokenRequest: e.onTokenRequest,
|
|
1733
1755
|
onTokenResponse: e.onTokenResponse,
|
|
1734
1756
|
onError: e.onError
|
|
1735
|
-
}, this.cache = e.cache ?? new
|
|
1757
|
+
}, this.cache = e.cache ?? new hn(), this.retryStrategy = e.retryStrategy ?? gn, this.tokenEndpoint = `${t}${mn.TOKEN_ENDPOINT}`;
|
|
1736
1758
|
}
|
|
1737
1759
|
getCacheKey(e, t) {
|
|
1738
1760
|
let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
|
|
@@ -1777,7 +1799,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1777
1799
|
let e = await fetch(this.tokenEndpoint, {
|
|
1778
1800
|
method: "POST",
|
|
1779
1801
|
headers: {
|
|
1780
|
-
"Content-Type":
|
|
1802
|
+
"Content-Type": mn.CONTENT_TYPE,
|
|
1781
1803
|
Accept: "application/json"
|
|
1782
1804
|
},
|
|
1783
1805
|
body: t.toString(),
|
|
@@ -1802,7 +1824,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1802
1824
|
}
|
|
1803
1825
|
return a;
|
|
1804
1826
|
} catch (e) {
|
|
1805
|
-
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new
|
|
1827
|
+
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new un(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new un(`Network error: ${e.message}`, e) : e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1806
1828
|
}
|
|
1807
1829
|
}
|
|
1808
1830
|
async executeWithRetry(e) {
|
|
@@ -1845,13 +1867,13 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1845
1867
|
parseToken(e) {
|
|
1846
1868
|
try {
|
|
1847
1869
|
let t = e.split(".");
|
|
1848
|
-
if (t.length !== 3) throw new
|
|
1870
|
+
if (t.length !== 3) throw new dn("Invalid JWT format: expected 3 parts");
|
|
1849
1871
|
let n = t[1];
|
|
1850
|
-
if (!n) throw new
|
|
1872
|
+
if (!n) throw new dn("Invalid JWT format: missing payload");
|
|
1851
1873
|
let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
|
|
1852
1874
|
return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
|
|
1853
1875
|
} catch (e) {
|
|
1854
|
-
throw e instanceof
|
|
1876
|
+
throw e instanceof dn ? e : new dn(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
1855
1877
|
}
|
|
1856
1878
|
}
|
|
1857
1879
|
clearCache() {
|
|
@@ -1866,7 +1888,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1866
1888
|
try {
|
|
1867
1889
|
let e = await fetch(t, {
|
|
1868
1890
|
method: "POST",
|
|
1869
|
-
headers: { "Content-Type":
|
|
1891
|
+
headers: { "Content-Type": mn.CONTENT_TYPE },
|
|
1870
1892
|
body: n.toString()
|
|
1871
1893
|
});
|
|
1872
1894
|
if (!e.ok && e.status !== 200) {
|
|
@@ -1893,50 +1915,50 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1893
1915
|
get audience() {
|
|
1894
1916
|
return this.config.audience;
|
|
1895
1917
|
}
|
|
1896
|
-
},
|
|
1918
|
+
}, vn = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", yn = 32, bn = (e) => {
|
|
1897
1919
|
let t = "";
|
|
1898
1920
|
for (let n = 0; n < e.length; n += 3) {
|
|
1899
1921
|
let r = e[n], i = e[n + 1], a = e[n + 2];
|
|
1900
|
-
t +=
|
|
1922
|
+
t += vn.charAt(r >> 2), t += vn.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += vn.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += vn.charAt(a & 63));
|
|
1901
1923
|
}
|
|
1902
1924
|
return t;
|
|
1903
|
-
},
|
|
1925
|
+
}, xn = () => {
|
|
1904
1926
|
let e = globalThis.crypto;
|
|
1905
1927
|
if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1906
1928
|
return e;
|
|
1907
|
-
},
|
|
1908
|
-
let t = await
|
|
1909
|
-
return
|
|
1910
|
-
},
|
|
1911
|
-
let e =
|
|
1929
|
+
}, Sn = async (e) => {
|
|
1930
|
+
let t = await xn().subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
1931
|
+
return bn(new Uint8Array(t));
|
|
1932
|
+
}, Cn = (e = yn) => bn(xn().getRandomValues(new Uint8Array(e))), wn = async () => {
|
|
1933
|
+
let e = Cn(yn);
|
|
1912
1934
|
return {
|
|
1913
1935
|
verifier: e,
|
|
1914
|
-
challenge: await
|
|
1936
|
+
challenge: await Sn(e)
|
|
1915
1937
|
};
|
|
1916
|
-
},
|
|
1938
|
+
}, Tn = () => !!globalThis.crypto?.subtle, U = class extends Error {
|
|
1917
1939
|
constructor(e, t) {
|
|
1918
1940
|
super(t), this.code = e, this.name = "PassflowOidcError";
|
|
1919
1941
|
}
|
|
1920
|
-
},
|
|
1942
|
+
}, En = "Sign in again.", Dn = (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.`, On = "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.", kn = () => new U("TOKENS_IN_URL_NOT_ALLOWED", "Tokens in the URL are accepted only for apps in Simple mode"), An = "passflow_oidc_pkce", jn = 6e5, Mn = (e) => {
|
|
1921
1943
|
try {
|
|
1922
1944
|
let t = new URL(e);
|
|
1923
1945
|
return `${t.protocol}//${t.host}${t.pathname.replace(/\/+$/, "")}`;
|
|
1924
1946
|
} catch {
|
|
1925
1947
|
return e;
|
|
1926
1948
|
}
|
|
1927
|
-
},
|
|
1928
|
-
if (!
|
|
1929
|
-
let t =
|
|
1949
|
+
}, Nn = (e) => !e.includes("openid") && (e.includes("id") || e.includes("oidc")) ? [...e, "openid"] : [...e], Pn = async (e) => {
|
|
1950
|
+
if (!Tn()) throw new U("SECURE_CONTEXT_REQUIRED", "Sign-in needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1951
|
+
let t = Nn(e.scopes), n = await wn(), r = {
|
|
1930
1952
|
verifier: n.verifier,
|
|
1931
|
-
state:
|
|
1932
|
-
...t.includes("openid") ? { nonce:
|
|
1953
|
+
state: Cn(),
|
|
1954
|
+
...t.includes("openid") ? { nonce: Cn() } : {},
|
|
1933
1955
|
clientId: e.clientId,
|
|
1934
1956
|
redirectUri: e.redirectUri,
|
|
1935
1957
|
scopes: t,
|
|
1936
|
-
expiresAt: Date.now() +
|
|
1958
|
+
expiresAt: Date.now() + jn
|
|
1937
1959
|
};
|
|
1938
1960
|
try {
|
|
1939
|
-
sessionStorage.setItem(
|
|
1961
|
+
sessionStorage.setItem(An, JSON.stringify(r));
|
|
1940
1962
|
} catch {
|
|
1941
1963
|
throw new U("STORAGE_UNAVAILABLE", "Sign-in needs sessionStorage, which cannot be written here");
|
|
1942
1964
|
}
|
|
@@ -1951,37 +1973,37 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1951
1973
|
code_challenge_method: "S256",
|
|
1952
1974
|
...r.nonce ? { nonce: r.nonce } : {}
|
|
1953
1975
|
}).toString(), i.toString();
|
|
1954
|
-
},
|
|
1976
|
+
}, Fn = (e) => {
|
|
1955
1977
|
let t = e;
|
|
1956
1978
|
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";
|
|
1957
|
-
},
|
|
1979
|
+
}, In = () => {
|
|
1958
1980
|
let e;
|
|
1959
1981
|
try {
|
|
1960
|
-
e = sessionStorage.getItem(
|
|
1982
|
+
e = sessionStorage.getItem(An);
|
|
1961
1983
|
} catch {
|
|
1962
1984
|
return { status: "none" };
|
|
1963
1985
|
}
|
|
1964
1986
|
if (!e) return { status: "none" };
|
|
1965
1987
|
try {
|
|
1966
1988
|
let t = JSON.parse(e);
|
|
1967
|
-
if (
|
|
1989
|
+
if (Fn(t) && Date.now() < t.expiresAt) return {
|
|
1968
1990
|
status: "live",
|
|
1969
1991
|
slot: t
|
|
1970
1992
|
};
|
|
1971
1993
|
} catch {}
|
|
1972
1994
|
return { status: "unusable" };
|
|
1973
|
-
},
|
|
1995
|
+
}, Ln = () => {
|
|
1974
1996
|
try {
|
|
1975
|
-
sessionStorage.removeItem(
|
|
1997
|
+
sessionStorage.removeItem(An);
|
|
1976
1998
|
} catch {}
|
|
1977
|
-
},
|
|
1999
|
+
}, Rn = async (e) => {
|
|
1978
2000
|
try {
|
|
1979
2001
|
let t = await e.json();
|
|
1980
2002
|
return typeof t == "object" && t ? t : void 0;
|
|
1981
2003
|
} catch {
|
|
1982
2004
|
return;
|
|
1983
2005
|
}
|
|
1984
|
-
},
|
|
2006
|
+
}, zn = async (e, t, n) => {
|
|
1985
2007
|
let r;
|
|
1986
2008
|
try {
|
|
1987
2009
|
r = await fetch(`${e.replace(/\/+$/, "")}/oidc/token`, {
|
|
@@ -1996,11 +2018,11 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
1996
2018
|
}).toString()
|
|
1997
2019
|
});
|
|
1998
2020
|
} catch {
|
|
1999
|
-
throw new U("TOKEN_EXCHANGE_FAILED",
|
|
2021
|
+
throw new U("TOKEN_EXCHANGE_FAILED", En);
|
|
2000
2022
|
}
|
|
2001
|
-
let i = await
|
|
2002
|
-
if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client",
|
|
2003
|
-
if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED",
|
|
2023
|
+
let i = await Rn(r);
|
|
2024
|
+
if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client", On) : i?.error === "invalid_grant" ? new U("invalid_grant", En) : new U("TOKEN_EXCHANGE_FAILED", En);
|
|
2025
|
+
if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED", En);
|
|
2004
2026
|
let a = typeof i.id_token == "string" ? i.id_token : void 0;
|
|
2005
2027
|
if (n.scopes.includes("openid")) {
|
|
2006
2028
|
let e;
|
|
@@ -2009,7 +2031,7 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
2009
2031
|
} catch {
|
|
2010
2032
|
e = void 0;
|
|
2011
2033
|
}
|
|
2012
|
-
if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${
|
|
2034
|
+
if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${En}`);
|
|
2013
2035
|
}
|
|
2014
2036
|
return {
|
|
2015
2037
|
access_token: i.access_token,
|
|
@@ -2017,13 +2039,13 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
2017
2039
|
...a ? { id_token: a } : {},
|
|
2018
2040
|
scopes: n.scopes
|
|
2019
2041
|
};
|
|
2020
|
-
},
|
|
2042
|
+
}, Bn = "error", Vn = /* @__PURE__ */ new WeakMap(), Hn = (e, t) => {
|
|
2021
2043
|
if (typeof t != "object" && typeof t != "function" || t === null) return !0;
|
|
2022
|
-
let n =
|
|
2023
|
-
return n || (n = /* @__PURE__ */ new WeakSet(),
|
|
2024
|
-
}, W = (e, t) =>
|
|
2044
|
+
let n = Vn.get(e);
|
|
2045
|
+
return n || (n = /* @__PURE__ */ new WeakSet(), Vn.set(e, n)), !n.has(t) && (n.add(t), !0);
|
|
2046
|
+
}, W = (e, t) => Hn(e, t.originalError) ? (e.notify(Bn, t), !0) : !1, G = /* @__PURE__ */ function(e) {
|
|
2025
2047
|
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.AntiBotSolving = "anti-bot:solving", e.AntiBotSolved = "anti-bot:solved", e;
|
|
2026
|
-
}({}),
|
|
2048
|
+
}({}), Un = class {
|
|
2027
2049
|
constructor() {
|
|
2028
2050
|
this.subscribers = /* @__PURE__ */ new Map();
|
|
2029
2051
|
}
|
|
@@ -2042,40 +2064,40 @@ var ot = /* @__PURE__ */ function(e) {
|
|
|
2042
2064
|
n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
|
|
2043
2065
|
}
|
|
2044
2066
|
notify(e, t) {
|
|
2045
|
-
e === "error" &&
|
|
2067
|
+
e === "error" && Hn(this, t?.originalError), this.subscribers.forEach((n, r) => {
|
|
2046
2068
|
(!n || n.has(e)) && r.onAuthChange?.(e, t);
|
|
2047
2069
|
});
|
|
2048
2070
|
}
|
|
2049
2071
|
notifyError(e) {
|
|
2050
2072
|
return W(this, e);
|
|
2051
2073
|
}
|
|
2052
|
-
},
|
|
2074
|
+
}, Wn = 256, Gn = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), Kn = (e) => {
|
|
2053
2075
|
let t = new Uint8Array(e), n = "";
|
|
2054
|
-
for (let e of t) n +=
|
|
2076
|
+
for (let e of t) n += Gn[e];
|
|
2055
2077
|
return n;
|
|
2056
|
-
},
|
|
2057
|
-
async function
|
|
2078
|
+
}, qn = class extends Error {};
|
|
2079
|
+
async function Jn(e, t, n, r = Infinity) {
|
|
2058
2080
|
let i = globalThis.crypto?.subtle;
|
|
2059
2081
|
if (!i) throw Error("Web Crypto unavailable");
|
|
2060
2082
|
let a = t.toLowerCase(), o = new TextEncoder();
|
|
2061
|
-
for (let t = 0; t <= n; t +=
|
|
2062
|
-
if (Date.now() > r) throw new
|
|
2063
|
-
let s = Math.min(t +
|
|
2083
|
+
for (let t = 0; t <= n; t += Wn) {
|
|
2084
|
+
if (Date.now() > r) throw new qn("Solve timed out");
|
|
2085
|
+
let s = Math.min(t + Wn - 1, n), c = [];
|
|
2064
2086
|
for (let n = t; n <= s; n++) c.push(i.digest("SHA-256", o.encode(`${e}:${n}`)));
|
|
2065
2087
|
let l = await Promise.all(c);
|
|
2066
|
-
for (let e = 0; e < l.length; e++) if (
|
|
2088
|
+
for (let e = 0; e < l.length; e++) if (Kn(l[e]) === a) return t + e;
|
|
2067
2089
|
}
|
|
2068
2090
|
return null;
|
|
2069
2091
|
}
|
|
2070
2092
|
// lib/anti-bot/solve.ts
|
|
2071
|
-
var
|
|
2093
|
+
var Yn = "The browser check could not be completed. Try again later.", Xn = "Verification failed. Try again.", Zn = 6e4, Qn = class extends Error {}, $n = (e, t, n, r) => new B({
|
|
2072
2094
|
id: e,
|
|
2073
2095
|
message: t,
|
|
2074
2096
|
status: 0,
|
|
2075
2097
|
location: n,
|
|
2076
2098
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2077
|
-
}, r === void 0 ? void 0 : { cause: r }),
|
|
2078
|
-
let i = new Worker(e), a = setTimeout(() => o(() => r(new
|
|
2099
|
+
}, r === void 0 ? void 0 : { cause: r }), er = (e, t) => new Promise((n, r) => {
|
|
2100
|
+
let i = new Worker(e), a = setTimeout(() => o(() => r(new Qn())), Zn), o = (e) => {
|
|
2079
2101
|
clearTimeout(a), i.terminate(), e();
|
|
2080
2102
|
};
|
|
2081
2103
|
i.addEventListener("message", (e) => {
|
|
@@ -2083,23 +2105,23 @@ var Wn = "The browser check could not be completed. Try again later.", Gn = "Ver
|
|
|
2083
2105
|
t && "error" in t ? o(() => r(Error(t.error))) : o(() => n(t?.number ?? null));
|
|
2084
2106
|
}), i.addEventListener("error", () => o(() => r(/* @__PURE__ */ Error("Anti-bot worker failed")))), i.addEventListener("messageerror", () => o(() => r(/* @__PURE__ */ Error("Anti-bot worker message failed")))), i.postMessage(t);
|
|
2085
2107
|
});
|
|
2086
|
-
async function
|
|
2087
|
-
if (e.algorithm !== "SHA-256") throw
|
|
2088
|
-
if (!Number.isSafeInteger(e.max) || e.max < 0 || e.max > 5e6) throw
|
|
2108
|
+
async function tr(e, t, n = "anti-bot") {
|
|
2109
|
+
if (e.algorithm !== "SHA-256") throw $n(Xe, Yn, n);
|
|
2110
|
+
if (!Number.isSafeInteger(e.max) || e.max < 0 || e.max > 5e6) throw $n(Xe, Xn, n);
|
|
2089
2111
|
let r = {
|
|
2090
2112
|
salt: e.salt,
|
|
2091
2113
|
challenge: e.challenge,
|
|
2092
2114
|
max: e.max
|
|
2093
2115
|
}, i;
|
|
2094
2116
|
try {
|
|
2095
|
-
i = t && typeof Worker < "u" ? await
|
|
2117
|
+
i = t && typeof Worker < "u" ? await er(t, r) : await Jn(r.salt, r.challenge, r.max, Date.now() + Zn);
|
|
2096
2118
|
} catch (e) {
|
|
2097
|
-
throw
|
|
2119
|
+
throw $n(Xe, e instanceof Qn || e instanceof qn ? Xn : Yn, n, e);
|
|
2098
2120
|
}
|
|
2099
|
-
if (i === null) throw
|
|
2121
|
+
if (i === null) throw $n(Xe, Yn, n);
|
|
2100
2122
|
return i;
|
|
2101
2123
|
}
|
|
2102
|
-
function
|
|
2124
|
+
function nr(e, t) {
|
|
2103
2125
|
let n = {
|
|
2104
2126
|
app: e.app,
|
|
2105
2127
|
exp: e.exp,
|
|
@@ -2112,8 +2134,8 @@ function Zn(e, t) {
|
|
|
2112
2134
|
return btoa(JSON.stringify(n));
|
|
2113
2135
|
}
|
|
2114
2136
|
// lib/anti-bot/anti-bot.ts
|
|
2115
|
-
var
|
|
2116
|
-
function
|
|
2137
|
+
var rr = "This app requires a verification token. Call setAntiBotTokenProvider() before signing in.", ir = "The verification could not be completed. Try again.";
|
|
2138
|
+
function ar(e) {
|
|
2117
2139
|
let t, n = async (e, t) => {
|
|
2118
2140
|
let n;
|
|
2119
2141
|
try {
|
|
@@ -2122,16 +2144,16 @@ function er(e) {
|
|
|
2122
2144
|
operation: t.operation
|
|
2123
2145
|
});
|
|
2124
2146
|
} catch (e) {
|
|
2125
|
-
throw
|
|
2147
|
+
throw $n(Ye, ir, t.operation, e);
|
|
2126
2148
|
}
|
|
2127
|
-
if (typeof n != "string" || n === "") throw
|
|
2149
|
+
if (typeof n != "string" || n === "") throw $n(Ye, ir, t.operation);
|
|
2128
2150
|
return n;
|
|
2129
2151
|
}, r = async (t) => {
|
|
2130
2152
|
let n = await e.fetchChallenge({
|
|
2131
2153
|
...t.identifier ? { identifier: t.identifier } : {},
|
|
2132
2154
|
...t.device ? { device: t.device } : {}
|
|
2133
2155
|
});
|
|
2134
|
-
return
|
|
2156
|
+
return nr(n, await tr(n, e.workerUrl, t.operation));
|
|
2135
2157
|
};
|
|
2136
2158
|
return {
|
|
2137
2159
|
setTokenProvider(e) {
|
|
@@ -2149,7 +2171,7 @@ function er(e) {
|
|
|
2149
2171
|
if (s) c = await r(i);
|
|
2150
2172
|
else {
|
|
2151
2173
|
let e = t;
|
|
2152
|
-
if (!e) throw
|
|
2174
|
+
if (!e) throw $n(Je, rr, i.operation);
|
|
2153
2175
|
c = await n(e, i);
|
|
2154
2176
|
}
|
|
2155
2177
|
return e.store.notify(G.AntiBotSolved, {
|
|
@@ -2163,97 +2185,97 @@ function er(e) {
|
|
|
2163
2185
|
};
|
|
2164
2186
|
}
|
|
2165
2187
|
// lib/refresh/constants.ts
|
|
2166
|
-
var
|
|
2188
|
+
var or = "passflow-refresh", sr = "passflow-refresh-takeover", cr = "passflow-auth", lr = Object.freeze([
|
|
2167
2189
|
1e3,
|
|
2168
2190
|
3e3,
|
|
2169
2191
|
1e4,
|
|
2170
2192
|
3e4,
|
|
2171
2193
|
6e4
|
|
2172
|
-
]),
|
|
2194
|
+
]), ur = .2, dr = 6e5, fr = 5e3, K = 2e4, pr = 2e4, mr = 1e3, hr = 2e3, gr = 1e3, _r = 1e4, vr = 5e3;
|
|
2173
2195
|
// lib/refresh/protocol.ts
|
|
2174
|
-
function
|
|
2196
|
+
function yr(e) {
|
|
2175
2197
|
let t = e ? `:${e}` : "";
|
|
2176
2198
|
return {
|
|
2177
|
-
lock: `${
|
|
2178
|
-
takeoverLock: `${
|
|
2179
|
-
channel: `${
|
|
2199
|
+
lock: `${or}${t}`,
|
|
2200
|
+
takeoverLock: `${sr}${t}`,
|
|
2201
|
+
channel: `${cr}${t}`
|
|
2180
2202
|
};
|
|
2181
2203
|
}
|
|
2182
2204
|
function q(e) {
|
|
2183
2205
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2184
2206
|
}
|
|
2185
|
-
function
|
|
2207
|
+
function br(e) {
|
|
2186
2208
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
2187
2209
|
}
|
|
2188
|
-
function
|
|
2210
|
+
function xr(e) {
|
|
2189
2211
|
return typeof e == "object" && !!e;
|
|
2190
2212
|
}
|
|
2191
|
-
function
|
|
2213
|
+
function Sr(e, t) {
|
|
2192
2214
|
for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
|
|
2193
2215
|
return e;
|
|
2194
2216
|
}
|
|
2195
|
-
function
|
|
2196
|
-
if (!
|
|
2217
|
+
function Cr(e) {
|
|
2218
|
+
if (!xr(e)) return null;
|
|
2197
2219
|
let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
|
|
2198
|
-
return
|
|
2220
|
+
return Sr({}, {
|
|
2199
2221
|
access_token: q(e.access_token),
|
|
2200
2222
|
refresh_token: q(e.refresh_token),
|
|
2201
2223
|
id_token: q(e.id_token),
|
|
2202
2224
|
scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
|
|
2203
2225
|
});
|
|
2204
2226
|
}
|
|
2205
|
-
function
|
|
2206
|
-
if (!
|
|
2227
|
+
function wr(e) {
|
|
2228
|
+
if (!xr(e)) return null;
|
|
2207
2229
|
let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
|
|
2208
|
-
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 ||
|
|
2230
|
+
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || br(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Sr({
|
|
2209
2231
|
kind: t,
|
|
2210
2232
|
attempt: n,
|
|
2211
2233
|
nextAt: r,
|
|
2212
2234
|
strikes: i
|
|
2213
2235
|
}, {
|
|
2214
2236
|
from: q(e.from),
|
|
2215
|
-
failingSince:
|
|
2237
|
+
failingSince: br(e.failingSince)
|
|
2216
2238
|
});
|
|
2217
2239
|
}
|
|
2218
|
-
function
|
|
2219
|
-
return
|
|
2240
|
+
function Tr(e) {
|
|
2241
|
+
return Sr({}, {
|
|
2220
2242
|
fp: q(e.fp),
|
|
2221
2243
|
sub: q(e.sub),
|
|
2222
2244
|
sid: q(e.sid),
|
|
2223
|
-
iat:
|
|
2245
|
+
iat: br(e.iat)
|
|
2224
2246
|
});
|
|
2225
2247
|
}
|
|
2226
|
-
function
|
|
2227
|
-
if (!
|
|
2248
|
+
function Er(e) {
|
|
2249
|
+
if (!xr(e)) return null;
|
|
2228
2250
|
let t = e;
|
|
2229
2251
|
if (t.v !== void 0 && t.v !== 1) return null;
|
|
2230
2252
|
let n = q(t.tabId);
|
|
2231
2253
|
if (!n) return null;
|
|
2232
2254
|
switch (t.type) {
|
|
2233
2255
|
case "tokens-refreshed": {
|
|
2234
|
-
let e =
|
|
2235
|
-
return !e || !r || !i ? null :
|
|
2256
|
+
let e = Cr(t.tokens), r = q(t.from), i = q(t.to);
|
|
2257
|
+
return !e || !r || !i ? null : Sr({
|
|
2236
2258
|
type: t.type,
|
|
2237
2259
|
tabId: n,
|
|
2238
2260
|
tokens: e,
|
|
2239
2261
|
from: r,
|
|
2240
2262
|
to: i
|
|
2241
2263
|
}, {
|
|
2242
|
-
fromIat:
|
|
2264
|
+
fromIat: br(t.fromIat),
|
|
2243
2265
|
fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
|
|
2244
|
-
sentAt:
|
|
2266
|
+
sentAt: br(t.sentAt)
|
|
2245
2267
|
});
|
|
2246
2268
|
}
|
|
2247
2269
|
case "session-refreshed": {
|
|
2248
|
-
let e =
|
|
2249
|
-
return e === void 0 ? null :
|
|
2270
|
+
let e = br(t.at);
|
|
2271
|
+
return e === void 0 ? null : Sr({
|
|
2250
2272
|
type: t.type,
|
|
2251
2273
|
tabId: n,
|
|
2252
2274
|
at: e
|
|
2253
2275
|
}, { sub: q(t.sub) });
|
|
2254
2276
|
}
|
|
2255
2277
|
case "still-refreshing": {
|
|
2256
|
-
let e = t.retry === void 0 ? null :
|
|
2278
|
+
let e = t.retry === void 0 ? null : wr(t.retry);
|
|
2257
2279
|
return e ? {
|
|
2258
2280
|
type: t.type,
|
|
2259
2281
|
tabId: n,
|
|
@@ -2264,7 +2286,7 @@ function xr(e) {
|
|
|
2264
2286
|
};
|
|
2265
2287
|
}
|
|
2266
2288
|
case "retry-scheduled": {
|
|
2267
|
-
let e =
|
|
2289
|
+
let e = wr(t);
|
|
2268
2290
|
return e ? {
|
|
2269
2291
|
type: t.type,
|
|
2270
2292
|
tabId: n,
|
|
@@ -2285,10 +2307,10 @@ function xr(e) {
|
|
|
2285
2307
|
case "signed-out": return {
|
|
2286
2308
|
type: t.type,
|
|
2287
2309
|
tabId: n,
|
|
2288
|
-
...
|
|
2310
|
+
...Tr(t)
|
|
2289
2311
|
};
|
|
2290
2312
|
case "rate-limited": {
|
|
2291
|
-
let e =
|
|
2313
|
+
let e = br(t.until);
|
|
2292
2314
|
return e === void 0 ? null : {
|
|
2293
2315
|
type: t.type,
|
|
2294
2316
|
tabId: n,
|
|
@@ -2307,22 +2329,22 @@ function xr(e) {
|
|
|
2307
2329
|
default: return null;
|
|
2308
2330
|
}
|
|
2309
2331
|
}
|
|
2310
|
-
function
|
|
2332
|
+
function Dr(e, t) {
|
|
2311
2333
|
let n = {
|
|
2312
2334
|
v: 1,
|
|
2313
2335
|
tabId: e
|
|
2314
2336
|
};
|
|
2315
2337
|
if (t.type === "retry-scheduled") {
|
|
2316
2338
|
let { retry: e, ...r } = t;
|
|
2317
|
-
return
|
|
2339
|
+
return Sr(n, {
|
|
2318
2340
|
...r,
|
|
2319
2341
|
...e
|
|
2320
2342
|
});
|
|
2321
2343
|
}
|
|
2322
|
-
return
|
|
2344
|
+
return Sr(n, { ...t });
|
|
2323
2345
|
}
|
|
2324
2346
|
// lib/refresh/resolve.ts
|
|
2325
|
-
var
|
|
2347
|
+
var Or = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", kr = {
|
|
2326
2348
|
now: () => Date.now(),
|
|
2327
2349
|
random: () => Math.random(),
|
|
2328
2350
|
setTimeout: (e, t) => {
|
|
@@ -2330,28 +2352,28 @@ var Cr = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
|
|
|
2330
2352
|
return n.unref?.(), () => clearTimeout(n);
|
|
2331
2353
|
}
|
|
2332
2354
|
};
|
|
2333
|
-
function
|
|
2355
|
+
function Ar() {
|
|
2334
2356
|
let e = globalThis.crypto;
|
|
2335
2357
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
2336
2358
|
}
|
|
2337
|
-
function
|
|
2359
|
+
function jr(e) {
|
|
2338
2360
|
return e ? {
|
|
2339
2361
|
now: () => e.now(),
|
|
2340
2362
|
setTimeout: (t, n) => e.setTimeout(t, n),
|
|
2341
|
-
random: e.random ? () => e.random?.() ?? Math.random() :
|
|
2342
|
-
} :
|
|
2363
|
+
random: e.random ? () => e.random?.() ?? Math.random() : kr.random
|
|
2364
|
+
} : kr;
|
|
2343
2365
|
}
|
|
2344
|
-
function
|
|
2366
|
+
function Mr(e) {
|
|
2345
2367
|
return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
|
|
2346
2368
|
}
|
|
2347
|
-
function
|
|
2369
|
+
function Nr(e) {
|
|
2348
2370
|
try {
|
|
2349
2371
|
return e.storageSharedAcrossTabs === !0;
|
|
2350
2372
|
} catch {
|
|
2351
2373
|
return !1;
|
|
2352
2374
|
}
|
|
2353
2375
|
}
|
|
2354
|
-
function
|
|
2376
|
+
function Pr() {
|
|
2355
2377
|
try {
|
|
2356
2378
|
let e = globalThis.navigator?.locks;
|
|
2357
2379
|
return e && typeof e.request == "function" ? e : void 0;
|
|
@@ -2359,7 +2381,7 @@ function kr() {
|
|
|
2359
2381
|
return;
|
|
2360
2382
|
}
|
|
2361
2383
|
}
|
|
2362
|
-
function
|
|
2384
|
+
function Fr(e) {
|
|
2363
2385
|
return (t) => {
|
|
2364
2386
|
let n = (n) => {
|
|
2365
2387
|
let r = n.key;
|
|
@@ -2368,20 +2390,20 @@ function Ar(e) {
|
|
|
2368
2390
|
return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
|
|
2369
2391
|
};
|
|
2370
2392
|
}
|
|
2371
|
-
function
|
|
2393
|
+
function Ir(e) {
|
|
2372
2394
|
return {
|
|
2373
2395
|
transports: null,
|
|
2374
|
-
names:
|
|
2375
|
-
clock:
|
|
2396
|
+
names: yr(e),
|
|
2397
|
+
clock: kr,
|
|
2376
2398
|
warnOnFirstCycle: !1
|
|
2377
2399
|
};
|
|
2378
2400
|
}
|
|
2379
|
-
function
|
|
2380
|
-
let i =
|
|
2401
|
+
function Lr(e, t, n, r) {
|
|
2402
|
+
let i = yr(n), a = Mr(t), o = a ? Fr(r.tokenKeys) : void 0, s = (e) => {
|
|
2381
2403
|
let t = {
|
|
2382
2404
|
transports: null,
|
|
2383
2405
|
names: i,
|
|
2384
|
-
clock:
|
|
2406
|
+
clock: kr,
|
|
2385
2407
|
warnOnFirstCycle: e
|
|
2386
2408
|
};
|
|
2387
2409
|
return o && (t.onStorageChange = o), t;
|
|
@@ -2391,16 +2413,16 @@ function Mr(e, t, n, r) {
|
|
|
2391
2413
|
transports: {
|
|
2392
2414
|
locks: e.locks,
|
|
2393
2415
|
channel: e.channel,
|
|
2394
|
-
tabId: e.tabId ??
|
|
2416
|
+
tabId: e.tabId ?? Ar()
|
|
2395
2417
|
},
|
|
2396
2418
|
names: i,
|
|
2397
|
-
clock:
|
|
2419
|
+
clock: jr(e.clock),
|
|
2398
2420
|
warnOnFirstCycle: !1
|
|
2399
2421
|
};
|
|
2400
2422
|
return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
|
|
2401
2423
|
}
|
|
2402
|
-
if (e === "none" || !a || !
|
|
2403
|
-
let c =
|
|
2424
|
+
if (e === "none" || !a || !Nr(t)) return s(!1);
|
|
2425
|
+
let c = Pr();
|
|
2404
2426
|
if (!c || typeof BroadcastChannel != "function") return s(!0);
|
|
2405
2427
|
let l;
|
|
2406
2428
|
try {
|
|
@@ -2412,16 +2434,16 @@ function Mr(e, t, n, r) {
|
|
|
2412
2434
|
transports: {
|
|
2413
2435
|
locks: c,
|
|
2414
2436
|
channel: l,
|
|
2415
|
-
tabId:
|
|
2437
|
+
tabId: Ar()
|
|
2416
2438
|
},
|
|
2417
2439
|
names: i,
|
|
2418
|
-
clock:
|
|
2440
|
+
clock: kr,
|
|
2419
2441
|
warnOnFirstCycle: !1
|
|
2420
2442
|
};
|
|
2421
2443
|
return o && (u.onStorageChange = o), u;
|
|
2422
2444
|
}
|
|
2423
2445
|
// lib/services/logger.ts
|
|
2424
|
-
var
|
|
2446
|
+
var Rr = class {
|
|
2425
2447
|
error(e, ...t) {
|
|
2426
2448
|
console.error(e, ...t);
|
|
2427
2449
|
}
|
|
@@ -2435,10 +2457,10 @@ var Nr = class {
|
|
|
2435
2457
|
console.debug(e, ...t);
|
|
2436
2458
|
}
|
|
2437
2459
|
};
|
|
2438
|
-
function
|
|
2439
|
-
return new
|
|
2460
|
+
function zr() {
|
|
2461
|
+
return new Rr();
|
|
2440
2462
|
}
|
|
2441
|
-
var
|
|
2463
|
+
var Br = Object.freeze([
|
|
2442
2464
|
"error.token.invalid.error",
|
|
2443
2465
|
"error.api.token.parse.error",
|
|
2444
2466
|
"error.api.user.blocked",
|
|
@@ -2446,25 +2468,25 @@ var Fr = Object.freeze([
|
|
|
2446
2468
|
"error.validation.token.invalid.subject",
|
|
2447
2469
|
"error.not.found"
|
|
2448
2470
|
]);
|
|
2449
|
-
function
|
|
2471
|
+
function Vr(e) {
|
|
2450
2472
|
if (typeof e != "object" || !e) return;
|
|
2451
2473
|
let t = e;
|
|
2452
2474
|
return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
|
|
2453
2475
|
}
|
|
2454
|
-
function
|
|
2455
|
-
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(
|
|
2476
|
+
function Hr(e, t) {
|
|
2477
|
+
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(dr, Math.floor(e) * 1e3);
|
|
2456
2478
|
if (typeof e != "string") return;
|
|
2457
2479
|
let n = e.trim();
|
|
2458
2480
|
if (n === "") return;
|
|
2459
|
-
if (/^\d+$/.test(n)) return Math.min(
|
|
2481
|
+
if (/^\d+$/.test(n)) return Math.min(dr, Number.parseInt(n, 10) * 1e3);
|
|
2460
2482
|
if (!/[a-z]/i.test(n)) return;
|
|
2461
2483
|
let r = Date.parse(n);
|
|
2462
|
-
if (!Number.isNaN(r)) return Math.min(
|
|
2484
|
+
if (!Number.isNaN(r)) return Math.min(dr, Math.max(0, r - t));
|
|
2463
2485
|
}
|
|
2464
|
-
function
|
|
2486
|
+
function Ur(e) {
|
|
2465
2487
|
return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
|
|
2466
2488
|
}
|
|
2467
|
-
function
|
|
2489
|
+
function Wr(e) {
|
|
2468
2490
|
if (typeof e.id == "string" && e.id !== "") return e.id;
|
|
2469
2491
|
let t = e.response?.data;
|
|
2470
2492
|
if (typeof t != "object" || !t) return;
|
|
@@ -2473,14 +2495,14 @@ function zr(e) {
|
|
|
2473
2495
|
let r = n.id;
|
|
2474
2496
|
return typeof r == "string" && r !== "" ? r : void 0;
|
|
2475
2497
|
}
|
|
2476
|
-
function
|
|
2498
|
+
function Gr(e, t = Date.now()) {
|
|
2477
2499
|
if (typeof e != "object" || !e) return { kind: "transient" };
|
|
2478
|
-
let n = e, r =
|
|
2500
|
+
let n = e, r = Wr(n), i = Ur(n.response?.status) ?? Ur(n.status), a = {};
|
|
2479
2501
|
if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
|
|
2480
2502
|
kind: "blocked",
|
|
2481
2503
|
...a
|
|
2482
2504
|
};
|
|
2483
|
-
if (r !== void 0 &&
|
|
2505
|
+
if (r !== void 0 && Br.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
|
|
2484
2506
|
kind: "auth",
|
|
2485
2507
|
...a
|
|
2486
2508
|
};
|
|
@@ -2488,7 +2510,7 @@ function Br(e, t = Date.now()) {
|
|
|
2488
2510
|
kind: "transient",
|
|
2489
2511
|
...a
|
|
2490
2512
|
};
|
|
2491
|
-
let o =
|
|
2513
|
+
let o = Hr(n.retryAfter ?? Vr(n.response?.headers), t);
|
|
2492
2514
|
return o === void 0 ? {
|
|
2493
2515
|
kind: "transient",
|
|
2494
2516
|
...a
|
|
@@ -2498,19 +2520,19 @@ function Br(e, t = Date.now()) {
|
|
|
2498
2520
|
retryAfterMs: o
|
|
2499
2521
|
};
|
|
2500
2522
|
}
|
|
2501
|
-
function
|
|
2502
|
-
let r =
|
|
2503
|
-
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0),
|
|
2523
|
+
function Kr(e, t, n) {
|
|
2524
|
+
let r = lr.length, i = lr[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? lr[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * ur * a);
|
|
2525
|
+
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), dr) : 0);
|
|
2504
2526
|
}
|
|
2505
2527
|
// lib/refresh/coordinator.ts
|
|
2506
|
-
var
|
|
2528
|
+
var qr = {
|
|
2507
2529
|
onGranted: () => !1,
|
|
2508
2530
|
onLockLost: () => void 0,
|
|
2509
2531
|
onMessage: () => void 0
|
|
2510
2532
|
};
|
|
2511
|
-
function
|
|
2512
|
-
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o =
|
|
2513
|
-
g || n.postMessage(
|
|
2533
|
+
function Jr(e) {
|
|
2534
|
+
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = qr, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
|
|
2535
|
+
g || n.postMessage(Dr(r, e));
|
|
2514
2536
|
}, v = () => s !== null && c === null, y = () => {
|
|
2515
2537
|
f?.(), f = null;
|
|
2516
2538
|
}, b = (e) => {
|
|
@@ -2525,7 +2547,7 @@ function Ur(e) {
|
|
|
2525
2547
|
type: "still-refreshing",
|
|
2526
2548
|
retry: m
|
|
2527
2549
|
} : { type: "still-refreshing" }), ee());
|
|
2528
|
-
},
|
|
2550
|
+
}, fr);
|
|
2529
2551
|
}, S = () => {
|
|
2530
2552
|
y(), x(), u?.(), u = null;
|
|
2531
2553
|
let e = s;
|
|
@@ -2576,7 +2598,7 @@ function Ur(e) {
|
|
|
2576
2598
|
});
|
|
2577
2599
|
}, te = (e) => {
|
|
2578
2600
|
if (g) return;
|
|
2579
|
-
let t =
|
|
2601
|
+
let t = Er(e.data);
|
|
2580
2602
|
if (t && t.tabId !== r) {
|
|
2581
2603
|
switch (t.type) {
|
|
2582
2604
|
case "still-refreshing":
|
|
@@ -2619,8 +2641,8 @@ function Ur(e) {
|
|
|
2619
2641
|
}
|
|
2620
2642
|
};
|
|
2621
2643
|
}
|
|
2622
|
-
function
|
|
2623
|
-
let t =
|
|
2644
|
+
function Yr(e = "local") {
|
|
2645
|
+
let t = qr, n = !1, r = !1, i = 0, a = !1, o = () => {
|
|
2624
2646
|
n = !1, r = !1, i += 1;
|
|
2625
2647
|
};
|
|
2626
2648
|
return {
|
|
@@ -2668,7 +2690,7 @@ var J = {
|
|
|
2668
2690
|
successorTimeout: "error.refresh.successor_timeout",
|
|
2669
2691
|
identityChanged: "error.refresh.identity_changed",
|
|
2670
2692
|
disposed: "error.refresh.disposed"
|
|
2671
|
-
},
|
|
2693
|
+
}, Xr = {
|
|
2672
2694
|
"error.refresh.unavailable": 503,
|
|
2673
2695
|
"error.refresh.auth_retry": 401,
|
|
2674
2696
|
"error.refresh.session_ended": 401,
|
|
@@ -2676,7 +2698,7 @@ var J = {
|
|
|
2676
2698
|
"error.refresh.successor_timeout": 401,
|
|
2677
2699
|
"error.refresh.identity_changed": 401,
|
|
2678
2700
|
"error.refresh.disposed": 499
|
|
2679
|
-
},
|
|
2701
|
+
}, Zr = {
|
|
2680
2702
|
"error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
|
|
2681
2703
|
"error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
|
|
2682
2704
|
"error.refresh.session_ended": "The session has ended",
|
|
@@ -2688,19 +2710,19 @@ var J = {
|
|
|
2688
2710
|
constructor(e, t = {}) {
|
|
2689
2711
|
super({
|
|
2690
2712
|
id: e,
|
|
2691
|
-
message: t.message ??
|
|
2692
|
-
status:
|
|
2713
|
+
message: t.message ?? Zr[e],
|
|
2714
|
+
status: Xr[e],
|
|
2693
2715
|
location: "/auth/refresh",
|
|
2694
2716
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2695
2717
|
}), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
|
|
2696
2718
|
}
|
|
2697
|
-
},
|
|
2719
|
+
}, Qr = class extends Error {
|
|
2698
2720
|
constructor(e, t) {
|
|
2699
2721
|
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;
|
|
2700
2722
|
}
|
|
2701
2723
|
};
|
|
2702
2724
|
// lib/refresh/lineage.ts
|
|
2703
|
-
function
|
|
2725
|
+
function $r(e) {
|
|
2704
2726
|
if (!e) return;
|
|
2705
2727
|
let t = 3735928559, n = 1103547991;
|
|
2706
2728
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -2709,24 +2731,24 @@ function Jr(e) {
|
|
|
2709
2731
|
}
|
|
2710
2732
|
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);
|
|
2711
2733
|
}
|
|
2712
|
-
function
|
|
2734
|
+
function ei(e) {
|
|
2713
2735
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2714
2736
|
}
|
|
2715
2737
|
function X(e) {
|
|
2716
|
-
let t =
|
|
2738
|
+
let t = $r(e);
|
|
2717
2739
|
if (!e || !t) return;
|
|
2718
2740
|
let n = {};
|
|
2719
2741
|
try {
|
|
2720
2742
|
let t = j(e);
|
|
2721
2743
|
typeof t == "object" && t && (n = t);
|
|
2722
2744
|
} catch {}
|
|
2723
|
-
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a =
|
|
2745
|
+
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = ei(n.sub), o = ei(n.sid);
|
|
2724
2746
|
return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
|
|
2725
2747
|
}
|
|
2726
|
-
var
|
|
2727
|
-
function
|
|
2748
|
+
var ti = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
|
|
2749
|
+
function ni(e = (e) => zr().warn(e)) {
|
|
2728
2750
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
|
|
2729
|
-
a || (a = !0, e(
|
|
2751
|
+
a || (a = !0, e(ti));
|
|
2730
2752
|
}, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
|
|
2731
2753
|
if (!e) return;
|
|
2732
2754
|
if (e.iat === void 0) {
|
|
@@ -2767,16 +2789,16 @@ function Zr(e = (e) => Pr().warn(e)) {
|
|
|
2767
2789
|
};
|
|
2768
2790
|
}
|
|
2769
2791
|
// lib/refresh/fence.ts
|
|
2770
|
-
var
|
|
2792
|
+
var ri = class extends Error {
|
|
2771
2793
|
constructor(e) {
|
|
2772
2794
|
super(e === "emptied" ? "The shared token storage was emptied" : "The stored refresh token belongs to an ended session"), this.name = "SessionEnded", this.cause = e;
|
|
2773
2795
|
}
|
|
2774
|
-
},
|
|
2796
|
+
}, ii = class extends Error {
|
|
2775
2797
|
constructor() {
|
|
2776
2798
|
super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
|
|
2777
2799
|
}
|
|
2778
2800
|
};
|
|
2779
|
-
function
|
|
2801
|
+
function ai(e) {
|
|
2780
2802
|
if (e) try {
|
|
2781
2803
|
let t = j(e).sub;
|
|
2782
2804
|
return typeof t == "string" && t !== "" ? t : void 0;
|
|
@@ -2785,20 +2807,20 @@ function ei(e) {
|
|
|
2785
2807
|
}
|
|
2786
2808
|
}
|
|
2787
2809
|
function Z(e) {
|
|
2788
|
-
return
|
|
2810
|
+
return ai(e?.access_token) ?? ai(e?.refresh_token) ?? ai(e?.id_token);
|
|
2789
2811
|
}
|
|
2790
|
-
function
|
|
2812
|
+
function oi(e, t) {
|
|
2791
2813
|
return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
|
|
2792
2814
|
}
|
|
2793
|
-
function
|
|
2815
|
+
function si(e) {
|
|
2794
2816
|
return typeof e == "object" && !!e;
|
|
2795
2817
|
}
|
|
2796
|
-
function
|
|
2797
|
-
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) =>
|
|
2818
|
+
function ci(e) {
|
|
2819
|
+
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => zr().warn(e)), o = e.lineage ?? ni(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
|
|
2798
2820
|
let e = t.getTokens(), n = e?.refresh_token;
|
|
2799
2821
|
if (!n) return p = l, e;
|
|
2800
2822
|
p !== void 0 && (f = Math.max(f, p, m), p = void 0);
|
|
2801
|
-
let r =
|
|
2823
|
+
let r = $r(n) ?? "";
|
|
2802
2824
|
return r !== c?.fp && (c = {
|
|
2803
2825
|
fp: r,
|
|
2804
2826
|
seq: l
|
|
@@ -2833,7 +2855,7 @@ function ri(e) {
|
|
|
2833
2855
|
h = void 0;
|
|
2834
2856
|
let e = y();
|
|
2835
2857
|
e?.refresh_token || C(e) ? A() : te(!0) === "end" && s?.("emptied");
|
|
2836
|
-
},
|
|
2858
|
+
}, hr));
|
|
2837
2859
|
let n = t === "keep" ? T() : void 0;
|
|
2838
2860
|
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;
|
|
2839
2861
|
}, O = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, ne = (e) => {
|
|
@@ -2846,7 +2868,7 @@ function ri(e) {
|
|
|
2846
2868
|
return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
|
|
2847
2869
|
}, ie = (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), ae = (e) => {
|
|
2848
2870
|
let t = b();
|
|
2849
|
-
t && t.fp !==
|
|
2871
|
+
t && t.fp !== $r(e.refresh_token) && o.retire(t), n.setTokensCache(e);
|
|
2850
2872
|
}, oe = (e) => {
|
|
2851
2873
|
let t = y(), n = t?.refresh_token;
|
|
2852
2874
|
if (n === e.refreshToken) return null;
|
|
@@ -2857,7 +2879,7 @@ function ri(e) {
|
|
|
2857
2879
|
kind: "superseded",
|
|
2858
2880
|
adopted: !1
|
|
2859
2881
|
};
|
|
2860
|
-
let r =
|
|
2882
|
+
let r = ai(t.access_token) ?? ai(n);
|
|
2861
2883
|
if (e.sub && r && e.sub !== r) return {
|
|
2862
2884
|
kind: "identity-changed",
|
|
2863
2885
|
saved: !1
|
|
@@ -2898,22 +2920,22 @@ function ri(e) {
|
|
|
2898
2920
|
let e = y();
|
|
2899
2921
|
if (C(e)) return "held";
|
|
2900
2922
|
if (!e?.refresh_token) {
|
|
2901
|
-
if (te() === "end") throw new
|
|
2923
|
+
if (te() === "end") throw new ri("emptied");
|
|
2902
2924
|
return "held";
|
|
2903
2925
|
}
|
|
2904
2926
|
let t = n.getTokens();
|
|
2905
2927
|
if (e.refresh_token === t?.refresh_token) return "send";
|
|
2906
2928
|
let r = i() ?? Z(t), a = Z(e);
|
|
2907
|
-
if (r && a && r !== a) throw new
|
|
2929
|
+
if (r && a && r !== a) throw new ii();
|
|
2908
2930
|
let s = X(e.refresh_token);
|
|
2909
2931
|
if (o.isEnded(s)) {
|
|
2910
2932
|
if (s && S(s)) return "held";
|
|
2911
|
-
throw new
|
|
2933
|
+
throw new ri("ended");
|
|
2912
2934
|
}
|
|
2913
2935
|
let c = X(t?.refresh_token);
|
|
2914
2936
|
return ie(s, c) ? (ae(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && ne(s) ? "held" : "send";
|
|
2915
2937
|
}, ce = (e) => {
|
|
2916
|
-
let t = i(), r =
|
|
2938
|
+
let t = i(), r = ai(e);
|
|
2917
2939
|
if (t && r && t !== r) return { kind: "identity-changed" };
|
|
2918
2940
|
let a = X(e) ?? { fp: e };
|
|
2919
2941
|
if (o.isEnded(a)) return S(a) ? { kind: "superseded" } : { kind: "ended" };
|
|
@@ -2921,7 +2943,7 @@ function ri(e) {
|
|
|
2921
2943
|
let s = {
|
|
2922
2944
|
refreshToken: e,
|
|
2923
2945
|
order: a
|
|
2924
|
-
}, c = t ?? r ??
|
|
2946
|
+
}, c = t ?? r ?? ai(n.getTokens()?.access_token);
|
|
2925
2947
|
return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
|
|
2926
2948
|
kind: "send",
|
|
2927
2949
|
sent: s
|
|
@@ -2930,7 +2952,7 @@ function ri(e) {
|
|
|
2930
2952
|
if (o.isEnded(e.order)) return k(e.order);
|
|
2931
2953
|
let i = oe(e);
|
|
2932
2954
|
if (i) return i;
|
|
2933
|
-
if (!O(e) && re(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${
|
|
2955
|
+
if (!O(e) && re(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${$r(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.`), {
|
|
2934
2956
|
kind: "superseded",
|
|
2935
2957
|
adopted: !1
|
|
2936
2958
|
};
|
|
@@ -2940,7 +2962,7 @@ function ri(e) {
|
|
|
2940
2962
|
saved: !0
|
|
2941
2963
|
};
|
|
2942
2964
|
let c = X(r.refresh_token);
|
|
2943
|
-
return c && (
|
|
2965
|
+
return c && (oi(c, e.order) || oi(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.`), {
|
|
2944
2966
|
kind: "superseded",
|
|
2945
2967
|
adopted: !1
|
|
2946
2968
|
}) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
|
|
@@ -2952,7 +2974,7 @@ function ri(e) {
|
|
|
2952
2974
|
kind: "superseded",
|
|
2953
2975
|
adopted: !1
|
|
2954
2976
|
};
|
|
2955
|
-
let r =
|
|
2977
|
+
let r = Gr(t), i = r.kind === "blocked" || r.kind === "auth";
|
|
2956
2978
|
return O(e) && i ? (o.retire(e.order), _ = e.order, {
|
|
2957
2979
|
kind: "own",
|
|
2958
2980
|
failure: r,
|
|
@@ -2963,11 +2985,11 @@ function ri(e) {
|
|
|
2963
2985
|
heldRefused: !1
|
|
2964
2986
|
});
|
|
2965
2987
|
}, I = (e) => {
|
|
2966
|
-
if (!
|
|
2988
|
+
if (!si(e)) return !1;
|
|
2967
2989
|
let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
|
|
2968
|
-
if (typeof t != "string" || typeof c != "string" || !
|
|
2990
|
+
if (typeof t != "string" || typeof c != "string" || !si(l)) return !1;
|
|
2969
2991
|
let u = l;
|
|
2970
|
-
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" ||
|
|
2992
|
+
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || $r(u.refresh_token) !== c) return !1;
|
|
2971
2993
|
let d = y();
|
|
2972
2994
|
if (!d?.refresh_token) return !1;
|
|
2973
2995
|
let f = n.getTokens(), p = i() ?? Z(f), m = Z(u);
|
|
@@ -2984,7 +3006,7 @@ function ri(e) {
|
|
|
2984
3006
|
}
|
|
2985
3007
|
return !0;
|
|
2986
3008
|
};
|
|
2987
|
-
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t &&
|
|
3009
|
+
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && $r(d.refresh_token) !== c ? !1 : (ae({ ...u }), _());
|
|
2988
3010
|
}, le = (e) => {
|
|
2989
3011
|
if (!e || !_) return !1;
|
|
2990
3012
|
let t = _;
|
|
@@ -3050,7 +3072,7 @@ function ri(e) {
|
|
|
3050
3072
|
};
|
|
3051
3073
|
}
|
|
3052
3074
|
// lib/refresh/controller.ts
|
|
3053
|
-
function
|
|
3075
|
+
function li() {
|
|
3054
3076
|
let e, t, n = new Promise((n, r) => {
|
|
3055
3077
|
e = n, t = r;
|
|
3056
3078
|
});
|
|
@@ -3060,7 +3082,7 @@ function ii() {
|
|
|
3060
3082
|
reject: t
|
|
3061
3083
|
};
|
|
3062
3084
|
}
|
|
3063
|
-
var
|
|
3085
|
+
var ui = {
|
|
3064
3086
|
strikes: J.sessionEnded,
|
|
3065
3087
|
"session-ended": J.sessionEnded,
|
|
3066
3088
|
"stored-ended": J.sessionEnded,
|
|
@@ -3071,42 +3093,42 @@ var ai = {
|
|
|
3071
3093
|
"identity-changed": J.identityChanged,
|
|
3072
3094
|
disposed: J.disposed
|
|
3073
3095
|
};
|
|
3074
|
-
function
|
|
3096
|
+
function di(e) {
|
|
3075
3097
|
throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
|
|
3076
3098
|
}
|
|
3077
|
-
function
|
|
3099
|
+
function fi(e) {
|
|
3078
3100
|
if (e === void 0 || !Number.isFinite(e)) return 3;
|
|
3079
3101
|
let t = Math.floor(e);
|
|
3080
3102
|
return t >= 1 ? t : 3;
|
|
3081
3103
|
}
|
|
3082
|
-
function
|
|
3104
|
+
function pi(e, t) {
|
|
3083
3105
|
return e instanceof Error && e.message ? e.message : t;
|
|
3084
3106
|
}
|
|
3085
|
-
function
|
|
3107
|
+
function mi(e) {
|
|
3086
3108
|
if (typeof e != "object" || !e) return;
|
|
3087
3109
|
let t = e.id;
|
|
3088
3110
|
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
3089
3111
|
}
|
|
3090
|
-
function
|
|
3112
|
+
function hi(e) {
|
|
3091
3113
|
let t = {};
|
|
3092
3114
|
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;
|
|
3093
3115
|
}
|
|
3094
|
-
function
|
|
3116
|
+
function gi(e, t) {
|
|
3095
3117
|
let n = {};
|
|
3096
3118
|
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);
|
|
3097
3119
|
let r = t?.scopes ?? e.scopes;
|
|
3098
3120
|
return r && (n.scopes = r), n;
|
|
3099
3121
|
}
|
|
3100
|
-
function
|
|
3101
|
-
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ??
|
|
3122
|
+
function _i(e) {
|
|
3123
|
+
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? zr(), c = fi(e.strikes), l = a.transports ? Jr({
|
|
3102
3124
|
locks: a.transports.locks,
|
|
3103
3125
|
channel: a.transports.channel,
|
|
3104
3126
|
tabId: a.transports.tabId,
|
|
3105
3127
|
names: a.names,
|
|
3106
3128
|
clock: o
|
|
3107
|
-
}) :
|
|
3129
|
+
}) : Yr(), u = { kind: "idle" }, d = 0, f = !1, p = !a.warnOnFirstCycle, m = 0, h = 0, g, _, v, y, b, x, ee, S, C = !1, w = () => o.now(), T = () => i.mode(), E = () => $r(r.getTokens()?.refresh_token), D = () => ({ ...r.getTokens() ?? {} }), te = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, O = () => (ee === void 0 && (ee = Z(r.getTokens() ?? n.getTokens())), ee), ne = /* @__PURE__ */ new Set(), re = /* @__PURE__ */ new Set(), ie = (e) => () => {
|
|
3108
3130
|
for (let t of Array.from(e)) t();
|
|
3109
|
-
}, ae = a.onStorageChange?.(ie(ne)), oe = e.platform?.onForeground(ie(re)), k =
|
|
3131
|
+
}, ae = a.onStorageChange?.(ie(ne)), oe = e.platform?.onForeground(ie(re)), k = ci({
|
|
3110
3132
|
storage: n,
|
|
3111
3133
|
cache: r,
|
|
3112
3134
|
identity: O,
|
|
@@ -3121,13 +3143,13 @@ function fi(e) {
|
|
|
3121
3143
|
}), A = (e) => ({
|
|
3122
3144
|
trigger: e,
|
|
3123
3145
|
startedAt: w(),
|
|
3124
|
-
plain:
|
|
3146
|
+
plain: li(),
|
|
3125
3147
|
fresh: []
|
|
3126
3148
|
}), j = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, M = (e, t) => {
|
|
3127
3149
|
if (t === void 0) return e.plain.promise;
|
|
3128
3150
|
let n = {
|
|
3129
3151
|
callTime: t,
|
|
3130
|
-
deferred:
|
|
3152
|
+
deferred: li()
|
|
3131
3153
|
};
|
|
3132
3154
|
return e.fresh.push(n), n.deferred.promise;
|
|
3133
3155
|
}, N = (e, t, n = !1) => {
|
|
@@ -3146,11 +3168,11 @@ function fi(e) {
|
|
|
3146
3168
|
}
|
|
3147
3169
|
}, P = (e, n, r, i) => {
|
|
3148
3170
|
let a = {
|
|
3149
|
-
message:
|
|
3171
|
+
message: pi(r, "Token refresh failed"),
|
|
3150
3172
|
originalError: r,
|
|
3151
3173
|
operation: e,
|
|
3152
3174
|
source: n
|
|
3153
|
-
}, o =
|
|
3175
|
+
}, o = mi(r);
|
|
3154
3176
|
o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
|
|
3155
3177
|
}, F = (e, t) => {
|
|
3156
3178
|
let n = {
|
|
@@ -3180,10 +3202,10 @@ function fi(e) {
|
|
|
3180
3202
|
};
|
|
3181
3203
|
n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
|
|
3182
3204
|
}, ue = (e, t) => {
|
|
3183
|
-
let n = r.getTokens(), i =
|
|
3205
|
+
let n = r.getTokens(), i = $r(n?.refresh_token);
|
|
3184
3206
|
e.fp && i && l.post({
|
|
3185
3207
|
type: "tokens-refreshed",
|
|
3186
|
-
tokens:
|
|
3208
|
+
tokens: hi(n),
|
|
3187
3209
|
from: e.fp,
|
|
3188
3210
|
...e.iat === void 0 ? {} : { fromIat: e.iat },
|
|
3189
3211
|
fromSid: e.sid ?? "",
|
|
@@ -3191,7 +3213,7 @@ function fi(e) {
|
|
|
3191
3213
|
...t === void 0 ? {} : { sentAt: t }
|
|
3192
3214
|
});
|
|
3193
3215
|
}, de = () => {
|
|
3194
|
-
p || (p = !0, s.warn(
|
|
3216
|
+
p || (p = !0, s.warn(Or));
|
|
3195
3217
|
}, fe = (e) => {
|
|
3196
3218
|
(e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
|
|
3197
3219
|
}, L = (e, n) => {
|
|
@@ -3205,7 +3227,7 @@ function fi(e) {
|
|
|
3205
3227
|
}, e !== "disposed" && k.dropSession(), (e === "strikes" || e === "successor-timeout") && T() !== "json" && i.invalidate(), u = {
|
|
3206
3228
|
kind: "ended",
|
|
3207
3229
|
cause: e
|
|
3208
|
-
}, ce(r, n ?? new Y(
|
|
3230
|
+
}, ce(r, n ?? new Y(ui[e])), e) {
|
|
3209
3231
|
case "strikes":
|
|
3210
3232
|
t("session:expired", {
|
|
3211
3233
|
reason: "refresh_failed",
|
|
@@ -3240,7 +3262,7 @@ function fi(e) {
|
|
|
3240
3262
|
break;
|
|
3241
3263
|
case "signed-out-here":
|
|
3242
3264
|
case "disposed": break;
|
|
3243
|
-
default:
|
|
3265
|
+
default: di(e);
|
|
3244
3266
|
}
|
|
3245
3267
|
}, R = () => {
|
|
3246
3268
|
if (u.kind !== "ended" || u.cause === "disposed" || f || T() !== "json") return;
|
|
@@ -3257,10 +3279,10 @@ function fi(e) {
|
|
|
3257
3279
|
}, pe = (e) => {
|
|
3258
3280
|
u.kind === "ended" || f || T() === "json" && (L(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && R());
|
|
3259
3281
|
}, me = (e) => {
|
|
3260
|
-
e instanceof
|
|
3282
|
+
e instanceof ii ? (L("identity-changed"), R()) : e instanceof ri ? L(e.cause === "emptied" ? "emptied" : "stored-ended") : L("stored-ended", e);
|
|
3261
3283
|
}, he = () => {
|
|
3262
3284
|
u = { kind: "idle" }, C || l.release();
|
|
3263
|
-
}, ge = (e) => !e.from || T() !== "json" || e.from === E() || e.from ===
|
|
3285
|
+
}, ge = (e) => !e.from || T() !== "json" || e.from === E() || e.from === $r(n.getTokens()?.refresh_token), _e = (e) => {
|
|
3264
3286
|
let t = g;
|
|
3265
3287
|
if (!t) return;
|
|
3266
3288
|
if (!l.holding) {
|
|
@@ -3326,14 +3348,14 @@ function fi(e) {
|
|
|
3326
3348
|
case "ended": return k.endHeldSend(), L("stored-ended"), !1;
|
|
3327
3349
|
case "identity-changed": return k.endHeldSend(), L("identity-changed"), R(), !1;
|
|
3328
3350
|
case "send": return Ce(e, t, a.sent, r);
|
|
3329
|
-
default: return
|
|
3351
|
+
default: return di(a);
|
|
3330
3352
|
}
|
|
3331
3353
|
}, Ce = (e, n, r, a) => {
|
|
3332
3354
|
let o = {
|
|
3333
3355
|
generation: d,
|
|
3334
3356
|
sentAt: w(),
|
|
3335
3357
|
trigger: n,
|
|
3336
|
-
settled:
|
|
3358
|
+
settled: li()
|
|
3337
3359
|
};
|
|
3338
3360
|
r ? o.sent = r : o.marker = te(), a && (o.stored = a), u = {
|
|
3339
3361
|
kind: "refreshing",
|
|
@@ -3370,7 +3392,7 @@ function fi(e) {
|
|
|
3370
3392
|
if (!we(e)) return;
|
|
3371
3393
|
r.setTokensCache({
|
|
3372
3394
|
...n.getTokens() ?? {},
|
|
3373
|
-
...
|
|
3395
|
+
...gi(t, void 0)
|
|
3374
3396
|
}), I("refresh", "this-tab");
|
|
3375
3397
|
let c = O();
|
|
3376
3398
|
l.post(c === void 0 ? {
|
|
@@ -3383,7 +3405,7 @@ function fi(e) {
|
|
|
3383
3405
|
}), he(), N(a, e.sentAt);
|
|
3384
3406
|
return;
|
|
3385
3407
|
}
|
|
3386
|
-
let o = E(), s = k.commitSave(e.sent,
|
|
3408
|
+
let o = E(), s = k.commitSave(e.sent, gi(t, e.stored));
|
|
3387
3409
|
switch (s.kind) {
|
|
3388
3410
|
case "saved":
|
|
3389
3411
|
I("refresh", "this-tab"), ue(e.sent.order, e.sentAt), he(), N(a, e.sentAt);
|
|
@@ -3401,7 +3423,7 @@ function fi(e) {
|
|
|
3401
3423
|
P("refresh", e.trigger, t, F("auth")), L("identity-changed", t), R();
|
|
3402
3424
|
return;
|
|
3403
3425
|
}
|
|
3404
|
-
default:
|
|
3426
|
+
default: di(s);
|
|
3405
3427
|
}
|
|
3406
3428
|
}, Ee = (e, t) => {
|
|
3407
3429
|
if (e.sent?.held && k.endHeldSend(), !we(e) || u.kind !== "refreshing") return;
|
|
@@ -3421,9 +3443,9 @@ function fi(e) {
|
|
|
3421
3443
|
case "own":
|
|
3422
3444
|
r = o.failure, i = o.heldRefused;
|
|
3423
3445
|
break;
|
|
3424
|
-
default:
|
|
3446
|
+
default: di(o);
|
|
3425
3447
|
}
|
|
3426
|
-
} else r =
|
|
3448
|
+
} else r = Gr(t, w());
|
|
3427
3449
|
if (i) P("refresh", e.trigger, t, F(r.kind)), I("adopted", "other-tab"), he(), N(n, void 0, !0);
|
|
3428
3450
|
else switch (r.kind) {
|
|
3429
3451
|
case "blocked":
|
|
@@ -3439,10 +3461,10 @@ function fi(e) {
|
|
|
3439
3461
|
case "transient":
|
|
3440
3462
|
m += 1, De(e, n, t, r);
|
|
3441
3463
|
return;
|
|
3442
|
-
default:
|
|
3464
|
+
default: di(r.kind);
|
|
3443
3465
|
}
|
|
3444
3466
|
}, De = (e, t, n, r) => {
|
|
3445
|
-
let i = w() +
|
|
3467
|
+
let i = w() + Kr(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
|
|
3446
3468
|
P("refresh", e.trigger, n, F(a, i)), a === "transient" && le(w(), i, "this-tab");
|
|
3447
3469
|
let s = {
|
|
3448
3470
|
kind: a,
|
|
@@ -3452,7 +3474,7 @@ function fi(e) {
|
|
|
3452
3474
|
}, c = e.sent?.order.fp;
|
|
3453
3475
|
c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
|
|
3454
3476
|
type: "retry-scheduled",
|
|
3455
|
-
message:
|
|
3477
|
+
message: pi(n, "Token refresh failed"),
|
|
3456
3478
|
retry: s
|
|
3457
3479
|
}), _e(A("retry")), se(t, n, e.sentAt);
|
|
3458
3480
|
}, Oe = (e, t) => {
|
|
@@ -3465,8 +3487,8 @@ function fi(e) {
|
|
|
3465
3487
|
fp: i.fp
|
|
3466
3488
|
})), r && k.deleteIfStillDead(r), L("strikes", t);
|
|
3467
3489
|
}, ke = (e, t, n, r) => {
|
|
3468
|
-
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${
|
|
3469
|
-
let i = d, a = w() +
|
|
3490
|
+
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${pi(n, "blocked")}`);
|
|
3491
|
+
let i = d, a = w() + pr, c = {
|
|
3470
3492
|
kind: "blocked-wait",
|
|
3471
3493
|
pending: e,
|
|
3472
3494
|
deadline: a,
|
|
@@ -3479,9 +3501,9 @@ function fi(e) {
|
|
|
3479
3501
|
i === d && u === c && (Ae() || (f ? (e.cookieRetried = !0, u = {
|
|
3480
3502
|
kind: "waiting",
|
|
3481
3503
|
pending: e
|
|
3482
|
-
}, l.request()) : w() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), L("successor-timeout")) : c.cancel = o.setTimeout(p,
|
|
3504
|
+
}, l.request()) : w() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), L("successor-timeout")) : c.cancel = o.setTimeout(p, mr)));
|
|
3483
3505
|
};
|
|
3484
|
-
c.cancel = o.setTimeout(p, f ?
|
|
3506
|
+
c.cancel = o.setTimeout(p, f ? gr : mr);
|
|
3485
3507
|
}, Ae = () => {
|
|
3486
3508
|
if (u.kind !== "blocked-wait") return !1;
|
|
3487
3509
|
let e = u;
|
|
@@ -3525,7 +3547,7 @@ function fi(e) {
|
|
|
3525
3547
|
case "idle":
|
|
3526
3548
|
case "refreshing":
|
|
3527
3549
|
case "ended": return;
|
|
3528
|
-
default:
|
|
3550
|
+
default: di(u);
|
|
3529
3551
|
}
|
|
3530
3552
|
}, Fe = (e) => {
|
|
3531
3553
|
let t = {};
|
|
@@ -3568,7 +3590,7 @@ function fi(e) {
|
|
|
3568
3590
|
Ne(e.retry, !0, e.message), Le();
|
|
3569
3591
|
return;
|
|
3570
3592
|
case "refresh-failed":
|
|
3571
|
-
if (u.kind === "ended" || T() !== "json" || e.from !== E() && e.from !==
|
|
3593
|
+
if (u.kind === "ended" || T() !== "json" || e.from !== E() && e.from !== $r(n.getTokens()?.refresh_token)) return;
|
|
3572
3594
|
if (le(w(), void 0, "other-tab"), u.kind === "waiting") {
|
|
3573
3595
|
let t = u.pending;
|
|
3574
3596
|
u.pending = A(t.trigger), se(t, new Y(J.unavailable, { cause: e.message }), void 0);
|
|
@@ -3589,7 +3611,7 @@ function fi(e) {
|
|
|
3589
3611
|
return;
|
|
3590
3612
|
case "takeover":
|
|
3591
3613
|
case "rate-limited": return;
|
|
3592
|
-
default:
|
|
3614
|
+
default: di(e);
|
|
3593
3615
|
}
|
|
3594
3616
|
}, Le = () => {
|
|
3595
3617
|
S && !l.holding && l.post({
|
|
@@ -3654,7 +3676,7 @@ function fi(e) {
|
|
|
3654
3676
|
case "refreshing":
|
|
3655
3677
|
case "backoff":
|
|
3656
3678
|
case "blocked-wait": return M(u.pending, t);
|
|
3657
|
-
default: return
|
|
3679
|
+
default: return di(u);
|
|
3658
3680
|
}
|
|
3659
3681
|
}, ze = (e) => {
|
|
3660
3682
|
if (f) return Promise.reject(new Y(J.disposed));
|
|
@@ -3705,9 +3727,9 @@ function fi(e) {
|
|
|
3705
3727
|
}, B = async (e, t) => {
|
|
3706
3728
|
if (f) throw new Y(J.disposed);
|
|
3707
3729
|
de();
|
|
3708
|
-
let n = w() +
|
|
3730
|
+
let n = w() + _r;
|
|
3709
3731
|
if (await He(n - w()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await Ve("commit", n - w())) === "timeout") {
|
|
3710
|
-
let e = new
|
|
3732
|
+
let e = new Qr("lock-timeout");
|
|
3711
3733
|
throw P("upgrade.commit", "upgrade", e), e;
|
|
3712
3734
|
}
|
|
3713
3735
|
C = !0;
|
|
@@ -3735,11 +3757,11 @@ function fi(e) {
|
|
|
3735
3757
|
order: X(t) ?? { fp: t }
|
|
3736
3758
|
};
|
|
3737
3759
|
}
|
|
3738
|
-
let c = w();
|
|
3760
|
+
let c = w(), u = d;
|
|
3739
3761
|
t("refresh:start", {});
|
|
3740
|
-
let
|
|
3762
|
+
let f;
|
|
3741
3763
|
try {
|
|
3742
|
-
|
|
3764
|
+
f = await i.send(s ? {
|
|
3743
3765
|
tokens: s,
|
|
3744
3766
|
upgrade: e
|
|
3745
3767
|
} : { upgrade: e });
|
|
@@ -3752,9 +3774,13 @@ function fi(e) {
|
|
|
3752
3774
|
throw P("upgrade.commit", "upgrade", e), e;
|
|
3753
3775
|
}
|
|
3754
3776
|
if (!o) {
|
|
3755
|
-
|
|
3777
|
+
if (u !== d) {
|
|
3778
|
+
let e = new Qr("superseded");
|
|
3779
|
+
throw P("upgrade.commit", "upgrade", e), e;
|
|
3780
|
+
}
|
|
3781
|
+
await i.applyOpaque(f), r.setTokensCache({
|
|
3756
3782
|
...n.getTokens() ?? {},
|
|
3757
|
-
...
|
|
3783
|
+
...gi(f, void 0)
|
|
3758
3784
|
}), Ge(c);
|
|
3759
3785
|
let e = O();
|
|
3760
3786
|
return l.post(e === void 0 ? {
|
|
@@ -3766,10 +3792,10 @@ function fi(e) {
|
|
|
3766
3792
|
sub: e
|
|
3767
3793
|
}), D();
|
|
3768
3794
|
}
|
|
3769
|
-
let
|
|
3770
|
-
if (
|
|
3771
|
-
let
|
|
3772
|
-
throw P("upgrade.commit", "upgrade",
|
|
3795
|
+
let p = k.commitSave(o, gi(f, s));
|
|
3796
|
+
if (p.kind === "saved") return Ge(c), ue(o.order, c), D();
|
|
3797
|
+
let m = new Qr("superseded");
|
|
3798
|
+
throw P("upgrade.commit", "upgrade", m), p.kind === "superseded" && p.adopted && I("adopted", "other-tab"), m;
|
|
3773
3799
|
}, Ge = (e) => {
|
|
3774
3800
|
if (I("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
|
|
3775
3801
|
let t = u.pending;
|
|
@@ -3794,7 +3820,7 @@ function fi(e) {
|
|
|
3794
3820
|
commitUpgrade: B,
|
|
3795
3821
|
signOut: async (e) => {
|
|
3796
3822
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3797
|
-
let t = w() +
|
|
3823
|
+
let t = w() + vr;
|
|
3798
3824
|
qe(), await He(t - w()), qe(), l.coordinated && !l.holding && await Ve("logout", t - w());
|
|
3799
3825
|
try {
|
|
3800
3826
|
Ke(), await e(n.getTokens()?.refresh_token);
|
|
@@ -3817,6 +3843,9 @@ function fi(e) {
|
|
|
3817
3843
|
fe(u), d += 1, m = 0, h = 0, g = void 0, _ = void 0, v = void 0, b = void 0, x = void 0, ee = void 0, l.setRetryInfo(void 0), u = { kind: "idle" }, C || l.release(), e && N(e, void 0, !0);
|
|
3818
3844
|
},
|
|
3819
3845
|
identity: O,
|
|
3846
|
+
get generation() {
|
|
3847
|
+
return d;
|
|
3848
|
+
},
|
|
3820
3849
|
get coordinated() {
|
|
3821
3850
|
return l.coordinated;
|
|
3822
3851
|
},
|
|
@@ -3837,7 +3866,7 @@ function fi(e) {
|
|
|
3837
3866
|
};
|
|
3838
3867
|
}
|
|
3839
3868
|
// lib/token/verify.ts
|
|
3840
|
-
var
|
|
3869
|
+
var vi = {
|
|
3841
3870
|
ES256: {
|
|
3842
3871
|
kty: "EC",
|
|
3843
3872
|
key: (e) => ({
|
|
@@ -3868,34 +3897,34 @@ var pi = {
|
|
|
3868
3897
|
},
|
|
3869
3898
|
signature: { name: "RSASSA-PKCS1-v1_5" }
|
|
3870
3899
|
}
|
|
3871
|
-
},
|
|
3900
|
+
}, yi = (e) => {
|
|
3872
3901
|
let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = globalThis.atob(t + "=".repeat((4 - t.length % 4) % 4));
|
|
3873
3902
|
return Uint8Array.from(n, (e) => e.charCodeAt(0));
|
|
3874
|
-
},
|
|
3903
|
+
}, bi = () => {
|
|
3875
3904
|
let e = globalThis.crypto;
|
|
3876
3905
|
if (!e?.subtle) throw Error("Verifying tokens needs the Web Crypto API, available only in a secure context (https or localhost)");
|
|
3877
3906
|
return e;
|
|
3878
3907
|
};
|
|
3879
|
-
async function
|
|
3880
|
-
let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(
|
|
3908
|
+
async function xi(e, t, n, r, i) {
|
|
3909
|
+
let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(yi(a))), l = c.alg === "ES256" || c.alg === "RS256" ? vi[c.alg] : void 0;
|
|
3881
3910
|
if (!l) throw Error(`Token signing algorithm ${String(c.alg)} is not accepted`);
|
|
3882
3911
|
let u = t.find((e) => e.kid === c.kid && e.kty === l.kty && (e.kty !== "EC" || e.crv === "P-256"));
|
|
3883
3912
|
if (!u) throw Error("Token signing key is not published by the server");
|
|
3884
|
-
let d =
|
|
3885
|
-
if (!await d.verify(l.signature, f,
|
|
3913
|
+
let d = bi().subtle, f = await d.importKey("jwk", l.key(u), l.imported, !1, ["verify"]), p = new TextEncoder().encode(`${a}.${o}`);
|
|
3914
|
+
if (!await d.verify(l.signature, f, yi(s), p)) throw Error("Token signature is not valid");
|
|
3886
3915
|
let m = j(e), h = Array.isArray(m.aud) ? m.aud : [m.aud];
|
|
3887
3916
|
if (m.iss !== n) throw Error("Token issuer does not match the server");
|
|
3888
3917
|
if (!h.includes(r)) throw Error("Token is not issued for this app");
|
|
3889
3918
|
if (typeof m.exp != "number" || A(m, 0)) throw Error("Token has expired");
|
|
3890
3919
|
if (i && m.type !== i) throw Error("Token type is not valid");
|
|
3891
3920
|
}
|
|
3892
|
-
async function
|
|
3921
|
+
async function Si(t, n, r) {
|
|
3893
3922
|
if (!n) throw Error("An app id is required to accept tokens from the URL");
|
|
3894
3923
|
if (!r.access_token) throw Error("No access token received");
|
|
3895
|
-
|
|
3924
|
+
bi();
|
|
3896
3925
|
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 ?? [];
|
|
3897
3926
|
if (!s) throw Error("The server did not publish an issuer");
|
|
3898
|
-
await
|
|
3927
|
+
await xi(r.access_token, c, s, n, M.access_token), r.refresh_token && await xi(r.refresh_token, c, s, n, M.refresh_token), r.id_token && await xi(r.id_token, c, s, n);
|
|
3899
3928
|
}
|
|
3900
3929
|
// lib/upgrade/errors.ts
|
|
3901
3930
|
var Q = {
|
|
@@ -3912,18 +3941,18 @@ var Q = {
|
|
|
3912
3941
|
twoFactorNotEnabled: "error.2fa.not_enabled",
|
|
3913
3942
|
notImplemented: "error.not.implemented",
|
|
3914
3943
|
tokenInvalid: "error.api.request.token.invalid"
|
|
3915
|
-
},
|
|
3944
|
+
}, Ci = Object.freeze([
|
|
3916
3945
|
Q.twoFactorCodeInvalid,
|
|
3917
3946
|
Q.twoFactorNotEnabled,
|
|
3918
3947
|
Q.challengeInvalid,
|
|
3919
3948
|
Q.challengeSessionMismatch,
|
|
3920
3949
|
Q.challengeTooManyAttempts
|
|
3921
|
-
]),
|
|
3950
|
+
]), wi = Object.freeze([Q.tokenInvalid]), Ti = Object.freeze([
|
|
3922
3951
|
"wrong_code",
|
|
3923
3952
|
"challenge_spent",
|
|
3924
3953
|
"not_registered",
|
|
3925
3954
|
"prepare_not_required"
|
|
3926
|
-
]),
|
|
3955
|
+
]), Ei = (e) => Ti.includes(e), Di = {
|
|
3927
3956
|
wrong_code: "That code was not accepted. Try again.",
|
|
3928
3957
|
challenge_spent: "That verification challenge is no longer valid. Start again.",
|
|
3929
3958
|
exhausted: "Too many attempts. Try again later.",
|
|
@@ -3938,9 +3967,9 @@ var Q = {
|
|
|
3938
3967
|
session_changed: "The session ended during verification."
|
|
3939
3968
|
}, $ = class extends Error {
|
|
3940
3969
|
constructor(e) {
|
|
3941
|
-
super(e.message ||
|
|
3970
|
+
super(e.message || Di[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, e.retryAfter !== void 0 && (this.retryAfter = e.retryAfter), this.retryable = Ei(e.kind), e.cause !== void 0 && (this.cause = e.cause);
|
|
3942
3971
|
}
|
|
3943
|
-
},
|
|
3972
|
+
}, Oi = Object.freeze([
|
|
3944
3973
|
"upgrade_transport",
|
|
3945
3974
|
"upgrade_insufficient",
|
|
3946
3975
|
"upgrade_unavailable",
|
|
@@ -3948,14 +3977,14 @@ var Q = {
|
|
|
3948
3977
|
"upgrade_cancelled",
|
|
3949
3978
|
"upgrade_unsatisfiable",
|
|
3950
3979
|
"upgrade_sign_in_required"
|
|
3951
|
-
]),
|
|
3980
|
+
]), ki = (e) => typeof e == "object" && !!e && typeof e.code == "string" && Oi.includes(e.code), Ai = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", ji = (e) => {
|
|
3952
3981
|
let t = e?.error, n = typeof t == "string" ? t : t?.message;
|
|
3953
3982
|
if (typeof n == "string" && n && !n.startsWith("localized error:")) return n;
|
|
3954
|
-
},
|
|
3983
|
+
}, Mi = (e) => {
|
|
3955
3984
|
if (!e || typeof e != "object") return;
|
|
3956
3985
|
let t = e["retry-after"];
|
|
3957
3986
|
return typeof t == "string" && /^\d+$/.test(t.trim()) ? Number(t.trim()) : void 0;
|
|
3958
|
-
},
|
|
3987
|
+
}, Ni = (e) => {
|
|
3959
3988
|
if (typeof e != "object" || !e) return {
|
|
3960
3989
|
hasResponse: !1,
|
|
3961
3990
|
message: typeof e == "string" ? e : void 0
|
|
@@ -3966,10 +3995,10 @@ var Q = {
|
|
|
3966
3995
|
errorId: typeof t.id == "string" ? t.id : i,
|
|
3967
3996
|
message: typeof t.message == "string" ? t.message : void 0,
|
|
3968
3997
|
hasResponse: n !== void 0 || typeof t.status == "number",
|
|
3969
|
-
serverText:
|
|
3970
|
-
retryAfter:
|
|
3998
|
+
serverText: ji(n?.data),
|
|
3999
|
+
retryAfter: Mi(n?.headers)
|
|
3971
4000
|
};
|
|
3972
|
-
},
|
|
4001
|
+
}, Pi = (e, t) => {
|
|
3973
4002
|
switch (e) {
|
|
3974
4003
|
case Q.twoFactorCodeInvalid: return "wrong_code";
|
|
3975
4004
|
case Q.challengeInvalid:
|
|
@@ -3987,15 +4016,15 @@ var Q = {
|
|
|
3987
4016
|
case "error.service.unavailable": return "network";
|
|
3988
4017
|
default: return;
|
|
3989
4018
|
}
|
|
3990
|
-
},
|
|
4019
|
+
}, Fi = (e, t) => e === void 0 ? "network" : e === 501 ? "unavailable" : e === 400 ? "fatal" : e === 429 ? "rate_limited" : e === 401 || e === 403 ? t === "start" ? "challenge_spent" : "session_changed" : e >= 500 ? "network" : "fatal", Ii = (e, t) => {
|
|
3991
4020
|
if (e instanceof $) return e;
|
|
3992
|
-
let n =
|
|
4021
|
+
let n = Ni(e);
|
|
3993
4022
|
if (!n.hasResponse) return new $({
|
|
3994
4023
|
kind: "network",
|
|
3995
4024
|
message: n.message,
|
|
3996
4025
|
cause: e
|
|
3997
4026
|
});
|
|
3998
|
-
let r =
|
|
4027
|
+
let r = Pi(n.errorId, t) ?? Fi(n.status, t);
|
|
3999
4028
|
return r === "rate_limited" ? new $({
|
|
4000
4029
|
kind: r,
|
|
4001
4030
|
message: n.serverText,
|
|
@@ -4010,61 +4039,61 @@ var Q = {
|
|
|
4010
4039
|
errorId: n.errorId,
|
|
4011
4040
|
cause: e
|
|
4012
4041
|
});
|
|
4013
|
-
},
|
|
4042
|
+
}, Li = (e) => e.errorId !== void 0 && Ci.includes(e.errorId), Ri = (e) => e.errorId !== void 0 && wi.includes(e.errorId), zi = class extends Error {
|
|
4014
4043
|
constructor(e, t, n) {
|
|
4015
4044
|
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;
|
|
4016
4045
|
}
|
|
4017
|
-
},
|
|
4046
|
+
}, Bi = class extends Error {
|
|
4018
4047
|
constructor(e = "Step-up verification is not available on this deployment") {
|
|
4019
4048
|
super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
|
|
4020
4049
|
}
|
|
4021
|
-
},
|
|
4050
|
+
}, Vi = class extends Error {
|
|
4022
4051
|
constructor(e = "The session changed during verification") {
|
|
4023
4052
|
super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
|
|
4024
4053
|
}
|
|
4025
|
-
},
|
|
4054
|
+
}, Hi = (e) => {
|
|
4026
4055
|
if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
|
|
4027
4056
|
sub: e.sub,
|
|
4028
4057
|
sid: e.sid
|
|
4029
4058
|
} : { sub: e.sub };
|
|
4030
|
-
},
|
|
4059
|
+
}, Ui = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
|
|
4031
4060
|
// lib/utils/validation.ts
|
|
4032
|
-
function
|
|
4061
|
+
function Wi(e) {
|
|
4033
4062
|
if (!e || typeof e != "string") return !1;
|
|
4034
4063
|
let t = e.split(".");
|
|
4035
4064
|
if (t.length !== 3) return !1;
|
|
4036
4065
|
let n = /^[A-Za-z0-9_-]+$/;
|
|
4037
4066
|
return t.every((e) => n.test(e) && e.length > 0);
|
|
4038
4067
|
}
|
|
4039
|
-
function
|
|
4068
|
+
function Gi(e) {
|
|
4040
4069
|
return e.replace(/<[^>]*>/g, "").substring(0, 200);
|
|
4041
4070
|
}
|
|
4042
|
-
function
|
|
4071
|
+
function Ki(e) {
|
|
4043
4072
|
if (!e || typeof e != "string") return !1;
|
|
4044
4073
|
let t = e.trim();
|
|
4045
4074
|
return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
|
|
4046
4075
|
}
|
|
4047
|
-
function
|
|
4076
|
+
function qi(e) {
|
|
4048
4077
|
if (!e || typeof e != "string") return !1;
|
|
4049
4078
|
let t = e.trim();
|
|
4050
4079
|
return /^\+[1-9]\d{1,14}$/.test(t);
|
|
4051
4080
|
}
|
|
4052
|
-
function
|
|
4081
|
+
function Ji(e) {
|
|
4053
4082
|
if (!e || typeof e != "string") return !1;
|
|
4054
4083
|
let t = e.trim();
|
|
4055
4084
|
return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
|
|
4056
4085
|
}
|
|
4057
|
-
function
|
|
4086
|
+
function Yi(e, t = 6) {
|
|
4058
4087
|
return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
|
|
4059
4088
|
}
|
|
4060
|
-
function
|
|
4089
|
+
function Xi(e) {
|
|
4061
4090
|
if (!e || typeof e != "string") return null;
|
|
4062
4091
|
let t = e.toUpperCase().replace(/\s+/g, "");
|
|
4063
4092
|
return t.length > 64 || !/^[A-Z0-9-]+$/.test(t) || t.replace(/-/g, "") === "" ? null : t;
|
|
4064
4093
|
}
|
|
4065
4094
|
// lib/services/auth-service.ts
|
|
4066
|
-
var
|
|
4067
|
-
function
|
|
4095
|
+
var Zi = (e) => e ? [e] : [], Qi = "passflow_2fa_pkce", $i = 3e5, ea = "passflow_pwless_pending", ta = 3e3, na = "passflow_federated_pkce", ra = 6e5, ia = "AppId is required for federated auth";
|
|
4096
|
+
function aa(e) {
|
|
4068
4097
|
let t;
|
|
4069
4098
|
try {
|
|
4070
4099
|
t = new URL(e).protocol;
|
|
@@ -4074,7 +4103,11 @@ function ea(e) {
|
|
|
4074
4103
|
if (t !== "https:" && t !== "http:") throw Error("The federated start returned an address that is not http or https");
|
|
4075
4104
|
return e;
|
|
4076
4105
|
}
|
|
4077
|
-
|
|
4106
|
+
function oa(e) {
|
|
4107
|
+
let t = {};
|
|
4108
|
+
return e.connection_id !== void 0 && (t.connection_id = e.connection_id), e.email !== void 0 && (t.email = e.email), t;
|
|
4109
|
+
}
|
|
4110
|
+
var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is gone", la = (e, t) => new Promise((n, r) => {
|
|
4078
4111
|
if (t?.aborted) {
|
|
4079
4112
|
r(t.reason);
|
|
4080
4113
|
return;
|
|
@@ -4085,21 +4118,21 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4085
4118
|
t?.removeEventListener("abort", i), n();
|
|
4086
4119
|
}, e);
|
|
4087
4120
|
t?.addEventListener("abort", i, { once: !0 });
|
|
4088
|
-
}),
|
|
4121
|
+
}), ua = (e) => {
|
|
4089
4122
|
if (!e) return;
|
|
4090
4123
|
let t = new URLSearchParams(e.search).get("token");
|
|
4091
4124
|
if (t) return t;
|
|
4092
4125
|
let n = e.hash.indexOf("?");
|
|
4093
4126
|
return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
|
|
4094
|
-
},
|
|
4127
|
+
}, da = (e) => {
|
|
4095
4128
|
if (e) try {
|
|
4096
4129
|
return j(e).email;
|
|
4097
4130
|
} catch {
|
|
4098
4131
|
return;
|
|
4099
4132
|
}
|
|
4100
|
-
},
|
|
4101
|
-
constructor(e, t, n, r, i, a, o, s, c, l, u, d = R, f, p = { coordination:
|
|
4102
|
-
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 ce(n), this.setBffModeIfConfigured(), this.refresh =
|
|
4133
|
+
}, fa = class {
|
|
4134
|
+
constructor(e, t, n, r, i, a, o, s, c, l, u, d = R, f, p = { coordination: Ir() }, m) {
|
|
4135
|
+
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 ce(n), this.setBffModeIfConfigured(), this.refresh = _i({
|
|
4103
4136
|
emit: this.createRefreshEmit(),
|
|
4104
4137
|
storage: n,
|
|
4105
4138
|
cache: i,
|
|
@@ -4107,11 +4140,12 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4107
4140
|
coordination: p.coordination,
|
|
4108
4141
|
platform: d,
|
|
4109
4142
|
...p.strikes === void 0 ? {} : { strikes: p.strikes },
|
|
4110
|
-
logger:
|
|
4143
|
+
logger: zr()
|
|
4111
4144
|
}), this.initializeSession();
|
|
4112
4145
|
}
|
|
4113
4146
|
setAppId(e) {
|
|
4114
|
-
|
|
4147
|
+
let t = this.appId;
|
|
4148
|
+
e !== t && (this.appId = e, this.tokenDeliveryManager.reload(), this.setBffModeIfConfigured(), t && (this.refresh.sessionStarted(), this.initializeSession()));
|
|
4115
4149
|
}
|
|
4116
4150
|
setBffModeIfConfigured() {
|
|
4117
4151
|
this.tokenExchangeConfig?.enabled && this.tokenDeliveryManager.setMode(N.BFF);
|
|
@@ -4128,21 +4162,22 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4128
4162
|
}
|
|
4129
4163
|
async restoreSession() {
|
|
4130
4164
|
if (this.storageManager.holdsOnlyOtherAppSession()) return !1;
|
|
4165
|
+
let e = this.refresh.generation, t = () => this.refresh.generation !== e;
|
|
4131
4166
|
if (this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.statusUrl) try {
|
|
4132
4167
|
let e = await fetch(this.tokenExchangeConfig.statusUrl, {
|
|
4133
4168
|
method: "GET",
|
|
4134
4169
|
credentials: "include"
|
|
4135
|
-
});
|
|
4136
|
-
return e.ok &&
|
|
4170
|
+
}), n = e.ok ? await e.json() : void 0;
|
|
4171
|
+
return t() ? !1 : e.ok && n.authenticated ? (this.tokenDeliveryManager.setSessionValid(), !0) : (this.tokenDeliveryManager.setSessionInvalid(), !1);
|
|
4137
4172
|
} catch {
|
|
4138
|
-
return this.tokenDeliveryManager.setSessionInvalid(), !1;
|
|
4173
|
+
return t() || this.tokenDeliveryManager.setSessionInvalid(), !1;
|
|
4139
4174
|
}
|
|
4140
4175
|
if (!this.tokenDeliveryManager.isCookieMode()) return !1;
|
|
4141
4176
|
try {
|
|
4142
4177
|
let e = await this.authApi.validateSession();
|
|
4143
|
-
return e?.id ? (this.tokenDeliveryManager.setSessionValid(), this.subscribeStore.notify(G.SessionRestored, e), !0) : (this.tokenDeliveryManager.setSessionInvalid(), !1);
|
|
4178
|
+
return t() ? !1 : e?.id ? (this.tokenDeliveryManager.setSessionValid(), this.subscribeStore.notify(G.SessionRestored, e), !0) : (this.tokenDeliveryManager.setSessionInvalid(), !1);
|
|
4144
4179
|
} catch {
|
|
4145
|
-
return this.tokenDeliveryManager.setSessionInvalid(), !1;
|
|
4180
|
+
return t() || this.tokenDeliveryManager.setSessionInvalid(), !1;
|
|
4146
4181
|
}
|
|
4147
4182
|
}
|
|
4148
4183
|
async processAuthResponse(e, t) {
|
|
@@ -4150,8 +4185,21 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4150
4185
|
}
|
|
4151
4186
|
async applyAuthResponse(e, t, n) {
|
|
4152
4187
|
if (e.code && !e.access_token) throw Error("A PKCE authorization code was not exchanged, so there are no tokens to apply");
|
|
4188
|
+
if (this.issuedForAnotherApp(e)) throw Error("The tokens were issued for another app than the current app id, so they are not applied");
|
|
4153
4189
|
this.tokenExchangeConfig?.enabled || "token_delivery" in e && e.token_delivery && this.tokenDeliveryManager.setMode(e.token_delivery), this.tokenDeliveryManager.setSessionValid(), this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.callbackUrl && await this.forwardTokensToBFF(e), e.scopes = t, this.storageManager.saveTokens(e, this.tokenDeliveryManager.getMode(), n), this.tokenCacheService.setTokensCache(e), e.csrf_token && this.storageManager.setCsrfToken(e.csrf_token);
|
|
4154
4190
|
}
|
|
4191
|
+
issuedForAnotherApp(e) {
|
|
4192
|
+
if (!this.appId) return !1;
|
|
4193
|
+
let t = e.id_token ?? e.access_token;
|
|
4194
|
+
if (!t) return !1;
|
|
4195
|
+
let n;
|
|
4196
|
+
try {
|
|
4197
|
+
n = j(t).aud;
|
|
4198
|
+
} catch {
|
|
4199
|
+
return !1;
|
|
4200
|
+
}
|
|
4201
|
+
return n !== void 0 && !(Array.isArray(n) ? n : [n]).includes(this.appId);
|
|
4202
|
+
}
|
|
4155
4203
|
notifyRegisteredAndSignedIn(e) {
|
|
4156
4204
|
let t = {
|
|
4157
4205
|
tokens: e,
|
|
@@ -4183,7 +4231,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4183
4231
|
rememberEmailChallenge(e, t) {
|
|
4184
4232
|
this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
|
|
4185
4233
|
for (let e of this.emailChallenges.keys()) {
|
|
4186
|
-
if (this.emailChallenges.size <=
|
|
4234
|
+
if (this.emailChallenges.size <= sa) break;
|
|
4187
4235
|
this.emailChallenges.delete(e);
|
|
4188
4236
|
}
|
|
4189
4237
|
}
|
|
@@ -4191,14 +4239,14 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4191
4239
|
if (this.pendingPkce = {
|
|
4192
4240
|
verifier: e,
|
|
4193
4241
|
scopes: t,
|
|
4194
|
-
expiresAt: Date.now() +
|
|
4242
|
+
expiresAt: Date.now() + $i
|
|
4195
4243
|
}, typeof sessionStorage < "u") try {
|
|
4196
|
-
sessionStorage.setItem(
|
|
4244
|
+
sessionStorage.setItem(Qi, JSON.stringify(this.pendingPkce));
|
|
4197
4245
|
} catch {}
|
|
4198
4246
|
}
|
|
4199
4247
|
readPendingPkce() {
|
|
4200
4248
|
if (!this.pendingPkce && typeof sessionStorage < "u") try {
|
|
4201
|
-
let e = sessionStorage.getItem(
|
|
4249
|
+
let e = sessionStorage.getItem(Qi);
|
|
4202
4250
|
this.pendingPkce = e ? JSON.parse(e) : void 0;
|
|
4203
4251
|
} catch {
|
|
4204
4252
|
this.pendingPkce = void 0;
|
|
@@ -4210,17 +4258,17 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4210
4258
|
}
|
|
4211
4259
|
forgetPkceSignIn() {
|
|
4212
4260
|
if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
|
|
4213
|
-
sessionStorage.removeItem(
|
|
4261
|
+
sessionStorage.removeItem(Qi);
|
|
4214
4262
|
} catch {}
|
|
4215
4263
|
}
|
|
4216
4264
|
rememberPendingPasswordless(e) {
|
|
4217
4265
|
if (this.pendingPasswordless = e, typeof sessionStorage < "u") try {
|
|
4218
|
-
sessionStorage.setItem(
|
|
4266
|
+
sessionStorage.setItem(ea, JSON.stringify(e));
|
|
4219
4267
|
} catch {}
|
|
4220
4268
|
}
|
|
4221
4269
|
readPendingPasswordless() {
|
|
4222
4270
|
if (!this.pendingPasswordless && typeof sessionStorage < "u") try {
|
|
4223
|
-
let e = sessionStorage.getItem(
|
|
4271
|
+
let e = sessionStorage.getItem(ea);
|
|
4224
4272
|
this.pendingPasswordless = e ? JSON.parse(e) : void 0;
|
|
4225
4273
|
} catch {
|
|
4226
4274
|
this.pendingPasswordless = void 0;
|
|
@@ -4229,21 +4277,21 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4229
4277
|
}
|
|
4230
4278
|
forgetPendingPasswordless() {
|
|
4231
4279
|
if (this.pendingPasswordless = void 0, typeof sessionStorage < "u") try {
|
|
4232
|
-
sessionStorage.removeItem(
|
|
4280
|
+
sessionStorage.removeItem(ea);
|
|
4233
4281
|
} catch {}
|
|
4234
4282
|
}
|
|
4235
4283
|
rememberFederatedSlot(e, t) {
|
|
4236
4284
|
if (this.federatedSlot = {
|
|
4237
4285
|
verifier: e,
|
|
4238
4286
|
scopes: t,
|
|
4239
|
-
expiresAt: Date.now() +
|
|
4287
|
+
expiresAt: Date.now() + ra
|
|
4240
4288
|
}, typeof sessionStorage < "u") try {
|
|
4241
|
-
sessionStorage.setItem(
|
|
4289
|
+
sessionStorage.setItem(na, JSON.stringify(this.federatedSlot));
|
|
4242
4290
|
} catch {}
|
|
4243
4291
|
}
|
|
4244
4292
|
readFederatedSlot() {
|
|
4245
4293
|
if (!this.federatedSlot && typeof sessionStorage < "u") try {
|
|
4246
|
-
let e = sessionStorage.getItem(
|
|
4294
|
+
let e = sessionStorage.getItem(na);
|
|
4247
4295
|
this.federatedSlot = e ? JSON.parse(e) : void 0;
|
|
4248
4296
|
} catch {
|
|
4249
4297
|
this.federatedSlot = void 0;
|
|
@@ -4252,7 +4300,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4252
4300
|
}
|
|
4253
4301
|
forgetFederatedSlot() {
|
|
4254
4302
|
if (this.federatedSlot = void 0, typeof sessionStorage < "u") try {
|
|
4255
|
-
sessionStorage.removeItem(
|
|
4303
|
+
sessionStorage.removeItem(na);
|
|
4256
4304
|
} catch {}
|
|
4257
4305
|
}
|
|
4258
4306
|
async startPkce() {
|
|
@@ -4260,17 +4308,17 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4260
4308
|
try {
|
|
4261
4309
|
e = await this.readPkceEnabled?.() ?? !1;
|
|
4262
4310
|
} catch (e) {
|
|
4263
|
-
|
|
4311
|
+
zr().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
|
|
4264
4312
|
return;
|
|
4265
4313
|
}
|
|
4266
|
-
return e ?
|
|
4314
|
+
return e ? wn() : void 0;
|
|
4267
4315
|
}
|
|
4268
4316
|
async exchangeCode(e, t) {
|
|
4269
4317
|
return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
|
|
4270
4318
|
}
|
|
4271
4319
|
async completePkceSignIn(e) {
|
|
4272
4320
|
let t = this.readPendingPkce();
|
|
4273
|
-
if (!t) throw Error(
|
|
4321
|
+
if (!t) throw Error(ca);
|
|
4274
4322
|
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
4275
4323
|
return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
|
|
4276
4324
|
}
|
|
@@ -4300,7 +4348,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4300
4348
|
if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
|
|
4301
4349
|
}
|
|
4302
4350
|
async signIn(e, t) {
|
|
4303
|
-
if ("email" in e && e.email && !
|
|
4351
|
+
if ("email" in e && e.email && !Ki(e.email)) {
|
|
4304
4352
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4305
4353
|
operation: "sign-in",
|
|
4306
4354
|
message: "Invalid email format",
|
|
@@ -4309,7 +4357,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4309
4357
|
};
|
|
4310
4358
|
throw W(this.subscribeStore, t), e;
|
|
4311
4359
|
}
|
|
4312
|
-
if ("username" in e && e.username && !
|
|
4360
|
+
if ("username" in e && e.username && !Ji(e.username)) {
|
|
4313
4361
|
let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
|
|
4314
4362
|
operation: "sign-in",
|
|
4315
4363
|
message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
|
|
@@ -4318,7 +4366,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4318
4366
|
};
|
|
4319
4367
|
throw W(this.subscribeStore, t), e;
|
|
4320
4368
|
}
|
|
4321
|
-
if ("phone" in e && e.phone && !
|
|
4369
|
+
if ("phone" in e && e.phone && !qi(e.phone)) {
|
|
4322
4370
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4323
4371
|
operation: "sign-in",
|
|
4324
4372
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4328,13 +4376,13 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4328
4376
|
throw W(this.subscribeStore, t), e;
|
|
4329
4377
|
}
|
|
4330
4378
|
this.subscribeStore.notify(G.SignInStart, { email: e.email });
|
|
4331
|
-
let n = this.deviceService.getDeviceId(), r =
|
|
4379
|
+
let n = this.deviceService.getDeviceId(), r = ct(this.platform.getDeviceType());
|
|
4332
4380
|
e.scopes = e.scopes ?? this.scopes;
|
|
4333
4381
|
try {
|
|
4334
4382
|
let i = await this.startPkce(), a = await this.authApi.signIn(i ? {
|
|
4335
4383
|
...e,
|
|
4336
4384
|
code_challenge: i.challenge
|
|
4337
|
-
} : e, n, r, ...
|
|
4385
|
+
} : e, n, r, ...Zi(t));
|
|
4338
4386
|
if (this.handleEmailVerificationStep(a, "sign-in", e.email, i, e.scopes) || this.handlePendingSecondFactor(a, e.email, i, e.scopes)) return a;
|
|
4339
4387
|
let o = await this.exchangeCode(a, i);
|
|
4340
4388
|
return this.handlePendingSecondFactor(o, e.email) || (await this.processAuthResponse(o, e.scopes), this.subscribeStore.notify(G.SignIn, {
|
|
@@ -4352,7 +4400,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4352
4400
|
}
|
|
4353
4401
|
}
|
|
4354
4402
|
async signUp(e, t) {
|
|
4355
|
-
if (e.user.email && !
|
|
4403
|
+
if (e.user.email && !Ki(e.user.email)) {
|
|
4356
4404
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4357
4405
|
operation: "sign-up",
|
|
4358
4406
|
message: "Invalid email format",
|
|
@@ -4361,7 +4409,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4361
4409
|
};
|
|
4362
4410
|
throw W(this.subscribeStore, t), e;
|
|
4363
4411
|
}
|
|
4364
|
-
if (e.user.phone_number && !
|
|
4412
|
+
if (e.user.phone_number && !qi(e.user.phone_number)) {
|
|
4365
4413
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4366
4414
|
operation: "sign-up",
|
|
4367
4415
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4375,7 +4423,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4375
4423
|
let n = await this.startPkce(), r = await this.authApi.signUp(n ? {
|
|
4376
4424
|
...e,
|
|
4377
4425
|
code_challenge: n.challenge
|
|
4378
|
-
} : e, ...
|
|
4426
|
+
} : e, ...Zi(t));
|
|
4379
4427
|
if (this.handleEmailVerificationStep(r, "sign-up", e.user.email, n, e.scopes) || this.handlePendingSecondFactor(r, e.user.email, n, e.scopes)) return r;
|
|
4380
4428
|
let i = await this.exchangeCode(r, n);
|
|
4381
4429
|
return this.handlePendingSecondFactor(i, e.user.email) || (await this.processAuthResponse(i, e.scopes), this.notifyRegisteredAndSignedIn(i), await this.submitSessionCheck()), i;
|
|
@@ -4390,7 +4438,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4390
4438
|
}
|
|
4391
4439
|
}
|
|
4392
4440
|
async passwordlessSignIn(e, t) {
|
|
4393
|
-
if (e.email && !
|
|
4441
|
+
if (e.email && !Ki(e.email)) {
|
|
4394
4442
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4395
4443
|
operation: "passwordless.start",
|
|
4396
4444
|
message: "Invalid email format",
|
|
@@ -4399,7 +4447,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4399
4447
|
};
|
|
4400
4448
|
throw W(this.subscribeStore, t), e;
|
|
4401
4449
|
}
|
|
4402
|
-
if (e.phone && !
|
|
4450
|
+
if (e.phone && !qi(e.phone)) {
|
|
4403
4451
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4404
4452
|
operation: "passwordless.start",
|
|
4405
4453
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4409,13 +4457,13 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4409
4457
|
throw W(this.subscribeStore, t), e;
|
|
4410
4458
|
}
|
|
4411
4459
|
this.subscribeStore.notify(G.SignInStart, { email: e.email });
|
|
4412
|
-
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId(), i =
|
|
4460
|
+
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId(), i = ct(this.platform.getDeviceType());
|
|
4413
4461
|
try {
|
|
4414
4462
|
let a = await this.startPkce(), o = await this.authApi.passwordlessSignIn({
|
|
4415
4463
|
...e,
|
|
4416
4464
|
scopes: n,
|
|
4417
4465
|
...a ? { code_challenge: a.challenge } : {}
|
|
4418
|
-
}, r, i, ...
|
|
4466
|
+
}, r, i, ...Zi(t));
|
|
4419
4467
|
return a && o.challenge_id ? this.rememberPendingPasswordless({
|
|
4420
4468
|
challengeId: o.challenge_id,
|
|
4421
4469
|
verifier: a.verifier,
|
|
@@ -4439,11 +4487,11 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4439
4487
|
this.subscribeStore.notify(G.SignInStart, {}), e.scopes = e.scopes ?? this.scopes, e.device = this.deviceService.getDeviceId();
|
|
4440
4488
|
let n = this.readPendingPasswordless(), r = n?.challengeId === e.challenge_id ? n : void 0, i = !1;
|
|
4441
4489
|
try {
|
|
4442
|
-
let n = await this.authApi.passwordlessSignInComplete(e, ...
|
|
4490
|
+
let n = await this.authApi.passwordlessSignInComplete(e, ...Zi(t));
|
|
4443
4491
|
if (i = !0, this.handlePendingSecondFactor(n, r?.email, r && { verifier: r.verifier }, r?.scopes)) return this.forgetPendingPasswordless(), n;
|
|
4444
4492
|
let a = n;
|
|
4445
4493
|
if (n.code) {
|
|
4446
|
-
if (!r) throw Error(
|
|
4494
|
+
if (!r) throw Error(ca);
|
|
4447
4495
|
if (a = await this.authApi.pkceExchange(n.code, r.verifier), this.handlePendingSecondFactor(a)) return this.forgetPendingPasswordless(), {
|
|
4448
4496
|
...a,
|
|
4449
4497
|
redirect_url: n.redirect_url ?? ""
|
|
@@ -4475,11 +4523,11 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4475
4523
|
let n = t?.signal;
|
|
4476
4524
|
try {
|
|
4477
4525
|
let t = this.readPendingPasswordless();
|
|
4478
|
-
if (t?.challengeId !== e) throw Error(
|
|
4526
|
+
if (t?.challengeId !== e) throw Error(ca);
|
|
4479
4527
|
for (;;) {
|
|
4480
4528
|
if (n?.aborted) throw n.reason;
|
|
4481
4529
|
if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
|
|
4482
|
-
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(
|
|
4530
|
+
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(ca);
|
|
4483
4531
|
let r;
|
|
4484
4532
|
try {
|
|
4485
4533
|
r = await this.authApi.passwordlessStatus({
|
|
@@ -4497,7 +4545,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4497
4545
|
status: "signed-in",
|
|
4498
4546
|
tokens: { redirect_url: r.redirect_url }
|
|
4499
4547
|
};
|
|
4500
|
-
await
|
|
4548
|
+
await la(ta, n);
|
|
4501
4549
|
}
|
|
4502
4550
|
} catch (e) {
|
|
4503
4551
|
if (n?.aborted && e === n.reason) throw e;
|
|
@@ -4566,14 +4614,14 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4566
4614
|
let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
|
|
4567
4615
|
try {
|
|
4568
4616
|
let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
|
|
4569
|
-
if (t?.pkce && !r) throw Error(
|
|
4617
|
+
if (t?.pkce && !r) throw Error(ca);
|
|
4570
4618
|
let i = await this.authApi.validateEmailCode(e);
|
|
4571
4619
|
this.emailChallenges.delete(e.challenge_id);
|
|
4572
4620
|
let a = r?.scopes ?? t?.scopes ?? this.scopes;
|
|
4573
4621
|
if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
|
|
4574
4622
|
let o = i;
|
|
4575
4623
|
if (i.code) {
|
|
4576
|
-
if (!r) throw Error(
|
|
4624
|
+
if (!r) throw Error(ca);
|
|
4577
4625
|
if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
|
|
4578
4626
|
}
|
|
4579
4627
|
let s = i.redirect_url ? {
|
|
@@ -4635,13 +4683,13 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4635
4683
|
readSessionPin() {
|
|
4636
4684
|
try {
|
|
4637
4685
|
let e = this.storageManager.getToken(M.access_token);
|
|
4638
|
-
return e ?
|
|
4686
|
+
return e ? Hi(j(e)) : void 0;
|
|
4639
4687
|
} catch {
|
|
4640
4688
|
return;
|
|
4641
4689
|
}
|
|
4642
4690
|
}
|
|
4643
4691
|
assertSessionPin(e) {
|
|
4644
|
-
if (e && !
|
|
4692
|
+
if (e && !Ui(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 Vi("The session changed during verification, so the elevated tokens were discarded");
|
|
4645
4693
|
}
|
|
4646
4694
|
refreshMode() {
|
|
4647
4695
|
return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
|
|
@@ -4689,7 +4737,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4689
4737
|
case "signout":
|
|
4690
4738
|
n.notify(G.SignOut, t);
|
|
4691
4739
|
return;
|
|
4692
|
-
default:
|
|
4740
|
+
default: zr().warn(`[passflow] Unknown refresh event: ${String(e)}`);
|
|
4693
4741
|
}
|
|
4694
4742
|
};
|
|
4695
4743
|
}
|
|
@@ -4762,7 +4810,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4762
4810
|
}
|
|
4763
4811
|
async sendPasswordResetEmail(e, t) {
|
|
4764
4812
|
try {
|
|
4765
|
-
return await this.authApi.sendPasswordResetEmail(e, ...
|
|
4813
|
+
return await this.authApi.sendPasswordResetEmail(e, ...Zi(t));
|
|
4766
4814
|
} catch (e) {
|
|
4767
4815
|
let t = {
|
|
4768
4816
|
operation: "password-reset.send",
|
|
@@ -4775,10 +4823,10 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4775
4823
|
}
|
|
4776
4824
|
async resetPassword(e, t, n) {
|
|
4777
4825
|
this.subscribeStore.notify(G.SignInStart, {});
|
|
4778
|
-
let r = n ??
|
|
4826
|
+
let r = n ?? ua(this.platform.getCurrentUrl()), i = t ?? this.scopes;
|
|
4779
4827
|
try {
|
|
4780
4828
|
let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
|
|
4781
|
-
if (this.handleEmailVerificationStep(n, "reset-password",
|
|
4829
|
+
if (this.handleEmailVerificationStep(n, "reset-password", da(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
|
|
4782
4830
|
let a = await this.exchangeCode(n, t);
|
|
4783
4831
|
if (this.handlePendingSecondFactor(a)) return a;
|
|
4784
4832
|
let o = n.redirect_url ? {
|
|
@@ -4802,17 +4850,17 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4802
4850
|
async passkeyRegister(e, t) {
|
|
4803
4851
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4804
4852
|
this.subscribeStore.notify(G.RegisterStart, {});
|
|
4805
|
-
let n = this.deviceService.getDeviceId(), r =
|
|
4853
|
+
let n = this.deviceService.getDeviceId(), r = ct(this.platform.getDeviceType());
|
|
4806
4854
|
e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
4807
4855
|
try {
|
|
4808
4856
|
let i = await this.startPkce(), { challenge_id: a, publicKey: o } = await this.authApi.passkeyRegisterStart(i ? {
|
|
4809
4857
|
...e,
|
|
4810
4858
|
code_challenge: i.challenge
|
|
4811
|
-
} : e, n, r, !this.appId, ...
|
|
4859
|
+
} : e, n, r, !this.appId, ...Zi(t));
|
|
4812
4860
|
o.user.id = this.platform.btoa(o.user.id);
|
|
4813
4861
|
let s = await this.platform.passkeys.startRegistration(o);
|
|
4814
4862
|
if (!s) throw Error("Passkey registration was not completed");
|
|
4815
|
-
let c = await this.authApi.passkeyRegisterComplete(s, n, a, !this.appId, ...
|
|
4863
|
+
let c = await this.authApi.passkeyRegisterComplete(s, n, a, !this.appId, ...Zi(t));
|
|
4816
4864
|
if (this.handlePendingSecondFactor(c, void 0, i, e.scopes)) return c;
|
|
4817
4865
|
let l = await this.exchangeCode(c, i);
|
|
4818
4866
|
return this.handlePendingSecondFactor(l) || (await this.processAuthResponse(l, e.scopes), this.notifyRegisteredAndSignedIn(l), await this.submitSessionCheck()), l;
|
|
@@ -4829,15 +4877,15 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4829
4877
|
async passkeyAuthenticate(e, t) {
|
|
4830
4878
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4831
4879
|
this.subscribeStore.notify(G.SignInStart, {});
|
|
4832
|
-
let n = this.deviceService.getDeviceId(), r =
|
|
4880
|
+
let n = this.deviceService.getDeviceId(), r = ct(this.platform.getDeviceType());
|
|
4833
4881
|
e.scopes = e.scopes ?? this.scopes;
|
|
4834
4882
|
try {
|
|
4835
4883
|
let i = await this.startPkce(), { challenge_id: a, publicKey: o } = await this.authApi.passkeyAuthenticateStart(i ? {
|
|
4836
4884
|
...e,
|
|
4837
4885
|
code_challenge: i.challenge
|
|
4838
|
-
} : e, n, r, !this.appId, ...
|
|
4886
|
+
} : e, n, r, !this.appId, ...Zi(t)), s = await this.platform.passkeys.startAuthentication(o);
|
|
4839
4887
|
if (!s) throw Error("Passkey authentication was not completed");
|
|
4840
|
-
let c = await this.authApi.passkeyAuthenticateComplete(s, n, a, !this.appId, ...
|
|
4888
|
+
let c = await this.authApi.passkeyAuthenticateComplete(s, n, a, !this.appId, ...Zi(t));
|
|
4841
4889
|
if (this.handlePendingSecondFactor(c, void 0, i, e.scopes)) return c;
|
|
4842
4890
|
let l = await this.exchangeCode(c, i);
|
|
4843
4891
|
return this.handlePendingSecondFactor(l) || "access_token" in l && (await this.processAuthResponse(l, e.scopes), this.subscribeStore.notify(G.SignIn, {
|
|
@@ -4876,12 +4924,15 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4876
4924
|
};
|
|
4877
4925
|
}
|
|
4878
4926
|
createFederatedAuthUrl(e) {
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4927
|
+
if (!this.appId) throw Error(ia);
|
|
4928
|
+
let t = new URL(`/auth/federated/start/${e.provider}`, this.url);
|
|
4929
|
+
return t.search = new URLSearchParams(this.federatedStartQuery(e, e.scopes ?? this.scopes, this.appId)).toString(), t.toString();
|
|
4930
|
+
}
|
|
4931
|
+
federatedStartQuery(e, t, n) {
|
|
4932
|
+
return {
|
|
4933
|
+
scopes: t.join(" "),
|
|
4883
4934
|
redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
|
|
4884
|
-
appId:
|
|
4935
|
+
appId: n,
|
|
4885
4936
|
...e.invite_token ? { invite_token: e.invite_token } : {},
|
|
4886
4937
|
...e.create_tenant ? { create_tenant: e.create_tenant.toString() } : {},
|
|
4887
4938
|
...e.device ? { device: e.device } : {},
|
|
@@ -4889,11 +4940,31 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4889
4940
|
...e.code_challenge_method ? { code_challenge_method: e.code_challenge_method } : {},
|
|
4890
4941
|
...e.state ? { state: e.state } : {},
|
|
4891
4942
|
...e.parent_challenge_id ? { parent_challenge_id: e.parent_challenge_id } : {}
|
|
4892
|
-
}
|
|
4893
|
-
|
|
4943
|
+
};
|
|
4944
|
+
}
|
|
4945
|
+
createEnterpriseAuthUrl(e) {
|
|
4946
|
+
if (!this.appId) throw Error(ia);
|
|
4947
|
+
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId(), r = new URL(z.enterpriseStart, this.url);
|
|
4948
|
+
return r.search = new URLSearchParams({
|
|
4949
|
+
...oa(e),
|
|
4950
|
+
...this.federatedStartQuery({
|
|
4951
|
+
...e,
|
|
4952
|
+
device: n
|
|
4953
|
+
}, t, this.appId)
|
|
4954
|
+
}).toString(), r.toString();
|
|
4955
|
+
}
|
|
4956
|
+
async enterpriseStart(e, t) {
|
|
4957
|
+
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
|
|
4958
|
+
return { auth_url: aa((await this.authApi.enterpriseStart({
|
|
4959
|
+
...oa(e),
|
|
4960
|
+
...this.federatedStartBody({
|
|
4961
|
+
...e,
|
|
4962
|
+
device: r
|
|
4963
|
+
}, n)
|
|
4964
|
+
}, t)).auth_url) };
|
|
4894
4965
|
}
|
|
4895
4966
|
async federatedAuthWithPopup(e, t) {
|
|
4896
|
-
if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(
|
|
4967
|
+
if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(ia);
|
|
4897
4968
|
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
|
|
4898
4969
|
try {
|
|
4899
4970
|
this.forgetFederatedSlot();
|
|
@@ -4911,7 +4982,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4911
4982
|
} : {}
|
|
4912
4983
|
};
|
|
4913
4984
|
return {
|
|
4914
|
-
url: await this.usesFederatedPost(t) ?
|
|
4985
|
+
url: await this.usesFederatedPost(t) ? aa((await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url) : this.createFederatedAuthUrl(a),
|
|
4915
4986
|
pkce: i
|
|
4916
4987
|
};
|
|
4917
4988
|
})(), o, s = (e) => {
|
|
@@ -4933,11 +5004,11 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4933
5004
|
scopes: n
|
|
4934
5005
|
};
|
|
4935
5006
|
if (o) {
|
|
4936
|
-
if (!f) throw
|
|
5007
|
+
if (!f) throw kn();
|
|
4937
5008
|
if (_ = await this.authApi.pkceExchange(f, o.verifier), this.handlePendingSecondFactor(_)) return;
|
|
4938
5009
|
} else {
|
|
4939
|
-
if (!await this.isSimpleModeApp()) throw
|
|
4940
|
-
await
|
|
5010
|
+
if (!await this.isSimpleModeApp()) throw kn();
|
|
5011
|
+
await Si(this.url, this.appId, _);
|
|
4941
5012
|
}
|
|
4942
5013
|
await this.processAuthResponse(_, n), this.subscribeStore.notify(G.SignIn, {
|
|
4943
5014
|
tokens: _,
|
|
@@ -4963,7 +5034,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4963
5034
|
}
|
|
4964
5035
|
}
|
|
4965
5036
|
federatedAuthWithRedirect(e, t) {
|
|
4966
|
-
if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(
|
|
5037
|
+
if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(ia);
|
|
4967
5038
|
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
|
|
4968
5039
|
this.startPkce().then(async (i) => {
|
|
4969
5040
|
let a = {
|
|
@@ -4974,7 +5045,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4974
5045
|
code_challenge: i.challenge,
|
|
4975
5046
|
code_challenge_method: "S256"
|
|
4976
5047
|
} : {}
|
|
4977
|
-
}, o = await this.usesFederatedPost(t) ?
|
|
5048
|
+
}, o = await this.usesFederatedPost(t) ? aa((await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url) : this.createFederatedAuthUrl(a);
|
|
4978
5049
|
i ? this.rememberFederatedSlot(i.verifier, n) : this.forgetFederatedSlot(), this.platform.navigateTo(o);
|
|
4979
5050
|
}).catch((e) => this.reportFederatedRedirectFailure(e));
|
|
4980
5051
|
}
|
|
@@ -5027,7 +5098,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5027
5098
|
async authRedirect(e = {}) {
|
|
5028
5099
|
try {
|
|
5029
5100
|
let { url: t, appId: n, redirectUrl: r, scopes: i, state: a } = e;
|
|
5030
|
-
if (t !== void 0 &&
|
|
5101
|
+
if (t !== void 0 && Mn(t) !== Mn(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");
|
|
5031
5102
|
let o = await this.readAppSettings?.();
|
|
5032
5103
|
if (o?.pkce_enabled !== !0) {
|
|
5033
5104
|
let e = this.authRedirectUrl({
|
|
@@ -5037,8 +5108,8 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5037
5108
|
this.platform.navigateTo(a ? `${e}&${new URLSearchParams({ state: a })}` : e);
|
|
5038
5109
|
return;
|
|
5039
5110
|
}
|
|
5040
|
-
if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT",
|
|
5041
|
-
let s = this.platform.getCurrentUrl(), c = await
|
|
5111
|
+
if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT", Dn(o.type));
|
|
5112
|
+
let s = this.platform.getCurrentUrl(), c = await Pn({
|
|
5042
5113
|
url: this.url,
|
|
5043
5114
|
clientId: this.appId ?? "",
|
|
5044
5115
|
redirectUri: r ?? (s ? s.origin + s.pathname : ""),
|
|
@@ -5059,9 +5130,9 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5059
5130
|
if (!this.appId) return !1;
|
|
5060
5131
|
let t = new URLSearchParams(e.search), n = t.get("code"), r = t.get("state"), i = t.get("error"), a = t.get("error_description");
|
|
5061
5132
|
if (t.get("user_state") || r === null || !n && !i) return !1;
|
|
5062
|
-
let o =
|
|
5133
|
+
let o = In();
|
|
5063
5134
|
if (o.status === "none") return !1;
|
|
5064
|
-
|
|
5135
|
+
Ln();
|
|
5065
5136
|
for (let e of [
|
|
5066
5137
|
"code",
|
|
5067
5138
|
"state",
|
|
@@ -5073,9 +5144,9 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5073
5144
|
return this.platform.replaceUrl(e.pathname + (s ? `?${s}` : "") + e.hash), this.finishOidcLanding(async () => {
|
|
5074
5145
|
if (o.status === "unusable") throw new U("VERIFIER_MISSING", "This sign-in has expired or its proof key is gone. Sign in again.");
|
|
5075
5146
|
if (o.slot.state !== r) throw new U("STATE_MISMATCH", "The sign-in answer does not belong to this sign-in. Sign in again.");
|
|
5076
|
-
if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED",
|
|
5147
|
+
if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED", Gi(a || i || "Sign in again."));
|
|
5077
5148
|
return {
|
|
5078
|
-
tokens: await
|
|
5149
|
+
tokens: await zn(this.url, n, o.slot),
|
|
5079
5150
|
scopes: o.slot.scopes,
|
|
5080
5151
|
returnUrl: o.slot.redirectUri
|
|
5081
5152
|
};
|
|
@@ -5164,7 +5235,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5164
5235
|
return;
|
|
5165
5236
|
}
|
|
5166
5237
|
}
|
|
5167
|
-
},
|
|
5238
|
+
}, pa = class {
|
|
5168
5239
|
constructor(e) {
|
|
5169
5240
|
this.invitationApi = e;
|
|
5170
5241
|
}
|
|
@@ -5183,7 +5254,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5183
5254
|
getInvitationLink(e) {
|
|
5184
5255
|
return this.invitationApi.getInvitationLink(e);
|
|
5185
5256
|
}
|
|
5186
|
-
},
|
|
5257
|
+
}, ma = class {
|
|
5187
5258
|
constructor(e) {
|
|
5188
5259
|
this.data = this.normalize(e);
|
|
5189
5260
|
}
|
|
@@ -5240,9 +5311,9 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5240
5311
|
getData() {
|
|
5241
5312
|
return this.data;
|
|
5242
5313
|
}
|
|
5243
|
-
},
|
|
5314
|
+
}, ha = class {
|
|
5244
5315
|
constructor(e, t, n) {
|
|
5245
|
-
this.tenantApi = e, this.scopes = t, this.logger = n ||
|
|
5316
|
+
this.tenantApi = e, this.scopes = t, this.logger = n || zr();
|
|
5246
5317
|
}
|
|
5247
5318
|
handlePassflowError(t, n) {
|
|
5248
5319
|
if (e.isAxiosError(t) && t.response?.data) {
|
|
@@ -5278,7 +5349,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5278
5349
|
}
|
|
5279
5350
|
async getTenantUserMembership(e) {
|
|
5280
5351
|
try {
|
|
5281
|
-
return new
|
|
5352
|
+
return new ma(await this.tenantApi.getTenantDetails(e));
|
|
5282
5353
|
} catch (t) {
|
|
5283
5354
|
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
5284
5355
|
}
|
|
@@ -5423,7 +5494,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5423
5494
|
this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
|
|
5424
5495
|
}
|
|
5425
5496
|
}
|
|
5426
|
-
},
|
|
5497
|
+
}, ga = class {
|
|
5427
5498
|
constructor(e, t, n, r = R) {
|
|
5428
5499
|
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();
|
|
5429
5500
|
}
|
|
@@ -5503,7 +5574,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5503
5574
|
isExpired() {
|
|
5504
5575
|
return this.tokensCache ? this.tokensCache.access_token ? A(j(this.tokensCache.access_token)) : !1 : !0;
|
|
5505
5576
|
}
|
|
5506
|
-
},
|
|
5577
|
+
}, _a = class {
|
|
5507
5578
|
constructor(e, t, n) {
|
|
5508
5579
|
this.twoFactorApi = e, this.subscribeStore = t, this.signInCompleter = n, this.PARTIAL_AUTH_TIMEOUT_MS = 3e5, this.SESSION_STORAGE_KEY = "passflow_2fa_challenge", this.subscribeStore.subscribe({ onAuthChange: (e, t) => {
|
|
5509
5580
|
if (e === G.TwoFactorRequired) {
|
|
@@ -5583,8 +5654,8 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5583
5654
|
assertTotpCode(e) {
|
|
5584
5655
|
let t = this.totpDigits;
|
|
5585
5656
|
if (t) {
|
|
5586
|
-
if (!
|
|
5587
|
-
} else if (!
|
|
5657
|
+
if (!Yi(e, t)) throw Error(`Invalid TOTP code format. Code must be exactly ${t} digits.`);
|
|
5658
|
+
} else if (!Yi(e, 6) && !Yi(e, 8)) throw Error("Invalid TOTP code format. Code must be 6 or 8 digits.");
|
|
5588
5659
|
}
|
|
5589
5660
|
requirePendingTfaToken() {
|
|
5590
5661
|
let e = this.pendingTfaToken();
|
|
@@ -5622,7 +5693,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5622
5693
|
}
|
|
5623
5694
|
async useRecoveryCode(e, t) {
|
|
5624
5695
|
try {
|
|
5625
|
-
let n =
|
|
5696
|
+
let n = Xi(e);
|
|
5626
5697
|
if (!n) throw Error("Invalid recovery code format. Expected letters, digits and dashes, such as XXXX-XXXX-XXXX.");
|
|
5627
5698
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
5628
5699
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
@@ -5834,7 +5905,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5834
5905
|
this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
|
|
5835
5906
|
}
|
|
5836
5907
|
}
|
|
5837
|
-
},
|
|
5908
|
+
}, va = class {
|
|
5838
5909
|
constructor(e, t, n = R) {
|
|
5839
5910
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
5840
5911
|
}
|
|
@@ -5849,7 +5920,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5849
5920
|
}
|
|
5850
5921
|
async addUserPasskey({ relyingPartyId: e, passkeyUsername: t, passkeyDisplayName: n } = {}) {
|
|
5851
5922
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
5852
|
-
let r = this.deviceService.getDeviceId(), i =
|
|
5923
|
+
let r = this.deviceService.getDeviceId(), i = ct(this.platform.getDeviceType()), { challenge_id: a, publicKey: o } = await this.userAPI.addUserPasskeyStart({
|
|
5853
5924
|
relyingPartyId: (e || this.platform.getCurrentUrl()?.hostname) ?? "",
|
|
5854
5925
|
deviceId: r,
|
|
5855
5926
|
os: i,
|
|
@@ -5870,77 +5941,77 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5870
5941
|
signOutOtherSessions() {
|
|
5871
5942
|
return this.userAPI.revokeOtherUserSessions();
|
|
5872
5943
|
}
|
|
5873
|
-
},
|
|
5944
|
+
}, ya = class extends Error {
|
|
5874
5945
|
constructor(e, t, n = !1) {
|
|
5875
5946
|
super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
|
|
5876
5947
|
}
|
|
5877
|
-
},
|
|
5948
|
+
}, ba = (e, t) => {
|
|
5878
5949
|
let n = t?.trim();
|
|
5879
|
-
if (!n) throw new
|
|
5950
|
+
if (!n) throw new ya(e, "A verification code is required");
|
|
5880
5951
|
return n;
|
|
5881
|
-
},
|
|
5952
|
+
}, xa = {
|
|
5882
5953
|
type: "totp",
|
|
5883
5954
|
requiresPrepare: !1,
|
|
5884
5955
|
input: "code",
|
|
5885
|
-
assert: async ({ code: e }) => ({ code:
|
|
5886
|
-
},
|
|
5956
|
+
assert: async ({ code: e }) => ({ code: ba("totp", e) })
|
|
5957
|
+
}, Sa = {
|
|
5887
5958
|
type: "recovery_codes",
|
|
5888
5959
|
requiresPrepare: !1,
|
|
5889
5960
|
input: "code",
|
|
5890
|
-
assert: async ({ code: e }) => ({ code:
|
|
5891
|
-
},
|
|
5961
|
+
assert: async ({ code: e }) => ({ code: ba("recovery_codes", e) })
|
|
5962
|
+
}, Ca = {
|
|
5892
5963
|
type: "passkey",
|
|
5893
5964
|
requiresPrepare: !0,
|
|
5894
5965
|
input: "none",
|
|
5895
5966
|
assert: async ({ prepared: e, platform: t }) => {
|
|
5896
|
-
if (!e?.webauthn) throw new
|
|
5967
|
+
if (!e?.webauthn) throw new ya("passkey", "The upgrade challenge carried no WebAuthn options");
|
|
5897
5968
|
let n = t.passkeys;
|
|
5898
|
-
if (!n) throw new
|
|
5969
|
+
if (!n) throw new ya("passkey", "This platform does not support passkeys");
|
|
5899
5970
|
let r;
|
|
5900
5971
|
try {
|
|
5901
5972
|
r = await n.startAuthentication(e.webauthn);
|
|
5902
5973
|
} catch (e) {
|
|
5903
|
-
throw new
|
|
5974
|
+
throw new ya("passkey", e?.message || "Passkey verification was cancelled", !0);
|
|
5904
5975
|
}
|
|
5905
|
-
if (!r) throw new
|
|
5976
|
+
if (!r) throw new ya("passkey", "Passkey verification was cancelled", !0);
|
|
5906
5977
|
return {
|
|
5907
5978
|
challenge_id: e.challengeId,
|
|
5908
5979
|
credential: r
|
|
5909
5980
|
};
|
|
5910
5981
|
}
|
|
5911
|
-
},
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
]),
|
|
5982
|
+
}, wa = Object.freeze([
|
|
5983
|
+
xa,
|
|
5984
|
+
Ca,
|
|
5985
|
+
Sa
|
|
5986
|
+
]), Ta = (e = wa) => new Map(e.map((e) => [e.type, e])), Ea = 3, Da = {
|
|
5916
5987
|
totp: 0,
|
|
5917
5988
|
passkey: 1,
|
|
5918
5989
|
email_otp: 2,
|
|
5919
5990
|
sms_otp: 3,
|
|
5920
5991
|
recovery_codes: 9
|
|
5921
|
-
},
|
|
5922
|
-
let n =
|
|
5992
|
+
}, Oa = (e) => e.requiredLevel ?? _e(e.acrValues), ka = (e, t) => {
|
|
5993
|
+
let n = Da[e.type] ?? 5, r = t !== void 0 && t >= Ea, i = e.type === "passkey";
|
|
5923
5994
|
return (r && !i ? 100 : 0) + n;
|
|
5924
|
-
},
|
|
5995
|
+
}, Aa = (e, t) => {
|
|
5925
5996
|
if (t.availableFactors) return t.availableFactors.flatMap((t) => e.find((e) => e.type === t) ?? []);
|
|
5926
|
-
let n =
|
|
5927
|
-
return [...e].sort((e, t) =>
|
|
5928
|
-
},
|
|
5997
|
+
let n = Oa(t);
|
|
5998
|
+
return [...e].sort((e, t) => ka(e, n) - ka(t, n));
|
|
5999
|
+
}, ja = class extends Error {
|
|
5929
6000
|
constructor(e) {
|
|
5930
6001
|
super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
|
|
5931
6002
|
}
|
|
5932
|
-
},
|
|
6003
|
+
}, Ma = class extends Error {
|
|
5933
6004
|
constructor(e = "Only a fresh sign-in can meet this challenge") {
|
|
5934
6005
|
super(e), this.code = "upgrade_sign_in_required", this.name = "UpgradeSignInRequiredError";
|
|
5935
6006
|
}
|
|
5936
|
-
},
|
|
5937
|
-
if (
|
|
5938
|
-
if (
|
|
5939
|
-
},
|
|
6007
|
+
}, Na = (e) => e?.signInRequired === !0 || e?.signInRequired === void 0 && e?.availableFactors?.length === 0, Pa = (e) => e?.signInRequired === !1 && e.availableFactors?.length === 0, Fa = "This account has no factor that reaches the required level (it may need a device-bound passkey)", Ia = (e) => {
|
|
6008
|
+
if (Na(e)) return new Ma();
|
|
6009
|
+
if (Pa(e)) return new La(Fa);
|
|
6010
|
+
}, La = class extends Error {
|
|
5940
6011
|
constructor(e = "No available authentication factor can satisfy this challenge") {
|
|
5941
6012
|
super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
|
|
5942
6013
|
}
|
|
5943
|
-
},
|
|
6014
|
+
}, Ra = 4, za = 3e4, Ba = () => {
|
|
5944
6015
|
let e = () => void 0, t = () => void 0;
|
|
5945
6016
|
return {
|
|
5946
6017
|
promise: new Promise((n, r) => {
|
|
@@ -5949,12 +6020,12 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5949
6020
|
resolve: e,
|
|
5950
6021
|
reject: t
|
|
5951
6022
|
};
|
|
5952
|
-
},
|
|
6023
|
+
}, Va = (e) => ({
|
|
5953
6024
|
acrValues: e.acrValues,
|
|
5954
6025
|
level: e.requiredLevel,
|
|
5955
6026
|
maxAge: e.maxAge
|
|
5956
|
-
}),
|
|
5957
|
-
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 ?? []])), { availableFactors: o, signInRequired: s } =
|
|
6027
|
+
}), Ha = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, Ua = (e, t) => {
|
|
6028
|
+
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 ?? []])), { availableFactors: o, signInRequired: s } = Wa(t, e) && !Wa(e, t) || !t.availableFactors ? e : t;
|
|
5958
6029
|
return {
|
|
5959
6030
|
acrValues: r,
|
|
5960
6031
|
requiredLevel: n,
|
|
@@ -5964,12 +6035,12 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5964
6035
|
...o ? { availableFactors: o } : {},
|
|
5965
6036
|
...s === void 0 ? {} : { signInRequired: s }
|
|
5966
6037
|
};
|
|
5967
|
-
},
|
|
6038
|
+
}, Wa = (e, t) => {
|
|
5968
6039
|
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);
|
|
5969
6040
|
return n || r;
|
|
5970
|
-
},
|
|
6041
|
+
}, Ga = class {
|
|
5971
6042
|
constructor(e) {
|
|
5972
|
-
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 ??
|
|
6043
|
+
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 ?? wa, this.registry = Ta(this.available), this.maxAttempts = e.maxAttempts ?? Ra, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? za;
|
|
5973
6044
|
}
|
|
5974
6045
|
get currentState() {
|
|
5975
6046
|
return this.state;
|
|
@@ -5989,9 +6060,9 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5989
6060
|
}
|
|
5990
6061
|
register(e, t) {
|
|
5991
6062
|
let n = t.kind === "imperative" && t.requested !== void 0, r = {
|
|
5992
|
-
demanded: t.kind === "imperative" && t.requested ? t.requested :
|
|
6063
|
+
demanded: t.kind === "imperative" && t.requested ? t.requested : Va(e),
|
|
5993
6064
|
statedBar: n,
|
|
5994
|
-
settlement:
|
|
6065
|
+
settlement: Ba(),
|
|
5995
6066
|
reported: !1,
|
|
5996
6067
|
entry: {
|
|
5997
6068
|
...t,
|
|
@@ -6007,15 +6078,15 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6007
6078
|
this.requirement = e;
|
|
6008
6079
|
return;
|
|
6009
6080
|
}
|
|
6010
|
-
let n =
|
|
6011
|
-
this.requirement =
|
|
6081
|
+
let n = Wa(t, e);
|
|
6082
|
+
this.requirement = Ua(t, e), Ia(this.requirement) ? this.state === "collecting" && this.selected === null && (this.openPrompt?.onClosed?.(), this.closeOpenPrompt?.()) : n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
|
|
6012
6083
|
challenge: this.requirement,
|
|
6013
6084
|
factors: this.offeredFactors()
|
|
6014
6085
|
});
|
|
6015
6086
|
}
|
|
6016
6087
|
offeredFactors() {
|
|
6017
6088
|
let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
|
|
6018
|
-
return t ?
|
|
6089
|
+
return t ? Aa(e, t) : e;
|
|
6019
6090
|
}
|
|
6020
6091
|
receiveReport(e, t) {
|
|
6021
6092
|
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());
|
|
@@ -6050,12 +6121,12 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6050
6121
|
}
|
|
6051
6122
|
release(e, t) {
|
|
6052
6123
|
if (e.entry.kind === "imperative") {
|
|
6053
|
-
if (e.statedBar && !
|
|
6124
|
+
if (e.statedBar && !Ha(t, e.demanded)) {
|
|
6054
6125
|
this.receiveReport(e, {
|
|
6055
6126
|
outcome: "insufficient",
|
|
6056
6127
|
obtained: t,
|
|
6057
6128
|
required: e.demanded
|
|
6058
|
-
}), e.settlement.reject(new
|
|
6129
|
+
}), e.settlement.reject(new zi(t, e.demanded));
|
|
6059
6130
|
return;
|
|
6060
6131
|
}
|
|
6061
6132
|
this.receiveReport(e, {
|
|
@@ -6125,7 +6196,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6125
6196
|
async prove() {
|
|
6126
6197
|
let e;
|
|
6127
6198
|
for (let t = 0; t < this.maxAttempts; t++) {
|
|
6128
|
-
let t =
|
|
6199
|
+
let t = Ia(this.requirement);
|
|
6129
6200
|
if (t) return {
|
|
6130
6201
|
status: "failed",
|
|
6131
6202
|
reason: t
|
|
@@ -6133,7 +6204,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6133
6204
|
let n = this.offeredFactors();
|
|
6134
6205
|
if (n.length === 0) return {
|
|
6135
6206
|
status: "failed",
|
|
6136
|
-
reason: new
|
|
6207
|
+
reason: new La()
|
|
6137
6208
|
};
|
|
6138
6209
|
let r = this.requirement, i;
|
|
6139
6210
|
try {
|
|
@@ -6141,29 +6212,29 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6141
6212
|
} catch (e) {
|
|
6142
6213
|
return {
|
|
6143
6214
|
status: "failed",
|
|
6144
|
-
reason: new
|
|
6215
|
+
reason: new ja(e)
|
|
6145
6216
|
};
|
|
6146
6217
|
}
|
|
6147
|
-
let a =
|
|
6218
|
+
let a = Ia(this.requirement);
|
|
6148
6219
|
if (a) return {
|
|
6149
6220
|
status: "failed",
|
|
6150
6221
|
reason: a
|
|
6151
6222
|
};
|
|
6152
6223
|
if (i.type === "cancel") return {
|
|
6153
6224
|
status: "failed",
|
|
6154
|
-
reason: new
|
|
6225
|
+
reason: new ja()
|
|
6155
6226
|
};
|
|
6156
6227
|
let o = this.registry.get(i.factor);
|
|
6157
|
-
if (!o) e = new
|
|
6228
|
+
if (!o) e = new La(`Unknown authentication factor: ${i.factor}`), this.state = "collecting", this.selected = null;
|
|
6158
6229
|
else try {
|
|
6159
6230
|
return await this.proveAndCommit(o, i.code), {
|
|
6160
6231
|
status: "proven",
|
|
6161
|
-
obtained: this.readObtainedBar?.() ??
|
|
6232
|
+
obtained: this.readObtainedBar?.() ?? Va(this.rankedRequirement ?? r)
|
|
6162
6233
|
};
|
|
6163
6234
|
} catch (t) {
|
|
6164
|
-
if (t instanceof
|
|
6235
|
+
if (t instanceof ya && t.cancelled) return {
|
|
6165
6236
|
status: "failed",
|
|
6166
|
-
reason: new
|
|
6237
|
+
reason: new ja()
|
|
6167
6238
|
};
|
|
6168
6239
|
let n = this.classifyProofFailure(t);
|
|
6169
6240
|
if (n) return {
|
|
@@ -6199,16 +6270,16 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6199
6270
|
});
|
|
6200
6271
|
}
|
|
6201
6272
|
classifyProofFailure(e) {
|
|
6202
|
-
if (e instanceof
|
|
6273
|
+
if (e instanceof zi || e instanceof Bi || e instanceof Vi) return e;
|
|
6203
6274
|
if (e instanceof $) switch (e.kind) {
|
|
6204
|
-
case "unavailable": return new
|
|
6275
|
+
case "unavailable": return new Bi(e.message);
|
|
6205
6276
|
case "exhausted":
|
|
6206
6277
|
case "attempts_exhausted":
|
|
6207
6278
|
case "rate_limited":
|
|
6208
6279
|
case "fatal":
|
|
6209
6280
|
case "protocol":
|
|
6210
6281
|
case "network": return e;
|
|
6211
|
-
case "session_changed": return new
|
|
6282
|
+
case "session_changed": return new Vi(e.message);
|
|
6212
6283
|
default: return;
|
|
6213
6284
|
}
|
|
6214
6285
|
}
|
|
@@ -6220,28 +6291,28 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6220
6291
|
});
|
|
6221
6292
|
await this.transport.commit(e.type, r);
|
|
6222
6293
|
}
|
|
6223
|
-
},
|
|
6294
|
+
}, Ka = (e) => typeof e == "function" ? e() : e, qa = (e) => {
|
|
6224
6295
|
try {
|
|
6225
6296
|
return new URL(e);
|
|
6226
6297
|
} catch {
|
|
6227
6298
|
return;
|
|
6228
6299
|
}
|
|
6229
|
-
},
|
|
6300
|
+
}, Ja = (e, t) => {
|
|
6230
6301
|
if (!t || t === "/") return !0;
|
|
6231
6302
|
let n = t.replace(/\/+$/, "");
|
|
6232
6303
|
return e === n || e.startsWith(`${n}/`);
|
|
6233
|
-
},
|
|
6304
|
+
}, Ya = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && Ja(e.pathname, t.pathPrefix), Xa = (e, t) => {
|
|
6234
6305
|
for (let n of t) {
|
|
6235
6306
|
if (n === "") continue;
|
|
6236
6307
|
if (n.startsWith("/")) {
|
|
6237
|
-
if (e.relativeToBase &&
|
|
6308
|
+
if (e.relativeToBase && Ja(e.pathname, n)) return !0;
|
|
6238
6309
|
continue;
|
|
6239
6310
|
}
|
|
6240
|
-
let t =
|
|
6241
|
-
if (t && e.origin !== void 0 && e.origin === t.origin &&
|
|
6311
|
+
let t = qa(n) ?? qa(`https://${n}`);
|
|
6312
|
+
if (t && e.origin !== void 0 && e.origin === t.origin && Ja(e.pathname, t.pathname)) return !0;
|
|
6242
6313
|
}
|
|
6243
6314
|
return !1;
|
|
6244
|
-
},
|
|
6315
|
+
}, Za = (e, t, n) => Ya(e, t.passflow) || Xa(e, t.backend) ? !n || n(e.href) !== !1 : !1, Qa = (e) => {
|
|
6245
6316
|
let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
|
|
6246
6317
|
console.warn(n, {
|
|
6247
6318
|
status: e.status,
|
|
@@ -6249,8 +6320,8 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6249
6320
|
reason: e.reason,
|
|
6250
6321
|
detail: t
|
|
6251
6322
|
});
|
|
6252
|
-
},
|
|
6253
|
-
let n = t.onUpgradeDiagnostic ??
|
|
6323
|
+
}, $a = (e, t) => {
|
|
6324
|
+
let n = t.onUpgradeDiagnostic ?? Qa;
|
|
6254
6325
|
return (t, r) => {
|
|
6255
6326
|
n({
|
|
6256
6327
|
status: e.status,
|
|
@@ -6262,8 +6333,8 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6262
6333
|
}
|
|
6263
6334
|
});
|
|
6264
6335
|
};
|
|
6265
|
-
},
|
|
6266
|
-
let r = n.onUpgradeDiagnostic ??
|
|
6336
|
+
}, eo = (e, t, n) => {
|
|
6337
|
+
let r = n.onUpgradeDiagnostic ?? Qa;
|
|
6267
6338
|
for (let n of e) r({
|
|
6268
6339
|
...n,
|
|
6269
6340
|
url: t.request.href,
|
|
@@ -6272,8 +6343,8 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6272
6343
|
...n.detail ?? {}
|
|
6273
6344
|
}
|
|
6274
6345
|
});
|
|
6275
|
-
},
|
|
6276
|
-
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n &&
|
|
6346
|
+
}, to = /\bjson\b/i, no = async (e, t) => {
|
|
6347
|
+
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && to.test(r), a;
|
|
6277
6348
|
if (i) try {
|
|
6278
6349
|
a = await e.readBody();
|
|
6279
6350
|
} catch {
|
|
@@ -6287,13 +6358,13 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6287
6358
|
status: e.status,
|
|
6288
6359
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
6289
6360
|
}, { requireChallengeChannel: t.requireChallengeChannel });
|
|
6290
|
-
},
|
|
6361
|
+
}, ro = (e) => ke({
|
|
6291
6362
|
status: e.status,
|
|
6292
6363
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
6293
|
-
}, { requireChallengeChannel: "header" }).challenge,
|
|
6364
|
+
}, { requireChallengeChannel: "header" }).challenge, io = (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.`, ao = (e, t) => e instanceof ja ? { kind: "cancelled" } : e instanceof Ma ? { kind: "sign-in-required" } : e instanceof La ? {
|
|
6294
6365
|
kind: "unsatisfiable",
|
|
6295
6366
|
error: e
|
|
6296
|
-
} : e instanceof
|
|
6367
|
+
} : e instanceof Bi ? { kind: "unavailable" } : e instanceof Vi ? { kind: "session-changed" } : e instanceof zi ? {
|
|
6297
6368
|
kind: "insufficient",
|
|
6298
6369
|
obtained: e.obtained,
|
|
6299
6370
|
required: e.required
|
|
@@ -6309,26 +6380,26 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6309
6380
|
kind: "transport-failure",
|
|
6310
6381
|
retryable: !1,
|
|
6311
6382
|
error: e instanceof Error ? e : Error(String(e))
|
|
6312
|
-
},
|
|
6383
|
+
}, oo = async (e, t, n, r) => {
|
|
6313
6384
|
if (e.status !== 401 && e.status !== 403) return {
|
|
6314
6385
|
kind: "replayed",
|
|
6315
6386
|
response: e
|
|
6316
6387
|
};
|
|
6317
|
-
let { challenge: i, diagnostics: a } = await
|
|
6318
|
-
if (
|
|
6388
|
+
let { challenge: i, diagnostics: a } = await no(e, t);
|
|
6389
|
+
if (eo(a, e, t), !i) return {
|
|
6319
6390
|
kind: "replayed",
|
|
6320
6391
|
response: e
|
|
6321
6392
|
};
|
|
6322
|
-
if (
|
|
6393
|
+
if (Na(i)) return {
|
|
6323
6394
|
kind: "sign-in-required",
|
|
6324
6395
|
response: e
|
|
6325
6396
|
};
|
|
6326
|
-
if (
|
|
6397
|
+
if (Pa(i)) return {
|
|
6327
6398
|
kind: "unsatisfiable",
|
|
6328
|
-
error:
|
|
6399
|
+
error: Ia(i),
|
|
6329
6400
|
response: e
|
|
6330
6401
|
};
|
|
6331
|
-
let o =
|
|
6402
|
+
let o = Va(i);
|
|
6332
6403
|
return r("elevated-insufficient", {
|
|
6333
6404
|
obtained: n,
|
|
6334
6405
|
required: o
|
|
@@ -6338,7 +6409,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6338
6409
|
required: o,
|
|
6339
6410
|
response: e
|
|
6340
6411
|
};
|
|
6341
|
-
},
|
|
6412
|
+
}, so = async (e, t) => {
|
|
6342
6413
|
if (!t) return {
|
|
6343
6414
|
aborted: !1,
|
|
6344
6415
|
value: await e
|
|
@@ -6365,14 +6436,14 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6365
6436
|
} finally {
|
|
6366
6437
|
n && t.removeEventListener?.("abort", n);
|
|
6367
6438
|
}
|
|
6368
|
-
},
|
|
6439
|
+
}, co = async (e, t) => {
|
|
6369
6440
|
if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
|
|
6370
|
-
let n =
|
|
6441
|
+
let n = $a(e, t);
|
|
6371
6442
|
if (e.markers.replayed) {
|
|
6372
|
-
if (!
|
|
6373
|
-
let { challenge: r, diagnostics: i } = await
|
|
6374
|
-
if (
|
|
6375
|
-
let a = t.readObtainedBar?.() ?? {}, o =
|
|
6443
|
+
if (!Za(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
|
|
6444
|
+
let { challenge: r, diagnostics: i } = await no(e, t);
|
|
6445
|
+
if (eo(i, e, t), !r) return { kind: "not-a-challenge" };
|
|
6446
|
+
let a = t.readObtainedBar?.() ?? {}, o = Va(r);
|
|
6376
6447
|
return n("elevated-insufficient", {
|
|
6377
6448
|
obtained: a,
|
|
6378
6449
|
required: o
|
|
@@ -6383,12 +6454,12 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6383
6454
|
response: e
|
|
6384
6455
|
};
|
|
6385
6456
|
}
|
|
6386
|
-
if (!
|
|
6457
|
+
if (!Za(e.request, t.scope, t.shouldIntercept)) return ro(e) ? (n("challenge-out-of-scope", {
|
|
6387
6458
|
header: e.getHeader("www-authenticate") ?? void 0,
|
|
6388
|
-
message:
|
|
6459
|
+
message: io(e.request.href, t.scope)
|
|
6389
6460
|
}), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
|
|
6390
|
-
let { challenge: r, diagnostics: i } = await
|
|
6391
|
-
if (
|
|
6461
|
+
let { challenge: r, diagnostics: i } = await no(e, t);
|
|
6462
|
+
if (eo(i, e, t), !r) {
|
|
6392
6463
|
let r = e.getHeader("www-authenticate");
|
|
6393
6464
|
return t.requireChallengeChannel !== "header" && n("no-channel", {
|
|
6394
6465
|
...r ? { header: r } : {},
|
|
@@ -6402,9 +6473,9 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6402
6473
|
method: e.request.method
|
|
6403
6474
|
}, s, c;
|
|
6404
6475
|
try {
|
|
6405
|
-
s = Promise.resolve(t.elevate(r, o)), c = await
|
|
6476
|
+
s = Promise.resolve(t.elevate(r, o)), c = await so(s, e.signal);
|
|
6406
6477
|
} catch (e) {
|
|
6407
|
-
return
|
|
6478
|
+
return ao(e, void 0);
|
|
6408
6479
|
}
|
|
6409
6480
|
if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
|
|
6410
6481
|
kind: "aborted",
|
|
@@ -6415,7 +6486,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6415
6486
|
kind: "aborted",
|
|
6416
6487
|
reason: e.signal.reason
|
|
6417
6488
|
};
|
|
6418
|
-
let u = l?.obtained ?? t.readObtainedBar?.() ??
|
|
6489
|
+
let u = l?.obtained ?? t.readObtainedBar?.() ?? Va(r), d = t.authorizationSwap?.(), f = d ? {
|
|
6419
6490
|
from: a?.from ?? d.from,
|
|
6420
6491
|
to: d.to
|
|
6421
6492
|
} : void 0;
|
|
@@ -6424,7 +6495,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6424
6495
|
try {
|
|
6425
6496
|
p = await e.replay(f ? { authorizationSwap: f } : void 0);
|
|
6426
6497
|
} catch (t) {
|
|
6427
|
-
if (t instanceof
|
|
6498
|
+
if (t instanceof zi) return l?.waiter.report({
|
|
6428
6499
|
outcome: "insufficient",
|
|
6429
6500
|
obtained: t.obtained,
|
|
6430
6501
|
required: t.required
|
|
@@ -6442,7 +6513,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6442
6513
|
};
|
|
6443
6514
|
throw t;
|
|
6444
6515
|
}
|
|
6445
|
-
let m = await
|
|
6516
|
+
let m = await oo(p, t, u, n);
|
|
6446
6517
|
return m.kind === "insufficient" ? l?.waiter.report({
|
|
6447
6518
|
outcome: "insufficient",
|
|
6448
6519
|
obtained: m.obtained,
|
|
@@ -6451,19 +6522,19 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6451
6522
|
outcome: "replayed",
|
|
6452
6523
|
obtained: u
|
|
6453
6524
|
}), m;
|
|
6454
|
-
},
|
|
6525
|
+
}, lo = (e) => {
|
|
6455
6526
|
switch (e.kind) {
|
|
6456
|
-
case "cancelled": return new
|
|
6457
|
-
case "unsatisfiable": return e.error ?? new
|
|
6458
|
-
case "sign-in-required": return new
|
|
6459
|
-
case "unavailable": return new
|
|
6460
|
-
case "session-changed": return new
|
|
6461
|
-
case "insufficient": return new
|
|
6527
|
+
case "cancelled": return new ja();
|
|
6528
|
+
case "unsatisfiable": return e.error ?? new La();
|
|
6529
|
+
case "sign-in-required": return new Ma();
|
|
6530
|
+
case "unavailable": return new Bi();
|
|
6531
|
+
case "session-changed": return new Vi();
|
|
6532
|
+
case "insufficient": return new zi(e.obtained, e.required);
|
|
6462
6533
|
case "exhausted": return e.error;
|
|
6463
6534
|
case "transport-failure": return e.error;
|
|
6464
6535
|
default: return;
|
|
6465
6536
|
}
|
|
6466
|
-
},
|
|
6537
|
+
}, uo = (e, t, n) => {
|
|
6467
6538
|
switch (e.kind) {
|
|
6468
6539
|
case "replayed": return {
|
|
6469
6540
|
settle: "resolve",
|
|
@@ -6481,26 +6552,26 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6481
6552
|
};
|
|
6482
6553
|
case "cancelled": return n.onCancel === "reject" ? {
|
|
6483
6554
|
settle: "reject",
|
|
6484
|
-
error: new
|
|
6555
|
+
error: new ja()
|
|
6485
6556
|
} : {
|
|
6486
6557
|
settle: "resolve",
|
|
6487
|
-
value:
|
|
6558
|
+
value: xo(t, e)
|
|
6488
6559
|
};
|
|
6489
6560
|
case "unsatisfiable":
|
|
6490
6561
|
case "sign-in-required": return {
|
|
6491
6562
|
settle: "resolve",
|
|
6492
|
-
value:
|
|
6563
|
+
value: xo(e.response?.raw ?? t, e)
|
|
6493
6564
|
};
|
|
6494
6565
|
case "insufficient": return {
|
|
6495
6566
|
settle: "resolve",
|
|
6496
|
-
value:
|
|
6567
|
+
value: xo(e.response?.raw ?? t, e)
|
|
6497
6568
|
};
|
|
6498
6569
|
default: return {
|
|
6499
6570
|
settle: "resolve",
|
|
6500
|
-
value:
|
|
6571
|
+
value: xo(t, e)
|
|
6501
6572
|
};
|
|
6502
6573
|
}
|
|
6503
|
-
},
|
|
6574
|
+
}, fo = (e, t) => {
|
|
6504
6575
|
switch (e.kind) {
|
|
6505
6576
|
case "replayed": return e.response.rejected ? {
|
|
6506
6577
|
settle: "reject",
|
|
@@ -6515,42 +6586,42 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6515
6586
|
};
|
|
6516
6587
|
default: return {
|
|
6517
6588
|
settle: "reject",
|
|
6518
|
-
error:
|
|
6589
|
+
error: lo(e) ?? t
|
|
6519
6590
|
};
|
|
6520
6591
|
}
|
|
6521
|
-
},
|
|
6592
|
+
}, po = /* @__PURE__ */ new WeakSet(), mo = /* @__PURE__ */ new WeakSet(), ho = /* @__PURE__ */ new WeakSet(), go = /* @__PURE__ */ new WeakSet(), _o = /* @__PURE__ */ new WeakSet(), vo = /* @__PURE__ */ new WeakSet(), yo = /* @__PURE__ */ new WeakSet(), bo = /* @__PURE__ */ new WeakSet(), xo = (e, t) => {
|
|
6522
6593
|
switch (t.kind) {
|
|
6523
6594
|
case "cancelled":
|
|
6524
|
-
|
|
6595
|
+
po.add(e);
|
|
6525
6596
|
break;
|
|
6526
6597
|
case "exhausted":
|
|
6527
|
-
|
|
6598
|
+
mo.add(e);
|
|
6528
6599
|
break;
|
|
6529
6600
|
case "insufficient":
|
|
6530
|
-
|
|
6601
|
+
ho.add(e);
|
|
6531
6602
|
break;
|
|
6532
6603
|
case "unsatisfiable":
|
|
6533
|
-
|
|
6604
|
+
go.add(e);
|
|
6534
6605
|
break;
|
|
6535
6606
|
case "sign-in-required":
|
|
6536
|
-
|
|
6607
|
+
_o.add(e);
|
|
6537
6608
|
break;
|
|
6538
6609
|
case "unavailable":
|
|
6539
|
-
|
|
6610
|
+
vo.add(e);
|
|
6540
6611
|
break;
|
|
6541
6612
|
case "session-changed":
|
|
6542
|
-
|
|
6613
|
+
yo.add(e);
|
|
6543
6614
|
break;
|
|
6544
|
-
case "transport-failure":
|
|
6615
|
+
case "transport-failure": bo.add(e);
|
|
6545
6616
|
}
|
|
6546
6617
|
return e;
|
|
6547
|
-
},
|
|
6618
|
+
}, So = (e) => po.has(e), Co = (e) => mo.has(e), wo = (e) => ho.has(e), To = (e) => go.has(e), Eo = (e) => _o.has(e), Do = (e) => vo.has(e), Oo = (e) => yo.has(e), ko = (e) => bo.has(e), Ao = "https://passflow-relative.invalid", jo = () => {
|
|
6548
6619
|
let e = globalThis, t = e.document?.baseURI;
|
|
6549
6620
|
if (typeof t == "string" && t !== "") return t;
|
|
6550
6621
|
let n = e.location?.href;
|
|
6551
|
-
return typeof n == "string" && n !== "" && n !== "about:blank" ? n :
|
|
6552
|
-
},
|
|
6553
|
-
let n = t ===
|
|
6622
|
+
return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Ao;
|
|
6623
|
+
}, Mo = (e, t = jo()) => {
|
|
6624
|
+
let n = t === Ao, r;
|
|
6554
6625
|
try {
|
|
6555
6626
|
r = new URL(t).origin;
|
|
6556
6627
|
} catch {
|
|
@@ -6576,28 +6647,28 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6576
6647
|
relativeToBase: !1,
|
|
6577
6648
|
sentinelBase: n
|
|
6578
6649
|
};
|
|
6579
|
-
},
|
|
6650
|
+
}, No = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Po = (e) => {
|
|
6580
6651
|
let t = [];
|
|
6581
6652
|
if (e == null) return Object.freeze(t);
|
|
6582
6653
|
let n = e;
|
|
6583
6654
|
if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
|
|
6584
|
-
let r =
|
|
6655
|
+
let r = No(n, e);
|
|
6585
6656
|
r && t.push(r);
|
|
6586
6657
|
}), Object.freeze(t);
|
|
6587
6658
|
if (Array.isArray(e)) {
|
|
6588
6659
|
for (let n of e) if (Array.isArray(n) && n.length >= 2) {
|
|
6589
|
-
let e =
|
|
6660
|
+
let e = No(String(n[0]), n[1]);
|
|
6590
6661
|
e && t.push(e);
|
|
6591
6662
|
}
|
|
6592
6663
|
return Object.freeze(t);
|
|
6593
6664
|
}
|
|
6594
6665
|
if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
|
|
6595
|
-
let e =
|
|
6666
|
+
let e = No(n, Array.isArray(r) ? r.join(", ") : r);
|
|
6596
6667
|
e && t.push(e);
|
|
6597
6668
|
}
|
|
6598
6669
|
return Object.freeze(t);
|
|
6599
|
-
},
|
|
6600
|
-
let t = e.base === void 0 ?
|
|
6670
|
+
}, Fo = (e) => {
|
|
6671
|
+
let t = e.base === void 0 ? Mo(e.url) : Mo(e.url, e.base), n = {
|
|
6601
6672
|
raw: e.url,
|
|
6602
6673
|
href: t.href,
|
|
6603
6674
|
dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
|
|
@@ -6606,29 +6677,29 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6606
6677
|
resolved: t.resolved,
|
|
6607
6678
|
relativeToBase: t.relativeToBase,
|
|
6608
6679
|
method: (e.method ?? "GET").toUpperCase(),
|
|
6609
|
-
headers:
|
|
6680
|
+
headers: Po(e.headers),
|
|
6610
6681
|
bodyKind: e.bodyKind,
|
|
6611
6682
|
..."body" in e ? { body: e.body } : {}
|
|
6612
6683
|
};
|
|
6613
6684
|
return Object.freeze(n);
|
|
6614
|
-
},
|
|
6685
|
+
}, Io = (e, t) => {
|
|
6615
6686
|
if (!t || t.from === t.to) return e;
|
|
6616
6687
|
let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
|
|
6617
6688
|
return n ? Object.freeze(r) : e;
|
|
6618
|
-
},
|
|
6689
|
+
}, Lo = (e) => {
|
|
6619
6690
|
let t = {};
|
|
6620
6691
|
for (let [n, r] of e) t[n] = r;
|
|
6621
6692
|
return t;
|
|
6622
|
-
},
|
|
6693
|
+
}, Ro = /* @__PURE__ */ new Set([
|
|
6623
6694
|
"GET",
|
|
6624
6695
|
"HEAD",
|
|
6625
6696
|
"OPTIONS"
|
|
6626
|
-
]),
|
|
6697
|
+
]), zo = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, Bo = (e) => typeof e == "string" ? e : zo(e) ? e.url : String(e), Vo = (e, t) => (t?.method ?? (zo(e) ? e.method : void 0) ?? "GET").toUpperCase(), Ho = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", Uo = (e) => {
|
|
6627
6698
|
if (typeof e == "string") return e.length;
|
|
6628
6699
|
let t = e;
|
|
6629
6700
|
if (typeof t?.size == "number") return t.size;
|
|
6630
6701
|
if (typeof t?.byteLength == "number") return t.byteLength;
|
|
6631
|
-
},
|
|
6702
|
+
}, Wo = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? Ro.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), Go = (e, t, n, r, i) => ({
|
|
6632
6703
|
replayable: !1,
|
|
6633
6704
|
bodyKind: e,
|
|
6634
6705
|
reason: t,
|
|
@@ -6636,11 +6707,11 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6636
6707
|
forwardInit: i,
|
|
6637
6708
|
snapshot: r,
|
|
6638
6709
|
replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
|
|
6639
|
-
}),
|
|
6710
|
+
}), Ko = (e, t) => Lo(Io(e.headers, t?.authorizationSwap)), qo = (e) => {
|
|
6640
6711
|
if (!e || !("headers" in e)) return e;
|
|
6641
6712
|
let { headers: t, ...n } = e;
|
|
6642
6713
|
return n;
|
|
6643
|
-
},
|
|
6714
|
+
}, Jo = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : zo(e) ? e.headers : void 0, Yo = (e) => {
|
|
6644
6715
|
if (e === null || typeof e == "string") return e;
|
|
6645
6716
|
if (typeof FormData < "u" && e instanceof FormData) {
|
|
6646
6717
|
let t = new FormData();
|
|
@@ -6648,18 +6719,18 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6648
6719
|
return t;
|
|
6649
6720
|
}
|
|
6650
6721
|
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;
|
|
6651
|
-
},
|
|
6652
|
-
let r =
|
|
6722
|
+
}, Xo = (e, t, n) => new Request(e, { headers: Ko(t, n) }), Zo = (e, t, n) => {
|
|
6723
|
+
let r = Bo(e), i = Vo(e, t), a = Jo(e, t), o = (e, t) => Fo({
|
|
6653
6724
|
url: r,
|
|
6654
6725
|
method: i,
|
|
6655
6726
|
headers: a,
|
|
6656
6727
|
bodyKind: e,
|
|
6657
6728
|
...t === void 0 ? {} : { body: t }
|
|
6658
6729
|
});
|
|
6659
|
-
if (
|
|
6730
|
+
if (zo(e)) {
|
|
6660
6731
|
if (e.body === null || e.body === void 0) {
|
|
6661
6732
|
let a = o("none");
|
|
6662
|
-
return
|
|
6733
|
+
return Wo(n, {
|
|
6663
6734
|
url: r,
|
|
6664
6735
|
method: i,
|
|
6665
6736
|
bodyKind: "none"
|
|
@@ -6669,20 +6740,20 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6669
6740
|
forwardInput: e,
|
|
6670
6741
|
forwardInit: t,
|
|
6671
6742
|
snapshot: a,
|
|
6672
|
-
replay: (n, r) => n(
|
|
6673
|
-
} :
|
|
6743
|
+
replay: (n, r) => n(Xo(e, a, r), qo(t))
|
|
6744
|
+
} : Go("none", "the replay policy refused this request", e, a, t);
|
|
6674
6745
|
}
|
|
6675
6746
|
let a = o("request-clone");
|
|
6676
|
-
if (!
|
|
6747
|
+
if (!Wo(n, {
|
|
6677
6748
|
url: r,
|
|
6678
6749
|
method: i,
|
|
6679
6750
|
bodyKind: "request-clone"
|
|
6680
|
-
})) return
|
|
6751
|
+
})) return Go("request-clone", "the replay policy refused this request", e, a, t);
|
|
6681
6752
|
let s;
|
|
6682
6753
|
try {
|
|
6683
6754
|
s = e.clone();
|
|
6684
6755
|
} catch {
|
|
6685
|
-
return
|
|
6756
|
+
return Go("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
|
|
6686
6757
|
}
|
|
6687
6758
|
return {
|
|
6688
6759
|
replayable: !0,
|
|
@@ -6690,17 +6761,17 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6690
6761
|
forwardInput: e,
|
|
6691
6762
|
forwardInit: t,
|
|
6692
6763
|
snapshot: a,
|
|
6693
|
-
replay: (e, n) => e(
|
|
6764
|
+
replay: (e, n) => e(Xo(s, a, n), qo(t))
|
|
6694
6765
|
};
|
|
6695
6766
|
}
|
|
6696
|
-
let s =
|
|
6697
|
-
if (s === "one-shot") return
|
|
6698
|
-
if (!
|
|
6767
|
+
let s = Ho(t?.body);
|
|
6768
|
+
if (s === "one-shot") return Go("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
|
|
6769
|
+
if (!Wo(n, {
|
|
6699
6770
|
url: r,
|
|
6700
6771
|
method: i,
|
|
6701
6772
|
bodyKind: s
|
|
6702
|
-
},
|
|
6703
|
-
let c = t && "body" in t ?
|
|
6773
|
+
}, Uo(t?.body))) return Go(s, "the replay policy refused this request", e, o(s), t);
|
|
6774
|
+
let c = t && "body" in t ? Yo(t.body ?? null) : void 0, l = o(s, c);
|
|
6704
6775
|
return {
|
|
6705
6776
|
replayable: !0,
|
|
6706
6777
|
bodyKind: s,
|
|
@@ -6708,21 +6779,21 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6708
6779
|
forwardInit: t,
|
|
6709
6780
|
snapshot: l,
|
|
6710
6781
|
replay: (e, n) => e(l.dispatchUrl, {
|
|
6711
|
-
...
|
|
6782
|
+
...qo(t),
|
|
6712
6783
|
...c === void 0 ? {} : { body: c },
|
|
6713
|
-
headers:
|
|
6784
|
+
headers: Ko(l, n),
|
|
6714
6785
|
method: l.method
|
|
6715
6786
|
})
|
|
6716
6787
|
};
|
|
6717
|
-
},
|
|
6718
|
-
if (!
|
|
6788
|
+
}, Qo = (e) => typeof e == "object" && !!e, $o = (e) => (t) => {
|
|
6789
|
+
if (!Qo(e)) return;
|
|
6719
6790
|
let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
|
|
6720
6791
|
return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
|
|
6721
|
-
},
|
|
6792
|
+
}, es = (e) => {
|
|
6722
6793
|
let t = e?.url ?? "", n = e?.baseURL;
|
|
6723
6794
|
return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
6724
|
-
},
|
|
6725
|
-
let r =
|
|
6795
|
+
}, ts = (e) => (e?.method ?? "GET").toUpperCase(), ns = (e) => e == null ? "none" : Qo(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", rs = (e, t, n) => {
|
|
6796
|
+
let r = Lo(Io(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
|
|
6726
6797
|
return {
|
|
6727
6798
|
...e,
|
|
6728
6799
|
...i ? { baseURL: void 0 } : {},
|
|
@@ -6731,10 +6802,10 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6731
6802
|
headers: r,
|
|
6732
6803
|
..."body" in t ? { data: t.body } : {}
|
|
6733
6804
|
};
|
|
6734
|
-
},
|
|
6735
|
-
let o = t ?? e?.config, s =
|
|
6736
|
-
url:
|
|
6737
|
-
method:
|
|
6805
|
+
}, is = (e, t, n, r, i, a) => {
|
|
6806
|
+
let o = t ?? e?.config, s = ns(o?.data), c = a ?? Fo({
|
|
6807
|
+
url: es(o),
|
|
6808
|
+
method: ts(o),
|
|
6738
6809
|
headers: o?.headers,
|
|
6739
6810
|
bodyKind: s,
|
|
6740
6811
|
body: o?.data
|
|
@@ -6742,22 +6813,22 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6742
6813
|
url: c.href,
|
|
6743
6814
|
method: c.method,
|
|
6744
6815
|
bodyKind: s
|
|
6745
|
-
}, u = s !== "one-shot" &&
|
|
6816
|
+
}, u = s !== "one-shot" && Wo(i.replay, l);
|
|
6746
6817
|
return {
|
|
6747
6818
|
status: e?.status ?? 0,
|
|
6748
|
-
getHeader:
|
|
6819
|
+
getHeader: $o(e?.headers),
|
|
6749
6820
|
readBody: async () => e?.data,
|
|
6750
6821
|
request: c,
|
|
6751
6822
|
replay: async (e) => {
|
|
6752
|
-
let t = Ie(
|
|
6823
|
+
let t = Ie(rs(o ?? {}, c, e));
|
|
6753
6824
|
try {
|
|
6754
6825
|
let e = await r(t);
|
|
6755
|
-
return
|
|
6826
|
+
return is(e, e?.config ?? t, e, r, i, c);
|
|
6756
6827
|
} catch (e) {
|
|
6757
|
-
let n =
|
|
6758
|
-
if (!n.response || typeof n.response.status != "number" ||
|
|
6828
|
+
let n = Qo(e) ? e : {};
|
|
6829
|
+
if (!n.response || typeof n.response.status != "number" || ki(e)) throw e;
|
|
6759
6830
|
return {
|
|
6760
|
-
...
|
|
6831
|
+
...is(n.response, n.config ?? t, e, r, i, c),
|
|
6761
6832
|
rejected: !0
|
|
6762
6833
|
};
|
|
6763
6834
|
}
|
|
@@ -6771,30 +6842,30 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6771
6842
|
replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
|
|
6772
6843
|
signal: o?.signal
|
|
6773
6844
|
};
|
|
6774
|
-
},
|
|
6775
|
-
let r =
|
|
6845
|
+
}, as = (e, t) => async (n) => {
|
|
6846
|
+
let r = Ka(e), i = Qo(n) ? n : {}, a = fo(await co(is(i.response, i.config, i.response, t, r), r), n);
|
|
6776
6847
|
if (a.settle === "reject") throw a.error;
|
|
6777
6848
|
return a.value;
|
|
6778
|
-
},
|
|
6779
|
-
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,
|
|
6849
|
+
}, os = (e, t, n) => {
|
|
6850
|
+
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, as(t, i)), o = !1;
|
|
6780
6851
|
return () => {
|
|
6781
6852
|
o || (o = !0, e.interceptors.response.eject(a));
|
|
6782
6853
|
};
|
|
6783
|
-
},
|
|
6854
|
+
}, ss = (t, n) => {
|
|
6784
6855
|
let r = e.create(t);
|
|
6785
6856
|
return n(r), r;
|
|
6786
|
-
},
|
|
6857
|
+
}, cs = () => {
|
|
6787
6858
|
let e = typeof location > "u" ? void 0 : location.origin;
|
|
6788
6859
|
return e && e !== "null" ? e : void 0;
|
|
6789
|
-
},
|
|
6860
|
+
}, ls = (e) => {
|
|
6790
6861
|
let t = new URL(e).origin;
|
|
6791
6862
|
if (t === "null") throw Error(`Passflow: "${e}" has no origin a request can be matched against; list http(s) origins only.`);
|
|
6792
6863
|
return t;
|
|
6793
|
-
},
|
|
6794
|
-
let n = (t?.origins ?? []).map(
|
|
6864
|
+
}, us = (e, t) => {
|
|
6865
|
+
let n = (t?.origins ?? []).map(ls);
|
|
6795
6866
|
return (t, r) => {
|
|
6796
6867
|
if (r) return Promise.resolve(void 0);
|
|
6797
|
-
let i =
|
|
6868
|
+
let i = cs(), a;
|
|
6798
6869
|
try {
|
|
6799
6870
|
a = new URL(t, i).origin;
|
|
6800
6871
|
} catch {
|
|
@@ -6802,22 +6873,22 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6802
6873
|
}
|
|
6803
6874
|
return a !== i && !n.includes(a) ? Promise.resolve(void 0) : e();
|
|
6804
6875
|
};
|
|
6805
|
-
},
|
|
6806
|
-
let r =
|
|
6876
|
+
}, ds = (e) => typeof Request < "u" && e instanceof Request, fs = (e, t) => new Headers(t?.headers === void 0 ? ds(e) ? e.headers : void 0 : t.headers), ps = (e, t, n) => {
|
|
6877
|
+
let r = us(t, n);
|
|
6807
6878
|
return async (t, n) => {
|
|
6808
|
-
let i =
|
|
6879
|
+
let i = ds(t) ? t.url : t instanceof URL ? t.href : String(t), a = fs(t, n), o = await r(i, a.has("authorization"));
|
|
6809
6880
|
return o ? (a.set("authorization", `Bearer ${o}`), e(t, {
|
|
6810
6881
|
...n,
|
|
6811
6882
|
headers: a
|
|
6812
6883
|
})) : e(t, n);
|
|
6813
6884
|
};
|
|
6814
|
-
},
|
|
6885
|
+
}, ms = (e) => {
|
|
6815
6886
|
let t = e.url ?? "", n = /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
|
|
6816
6887
|
return !e.baseURL || n && e.allowAbsoluteUrls !== !1 ? t : t ? `${e.baseURL.replace(/\/?\/$/, "")}/${t.replace(/^\/+/, "")}` : e.baseURL;
|
|
6817
|
-
},
|
|
6818
|
-
let n =
|
|
6888
|
+
}, hs = (e) => e ? typeof e.has == "function" ? e.has("Authorization") : Object.keys(e).some((t) => t.toLowerCase() === "authorization" && e[t] != null) : !1, gs = (e, t) => {
|
|
6889
|
+
let n = us(e, t);
|
|
6819
6890
|
return async (e) => {
|
|
6820
|
-
let t = e.headers, r = await n(
|
|
6891
|
+
let t = e.headers, r = await n(ms(e), hs(t));
|
|
6821
6892
|
if (!r) return e;
|
|
6822
6893
|
let i = `Bearer ${r}`;
|
|
6823
6894
|
return t && typeof t.set == "function" ? t.set("Authorization", i) : e.headers = {
|
|
@@ -6825,7 +6896,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6825
6896
|
Authorization: i
|
|
6826
6897
|
}, e;
|
|
6827
6898
|
};
|
|
6828
|
-
},
|
|
6899
|
+
}, _s = 0, vs = (e, t) => {
|
|
6829
6900
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
6830
6901
|
if (n) return {
|
|
6831
6902
|
get aborted() {
|
|
@@ -6839,34 +6910,34 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6839
6910
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
6840
6911
|
} : {}
|
|
6841
6912
|
};
|
|
6842
|
-
},
|
|
6913
|
+
}, ys = (e) => (t) => e.headers?.get(t), bs = (e, t, n, r, i) => ({
|
|
6843
6914
|
status: e.status,
|
|
6844
|
-
getHeader:
|
|
6915
|
+
getHeader: ys(e),
|
|
6845
6916
|
readBody: () => e.clone().json(),
|
|
6846
6917
|
request: t.snapshot,
|
|
6847
|
-
replay: async (e) =>
|
|
6918
|
+
replay: async (e) => bs(await t.replay(n, e), t, n, r, i),
|
|
6848
6919
|
markers: r,
|
|
6849
6920
|
raw: e,
|
|
6850
6921
|
replayable: t.replayable,
|
|
6851
6922
|
replayUnsupportedReason: t.reason,
|
|
6852
6923
|
signal: i,
|
|
6853
6924
|
responseType: e.type
|
|
6854
|
-
}),
|
|
6925
|
+
}), xs = (e, t) => {
|
|
6855
6926
|
let n = (t, n) => {
|
|
6856
|
-
|
|
6927
|
+
_s += 1;
|
|
6857
6928
|
try {
|
|
6858
6929
|
return e(t, n);
|
|
6859
6930
|
} finally {
|
|
6860
|
-
--
|
|
6931
|
+
--_s;
|
|
6861
6932
|
}
|
|
6862
6933
|
};
|
|
6863
6934
|
return async (e, r) => {
|
|
6864
|
-
if (
|
|
6865
|
-
let i =
|
|
6935
|
+
if (_s > 0) return n(e, r);
|
|
6936
|
+
let i = Ka(t), a = Zo(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = uo(await co(bs(o, a, n, {}, vs(e, r)), i), o, i);
|
|
6866
6937
|
if (s.settle === "reject") throw s.error;
|
|
6867
6938
|
return s.value;
|
|
6868
6939
|
};
|
|
6869
|
-
},
|
|
6940
|
+
}, Ss = new Set(wa.filter((e) => !e.requiresPrepare).map((e) => e.type)), Cs = (e) => {
|
|
6870
6941
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
6871
6942
|
kind: "protocol",
|
|
6872
6943
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -6878,17 +6949,17 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6878
6949
|
webauthn: e.webauthn,
|
|
6879
6950
|
codeSentTo: e.code_sent_to
|
|
6880
6951
|
};
|
|
6881
|
-
},
|
|
6952
|
+
}, ws = (e) => ki(e) && !Ai(e), Ts = (e) => ({
|
|
6882
6953
|
async prepare(t) {
|
|
6883
|
-
if (!
|
|
6954
|
+
if (!Ss.has(t)) try {
|
|
6884
6955
|
let n = e.relyingPartyId?.();
|
|
6885
|
-
return
|
|
6956
|
+
return Cs(await e.startUpgrade(n ? {
|
|
6886
6957
|
method: t,
|
|
6887
6958
|
relying_party_id: n
|
|
6888
6959
|
} : { method: t }));
|
|
6889
6960
|
} catch (e) {
|
|
6890
|
-
if (
|
|
6891
|
-
let t =
|
|
6961
|
+
if (ws(e)) throw e;
|
|
6962
|
+
let t = Ii(e, "start");
|
|
6892
6963
|
if (t.kind === "prepare_not_required") return;
|
|
6893
6964
|
throw t;
|
|
6894
6965
|
}
|
|
@@ -6905,17 +6976,17 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6905
6976
|
assertion: n
|
|
6906
6977
|
});
|
|
6907
6978
|
} catch (t) {
|
|
6908
|
-
if (
|
|
6909
|
-
let n =
|
|
6910
|
-
throw n.status === 401 &&
|
|
6979
|
+
if (ws(t)) throw t;
|
|
6980
|
+
let n = Ii(t, "refresh");
|
|
6981
|
+
throw n.status === 401 && Ri(n) && e.markSessionInvalid?.(), n;
|
|
6911
6982
|
}
|
|
6912
6983
|
}
|
|
6913
|
-
}),
|
|
6984
|
+
}), Es = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Ds = (e) => {
|
|
6914
6985
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
6915
6986
|
let i = () => {
|
|
6916
6987
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
6917
6988
|
};
|
|
6918
|
-
return
|
|
6989
|
+
return Ts({
|
|
6919
6990
|
...e,
|
|
6920
6991
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
6921
6992
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -6926,7 +6997,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6926
6997
|
});
|
|
6927
6998
|
}, i = (t, n) => {
|
|
6928
6999
|
let i = {}, a = {
|
|
6929
|
-
controller: new
|
|
7000
|
+
controller: new Ga({
|
|
6930
7001
|
transport: r(() => i.current),
|
|
6931
7002
|
prompt: t.prompt,
|
|
6932
7003
|
platform: e.platform,
|
|
@@ -6938,7 +7009,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6938
7009
|
options: t,
|
|
6939
7010
|
scope: {
|
|
6940
7011
|
passflow: e.passflowDomain,
|
|
6941
|
-
backend:
|
|
7012
|
+
backend: Es(t.backend)
|
|
6942
7013
|
},
|
|
6943
7014
|
generation: n
|
|
6944
7015
|
};
|
|
@@ -6948,17 +7019,17 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6948
7019
|
s = void 0;
|
|
6949
7020
|
});
|
|
6950
7021
|
let c = (e) => {
|
|
6951
|
-
if (!s ||
|
|
7022
|
+
if (!s || Wa(s.challenge, e)) return;
|
|
6952
7023
|
let t = Math.min(o, e.maxAge === void 0 ? o : e.maxAge * 1e3);
|
|
6953
7024
|
if (!(Date.now() - s.at > t)) return s.challenge;
|
|
6954
7025
|
}, l = async (r, i) => {
|
|
6955
7026
|
let o = t;
|
|
6956
|
-
if (!o) throw new
|
|
7027
|
+
if (!o) throw new Bi("Step-up verification is not enabled on this Passflow instance");
|
|
6957
7028
|
let l = e.stopRepeatedElevation ? c(r) : void 0;
|
|
6958
|
-
if (l) throw new
|
|
7029
|
+
if (l) throw new zi(Va(l), Va(r), "This requirement was already proved and the server still refused it: sign the user in again");
|
|
6959
7030
|
o.controller.active || (o.pin = e.readSessionPin?.());
|
|
6960
7031
|
let u = await o.controller.elevate(r, i);
|
|
6961
|
-
if (!n(o)) throw new
|
|
7032
|
+
if (!n(o)) throw new Vi();
|
|
6962
7033
|
return e.stopRepeatedElevation && (s = {
|
|
6963
7034
|
challenge: r,
|
|
6964
7035
|
at: a ?? Date.now()
|
|
@@ -7005,9 +7076,9 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7005
7076
|
let r = [];
|
|
7006
7077
|
if (e.attachInternalSeam) {
|
|
7007
7078
|
let t = e.attachInternalSeam;
|
|
7008
|
-
t((e) =>
|
|
7079
|
+
t((e) => as(u, e)), r.push(() => t(void 0));
|
|
7009
7080
|
}
|
|
7010
|
-
n.interceptFetch && r.push(
|
|
7081
|
+
n.interceptFetch && r.push(cn((e, t, n) => xs(e, u)(t, n), {
|
|
7011
7082
|
priority: 20,
|
|
7012
7083
|
name: "passflow-upgrade"
|
|
7013
7084
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -7039,8 +7110,8 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7039
7110
|
enumerable: !0,
|
|
7040
7111
|
value: (t, n) => {
|
|
7041
7112
|
let r = (t) => {
|
|
7042
|
-
let r =
|
|
7043
|
-
return e.readAccessToken ?
|
|
7113
|
+
let r = xs(t, u);
|
|
7114
|
+
return e.readAccessToken ? ps(r, e.readAccessToken, n) : r;
|
|
7044
7115
|
};
|
|
7045
7116
|
if (t) return r(t);
|
|
7046
7117
|
let i = typeof globalThis > "u" ? void 0 : globalThis;
|
|
@@ -7051,14 +7122,14 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7051
7122
|
attachAuth: {
|
|
7052
7123
|
enumerable: !0,
|
|
7053
7124
|
value: (t, n) => {
|
|
7054
|
-
let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(
|
|
7125
|
+
let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(gs(e.readAccessToken, n)), a = os(t, u);
|
|
7055
7126
|
return () => {
|
|
7056
7127
|
a(), r && i !== void 0 && r.eject(i);
|
|
7057
7128
|
};
|
|
7058
7129
|
}
|
|
7059
7130
|
}
|
|
7060
7131
|
});
|
|
7061
|
-
},
|
|
7132
|
+
}, Os, ks = class {
|
|
7062
7133
|
get origin() {
|
|
7063
7134
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
7064
7135
|
}
|
|
@@ -7071,9 +7142,9 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7071
7142
|
prefix: e.keyStoragePrefix ?? "",
|
|
7072
7143
|
storage: this.platform.storage,
|
|
7073
7144
|
appId: n
|
|
7074
|
-
}), this.deviceService = new de(this.storageManager), this.authApi = new
|
|
7075
|
-
let i =
|
|
7076
|
-
this.authService = new
|
|
7145
|
+
}), this.deviceService = new de(this.storageManager), this.authApi = new It(e, this.storageManager, this.deviceService), this.appApi = new kt(e, this.storageManager, this.deviceService), this.userApi = new qt(e, this.storageManager, this.deviceService), this.settingApi = new zt(e, this.storageManager, this.deviceService), this.tenantApi = new Bt(e, this.storageManager, this.deviceService), this.invitationApi = new Rt(e, this.storageManager, this.deviceService), this.twoFactorApi = new Gt(e, this.storageManager, this.deviceService), this.upgradeApi = new Kt(e, this.storageManager, this.deviceService), this.upgradeDomain = Be(e.url), this.subscribeStore = new Un(), this.tokenCacheService = new ga(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? _, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
|
|
7146
|
+
let i = Lr(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
|
|
7147
|
+
this.authService = new fa(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
|
|
7077
7148
|
createSession: async (e) => {
|
|
7078
7149
|
await this.createSessionCallback?.(e);
|
|
7079
7150
|
},
|
|
@@ -7083,7 +7154,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7083
7154
|
}, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
|
|
7084
7155
|
coordination: i,
|
|
7085
7156
|
...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
|
|
7086
|
-
}, () => this.readAppSettings()), this.antiBot =
|
|
7157
|
+
}, () => this.readAppSettings()), this.antiBot = ar({
|
|
7087
7158
|
readSettings: () => this.readAppSettings(),
|
|
7088
7159
|
fetchChallenge: ({ identifier: e, device: t }) => t ? this.authApi.deviceAntiBotChallenge({
|
|
7089
7160
|
user_code: t.userCode,
|
|
@@ -7093,7 +7164,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7093
7164
|
...e.antiBotWorkerUrl ? { workerUrl: e.antiBotWorkerUrl } : {}
|
|
7094
7165
|
}), this.authApi.setAntiBotHandler((e) => this.antiBot.headerFor(e)), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
7095
7166
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
7096
|
-
this.userService = new
|
|
7167
|
+
this.userService = new va(this.userApi, this.deviceService, this.platform), this.tenantService = new ha(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new pa(this.invitationApi), this.twoFactorService = new _a(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Ds({
|
|
7097
7168
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
7098
7169
|
commitRefresh: async (e, t) => {
|
|
7099
7170
|
await this.authService.refreshToken(e, t);
|
|
@@ -7122,7 +7193,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7122
7193
|
let e = (await this.getTokens(!0))?.access_token;
|
|
7123
7194
|
return e && !A(j(e)) ? e : void 0;
|
|
7124
7195
|
}
|
|
7125
|
-
}), this.hostedUpgrade =
|
|
7196
|
+
}), this.hostedUpgrade = Ds({
|
|
7126
7197
|
startUpgrade: (e) => this.upgradeApi.startHostedUpgrade(e),
|
|
7127
7198
|
commitRefresh: (e) => this.upgradeApi.commitHostedUpgrade(e),
|
|
7128
7199
|
canCommit: () => ({ ok: !0 }),
|
|
@@ -7150,7 +7221,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7150
7221
|
return this.readAppSettings().then((e) => e?.pkce_enabled ?? !1);
|
|
7151
7222
|
}
|
|
7152
7223
|
setAppId(e) {
|
|
7153
|
-
this.appId = e, this.storageManager.setAppId(e), this.appSettingsRead = void 0, this.authApi.setAppId(e), this.appApi.setAppId(e), this.userApi.setAppId(e), this.settingApi.setAppId(e), this.tenantApi.setAppId(e), this.invitationApi.setAppId(e), this.twoFactorApi.setAppId(e), this.upgradeApi.setAppId(e), this.authService.setAppId(e);
|
|
7224
|
+
e !== this.appId && (this.appId = e, this.storageManager.setAppId(e), this.appSettingsRead = void 0, this.authApi.setAppId(e), this.appApi.setAppId(e), this.userApi.setAppId(e), this.settingApi.setAppId(e), this.tenantApi.setAppId(e), this.invitationApi.setAppId(e), this.twoFactorApi.setAppId(e), this.upgradeApi.setAppId(e), this.authService.setAppId(e), this.tokenCacheService.setTokensCache(void 0), this.setTokensToCacheFromLocalStorage());
|
|
7154
7225
|
}
|
|
7155
7226
|
withAuth(e, t) {
|
|
7156
7227
|
return this.upgrade.withAuth(e, t);
|
|
@@ -7159,7 +7230,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7159
7230
|
return this.upgrade.attachAuth(e, t);
|
|
7160
7231
|
}
|
|
7161
7232
|
createClient(e, t) {
|
|
7162
|
-
return
|
|
7233
|
+
return ss(e, (e) => this.upgrade.attachAuth(e, t));
|
|
7163
7234
|
}
|
|
7164
7235
|
readAssuranceBar() {
|
|
7165
7236
|
let e = this.storageManager.getToken(M.access_token);
|
|
@@ -7242,7 +7313,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7242
7313
|
}
|
|
7243
7314
|
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;
|
|
7244
7315
|
if (n) {
|
|
7245
|
-
if (!
|
|
7316
|
+
if (!Wi(n)) {
|
|
7246
7317
|
W(this.subscribeStore, {
|
|
7247
7318
|
operation: "tokens.from-url",
|
|
7248
7319
|
message: "Invalid access token format received",
|
|
@@ -7250,7 +7321,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7250
7321
|
}), this.cleanupUrlParams(e);
|
|
7251
7322
|
return;
|
|
7252
7323
|
}
|
|
7253
|
-
if (r && !
|
|
7324
|
+
if (r && !Wi(r)) {
|
|
7254
7325
|
W(this.subscribeStore, {
|
|
7255
7326
|
operation: "tokens.from-url",
|
|
7256
7327
|
message: "Invalid refresh token format received",
|
|
@@ -7258,7 +7329,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7258
7329
|
}), this.cleanupUrlParams(e);
|
|
7259
7330
|
return;
|
|
7260
7331
|
}
|
|
7261
|
-
if (i && !
|
|
7332
|
+
if (i && !Wi(i)) {
|
|
7262
7333
|
W(this.subscribeStore, {
|
|
7263
7334
|
operation: "tokens.from-url",
|
|
7264
7335
|
message: "Invalid ID token format received",
|
|
@@ -7273,8 +7344,8 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7273
7344
|
scopes: o
|
|
7274
7345
|
};
|
|
7275
7346
|
this.cleanupUrlParams(e), this.error = void 0, this.readAppSettings().catch(() => void 0).then((e) => {
|
|
7276
|
-
if (e?.pkce_enabled !== !1) throw
|
|
7277
|
-
return
|
|
7347
|
+
if (e?.pkce_enabled !== !1) throw kn();
|
|
7348
|
+
return Si(this.url, this.appId, t);
|
|
7278
7349
|
}).then(() => {
|
|
7279
7350
|
this.storageManager.clearDeliveryMode(), this.storageManager.saveTokens(t, void 0, { replace: !0 }), e && this.storageManager.setHostedSignIn(e.origin + e.pathname), this.tokenCacheService.setTokensCache(t), this.authService.refresh.sessionStarted();
|
|
7280
7351
|
}).then(() => (this.subscribeStore.notify(G.SignIn, {
|
|
@@ -7309,7 +7380,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7309
7380
|
if (!n) return !1;
|
|
7310
7381
|
t.delete("tfa_token");
|
|
7311
7382
|
let r = t.toString();
|
|
7312
|
-
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")),
|
|
7383
|
+
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), Wi(n) ? (this.subscribeStore.notify(G.TwoFactorRequired, {
|
|
7313
7384
|
email: "",
|
|
7314
7385
|
challengeId: "",
|
|
7315
7386
|
tfaToken: n
|
|
@@ -7322,7 +7393,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7322
7393
|
checkErrorsFromURL() {
|
|
7323
7394
|
let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
|
|
7324
7395
|
if (e) {
|
|
7325
|
-
let t =
|
|
7396
|
+
let t = Gi(e);
|
|
7326
7397
|
return Error(t);
|
|
7327
7398
|
}
|
|
7328
7399
|
}
|
|
@@ -7457,6 +7528,23 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7457
7528
|
federatedAuthWithRedirect(e, t) {
|
|
7458
7529
|
this.authService.federatedAuthWithRedirect(e, t);
|
|
7459
7530
|
}
|
|
7531
|
+
async enterpriseResolve(e) {
|
|
7532
|
+
try {
|
|
7533
|
+
return await this.authApi.enterpriseResolve(e);
|
|
7534
|
+
} catch (e) {
|
|
7535
|
+
this.handleError(e, "enterprise.resolve", "Enterprise resolve");
|
|
7536
|
+
}
|
|
7537
|
+
}
|
|
7538
|
+
createEnterpriseAuthUrl(e) {
|
|
7539
|
+
return this.authService.createEnterpriseAuthUrl(e);
|
|
7540
|
+
}
|
|
7541
|
+
async enterpriseStart(e, t) {
|
|
7542
|
+
try {
|
|
7543
|
+
return await this.authService.enterpriseStart(e, t);
|
|
7544
|
+
} catch (e) {
|
|
7545
|
+
this.handleError(e, "enterprise.start", "Enterprise start");
|
|
7546
|
+
}
|
|
7547
|
+
}
|
|
7460
7548
|
reset(e) {
|
|
7461
7549
|
if (this.notifySignedOut(this.authService.resetSession()), e) {
|
|
7462
7550
|
this.error = Error(e);
|
|
@@ -7772,7 +7860,7 @@ var ta = 10, na = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7772
7860
|
this.twoFactorService.clearMagicLinkSession();
|
|
7773
7861
|
}
|
|
7774
7862
|
};
|
|
7775
|
-
|
|
7776
|
-
export { p as AGENT_TOOL_HEADER_KEY, m as ANTI_BOT_ACTION, Ke as ANTI_BOT_FAILED_ERROR_ID, f as ANTI_BOT_HEADER_KEY, Ye as ANTI_BOT_PROVIDER_FAILED_ERROR_ID, Je as ANTI_BOT_PROVIDER_MISSING_ERROR_ID, Ge as ANTI_BOT_REQUIRED_ERROR_ID, Xe as ANTI_BOT_SOLVE_FAILED_ERROR_ID, qe as ANTI_BOT_UNAVAILABLE_ERROR_ID, c as APP_ID_HEADER_KEY,
|
|
7863
|
+
Os = ks, Os.version = h;
|
|
7864
|
+
export { p as AGENT_TOOL_HEADER_KEY, m as ANTI_BOT_ACTION, Ke as ANTI_BOT_FAILED_ERROR_ID, f as ANTI_BOT_HEADER_KEY, Ye as ANTI_BOT_PROVIDER_FAILED_ERROR_ID, Je as ANTI_BOT_PROVIDER_MISSING_ERROR_ID, Ge as ANTI_BOT_REQUIRED_ERROR_ID, Xe as ANTI_BOT_SOLVE_FAILED_ERROR_ID, qe as ANTI_BOT_UNAVAILABLE_ERROR_ID, c as APP_ID_HEADER_KEY, rt as APP_SECRET_NAMES, l as AUTHORIZATION_HEADER_KEY, kt as AppAPI, It as AuthAPI, fa as AuthService, Lt as CLIAuthAPI, y as DEFAULT_GROUP_NAME, _ as DEFAULT_SCOPES, wa as DEFAULT_UPGRADE_FACTORS, u as DEVICE_ID_HEADER_KEY, d as DEVICE_TYPE_HEADER_KEY, et as ENTERPRISE_CONNECTION_AMBIGUOUS_ERROR_ID, Ze as ENTERPRISE_EMAIL_INVALID_ERROR_ID, $e as ENTERPRISE_NO_CONNECTION_ERROR_ID, Qe as ENTERPRISE_START_INPUT_ERROR_ID, E as ERROR_MESSAGE_MAX_LENGTH, Jt as FETCH_PRIORITY_OIDC, Yt as FETCH_PRIORITY_UPGRADE, Xt as FetchMiddlewareContractError, ve as INSUFFICIENT_USER_AUTHENTICATION, Rt as InvitationAPI, pa as InvitationService, _n as M2MClient, fn as M2MConfigError, H as M2MError, pn as M2MErrorCodes, un as M2MNetworkError, dn as M2MTokenParseError, mn as M2M_DEFAULTS, it as MASKED_SECRET_PREFIX, g as MINIMAL_DEFAULT_SCOPES, st as OS, v as PASSFLOW_CLOUD_URL, We as PASSWORD_CHANGE_REQUIRED_ERROR_ID, x as POPUP_HEIGHT, ee as POPUP_POLL_INTERVAL_MS, S as POPUP_TIMEOUT_MS, b as POPUP_WIDTH, ks as Passflow, ze as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, B as PassflowError, G as PassflowEvent, U as PassflowOidcError, tt as PassflowPasswordChangeRequiredError, Y as PassflowRefreshError, fe as PopupClosedError, nt as Providers, Ci as RECOVERABLE_COMMIT_ERROR_IDS, Br as REFRESH_AUTH_FAILURE_IDS, J as RefreshErrorId, Re as RequestMethod, h as SDK_VERSION, He as SERVICE_UNAVAILABLE_ERROR_ID, Ue as SERVICE_UNAVAILABLE_MESSAGE, wi as SESSION_INVALIDATING_COMMIT_ERROR_IDS, at as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, se as SessionState, zt as SettingAPI, C as TOKEN_EXPIRY_BUFFER_SECONDS, Bt as TenantAPI, ha as TenantService, ma as TenantUserMembership, ga as TokenCacheService, N as TokenDeliveryMode, M as TokenType, Gt as TwoFactorApiClient, ut as TwoFactorPolicy, _a as TwoFactorService, ye as UPGRADE_REQUIRED, T as USERNAME_MAX_LENGTH, w as USERNAME_MIN_LENGTH, Kt as UpgradeAPI, ja as UpgradeCancelledError, Qr as UpgradeCommitInterruptedError, Ga as UpgradeController, Q as UpgradeErrorIds, ya as UpgradeFactorError, zi as UpgradeInsufficientError, Vi as UpgradeSessionChangedError, Ma as UpgradeSignInRequiredError, $ as UpgradeTransportError, Bi as UpgradeUnavailableError, La as UpgradeUnsatisfiableError, qt as UserAPI, va as UserService, L as WebAdapter, Ii as classifyUpgradeError, Ta as factorRegistry, ln as fetchRegistryState, ct as getOSFromDeviceType, Ri as invalidatesSessionOnCommit, Ve as isEmailVerificationStep, ot as isMaskedSecret, Li as isRecoverableCommitFailure, Ei as isRetryableUpgradeKind, A as isTokenExpired, So as isUpgradeCancelled, Co as isUpgradeExhausted, wo as isUpgradeInsufficient, Oo as isUpgradeSessionChanged, Eo as isUpgradeSignInRequired, Ai as isUpgradeTransportError, ko as isUpgradeTransportFailure, Do as isUpgradeUnavailable, To as isUpgradeUnsatisfiable, Ki as isValidEmail, Wi as isValidJWTFormat, qi as isValidPhoneNumber, Ji as isValidUsername, Ee as parseChallengeBody, Te as parseChallengeHeader, j as parseToken, Ae as parseUpgradeChallenge, Ca as passkeyFactor, lt as pathWithParams, Sa as recoveryCodesFactor, cn as registerFetchMiddleware, _e as requiredAcrLevel, Be as resolveUpgradeDomain, Gi as sanitizeErrorMessage, Aa as selectFactors, xa as totpFactor, R as webAdapter };
|
|
7777
7865
|
|
|
7778
7866
|
//# sourceMappingURL=index.mjs.map
|