@passflow/core 0.37.1 → 0.39.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 +83 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +363 -138
- package/dist/index.d.ts +363 -138
- package/dist/index.mjs +836 -729
- 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.39.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.TwoFactorPreferredMethod = "/v2/user/2fa/preferred-method", 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;
|
|
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.userProfile = "/user/profile", e.AddressChangeProof = "/v2/user/address-change/proof", 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.TwoFactorPreferredMethod = "/v2/user/2fa/preferred-method", 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) => {
|
|
@@ -697,37 +697,53 @@ var M = /* @__PURE__ */ function(e) {
|
|
|
697
697
|
constructor(e, t) {
|
|
698
698
|
super(e, t), this.name = "PassflowPasswordChangeRequiredError";
|
|
699
699
|
}
|
|
700
|
-
}, nt =
|
|
700
|
+
}, nt = "error.2fa.sms.quota.exceeded", rt = "error.2fa.rate_limit_exceeded", it = "error.2fa.recovery_codes.step_up_required", at = "error.user.address.change.proof.required", ot = class extends B {
|
|
701
|
+
constructor(e, t) {
|
|
702
|
+
super(e, t), this.name = "PassflowSmsQuotaExceededError";
|
|
703
|
+
}
|
|
704
|
+
}, st = class extends B {
|
|
705
|
+
constructor(e, t, n) {
|
|
706
|
+
super(e, n), this.name = "PassflowSendLimitError", this.retryAfter = t;
|
|
707
|
+
}
|
|
708
|
+
}, ct = class extends B {
|
|
709
|
+
constructor(e, t, n) {
|
|
710
|
+
super(e, n), this.name = "PassflowRecoveryCodesStepUpRequiredError", this.challenge = t;
|
|
711
|
+
}
|
|
712
|
+
}, lt = class extends B {
|
|
713
|
+
constructor(e, t) {
|
|
714
|
+
super(e, t), this.name = "PassflowAddressChangeProofRequiredError";
|
|
715
|
+
}
|
|
716
|
+
}, ut = /* @__PURE__ */ function(e) {
|
|
701
717
|
return e.google = "google", e.facebook = "facebook", e;
|
|
702
|
-
}({}),
|
|
718
|
+
}({}), dt = Object.freeze([
|
|
703
719
|
"debug_otp_code_for_registration",
|
|
704
720
|
"fcm_server_key",
|
|
705
721
|
"webpush_vapid_private_key"
|
|
706
|
-
]),
|
|
722
|
+
]), ft = "mask://", pt = "error.server.update.settings.masked.value.unknown", mt = (e) => typeof e == "string" && e.startsWith("mask://"), ht = /* @__PURE__ */ function(e) {
|
|
707
723
|
return e.web = "web", e.ios = "ios", e.android = "android", e;
|
|
708
724
|
}({});
|
|
709
|
-
function
|
|
725
|
+
function gt(e) {
|
|
710
726
|
return e;
|
|
711
727
|
}
|
|
712
|
-
function
|
|
728
|
+
function _t(e, t) {
|
|
713
729
|
let n = e;
|
|
714
730
|
return Object.entries(t).forEach(([e, t]) => {
|
|
715
731
|
n = n.replace(`:${e}`, t);
|
|
716
732
|
}), n;
|
|
717
733
|
}
|
|
718
|
-
var
|
|
734
|
+
var vt = /* @__PURE__ */ function(e) {
|
|
719
735
|
return e.Disabled = "disabled", e.Optional = "optional", e.Required = "required", e;
|
|
720
|
-
}({}),
|
|
736
|
+
}({}), yt = 3, bt = 1e3, xt = (e) => (t) => {
|
|
721
737
|
let n = e.headers?.[t] ?? e.headers?.[t.toLowerCase()];
|
|
722
738
|
return Array.isArray(n) ? n.join(", ") : n;
|
|
723
|
-
},
|
|
739
|
+
}, St = (e) => Ae(e.status, xt(e), e.data), Ct = (e) => St(e) !== void 0, wt = (e) => {
|
|
724
740
|
let t = e.response?.data?.error;
|
|
725
741
|
return typeof t?.id == "string" ? t.id : void 0;
|
|
726
|
-
},
|
|
742
|
+
}, Tt = (n) => e.isAxiosError(n) && !n.response && (n.code === t.ERR_NETWORK || !n.code && n.cause instanceof TypeError), Et = [
|
|
727
743
|
502,
|
|
728
744
|
503,
|
|
729
745
|
504
|
|
730
|
-
],
|
|
746
|
+
], Dt = (e) => typeof e == "object" && !!e && typeof e.error == "object" && e.error !== null, Ot = (e, n) => {
|
|
731
747
|
let r = new t(e.message, e.code);
|
|
732
748
|
return e.cause instanceof TypeError && (r.cause = e.cause), new B({
|
|
733
749
|
id: He,
|
|
@@ -736,10 +752,32 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
736
752
|
location: e.config?.url ?? "unknown",
|
|
737
753
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
738
754
|
}, { cause: r });
|
|
739
|
-
},
|
|
755
|
+
}, kt = (e) => e?.includes(z.refresh) ?? !1, At = (e) => e?.includes("/auth/session/") ?? !1, jt = (e) => e?.includes("logout") ?? !1, Mt = "__passflowOwnBearer", Nt = "__passflowRefreshedAfter401", Pt = (e) => typeof e == "object" && !!e && e[Mt] === !0, Ft = (e) => e ? {
|
|
740
756
|
headers: { [l]: `Bearer ${e}` },
|
|
741
|
-
[
|
|
742
|
-
} : {},
|
|
757
|
+
[Mt]: !0
|
|
758
|
+
} : {}, It = "__passflowSendRefusal", Lt = (e) => typeof e == "object" && !!e && e[It] === !0, Rt = (e = {}) => ({
|
|
759
|
+
...e,
|
|
760
|
+
[It]: !0
|
|
761
|
+
}), zt = (e) => {
|
|
762
|
+
let t = e ? xt(e)("Retry-After")?.trim() : void 0;
|
|
763
|
+
if (!t) return;
|
|
764
|
+
if (/^\d+$/.test(t)) return Number.parseInt(t, 10);
|
|
765
|
+
let n = Date.parse(t);
|
|
766
|
+
return Number.isNaN(n) ? void 0 : Math.max(0, Math.ceil((n - Date.now()) / 1e3));
|
|
767
|
+
}, Bt = (e) => {
|
|
768
|
+
let t = e.response?.data;
|
|
769
|
+
if (!Dt(t)) return;
|
|
770
|
+
let { error: n } = t;
|
|
771
|
+
switch (n.id) {
|
|
772
|
+
case nt: return new ot(n);
|
|
773
|
+
case rt: return new st(n, zt(e.response));
|
|
774
|
+
default: return;
|
|
775
|
+
}
|
|
776
|
+
}, Vt = {
|
|
777
|
+
acrValues: "2",
|
|
778
|
+
requiredLevel: 2,
|
|
779
|
+
status: 403
|
|
780
|
+
}, Ht = class {
|
|
743
781
|
get origin() {
|
|
744
782
|
return this._platform.getCurrentUrl()?.origin ?? "";
|
|
745
783
|
}
|
|
@@ -777,17 +815,17 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
777
815
|
let n = await this.antiBotHandler(t);
|
|
778
816
|
n && (e.headers[f] = n.value, t.builtin = n.builtin);
|
|
779
817
|
}
|
|
780
|
-
if (this.isNonAuthEndpoint(e.url) ||
|
|
818
|
+
if (this.isNonAuthEndpoint(e.url) || Pt(e) || At(e.url)) return e;
|
|
781
819
|
if (this.storageManager.getDeliveryMode() === N.Cookie) {
|
|
782
820
|
e.withCredentials = !0;
|
|
783
821
|
let t = this.storageManager.getCsrfToken();
|
|
784
822
|
return t && (e.headers["X-CSRF-Token"] = t), e;
|
|
785
823
|
}
|
|
786
|
-
if (
|
|
824
|
+
if (kt(e.url)) return e;
|
|
787
825
|
let n = this.storageManager.getTokens();
|
|
788
826
|
if (!n?.access_token) return e;
|
|
789
827
|
let r = n.access_token;
|
|
790
|
-
if (this.refreshHandler && n.refresh_token && !
|
|
828
|
+
if (this.refreshHandler && n.refresh_token && !jt(e.url)) {
|
|
791
829
|
let e = j(n.access_token);
|
|
792
830
|
if (A(e, 30)) {
|
|
793
831
|
let t = !A(e, 0);
|
|
@@ -803,25 +841,29 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
803
841
|
}
|
|
804
842
|
return e.headers[l] = `Bearer ${r}`, e;
|
|
805
843
|
}), this.instance.interceptors.response.use((e) => e, async (e) => {
|
|
806
|
-
if (e.response?.status === 401 && !
|
|
844
|
+
if (e.response?.status === 401 && !kt(e.config?.url) && !At(e.config?.url) && !Pt(e.config) && !this.isUpgradeTransactionError(e)) {
|
|
807
845
|
if (e.config && await this.refreshedAfterUnauthorized(e.config)) return this.instance.request(e.config);
|
|
808
846
|
this.tokenDeliveryManager.setSessionInvalid();
|
|
809
847
|
}
|
|
810
848
|
let t = o(e.config);
|
|
811
|
-
if (e.config && e.response?.status === 403 &&
|
|
812
|
-
if (e.response && this.upgradeHandler && !
|
|
813
|
-
let t =
|
|
849
|
+
if (e.config && e.response?.status === 403 && wt(e) === "error.api.anti_bot.failed" && t?.builtin && !t.retried) return t.retried = !0, this.instance.request(e.config);
|
|
850
|
+
if (e.response && this.upgradeHandler && !At(e.config?.url)) {
|
|
851
|
+
let t = St(e.response);
|
|
814
852
|
if (t) try {
|
|
815
853
|
return await this.upgradeHandler(e, t);
|
|
816
854
|
} catch (t) {
|
|
817
855
|
if (t !== e) throw t;
|
|
818
856
|
}
|
|
819
857
|
}
|
|
820
|
-
|
|
858
|
+
if (e.response?.status === 429) {
|
|
859
|
+
let t = Lt(e.config) ? Bt(e) : void 0;
|
|
860
|
+
return t ? Promise.reject(t) : await this.handleRateLimitError(e);
|
|
861
|
+
}
|
|
862
|
+
return this.handleAxiosError(e);
|
|
821
863
|
});
|
|
822
864
|
}
|
|
823
865
|
isUpgradeTransactionError(e) {
|
|
824
|
-
return Fe(e.config) || e.response !== void 0 &&
|
|
866
|
+
return Fe(e.config) || e.response !== void 0 && Ct(e.response);
|
|
825
867
|
}
|
|
826
868
|
setUpgradeInterceptor(e) {
|
|
827
869
|
this.upgradeHandler = e;
|
|
@@ -840,8 +882,8 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
840
882
|
}
|
|
841
883
|
async refreshedAfterUnauthorized(e) {
|
|
842
884
|
let t = e, n = this.storageManager.getDeliveryMode();
|
|
843
|
-
if (!this.refreshHandler || t[
|
|
844
|
-
t[
|
|
885
|
+
if (!this.refreshHandler || t[Nt] || n !== N.Cookie && n !== N.BFF || this.isNonAuthEndpoint(e.url) || jt(e.url)) return !1;
|
|
886
|
+
t[Nt] = !0;
|
|
845
887
|
try {
|
|
846
888
|
return await this.refreshHandler({
|
|
847
889
|
trigger: "pre-request",
|
|
@@ -859,7 +901,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
859
901
|
}
|
|
860
902
|
async handleRateLimitError(e) {
|
|
861
903
|
let t = e.config;
|
|
862
|
-
if (!t ||
|
|
904
|
+
if (!t || kt(t.url)) return Promise.reject(e);
|
|
863
905
|
let n = t.method?.toUpperCase();
|
|
864
906
|
if (![
|
|
865
907
|
"GET",
|
|
@@ -867,8 +909,8 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
867
909
|
"OPTIONS"
|
|
868
910
|
].includes(n || "")) return Promise.reject(e);
|
|
869
911
|
let r = t._retryCount || 0;
|
|
870
|
-
if (r >=
|
|
871
|
-
let i =
|
|
912
|
+
if (r >= yt) return Promise.reject(e);
|
|
913
|
+
let i = bt * 2 ** r, a = e.response?.headers?.["retry-after"];
|
|
872
914
|
if (a) {
|
|
873
915
|
let e = Number.parseInt(a, 10);
|
|
874
916
|
if (!Number.isNaN(e)) i = e * 1e3;
|
|
@@ -880,14 +922,19 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
880
922
|
return await new Promise((e) => setTimeout(e, i)), t._retryCount = r + 1, this.instance.request(t);
|
|
881
923
|
}
|
|
882
924
|
async handleAxiosError(e) {
|
|
883
|
-
if (
|
|
925
|
+
if (Tt(e)) return Promise.reject(Ot(e, 0));
|
|
884
926
|
if (!e.response) return Promise.reject(e);
|
|
885
927
|
let t = e.response.status;
|
|
886
|
-
if (
|
|
928
|
+
if (Et.includes(t) && !Dt(e.response.data)) return Promise.reject(Ot(e, t));
|
|
887
929
|
let n = e.response.data;
|
|
888
930
|
if ("error" in n && typeof n.error == "object" && n.error !== null) {
|
|
889
|
-
let { error:
|
|
890
|
-
|
|
931
|
+
let { error: t } = n;
|
|
932
|
+
switch (t.id) {
|
|
933
|
+
case We: return Promise.reject(new tt(t));
|
|
934
|
+
case at: return Promise.reject(new lt(t));
|
|
935
|
+
case it: return Promise.reject(new ct(t, St(e.response) ?? { ...Vt }));
|
|
936
|
+
default: return Promise.reject(new B(t));
|
|
937
|
+
}
|
|
891
938
|
}
|
|
892
939
|
return Promise.reject(new B({
|
|
893
940
|
id: `error.http.${t}`,
|
|
@@ -934,9 +981,9 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
934
981
|
[c]: e
|
|
935
982
|
}, this.instance.defaults.headers[c] = e;
|
|
936
983
|
}
|
|
937
|
-
},
|
|
984
|
+
}, Ut = class {
|
|
938
985
|
constructor(e, t, n) {
|
|
939
|
-
this.axiosClient = new
|
|
986
|
+
this.axiosClient = new Ht(e, t, n);
|
|
940
987
|
}
|
|
941
988
|
setAppId(e) {
|
|
942
989
|
this.axiosClient.setAppId(e);
|
|
@@ -944,7 +991,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
944
991
|
getAppSettings() {
|
|
945
992
|
return this.axiosClient.get(z.appSettings);
|
|
946
993
|
}
|
|
947
|
-
},
|
|
994
|
+
}, Wt = { withCredentials: !0 }, Gt = 15e3, Kt = "X-Passflow-CSRF", qt = "Sign-in failed. Start again.", Jt = "Something went wrong. Try again later.", Yt = (e, t, n, r) => {
|
|
948
995
|
if (e instanceof B) return e;
|
|
949
996
|
let i = e?.response?.data?.error;
|
|
950
997
|
return new B({
|
|
@@ -961,9 +1008,9 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
961
1008
|
...e?.headers,
|
|
962
1009
|
[p]: "1"
|
|
963
1010
|
} } : {}
|
|
964
|
-
},
|
|
1011
|
+
}, Xt = class {
|
|
965
1012
|
constructor(e, t, n) {
|
|
966
|
-
this.axiosClient = new
|
|
1013
|
+
this.axiosClient = new Ht(e, t, n);
|
|
967
1014
|
}
|
|
968
1015
|
setAppId(e) {
|
|
969
1016
|
this.axiosClient.setAppId(e);
|
|
@@ -975,24 +1022,24 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
975
1022
|
try {
|
|
976
1023
|
return await this.axiosClient.post(z.antiBotChallenge, e);
|
|
977
1024
|
} catch (e) {
|
|
978
|
-
throw
|
|
1025
|
+
throw Yt(e, z.antiBotChallenge, "error.anti_bot.challenge", Jt);
|
|
979
1026
|
}
|
|
980
1027
|
}
|
|
981
1028
|
async deviceAntiBotChallenge(e, t) {
|
|
982
1029
|
try {
|
|
983
|
-
return await this.axiosClient.post(z.deviceAntiBotChallenge, e, { headers: { [
|
|
1030
|
+
return await this.axiosClient.post(z.deviceAntiBotChallenge, e, { headers: { [Kt]: t } });
|
|
984
1031
|
} catch (e) {
|
|
985
|
-
throw
|
|
1032
|
+
throw Yt(e, z.deviceAntiBotChallenge, "error.anti_bot.challenge", Jt);
|
|
986
1033
|
}
|
|
987
1034
|
}
|
|
988
1035
|
federatedStart(e, t, n) {
|
|
989
|
-
return this.axiosClient.post(`${z.signInWithProvider}${e}`, t, V(
|
|
1036
|
+
return this.axiosClient.post(`${z.signInWithProvider}${e}`, t, V(Wt, "federated.start", void 0, n));
|
|
990
1037
|
}
|
|
991
1038
|
enterpriseResolve(e) {
|
|
992
1039
|
return this.axiosClient.post(z.enterpriseResolve, { email: e });
|
|
993
1040
|
}
|
|
994
1041
|
enterpriseStart(e, t) {
|
|
995
|
-
return this.axiosClient.post(z.enterpriseStart, e, V(
|
|
1042
|
+
return this.axiosClient.post(z.enterpriseStart, e, V(Wt, "federated.start", e.email, t));
|
|
996
1043
|
}
|
|
997
1044
|
refreshToken(e, t, n, r) {
|
|
998
1045
|
let i = {
|
|
@@ -1008,7 +1055,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1008
1055
|
device: t,
|
|
1009
1056
|
os: n
|
|
1010
1057
|
};
|
|
1011
|
-
return this.axiosClient.post(z.signin, i, V(
|
|
1058
|
+
return this.axiosClient.post(z.signin, i, V(Wt, "sign-in", e.email ?? e.phone ?? e.username, r));
|
|
1012
1059
|
}
|
|
1013
1060
|
signUp(e, t) {
|
|
1014
1061
|
let { create_tenant: n, anonymous: r } = e, i = {
|
|
@@ -1016,16 +1063,16 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1016
1063
|
create_tenant: n ?? !1,
|
|
1017
1064
|
anonymous: r ?? !1
|
|
1018
1065
|
};
|
|
1019
|
-
return this.axiosClient.post(z.signup, i, V(
|
|
1066
|
+
return this.axiosClient.post(z.signup, i, V(Wt, "sign-up", e.user.email ?? e.user.phone_number ?? e.user.username, t));
|
|
1020
1067
|
}
|
|
1021
1068
|
async pkceExchange(e, t) {
|
|
1022
1069
|
try {
|
|
1023
1070
|
return await this.axiosClient.post(z.pkceExchange, {
|
|
1024
1071
|
authz_code: e,
|
|
1025
1072
|
verifier: t
|
|
1026
|
-
},
|
|
1073
|
+
}, Wt);
|
|
1027
1074
|
} catch (e) {
|
|
1028
|
-
throw
|
|
1075
|
+
throw Yt(e, z.pkceExchange, "error.pkce.exchange", qt);
|
|
1029
1076
|
}
|
|
1030
1077
|
}
|
|
1031
1078
|
async passwordlessSignIn(e, t, n, r) {
|
|
@@ -1038,53 +1085,53 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1038
1085
|
try {
|
|
1039
1086
|
return await this.axiosClient.post(z.passwordless, a, V(void 0, "passwordless.start", e.email ?? e.phone, r));
|
|
1040
1087
|
} catch (e) {
|
|
1041
|
-
throw
|
|
1088
|
+
throw Yt(e, z.passwordless, "error.passwordless.start", Jt);
|
|
1042
1089
|
}
|
|
1043
1090
|
}
|
|
1044
1091
|
async passwordlessSignInComplete(e, t) {
|
|
1045
1092
|
try {
|
|
1046
|
-
return await this.axiosClient.post(z.passwordlessComplete, e, V(
|
|
1093
|
+
return await this.axiosClient.post(z.passwordlessComplete, e, V(Wt, void 0, void 0, t));
|
|
1047
1094
|
} catch (e) {
|
|
1048
|
-
throw
|
|
1095
|
+
throw Yt(e, z.passwordlessComplete, "error.passwordless.complete", Jt);
|
|
1049
1096
|
}
|
|
1050
1097
|
}
|
|
1051
1098
|
async passwordlessStatus(e, t) {
|
|
1052
1099
|
try {
|
|
1053
1100
|
return await this.axiosClient.post(z.passwordlessStatus, e, {
|
|
1054
|
-
...
|
|
1055
|
-
timeout:
|
|
1101
|
+
...Wt,
|
|
1102
|
+
timeout: Gt,
|
|
1056
1103
|
signal: t?.signal
|
|
1057
1104
|
});
|
|
1058
1105
|
} catch (e) {
|
|
1059
|
-
throw
|
|
1106
|
+
throw Yt(e, z.passwordlessStatus, "error.passwordless.status", qt);
|
|
1060
1107
|
}
|
|
1061
1108
|
}
|
|
1062
1109
|
async checkRedirectUrl(e) {
|
|
1063
1110
|
try {
|
|
1064
1111
|
return (await this.axiosClient.post(z.redirectCheck, { redirect_url: e })).redirect_url;
|
|
1065
1112
|
} catch (e) {
|
|
1066
|
-
throw
|
|
1113
|
+
throw Yt(e, z.redirectCheck, "error.redirect.check", Jt);
|
|
1067
1114
|
}
|
|
1068
1115
|
}
|
|
1069
1116
|
async passwordlessApprovalInfo(e) {
|
|
1070
1117
|
try {
|
|
1071
1118
|
return await this.axiosClient.post(z.passwordlessApprovalInfo, e);
|
|
1072
1119
|
} catch (e) {
|
|
1073
|
-
throw
|
|
1120
|
+
throw Yt(e, z.passwordlessApprovalInfo, "error.passwordless.approval", Jt);
|
|
1074
1121
|
}
|
|
1075
1122
|
}
|
|
1076
1123
|
async passwordlessApprovalDecide(e) {
|
|
1077
1124
|
try {
|
|
1078
1125
|
return await this.axiosClient.post(z.passwordlessApprovalDecide, e);
|
|
1079
1126
|
} catch (e) {
|
|
1080
|
-
throw
|
|
1127
|
+
throw Yt(e, z.passwordlessApprovalDecide, "error.passwordless.approval", Jt);
|
|
1081
1128
|
}
|
|
1082
1129
|
}
|
|
1083
1130
|
validateEmailCode(e) {
|
|
1084
1131
|
return this.axiosClient.post(z.passkeyValidate, {
|
|
1085
1132
|
challenge_id: e.challenge_id,
|
|
1086
1133
|
otp: e.otp
|
|
1087
|
-
},
|
|
1134
|
+
}, Wt);
|
|
1088
1135
|
}
|
|
1089
1136
|
logOut(e, t, n = !1) {
|
|
1090
1137
|
let r = n ? void 0 : {
|
|
@@ -1125,7 +1172,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1125
1172
|
device: t,
|
|
1126
1173
|
passkey_data: e
|
|
1127
1174
|
}, o = r ? ze.passkeyRegisterComplete : z.passkeyRegisterComplete;
|
|
1128
|
-
return this.axiosClient.post(o, a, V(
|
|
1175
|
+
return this.axiosClient.post(o, a, V(Wt, void 0, void 0, i));
|
|
1129
1176
|
}
|
|
1130
1177
|
passkeyAuthenticateStart(e, t, n, r = !1, i) {
|
|
1131
1178
|
let a = {
|
|
@@ -1142,7 +1189,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1142
1189
|
device: t,
|
|
1143
1190
|
passkey_data: e
|
|
1144
1191
|
}, o = r ? ze.passkeyAuthenticateComplete : z.passkeyAuthenticateComplete;
|
|
1145
|
-
return this.axiosClient.post(o, a, V(
|
|
1192
|
+
return this.axiosClient.post(o, a, V(Wt, void 0, void 0, i));
|
|
1146
1193
|
}
|
|
1147
1194
|
passkeyValidate(e, t, n, r = !1, i) {
|
|
1148
1195
|
let a = {
|
|
@@ -1154,23 +1201,23 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1154
1201
|
let s = i ? { [c]: i } : {};
|
|
1155
1202
|
return this.axiosClient.post(o, a, { headers: s });
|
|
1156
1203
|
}
|
|
1157
|
-
},
|
|
1204
|
+
}, Zt = class {
|
|
1158
1205
|
constructor(e, t, n) {
|
|
1159
|
-
this.axiosClient = new
|
|
1206
|
+
this.axiosClient = new Ht(e, t, n);
|
|
1160
1207
|
}
|
|
1161
1208
|
setAppId(e) {
|
|
1162
1209
|
this.axiosClient.setAppId(e);
|
|
1163
1210
|
}
|
|
1164
1211
|
getCLIAuthStatus(e) {
|
|
1165
|
-
let t =
|
|
1212
|
+
let t = _t(z.cliAuthStatus, { sessionId: e });
|
|
1166
1213
|
return this.axiosClient.get(t);
|
|
1167
1214
|
}
|
|
1168
1215
|
completeCLIAuth(e) {
|
|
1169
1216
|
return this.axiosClient.post(z.cliAuthComplete, e);
|
|
1170
1217
|
}
|
|
1171
|
-
},
|
|
1218
|
+
}, Qt = class {
|
|
1172
1219
|
constructor(e, t, n) {
|
|
1173
|
-
this.axiosClient = new
|
|
1220
|
+
this.axiosClient = new Ht(e, t, n);
|
|
1174
1221
|
}
|
|
1175
1222
|
setAppId(e) {
|
|
1176
1223
|
this.axiosClient.setAppId(e);
|
|
@@ -1181,27 +1228,27 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1181
1228
|
getInvitations(e) {
|
|
1182
1229
|
let t = {};
|
|
1183
1230
|
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());
|
|
1184
|
-
let n =
|
|
1231
|
+
let n = _t(z.invitationsPath, { tenantID: e.tenantID });
|
|
1185
1232
|
return this.axiosClient.get(n, { params: t }).then((e) => ({
|
|
1186
1233
|
invites: e.invites,
|
|
1187
1234
|
nextPageSkip: e.next_page_skip
|
|
1188
1235
|
}));
|
|
1189
1236
|
}
|
|
1190
1237
|
deleteInvitation(e) {
|
|
1191
|
-
let t =
|
|
1238
|
+
let t = _t(z.invitationDelete, { invitationID: e });
|
|
1192
1239
|
return this.axiosClient.delete(t);
|
|
1193
1240
|
}
|
|
1194
1241
|
resendInvitation(e) {
|
|
1195
|
-
let t =
|
|
1242
|
+
let t = _t(z.invitationResend, { invitationID: e });
|
|
1196
1243
|
return this.axiosClient.post(t, {});
|
|
1197
1244
|
}
|
|
1198
1245
|
getInvitationLink(e) {
|
|
1199
|
-
let t =
|
|
1246
|
+
let t = _t(z.invitationGetLink, { invitationID: e });
|
|
1200
1247
|
return this.axiosClient.get(t);
|
|
1201
1248
|
}
|
|
1202
|
-
},
|
|
1249
|
+
}, $t = class {
|
|
1203
1250
|
constructor(e, t, n) {
|
|
1204
|
-
this.axiosClient = new
|
|
1251
|
+
this.axiosClient = new Ht(e, t, n);
|
|
1205
1252
|
}
|
|
1206
1253
|
setAppId(e) {
|
|
1207
1254
|
this.axiosClient.setAppId(e);
|
|
@@ -1215,9 +1262,9 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1215
1262
|
getPasskeySettings() {
|
|
1216
1263
|
return this.axiosClient.get(z.settingsPasskey);
|
|
1217
1264
|
}
|
|
1218
|
-
},
|
|
1265
|
+
}, en = class {
|
|
1219
1266
|
constructor(e, t, n) {
|
|
1220
|
-
this.axiosClient = new
|
|
1267
|
+
this.axiosClient = new Ht(e, t, n);
|
|
1221
1268
|
}
|
|
1222
1269
|
setAppId(e) {
|
|
1223
1270
|
this.axiosClient.setAppId(e);
|
|
@@ -1331,58 +1378,58 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1331
1378
|
let r = `${z.tenantPath}/${e}/group/${t}/invite/email/${n}`;
|
|
1332
1379
|
return this.axiosClient.delete(r);
|
|
1333
1380
|
}
|
|
1334
|
-
},
|
|
1381
|
+
}, tn = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, nn = (e) => ({
|
|
1335
1382
|
withCredentials: !0,
|
|
1336
|
-
...
|
|
1337
|
-
}),
|
|
1383
|
+
...tn(e)
|
|
1384
|
+
}), rn = ({ qr_code_image: e, qr_code: t, ...n }) => ({
|
|
1338
1385
|
...n,
|
|
1339
1386
|
qr_code: (t ?? e ?? "").replace(/^data:image\/png;base64,/, "")
|
|
1340
|
-
}),
|
|
1387
|
+
}), an = {
|
|
1341
1388
|
"error.2fa.setup.token.expired": "EXPIRED_TOKEN",
|
|
1342
1389
|
"error.2fa.setup.token.revoked": "REVOKED_TOKEN",
|
|
1343
1390
|
"error.2fa.setup.token.already_used": "ALREADY_USED",
|
|
1344
1391
|
"error.2fa.setup.token.rate.limit.exceeded": "RATE_LIMITED"
|
|
1345
|
-
},
|
|
1392
|
+
}, on = class {
|
|
1346
1393
|
constructor(e, t, n) {
|
|
1347
|
-
this.axiosClient = new
|
|
1394
|
+
this.axiosClient = new Ht(e, t, n);
|
|
1348
1395
|
}
|
|
1349
1396
|
setAppId(e) {
|
|
1350
1397
|
this.axiosClient.setAppId(e);
|
|
1351
1398
|
}
|
|
1352
1399
|
getStatus(e) {
|
|
1353
|
-
return this.axiosClient.get(z.twoFactorStatus,
|
|
1400
|
+
return this.axiosClient.get(z.twoFactorStatus, Ft(e));
|
|
1354
1401
|
}
|
|
1355
1402
|
async beginSetup(e) {
|
|
1356
|
-
return
|
|
1403
|
+
return rn(await this.axiosClient.post(z.twoFactorSetupBegin, {}, Ft(e)));
|
|
1357
1404
|
}
|
|
1358
1405
|
confirmSetup(e, t) {
|
|
1359
|
-
return this.axiosClient.post(z.twoFactorSetupConfirm, e,
|
|
1406
|
+
return this.axiosClient.post(z.twoFactorSetupConfirm, e, Ft(t));
|
|
1360
1407
|
}
|
|
1361
1408
|
getEnrollment(e) {
|
|
1362
|
-
return this.axiosClient.get(z.twoFactorEnrollment,
|
|
1409
|
+
return this.axiosClient.get(z.twoFactorEnrollment, Ft(e));
|
|
1363
1410
|
}
|
|
1364
1411
|
sendSetupLink(e) {
|
|
1365
|
-
return this.axiosClient.post(z.twoFactorEnrollmentEmailLink, void 0,
|
|
1412
|
+
return this.axiosClient.post(z.twoFactorEnrollmentEmailLink, void 0, Ft(e));
|
|
1366
1413
|
}
|
|
1367
1414
|
async beginEnrollment(e) {
|
|
1368
|
-
return
|
|
1415
|
+
return rn(await this.axiosClient.post(z.twoFactorEnrollmentBegin, void 0, Ft(e)));
|
|
1369
1416
|
}
|
|
1370
1417
|
confirmEnrollment(e, t) {
|
|
1371
|
-
return this.axiosClient.post(z.twoFactorEnrollmentConfirm, t,
|
|
1418
|
+
return this.axiosClient.post(z.twoFactorEnrollmentConfirm, t, Ft(e));
|
|
1372
1419
|
}
|
|
1373
1420
|
verify(e) {
|
|
1374
1421
|
let { tfa_token: t, code: n, trust_device: r } = e;
|
|
1375
1422
|
return this.axiosClient.post(z.twoFactorVerify, {
|
|
1376
1423
|
code: n,
|
|
1377
1424
|
...r ? { trust_device: !0 } : {}
|
|
1378
|
-
},
|
|
1425
|
+
}, nn(t));
|
|
1379
1426
|
}
|
|
1380
1427
|
useRecoveryCode(e) {
|
|
1381
1428
|
let { tfa_token: t, recovery_code: n, trust_device: r } = e;
|
|
1382
1429
|
return this.axiosClient.post(z.twoFactorRecovery, {
|
|
1383
1430
|
recovery_code: n,
|
|
1384
1431
|
...r ? { trust_device: !0 } : {}
|
|
1385
|
-
},
|
|
1432
|
+
}, nn(t));
|
|
1386
1433
|
}
|
|
1387
1434
|
disable(e) {
|
|
1388
1435
|
return this.axiosClient.delete(z.twoFactor, { data: e });
|
|
@@ -1412,7 +1459,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1412
1459
|
if (e instanceof B) return {
|
|
1413
1460
|
success: !1,
|
|
1414
1461
|
error: {
|
|
1415
|
-
code:
|
|
1462
|
+
code: an[e.id] ?? this.mapStatusToErrorCode(e.status),
|
|
1416
1463
|
message: e.message || this.getDefaultErrorMessage(e.status)
|
|
1417
1464
|
}
|
|
1418
1465
|
};
|
|
@@ -1457,8 +1504,9 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1457
1504
|
async getAvailableMethods() {
|
|
1458
1505
|
return (await this.axiosClient.get(z.TwoFactorMethodsAvailable))?.available_methods ?? [];
|
|
1459
1506
|
}
|
|
1460
|
-
async getRegisteredMethods() {
|
|
1461
|
-
|
|
1507
|
+
async getRegisteredMethods(e) {
|
|
1508
|
+
let t = Object.fromEntries(Object.entries(e ?? {}).filter(([, e]) => e !== void 0));
|
|
1509
|
+
return (await this.axiosClient.get(z.TwoFactorMethodsRegistered, Object.keys(t).length > 0 ? { params: t } : void 0))?.registered_methods ?? [];
|
|
1462
1510
|
}
|
|
1463
1511
|
startMethodSetup(e, t) {
|
|
1464
1512
|
return this.axiosClient.post(z.TwoFactorSetupStart, {
|
|
@@ -1472,28 +1520,41 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1472
1520
|
method: e
|
|
1473
1521
|
});
|
|
1474
1522
|
}
|
|
1523
|
+
startRecoveryCodesByCode(e) {
|
|
1524
|
+
return this.axiosClient.post(z.TwoFactorSetupStart, {
|
|
1525
|
+
method: "recovery_codes",
|
|
1526
|
+
via: e
|
|
1527
|
+
}, Rt());
|
|
1528
|
+
}
|
|
1529
|
+
completeRecoveryCodesByCode(e, t) {
|
|
1530
|
+
return this.axiosClient.post(z.TwoFactorSetupComplete, {
|
|
1531
|
+
method: "recovery_codes",
|
|
1532
|
+
setup_id: e,
|
|
1533
|
+
code: t
|
|
1534
|
+
}, Rt());
|
|
1535
|
+
}
|
|
1475
1536
|
removeMethod(e) {
|
|
1476
|
-
let t =
|
|
1537
|
+
let t = _t(z.TwoFactorMethodRemove, { id: e });
|
|
1477
1538
|
return this.axiosClient.delete(t);
|
|
1478
1539
|
}
|
|
1479
1540
|
requestChallenge(e, t) {
|
|
1480
|
-
return this.axiosClient.post(z.TwoFactorChallenge, e,
|
|
1541
|
+
return this.axiosClient.post(z.TwoFactorChallenge, e, Rt(tn(t)));
|
|
1481
1542
|
}
|
|
1482
1543
|
verifyV2(e, t) {
|
|
1483
1544
|
let { trust_device: n, ...r } = e;
|
|
1484
1545
|
return this.axiosClient.post(z.TwoFactorVerifyV2, {
|
|
1485
1546
|
...r,
|
|
1486
1547
|
...n ? { trust_device: !0 } : {}
|
|
1487
|
-
},
|
|
1548
|
+
}, nn(t));
|
|
1488
1549
|
}
|
|
1489
1550
|
switchToAlternative(e, t) {
|
|
1490
|
-
return this.axiosClient.post(z.TwoFactorAlternative, e,
|
|
1551
|
+
return this.axiosClient.post(z.TwoFactorAlternative, e, Rt(tn(t)));
|
|
1491
1552
|
}
|
|
1492
1553
|
async getTrustedDevices() {
|
|
1493
1554
|
return (await this.axiosClient.get(z.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
|
|
1494
1555
|
}
|
|
1495
1556
|
revokeTrustedDevice(e) {
|
|
1496
|
-
let t =
|
|
1557
|
+
let t = _t(z.TwoFactorTrustedDeviceRevoke, { id: e });
|
|
1497
1558
|
return this.axiosClient.delete(t);
|
|
1498
1559
|
}
|
|
1499
1560
|
async getPreferredMethod() {
|
|
@@ -1505,9 +1566,9 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1505
1566
|
async clearPreferredMethod() {
|
|
1506
1567
|
await this.axiosClient.delete(z.TwoFactorPreferredMethod);
|
|
1507
1568
|
}
|
|
1508
|
-
},
|
|
1569
|
+
}, sn = class {
|
|
1509
1570
|
constructor(e, t, n) {
|
|
1510
|
-
this.axiosClient = new
|
|
1571
|
+
this.axiosClient = new Ht(e, t, n);
|
|
1511
1572
|
}
|
|
1512
1573
|
setAppId(e) {
|
|
1513
1574
|
this.axiosClient.setAppId(e);
|
|
@@ -1521,9 +1582,9 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1521
1582
|
async commitHostedUpgrade(e) {
|
|
1522
1583
|
await this.axiosClient.post(z.hostedUpgrade, e, { withCredentials: !0 });
|
|
1523
1584
|
}
|
|
1524
|
-
},
|
|
1585
|
+
}, cn = class {
|
|
1525
1586
|
constructor(e, t, n) {
|
|
1526
|
-
this.axiosClient = new
|
|
1587
|
+
this.axiosClient = new Ht(e, t, n);
|
|
1527
1588
|
}
|
|
1528
1589
|
setAppId(e) {
|
|
1529
1590
|
this.axiosClient.setAppId(e);
|
|
@@ -1563,48 +1624,57 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1563
1624
|
revokeOtherUserSessions() {
|
|
1564
1625
|
return this.axiosClient.post(z.userSessionsRevokeOthers);
|
|
1565
1626
|
}
|
|
1566
|
-
|
|
1627
|
+
requestAddressChangeProof(e) {
|
|
1628
|
+
return this.axiosClient.post(z.AddressChangeProof, { method: e }, Rt());
|
|
1629
|
+
}
|
|
1630
|
+
updateProfile(e, t) {
|
|
1631
|
+
return this.axiosClient.patch(z.userProfile, {
|
|
1632
|
+
...e,
|
|
1633
|
+
...t ? { proof: t } : {}
|
|
1634
|
+
}, Rt());
|
|
1635
|
+
}
|
|
1636
|
+
}, ln = 10, un = 20, dn = class extends Error {
|
|
1567
1637
|
constructor(e) {
|
|
1568
1638
|
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;
|
|
1569
1639
|
}
|
|
1570
|
-
},
|
|
1640
|
+
}, fn = [], pn = 0, mn = !1, hn, gn, _n = (e, t) => e.priority - t.priority || e.seq - t.seq, vn = () => typeof globalThis > "u" ? void 0 : globalThis, yn = async (e, t, n, r) => {
|
|
1571
1641
|
if (t >= e.length) {
|
|
1572
|
-
let e =
|
|
1642
|
+
let e = hn;
|
|
1573
1643
|
if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
|
|
1574
1644
|
return e(n, r);
|
|
1575
1645
|
}
|
|
1576
1646
|
let i = e[t];
|
|
1577
|
-
if (!i) return
|
|
1578
|
-
let a = !1, o = await i.middleware((n, r) => (a = !0,
|
|
1579
|
-
if (!a) throw new
|
|
1647
|
+
if (!i) return yn(e, e.length, n, r);
|
|
1648
|
+
let a = !1, o = await i.middleware((n, r) => (a = !0, yn(e, t + 1, n, r)), n, r);
|
|
1649
|
+
if (!a) throw new dn(i.name);
|
|
1580
1650
|
return o;
|
|
1581
|
-
},
|
|
1582
|
-
let e =
|
|
1651
|
+
}, bn = () => {
|
|
1652
|
+
let e = vn();
|
|
1583
1653
|
if (!e || typeof e.fetch != "function") return !1;
|
|
1584
|
-
let t = e.fetch.bind(e), n = (e, t) =>
|
|
1585
|
-
return
|
|
1586
|
-
},
|
|
1587
|
-
let e =
|
|
1588
|
-
e &&
|
|
1589
|
-
},
|
|
1590
|
-
if (
|
|
1654
|
+
let t = e.fetch.bind(e), n = (e, t) => yn([...fn].sort(_n), 0, e, t);
|
|
1655
|
+
return hn = t, gn = n, e.fetch = n, mn = !0, !0;
|
|
1656
|
+
}, xn = () => {
|
|
1657
|
+
let e = vn();
|
|
1658
|
+
e && gn && e.fetch === gn && (hn && (e.fetch = hn), mn = !1, gn = void 0, hn = void 0);
|
|
1659
|
+
}, Sn = (e, t) => {
|
|
1660
|
+
if (!mn && !bn()) return () => {};
|
|
1591
1661
|
let n = {
|
|
1592
1662
|
middleware: e,
|
|
1593
1663
|
name: t.name,
|
|
1594
1664
|
priority: t.priority,
|
|
1595
|
-
seq:
|
|
1665
|
+
seq: pn++
|
|
1596
1666
|
};
|
|
1597
|
-
|
|
1667
|
+
fn.push(n);
|
|
1598
1668
|
let r = !1;
|
|
1599
1669
|
return () => {
|
|
1600
|
-
r || (r = !0,
|
|
1670
|
+
r || (r = !0, fn = fn.filter((e) => e !== n), fn.length === 0 && xn());
|
|
1601
1671
|
};
|
|
1602
|
-
},
|
|
1603
|
-
let e =
|
|
1672
|
+
}, Cn = () => {
|
|
1673
|
+
let e = vn();
|
|
1604
1674
|
return {
|
|
1605
|
-
installed:
|
|
1606
|
-
names: [...
|
|
1607
|
-
foreignPatch:
|
|
1675
|
+
installed: mn,
|
|
1676
|
+
names: [...fn].sort(_n).map((e) => e.name),
|
|
1677
|
+
foreignPatch: mn && !!e && !!gn && e.fetch !== gn
|
|
1608
1678
|
};
|
|
1609
1679
|
}, H = class e extends Error {
|
|
1610
1680
|
constructor(t) {
|
|
@@ -1675,7 +1745,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1675
1745
|
let e = `M2MError [${this.code}]: ${this.message}`;
|
|
1676
1746
|
return this.status && (e += ` (HTTP ${this.status})`), e;
|
|
1677
1747
|
}
|
|
1678
|
-
},
|
|
1748
|
+
}, wn = class extends H {
|
|
1679
1749
|
constructor(e, t) {
|
|
1680
1750
|
super({
|
|
1681
1751
|
code: "temporarily_unavailable",
|
|
@@ -1684,7 +1754,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1684
1754
|
cause: t
|
|
1685
1755
|
}), this.name = "M2MNetworkError";
|
|
1686
1756
|
}
|
|
1687
|
-
},
|
|
1757
|
+
}, Tn = class extends H {
|
|
1688
1758
|
constructor(e, t) {
|
|
1689
1759
|
super({
|
|
1690
1760
|
code: "invalid_request",
|
|
@@ -1693,7 +1763,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1693
1763
|
cause: t
|
|
1694
1764
|
}), this.name = "M2MTokenParseError";
|
|
1695
1765
|
}
|
|
1696
|
-
},
|
|
1766
|
+
}, En = class extends H {
|
|
1697
1767
|
constructor(e) {
|
|
1698
1768
|
super({
|
|
1699
1769
|
code: "invalid_request",
|
|
@@ -1701,7 +1771,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1701
1771
|
status: 400
|
|
1702
1772
|
}), this.name = "M2MConfigError";
|
|
1703
1773
|
}
|
|
1704
|
-
},
|
|
1774
|
+
}, Dn = {
|
|
1705
1775
|
InvalidRequest: "invalid_request",
|
|
1706
1776
|
InvalidClient: "invalid_client",
|
|
1707
1777
|
InvalidGrant: "invalid_grant",
|
|
@@ -1711,14 +1781,14 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1711
1781
|
RateLimitExceeded: "rate_limit_exceeded",
|
|
1712
1782
|
ServerError: "server_error",
|
|
1713
1783
|
TemporarilyUnavailable: "temporarily_unavailable"
|
|
1714
|
-
},
|
|
1784
|
+
}, On = {
|
|
1715
1785
|
TOKEN_ENDPOINT: "/oauth2/token",
|
|
1716
1786
|
TIMEOUT: 1e4,
|
|
1717
1787
|
RETRIES: 3,
|
|
1718
1788
|
RETRY_DELAY: 1e3,
|
|
1719
1789
|
REFRESH_THRESHOLD: 30,
|
|
1720
1790
|
CONTENT_TYPE: "application/x-www-form-urlencoded"
|
|
1721
|
-
},
|
|
1791
|
+
}, kn = class {
|
|
1722
1792
|
constructor() {
|
|
1723
1793
|
this.cache = /* @__PURE__ */ new Map();
|
|
1724
1794
|
}
|
|
@@ -1735,18 +1805,18 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1735
1805
|
delete(e) {
|
|
1736
1806
|
return this.cache.delete(e), Promise.resolve();
|
|
1737
1807
|
}
|
|
1738
|
-
},
|
|
1808
|
+
}, An = {
|
|
1739
1809
|
shouldRetry(e, t) {
|
|
1740
1810
|
return t >= 3 ? !1 : e.code === "server_error" || e.code === "temporarily_unavailable" || e.code === "rate_limit_exceeded" || e.status !== void 0 && e.status >= 500;
|
|
1741
1811
|
},
|
|
1742
1812
|
getDelay(e) {
|
|
1743
1813
|
return 2 ** (e - 1) * 1e3;
|
|
1744
1814
|
}
|
|
1745
|
-
},
|
|
1815
|
+
}, jn = class {
|
|
1746
1816
|
constructor(e) {
|
|
1747
|
-
if (!e.url) throw new
|
|
1748
|
-
if (!e.clientId) throw new
|
|
1749
|
-
if (!e.clientSecret) throw new
|
|
1817
|
+
if (!e.url) throw new En("M2M client requires a URL");
|
|
1818
|
+
if (!e.clientId) throw new En("M2M client requires a clientId");
|
|
1819
|
+
if (!e.clientSecret) throw new En("M2M client requires a clientSecret");
|
|
1750
1820
|
let t = e.url.replace(/\/$/, "");
|
|
1751
1821
|
this.config = {
|
|
1752
1822
|
url: t,
|
|
@@ -1755,16 +1825,16 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1755
1825
|
scopes: e.scopes,
|
|
1756
1826
|
audience: e.audience,
|
|
1757
1827
|
autoRefresh: e.autoRefresh ?? !1,
|
|
1758
|
-
refreshThreshold: e.refreshThreshold ??
|
|
1759
|
-
timeout: e.timeout ??
|
|
1760
|
-
retries: e.retries ??
|
|
1761
|
-
retryDelay: e.retryDelay ??
|
|
1828
|
+
refreshThreshold: e.refreshThreshold ?? On.REFRESH_THRESHOLD,
|
|
1829
|
+
timeout: e.timeout ?? On.TIMEOUT,
|
|
1830
|
+
retries: e.retries ?? On.RETRIES,
|
|
1831
|
+
retryDelay: e.retryDelay ?? On.RETRY_DELAY,
|
|
1762
1832
|
retryStrategy: e.retryStrategy,
|
|
1763
1833
|
cache: e.cache,
|
|
1764
1834
|
onTokenRequest: e.onTokenRequest,
|
|
1765
1835
|
onTokenResponse: e.onTokenResponse,
|
|
1766
1836
|
onError: e.onError
|
|
1767
|
-
}, this.cache = e.cache ?? new
|
|
1837
|
+
}, this.cache = e.cache ?? new kn(), this.retryStrategy = e.retryStrategy ?? An, this.tokenEndpoint = `${t}${On.TOKEN_ENDPOINT}`;
|
|
1768
1838
|
}
|
|
1769
1839
|
getCacheKey(e, t) {
|
|
1770
1840
|
let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
|
|
@@ -1809,7 +1879,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1809
1879
|
let e = await fetch(this.tokenEndpoint, {
|
|
1810
1880
|
method: "POST",
|
|
1811
1881
|
headers: {
|
|
1812
|
-
"Content-Type":
|
|
1882
|
+
"Content-Type": On.CONTENT_TYPE,
|
|
1813
1883
|
Accept: "application/json"
|
|
1814
1884
|
},
|
|
1815
1885
|
body: t.toString(),
|
|
@@ -1834,7 +1904,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1834
1904
|
}
|
|
1835
1905
|
return a;
|
|
1836
1906
|
} catch (e) {
|
|
1837
|
-
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new
|
|
1907
|
+
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new wn(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new wn(`Network error: ${e.message}`, e) : e instanceof H ? e : H.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1838
1908
|
}
|
|
1839
1909
|
}
|
|
1840
1910
|
async executeWithRetry(e) {
|
|
@@ -1877,13 +1947,13 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1877
1947
|
parseToken(e) {
|
|
1878
1948
|
try {
|
|
1879
1949
|
let t = e.split(".");
|
|
1880
|
-
if (t.length !== 3) throw new
|
|
1950
|
+
if (t.length !== 3) throw new Tn("Invalid JWT format: expected 3 parts");
|
|
1881
1951
|
let n = t[1];
|
|
1882
|
-
if (!n) throw new
|
|
1952
|
+
if (!n) throw new Tn("Invalid JWT format: missing payload");
|
|
1883
1953
|
let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
|
|
1884
1954
|
return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
|
|
1885
1955
|
} catch (e) {
|
|
1886
|
-
throw e instanceof
|
|
1956
|
+
throw e instanceof Tn ? e : new Tn(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
1887
1957
|
}
|
|
1888
1958
|
}
|
|
1889
1959
|
clearCache() {
|
|
@@ -1898,7 +1968,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1898
1968
|
try {
|
|
1899
1969
|
let e = await fetch(t, {
|
|
1900
1970
|
method: "POST",
|
|
1901
|
-
headers: { "Content-Type":
|
|
1971
|
+
headers: { "Content-Type": On.CONTENT_TYPE },
|
|
1902
1972
|
body: n.toString()
|
|
1903
1973
|
});
|
|
1904
1974
|
if (!e.ok && e.status !== 200) {
|
|
@@ -1925,50 +1995,50 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1925
1995
|
get audience() {
|
|
1926
1996
|
return this.config.audience;
|
|
1927
1997
|
}
|
|
1928
|
-
},
|
|
1998
|
+
}, Mn = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", Nn = 32, Pn = (e) => {
|
|
1929
1999
|
let t = "";
|
|
1930
2000
|
for (let n = 0; n < e.length; n += 3) {
|
|
1931
2001
|
let r = e[n], i = e[n + 1], a = e[n + 2];
|
|
1932
|
-
t +=
|
|
2002
|
+
t += Mn.charAt(r >> 2), t += Mn.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += Mn.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += Mn.charAt(a & 63));
|
|
1933
2003
|
}
|
|
1934
2004
|
return t;
|
|
1935
|
-
},
|
|
2005
|
+
}, Fn = () => {
|
|
1936
2006
|
let e = globalThis.crypto;
|
|
1937
2007
|
if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1938
2008
|
return e;
|
|
1939
|
-
},
|
|
1940
|
-
let t = await
|
|
1941
|
-
return
|
|
1942
|
-
},
|
|
1943
|
-
let e =
|
|
2009
|
+
}, In = async (e) => {
|
|
2010
|
+
let t = await Fn().subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
2011
|
+
return Pn(new Uint8Array(t));
|
|
2012
|
+
}, Ln = (e = Nn) => Pn(Fn().getRandomValues(new Uint8Array(e))), Rn = async () => {
|
|
2013
|
+
let e = Ln(Nn);
|
|
1944
2014
|
return {
|
|
1945
2015
|
verifier: e,
|
|
1946
|
-
challenge: await
|
|
2016
|
+
challenge: await In(e)
|
|
1947
2017
|
};
|
|
1948
|
-
},
|
|
2018
|
+
}, zn = () => !!globalThis.crypto?.subtle, U = class extends Error {
|
|
1949
2019
|
constructor(e, t) {
|
|
1950
2020
|
super(t), this.code = e, this.name = "PassflowOidcError";
|
|
1951
2021
|
}
|
|
1952
|
-
},
|
|
2022
|
+
}, Bn = "Sign in again.", Vn = (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.`, Hn = "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.", Un = () => new U("TOKENS_IN_URL_NOT_ALLOWED", "Tokens in the URL are accepted only for apps in Simple mode"), Wn = "passflow_oidc_pkce", Gn = 6e5, Kn = (e) => {
|
|
1953
2023
|
try {
|
|
1954
2024
|
let t = new URL(e);
|
|
1955
2025
|
return `${t.protocol}//${t.host}${t.pathname.replace(/\/+$/, "")}`;
|
|
1956
2026
|
} catch {
|
|
1957
2027
|
return e;
|
|
1958
2028
|
}
|
|
1959
|
-
},
|
|
1960
|
-
if (!
|
|
1961
|
-
let t =
|
|
2029
|
+
}, qn = (e) => !e.includes("openid") && (e.includes("id") || e.includes("oidc")) ? [...e, "openid"] : [...e], Jn = async (e) => {
|
|
2030
|
+
if (!zn()) throw new U("SECURE_CONTEXT_REQUIRED", "Sign-in needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
2031
|
+
let t = qn(e.scopes), n = await Rn(), r = {
|
|
1962
2032
|
verifier: n.verifier,
|
|
1963
|
-
state:
|
|
1964
|
-
...t.includes("openid") ? { nonce:
|
|
2033
|
+
state: Ln(),
|
|
2034
|
+
...t.includes("openid") ? { nonce: Ln() } : {},
|
|
1965
2035
|
clientId: e.clientId,
|
|
1966
2036
|
redirectUri: e.redirectUri,
|
|
1967
2037
|
scopes: t,
|
|
1968
|
-
expiresAt: Date.now() +
|
|
2038
|
+
expiresAt: Date.now() + Gn
|
|
1969
2039
|
};
|
|
1970
2040
|
try {
|
|
1971
|
-
sessionStorage.setItem(
|
|
2041
|
+
sessionStorage.setItem(Wn, JSON.stringify(r));
|
|
1972
2042
|
} catch {
|
|
1973
2043
|
throw new U("STORAGE_UNAVAILABLE", "Sign-in needs sessionStorage, which cannot be written here");
|
|
1974
2044
|
}
|
|
@@ -1983,37 +2053,37 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
1983
2053
|
code_challenge_method: "S256",
|
|
1984
2054
|
...r.nonce ? { nonce: r.nonce } : {}
|
|
1985
2055
|
}).toString(), i.toString();
|
|
1986
|
-
},
|
|
2056
|
+
}, Yn = (e) => {
|
|
1987
2057
|
let t = e;
|
|
1988
2058
|
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";
|
|
1989
|
-
},
|
|
2059
|
+
}, Xn = () => {
|
|
1990
2060
|
let e;
|
|
1991
2061
|
try {
|
|
1992
|
-
e = sessionStorage.getItem(
|
|
2062
|
+
e = sessionStorage.getItem(Wn);
|
|
1993
2063
|
} catch {
|
|
1994
2064
|
return { status: "none" };
|
|
1995
2065
|
}
|
|
1996
2066
|
if (!e) return { status: "none" };
|
|
1997
2067
|
try {
|
|
1998
2068
|
let t = JSON.parse(e);
|
|
1999
|
-
if (
|
|
2069
|
+
if (Yn(t) && Date.now() < t.expiresAt) return {
|
|
2000
2070
|
status: "live",
|
|
2001
2071
|
slot: t
|
|
2002
2072
|
};
|
|
2003
2073
|
} catch {}
|
|
2004
2074
|
return { status: "unusable" };
|
|
2005
|
-
},
|
|
2075
|
+
}, Zn = () => {
|
|
2006
2076
|
try {
|
|
2007
|
-
sessionStorage.removeItem(
|
|
2077
|
+
sessionStorage.removeItem(Wn);
|
|
2008
2078
|
} catch {}
|
|
2009
|
-
},
|
|
2079
|
+
}, Qn = async (e) => {
|
|
2010
2080
|
try {
|
|
2011
2081
|
let t = await e.json();
|
|
2012
2082
|
return typeof t == "object" && t ? t : void 0;
|
|
2013
2083
|
} catch {
|
|
2014
2084
|
return;
|
|
2015
2085
|
}
|
|
2016
|
-
},
|
|
2086
|
+
}, $n = async (e, t, n) => {
|
|
2017
2087
|
let r;
|
|
2018
2088
|
try {
|
|
2019
2089
|
r = await fetch(`${e.replace(/\/+$/, "")}/oidc/token`, {
|
|
@@ -2028,11 +2098,11 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
2028
2098
|
}).toString()
|
|
2029
2099
|
});
|
|
2030
2100
|
} catch {
|
|
2031
|
-
throw new U("TOKEN_EXCHANGE_FAILED",
|
|
2101
|
+
throw new U("TOKEN_EXCHANGE_FAILED", Bn);
|
|
2032
2102
|
}
|
|
2033
|
-
let i = await
|
|
2034
|
-
if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client",
|
|
2035
|
-
if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED",
|
|
2103
|
+
let i = await Qn(r);
|
|
2104
|
+
if (!r.ok) throw i?.error === "invalid_client" ? new U("invalid_client", Hn) : i?.error === "invalid_grant" ? new U("invalid_grant", Bn) : new U("TOKEN_EXCHANGE_FAILED", Bn);
|
|
2105
|
+
if (typeof i?.access_token != "string") throw new U("TOKEN_EXCHANGE_FAILED", Bn);
|
|
2036
2106
|
let a = typeof i.id_token == "string" ? i.id_token : void 0;
|
|
2037
2107
|
if (n.scopes.includes("openid")) {
|
|
2038
2108
|
let e;
|
|
@@ -2041,7 +2111,7 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
2041
2111
|
} catch {
|
|
2042
2112
|
e = void 0;
|
|
2043
2113
|
}
|
|
2044
|
-
if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${
|
|
2114
|
+
if (!a || e !== n.nonce) throw new U("ID_TOKEN_INVALID", `The ID token is missing or not issued for this sign-in. ${Bn}`);
|
|
2045
2115
|
}
|
|
2046
2116
|
return {
|
|
2047
2117
|
access_token: i.access_token,
|
|
@@ -2049,13 +2119,13 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
2049
2119
|
...a ? { id_token: a } : {},
|
|
2050
2120
|
scopes: n.scopes
|
|
2051
2121
|
};
|
|
2052
|
-
},
|
|
2122
|
+
}, er = "error", tr = /* @__PURE__ */ new WeakMap(), nr = (e, t) => {
|
|
2053
2123
|
if (typeof t != "object" && typeof t != "function" || t === null) return !0;
|
|
2054
|
-
let n =
|
|
2055
|
-
return n || (n = /* @__PURE__ */ new WeakSet(),
|
|
2056
|
-
}, W = (e, t) =>
|
|
2124
|
+
let n = tr.get(e);
|
|
2125
|
+
return n || (n = /* @__PURE__ */ new WeakSet(), tr.set(e, n)), !n.has(t) && (n.add(t), !0);
|
|
2126
|
+
}, W = (e, t) => nr(e, t.originalError) ? (e.notify(er, t), !0) : !1, G = /* @__PURE__ */ function(e) {
|
|
2057
2127
|
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;
|
|
2058
|
-
}({}),
|
|
2128
|
+
}({}), rr = class {
|
|
2059
2129
|
constructor() {
|
|
2060
2130
|
this.subscribers = /* @__PURE__ */ new Map();
|
|
2061
2131
|
}
|
|
@@ -2074,40 +2144,40 @@ var ut = /* @__PURE__ */ function(e) {
|
|
|
2074
2144
|
n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
|
|
2075
2145
|
}
|
|
2076
2146
|
notify(e, t) {
|
|
2077
|
-
e === "error" &&
|
|
2147
|
+
e === "error" && nr(this, t?.originalError), this.subscribers.forEach((n, r) => {
|
|
2078
2148
|
(!n || n.has(e)) && r.onAuthChange?.(e, t);
|
|
2079
2149
|
});
|
|
2080
2150
|
}
|
|
2081
2151
|
notifyError(e) {
|
|
2082
2152
|
return W(this, e);
|
|
2083
2153
|
}
|
|
2084
|
-
},
|
|
2154
|
+
}, ir = 256, ar = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0")), or = (e) => {
|
|
2085
2155
|
let t = new Uint8Array(e), n = "";
|
|
2086
|
-
for (let e of t) n +=
|
|
2156
|
+
for (let e of t) n += ar[e];
|
|
2087
2157
|
return n;
|
|
2088
|
-
},
|
|
2089
|
-
async function
|
|
2158
|
+
}, sr = class extends Error {};
|
|
2159
|
+
async function cr(e, t, n, r = Infinity) {
|
|
2090
2160
|
let i = globalThis.crypto?.subtle;
|
|
2091
2161
|
if (!i) throw Error("Web Crypto unavailable");
|
|
2092
2162
|
let a = t.toLowerCase(), o = new TextEncoder();
|
|
2093
|
-
for (let t = 0; t <= n; t +=
|
|
2094
|
-
if (Date.now() > r) throw new
|
|
2095
|
-
let s = Math.min(t +
|
|
2163
|
+
for (let t = 0; t <= n; t += ir) {
|
|
2164
|
+
if (Date.now() > r) throw new sr("Solve timed out");
|
|
2165
|
+
let s = Math.min(t + ir - 1, n), c = [];
|
|
2096
2166
|
for (let n = t; n <= s; n++) c.push(i.digest("SHA-256", o.encode(`${e}:${n}`)));
|
|
2097
2167
|
let l = await Promise.all(c);
|
|
2098
|
-
for (let e = 0; e < l.length; e++) if (
|
|
2168
|
+
for (let e = 0; e < l.length; e++) if (or(l[e]) === a) return t + e;
|
|
2099
2169
|
}
|
|
2100
2170
|
return null;
|
|
2101
2171
|
}
|
|
2102
2172
|
// lib/anti-bot/solve.ts
|
|
2103
|
-
var
|
|
2173
|
+
var lr = "The browser check could not be completed. Try again later.", ur = "Verification failed. Try again.", dr = 6e4, fr = class extends Error {}, pr = (e, t, n, r) => new B({
|
|
2104
2174
|
id: e,
|
|
2105
2175
|
message: t,
|
|
2106
2176
|
status: 0,
|
|
2107
2177
|
location: n,
|
|
2108
2178
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2109
|
-
}, r === void 0 ? void 0 : { cause: r }),
|
|
2110
|
-
let i = new Worker(e), a = setTimeout(() => o(() => r(new
|
|
2179
|
+
}, r === void 0 ? void 0 : { cause: r }), mr = (e, t) => new Promise((n, r) => {
|
|
2180
|
+
let i = new Worker(e), a = setTimeout(() => o(() => r(new fr())), dr), o = (e) => {
|
|
2111
2181
|
clearTimeout(a), i.terminate(), e();
|
|
2112
2182
|
};
|
|
2113
2183
|
i.addEventListener("message", (e) => {
|
|
@@ -2115,23 +2185,23 @@ var Yn = "The browser check could not be completed. Try again later.", Xn = "Ver
|
|
|
2115
2185
|
t && "error" in t ? o(() => r(Error(t.error))) : o(() => n(t?.number ?? null));
|
|
2116
2186
|
}), 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);
|
|
2117
2187
|
});
|
|
2118
|
-
async function
|
|
2119
|
-
if (e.algorithm !== "SHA-256") throw
|
|
2120
|
-
if (!Number.isSafeInteger(e.max) || e.max < 0 || e.max > 5e6) throw
|
|
2188
|
+
async function hr(e, t, n = "anti-bot") {
|
|
2189
|
+
if (e.algorithm !== "SHA-256") throw pr(Xe, lr, n);
|
|
2190
|
+
if (!Number.isSafeInteger(e.max) || e.max < 0 || e.max > 5e6) throw pr(Xe, ur, n);
|
|
2121
2191
|
let r = {
|
|
2122
2192
|
salt: e.salt,
|
|
2123
2193
|
challenge: e.challenge,
|
|
2124
2194
|
max: e.max
|
|
2125
2195
|
}, i;
|
|
2126
2196
|
try {
|
|
2127
|
-
i = t && typeof Worker < "u" ? await
|
|
2197
|
+
i = t && typeof Worker < "u" ? await mr(t, r) : await cr(r.salt, r.challenge, r.max, Date.now() + dr);
|
|
2128
2198
|
} catch (e) {
|
|
2129
|
-
throw
|
|
2199
|
+
throw pr(Xe, e instanceof fr || e instanceof sr ? ur : lr, n, e);
|
|
2130
2200
|
}
|
|
2131
|
-
if (i === null) throw
|
|
2201
|
+
if (i === null) throw pr(Xe, lr, n);
|
|
2132
2202
|
return i;
|
|
2133
2203
|
}
|
|
2134
|
-
function
|
|
2204
|
+
function gr(e, t) {
|
|
2135
2205
|
let n = {
|
|
2136
2206
|
app: e.app,
|
|
2137
2207
|
exp: e.exp,
|
|
@@ -2144,8 +2214,8 @@ function nr(e, t) {
|
|
|
2144
2214
|
return btoa(JSON.stringify(n));
|
|
2145
2215
|
}
|
|
2146
2216
|
// lib/anti-bot/anti-bot.ts
|
|
2147
|
-
var
|
|
2148
|
-
function
|
|
2217
|
+
var _r = "This app requires a verification token. Call setAntiBotTokenProvider() before signing in.", vr = "The verification could not be completed. Try again.";
|
|
2218
|
+
function yr(e) {
|
|
2149
2219
|
let t, n = async (e, t) => {
|
|
2150
2220
|
let n;
|
|
2151
2221
|
try {
|
|
@@ -2154,16 +2224,16 @@ function ar(e) {
|
|
|
2154
2224
|
operation: t.operation
|
|
2155
2225
|
});
|
|
2156
2226
|
} catch (e) {
|
|
2157
|
-
throw
|
|
2227
|
+
throw pr(Ye, vr, t.operation, e);
|
|
2158
2228
|
}
|
|
2159
|
-
if (typeof n != "string" || n === "") throw
|
|
2229
|
+
if (typeof n != "string" || n === "") throw pr(Ye, vr, t.operation);
|
|
2160
2230
|
return n;
|
|
2161
2231
|
}, r = async (t) => {
|
|
2162
2232
|
let n = await e.fetchChallenge({
|
|
2163
2233
|
...t.identifier ? { identifier: t.identifier } : {},
|
|
2164
2234
|
...t.device ? { device: t.device } : {}
|
|
2165
2235
|
});
|
|
2166
|
-
return
|
|
2236
|
+
return gr(n, await hr(n, e.workerUrl, t.operation));
|
|
2167
2237
|
};
|
|
2168
2238
|
return {
|
|
2169
2239
|
setTokenProvider(e) {
|
|
@@ -2181,7 +2251,7 @@ function ar(e) {
|
|
|
2181
2251
|
if (s) c = await r(i);
|
|
2182
2252
|
else {
|
|
2183
2253
|
let e = t;
|
|
2184
|
-
if (!e) throw
|
|
2254
|
+
if (!e) throw pr(Je, _r, i.operation);
|
|
2185
2255
|
c = await n(e, i);
|
|
2186
2256
|
}
|
|
2187
2257
|
return e.store.notify(G.AntiBotSolved, {
|
|
@@ -2195,97 +2265,97 @@ function ar(e) {
|
|
|
2195
2265
|
};
|
|
2196
2266
|
}
|
|
2197
2267
|
// lib/refresh/constants.ts
|
|
2198
|
-
var
|
|
2268
|
+
var br = "passflow-refresh", xr = "passflow-refresh-takeover", Sr = "passflow-auth", Cr = Object.freeze([
|
|
2199
2269
|
1e3,
|
|
2200
2270
|
3e3,
|
|
2201
2271
|
1e4,
|
|
2202
2272
|
3e4,
|
|
2203
2273
|
6e4
|
|
2204
|
-
]),
|
|
2274
|
+
]), wr = .2, Tr = 6e5, Er = 5e3, K = 2e4, Dr = 2e4, Or = 1e3, kr = 2e3, Ar = 1e3, jr = 1e4, Mr = 5e3;
|
|
2205
2275
|
// lib/refresh/protocol.ts
|
|
2206
|
-
function
|
|
2276
|
+
function Nr(e) {
|
|
2207
2277
|
let t = e ? `:${e}` : "";
|
|
2208
2278
|
return {
|
|
2209
|
-
lock: `${
|
|
2210
|
-
takeoverLock: `${
|
|
2211
|
-
channel: `${
|
|
2279
|
+
lock: `${br}${t}`,
|
|
2280
|
+
takeoverLock: `${xr}${t}`,
|
|
2281
|
+
channel: `${Sr}${t}`
|
|
2212
2282
|
};
|
|
2213
2283
|
}
|
|
2214
2284
|
function q(e) {
|
|
2215
2285
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2216
2286
|
}
|
|
2217
|
-
function
|
|
2287
|
+
function Pr(e) {
|
|
2218
2288
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
2219
2289
|
}
|
|
2220
|
-
function
|
|
2290
|
+
function Fr(e) {
|
|
2221
2291
|
return typeof e == "object" && !!e;
|
|
2222
2292
|
}
|
|
2223
|
-
function
|
|
2293
|
+
function Ir(e, t) {
|
|
2224
2294
|
for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
|
|
2225
2295
|
return e;
|
|
2226
2296
|
}
|
|
2227
|
-
function
|
|
2228
|
-
if (!
|
|
2297
|
+
function Lr(e) {
|
|
2298
|
+
if (!Fr(e)) return null;
|
|
2229
2299
|
let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
|
|
2230
|
-
return
|
|
2300
|
+
return Ir({}, {
|
|
2231
2301
|
access_token: q(e.access_token),
|
|
2232
2302
|
refresh_token: q(e.refresh_token),
|
|
2233
2303
|
id_token: q(e.id_token),
|
|
2234
2304
|
scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
|
|
2235
2305
|
});
|
|
2236
2306
|
}
|
|
2237
|
-
function
|
|
2238
|
-
if (!
|
|
2307
|
+
function Rr(e) {
|
|
2308
|
+
if (!Fr(e)) return null;
|
|
2239
2309
|
let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
|
|
2240
|
-
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 ||
|
|
2310
|
+
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || Pr(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Ir({
|
|
2241
2311
|
kind: t,
|
|
2242
2312
|
attempt: n,
|
|
2243
2313
|
nextAt: r,
|
|
2244
2314
|
strikes: i
|
|
2245
2315
|
}, {
|
|
2246
2316
|
from: q(e.from),
|
|
2247
|
-
failingSince:
|
|
2317
|
+
failingSince: Pr(e.failingSince)
|
|
2248
2318
|
});
|
|
2249
2319
|
}
|
|
2250
|
-
function
|
|
2251
|
-
return
|
|
2320
|
+
function zr(e) {
|
|
2321
|
+
return Ir({}, {
|
|
2252
2322
|
fp: q(e.fp),
|
|
2253
2323
|
sub: q(e.sub),
|
|
2254
2324
|
sid: q(e.sid),
|
|
2255
|
-
iat:
|
|
2325
|
+
iat: Pr(e.iat)
|
|
2256
2326
|
});
|
|
2257
2327
|
}
|
|
2258
|
-
function
|
|
2259
|
-
if (!
|
|
2328
|
+
function Br(e) {
|
|
2329
|
+
if (!Fr(e)) return null;
|
|
2260
2330
|
let t = e;
|
|
2261
2331
|
if (t.v !== void 0 && t.v !== 1) return null;
|
|
2262
2332
|
let n = q(t.tabId);
|
|
2263
2333
|
if (!n) return null;
|
|
2264
2334
|
switch (t.type) {
|
|
2265
2335
|
case "tokens-refreshed": {
|
|
2266
|
-
let e =
|
|
2267
|
-
return !e || !r || !i ? null :
|
|
2336
|
+
let e = Lr(t.tokens), r = q(t.from), i = q(t.to);
|
|
2337
|
+
return !e || !r || !i ? null : Ir({
|
|
2268
2338
|
type: t.type,
|
|
2269
2339
|
tabId: n,
|
|
2270
2340
|
tokens: e,
|
|
2271
2341
|
from: r,
|
|
2272
2342
|
to: i
|
|
2273
2343
|
}, {
|
|
2274
|
-
fromIat:
|
|
2344
|
+
fromIat: Pr(t.fromIat),
|
|
2275
2345
|
fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
|
|
2276
|
-
sentAt:
|
|
2346
|
+
sentAt: Pr(t.sentAt)
|
|
2277
2347
|
});
|
|
2278
2348
|
}
|
|
2279
2349
|
case "session-refreshed": {
|
|
2280
|
-
let e =
|
|
2281
|
-
return e === void 0 ? null :
|
|
2350
|
+
let e = Pr(t.at);
|
|
2351
|
+
return e === void 0 ? null : Ir({
|
|
2282
2352
|
type: t.type,
|
|
2283
2353
|
tabId: n,
|
|
2284
2354
|
at: e
|
|
2285
2355
|
}, { sub: q(t.sub) });
|
|
2286
2356
|
}
|
|
2287
2357
|
case "still-refreshing": {
|
|
2288
|
-
let e = t.retry === void 0 ? null :
|
|
2358
|
+
let e = t.retry === void 0 ? null : Rr(t.retry);
|
|
2289
2359
|
return e ? {
|
|
2290
2360
|
type: t.type,
|
|
2291
2361
|
tabId: n,
|
|
@@ -2296,7 +2366,7 @@ function Er(e) {
|
|
|
2296
2366
|
};
|
|
2297
2367
|
}
|
|
2298
2368
|
case "retry-scheduled": {
|
|
2299
|
-
let e =
|
|
2369
|
+
let e = Rr(t);
|
|
2300
2370
|
return e ? {
|
|
2301
2371
|
type: t.type,
|
|
2302
2372
|
tabId: n,
|
|
@@ -2317,10 +2387,10 @@ function Er(e) {
|
|
|
2317
2387
|
case "signed-out": return {
|
|
2318
2388
|
type: t.type,
|
|
2319
2389
|
tabId: n,
|
|
2320
|
-
...
|
|
2390
|
+
...zr(t)
|
|
2321
2391
|
};
|
|
2322
2392
|
case "rate-limited": {
|
|
2323
|
-
let e =
|
|
2393
|
+
let e = Pr(t.until);
|
|
2324
2394
|
return e === void 0 ? null : {
|
|
2325
2395
|
type: t.type,
|
|
2326
2396
|
tabId: n,
|
|
@@ -2339,22 +2409,22 @@ function Er(e) {
|
|
|
2339
2409
|
default: return null;
|
|
2340
2410
|
}
|
|
2341
2411
|
}
|
|
2342
|
-
function
|
|
2412
|
+
function Vr(e, t) {
|
|
2343
2413
|
let n = {
|
|
2344
2414
|
v: 1,
|
|
2345
2415
|
tabId: e
|
|
2346
2416
|
};
|
|
2347
2417
|
if (t.type === "retry-scheduled") {
|
|
2348
2418
|
let { retry: e, ...r } = t;
|
|
2349
|
-
return
|
|
2419
|
+
return Ir(n, {
|
|
2350
2420
|
...r,
|
|
2351
2421
|
...e
|
|
2352
2422
|
});
|
|
2353
2423
|
}
|
|
2354
|
-
return
|
|
2424
|
+
return Ir(n, { ...t });
|
|
2355
2425
|
}
|
|
2356
2426
|
// lib/refresh/resolve.ts
|
|
2357
|
-
var
|
|
2427
|
+
var Hr = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", Ur = {
|
|
2358
2428
|
now: () => Date.now(),
|
|
2359
2429
|
random: () => Math.random(),
|
|
2360
2430
|
setTimeout: (e, t) => {
|
|
@@ -2362,28 +2432,28 @@ var Or = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
|
|
|
2362
2432
|
return n.unref?.(), () => clearTimeout(n);
|
|
2363
2433
|
}
|
|
2364
2434
|
};
|
|
2365
|
-
function
|
|
2435
|
+
function Wr() {
|
|
2366
2436
|
let e = globalThis.crypto;
|
|
2367
2437
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
2368
2438
|
}
|
|
2369
|
-
function
|
|
2439
|
+
function Gr(e) {
|
|
2370
2440
|
return e ? {
|
|
2371
2441
|
now: () => e.now(),
|
|
2372
2442
|
setTimeout: (t, n) => e.setTimeout(t, n),
|
|
2373
|
-
random: e.random ? () => e.random?.() ?? Math.random() :
|
|
2374
|
-
} :
|
|
2443
|
+
random: e.random ? () => e.random?.() ?? Math.random() : Ur.random
|
|
2444
|
+
} : Ur;
|
|
2375
2445
|
}
|
|
2376
|
-
function
|
|
2446
|
+
function Kr(e) {
|
|
2377
2447
|
return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
|
|
2378
2448
|
}
|
|
2379
|
-
function
|
|
2449
|
+
function qr(e) {
|
|
2380
2450
|
try {
|
|
2381
2451
|
return e.storageSharedAcrossTabs === !0;
|
|
2382
2452
|
} catch {
|
|
2383
2453
|
return !1;
|
|
2384
2454
|
}
|
|
2385
2455
|
}
|
|
2386
|
-
function
|
|
2456
|
+
function Jr() {
|
|
2387
2457
|
try {
|
|
2388
2458
|
let e = globalThis.navigator?.locks;
|
|
2389
2459
|
return e && typeof e.request == "function" ? e : void 0;
|
|
@@ -2391,7 +2461,7 @@ function Pr() {
|
|
|
2391
2461
|
return;
|
|
2392
2462
|
}
|
|
2393
2463
|
}
|
|
2394
|
-
function
|
|
2464
|
+
function Yr(e) {
|
|
2395
2465
|
return (t) => {
|
|
2396
2466
|
let n = (n) => {
|
|
2397
2467
|
let r = n.key;
|
|
@@ -2400,20 +2470,20 @@ function Fr(e) {
|
|
|
2400
2470
|
return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
|
|
2401
2471
|
};
|
|
2402
2472
|
}
|
|
2403
|
-
function
|
|
2473
|
+
function Xr(e) {
|
|
2404
2474
|
return {
|
|
2405
2475
|
transports: null,
|
|
2406
|
-
names:
|
|
2407
|
-
clock:
|
|
2476
|
+
names: Nr(e),
|
|
2477
|
+
clock: Ur,
|
|
2408
2478
|
warnOnFirstCycle: !1
|
|
2409
2479
|
};
|
|
2410
2480
|
}
|
|
2411
|
-
function
|
|
2412
|
-
let i =
|
|
2481
|
+
function Zr(e, t, n, r) {
|
|
2482
|
+
let i = Nr(n), a = Kr(t), o = a ? Yr(r.tokenKeys) : void 0, s = (e) => {
|
|
2413
2483
|
let t = {
|
|
2414
2484
|
transports: null,
|
|
2415
2485
|
names: i,
|
|
2416
|
-
clock:
|
|
2486
|
+
clock: Ur,
|
|
2417
2487
|
warnOnFirstCycle: e
|
|
2418
2488
|
};
|
|
2419
2489
|
return o && (t.onStorageChange = o), t;
|
|
@@ -2423,16 +2493,16 @@ function Lr(e, t, n, r) {
|
|
|
2423
2493
|
transports: {
|
|
2424
2494
|
locks: e.locks,
|
|
2425
2495
|
channel: e.channel,
|
|
2426
|
-
tabId: e.tabId ??
|
|
2496
|
+
tabId: e.tabId ?? Wr()
|
|
2427
2497
|
},
|
|
2428
2498
|
names: i,
|
|
2429
|
-
clock:
|
|
2499
|
+
clock: Gr(e.clock),
|
|
2430
2500
|
warnOnFirstCycle: !1
|
|
2431
2501
|
};
|
|
2432
2502
|
return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
|
|
2433
2503
|
}
|
|
2434
|
-
if (e === "none" || !a || !
|
|
2435
|
-
let c =
|
|
2504
|
+
if (e === "none" || !a || !qr(t)) return s(!1);
|
|
2505
|
+
let c = Jr();
|
|
2436
2506
|
if (!c || typeof BroadcastChannel != "function") return s(!0);
|
|
2437
2507
|
let l;
|
|
2438
2508
|
try {
|
|
@@ -2444,16 +2514,16 @@ function Lr(e, t, n, r) {
|
|
|
2444
2514
|
transports: {
|
|
2445
2515
|
locks: c,
|
|
2446
2516
|
channel: l,
|
|
2447
|
-
tabId:
|
|
2517
|
+
tabId: Wr()
|
|
2448
2518
|
},
|
|
2449
2519
|
names: i,
|
|
2450
|
-
clock:
|
|
2520
|
+
clock: Ur,
|
|
2451
2521
|
warnOnFirstCycle: !1
|
|
2452
2522
|
};
|
|
2453
2523
|
return o && (u.onStorageChange = o), u;
|
|
2454
2524
|
}
|
|
2455
2525
|
// lib/services/logger.ts
|
|
2456
|
-
var
|
|
2526
|
+
var Qr = class {
|
|
2457
2527
|
error(e, ...t) {
|
|
2458
2528
|
console.error(e, ...t);
|
|
2459
2529
|
}
|
|
@@ -2467,10 +2537,10 @@ var Rr = class {
|
|
|
2467
2537
|
console.debug(e, ...t);
|
|
2468
2538
|
}
|
|
2469
2539
|
};
|
|
2470
|
-
function
|
|
2471
|
-
return new
|
|
2540
|
+
function $r() {
|
|
2541
|
+
return new Qr();
|
|
2472
2542
|
}
|
|
2473
|
-
var
|
|
2543
|
+
var ei = Object.freeze([
|
|
2474
2544
|
"error.token.invalid.error",
|
|
2475
2545
|
"error.api.token.parse.error",
|
|
2476
2546
|
"error.api.user.blocked",
|
|
@@ -2478,25 +2548,25 @@ var Br = Object.freeze([
|
|
|
2478
2548
|
"error.validation.token.invalid.subject",
|
|
2479
2549
|
"error.not.found"
|
|
2480
2550
|
]);
|
|
2481
|
-
function
|
|
2551
|
+
function ti(e) {
|
|
2482
2552
|
if (typeof e != "object" || !e) return;
|
|
2483
2553
|
let t = e;
|
|
2484
2554
|
return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
|
|
2485
2555
|
}
|
|
2486
|
-
function
|
|
2487
|
-
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(
|
|
2556
|
+
function ni(e, t) {
|
|
2557
|
+
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(Tr, Math.floor(e) * 1e3);
|
|
2488
2558
|
if (typeof e != "string") return;
|
|
2489
2559
|
let n = e.trim();
|
|
2490
2560
|
if (n === "") return;
|
|
2491
|
-
if (/^\d+$/.test(n)) return Math.min(
|
|
2561
|
+
if (/^\d+$/.test(n)) return Math.min(Tr, Number.parseInt(n, 10) * 1e3);
|
|
2492
2562
|
if (!/[a-z]/i.test(n)) return;
|
|
2493
2563
|
let r = Date.parse(n);
|
|
2494
|
-
if (!Number.isNaN(r)) return Math.min(
|
|
2564
|
+
if (!Number.isNaN(r)) return Math.min(Tr, Math.max(0, r - t));
|
|
2495
2565
|
}
|
|
2496
|
-
function
|
|
2566
|
+
function ri(e) {
|
|
2497
2567
|
return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
|
|
2498
2568
|
}
|
|
2499
|
-
function
|
|
2569
|
+
function ii(e) {
|
|
2500
2570
|
if (typeof e.id == "string" && e.id !== "") return e.id;
|
|
2501
2571
|
let t = e.response?.data;
|
|
2502
2572
|
if (typeof t != "object" || !t) return;
|
|
@@ -2505,14 +2575,14 @@ function Wr(e) {
|
|
|
2505
2575
|
let r = n.id;
|
|
2506
2576
|
return typeof r == "string" && r !== "" ? r : void 0;
|
|
2507
2577
|
}
|
|
2508
|
-
function
|
|
2578
|
+
function ai(e, t = Date.now()) {
|
|
2509
2579
|
if (typeof e != "object" || !e) return { kind: "transient" };
|
|
2510
|
-
let n = e, r =
|
|
2580
|
+
let n = e, r = ii(n), i = ri(n.response?.status) ?? ri(n.status), a = {};
|
|
2511
2581
|
if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
|
|
2512
2582
|
kind: "blocked",
|
|
2513
2583
|
...a
|
|
2514
2584
|
};
|
|
2515
|
-
if (r !== void 0 &&
|
|
2585
|
+
if (r !== void 0 && ei.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
|
|
2516
2586
|
kind: "auth",
|
|
2517
2587
|
...a
|
|
2518
2588
|
};
|
|
@@ -2520,7 +2590,7 @@ function Gr(e, t = Date.now()) {
|
|
|
2520
2590
|
kind: "transient",
|
|
2521
2591
|
...a
|
|
2522
2592
|
};
|
|
2523
|
-
let o =
|
|
2593
|
+
let o = ni(n.retryAfter ?? ti(n.response?.headers), t);
|
|
2524
2594
|
return o === void 0 ? {
|
|
2525
2595
|
kind: "transient",
|
|
2526
2596
|
...a
|
|
@@ -2530,19 +2600,19 @@ function Gr(e, t = Date.now()) {
|
|
|
2530
2600
|
retryAfterMs: o
|
|
2531
2601
|
};
|
|
2532
2602
|
}
|
|
2533
|
-
function
|
|
2534
|
-
let r =
|
|
2535
|
-
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0),
|
|
2603
|
+
function oi(e, t, n) {
|
|
2604
|
+
let r = Cr.length, i = Cr[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? Cr[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * wr * a);
|
|
2605
|
+
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), Tr) : 0);
|
|
2536
2606
|
}
|
|
2537
2607
|
// lib/refresh/coordinator.ts
|
|
2538
|
-
var
|
|
2608
|
+
var si = {
|
|
2539
2609
|
onGranted: () => !1,
|
|
2540
2610
|
onLockLost: () => void 0,
|
|
2541
2611
|
onMessage: () => void 0
|
|
2542
2612
|
};
|
|
2543
|
-
function
|
|
2544
|
-
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o =
|
|
2545
|
-
g || n.postMessage(
|
|
2613
|
+
function ci(e) {
|
|
2614
|
+
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = si, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
|
|
2615
|
+
g || n.postMessage(Vr(r, e));
|
|
2546
2616
|
}, v = () => s !== null && c === null, y = () => {
|
|
2547
2617
|
f?.(), f = null;
|
|
2548
2618
|
}, b = (e) => {
|
|
@@ -2557,7 +2627,7 @@ function Jr(e) {
|
|
|
2557
2627
|
type: "still-refreshing",
|
|
2558
2628
|
retry: m
|
|
2559
2629
|
} : { type: "still-refreshing" }), ee());
|
|
2560
|
-
},
|
|
2630
|
+
}, Er);
|
|
2561
2631
|
}, S = () => {
|
|
2562
2632
|
y(), x(), u?.(), u = null;
|
|
2563
2633
|
let e = s;
|
|
@@ -2608,7 +2678,7 @@ function Jr(e) {
|
|
|
2608
2678
|
});
|
|
2609
2679
|
}, te = (e) => {
|
|
2610
2680
|
if (g) return;
|
|
2611
|
-
let t =
|
|
2681
|
+
let t = Br(e.data);
|
|
2612
2682
|
if (t && t.tabId !== r) {
|
|
2613
2683
|
switch (t.type) {
|
|
2614
2684
|
case "still-refreshing":
|
|
@@ -2651,8 +2721,8 @@ function Jr(e) {
|
|
|
2651
2721
|
}
|
|
2652
2722
|
};
|
|
2653
2723
|
}
|
|
2654
|
-
function
|
|
2655
|
-
let t =
|
|
2724
|
+
function li(e = "local") {
|
|
2725
|
+
let t = si, n = !1, r = !1, i = 0, a = !1, o = () => {
|
|
2656
2726
|
n = !1, r = !1, i += 1;
|
|
2657
2727
|
};
|
|
2658
2728
|
return {
|
|
@@ -2700,7 +2770,7 @@ var J = {
|
|
|
2700
2770
|
successorTimeout: "error.refresh.successor_timeout",
|
|
2701
2771
|
identityChanged: "error.refresh.identity_changed",
|
|
2702
2772
|
disposed: "error.refresh.disposed"
|
|
2703
|
-
},
|
|
2773
|
+
}, ui = {
|
|
2704
2774
|
"error.refresh.unavailable": 503,
|
|
2705
2775
|
"error.refresh.auth_retry": 401,
|
|
2706
2776
|
"error.refresh.session_ended": 401,
|
|
@@ -2708,7 +2778,7 @@ var J = {
|
|
|
2708
2778
|
"error.refresh.successor_timeout": 401,
|
|
2709
2779
|
"error.refresh.identity_changed": 401,
|
|
2710
2780
|
"error.refresh.disposed": 499
|
|
2711
|
-
},
|
|
2781
|
+
}, di = {
|
|
2712
2782
|
"error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
|
|
2713
2783
|
"error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
|
|
2714
2784
|
"error.refresh.session_ended": "The session has ended",
|
|
@@ -2720,19 +2790,19 @@ var J = {
|
|
|
2720
2790
|
constructor(e, t = {}) {
|
|
2721
2791
|
super({
|
|
2722
2792
|
id: e,
|
|
2723
|
-
message: t.message ??
|
|
2724
|
-
status:
|
|
2793
|
+
message: t.message ?? di[e],
|
|
2794
|
+
status: ui[e],
|
|
2725
2795
|
location: "/auth/refresh",
|
|
2726
2796
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2727
2797
|
}), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
|
|
2728
2798
|
}
|
|
2729
|
-
},
|
|
2799
|
+
}, fi = class extends Error {
|
|
2730
2800
|
constructor(e, t) {
|
|
2731
2801
|
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;
|
|
2732
2802
|
}
|
|
2733
2803
|
};
|
|
2734
2804
|
// lib/refresh/lineage.ts
|
|
2735
|
-
function
|
|
2805
|
+
function pi(e) {
|
|
2736
2806
|
if (!e) return;
|
|
2737
2807
|
let t = 3735928559, n = 1103547991;
|
|
2738
2808
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -2741,24 +2811,24 @@ function $r(e) {
|
|
|
2741
2811
|
}
|
|
2742
2812
|
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);
|
|
2743
2813
|
}
|
|
2744
|
-
function
|
|
2814
|
+
function mi(e) {
|
|
2745
2815
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2746
2816
|
}
|
|
2747
2817
|
function X(e) {
|
|
2748
|
-
let t =
|
|
2818
|
+
let t = pi(e);
|
|
2749
2819
|
if (!e || !t) return;
|
|
2750
2820
|
let n = {};
|
|
2751
2821
|
try {
|
|
2752
2822
|
let t = j(e);
|
|
2753
2823
|
typeof t == "object" && t && (n = t);
|
|
2754
2824
|
} catch {}
|
|
2755
|
-
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a =
|
|
2825
|
+
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = mi(n.sub), o = mi(n.sid);
|
|
2756
2826
|
return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
|
|
2757
2827
|
}
|
|
2758
|
-
var
|
|
2759
|
-
function
|
|
2828
|
+
var hi = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
|
|
2829
|
+
function gi(e = (e) => $r().warn(e)) {
|
|
2760
2830
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
|
|
2761
|
-
a || (a = !0, e(
|
|
2831
|
+
a || (a = !0, e(hi));
|
|
2762
2832
|
}, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
|
|
2763
2833
|
if (!e) return;
|
|
2764
2834
|
if (e.iat === void 0) {
|
|
@@ -2799,16 +2869,16 @@ function ni(e = (e) => zr().warn(e)) {
|
|
|
2799
2869
|
};
|
|
2800
2870
|
}
|
|
2801
2871
|
// lib/refresh/fence.ts
|
|
2802
|
-
var
|
|
2872
|
+
var _i = class extends Error {
|
|
2803
2873
|
constructor(e) {
|
|
2804
2874
|
super(e === "emptied" ? "The shared token storage was emptied" : "The stored refresh token belongs to an ended session"), this.name = "SessionEnded", this.cause = e;
|
|
2805
2875
|
}
|
|
2806
|
-
},
|
|
2876
|
+
}, vi = class extends Error {
|
|
2807
2877
|
constructor() {
|
|
2808
2878
|
super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
|
|
2809
2879
|
}
|
|
2810
2880
|
};
|
|
2811
|
-
function
|
|
2881
|
+
function yi(e) {
|
|
2812
2882
|
if (e) try {
|
|
2813
2883
|
let t = j(e).sub;
|
|
2814
2884
|
return typeof t == "string" && t !== "" ? t : void 0;
|
|
@@ -2817,20 +2887,20 @@ function ai(e) {
|
|
|
2817
2887
|
}
|
|
2818
2888
|
}
|
|
2819
2889
|
function Z(e) {
|
|
2820
|
-
return
|
|
2890
|
+
return yi(e?.access_token) ?? yi(e?.refresh_token) ?? yi(e?.id_token);
|
|
2821
2891
|
}
|
|
2822
|
-
function
|
|
2892
|
+
function bi(e, t) {
|
|
2823
2893
|
return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
|
|
2824
2894
|
}
|
|
2825
|
-
function
|
|
2895
|
+
function xi(e) {
|
|
2826
2896
|
return typeof e == "object" && !!e;
|
|
2827
2897
|
}
|
|
2828
|
-
function
|
|
2829
|
-
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) =>
|
|
2898
|
+
function Si(e) {
|
|
2899
|
+
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => $r().warn(e)), o = e.lineage ?? gi(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
|
|
2830
2900
|
let e = t.getTokens(), n = e?.refresh_token;
|
|
2831
2901
|
if (!n) return p = l, e;
|
|
2832
2902
|
p !== void 0 && (f = Math.max(f, p, m), p = void 0);
|
|
2833
|
-
let r =
|
|
2903
|
+
let r = pi(n) ?? "";
|
|
2834
2904
|
return r !== c?.fp && (c = {
|
|
2835
2905
|
fp: r,
|
|
2836
2906
|
seq: l
|
|
@@ -2865,7 +2935,7 @@ function ci(e) {
|
|
|
2865
2935
|
h = void 0;
|
|
2866
2936
|
let e = y();
|
|
2867
2937
|
e?.refresh_token || C(e) ? A() : te(!0) === "end" && s?.("emptied");
|
|
2868
|
-
},
|
|
2938
|
+
}, kr));
|
|
2869
2939
|
let n = t === "keep" ? T() : void 0;
|
|
2870
2940
|
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;
|
|
2871
2941
|
}, O = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, ne = (e) => {
|
|
@@ -2878,7 +2948,7 @@ function ci(e) {
|
|
|
2878
2948
|
return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
|
|
2879
2949
|
}, 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) => {
|
|
2880
2950
|
let t = b();
|
|
2881
|
-
t && t.fp !==
|
|
2951
|
+
t && t.fp !== pi(e.refresh_token) && o.retire(t), n.setTokensCache(e);
|
|
2882
2952
|
}, oe = (e) => {
|
|
2883
2953
|
let t = y(), n = t?.refresh_token;
|
|
2884
2954
|
if (n === e.refreshToken) return null;
|
|
@@ -2889,7 +2959,7 @@ function ci(e) {
|
|
|
2889
2959
|
kind: "superseded",
|
|
2890
2960
|
adopted: !1
|
|
2891
2961
|
};
|
|
2892
|
-
let r =
|
|
2962
|
+
let r = yi(t.access_token) ?? yi(n);
|
|
2893
2963
|
if (e.sub && r && e.sub !== r) return {
|
|
2894
2964
|
kind: "identity-changed",
|
|
2895
2965
|
saved: !1
|
|
@@ -2930,22 +3000,22 @@ function ci(e) {
|
|
|
2930
3000
|
let e = y();
|
|
2931
3001
|
if (C(e)) return "held";
|
|
2932
3002
|
if (!e?.refresh_token) {
|
|
2933
|
-
if (te() === "end") throw new
|
|
3003
|
+
if (te() === "end") throw new _i("emptied");
|
|
2934
3004
|
return "held";
|
|
2935
3005
|
}
|
|
2936
3006
|
let t = n.getTokens();
|
|
2937
3007
|
if (e.refresh_token === t?.refresh_token) return "send";
|
|
2938
3008
|
let r = i() ?? Z(t), a = Z(e);
|
|
2939
|
-
if (r && a && r !== a) throw new
|
|
3009
|
+
if (r && a && r !== a) throw new vi();
|
|
2940
3010
|
let s = X(e.refresh_token);
|
|
2941
3011
|
if (o.isEnded(s)) {
|
|
2942
3012
|
if (s && S(s)) return "held";
|
|
2943
|
-
throw new
|
|
3013
|
+
throw new _i("ended");
|
|
2944
3014
|
}
|
|
2945
3015
|
let c = X(t?.refresh_token);
|
|
2946
3016
|
return ie(s, c) ? (ae(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && ne(s) ? "held" : "send";
|
|
2947
3017
|
}, ce = (e) => {
|
|
2948
|
-
let t = i(), r =
|
|
3018
|
+
let t = i(), r = yi(e);
|
|
2949
3019
|
if (t && r && t !== r) return { kind: "identity-changed" };
|
|
2950
3020
|
let a = X(e) ?? { fp: e };
|
|
2951
3021
|
if (o.isEnded(a)) return S(a) ? { kind: "superseded" } : { kind: "ended" };
|
|
@@ -2953,7 +3023,7 @@ function ci(e) {
|
|
|
2953
3023
|
let s = {
|
|
2954
3024
|
refreshToken: e,
|
|
2955
3025
|
order: a
|
|
2956
|
-
}, c = t ?? r ??
|
|
3026
|
+
}, c = t ?? r ?? yi(n.getTokens()?.access_token);
|
|
2957
3027
|
return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
|
|
2958
3028
|
kind: "send",
|
|
2959
3029
|
sent: s
|
|
@@ -2962,7 +3032,7 @@ function ci(e) {
|
|
|
2962
3032
|
if (o.isEnded(e.order)) return k(e.order);
|
|
2963
3033
|
let i = oe(e);
|
|
2964
3034
|
if (i) return i;
|
|
2965
|
-
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 ${
|
|
3035
|
+
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 ${pi(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.`), {
|
|
2966
3036
|
kind: "superseded",
|
|
2967
3037
|
adopted: !1
|
|
2968
3038
|
};
|
|
@@ -2972,7 +3042,7 @@ function ci(e) {
|
|
|
2972
3042
|
saved: !0
|
|
2973
3043
|
};
|
|
2974
3044
|
let c = X(r.refresh_token);
|
|
2975
|
-
return c && (
|
|
3045
|
+
return c && (bi(c, e.order) || bi(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.`), {
|
|
2976
3046
|
kind: "superseded",
|
|
2977
3047
|
adopted: !1
|
|
2978
3048
|
}) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
|
|
@@ -2984,7 +3054,7 @@ function ci(e) {
|
|
|
2984
3054
|
kind: "superseded",
|
|
2985
3055
|
adopted: !1
|
|
2986
3056
|
};
|
|
2987
|
-
let r =
|
|
3057
|
+
let r = ai(t), i = r.kind === "blocked" || r.kind === "auth";
|
|
2988
3058
|
return O(e) && i ? (o.retire(e.order), _ = e.order, {
|
|
2989
3059
|
kind: "own",
|
|
2990
3060
|
failure: r,
|
|
@@ -2995,11 +3065,11 @@ function ci(e) {
|
|
|
2995
3065
|
heldRefused: !1
|
|
2996
3066
|
});
|
|
2997
3067
|
}, I = (e) => {
|
|
2998
|
-
if (!
|
|
3068
|
+
if (!xi(e)) return !1;
|
|
2999
3069
|
let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
|
|
3000
|
-
if (typeof t != "string" || typeof c != "string" || !
|
|
3070
|
+
if (typeof t != "string" || typeof c != "string" || !xi(l)) return !1;
|
|
3001
3071
|
let u = l;
|
|
3002
|
-
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" ||
|
|
3072
|
+
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || pi(u.refresh_token) !== c) return !1;
|
|
3003
3073
|
let d = y();
|
|
3004
3074
|
if (!d?.refresh_token) return !1;
|
|
3005
3075
|
let f = n.getTokens(), p = i() ?? Z(f), m = Z(u);
|
|
@@ -3016,7 +3086,7 @@ function ci(e) {
|
|
|
3016
3086
|
}
|
|
3017
3087
|
return !0;
|
|
3018
3088
|
};
|
|
3019
|
-
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t &&
|
|
3089
|
+
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && pi(d.refresh_token) !== c ? !1 : (ae({ ...u }), _());
|
|
3020
3090
|
}, le = (e) => {
|
|
3021
3091
|
if (!e || !_) return !1;
|
|
3022
3092
|
let t = _;
|
|
@@ -3082,7 +3152,7 @@ function ci(e) {
|
|
|
3082
3152
|
};
|
|
3083
3153
|
}
|
|
3084
3154
|
// lib/refresh/controller.ts
|
|
3085
|
-
function
|
|
3155
|
+
function Ci() {
|
|
3086
3156
|
let e, t, n = new Promise((n, r) => {
|
|
3087
3157
|
e = n, t = r;
|
|
3088
3158
|
});
|
|
@@ -3092,7 +3162,7 @@ function li() {
|
|
|
3092
3162
|
reject: t
|
|
3093
3163
|
};
|
|
3094
3164
|
}
|
|
3095
|
-
var
|
|
3165
|
+
var wi = {
|
|
3096
3166
|
strikes: J.sessionEnded,
|
|
3097
3167
|
"session-ended": J.sessionEnded,
|
|
3098
3168
|
"stored-ended": J.sessionEnded,
|
|
@@ -3103,42 +3173,42 @@ var ui = {
|
|
|
3103
3173
|
"identity-changed": J.identityChanged,
|
|
3104
3174
|
disposed: J.disposed
|
|
3105
3175
|
};
|
|
3106
|
-
function
|
|
3176
|
+
function Ti(e) {
|
|
3107
3177
|
throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
|
|
3108
3178
|
}
|
|
3109
|
-
function
|
|
3179
|
+
function Ei(e) {
|
|
3110
3180
|
if (e === void 0 || !Number.isFinite(e)) return 3;
|
|
3111
3181
|
let t = Math.floor(e);
|
|
3112
3182
|
return t >= 1 ? t : 3;
|
|
3113
3183
|
}
|
|
3114
|
-
function
|
|
3184
|
+
function Di(e, t) {
|
|
3115
3185
|
return e instanceof Error && e.message ? e.message : t;
|
|
3116
3186
|
}
|
|
3117
|
-
function
|
|
3187
|
+
function Oi(e) {
|
|
3118
3188
|
if (typeof e != "object" || !e) return;
|
|
3119
3189
|
let t = e.id;
|
|
3120
3190
|
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
3121
3191
|
}
|
|
3122
|
-
function
|
|
3192
|
+
function ki(e) {
|
|
3123
3193
|
let t = {};
|
|
3124
3194
|
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;
|
|
3125
3195
|
}
|
|
3126
|
-
function
|
|
3196
|
+
function Ai(e, t) {
|
|
3127
3197
|
let n = {};
|
|
3128
3198
|
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);
|
|
3129
3199
|
let r = t?.scopes ?? e.scopes;
|
|
3130
3200
|
return r && (n.scopes = r), n;
|
|
3131
3201
|
}
|
|
3132
|
-
function
|
|
3133
|
-
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ??
|
|
3202
|
+
function ji(e) {
|
|
3203
|
+
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? $r(), c = Ei(e.strikes), l = a.transports ? ci({
|
|
3134
3204
|
locks: a.transports.locks,
|
|
3135
3205
|
channel: a.transports.channel,
|
|
3136
3206
|
tabId: a.transports.tabId,
|
|
3137
3207
|
names: a.names,
|
|
3138
3208
|
clock: o
|
|
3139
|
-
}) :
|
|
3209
|
+
}) : li(), 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 = () => pi(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) => () => {
|
|
3140
3210
|
for (let t of Array.from(e)) t();
|
|
3141
|
-
}, ae = a.onStorageChange?.(ie(ne)), oe = e.platform?.onForeground(ie(re)), k =
|
|
3211
|
+
}, ae = a.onStorageChange?.(ie(ne)), oe = e.platform?.onForeground(ie(re)), k = Si({
|
|
3142
3212
|
storage: n,
|
|
3143
3213
|
cache: r,
|
|
3144
3214
|
identity: O,
|
|
@@ -3153,13 +3223,13 @@ function _i(e) {
|
|
|
3153
3223
|
}), A = (e) => ({
|
|
3154
3224
|
trigger: e,
|
|
3155
3225
|
startedAt: w(),
|
|
3156
|
-
plain:
|
|
3226
|
+
plain: Ci(),
|
|
3157
3227
|
fresh: []
|
|
3158
3228
|
}), j = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, M = (e, t) => {
|
|
3159
3229
|
if (t === void 0) return e.plain.promise;
|
|
3160
3230
|
let n = {
|
|
3161
3231
|
callTime: t,
|
|
3162
|
-
deferred:
|
|
3232
|
+
deferred: Ci()
|
|
3163
3233
|
};
|
|
3164
3234
|
return e.fresh.push(n), n.deferred.promise;
|
|
3165
3235
|
}, N = (e, t, n = !1) => {
|
|
@@ -3178,11 +3248,11 @@ function _i(e) {
|
|
|
3178
3248
|
}
|
|
3179
3249
|
}, P = (e, n, r, i) => {
|
|
3180
3250
|
let a = {
|
|
3181
|
-
message:
|
|
3251
|
+
message: Di(r, "Token refresh failed"),
|
|
3182
3252
|
originalError: r,
|
|
3183
3253
|
operation: e,
|
|
3184
3254
|
source: n
|
|
3185
|
-
}, o =
|
|
3255
|
+
}, o = Oi(r);
|
|
3186
3256
|
o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
|
|
3187
3257
|
}, F = (e, t) => {
|
|
3188
3258
|
let n = {
|
|
@@ -3212,10 +3282,10 @@ function _i(e) {
|
|
|
3212
3282
|
};
|
|
3213
3283
|
n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
|
|
3214
3284
|
}, ue = (e, t) => {
|
|
3215
|
-
let n = r.getTokens(), i =
|
|
3285
|
+
let n = r.getTokens(), i = pi(n?.refresh_token);
|
|
3216
3286
|
e.fp && i && l.post({
|
|
3217
3287
|
type: "tokens-refreshed",
|
|
3218
|
-
tokens:
|
|
3288
|
+
tokens: ki(n),
|
|
3219
3289
|
from: e.fp,
|
|
3220
3290
|
...e.iat === void 0 ? {} : { fromIat: e.iat },
|
|
3221
3291
|
fromSid: e.sid ?? "",
|
|
@@ -3223,7 +3293,7 @@ function _i(e) {
|
|
|
3223
3293
|
...t === void 0 ? {} : { sentAt: t }
|
|
3224
3294
|
});
|
|
3225
3295
|
}, de = () => {
|
|
3226
|
-
p || (p = !0, s.warn(
|
|
3296
|
+
p || (p = !0, s.warn(Hr));
|
|
3227
3297
|
}, fe = (e) => {
|
|
3228
3298
|
(e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
|
|
3229
3299
|
}, L = (e, n) => {
|
|
@@ -3237,7 +3307,7 @@ function _i(e) {
|
|
|
3237
3307
|
}, e !== "disposed" && k.dropSession(), (e === "strikes" || e === "successor-timeout") && T() !== "json" && i.invalidate(), u = {
|
|
3238
3308
|
kind: "ended",
|
|
3239
3309
|
cause: e
|
|
3240
|
-
}, ce(r, n ?? new Y(
|
|
3310
|
+
}, ce(r, n ?? new Y(wi[e])), e) {
|
|
3241
3311
|
case "strikes":
|
|
3242
3312
|
t("session:expired", {
|
|
3243
3313
|
reason: "refresh_failed",
|
|
@@ -3272,7 +3342,7 @@ function _i(e) {
|
|
|
3272
3342
|
break;
|
|
3273
3343
|
case "signed-out-here":
|
|
3274
3344
|
case "disposed": break;
|
|
3275
|
-
default:
|
|
3345
|
+
default: Ti(e);
|
|
3276
3346
|
}
|
|
3277
3347
|
}, R = () => {
|
|
3278
3348
|
if (u.kind !== "ended" || u.cause === "disposed" || f || T() !== "json") return;
|
|
@@ -3289,10 +3359,10 @@ function _i(e) {
|
|
|
3289
3359
|
}, pe = (e) => {
|
|
3290
3360
|
u.kind === "ended" || f || T() === "json" && (L(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && R());
|
|
3291
3361
|
}, me = (e) => {
|
|
3292
|
-
e instanceof
|
|
3362
|
+
e instanceof vi ? (L("identity-changed"), R()) : e instanceof _i ? L(e.cause === "emptied" ? "emptied" : "stored-ended") : L("stored-ended", e);
|
|
3293
3363
|
}, he = () => {
|
|
3294
3364
|
u = { kind: "idle" }, C || l.release();
|
|
3295
|
-
}, ge = (e) => !e.from || T() !== "json" || e.from === E() || e.from ===
|
|
3365
|
+
}, ge = (e) => !e.from || T() !== "json" || e.from === E() || e.from === pi(n.getTokens()?.refresh_token), _e = (e) => {
|
|
3296
3366
|
let t = g;
|
|
3297
3367
|
if (!t) return;
|
|
3298
3368
|
if (!l.holding) {
|
|
@@ -3358,14 +3428,14 @@ function _i(e) {
|
|
|
3358
3428
|
case "ended": return k.endHeldSend(), L("stored-ended"), !1;
|
|
3359
3429
|
case "identity-changed": return k.endHeldSend(), L("identity-changed"), R(), !1;
|
|
3360
3430
|
case "send": return Ce(e, t, a.sent, r);
|
|
3361
|
-
default: return
|
|
3431
|
+
default: return Ti(a);
|
|
3362
3432
|
}
|
|
3363
3433
|
}, Ce = (e, n, r, a) => {
|
|
3364
3434
|
let o = {
|
|
3365
3435
|
generation: d,
|
|
3366
3436
|
sentAt: w(),
|
|
3367
3437
|
trigger: n,
|
|
3368
|
-
settled:
|
|
3438
|
+
settled: Ci()
|
|
3369
3439
|
};
|
|
3370
3440
|
r ? o.sent = r : o.marker = te(), a && (o.stored = a), u = {
|
|
3371
3441
|
kind: "refreshing",
|
|
@@ -3402,7 +3472,7 @@ function _i(e) {
|
|
|
3402
3472
|
if (!we(e)) return;
|
|
3403
3473
|
r.setTokensCache({
|
|
3404
3474
|
...n.getTokens() ?? {},
|
|
3405
|
-
...
|
|
3475
|
+
...Ai(t, void 0)
|
|
3406
3476
|
}), I("refresh", "this-tab");
|
|
3407
3477
|
let c = O();
|
|
3408
3478
|
l.post(c === void 0 ? {
|
|
@@ -3415,7 +3485,7 @@ function _i(e) {
|
|
|
3415
3485
|
}), he(), N(a, e.sentAt);
|
|
3416
3486
|
return;
|
|
3417
3487
|
}
|
|
3418
|
-
let o = E(), s = k.commitSave(e.sent,
|
|
3488
|
+
let o = E(), s = k.commitSave(e.sent, Ai(t, e.stored));
|
|
3419
3489
|
switch (s.kind) {
|
|
3420
3490
|
case "saved":
|
|
3421
3491
|
I("refresh", "this-tab"), ue(e.sent.order, e.sentAt), he(), N(a, e.sentAt);
|
|
@@ -3433,7 +3503,7 @@ function _i(e) {
|
|
|
3433
3503
|
P("refresh", e.trigger, t, F("auth")), L("identity-changed", t), R();
|
|
3434
3504
|
return;
|
|
3435
3505
|
}
|
|
3436
|
-
default:
|
|
3506
|
+
default: Ti(s);
|
|
3437
3507
|
}
|
|
3438
3508
|
}, Ee = (e, t) => {
|
|
3439
3509
|
if (e.sent?.held && k.endHeldSend(), !we(e) || u.kind !== "refreshing") return;
|
|
@@ -3453,9 +3523,9 @@ function _i(e) {
|
|
|
3453
3523
|
case "own":
|
|
3454
3524
|
r = o.failure, i = o.heldRefused;
|
|
3455
3525
|
break;
|
|
3456
|
-
default:
|
|
3526
|
+
default: Ti(o);
|
|
3457
3527
|
}
|
|
3458
|
-
} else r =
|
|
3528
|
+
} else r = ai(t, w());
|
|
3459
3529
|
if (i) P("refresh", e.trigger, t, F(r.kind)), I("adopted", "other-tab"), he(), N(n, void 0, !0);
|
|
3460
3530
|
else switch (r.kind) {
|
|
3461
3531
|
case "blocked":
|
|
@@ -3471,10 +3541,10 @@ function _i(e) {
|
|
|
3471
3541
|
case "transient":
|
|
3472
3542
|
m += 1, De(e, n, t, r);
|
|
3473
3543
|
return;
|
|
3474
|
-
default:
|
|
3544
|
+
default: Ti(r.kind);
|
|
3475
3545
|
}
|
|
3476
3546
|
}, De = (e, t, n, r) => {
|
|
3477
|
-
let i = w() +
|
|
3547
|
+
let i = w() + oi(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
|
|
3478
3548
|
P("refresh", e.trigger, n, F(a, i)), a === "transient" && le(w(), i, "this-tab");
|
|
3479
3549
|
let s = {
|
|
3480
3550
|
kind: a,
|
|
@@ -3484,7 +3554,7 @@ function _i(e) {
|
|
|
3484
3554
|
}, c = e.sent?.order.fp;
|
|
3485
3555
|
c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
|
|
3486
3556
|
type: "retry-scheduled",
|
|
3487
|
-
message:
|
|
3557
|
+
message: Di(n, "Token refresh failed"),
|
|
3488
3558
|
retry: s
|
|
3489
3559
|
}), _e(A("retry")), se(t, n, e.sentAt);
|
|
3490
3560
|
}, Oe = (e, t) => {
|
|
@@ -3497,8 +3567,8 @@ function _i(e) {
|
|
|
3497
3567
|
fp: i.fp
|
|
3498
3568
|
})), r && k.deleteIfStillDead(r), L("strikes", t);
|
|
3499
3569
|
}, ke = (e, t, n, r) => {
|
|
3500
|
-
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${
|
|
3501
|
-
let i = d, a = w() +
|
|
3570
|
+
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${Di(n, "blocked")}`);
|
|
3571
|
+
let i = d, a = w() + Dr, c = {
|
|
3502
3572
|
kind: "blocked-wait",
|
|
3503
3573
|
pending: e,
|
|
3504
3574
|
deadline: a,
|
|
@@ -3511,9 +3581,9 @@ function _i(e) {
|
|
|
3511
3581
|
i === d && u === c && (Ae() || (f ? (e.cookieRetried = !0, u = {
|
|
3512
3582
|
kind: "waiting",
|
|
3513
3583
|
pending: e
|
|
3514
|
-
}, 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,
|
|
3584
|
+
}, 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, Or)));
|
|
3515
3585
|
};
|
|
3516
|
-
c.cancel = o.setTimeout(p, f ?
|
|
3586
|
+
c.cancel = o.setTimeout(p, f ? Ar : Or);
|
|
3517
3587
|
}, Ae = () => {
|
|
3518
3588
|
if (u.kind !== "blocked-wait") return !1;
|
|
3519
3589
|
let e = u;
|
|
@@ -3557,7 +3627,7 @@ function _i(e) {
|
|
|
3557
3627
|
case "idle":
|
|
3558
3628
|
case "refreshing":
|
|
3559
3629
|
case "ended": return;
|
|
3560
|
-
default:
|
|
3630
|
+
default: Ti(u);
|
|
3561
3631
|
}
|
|
3562
3632
|
}, Fe = (e) => {
|
|
3563
3633
|
let t = {};
|
|
@@ -3600,7 +3670,7 @@ function _i(e) {
|
|
|
3600
3670
|
Ne(e.retry, !0, e.message), Le();
|
|
3601
3671
|
return;
|
|
3602
3672
|
case "refresh-failed":
|
|
3603
|
-
if (u.kind === "ended" || T() !== "json" || e.from !== E() && e.from !==
|
|
3673
|
+
if (u.kind === "ended" || T() !== "json" || e.from !== E() && e.from !== pi(n.getTokens()?.refresh_token)) return;
|
|
3604
3674
|
if (le(w(), void 0, "other-tab"), u.kind === "waiting") {
|
|
3605
3675
|
let t = u.pending;
|
|
3606
3676
|
u.pending = A(t.trigger), se(t, new Y(J.unavailable, { cause: e.message }), void 0);
|
|
@@ -3621,7 +3691,7 @@ function _i(e) {
|
|
|
3621
3691
|
return;
|
|
3622
3692
|
case "takeover":
|
|
3623
3693
|
case "rate-limited": return;
|
|
3624
|
-
default:
|
|
3694
|
+
default: Ti(e);
|
|
3625
3695
|
}
|
|
3626
3696
|
}, Le = () => {
|
|
3627
3697
|
S && !l.holding && l.post({
|
|
@@ -3686,7 +3756,7 @@ function _i(e) {
|
|
|
3686
3756
|
case "refreshing":
|
|
3687
3757
|
case "backoff":
|
|
3688
3758
|
case "blocked-wait": return M(u.pending, t);
|
|
3689
|
-
default: return
|
|
3759
|
+
default: return Ti(u);
|
|
3690
3760
|
}
|
|
3691
3761
|
}, ze = (e) => {
|
|
3692
3762
|
if (f) return Promise.reject(new Y(J.disposed));
|
|
@@ -3737,9 +3807,9 @@ function _i(e) {
|
|
|
3737
3807
|
}, B = async (e, t) => {
|
|
3738
3808
|
if (f) throw new Y(J.disposed);
|
|
3739
3809
|
de();
|
|
3740
|
-
let n = w() +
|
|
3810
|
+
let n = w() + jr;
|
|
3741
3811
|
if (await He(n - w()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await Ve("commit", n - w())) === "timeout") {
|
|
3742
|
-
let e = new
|
|
3812
|
+
let e = new fi("lock-timeout");
|
|
3743
3813
|
throw P("upgrade.commit", "upgrade", e), e;
|
|
3744
3814
|
}
|
|
3745
3815
|
C = !0;
|
|
@@ -3785,12 +3855,12 @@ function _i(e) {
|
|
|
3785
3855
|
}
|
|
3786
3856
|
if (!o) {
|
|
3787
3857
|
if (u !== d) {
|
|
3788
|
-
let e = new
|
|
3858
|
+
let e = new fi("superseded");
|
|
3789
3859
|
throw P("upgrade.commit", "upgrade", e), e;
|
|
3790
3860
|
}
|
|
3791
3861
|
await i.applyOpaque(f), r.setTokensCache({
|
|
3792
3862
|
...n.getTokens() ?? {},
|
|
3793
|
-
...
|
|
3863
|
+
...Ai(f, void 0)
|
|
3794
3864
|
}), Ge(c);
|
|
3795
3865
|
let e = O();
|
|
3796
3866
|
return l.post(e === void 0 ? {
|
|
@@ -3802,9 +3872,9 @@ function _i(e) {
|
|
|
3802
3872
|
sub: e
|
|
3803
3873
|
}), D();
|
|
3804
3874
|
}
|
|
3805
|
-
let p = k.commitSave(o,
|
|
3875
|
+
let p = k.commitSave(o, Ai(f, s));
|
|
3806
3876
|
if (p.kind === "saved") return Ge(c), ue(o.order, c), D();
|
|
3807
|
-
let m = new
|
|
3877
|
+
let m = new fi("superseded");
|
|
3808
3878
|
throw P("upgrade.commit", "upgrade", m), p.kind === "superseded" && p.adopted && I("adopted", "other-tab"), m;
|
|
3809
3879
|
}, Ge = (e) => {
|
|
3810
3880
|
if (I("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
|
|
@@ -3830,7 +3900,7 @@ function _i(e) {
|
|
|
3830
3900
|
commitUpgrade: B,
|
|
3831
3901
|
signOut: async (e) => {
|
|
3832
3902
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3833
|
-
let t = w() +
|
|
3903
|
+
let t = w() + Mr;
|
|
3834
3904
|
qe(), await He(t - w()), qe(), l.coordinated && !l.holding && await Ve("logout", t - w());
|
|
3835
3905
|
try {
|
|
3836
3906
|
Ke(), await e(n.getTokens()?.refresh_token);
|
|
@@ -3876,7 +3946,7 @@ function _i(e) {
|
|
|
3876
3946
|
};
|
|
3877
3947
|
}
|
|
3878
3948
|
// lib/token/verify.ts
|
|
3879
|
-
var
|
|
3949
|
+
var Mi = {
|
|
3880
3950
|
ES256: {
|
|
3881
3951
|
kty: "EC",
|
|
3882
3952
|
key: (e) => ({
|
|
@@ -3907,34 +3977,34 @@ var vi = {
|
|
|
3907
3977
|
},
|
|
3908
3978
|
signature: { name: "RSASSA-PKCS1-v1_5" }
|
|
3909
3979
|
}
|
|
3910
|
-
},
|
|
3980
|
+
}, Ni = (e) => {
|
|
3911
3981
|
let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = globalThis.atob(t + "=".repeat((4 - t.length % 4) % 4));
|
|
3912
3982
|
return Uint8Array.from(n, (e) => e.charCodeAt(0));
|
|
3913
|
-
},
|
|
3983
|
+
}, Pi = () => {
|
|
3914
3984
|
let e = globalThis.crypto;
|
|
3915
3985
|
if (!e?.subtle) throw Error("Verifying tokens needs the Web Crypto API, available only in a secure context (https or localhost)");
|
|
3916
3986
|
return e;
|
|
3917
3987
|
};
|
|
3918
|
-
async function
|
|
3919
|
-
let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(
|
|
3988
|
+
async function Fi(e, t, n, r, i) {
|
|
3989
|
+
let [a = "", o = "", s = ""] = e.split("."), c = JSON.parse(new TextDecoder().decode(Ni(a))), l = c.alg === "ES256" || c.alg === "RS256" ? Mi[c.alg] : void 0;
|
|
3920
3990
|
if (!l) throw Error(`Token signing algorithm ${String(c.alg)} is not accepted`);
|
|
3921
3991
|
let u = t.find((e) => e.kid === c.kid && e.kty === l.kty && (e.kty !== "EC" || e.crv === "P-256"));
|
|
3922
3992
|
if (!u) throw Error("Token signing key is not published by the server");
|
|
3923
|
-
let d =
|
|
3924
|
-
if (!await d.verify(l.signature, f,
|
|
3993
|
+
let d = Pi().subtle, f = await d.importKey("jwk", l.key(u), l.imported, !1, ["verify"]), p = new TextEncoder().encode(`${a}.${o}`);
|
|
3994
|
+
if (!await d.verify(l.signature, f, Ni(s), p)) throw Error("Token signature is not valid");
|
|
3925
3995
|
let m = j(e), h = Array.isArray(m.aud) ? m.aud : [m.aud];
|
|
3926
3996
|
if (m.iss !== n) throw Error("Token issuer does not match the server");
|
|
3927
3997
|
if (!h.includes(r)) throw Error("Token is not issued for this app");
|
|
3928
3998
|
if (typeof m.exp != "number" || A(m, 0)) throw Error("Token has expired");
|
|
3929
3999
|
if (i && m.type !== i) throw Error("Token type is not valid");
|
|
3930
4000
|
}
|
|
3931
|
-
async function
|
|
4001
|
+
async function Ii(t, n, r) {
|
|
3932
4002
|
if (!n) throw Error("An app id is required to accept tokens from the URL");
|
|
3933
4003
|
if (!r.access_token) throw Error("No access token received");
|
|
3934
|
-
|
|
4004
|
+
Pi();
|
|
3935
4005
|
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 ?? [];
|
|
3936
4006
|
if (!s) throw Error("The server did not publish an issuer");
|
|
3937
|
-
await
|
|
4007
|
+
await Fi(r.access_token, c, s, n, M.access_token), r.refresh_token && await Fi(r.refresh_token, c, s, n, M.refresh_token), r.id_token && await Fi(r.id_token, c, s, n);
|
|
3938
4008
|
}
|
|
3939
4009
|
// lib/upgrade/errors.ts
|
|
3940
4010
|
var Q = {
|
|
@@ -3954,23 +4024,23 @@ var Q = {
|
|
|
3954
4024
|
grantPredatesCredentialReset: "error.grant.predates_credential_reset",
|
|
3955
4025
|
tokenAccessEnded: "error.token.access_ended",
|
|
3956
4026
|
userNotFound: "error.user.not_found"
|
|
3957
|
-
},
|
|
4027
|
+
}, Li = Object.freeze([
|
|
3958
4028
|
Q.twoFactorCodeInvalid,
|
|
3959
4029
|
Q.twoFactorNotEnabled,
|
|
3960
4030
|
Q.challengeInvalid,
|
|
3961
4031
|
Q.challengeSessionMismatch,
|
|
3962
4032
|
Q.challengeTooManyAttempts
|
|
3963
|
-
]),
|
|
4033
|
+
]), Ri = Object.freeze([
|
|
3964
4034
|
Q.tokenInvalid,
|
|
3965
4035
|
Q.grantPredatesCredentialReset,
|
|
3966
4036
|
Q.tokenAccessEnded,
|
|
3967
4037
|
Q.userNotFound
|
|
3968
|
-
]),
|
|
4038
|
+
]), zi = Object.freeze([
|
|
3969
4039
|
"wrong_code",
|
|
3970
4040
|
"challenge_spent",
|
|
3971
4041
|
"not_registered",
|
|
3972
4042
|
"prepare_not_required"
|
|
3973
|
-
]),
|
|
4043
|
+
]), Bi = (e) => zi.includes(e), Vi = {
|
|
3974
4044
|
wrong_code: "That code was not accepted. Try again.",
|
|
3975
4045
|
challenge_spent: "That verification challenge is no longer valid. Start again.",
|
|
3976
4046
|
exhausted: "Too many attempts. Try again later.",
|
|
@@ -3985,9 +4055,9 @@ var Q = {
|
|
|
3985
4055
|
session_changed: "The session ended during verification."
|
|
3986
4056
|
}, $ = class extends Error {
|
|
3987
4057
|
constructor(e) {
|
|
3988
|
-
super(e.message ||
|
|
4058
|
+
super(e.message || Vi[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 = Bi(e.kind), e.cause !== void 0 && (this.cause = e.cause);
|
|
3989
4059
|
}
|
|
3990
|
-
},
|
|
4060
|
+
}, Hi = Object.freeze([
|
|
3991
4061
|
"upgrade_transport",
|
|
3992
4062
|
"upgrade_insufficient",
|
|
3993
4063
|
"upgrade_unavailable",
|
|
@@ -3995,14 +4065,14 @@ var Q = {
|
|
|
3995
4065
|
"upgrade_cancelled",
|
|
3996
4066
|
"upgrade_unsatisfiable",
|
|
3997
4067
|
"upgrade_sign_in_required"
|
|
3998
|
-
]),
|
|
4068
|
+
]), Ui = (e) => typeof e == "object" && !!e && typeof e.code == "string" && Hi.includes(e.code), Wi = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", Gi = (e) => {
|
|
3999
4069
|
let t = e?.error, n = typeof t == "string" ? t : t?.message;
|
|
4000
4070
|
if (typeof n == "string" && n && !n.startsWith("localized error:")) return n;
|
|
4001
|
-
},
|
|
4071
|
+
}, Ki = (e) => {
|
|
4002
4072
|
if (!e || typeof e != "object") return;
|
|
4003
4073
|
let t = e["retry-after"];
|
|
4004
4074
|
return typeof t == "string" && /^\d+$/.test(t.trim()) ? Number(t.trim()) : void 0;
|
|
4005
|
-
},
|
|
4075
|
+
}, qi = (e) => {
|
|
4006
4076
|
if (typeof e != "object" || !e) return {
|
|
4007
4077
|
hasResponse: !1,
|
|
4008
4078
|
message: typeof e == "string" ? e : void 0
|
|
@@ -4013,10 +4083,10 @@ var Q = {
|
|
|
4013
4083
|
errorId: typeof t.id == "string" ? t.id : i,
|
|
4014
4084
|
message: typeof t.message == "string" ? t.message : void 0,
|
|
4015
4085
|
hasResponse: n !== void 0 || typeof t.status == "number",
|
|
4016
|
-
serverText:
|
|
4017
|
-
retryAfter:
|
|
4086
|
+
serverText: Gi(n?.data),
|
|
4087
|
+
retryAfter: Ki(n?.headers)
|
|
4018
4088
|
};
|
|
4019
|
-
},
|
|
4089
|
+
}, Ji = (e, t) => {
|
|
4020
4090
|
switch (e) {
|
|
4021
4091
|
case Q.twoFactorCodeInvalid: return "wrong_code";
|
|
4022
4092
|
case Q.challengeInvalid:
|
|
@@ -4034,15 +4104,15 @@ var Q = {
|
|
|
4034
4104
|
case "error.service.unavailable": return "network";
|
|
4035
4105
|
default: return;
|
|
4036
4106
|
}
|
|
4037
|
-
},
|
|
4107
|
+
}, Yi = (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", Xi = (e, t) => {
|
|
4038
4108
|
if (e instanceof $) return e;
|
|
4039
|
-
let n =
|
|
4109
|
+
let n = qi(e);
|
|
4040
4110
|
if (!n.hasResponse) return new $({
|
|
4041
4111
|
kind: "network",
|
|
4042
4112
|
message: n.message,
|
|
4043
4113
|
cause: e
|
|
4044
4114
|
});
|
|
4045
|
-
let r =
|
|
4115
|
+
let r = Ji(n.errorId, t) ?? Yi(n.status, t);
|
|
4046
4116
|
return r === "rate_limited" ? new $({
|
|
4047
4117
|
kind: r,
|
|
4048
4118
|
message: n.serverText,
|
|
@@ -4057,61 +4127,61 @@ var Q = {
|
|
|
4057
4127
|
errorId: n.errorId,
|
|
4058
4128
|
cause: e
|
|
4059
4129
|
});
|
|
4060
|
-
},
|
|
4130
|
+
}, Zi = (e) => e.errorId !== void 0 && Li.includes(e.errorId), Qi = (e) => e.errorId !== void 0 && Ri.includes(e.errorId), $i = class extends Error {
|
|
4061
4131
|
constructor(e, t, n) {
|
|
4062
4132
|
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;
|
|
4063
4133
|
}
|
|
4064
|
-
},
|
|
4134
|
+
}, ea = class extends Error {
|
|
4065
4135
|
constructor(e = "Step-up verification is not available on this deployment") {
|
|
4066
4136
|
super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
|
|
4067
4137
|
}
|
|
4068
|
-
},
|
|
4138
|
+
}, ta = class extends Error {
|
|
4069
4139
|
constructor(e = "The session changed during verification") {
|
|
4070
4140
|
super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
|
|
4071
4141
|
}
|
|
4072
|
-
},
|
|
4142
|
+
}, na = (e) => {
|
|
4073
4143
|
if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
|
|
4074
4144
|
sub: e.sub,
|
|
4075
4145
|
sid: e.sid
|
|
4076
4146
|
} : { sub: e.sub };
|
|
4077
|
-
},
|
|
4147
|
+
}, ra = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
|
|
4078
4148
|
// lib/utils/validation.ts
|
|
4079
|
-
function
|
|
4149
|
+
function ia(e) {
|
|
4080
4150
|
if (!e || typeof e != "string") return !1;
|
|
4081
4151
|
let t = e.split(".");
|
|
4082
4152
|
if (t.length !== 3) return !1;
|
|
4083
4153
|
let n = /^[A-Za-z0-9_-]+$/;
|
|
4084
4154
|
return t.every((e) => n.test(e) && e.length > 0);
|
|
4085
4155
|
}
|
|
4086
|
-
function
|
|
4156
|
+
function aa(e) {
|
|
4087
4157
|
return e.replace(/<[^>]*>/g, "").substring(0, 200);
|
|
4088
4158
|
}
|
|
4089
|
-
function
|
|
4159
|
+
function oa(e) {
|
|
4090
4160
|
if (!e || typeof e != "string") return !1;
|
|
4091
4161
|
let t = e.trim();
|
|
4092
4162
|
return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
|
|
4093
4163
|
}
|
|
4094
|
-
function
|
|
4164
|
+
function sa(e) {
|
|
4095
4165
|
if (!e || typeof e != "string") return !1;
|
|
4096
4166
|
let t = e.trim();
|
|
4097
4167
|
return /^\+[1-9]\d{1,14}$/.test(t);
|
|
4098
4168
|
}
|
|
4099
|
-
function
|
|
4169
|
+
function ca(e) {
|
|
4100
4170
|
if (!e || typeof e != "string") return !1;
|
|
4101
4171
|
let t = e.trim();
|
|
4102
4172
|
return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
|
|
4103
4173
|
}
|
|
4104
|
-
function
|
|
4174
|
+
function la(e, t = 6) {
|
|
4105
4175
|
return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
|
|
4106
4176
|
}
|
|
4107
|
-
function
|
|
4177
|
+
function ua(e) {
|
|
4108
4178
|
if (!e || typeof e != "string") return null;
|
|
4109
4179
|
let t = e.toUpperCase().replace(/\s+/g, "");
|
|
4110
4180
|
return t.length > 64 || !/^[A-Z0-9-]+$/.test(t) || t.replace(/-/g, "") === "" ? null : t;
|
|
4111
4181
|
}
|
|
4112
4182
|
// lib/services/auth-service.ts
|
|
4113
|
-
var
|
|
4114
|
-
function
|
|
4183
|
+
var da = (e) => e ? [e] : [], fa = "passflow_2fa_pkce", pa = 3e5, ma = "passflow_pwless_pending", ha = 3e3, ga = "passflow_federated_pkce", _a = 6e5, va = "AppId is required for federated auth";
|
|
4184
|
+
function ya(e) {
|
|
4115
4185
|
let t;
|
|
4116
4186
|
try {
|
|
4117
4187
|
t = new URL(e).protocol;
|
|
@@ -4121,11 +4191,11 @@ function aa(e) {
|
|
|
4121
4191
|
if (t !== "https:" && t !== "http:") throw Error("The federated start returned an address that is not http or https");
|
|
4122
4192
|
return e;
|
|
4123
4193
|
}
|
|
4124
|
-
function
|
|
4194
|
+
function ba(e) {
|
|
4125
4195
|
let t = {};
|
|
4126
4196
|
return e.connection_id !== void 0 && (t.connection_id = e.connection_id), e.email !== void 0 && (t.email = e.email), t;
|
|
4127
4197
|
}
|
|
4128
|
-
var
|
|
4198
|
+
var xa = 10, Sa = "The sign-in answered with a PKCE code, but its verifier is gone", Ca = (e, t) => new Promise((n, r) => {
|
|
4129
4199
|
if (t?.aborted) {
|
|
4130
4200
|
r(t.reason);
|
|
4131
4201
|
return;
|
|
@@ -4136,21 +4206,21 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4136
4206
|
t?.removeEventListener("abort", i), n();
|
|
4137
4207
|
}, e);
|
|
4138
4208
|
t?.addEventListener("abort", i, { once: !0 });
|
|
4139
|
-
}),
|
|
4209
|
+
}), wa = (e) => {
|
|
4140
4210
|
if (!e) return;
|
|
4141
4211
|
let t = new URLSearchParams(e.search).get("token");
|
|
4142
4212
|
if (t) return t;
|
|
4143
4213
|
let n = e.hash.indexOf("?");
|
|
4144
4214
|
return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
|
|
4145
|
-
},
|
|
4215
|
+
}, Ta = (e) => {
|
|
4146
4216
|
if (e) try {
|
|
4147
4217
|
return j(e).email;
|
|
4148
4218
|
} catch {
|
|
4149
4219
|
return;
|
|
4150
4220
|
}
|
|
4151
|
-
},
|
|
4152
|
-
constructor(e, t, n, r, i, a, o, s, c, l, u, d = R, f, p = { coordination:
|
|
4153
|
-
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 =
|
|
4221
|
+
}, Ea = class {
|
|
4222
|
+
constructor(e, t, n, r, i, a, o, s, c, l, u, d = R, f, p = { coordination: Xr() }, m) {
|
|
4223
|
+
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 = ji({
|
|
4154
4224
|
emit: this.createRefreshEmit(),
|
|
4155
4225
|
storage: n,
|
|
4156
4226
|
cache: i,
|
|
@@ -4158,7 +4228,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4158
4228
|
coordination: p.coordination,
|
|
4159
4229
|
platform: d,
|
|
4160
4230
|
...p.strikes === void 0 ? {} : { strikes: p.strikes },
|
|
4161
|
-
logger:
|
|
4231
|
+
logger: $r()
|
|
4162
4232
|
}), this.initializeSession();
|
|
4163
4233
|
}
|
|
4164
4234
|
setAppId(e) {
|
|
@@ -4249,7 +4319,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4249
4319
|
rememberEmailChallenge(e, t) {
|
|
4250
4320
|
this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
|
|
4251
4321
|
for (let e of this.emailChallenges.keys()) {
|
|
4252
|
-
if (this.emailChallenges.size <=
|
|
4322
|
+
if (this.emailChallenges.size <= xa) break;
|
|
4253
4323
|
this.emailChallenges.delete(e);
|
|
4254
4324
|
}
|
|
4255
4325
|
}
|
|
@@ -4257,14 +4327,14 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4257
4327
|
if (this.pendingPkce = {
|
|
4258
4328
|
verifier: e,
|
|
4259
4329
|
scopes: t,
|
|
4260
|
-
expiresAt: Date.now() +
|
|
4330
|
+
expiresAt: Date.now() + pa
|
|
4261
4331
|
}, typeof sessionStorage < "u") try {
|
|
4262
|
-
sessionStorage.setItem(
|
|
4332
|
+
sessionStorage.setItem(fa, JSON.stringify(this.pendingPkce));
|
|
4263
4333
|
} catch {}
|
|
4264
4334
|
}
|
|
4265
4335
|
readPendingPkce() {
|
|
4266
4336
|
if (!this.pendingPkce && typeof sessionStorage < "u") try {
|
|
4267
|
-
let e = sessionStorage.getItem(
|
|
4337
|
+
let e = sessionStorage.getItem(fa);
|
|
4268
4338
|
this.pendingPkce = e ? JSON.parse(e) : void 0;
|
|
4269
4339
|
} catch {
|
|
4270
4340
|
this.pendingPkce = void 0;
|
|
@@ -4276,17 +4346,17 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4276
4346
|
}
|
|
4277
4347
|
forgetPkceSignIn() {
|
|
4278
4348
|
if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
|
|
4279
|
-
sessionStorage.removeItem(
|
|
4349
|
+
sessionStorage.removeItem(fa);
|
|
4280
4350
|
} catch {}
|
|
4281
4351
|
}
|
|
4282
4352
|
rememberPendingPasswordless(e) {
|
|
4283
4353
|
if (this.pendingPasswordless = e, typeof sessionStorage < "u") try {
|
|
4284
|
-
sessionStorage.setItem(
|
|
4354
|
+
sessionStorage.setItem(ma, JSON.stringify(e));
|
|
4285
4355
|
} catch {}
|
|
4286
4356
|
}
|
|
4287
4357
|
readPendingPasswordless() {
|
|
4288
4358
|
if (!this.pendingPasswordless && typeof sessionStorage < "u") try {
|
|
4289
|
-
let e = sessionStorage.getItem(
|
|
4359
|
+
let e = sessionStorage.getItem(ma);
|
|
4290
4360
|
this.pendingPasswordless = e ? JSON.parse(e) : void 0;
|
|
4291
4361
|
} catch {
|
|
4292
4362
|
this.pendingPasswordless = void 0;
|
|
@@ -4295,21 +4365,21 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4295
4365
|
}
|
|
4296
4366
|
forgetPendingPasswordless() {
|
|
4297
4367
|
if (this.pendingPasswordless = void 0, typeof sessionStorage < "u") try {
|
|
4298
|
-
sessionStorage.removeItem(
|
|
4368
|
+
sessionStorage.removeItem(ma);
|
|
4299
4369
|
} catch {}
|
|
4300
4370
|
}
|
|
4301
4371
|
rememberFederatedSlot(e, t) {
|
|
4302
4372
|
if (this.federatedSlot = {
|
|
4303
4373
|
verifier: e,
|
|
4304
4374
|
scopes: t,
|
|
4305
|
-
expiresAt: Date.now() +
|
|
4375
|
+
expiresAt: Date.now() + _a
|
|
4306
4376
|
}, typeof sessionStorage < "u") try {
|
|
4307
|
-
sessionStorage.setItem(
|
|
4377
|
+
sessionStorage.setItem(ga, JSON.stringify(this.federatedSlot));
|
|
4308
4378
|
} catch {}
|
|
4309
4379
|
}
|
|
4310
4380
|
readFederatedSlot() {
|
|
4311
4381
|
if (!this.federatedSlot && typeof sessionStorage < "u") try {
|
|
4312
|
-
let e = sessionStorage.getItem(
|
|
4382
|
+
let e = sessionStorage.getItem(ga);
|
|
4313
4383
|
this.federatedSlot = e ? JSON.parse(e) : void 0;
|
|
4314
4384
|
} catch {
|
|
4315
4385
|
this.federatedSlot = void 0;
|
|
@@ -4318,7 +4388,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4318
4388
|
}
|
|
4319
4389
|
forgetFederatedSlot() {
|
|
4320
4390
|
if (this.federatedSlot = void 0, typeof sessionStorage < "u") try {
|
|
4321
|
-
sessionStorage.removeItem(
|
|
4391
|
+
sessionStorage.removeItem(ga);
|
|
4322
4392
|
} catch {}
|
|
4323
4393
|
}
|
|
4324
4394
|
async startPkce() {
|
|
@@ -4326,17 +4396,17 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4326
4396
|
try {
|
|
4327
4397
|
e = await this.readPkceEnabled?.() ?? !1;
|
|
4328
4398
|
} catch (e) {
|
|
4329
|
-
|
|
4399
|
+
$r().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
|
|
4330
4400
|
return;
|
|
4331
4401
|
}
|
|
4332
|
-
return e ?
|
|
4402
|
+
return e ? Rn() : void 0;
|
|
4333
4403
|
}
|
|
4334
4404
|
async exchangeCode(e, t) {
|
|
4335
4405
|
return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
|
|
4336
4406
|
}
|
|
4337
4407
|
async completePkceSignIn(e) {
|
|
4338
4408
|
let t = this.readPendingPkce();
|
|
4339
|
-
if (!t) throw Error(
|
|
4409
|
+
if (!t) throw Error(Sa);
|
|
4340
4410
|
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
4341
4411
|
return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
|
|
4342
4412
|
}
|
|
@@ -4366,7 +4436,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4366
4436
|
if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
|
|
4367
4437
|
}
|
|
4368
4438
|
async signIn(e, t) {
|
|
4369
|
-
if ("email" in e && e.email && !
|
|
4439
|
+
if ("email" in e && e.email && !oa(e.email)) {
|
|
4370
4440
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4371
4441
|
operation: "sign-in",
|
|
4372
4442
|
message: "Invalid email format",
|
|
@@ -4375,7 +4445,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4375
4445
|
};
|
|
4376
4446
|
throw W(this.subscribeStore, t), e;
|
|
4377
4447
|
}
|
|
4378
|
-
if ("username" in e && e.username && !
|
|
4448
|
+
if ("username" in e && e.username && !ca(e.username)) {
|
|
4379
4449
|
let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
|
|
4380
4450
|
operation: "sign-in",
|
|
4381
4451
|
message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
|
|
@@ -4384,7 +4454,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4384
4454
|
};
|
|
4385
4455
|
throw W(this.subscribeStore, t), e;
|
|
4386
4456
|
}
|
|
4387
|
-
if ("phone" in e && e.phone && !
|
|
4457
|
+
if ("phone" in e && e.phone && !sa(e.phone)) {
|
|
4388
4458
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4389
4459
|
operation: "sign-in",
|
|
4390
4460
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4394,13 +4464,13 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4394
4464
|
throw W(this.subscribeStore, t), e;
|
|
4395
4465
|
}
|
|
4396
4466
|
this.subscribeStore.notify(G.SignInStart, { email: e.email });
|
|
4397
|
-
let n = this.deviceService.getDeviceId(), r =
|
|
4467
|
+
let n = this.deviceService.getDeviceId(), r = gt(this.platform.getDeviceType());
|
|
4398
4468
|
e.scopes = e.scopes ?? this.scopes;
|
|
4399
4469
|
try {
|
|
4400
4470
|
let i = await this.startPkce(), a = await this.authApi.signIn(i ? {
|
|
4401
4471
|
...e,
|
|
4402
4472
|
code_challenge: i.challenge
|
|
4403
|
-
} : e, n, r, ...
|
|
4473
|
+
} : e, n, r, ...da(t));
|
|
4404
4474
|
if (this.handleEmailVerificationStep(a, "sign-in", e.email, i, e.scopes) || this.handlePendingSecondFactor(a, e.email, i, e.scopes)) return a;
|
|
4405
4475
|
let o = await this.exchangeCode(a, i);
|
|
4406
4476
|
return this.handlePendingSecondFactor(o, e.email) || (await this.processAuthResponse(o, e.scopes), this.subscribeStore.notify(G.SignIn, {
|
|
@@ -4418,7 +4488,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4418
4488
|
}
|
|
4419
4489
|
}
|
|
4420
4490
|
async signUp(e, t) {
|
|
4421
|
-
if (e.user.email && !
|
|
4491
|
+
if (e.user.email && !oa(e.user.email)) {
|
|
4422
4492
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4423
4493
|
operation: "sign-up",
|
|
4424
4494
|
message: "Invalid email format",
|
|
@@ -4427,7 +4497,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4427
4497
|
};
|
|
4428
4498
|
throw W(this.subscribeStore, t), e;
|
|
4429
4499
|
}
|
|
4430
|
-
if (e.user.phone_number && !
|
|
4500
|
+
if (e.user.phone_number && !sa(e.user.phone_number)) {
|
|
4431
4501
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4432
4502
|
operation: "sign-up",
|
|
4433
4503
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4441,7 +4511,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4441
4511
|
let n = await this.startPkce(), r = await this.authApi.signUp(n ? {
|
|
4442
4512
|
...e,
|
|
4443
4513
|
code_challenge: n.challenge
|
|
4444
|
-
} : e, ...
|
|
4514
|
+
} : e, ...da(t));
|
|
4445
4515
|
if (this.handleEmailVerificationStep(r, "sign-up", e.user.email, n, e.scopes) || this.handlePendingSecondFactor(r, e.user.email, n, e.scopes)) return r;
|
|
4446
4516
|
let i = await this.exchangeCode(r, n);
|
|
4447
4517
|
return this.handlePendingSecondFactor(i, e.user.email) || (await this.processAuthResponse(i, e.scopes), this.notifyRegisteredAndSignedIn(i), await this.submitSessionCheck()), i;
|
|
@@ -4456,7 +4526,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4456
4526
|
}
|
|
4457
4527
|
}
|
|
4458
4528
|
async passwordlessSignIn(e, t) {
|
|
4459
|
-
if (e.email && !
|
|
4529
|
+
if (e.email && !oa(e.email)) {
|
|
4460
4530
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
4461
4531
|
operation: "passwordless.start",
|
|
4462
4532
|
message: "Invalid email format",
|
|
@@ -4465,7 +4535,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4465
4535
|
};
|
|
4466
4536
|
throw W(this.subscribeStore, t), e;
|
|
4467
4537
|
}
|
|
4468
|
-
if (e.phone && !
|
|
4538
|
+
if (e.phone && !sa(e.phone)) {
|
|
4469
4539
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
4470
4540
|
operation: "passwordless.start",
|
|
4471
4541
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
@@ -4475,13 +4545,13 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4475
4545
|
throw W(this.subscribeStore, t), e;
|
|
4476
4546
|
}
|
|
4477
4547
|
this.subscribeStore.notify(G.SignInStart, { email: e.email });
|
|
4478
|
-
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId(), i =
|
|
4548
|
+
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId(), i = gt(this.platform.getDeviceType());
|
|
4479
4549
|
try {
|
|
4480
4550
|
let a = await this.startPkce(), o = await this.authApi.passwordlessSignIn({
|
|
4481
4551
|
...e,
|
|
4482
4552
|
scopes: n,
|
|
4483
4553
|
...a ? { code_challenge: a.challenge } : {}
|
|
4484
|
-
}, r, i, ...
|
|
4554
|
+
}, r, i, ...da(t));
|
|
4485
4555
|
return a && o.challenge_id ? this.rememberPendingPasswordless({
|
|
4486
4556
|
challengeId: o.challenge_id,
|
|
4487
4557
|
verifier: a.verifier,
|
|
@@ -4505,11 +4575,11 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4505
4575
|
this.subscribeStore.notify(G.SignInStart, {}), e.scopes = e.scopes ?? this.scopes, e.device = this.deviceService.getDeviceId();
|
|
4506
4576
|
let n = this.readPendingPasswordless(), r = n?.challengeId === e.challenge_id ? n : void 0, i = !1;
|
|
4507
4577
|
try {
|
|
4508
|
-
let n = await this.authApi.passwordlessSignInComplete(e, ...
|
|
4578
|
+
let n = await this.authApi.passwordlessSignInComplete(e, ...da(t));
|
|
4509
4579
|
if (i = !0, this.handlePendingSecondFactor(n, r?.email, r && { verifier: r.verifier }, r?.scopes)) return this.forgetPendingPasswordless(), n;
|
|
4510
4580
|
let a = n;
|
|
4511
4581
|
if (n.code) {
|
|
4512
|
-
if (!r) throw Error(
|
|
4582
|
+
if (!r) throw Error(Sa);
|
|
4513
4583
|
if (a = await this.authApi.pkceExchange(n.code, r.verifier), this.handlePendingSecondFactor(a)) return this.forgetPendingPasswordless(), {
|
|
4514
4584
|
...a,
|
|
4515
4585
|
redirect_url: n.redirect_url ?? ""
|
|
@@ -4541,11 +4611,11 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4541
4611
|
let n = t?.signal;
|
|
4542
4612
|
try {
|
|
4543
4613
|
let t = this.readPendingPasswordless();
|
|
4544
|
-
if (t?.challengeId !== e) throw Error(
|
|
4614
|
+
if (t?.challengeId !== e) throw Error(Sa);
|
|
4545
4615
|
for (;;) {
|
|
4546
4616
|
if (n?.aborted) throw n.reason;
|
|
4547
4617
|
if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
|
|
4548
|
-
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(
|
|
4618
|
+
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(Sa);
|
|
4549
4619
|
let r;
|
|
4550
4620
|
try {
|
|
4551
4621
|
r = await this.authApi.passwordlessStatus({
|
|
@@ -4563,7 +4633,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4563
4633
|
status: "signed-in",
|
|
4564
4634
|
tokens: { redirect_url: r.redirect_url }
|
|
4565
4635
|
};
|
|
4566
|
-
await
|
|
4636
|
+
await Ca(ha, n);
|
|
4567
4637
|
}
|
|
4568
4638
|
} catch (e) {
|
|
4569
4639
|
if (n?.aborted && e === n.reason) throw e;
|
|
@@ -4632,14 +4702,14 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4632
4702
|
let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
|
|
4633
4703
|
try {
|
|
4634
4704
|
let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
|
|
4635
|
-
if (t?.pkce && !r) throw Error(
|
|
4705
|
+
if (t?.pkce && !r) throw Error(Sa);
|
|
4636
4706
|
let i = await this.authApi.validateEmailCode(e);
|
|
4637
4707
|
this.emailChallenges.delete(e.challenge_id);
|
|
4638
4708
|
let a = r?.scopes ?? t?.scopes ?? this.scopes;
|
|
4639
4709
|
if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
|
|
4640
4710
|
let o = i;
|
|
4641
4711
|
if (i.code) {
|
|
4642
|
-
if (!r) throw Error(
|
|
4712
|
+
if (!r) throw Error(Sa);
|
|
4643
4713
|
if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
|
|
4644
4714
|
}
|
|
4645
4715
|
let s = i.redirect_url ? {
|
|
@@ -4701,13 +4771,13 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4701
4771
|
readSessionPin() {
|
|
4702
4772
|
try {
|
|
4703
4773
|
let e = this.storageManager.getToken(M.access_token);
|
|
4704
|
-
return e ?
|
|
4774
|
+
return e ? na(j(e)) : void 0;
|
|
4705
4775
|
} catch {
|
|
4706
4776
|
return;
|
|
4707
4777
|
}
|
|
4708
4778
|
}
|
|
4709
4779
|
assertSessionPin(e) {
|
|
4710
|
-
if (e && !
|
|
4780
|
+
if (e && !ra(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 ta("The session changed during verification, so the elevated tokens were discarded");
|
|
4711
4781
|
}
|
|
4712
4782
|
refreshMode() {
|
|
4713
4783
|
return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
|
|
@@ -4755,7 +4825,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4755
4825
|
case "signout":
|
|
4756
4826
|
n.notify(G.SignOut, t);
|
|
4757
4827
|
return;
|
|
4758
|
-
default:
|
|
4828
|
+
default: $r().warn(`[passflow] Unknown refresh event: ${String(e)}`);
|
|
4759
4829
|
}
|
|
4760
4830
|
};
|
|
4761
4831
|
}
|
|
@@ -4828,7 +4898,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4828
4898
|
}
|
|
4829
4899
|
async sendPasswordResetEmail(e, t) {
|
|
4830
4900
|
try {
|
|
4831
|
-
return await this.authApi.sendPasswordResetEmail(e, ...
|
|
4901
|
+
return await this.authApi.sendPasswordResetEmail(e, ...da(t));
|
|
4832
4902
|
} catch (e) {
|
|
4833
4903
|
let t = {
|
|
4834
4904
|
operation: "password-reset.send",
|
|
@@ -4841,10 +4911,10 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4841
4911
|
}
|
|
4842
4912
|
async resetPassword(e, t, n) {
|
|
4843
4913
|
this.subscribeStore.notify(G.SignInStart, {});
|
|
4844
|
-
let r = n ??
|
|
4914
|
+
let r = n ?? wa(this.platform.getCurrentUrl()), i = t ?? this.scopes;
|
|
4845
4915
|
try {
|
|
4846
4916
|
let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
|
|
4847
|
-
if (this.handleEmailVerificationStep(n, "reset-password",
|
|
4917
|
+
if (this.handleEmailVerificationStep(n, "reset-password", Ta(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
|
|
4848
4918
|
let a = await this.exchangeCode(n, t);
|
|
4849
4919
|
if (this.handlePendingSecondFactor(a)) return a;
|
|
4850
4920
|
let o = n.redirect_url ? {
|
|
@@ -4868,17 +4938,17 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4868
4938
|
async passkeyRegister(e, t) {
|
|
4869
4939
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4870
4940
|
this.subscribeStore.notify(G.RegisterStart, {});
|
|
4871
|
-
let n = this.deviceService.getDeviceId(), r =
|
|
4941
|
+
let n = this.deviceService.getDeviceId(), r = gt(this.platform.getDeviceType());
|
|
4872
4942
|
e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
4873
4943
|
try {
|
|
4874
4944
|
let i = await this.startPkce(), { challenge_id: a, publicKey: o } = await this.authApi.passkeyRegisterStart(i ? {
|
|
4875
4945
|
...e,
|
|
4876
4946
|
code_challenge: i.challenge
|
|
4877
|
-
} : e, n, r, !this.appId, ...
|
|
4947
|
+
} : e, n, r, !this.appId, ...da(t));
|
|
4878
4948
|
o.user.id = this.platform.btoa(o.user.id);
|
|
4879
4949
|
let s = await this.platform.passkeys.startRegistration(o);
|
|
4880
4950
|
if (!s) throw Error("Passkey registration was not completed");
|
|
4881
|
-
let c = await this.authApi.passkeyRegisterComplete(s, n, a, !this.appId, ...
|
|
4951
|
+
let c = await this.authApi.passkeyRegisterComplete(s, n, a, !this.appId, ...da(t));
|
|
4882
4952
|
if (this.handlePendingSecondFactor(c, void 0, i, e.scopes)) return c;
|
|
4883
4953
|
let l = await this.exchangeCode(c, i);
|
|
4884
4954
|
return this.handlePendingSecondFactor(l) || (await this.processAuthResponse(l, e.scopes), this.notifyRegisteredAndSignedIn(l), await this.submitSessionCheck()), l;
|
|
@@ -4895,15 +4965,15 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4895
4965
|
async passkeyAuthenticate(e, t) {
|
|
4896
4966
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4897
4967
|
this.subscribeStore.notify(G.SignInStart, {});
|
|
4898
|
-
let n = this.deviceService.getDeviceId(), r =
|
|
4968
|
+
let n = this.deviceService.getDeviceId(), r = gt(this.platform.getDeviceType());
|
|
4899
4969
|
e.scopes = e.scopes ?? this.scopes;
|
|
4900
4970
|
try {
|
|
4901
4971
|
let i = await this.startPkce(), { challenge_id: a, publicKey: o } = await this.authApi.passkeyAuthenticateStart(i ? {
|
|
4902
4972
|
...e,
|
|
4903
4973
|
code_challenge: i.challenge
|
|
4904
|
-
} : e, n, r, !this.appId, ...
|
|
4974
|
+
} : e, n, r, !this.appId, ...da(t)), s = await this.platform.passkeys.startAuthentication(o);
|
|
4905
4975
|
if (!s) throw Error("Passkey authentication was not completed");
|
|
4906
|
-
let c = await this.authApi.passkeyAuthenticateComplete(s, n, a, !this.appId, ...
|
|
4976
|
+
let c = await this.authApi.passkeyAuthenticateComplete(s, n, a, !this.appId, ...da(t));
|
|
4907
4977
|
if (this.handlePendingSecondFactor(c, void 0, i, e.scopes)) return c;
|
|
4908
4978
|
let l = await this.exchangeCode(c, i);
|
|
4909
4979
|
return this.handlePendingSecondFactor(l) || "access_token" in l && (await this.processAuthResponse(l, e.scopes), this.subscribeStore.notify(G.SignIn, {
|
|
@@ -4942,7 +5012,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4942
5012
|
};
|
|
4943
5013
|
}
|
|
4944
5014
|
createFederatedAuthUrl(e) {
|
|
4945
|
-
if (!this.appId) throw Error(
|
|
5015
|
+
if (!this.appId) throw Error(va);
|
|
4946
5016
|
let t = new URL(`/auth/federated/start/${e.provider}`, this.url);
|
|
4947
5017
|
return t.search = new URLSearchParams(this.federatedStartQuery(e, e.scopes ?? this.scopes, this.appId)).toString(), t.toString();
|
|
4948
5018
|
}
|
|
@@ -4961,10 +5031,10 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4961
5031
|
};
|
|
4962
5032
|
}
|
|
4963
5033
|
createEnterpriseAuthUrl(e) {
|
|
4964
|
-
if (!this.appId) throw Error(
|
|
5034
|
+
if (!this.appId) throw Error(va);
|
|
4965
5035
|
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId(), r = new URL(z.enterpriseStart, this.url);
|
|
4966
5036
|
return r.search = new URLSearchParams({
|
|
4967
|
-
...
|
|
5037
|
+
...ba(e),
|
|
4968
5038
|
...this.federatedStartQuery({
|
|
4969
5039
|
...e,
|
|
4970
5040
|
device: n
|
|
@@ -4973,8 +5043,8 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4973
5043
|
}
|
|
4974
5044
|
async enterpriseStart(e, t) {
|
|
4975
5045
|
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
|
|
4976
|
-
return { auth_url:
|
|
4977
|
-
...
|
|
5046
|
+
return { auth_url: ya((await this.authApi.enterpriseStart({
|
|
5047
|
+
...ba(e),
|
|
4978
5048
|
...this.federatedStartBody({
|
|
4979
5049
|
...e,
|
|
4980
5050
|
device: r
|
|
@@ -4982,7 +5052,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
4982
5052
|
}, t)).auth_url) };
|
|
4983
5053
|
}
|
|
4984
5054
|
async federatedAuthWithPopup(e, t) {
|
|
4985
|
-
if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(
|
|
5055
|
+
if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(va);
|
|
4986
5056
|
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
|
|
4987
5057
|
try {
|
|
4988
5058
|
this.forgetFederatedSlot();
|
|
@@ -5000,7 +5070,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5000
5070
|
} : {}
|
|
5001
5071
|
};
|
|
5002
5072
|
return {
|
|
5003
|
-
url: await this.usesFederatedPost(t) ?
|
|
5073
|
+
url: await this.usesFederatedPost(t) ? ya((await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url) : this.createFederatedAuthUrl(a),
|
|
5004
5074
|
pkce: i
|
|
5005
5075
|
};
|
|
5006
5076
|
})(), o, s = (e) => {
|
|
@@ -5022,11 +5092,11 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5022
5092
|
scopes: n
|
|
5023
5093
|
};
|
|
5024
5094
|
if (o) {
|
|
5025
|
-
if (!f) throw
|
|
5095
|
+
if (!f) throw Un();
|
|
5026
5096
|
if (_ = await this.authApi.pkceExchange(f, o.verifier), this.handlePendingSecondFactor(_)) return;
|
|
5027
5097
|
} else {
|
|
5028
|
-
if (!await this.isSimpleModeApp()) throw
|
|
5029
|
-
await
|
|
5098
|
+
if (!await this.isSimpleModeApp()) throw Un();
|
|
5099
|
+
await Ii(this.url, this.appId, _);
|
|
5030
5100
|
}
|
|
5031
5101
|
await this.processAuthResponse(_, n), this.subscribeStore.notify(G.SignIn, {
|
|
5032
5102
|
tokens: _,
|
|
@@ -5052,7 +5122,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5052
5122
|
}
|
|
5053
5123
|
}
|
|
5054
5124
|
federatedAuthWithRedirect(e, t) {
|
|
5055
|
-
if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(
|
|
5125
|
+
if (this.subscribeStore.notify(G.SignInStart, { provider: e.provider }), !this.appId) throw Error(va);
|
|
5056
5126
|
let n = e.scopes ?? this.scopes, r = this.deviceService.getDeviceId();
|
|
5057
5127
|
this.startPkce().then(async (i) => {
|
|
5058
5128
|
let a = {
|
|
@@ -5063,7 +5133,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5063
5133
|
code_challenge: i.challenge,
|
|
5064
5134
|
code_challenge_method: "S256"
|
|
5065
5135
|
} : {}
|
|
5066
|
-
}, o = await this.usesFederatedPost(t) ?
|
|
5136
|
+
}, o = await this.usesFederatedPost(t) ? ya((await this.authApi.federatedStart(e.provider, this.federatedStartBody(a, n), t)).auth_url) : this.createFederatedAuthUrl(a);
|
|
5067
5137
|
i ? this.rememberFederatedSlot(i.verifier, n) : this.forgetFederatedSlot(), this.platform.navigateTo(o);
|
|
5068
5138
|
}).catch((e) => this.reportFederatedRedirectFailure(e));
|
|
5069
5139
|
}
|
|
@@ -5116,7 +5186,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5116
5186
|
async authRedirect(e = {}) {
|
|
5117
5187
|
try {
|
|
5118
5188
|
let { url: t, appId: n, redirectUrl: r, scopes: i, state: a } = e;
|
|
5119
|
-
if (t !== void 0 &&
|
|
5189
|
+
if (t !== void 0 && Kn(t) !== Kn(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");
|
|
5120
5190
|
let o = await this.readAppSettings?.();
|
|
5121
5191
|
if (o?.pkce_enabled !== !0) {
|
|
5122
5192
|
let e = this.authRedirectUrl({
|
|
@@ -5126,8 +5196,8 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5126
5196
|
this.platform.navigateTo(a ? `${e}&${new URLSearchParams({ state: a })}` : e);
|
|
5127
5197
|
return;
|
|
5128
5198
|
}
|
|
5129
|
-
if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT",
|
|
5130
|
-
let s = this.platform.getCurrentUrl(), c = await
|
|
5199
|
+
if (o.public_client === !1) throw new U("CONFIDENTIAL_CLIENT", Vn(o.type));
|
|
5200
|
+
let s = this.platform.getCurrentUrl(), c = await Jn({
|
|
5131
5201
|
url: this.url,
|
|
5132
5202
|
clientId: this.appId ?? "",
|
|
5133
5203
|
redirectUri: r ?? (s ? s.origin + s.pathname : ""),
|
|
@@ -5148,9 +5218,9 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5148
5218
|
if (!this.appId) return !1;
|
|
5149
5219
|
let t = new URLSearchParams(e.search), n = t.get("code"), r = t.get("state"), i = t.get("error"), a = t.get("error_description");
|
|
5150
5220
|
if (t.get("user_state") || r === null || !n && !i) return !1;
|
|
5151
|
-
let o =
|
|
5221
|
+
let o = Xn();
|
|
5152
5222
|
if (o.status === "none") return !1;
|
|
5153
|
-
|
|
5223
|
+
Zn();
|
|
5154
5224
|
for (let e of [
|
|
5155
5225
|
"code",
|
|
5156
5226
|
"state",
|
|
@@ -5162,9 +5232,9 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5162
5232
|
return this.platform.replaceUrl(e.pathname + (s ? `?${s}` : "") + e.hash), this.finishOidcLanding(async () => {
|
|
5163
5233
|
if (o.status === "unusable") throw new U("VERIFIER_MISSING", "This sign-in has expired or its proof key is gone. Sign in again.");
|
|
5164
5234
|
if (o.slot.state !== r) throw new U("STATE_MISMATCH", "The sign-in answer does not belong to this sign-in. Sign in again.");
|
|
5165
|
-
if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED",
|
|
5235
|
+
if (i || !n) throw new U(i ?? "TOKEN_EXCHANGE_FAILED", aa(a || i || "Sign in again."));
|
|
5166
5236
|
return {
|
|
5167
|
-
tokens: await
|
|
5237
|
+
tokens: await $n(this.url, n, o.slot),
|
|
5168
5238
|
scopes: o.slot.scopes,
|
|
5169
5239
|
returnUrl: o.slot.redirectUri
|
|
5170
5240
|
};
|
|
@@ -5253,7 +5323,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5253
5323
|
return;
|
|
5254
5324
|
}
|
|
5255
5325
|
}
|
|
5256
|
-
},
|
|
5326
|
+
}, Da = class {
|
|
5257
5327
|
constructor(e) {
|
|
5258
5328
|
this.invitationApi = e;
|
|
5259
5329
|
}
|
|
@@ -5272,7 +5342,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5272
5342
|
getInvitationLink(e) {
|
|
5273
5343
|
return this.invitationApi.getInvitationLink(e);
|
|
5274
5344
|
}
|
|
5275
|
-
},
|
|
5345
|
+
}, Oa = class {
|
|
5276
5346
|
constructor(e) {
|
|
5277
5347
|
this.data = this.normalize(e);
|
|
5278
5348
|
}
|
|
@@ -5329,9 +5399,9 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5329
5399
|
getData() {
|
|
5330
5400
|
return this.data;
|
|
5331
5401
|
}
|
|
5332
|
-
},
|
|
5402
|
+
}, ka = class {
|
|
5333
5403
|
constructor(e, t, n) {
|
|
5334
|
-
this.tenantApi = e, this.scopes = t, this.logger = n ||
|
|
5404
|
+
this.tenantApi = e, this.scopes = t, this.logger = n || $r();
|
|
5335
5405
|
}
|
|
5336
5406
|
handlePassflowError(t, n) {
|
|
5337
5407
|
if (e.isAxiosError(t) && t.response?.data) {
|
|
@@ -5367,7 +5437,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5367
5437
|
}
|
|
5368
5438
|
async getTenantUserMembership(e) {
|
|
5369
5439
|
try {
|
|
5370
|
-
return new
|
|
5440
|
+
return new Oa(await this.tenantApi.getTenantDetails(e));
|
|
5371
5441
|
} catch (t) {
|
|
5372
5442
|
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
5373
5443
|
}
|
|
@@ -5512,7 +5582,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5512
5582
|
this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
|
|
5513
5583
|
}
|
|
5514
5584
|
}
|
|
5515
|
-
},
|
|
5585
|
+
}, Aa = class {
|
|
5516
5586
|
constructor(e, t, n, r = R) {
|
|
5517
5587
|
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();
|
|
5518
5588
|
}
|
|
@@ -5592,7 +5662,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5592
5662
|
isExpired() {
|
|
5593
5663
|
return this.tokensCache ? this.tokensCache.access_token ? A(j(this.tokensCache.access_token)) : !1 : !0;
|
|
5594
5664
|
}
|
|
5595
|
-
},
|
|
5665
|
+
}, ja = class {
|
|
5596
5666
|
constructor(e, t, n) {
|
|
5597
5667
|
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) => {
|
|
5598
5668
|
if (e === G.TwoFactorRequired) {
|
|
@@ -5672,8 +5742,8 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5672
5742
|
assertTotpCode(e) {
|
|
5673
5743
|
let t = this.totpDigits;
|
|
5674
5744
|
if (t) {
|
|
5675
|
-
if (!
|
|
5676
|
-
} else if (!
|
|
5745
|
+
if (!la(e, t)) throw Error(`Invalid TOTP code format. Code must be exactly ${t} digits.`);
|
|
5746
|
+
} else if (!la(e, 6) && !la(e, 8)) throw Error("Invalid TOTP code format. Code must be 6 or 8 digits.");
|
|
5677
5747
|
}
|
|
5678
5748
|
requirePendingTfaToken() {
|
|
5679
5749
|
let e = this.pendingTfaToken();
|
|
@@ -5711,7 +5781,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5711
5781
|
}
|
|
5712
5782
|
async useRecoveryCode(e, t) {
|
|
5713
5783
|
try {
|
|
5714
|
-
let n =
|
|
5784
|
+
let n = ua(e);
|
|
5715
5785
|
if (!n) throw Error("Invalid recovery code format. Expected letters, digits and dashes, such as XXXX-XXXX-XXXX.");
|
|
5716
5786
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
5717
5787
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
@@ -5840,13 +5910,27 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5840
5910
|
this.emitErrorAndThrow(e, "2fa.methods.available", "Get available 2FA methods");
|
|
5841
5911
|
}
|
|
5842
5912
|
}
|
|
5843
|
-
async getRegisteredMethods() {
|
|
5913
|
+
async getRegisteredMethods(e) {
|
|
5844
5914
|
try {
|
|
5845
|
-
return await this.twoFactorApi.getRegisteredMethods();
|
|
5915
|
+
return await this.twoFactorApi.getRegisteredMethods(e);
|
|
5846
5916
|
} catch (e) {
|
|
5847
5917
|
this.emitErrorAndThrow(e, "2fa.methods.registered", "Get registered 2FA methods");
|
|
5848
5918
|
}
|
|
5849
5919
|
}
|
|
5920
|
+
async startRecoveryCodesByCode(e) {
|
|
5921
|
+
try {
|
|
5922
|
+
return await this.twoFactorApi.startRecoveryCodesByCode(e);
|
|
5923
|
+
} catch (e) {
|
|
5924
|
+
this.emitErrorAndThrow(e, "2fa.recovery-codes.start", "Start recovery codes by code");
|
|
5925
|
+
}
|
|
5926
|
+
}
|
|
5927
|
+
async completeRecoveryCodesByCode(e, t) {
|
|
5928
|
+
try {
|
|
5929
|
+
return await this.twoFactorApi.completeRecoveryCodesByCode(e, t);
|
|
5930
|
+
} catch (e) {
|
|
5931
|
+
this.emitErrorAndThrow(e, "2fa.recovery-codes.complete", "Complete recovery codes by code");
|
|
5932
|
+
}
|
|
5933
|
+
}
|
|
5850
5934
|
async startMethodSetup(e, t) {
|
|
5851
5935
|
try {
|
|
5852
5936
|
let n = await this.twoFactorApi.startMethodSetup(e, t);
|
|
@@ -5946,7 +6030,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5946
6030
|
this.emitErrorAndThrow(e, "2fa.preferred-method.clear", "Clear preferred 2FA method");
|
|
5947
6031
|
}
|
|
5948
6032
|
}
|
|
5949
|
-
},
|
|
6033
|
+
}, Ma = class {
|
|
5950
6034
|
constructor(e, t, n = R) {
|
|
5951
6035
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
5952
6036
|
}
|
|
@@ -5961,7 +6045,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5961
6045
|
}
|
|
5962
6046
|
async addUserPasskey({ relyingPartyId: e, passkeyUsername: t, passkeyDisplayName: n } = {}) {
|
|
5963
6047
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
5964
|
-
let r = this.deviceService.getDeviceId(), i =
|
|
6048
|
+
let r = this.deviceService.getDeviceId(), i = gt(this.platform.getDeviceType()), { challenge_id: a, publicKey: o } = await this.userAPI.addUserPasskeyStart({
|
|
5965
6049
|
relyingPartyId: (e || this.platform.getCurrentUrl()?.hostname) ?? "",
|
|
5966
6050
|
deviceId: r,
|
|
5967
6051
|
os: i,
|
|
@@ -5982,77 +6066,83 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
5982
6066
|
signOutOtherSessions() {
|
|
5983
6067
|
return this.userAPI.revokeOtherUserSessions();
|
|
5984
6068
|
}
|
|
5985
|
-
|
|
6069
|
+
requestAddressChangeProof(e) {
|
|
6070
|
+
return this.userAPI.requestAddressChangeProof(e);
|
|
6071
|
+
}
|
|
6072
|
+
updateProfile(e, t) {
|
|
6073
|
+
return this.userAPI.updateProfile(e, t);
|
|
6074
|
+
}
|
|
6075
|
+
}, Na = class extends Error {
|
|
5986
6076
|
constructor(e, t, n = !1) {
|
|
5987
6077
|
super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
|
|
5988
6078
|
}
|
|
5989
|
-
},
|
|
6079
|
+
}, Pa = (e, t) => {
|
|
5990
6080
|
let n = t?.trim();
|
|
5991
|
-
if (!n) throw new
|
|
6081
|
+
if (!n) throw new Na(e, "A verification code is required");
|
|
5992
6082
|
return n;
|
|
5993
|
-
},
|
|
6083
|
+
}, Fa = {
|
|
5994
6084
|
type: "totp",
|
|
5995
6085
|
requiresPrepare: !1,
|
|
5996
6086
|
input: "code",
|
|
5997
|
-
assert: async ({ code: e }) => ({ code:
|
|
5998
|
-
},
|
|
6087
|
+
assert: async ({ code: e }) => ({ code: Pa("totp", e) })
|
|
6088
|
+
}, Ia = {
|
|
5999
6089
|
type: "recovery_codes",
|
|
6000
6090
|
requiresPrepare: !1,
|
|
6001
6091
|
input: "code",
|
|
6002
|
-
assert: async ({ code: e }) => ({ code:
|
|
6003
|
-
},
|
|
6092
|
+
assert: async ({ code: e }) => ({ code: Pa("recovery_codes", e) })
|
|
6093
|
+
}, La = {
|
|
6004
6094
|
type: "passkey",
|
|
6005
6095
|
requiresPrepare: !0,
|
|
6006
6096
|
input: "none",
|
|
6007
6097
|
assert: async ({ prepared: e, platform: t }) => {
|
|
6008
|
-
if (!e?.webauthn) throw new
|
|
6098
|
+
if (!e?.webauthn) throw new Na("passkey", "The upgrade challenge carried no WebAuthn options");
|
|
6009
6099
|
let n = t.passkeys;
|
|
6010
|
-
if (!n) throw new
|
|
6100
|
+
if (!n) throw new Na("passkey", "This platform does not support passkeys");
|
|
6011
6101
|
let r;
|
|
6012
6102
|
try {
|
|
6013
6103
|
r = await n.startAuthentication(e.webauthn);
|
|
6014
6104
|
} catch (e) {
|
|
6015
|
-
throw new
|
|
6105
|
+
throw new Na("passkey", e?.message || "Passkey verification was cancelled", !0);
|
|
6016
6106
|
}
|
|
6017
|
-
if (!r) throw new
|
|
6107
|
+
if (!r) throw new Na("passkey", "Passkey verification was cancelled", !0);
|
|
6018
6108
|
return {
|
|
6019
6109
|
challenge_id: e.challengeId,
|
|
6020
6110
|
credential: r
|
|
6021
6111
|
};
|
|
6022
6112
|
}
|
|
6023
|
-
},
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
]),
|
|
6113
|
+
}, Ra = Object.freeze([
|
|
6114
|
+
Fa,
|
|
6115
|
+
La,
|
|
6116
|
+
Ia
|
|
6117
|
+
]), za = (e = Ra) => new Map(e.map((e) => [e.type, e])), Ba = 3, Va = {
|
|
6028
6118
|
totp: 0,
|
|
6029
6119
|
passkey: 1,
|
|
6030
6120
|
email_otp: 2,
|
|
6031
6121
|
sms_otp: 3,
|
|
6032
6122
|
recovery_codes: 9
|
|
6033
|
-
},
|
|
6034
|
-
let n =
|
|
6123
|
+
}, Ha = (e) => e.requiredLevel ?? _e(e.acrValues), Ua = (e, t) => {
|
|
6124
|
+
let n = Va[e.type] ?? 5, r = t !== void 0 && t >= Ba, i = e.type === "passkey";
|
|
6035
6125
|
return (r && !i ? 100 : 0) + n;
|
|
6036
|
-
},
|
|
6126
|
+
}, Wa = (e, t) => {
|
|
6037
6127
|
if (t.availableFactors) return t.availableFactors.flatMap((t) => e.find((e) => e.type === t) ?? []);
|
|
6038
|
-
let n =
|
|
6039
|
-
return [...e].sort((e, t) =>
|
|
6040
|
-
},
|
|
6128
|
+
let n = Ha(t);
|
|
6129
|
+
return [...e].sort((e, t) => Ua(e, n) - Ua(t, n));
|
|
6130
|
+
}, Ga = class extends Error {
|
|
6041
6131
|
constructor(e) {
|
|
6042
6132
|
super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
|
|
6043
6133
|
}
|
|
6044
|
-
},
|
|
6134
|
+
}, Ka = class extends Error {
|
|
6045
6135
|
constructor(e = "Only a fresh sign-in can meet this challenge") {
|
|
6046
6136
|
super(e), this.code = "upgrade_sign_in_required", this.name = "UpgradeSignInRequiredError";
|
|
6047
6137
|
}
|
|
6048
|
-
},
|
|
6049
|
-
if (
|
|
6050
|
-
if (
|
|
6051
|
-
},
|
|
6138
|
+
}, qa = (e) => e?.signInRequired === !0 || e?.signInRequired === void 0 && e?.availableFactors?.length === 0, Ja = (e) => e?.signInRequired === !1 && e.availableFactors?.length === 0, Ya = "This account has no factor that reaches the required level (it may need a device-bound passkey)", Xa = (e) => {
|
|
6139
|
+
if (qa(e)) return new Ka();
|
|
6140
|
+
if (Ja(e)) return new Za(Ya);
|
|
6141
|
+
}, Za = class extends Error {
|
|
6052
6142
|
constructor(e = "No available authentication factor can satisfy this challenge") {
|
|
6053
6143
|
super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
|
|
6054
6144
|
}
|
|
6055
|
-
},
|
|
6145
|
+
}, Qa = 4, $a = 3e4, eo = () => {
|
|
6056
6146
|
let e = () => void 0, t = () => void 0;
|
|
6057
6147
|
return {
|
|
6058
6148
|
promise: new Promise((n, r) => {
|
|
@@ -6061,12 +6151,12 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6061
6151
|
resolve: e,
|
|
6062
6152
|
reject: t
|
|
6063
6153
|
};
|
|
6064
|
-
},
|
|
6154
|
+
}, to = (e) => ({
|
|
6065
6155
|
acrValues: e.acrValues,
|
|
6066
6156
|
level: e.requiredLevel,
|
|
6067
6157
|
maxAge: e.maxAge
|
|
6068
|
-
}),
|
|
6069
|
-
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 } =
|
|
6158
|
+
}), no = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, ro = (e, t) => {
|
|
6159
|
+
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 } = io(t, e) && !io(e, t) || !t.availableFactors ? e : t;
|
|
6070
6160
|
return {
|
|
6071
6161
|
acrValues: r,
|
|
6072
6162
|
requiredLevel: n,
|
|
@@ -6076,12 +6166,12 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6076
6166
|
...o ? { availableFactors: o } : {},
|
|
6077
6167
|
...s === void 0 ? {} : { signInRequired: s }
|
|
6078
6168
|
};
|
|
6079
|
-
},
|
|
6169
|
+
}, io = (e, t) => {
|
|
6080
6170
|
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);
|
|
6081
6171
|
return n || r;
|
|
6082
|
-
},
|
|
6172
|
+
}, ao = class {
|
|
6083
6173
|
constructor(e) {
|
|
6084
|
-
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 ??
|
|
6174
|
+
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 ?? Ra, this.registry = za(this.available), this.maxAttempts = e.maxAttempts ?? Qa, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? $a;
|
|
6085
6175
|
}
|
|
6086
6176
|
get currentState() {
|
|
6087
6177
|
return this.state;
|
|
@@ -6101,9 +6191,9 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6101
6191
|
}
|
|
6102
6192
|
register(e, t) {
|
|
6103
6193
|
let n = t.kind === "imperative" && t.requested !== void 0, r = {
|
|
6104
|
-
demanded: t.kind === "imperative" && t.requested ? t.requested :
|
|
6194
|
+
demanded: t.kind === "imperative" && t.requested ? t.requested : to(e),
|
|
6105
6195
|
statedBar: n,
|
|
6106
|
-
settlement:
|
|
6196
|
+
settlement: eo(),
|
|
6107
6197
|
reported: !1,
|
|
6108
6198
|
entry: {
|
|
6109
6199
|
...t,
|
|
@@ -6119,15 +6209,15 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6119
6209
|
this.requirement = e;
|
|
6120
6210
|
return;
|
|
6121
6211
|
}
|
|
6122
|
-
let n =
|
|
6123
|
-
this.requirement =
|
|
6212
|
+
let n = io(t, e);
|
|
6213
|
+
this.requirement = ro(t, e), Xa(this.requirement) ? this.state === "collecting" && this.selected === null && (this.openPrompt?.onClosed?.(), this.closeOpenPrompt?.()) : n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
|
|
6124
6214
|
challenge: this.requirement,
|
|
6125
6215
|
factors: this.offeredFactors()
|
|
6126
6216
|
});
|
|
6127
6217
|
}
|
|
6128
6218
|
offeredFactors() {
|
|
6129
6219
|
let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
|
|
6130
|
-
return t ?
|
|
6220
|
+
return t ? Wa(e, t) : e;
|
|
6131
6221
|
}
|
|
6132
6222
|
receiveReport(e, t) {
|
|
6133
6223
|
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());
|
|
@@ -6162,12 +6252,12 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6162
6252
|
}
|
|
6163
6253
|
release(e, t) {
|
|
6164
6254
|
if (e.entry.kind === "imperative") {
|
|
6165
|
-
if (e.statedBar && !
|
|
6255
|
+
if (e.statedBar && !no(t, e.demanded)) {
|
|
6166
6256
|
this.receiveReport(e, {
|
|
6167
6257
|
outcome: "insufficient",
|
|
6168
6258
|
obtained: t,
|
|
6169
6259
|
required: e.demanded
|
|
6170
|
-
}), e.settlement.reject(new
|
|
6260
|
+
}), e.settlement.reject(new $i(t, e.demanded));
|
|
6171
6261
|
return;
|
|
6172
6262
|
}
|
|
6173
6263
|
this.receiveReport(e, {
|
|
@@ -6237,7 +6327,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6237
6327
|
async prove() {
|
|
6238
6328
|
let e;
|
|
6239
6329
|
for (let t = 0; t < this.maxAttempts; t++) {
|
|
6240
|
-
let t =
|
|
6330
|
+
let t = Xa(this.requirement);
|
|
6241
6331
|
if (t) return {
|
|
6242
6332
|
status: "failed",
|
|
6243
6333
|
reason: t
|
|
@@ -6245,7 +6335,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6245
6335
|
let n = this.offeredFactors();
|
|
6246
6336
|
if (n.length === 0) return {
|
|
6247
6337
|
status: "failed",
|
|
6248
|
-
reason: new
|
|
6338
|
+
reason: new Za()
|
|
6249
6339
|
};
|
|
6250
6340
|
let r = this.requirement, i;
|
|
6251
6341
|
try {
|
|
@@ -6253,29 +6343,29 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6253
6343
|
} catch (e) {
|
|
6254
6344
|
return {
|
|
6255
6345
|
status: "failed",
|
|
6256
|
-
reason: new
|
|
6346
|
+
reason: new Ga(e)
|
|
6257
6347
|
};
|
|
6258
6348
|
}
|
|
6259
|
-
let a =
|
|
6349
|
+
let a = Xa(this.requirement);
|
|
6260
6350
|
if (a) return {
|
|
6261
6351
|
status: "failed",
|
|
6262
6352
|
reason: a
|
|
6263
6353
|
};
|
|
6264
6354
|
if (i.type === "cancel") return {
|
|
6265
6355
|
status: "failed",
|
|
6266
|
-
reason: new
|
|
6356
|
+
reason: new Ga()
|
|
6267
6357
|
};
|
|
6268
6358
|
let o = this.registry.get(i.factor);
|
|
6269
|
-
if (!o) e = new
|
|
6359
|
+
if (!o) e = new Za(`Unknown authentication factor: ${i.factor}`), this.state = "collecting", this.selected = null;
|
|
6270
6360
|
else try {
|
|
6271
6361
|
return await this.proveAndCommit(o, i.code), {
|
|
6272
6362
|
status: "proven",
|
|
6273
|
-
obtained: this.readObtainedBar?.() ??
|
|
6363
|
+
obtained: this.readObtainedBar?.() ?? to(this.rankedRequirement ?? r)
|
|
6274
6364
|
};
|
|
6275
6365
|
} catch (t) {
|
|
6276
|
-
if (t instanceof
|
|
6366
|
+
if (t instanceof Na && t.cancelled) return {
|
|
6277
6367
|
status: "failed",
|
|
6278
|
-
reason: new
|
|
6368
|
+
reason: new Ga()
|
|
6279
6369
|
};
|
|
6280
6370
|
let n = this.classifyProofFailure(t);
|
|
6281
6371
|
if (n) return {
|
|
@@ -6311,16 +6401,16 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6311
6401
|
});
|
|
6312
6402
|
}
|
|
6313
6403
|
classifyProofFailure(e) {
|
|
6314
|
-
if (e instanceof
|
|
6404
|
+
if (e instanceof $i || e instanceof ea || e instanceof ta) return e;
|
|
6315
6405
|
if (e instanceof $) switch (e.kind) {
|
|
6316
|
-
case "unavailable": return new
|
|
6406
|
+
case "unavailable": return new ea(e.message);
|
|
6317
6407
|
case "exhausted":
|
|
6318
6408
|
case "attempts_exhausted":
|
|
6319
6409
|
case "rate_limited":
|
|
6320
6410
|
case "fatal":
|
|
6321
6411
|
case "protocol":
|
|
6322
6412
|
case "network": return e;
|
|
6323
|
-
case "session_changed": return new
|
|
6413
|
+
case "session_changed": return new ta(e.message);
|
|
6324
6414
|
default: return;
|
|
6325
6415
|
}
|
|
6326
6416
|
}
|
|
@@ -6332,28 +6422,28 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6332
6422
|
});
|
|
6333
6423
|
await this.transport.commit(e.type, r);
|
|
6334
6424
|
}
|
|
6335
|
-
},
|
|
6425
|
+
}, oo = (e) => typeof e == "function" ? e() : e, so = (e) => {
|
|
6336
6426
|
try {
|
|
6337
6427
|
return new URL(e);
|
|
6338
6428
|
} catch {
|
|
6339
6429
|
return;
|
|
6340
6430
|
}
|
|
6341
|
-
},
|
|
6431
|
+
}, co = (e, t) => {
|
|
6342
6432
|
if (!t || t === "/") return !0;
|
|
6343
6433
|
let n = t.replace(/\/+$/, "");
|
|
6344
6434
|
return e === n || e.startsWith(`${n}/`);
|
|
6345
|
-
},
|
|
6435
|
+
}, lo = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && co(e.pathname, t.pathPrefix), uo = (e, t) => {
|
|
6346
6436
|
for (let n of t) {
|
|
6347
6437
|
if (n === "") continue;
|
|
6348
6438
|
if (n.startsWith("/")) {
|
|
6349
|
-
if (e.relativeToBase &&
|
|
6439
|
+
if (e.relativeToBase && co(e.pathname, n)) return !0;
|
|
6350
6440
|
continue;
|
|
6351
6441
|
}
|
|
6352
|
-
let t =
|
|
6353
|
-
if (t && e.origin !== void 0 && e.origin === t.origin &&
|
|
6442
|
+
let t = so(n) ?? so(`https://${n}`);
|
|
6443
|
+
if (t && e.origin !== void 0 && e.origin === t.origin && co(e.pathname, t.pathname)) return !0;
|
|
6354
6444
|
}
|
|
6355
6445
|
return !1;
|
|
6356
|
-
},
|
|
6446
|
+
}, fo = (e, t, n) => lo(e, t.passflow) || uo(e, t.backend) ? !n || n(e.href) !== !1 : !1, po = (e) => {
|
|
6357
6447
|
let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
|
|
6358
6448
|
console.warn(n, {
|
|
6359
6449
|
status: e.status,
|
|
@@ -6361,8 +6451,8 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6361
6451
|
reason: e.reason,
|
|
6362
6452
|
detail: t
|
|
6363
6453
|
});
|
|
6364
|
-
},
|
|
6365
|
-
let n = t.onUpgradeDiagnostic ??
|
|
6454
|
+
}, mo = (e, t) => {
|
|
6455
|
+
let n = t.onUpgradeDiagnostic ?? po;
|
|
6366
6456
|
return (t, r) => {
|
|
6367
6457
|
n({
|
|
6368
6458
|
status: e.status,
|
|
@@ -6374,8 +6464,8 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6374
6464
|
}
|
|
6375
6465
|
});
|
|
6376
6466
|
};
|
|
6377
|
-
},
|
|
6378
|
-
let r = n.onUpgradeDiagnostic ??
|
|
6467
|
+
}, ho = (e, t, n) => {
|
|
6468
|
+
let r = n.onUpgradeDiagnostic ?? po;
|
|
6379
6469
|
for (let n of e) r({
|
|
6380
6470
|
...n,
|
|
6381
6471
|
url: t.request.href,
|
|
@@ -6384,8 +6474,8 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6384
6474
|
...n.detail ?? {}
|
|
6385
6475
|
}
|
|
6386
6476
|
});
|
|
6387
|
-
},
|
|
6388
|
-
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n &&
|
|
6477
|
+
}, go = /\bjson\b/i, _o = async (e, t) => {
|
|
6478
|
+
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && go.test(r), a;
|
|
6389
6479
|
if (i) try {
|
|
6390
6480
|
a = await e.readBody();
|
|
6391
6481
|
} catch {
|
|
@@ -6399,13 +6489,13 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6399
6489
|
status: e.status,
|
|
6400
6490
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
6401
6491
|
}, { requireChallengeChannel: t.requireChallengeChannel });
|
|
6402
|
-
},
|
|
6492
|
+
}, vo = (e) => ke({
|
|
6403
6493
|
status: e.status,
|
|
6404
6494
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
6405
|
-
}, { requireChallengeChannel: "header" }).challenge,
|
|
6495
|
+
}, { requireChallengeChannel: "header" }).challenge, yo = (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.`, bo = (e, t) => e instanceof Ga ? { kind: "cancelled" } : e instanceof Ka ? { kind: "sign-in-required" } : e instanceof Za ? {
|
|
6406
6496
|
kind: "unsatisfiable",
|
|
6407
6497
|
error: e
|
|
6408
|
-
} : e instanceof
|
|
6498
|
+
} : e instanceof ea ? { kind: "unavailable" } : e instanceof ta ? { kind: "session-changed" } : e instanceof $i ? {
|
|
6409
6499
|
kind: "insufficient",
|
|
6410
6500
|
obtained: e.obtained,
|
|
6411
6501
|
required: e.required
|
|
@@ -6421,26 +6511,26 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6421
6511
|
kind: "transport-failure",
|
|
6422
6512
|
retryable: !1,
|
|
6423
6513
|
error: e instanceof Error ? e : Error(String(e))
|
|
6424
|
-
},
|
|
6514
|
+
}, xo = async (e, t, n, r) => {
|
|
6425
6515
|
if (e.status !== 401 && e.status !== 403) return {
|
|
6426
6516
|
kind: "replayed",
|
|
6427
6517
|
response: e
|
|
6428
6518
|
};
|
|
6429
|
-
let { challenge: i, diagnostics: a } = await
|
|
6430
|
-
if (
|
|
6519
|
+
let { challenge: i, diagnostics: a } = await _o(e, t);
|
|
6520
|
+
if (ho(a, e, t), !i) return {
|
|
6431
6521
|
kind: "replayed",
|
|
6432
6522
|
response: e
|
|
6433
6523
|
};
|
|
6434
|
-
if (
|
|
6524
|
+
if (qa(i)) return {
|
|
6435
6525
|
kind: "sign-in-required",
|
|
6436
6526
|
response: e
|
|
6437
6527
|
};
|
|
6438
|
-
if (
|
|
6528
|
+
if (Ja(i)) return {
|
|
6439
6529
|
kind: "unsatisfiable",
|
|
6440
|
-
error:
|
|
6530
|
+
error: Xa(i),
|
|
6441
6531
|
response: e
|
|
6442
6532
|
};
|
|
6443
|
-
let o =
|
|
6533
|
+
let o = to(i);
|
|
6444
6534
|
return r("elevated-insufficient", {
|
|
6445
6535
|
obtained: n,
|
|
6446
6536
|
required: o
|
|
@@ -6450,7 +6540,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6450
6540
|
required: o,
|
|
6451
6541
|
response: e
|
|
6452
6542
|
};
|
|
6453
|
-
},
|
|
6543
|
+
}, So = async (e, t) => {
|
|
6454
6544
|
if (!t) return {
|
|
6455
6545
|
aborted: !1,
|
|
6456
6546
|
value: await e
|
|
@@ -6477,14 +6567,14 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6477
6567
|
} finally {
|
|
6478
6568
|
n && t.removeEventListener?.("abort", n);
|
|
6479
6569
|
}
|
|
6480
|
-
},
|
|
6570
|
+
}, Co = async (e, t) => {
|
|
6481
6571
|
if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
|
|
6482
|
-
let n =
|
|
6572
|
+
let n = mo(e, t);
|
|
6483
6573
|
if (e.markers.replayed) {
|
|
6484
|
-
if (!
|
|
6485
|
-
let { challenge: r, diagnostics: i } = await
|
|
6486
|
-
if (
|
|
6487
|
-
let a = t.readObtainedBar?.() ?? {}, o =
|
|
6574
|
+
if (!fo(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
|
|
6575
|
+
let { challenge: r, diagnostics: i } = await _o(e, t);
|
|
6576
|
+
if (ho(i, e, t), !r) return { kind: "not-a-challenge" };
|
|
6577
|
+
let a = t.readObtainedBar?.() ?? {}, o = to(r);
|
|
6488
6578
|
return n("elevated-insufficient", {
|
|
6489
6579
|
obtained: a,
|
|
6490
6580
|
required: o
|
|
@@ -6495,12 +6585,12 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6495
6585
|
response: e
|
|
6496
6586
|
};
|
|
6497
6587
|
}
|
|
6498
|
-
if (!
|
|
6588
|
+
if (!fo(e.request, t.scope, t.shouldIntercept)) return vo(e) ? (n("challenge-out-of-scope", {
|
|
6499
6589
|
header: e.getHeader("www-authenticate") ?? void 0,
|
|
6500
|
-
message:
|
|
6590
|
+
message: yo(e.request.href, t.scope)
|
|
6501
6591
|
}), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
|
|
6502
|
-
let { challenge: r, diagnostics: i } = await
|
|
6503
|
-
if (
|
|
6592
|
+
let { challenge: r, diagnostics: i } = await _o(e, t);
|
|
6593
|
+
if (ho(i, e, t), !r) {
|
|
6504
6594
|
let r = e.getHeader("www-authenticate");
|
|
6505
6595
|
return t.requireChallengeChannel !== "header" && n("no-channel", {
|
|
6506
6596
|
...r ? { header: r } : {},
|
|
@@ -6514,9 +6604,9 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6514
6604
|
method: e.request.method
|
|
6515
6605
|
}, s, c;
|
|
6516
6606
|
try {
|
|
6517
|
-
s = Promise.resolve(t.elevate(r, o)), c = await
|
|
6607
|
+
s = Promise.resolve(t.elevate(r, o)), c = await So(s, e.signal);
|
|
6518
6608
|
} catch (e) {
|
|
6519
|
-
return
|
|
6609
|
+
return bo(e, void 0);
|
|
6520
6610
|
}
|
|
6521
6611
|
if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
|
|
6522
6612
|
kind: "aborted",
|
|
@@ -6527,7 +6617,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6527
6617
|
kind: "aborted",
|
|
6528
6618
|
reason: e.signal.reason
|
|
6529
6619
|
};
|
|
6530
|
-
let u = l?.obtained ?? t.readObtainedBar?.() ??
|
|
6620
|
+
let u = l?.obtained ?? t.readObtainedBar?.() ?? to(r), d = t.authorizationSwap?.(), f = d ? {
|
|
6531
6621
|
from: a?.from ?? d.from,
|
|
6532
6622
|
to: d.to
|
|
6533
6623
|
} : void 0;
|
|
@@ -6536,7 +6626,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6536
6626
|
try {
|
|
6537
6627
|
p = await e.replay(f ? { authorizationSwap: f } : void 0);
|
|
6538
6628
|
} catch (t) {
|
|
6539
|
-
if (t instanceof
|
|
6629
|
+
if (t instanceof $i) return l?.waiter.report({
|
|
6540
6630
|
outcome: "insufficient",
|
|
6541
6631
|
obtained: t.obtained,
|
|
6542
6632
|
required: t.required
|
|
@@ -6554,7 +6644,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6554
6644
|
};
|
|
6555
6645
|
throw t;
|
|
6556
6646
|
}
|
|
6557
|
-
let m = await
|
|
6647
|
+
let m = await xo(p, t, u, n);
|
|
6558
6648
|
return m.kind === "insufficient" ? l?.waiter.report({
|
|
6559
6649
|
outcome: "insufficient",
|
|
6560
6650
|
obtained: m.obtained,
|
|
@@ -6563,19 +6653,19 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6563
6653
|
outcome: "replayed",
|
|
6564
6654
|
obtained: u
|
|
6565
6655
|
}), m;
|
|
6566
|
-
},
|
|
6656
|
+
}, wo = (e) => {
|
|
6567
6657
|
switch (e.kind) {
|
|
6568
|
-
case "cancelled": return new
|
|
6569
|
-
case "unsatisfiable": return e.error ?? new
|
|
6570
|
-
case "sign-in-required": return new
|
|
6571
|
-
case "unavailable": return new
|
|
6572
|
-
case "session-changed": return new
|
|
6573
|
-
case "insufficient": return new
|
|
6658
|
+
case "cancelled": return new Ga();
|
|
6659
|
+
case "unsatisfiable": return e.error ?? new Za();
|
|
6660
|
+
case "sign-in-required": return new Ka();
|
|
6661
|
+
case "unavailable": return new ea();
|
|
6662
|
+
case "session-changed": return new ta();
|
|
6663
|
+
case "insufficient": return new $i(e.obtained, e.required);
|
|
6574
6664
|
case "exhausted": return e.error;
|
|
6575
6665
|
case "transport-failure": return e.error;
|
|
6576
6666
|
default: return;
|
|
6577
6667
|
}
|
|
6578
|
-
},
|
|
6668
|
+
}, To = (e, t, n) => {
|
|
6579
6669
|
switch (e.kind) {
|
|
6580
6670
|
case "replayed": return {
|
|
6581
6671
|
settle: "resolve",
|
|
@@ -6593,26 +6683,26 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6593
6683
|
};
|
|
6594
6684
|
case "cancelled": return n.onCancel === "reject" ? {
|
|
6595
6685
|
settle: "reject",
|
|
6596
|
-
error: new
|
|
6686
|
+
error: new Ga()
|
|
6597
6687
|
} : {
|
|
6598
6688
|
settle: "resolve",
|
|
6599
|
-
value:
|
|
6689
|
+
value: Fo(t, e)
|
|
6600
6690
|
};
|
|
6601
6691
|
case "unsatisfiable":
|
|
6602
6692
|
case "sign-in-required": return {
|
|
6603
6693
|
settle: "resolve",
|
|
6604
|
-
value:
|
|
6694
|
+
value: Fo(e.response?.raw ?? t, e)
|
|
6605
6695
|
};
|
|
6606
6696
|
case "insufficient": return {
|
|
6607
6697
|
settle: "resolve",
|
|
6608
|
-
value:
|
|
6698
|
+
value: Fo(e.response?.raw ?? t, e)
|
|
6609
6699
|
};
|
|
6610
6700
|
default: return {
|
|
6611
6701
|
settle: "resolve",
|
|
6612
|
-
value:
|
|
6702
|
+
value: Fo(t, e)
|
|
6613
6703
|
};
|
|
6614
6704
|
}
|
|
6615
|
-
},
|
|
6705
|
+
}, Eo = (e, t) => {
|
|
6616
6706
|
switch (e.kind) {
|
|
6617
6707
|
case "replayed": return e.response.rejected ? {
|
|
6618
6708
|
settle: "reject",
|
|
@@ -6627,42 +6717,42 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6627
6717
|
};
|
|
6628
6718
|
default: return {
|
|
6629
6719
|
settle: "reject",
|
|
6630
|
-
error:
|
|
6720
|
+
error: wo(e) ?? t
|
|
6631
6721
|
};
|
|
6632
6722
|
}
|
|
6633
|
-
},
|
|
6723
|
+
}, Do = /* @__PURE__ */ new WeakSet(), Oo = /* @__PURE__ */ new WeakSet(), ko = /* @__PURE__ */ new WeakSet(), Ao = /* @__PURE__ */ new WeakSet(), jo = /* @__PURE__ */ new WeakSet(), Mo = /* @__PURE__ */ new WeakSet(), No = /* @__PURE__ */ new WeakSet(), Po = /* @__PURE__ */ new WeakSet(), Fo = (e, t) => {
|
|
6634
6724
|
switch (t.kind) {
|
|
6635
6725
|
case "cancelled":
|
|
6636
|
-
|
|
6726
|
+
Do.add(e);
|
|
6637
6727
|
break;
|
|
6638
6728
|
case "exhausted":
|
|
6639
|
-
|
|
6729
|
+
Oo.add(e);
|
|
6640
6730
|
break;
|
|
6641
6731
|
case "insufficient":
|
|
6642
|
-
|
|
6732
|
+
ko.add(e);
|
|
6643
6733
|
break;
|
|
6644
6734
|
case "unsatisfiable":
|
|
6645
|
-
|
|
6735
|
+
Ao.add(e);
|
|
6646
6736
|
break;
|
|
6647
6737
|
case "sign-in-required":
|
|
6648
|
-
|
|
6738
|
+
jo.add(e);
|
|
6649
6739
|
break;
|
|
6650
6740
|
case "unavailable":
|
|
6651
|
-
|
|
6741
|
+
Mo.add(e);
|
|
6652
6742
|
break;
|
|
6653
6743
|
case "session-changed":
|
|
6654
|
-
|
|
6744
|
+
No.add(e);
|
|
6655
6745
|
break;
|
|
6656
|
-
case "transport-failure":
|
|
6746
|
+
case "transport-failure": Po.add(e);
|
|
6657
6747
|
}
|
|
6658
6748
|
return e;
|
|
6659
|
-
},
|
|
6749
|
+
}, Io = (e) => Do.has(e), Lo = (e) => Oo.has(e), Ro = (e) => ko.has(e), zo = (e) => Ao.has(e), Bo = (e) => jo.has(e), Vo = (e) => Mo.has(e), Ho = (e) => No.has(e), Uo = (e) => Po.has(e), Wo = "https://passflow-relative.invalid", Go = () => {
|
|
6660
6750
|
let e = globalThis, t = e.document?.baseURI;
|
|
6661
6751
|
if (typeof t == "string" && t !== "") return t;
|
|
6662
6752
|
let n = e.location?.href;
|
|
6663
|
-
return typeof n == "string" && n !== "" && n !== "about:blank" ? n :
|
|
6664
|
-
},
|
|
6665
|
-
let n = t ===
|
|
6753
|
+
return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Wo;
|
|
6754
|
+
}, Ko = (e, t = Go()) => {
|
|
6755
|
+
let n = t === Wo, r;
|
|
6666
6756
|
try {
|
|
6667
6757
|
r = new URL(t).origin;
|
|
6668
6758
|
} catch {
|
|
@@ -6688,28 +6778,28 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6688
6778
|
relativeToBase: !1,
|
|
6689
6779
|
sentinelBase: n
|
|
6690
6780
|
};
|
|
6691
|
-
},
|
|
6781
|
+
}, qo = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Jo = (e) => {
|
|
6692
6782
|
let t = [];
|
|
6693
6783
|
if (e == null) return Object.freeze(t);
|
|
6694
6784
|
let n = e;
|
|
6695
6785
|
if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
|
|
6696
|
-
let r =
|
|
6786
|
+
let r = qo(n, e);
|
|
6697
6787
|
r && t.push(r);
|
|
6698
6788
|
}), Object.freeze(t);
|
|
6699
6789
|
if (Array.isArray(e)) {
|
|
6700
6790
|
for (let n of e) if (Array.isArray(n) && n.length >= 2) {
|
|
6701
|
-
let e =
|
|
6791
|
+
let e = qo(String(n[0]), n[1]);
|
|
6702
6792
|
e && t.push(e);
|
|
6703
6793
|
}
|
|
6704
6794
|
return Object.freeze(t);
|
|
6705
6795
|
}
|
|
6706
6796
|
if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
|
|
6707
|
-
let e =
|
|
6797
|
+
let e = qo(n, Array.isArray(r) ? r.join(", ") : r);
|
|
6708
6798
|
e && t.push(e);
|
|
6709
6799
|
}
|
|
6710
6800
|
return Object.freeze(t);
|
|
6711
|
-
},
|
|
6712
|
-
let t = e.base === void 0 ?
|
|
6801
|
+
}, Yo = (e) => {
|
|
6802
|
+
let t = e.base === void 0 ? Ko(e.url) : Ko(e.url, e.base), n = {
|
|
6713
6803
|
raw: e.url,
|
|
6714
6804
|
href: t.href,
|
|
6715
6805
|
dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
|
|
@@ -6718,29 +6808,29 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6718
6808
|
resolved: t.resolved,
|
|
6719
6809
|
relativeToBase: t.relativeToBase,
|
|
6720
6810
|
method: (e.method ?? "GET").toUpperCase(),
|
|
6721
|
-
headers:
|
|
6811
|
+
headers: Jo(e.headers),
|
|
6722
6812
|
bodyKind: e.bodyKind,
|
|
6723
6813
|
..."body" in e ? { body: e.body } : {}
|
|
6724
6814
|
};
|
|
6725
6815
|
return Object.freeze(n);
|
|
6726
|
-
},
|
|
6816
|
+
}, Xo = (e, t) => {
|
|
6727
6817
|
if (!t || t.from === t.to) return e;
|
|
6728
6818
|
let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
|
|
6729
6819
|
return n ? Object.freeze(r) : e;
|
|
6730
|
-
},
|
|
6820
|
+
}, Zo = (e) => {
|
|
6731
6821
|
let t = {};
|
|
6732
6822
|
for (let [n, r] of e) t[n] = r;
|
|
6733
6823
|
return t;
|
|
6734
|
-
},
|
|
6824
|
+
}, Qo = /* @__PURE__ */ new Set([
|
|
6735
6825
|
"GET",
|
|
6736
6826
|
"HEAD",
|
|
6737
6827
|
"OPTIONS"
|
|
6738
|
-
]),
|
|
6828
|
+
]), $o = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, es = (e) => typeof e == "string" ? e : $o(e) ? e.url : String(e), ts = (e, t) => (t?.method ?? ($o(e) ? e.method : void 0) ?? "GET").toUpperCase(), ns = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", rs = (e) => {
|
|
6739
6829
|
if (typeof e == "string") return e.length;
|
|
6740
6830
|
let t = e;
|
|
6741
6831
|
if (typeof t?.size == "number") return t.size;
|
|
6742
6832
|
if (typeof t?.byteLength == "number") return t.byteLength;
|
|
6743
|
-
},
|
|
6833
|
+
}, is = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? Qo.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), as = (e, t, n, r, i) => ({
|
|
6744
6834
|
replayable: !1,
|
|
6745
6835
|
bodyKind: e,
|
|
6746
6836
|
reason: t,
|
|
@@ -6748,11 +6838,11 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6748
6838
|
forwardInit: i,
|
|
6749
6839
|
snapshot: r,
|
|
6750
6840
|
replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
|
|
6751
|
-
}),
|
|
6841
|
+
}), os = (e, t) => Zo(Xo(e.headers, t?.authorizationSwap)), ss = (e) => {
|
|
6752
6842
|
if (!e || !("headers" in e)) return e;
|
|
6753
6843
|
let { headers: t, ...n } = e;
|
|
6754
6844
|
return n;
|
|
6755
|
-
},
|
|
6845
|
+
}, cs = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : $o(e) ? e.headers : void 0, ls = (e) => {
|
|
6756
6846
|
if (e === null || typeof e == "string") return e;
|
|
6757
6847
|
if (typeof FormData < "u" && e instanceof FormData) {
|
|
6758
6848
|
let t = new FormData();
|
|
@@ -6760,18 +6850,18 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6760
6850
|
return t;
|
|
6761
6851
|
}
|
|
6762
6852
|
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;
|
|
6763
|
-
},
|
|
6764
|
-
let r =
|
|
6853
|
+
}, us = (e, t, n) => new Request(e, { headers: os(t, n) }), ds = (e, t, n) => {
|
|
6854
|
+
let r = es(e), i = ts(e, t), a = cs(e, t), o = (e, t) => Yo({
|
|
6765
6855
|
url: r,
|
|
6766
6856
|
method: i,
|
|
6767
6857
|
headers: a,
|
|
6768
6858
|
bodyKind: e,
|
|
6769
6859
|
...t === void 0 ? {} : { body: t }
|
|
6770
6860
|
});
|
|
6771
|
-
if (
|
|
6861
|
+
if ($o(e)) {
|
|
6772
6862
|
if (e.body === null || e.body === void 0) {
|
|
6773
6863
|
let a = o("none");
|
|
6774
|
-
return
|
|
6864
|
+
return is(n, {
|
|
6775
6865
|
url: r,
|
|
6776
6866
|
method: i,
|
|
6777
6867
|
bodyKind: "none"
|
|
@@ -6781,20 +6871,20 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6781
6871
|
forwardInput: e,
|
|
6782
6872
|
forwardInit: t,
|
|
6783
6873
|
snapshot: a,
|
|
6784
|
-
replay: (n, r) => n(
|
|
6785
|
-
} :
|
|
6874
|
+
replay: (n, r) => n(us(e, a, r), ss(t))
|
|
6875
|
+
} : as("none", "the replay policy refused this request", e, a, t);
|
|
6786
6876
|
}
|
|
6787
6877
|
let a = o("request-clone");
|
|
6788
|
-
if (!
|
|
6878
|
+
if (!is(n, {
|
|
6789
6879
|
url: r,
|
|
6790
6880
|
method: i,
|
|
6791
6881
|
bodyKind: "request-clone"
|
|
6792
|
-
})) return
|
|
6882
|
+
})) return as("request-clone", "the replay policy refused this request", e, a, t);
|
|
6793
6883
|
let s;
|
|
6794
6884
|
try {
|
|
6795
6885
|
s = e.clone();
|
|
6796
6886
|
} catch {
|
|
6797
|
-
return
|
|
6887
|
+
return as("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
|
|
6798
6888
|
}
|
|
6799
6889
|
return {
|
|
6800
6890
|
replayable: !0,
|
|
@@ -6802,17 +6892,17 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6802
6892
|
forwardInput: e,
|
|
6803
6893
|
forwardInit: t,
|
|
6804
6894
|
snapshot: a,
|
|
6805
|
-
replay: (e, n) => e(
|
|
6895
|
+
replay: (e, n) => e(us(s, a, n), ss(t))
|
|
6806
6896
|
};
|
|
6807
6897
|
}
|
|
6808
|
-
let s =
|
|
6809
|
-
if (s === "one-shot") return
|
|
6810
|
-
if (!
|
|
6898
|
+
let s = ns(t?.body);
|
|
6899
|
+
if (s === "one-shot") return as("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
|
|
6900
|
+
if (!is(n, {
|
|
6811
6901
|
url: r,
|
|
6812
6902
|
method: i,
|
|
6813
6903
|
bodyKind: s
|
|
6814
|
-
},
|
|
6815
|
-
let c = t && "body" in t ?
|
|
6904
|
+
}, rs(t?.body))) return as(s, "the replay policy refused this request", e, o(s), t);
|
|
6905
|
+
let c = t && "body" in t ? ls(t.body ?? null) : void 0, l = o(s, c);
|
|
6816
6906
|
return {
|
|
6817
6907
|
replayable: !0,
|
|
6818
6908
|
bodyKind: s,
|
|
@@ -6820,21 +6910,21 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6820
6910
|
forwardInit: t,
|
|
6821
6911
|
snapshot: l,
|
|
6822
6912
|
replay: (e, n) => e(l.dispatchUrl, {
|
|
6823
|
-
...
|
|
6913
|
+
...ss(t),
|
|
6824
6914
|
...c === void 0 ? {} : { body: c },
|
|
6825
|
-
headers:
|
|
6915
|
+
headers: os(l, n),
|
|
6826
6916
|
method: l.method
|
|
6827
6917
|
})
|
|
6828
6918
|
};
|
|
6829
|
-
},
|
|
6830
|
-
if (!
|
|
6919
|
+
}, fs = (e) => typeof e == "object" && !!e, ps = (e) => (t) => {
|
|
6920
|
+
if (!fs(e)) return;
|
|
6831
6921
|
let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
|
|
6832
6922
|
return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
|
|
6833
|
-
},
|
|
6923
|
+
}, ms = (e) => {
|
|
6834
6924
|
let t = e?.url ?? "", n = e?.baseURL;
|
|
6835
6925
|
return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
6836
|
-
},
|
|
6837
|
-
let r =
|
|
6926
|
+
}, hs = (e) => (e?.method ?? "GET").toUpperCase(), gs = (e) => e == null ? "none" : fs(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", _s = (e, t, n) => {
|
|
6927
|
+
let r = Zo(Xo(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
|
|
6838
6928
|
return {
|
|
6839
6929
|
...e,
|
|
6840
6930
|
...i ? { baseURL: void 0 } : {},
|
|
@@ -6843,10 +6933,10 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6843
6933
|
headers: r,
|
|
6844
6934
|
..."body" in t ? { data: t.body } : {}
|
|
6845
6935
|
};
|
|
6846
|
-
},
|
|
6847
|
-
let o = t ?? e?.config, s =
|
|
6848
|
-
url:
|
|
6849
|
-
method:
|
|
6936
|
+
}, vs = (e, t, n, r, i, a) => {
|
|
6937
|
+
let o = t ?? e?.config, s = gs(o?.data), c = a ?? Yo({
|
|
6938
|
+
url: ms(o),
|
|
6939
|
+
method: hs(o),
|
|
6850
6940
|
headers: o?.headers,
|
|
6851
6941
|
bodyKind: s,
|
|
6852
6942
|
body: o?.data
|
|
@@ -6854,22 +6944,22 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6854
6944
|
url: c.href,
|
|
6855
6945
|
method: c.method,
|
|
6856
6946
|
bodyKind: s
|
|
6857
|
-
}, u = s !== "one-shot" &&
|
|
6947
|
+
}, u = s !== "one-shot" && is(i.replay, l);
|
|
6858
6948
|
return {
|
|
6859
6949
|
status: e?.status ?? 0,
|
|
6860
|
-
getHeader:
|
|
6950
|
+
getHeader: ps(e?.headers),
|
|
6861
6951
|
readBody: async () => e?.data,
|
|
6862
6952
|
request: c,
|
|
6863
6953
|
replay: async (e) => {
|
|
6864
|
-
let t = Ie(
|
|
6954
|
+
let t = Ie(_s(o ?? {}, c, e));
|
|
6865
6955
|
try {
|
|
6866
6956
|
let e = await r(t);
|
|
6867
|
-
return
|
|
6957
|
+
return vs(e, e?.config ?? t, e, r, i, c);
|
|
6868
6958
|
} catch (e) {
|
|
6869
|
-
let n =
|
|
6870
|
-
if (!n.response || typeof n.response.status != "number" ||
|
|
6959
|
+
let n = fs(e) ? e : {};
|
|
6960
|
+
if (!n.response || typeof n.response.status != "number" || Ui(e)) throw e;
|
|
6871
6961
|
return {
|
|
6872
|
-
...
|
|
6962
|
+
...vs(n.response, n.config ?? t, e, r, i, c),
|
|
6873
6963
|
rejected: !0
|
|
6874
6964
|
};
|
|
6875
6965
|
}
|
|
@@ -6883,30 +6973,30 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6883
6973
|
replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
|
|
6884
6974
|
signal: o?.signal
|
|
6885
6975
|
};
|
|
6886
|
-
},
|
|
6887
|
-
let r =
|
|
6976
|
+
}, ys = (e, t) => async (n) => {
|
|
6977
|
+
let r = oo(e), i = fs(n) ? n : {}, a = Eo(await Co(vs(i.response, i.config, i.response, t, r), r), n);
|
|
6888
6978
|
if (a.settle === "reject") throw a.error;
|
|
6889
6979
|
return a.value;
|
|
6890
|
-
},
|
|
6891
|
-
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,
|
|
6980
|
+
}, bs = (e, t, n) => {
|
|
6981
|
+
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, ys(t, i)), o = !1;
|
|
6892
6982
|
return () => {
|
|
6893
6983
|
o || (o = !0, e.interceptors.response.eject(a));
|
|
6894
6984
|
};
|
|
6895
|
-
},
|
|
6985
|
+
}, xs = (t, n) => {
|
|
6896
6986
|
let r = e.create(t);
|
|
6897
6987
|
return n(r), r;
|
|
6898
|
-
},
|
|
6988
|
+
}, Ss = () => {
|
|
6899
6989
|
let e = typeof location > "u" ? void 0 : location.origin;
|
|
6900
6990
|
return e && e !== "null" ? e : void 0;
|
|
6901
|
-
},
|
|
6991
|
+
}, Cs = (e) => {
|
|
6902
6992
|
let t = new URL(e).origin;
|
|
6903
6993
|
if (t === "null") throw Error(`Passflow: "${e}" has no origin a request can be matched against; list http(s) origins only.`);
|
|
6904
6994
|
return t;
|
|
6905
|
-
},
|
|
6906
|
-
let n = (t?.origins ?? []).map(
|
|
6995
|
+
}, ws = (e, t) => {
|
|
6996
|
+
let n = (t?.origins ?? []).map(Cs);
|
|
6907
6997
|
return (t, r) => {
|
|
6908
6998
|
if (r) return Promise.resolve(void 0);
|
|
6909
|
-
let i =
|
|
6999
|
+
let i = Ss(), a;
|
|
6910
7000
|
try {
|
|
6911
7001
|
a = new URL(t, i).origin;
|
|
6912
7002
|
} catch {
|
|
@@ -6914,22 +7004,22 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6914
7004
|
}
|
|
6915
7005
|
return a !== i && !n.includes(a) ? Promise.resolve(void 0) : e();
|
|
6916
7006
|
};
|
|
6917
|
-
},
|
|
6918
|
-
let r =
|
|
7007
|
+
}, Ts = (e) => typeof Request < "u" && e instanceof Request, Es = (e, t) => new Headers(t?.headers === void 0 ? Ts(e) ? e.headers : void 0 : t.headers), Ds = (e, t, n) => {
|
|
7008
|
+
let r = ws(t, n);
|
|
6919
7009
|
return async (t, n) => {
|
|
6920
|
-
let i =
|
|
7010
|
+
let i = Ts(t) ? t.url : t instanceof URL ? t.href : String(t), a = Es(t, n), o = await r(i, a.has("authorization"));
|
|
6921
7011
|
return o ? (a.set("authorization", `Bearer ${o}`), e(t, {
|
|
6922
7012
|
...n,
|
|
6923
7013
|
headers: a
|
|
6924
7014
|
})) : e(t, n);
|
|
6925
7015
|
};
|
|
6926
|
-
},
|
|
7016
|
+
}, Os = (e) => {
|
|
6927
7017
|
let t = e.url ?? "", n = /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);
|
|
6928
7018
|
return !e.baseURL || n && e.allowAbsoluteUrls !== !1 ? t : t ? `${e.baseURL.replace(/\/?\/$/, "")}/${t.replace(/^\/+/, "")}` : e.baseURL;
|
|
6929
|
-
},
|
|
6930
|
-
let n =
|
|
7019
|
+
}, ks = (e) => e ? typeof e.has == "function" ? e.has("Authorization") : Object.keys(e).some((t) => t.toLowerCase() === "authorization" && e[t] != null) : !1, As = (e, t) => {
|
|
7020
|
+
let n = ws(e, t);
|
|
6931
7021
|
return async (e) => {
|
|
6932
|
-
let t = e.headers, r = await n(
|
|
7022
|
+
let t = e.headers, r = await n(Os(e), ks(t));
|
|
6933
7023
|
if (!r) return e;
|
|
6934
7024
|
let i = `Bearer ${r}`;
|
|
6935
7025
|
return t && typeof t.set == "function" ? t.set("Authorization", i) : e.headers = {
|
|
@@ -6937,7 +7027,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6937
7027
|
Authorization: i
|
|
6938
7028
|
}, e;
|
|
6939
7029
|
};
|
|
6940
|
-
},
|
|
7030
|
+
}, js = 0, Ms = (e, t) => {
|
|
6941
7031
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
6942
7032
|
if (n) return {
|
|
6943
7033
|
get aborted() {
|
|
@@ -6951,34 +7041,34 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6951
7041
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
6952
7042
|
} : {}
|
|
6953
7043
|
};
|
|
6954
|
-
},
|
|
7044
|
+
}, Ns = (e) => (t) => e.headers?.get(t), Ps = (e, t, n, r, i) => ({
|
|
6955
7045
|
status: e.status,
|
|
6956
|
-
getHeader:
|
|
7046
|
+
getHeader: Ns(e),
|
|
6957
7047
|
readBody: () => e.clone().json(),
|
|
6958
7048
|
request: t.snapshot,
|
|
6959
|
-
replay: async (e) =>
|
|
7049
|
+
replay: async (e) => Ps(await t.replay(n, e), t, n, r, i),
|
|
6960
7050
|
markers: r,
|
|
6961
7051
|
raw: e,
|
|
6962
7052
|
replayable: t.replayable,
|
|
6963
7053
|
replayUnsupportedReason: t.reason,
|
|
6964
7054
|
signal: i,
|
|
6965
7055
|
responseType: e.type
|
|
6966
|
-
}),
|
|
7056
|
+
}), Fs = (e, t) => {
|
|
6967
7057
|
let n = (t, n) => {
|
|
6968
|
-
|
|
7058
|
+
js += 1;
|
|
6969
7059
|
try {
|
|
6970
7060
|
return e(t, n);
|
|
6971
7061
|
} finally {
|
|
6972
|
-
--
|
|
7062
|
+
--js;
|
|
6973
7063
|
}
|
|
6974
7064
|
};
|
|
6975
7065
|
return async (e, r) => {
|
|
6976
|
-
if (
|
|
6977
|
-
let i =
|
|
7066
|
+
if (js > 0) return n(e, r);
|
|
7067
|
+
let i = oo(t), a = ds(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = To(await Co(Ps(o, a, n, {}, Ms(e, r)), i), o, i);
|
|
6978
7068
|
if (s.settle === "reject") throw s.error;
|
|
6979
7069
|
return s.value;
|
|
6980
7070
|
};
|
|
6981
|
-
},
|
|
7071
|
+
}, Is = new Set(Ra.filter((e) => !e.requiresPrepare).map((e) => e.type)), Ls = (e) => {
|
|
6982
7072
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
6983
7073
|
kind: "protocol",
|
|
6984
7074
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -6990,17 +7080,17 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
6990
7080
|
webauthn: e.webauthn,
|
|
6991
7081
|
codeSentTo: e.code_sent_to
|
|
6992
7082
|
};
|
|
6993
|
-
},
|
|
7083
|
+
}, Rs = (e) => Ui(e) && !Wi(e), zs = (e) => ({
|
|
6994
7084
|
async prepare(t) {
|
|
6995
|
-
if (!
|
|
7085
|
+
if (!Is.has(t)) try {
|
|
6996
7086
|
let n = e.relyingPartyId?.();
|
|
6997
|
-
return
|
|
7087
|
+
return Ls(await e.startUpgrade(n ? {
|
|
6998
7088
|
method: t,
|
|
6999
7089
|
relying_party_id: n
|
|
7000
7090
|
} : { method: t }));
|
|
7001
7091
|
} catch (e) {
|
|
7002
|
-
if (
|
|
7003
|
-
let t =
|
|
7092
|
+
if (Rs(e)) throw e;
|
|
7093
|
+
let t = Xi(e, "start");
|
|
7004
7094
|
if (t.kind === "prepare_not_required") return;
|
|
7005
7095
|
throw t;
|
|
7006
7096
|
}
|
|
@@ -7017,17 +7107,17 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7017
7107
|
assertion: n
|
|
7018
7108
|
});
|
|
7019
7109
|
} catch (t) {
|
|
7020
|
-
if (
|
|
7021
|
-
let n =
|
|
7022
|
-
throw n.status === 401 &&
|
|
7110
|
+
if (Rs(t)) throw t;
|
|
7111
|
+
let n = Xi(t, "refresh");
|
|
7112
|
+
throw n.status === 401 && Qi(n) && e.markSessionInvalid?.(), n;
|
|
7023
7113
|
}
|
|
7024
7114
|
}
|
|
7025
|
-
}),
|
|
7115
|
+
}), Bs = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Vs = (e) => {
|
|
7026
7116
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
7027
7117
|
let i = () => {
|
|
7028
7118
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
7029
7119
|
};
|
|
7030
|
-
return
|
|
7120
|
+
return zs({
|
|
7031
7121
|
...e,
|
|
7032
7122
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
7033
7123
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -7038,7 +7128,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7038
7128
|
});
|
|
7039
7129
|
}, i = (t, n) => {
|
|
7040
7130
|
let i = {}, a = {
|
|
7041
|
-
controller: new
|
|
7131
|
+
controller: new ao({
|
|
7042
7132
|
transport: r(() => i.current),
|
|
7043
7133
|
prompt: t.prompt,
|
|
7044
7134
|
platform: e.platform,
|
|
@@ -7050,7 +7140,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7050
7140
|
options: t,
|
|
7051
7141
|
scope: {
|
|
7052
7142
|
passflow: e.passflowDomain,
|
|
7053
|
-
backend:
|
|
7143
|
+
backend: Bs(t.backend)
|
|
7054
7144
|
},
|
|
7055
7145
|
generation: n
|
|
7056
7146
|
};
|
|
@@ -7060,17 +7150,17 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7060
7150
|
s = void 0;
|
|
7061
7151
|
});
|
|
7062
7152
|
let c = (e) => {
|
|
7063
|
-
if (!s ||
|
|
7153
|
+
if (!s || io(s.challenge, e)) return;
|
|
7064
7154
|
let t = Math.min(o, e.maxAge === void 0 ? o : e.maxAge * 1e3);
|
|
7065
7155
|
if (!(Date.now() - s.at > t)) return s.challenge;
|
|
7066
7156
|
}, l = async (r, i) => {
|
|
7067
7157
|
let o = t;
|
|
7068
|
-
if (!o) throw new
|
|
7158
|
+
if (!o) throw new ea("Step-up verification is not enabled on this Passflow instance");
|
|
7069
7159
|
let l = e.stopRepeatedElevation ? c(r) : void 0;
|
|
7070
|
-
if (l) throw new
|
|
7160
|
+
if (l) throw new $i(to(l), to(r), "This requirement was already proved and the server still refused it: sign the user in again");
|
|
7071
7161
|
o.controller.active || (o.pin = e.readSessionPin?.());
|
|
7072
7162
|
let u = await o.controller.elevate(r, i);
|
|
7073
|
-
if (!n(o)) throw new
|
|
7163
|
+
if (!n(o)) throw new ta();
|
|
7074
7164
|
return e.stopRepeatedElevation && (s = {
|
|
7075
7165
|
challenge: r,
|
|
7076
7166
|
at: a ?? Date.now()
|
|
@@ -7117,9 +7207,9 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7117
7207
|
let r = [];
|
|
7118
7208
|
if (e.attachInternalSeam) {
|
|
7119
7209
|
let t = e.attachInternalSeam;
|
|
7120
|
-
t((e) =>
|
|
7210
|
+
t((e) => ys(u, e)), r.push(() => t(void 0));
|
|
7121
7211
|
}
|
|
7122
|
-
n.interceptFetch && r.push(
|
|
7212
|
+
n.interceptFetch && r.push(Sn((e, t, n) => Fs(e, u)(t, n), {
|
|
7123
7213
|
priority: 20,
|
|
7124
7214
|
name: "passflow-upgrade"
|
|
7125
7215
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -7151,8 +7241,8 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7151
7241
|
enumerable: !0,
|
|
7152
7242
|
value: (t, n) => {
|
|
7153
7243
|
let r = (t) => {
|
|
7154
|
-
let r =
|
|
7155
|
-
return e.readAccessToken ?
|
|
7244
|
+
let r = Fs(t, u);
|
|
7245
|
+
return e.readAccessToken ? Ds(r, e.readAccessToken, n) : r;
|
|
7156
7246
|
};
|
|
7157
7247
|
if (t) return r(t);
|
|
7158
7248
|
let i = typeof globalThis > "u" ? void 0 : globalThis;
|
|
@@ -7163,14 +7253,14 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7163
7253
|
attachAuth: {
|
|
7164
7254
|
enumerable: !0,
|
|
7165
7255
|
value: (t, n) => {
|
|
7166
|
-
let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(
|
|
7256
|
+
let r = e.readAccessToken ? t.interceptors.request : void 0, i = r?.use(As(e.readAccessToken, n)), a = bs(t, u);
|
|
7167
7257
|
return () => {
|
|
7168
7258
|
a(), r && i !== void 0 && r.eject(i);
|
|
7169
7259
|
};
|
|
7170
7260
|
}
|
|
7171
7261
|
}
|
|
7172
7262
|
});
|
|
7173
|
-
},
|
|
7263
|
+
}, Hs, Us = class {
|
|
7174
7264
|
get origin() {
|
|
7175
7265
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
7176
7266
|
}
|
|
@@ -7183,9 +7273,9 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7183
7273
|
prefix: e.keyStoragePrefix ?? "",
|
|
7184
7274
|
storage: this.platform.storage,
|
|
7185
7275
|
appId: n
|
|
7186
|
-
}), this.deviceService = new de(this.storageManager), this.authApi = new
|
|
7187
|
-
let i =
|
|
7188
|
-
this.authService = new
|
|
7276
|
+
}), this.deviceService = new de(this.storageManager), this.authApi = new Xt(e, this.storageManager, this.deviceService), this.appApi = new Ut(e, this.storageManager, this.deviceService), this.userApi = new cn(e, this.storageManager, this.deviceService), this.settingApi = new $t(e, this.storageManager, this.deviceService), this.tenantApi = new en(e, this.storageManager, this.deviceService), this.invitationApi = new Qt(e, this.storageManager, this.deviceService), this.twoFactorApi = new on(e, this.storageManager, this.deviceService), this.upgradeApi = new sn(e, this.storageManager, this.deviceService), this.upgradeDomain = Be(e.url), this.subscribeStore = new rr(), this.tokenCacheService = new Aa(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? _, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
|
|
7277
|
+
let i = Zr(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
|
|
7278
|
+
this.authService = new Ea(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
|
|
7189
7279
|
createSession: async (e) => {
|
|
7190
7280
|
await this.createSessionCallback?.(e);
|
|
7191
7281
|
},
|
|
@@ -7195,7 +7285,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7195
7285
|
}, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
|
|
7196
7286
|
coordination: i,
|
|
7197
7287
|
...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
|
|
7198
|
-
}, () => this.readAppSettings()), this.antiBot =
|
|
7288
|
+
}, () => this.readAppSettings()), this.antiBot = yr({
|
|
7199
7289
|
readSettings: () => this.readAppSettings(),
|
|
7200
7290
|
fetchChallenge: ({ identifier: e, device: t }) => t ? this.authApi.deviceAntiBotChallenge({
|
|
7201
7291
|
user_code: t.userCode,
|
|
@@ -7205,7 +7295,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7205
7295
|
...e.antiBotWorkerUrl ? { workerUrl: e.antiBotWorkerUrl } : {}
|
|
7206
7296
|
}), this.authApi.setAntiBotHandler((e) => this.antiBot.headerFor(e)), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
7207
7297
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
7208
|
-
this.userService = new
|
|
7298
|
+
this.userService = new Ma(this.userApi, this.deviceService, this.platform), this.tenantService = new ka(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new Da(this.invitationApi), this.twoFactorService = new ja(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Vs({
|
|
7209
7299
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
7210
7300
|
commitRefresh: async (e, t) => {
|
|
7211
7301
|
await this.authService.refreshToken(e, t);
|
|
@@ -7234,7 +7324,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7234
7324
|
let e = (await this.getTokens(!0))?.access_token;
|
|
7235
7325
|
return e && !A(j(e)) ? e : void 0;
|
|
7236
7326
|
}
|
|
7237
|
-
}), this.hostedUpgrade =
|
|
7327
|
+
}), this.hostedUpgrade = Vs({
|
|
7238
7328
|
startUpgrade: (e) => this.upgradeApi.startHostedUpgrade(e),
|
|
7239
7329
|
commitRefresh: (e) => this.upgradeApi.commitHostedUpgrade(e),
|
|
7240
7330
|
canCommit: () => ({ ok: !0 }),
|
|
@@ -7271,7 +7361,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7271
7361
|
return this.upgrade.attachAuth(e, t);
|
|
7272
7362
|
}
|
|
7273
7363
|
createClient(e, t) {
|
|
7274
|
-
return
|
|
7364
|
+
return xs(e, (e) => this.upgrade.attachAuth(e, t));
|
|
7275
7365
|
}
|
|
7276
7366
|
readAssuranceBar() {
|
|
7277
7367
|
let e = this.storageManager.getToken(M.access_token);
|
|
@@ -7354,7 +7444,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7354
7444
|
}
|
|
7355
7445
|
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;
|
|
7356
7446
|
if (n) {
|
|
7357
|
-
if (!
|
|
7447
|
+
if (!ia(n)) {
|
|
7358
7448
|
W(this.subscribeStore, {
|
|
7359
7449
|
operation: "tokens.from-url",
|
|
7360
7450
|
message: "Invalid access token format received",
|
|
@@ -7362,7 +7452,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7362
7452
|
}), this.cleanupUrlParams(e);
|
|
7363
7453
|
return;
|
|
7364
7454
|
}
|
|
7365
|
-
if (r && !
|
|
7455
|
+
if (r && !ia(r)) {
|
|
7366
7456
|
W(this.subscribeStore, {
|
|
7367
7457
|
operation: "tokens.from-url",
|
|
7368
7458
|
message: "Invalid refresh token format received",
|
|
@@ -7370,7 +7460,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7370
7460
|
}), this.cleanupUrlParams(e);
|
|
7371
7461
|
return;
|
|
7372
7462
|
}
|
|
7373
|
-
if (i && !
|
|
7463
|
+
if (i && !ia(i)) {
|
|
7374
7464
|
W(this.subscribeStore, {
|
|
7375
7465
|
operation: "tokens.from-url",
|
|
7376
7466
|
message: "Invalid ID token format received",
|
|
@@ -7385,8 +7475,8 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7385
7475
|
scopes: o
|
|
7386
7476
|
};
|
|
7387
7477
|
this.cleanupUrlParams(e), this.error = void 0, this.readAppSettings().catch(() => void 0).then((e) => {
|
|
7388
|
-
if (e?.pkce_enabled !== !1) throw
|
|
7389
|
-
return
|
|
7478
|
+
if (e?.pkce_enabled !== !1) throw Un();
|
|
7479
|
+
return Ii(this.url, this.appId, t);
|
|
7390
7480
|
}).then(() => {
|
|
7391
7481
|
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();
|
|
7392
7482
|
}).then(() => (this.subscribeStore.notify(G.SignIn, {
|
|
@@ -7421,7 +7511,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7421
7511
|
if (!n) return !1;
|
|
7422
7512
|
t.delete("tfa_token");
|
|
7423
7513
|
let r = t.toString();
|
|
7424
|
-
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")),
|
|
7514
|
+
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), ia(n) ? (this.subscribeStore.notify(G.TwoFactorRequired, {
|
|
7425
7515
|
email: "",
|
|
7426
7516
|
challengeId: "",
|
|
7427
7517
|
tfaToken: n
|
|
@@ -7434,7 +7524,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7434
7524
|
checkErrorsFromURL() {
|
|
7435
7525
|
let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
|
|
7436
7526
|
if (e) {
|
|
7437
|
-
let t =
|
|
7527
|
+
let t = aa(e);
|
|
7438
7528
|
return Error(t);
|
|
7439
7529
|
}
|
|
7440
7530
|
}
|
|
@@ -7713,6 +7803,20 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7713
7803
|
this.handleError(e, "session.revoke-others", "Sign out other sessions");
|
|
7714
7804
|
}
|
|
7715
7805
|
}
|
|
7806
|
+
async requestAddressChangeProof(e) {
|
|
7807
|
+
try {
|
|
7808
|
+
return await this.userService.requestAddressChangeProof(e);
|
|
7809
|
+
} catch (e) {
|
|
7810
|
+
this.handleError(e, "profile.address-proof", "Request address change proof");
|
|
7811
|
+
}
|
|
7812
|
+
}
|
|
7813
|
+
async updateProfile(e, t) {
|
|
7814
|
+
try {
|
|
7815
|
+
return await this.userService.updateProfile(e, t);
|
|
7816
|
+
} catch (e) {
|
|
7817
|
+
this.handleError(e, "profile.update", "Update profile");
|
|
7818
|
+
}
|
|
7819
|
+
}
|
|
7716
7820
|
currentSessionId() {
|
|
7717
7821
|
let e = [this.storageManager.getToken(M.access_token), this.storageManager.getToken(M.id_token) ?? this.storageManager.getIdToken()];
|
|
7718
7822
|
for (let t of e) if (t) try {
|
|
@@ -7780,6 +7884,9 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7780
7884
|
getDeliveryMode() {
|
|
7781
7885
|
return this.authService.tokenDeliveryManager.getMode();
|
|
7782
7886
|
}
|
|
7887
|
+
getDeviceId() {
|
|
7888
|
+
return this.deviceService.getDeviceId();
|
|
7889
|
+
}
|
|
7783
7890
|
async restoreSession() {
|
|
7784
7891
|
return await this.authService.restoreSession();
|
|
7785
7892
|
}
|
|
@@ -7922,7 +8029,7 @@ var sa = 10, ca = "The sign-in answered with a PKCE code, but its verifier is go
|
|
|
7922
8029
|
this.twoFactorService.clearMagicLinkSession();
|
|
7923
8030
|
}
|
|
7924
8031
|
};
|
|
7925
|
-
|
|
7926
|
-
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,
|
|
8032
|
+
Hs = Us, Hs.version = h;
|
|
8033
|
+
export { at as ADDRESS_CHANGE_PROOF_REQUIRED_ERROR_ID, 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, dt as APP_SECRET_NAMES, l as AUTHORIZATION_HEADER_KEY, Ut as AppAPI, Xt as AuthAPI, Ea as AuthService, Zt as CLIAuthAPI, y as DEFAULT_GROUP_NAME, _ as DEFAULT_SCOPES, Ra 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, ln as FETCH_PRIORITY_OIDC, un as FETCH_PRIORITY_UPGRADE, dn as FetchMiddlewareContractError, ve as INSUFFICIENT_USER_AUTHENTICATION, Qt as InvitationAPI, Da as InvitationService, jn as M2MClient, En as M2MConfigError, H as M2MError, Dn as M2MErrorCodes, wn as M2MNetworkError, Tn as M2MTokenParseError, On as M2M_DEFAULTS, ft as MASKED_SECRET_PREFIX, g as MINIMAL_DEFAULT_SCOPES, ht 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, Us as Passflow, lt as PassflowAddressChangeProofRequiredError, ze as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, B as PassflowError, G as PassflowEvent, U as PassflowOidcError, tt as PassflowPasswordChangeRequiredError, ct as PassflowRecoveryCodesStepUpRequiredError, Y as PassflowRefreshError, st as PassflowSendLimitError, ot as PassflowSmsQuotaExceededError, fe as PopupClosedError, ut as Providers, Li as RECOVERABLE_COMMIT_ERROR_IDS, it as RECOVERY_CODES_STEP_UP_REQUIRED_ERROR_ID, ei 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, Ri as SESSION_INVALIDATING_COMMIT_ERROR_IDS, pt as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, se as SessionState, $t as SettingAPI, C as TOKEN_EXPIRY_BUFFER_SECONDS, rt as TWO_FACTOR_SEND_LIMIT_ERROR_ID, nt as TWO_FACTOR_SMS_QUOTA_EXCEEDED_ERROR_ID, en as TenantAPI, ka as TenantService, Oa as TenantUserMembership, Aa as TokenCacheService, N as TokenDeliveryMode, M as TokenType, on as TwoFactorApiClient, vt as TwoFactorPolicy, ja as TwoFactorService, ye as UPGRADE_REQUIRED, T as USERNAME_MAX_LENGTH, w as USERNAME_MIN_LENGTH, sn as UpgradeAPI, Ga as UpgradeCancelledError, fi as UpgradeCommitInterruptedError, ao as UpgradeController, Q as UpgradeErrorIds, Na as UpgradeFactorError, $i as UpgradeInsufficientError, ta as UpgradeSessionChangedError, Ka as UpgradeSignInRequiredError, $ as UpgradeTransportError, ea as UpgradeUnavailableError, Za as UpgradeUnsatisfiableError, cn as UserAPI, Ma as UserService, L as WebAdapter, Xi as classifyUpgradeError, za as factorRegistry, Cn as fetchRegistryState, gt as getOSFromDeviceType, Qi as invalidatesSessionOnCommit, Ve as isEmailVerificationStep, mt as isMaskedSecret, Zi as isRecoverableCommitFailure, Bi as isRetryableUpgradeKind, A as isTokenExpired, Io as isUpgradeCancelled, Lo as isUpgradeExhausted, Ro as isUpgradeInsufficient, Ho as isUpgradeSessionChanged, Bo as isUpgradeSignInRequired, Wi as isUpgradeTransportError, Uo as isUpgradeTransportFailure, Vo as isUpgradeUnavailable, zo as isUpgradeUnsatisfiable, oa as isValidEmail, ia as isValidJWTFormat, sa as isValidPhoneNumber, ca as isValidUsername, Ee as parseChallengeBody, Te as parseChallengeHeader, j as parseToken, Ae as parseUpgradeChallenge, La as passkeyFactor, _t as pathWithParams, Ia as recoveryCodesFactor, Sn as registerFetchMiddleware, _e as requiredAcrLevel, Be as resolveUpgradeDomain, aa as sanitizeErrorMessage, Wa as selectFactors, Fa as totpFactor, R as webAdapter };
|
|
7927
8034
|
|
|
7928
8035
|
//# sourceMappingURL=index.mjs.map
|