@passflow/core 0.22.0 → 0.24.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 +73 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +263 -3
- package/dist/index.d.ts +263 -3
- package/dist/index.mjs +978 -689
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import e from "axios";
|
|
2
2
|
import { startAuthentication as t, startRegistration as n } from "@simplewebauthn/browser";
|
|
3
3
|
// package.json
|
|
4
|
-
var r = "0.
|
|
4
|
+
var r = "0.24.0", i = "X-Passflow-Clientid", a = "Authorization", o = "X-Passflow-DeviceId", s = "X-Passflow-DeviceType", c = r, l = [
|
|
5
5
|
"id",
|
|
6
6
|
"offline",
|
|
7
7
|
"openid"
|
|
@@ -567,7 +567,7 @@ var j = /* @__PURE__ */ function(e) {
|
|
|
567
567
|
}), Ee = (e) => Se(e, xe), De = /* @__PURE__ */ function(e) {
|
|
568
568
|
return e.GET = "get", e.POST = "post", e.PUT = "put", e.PATCH = "patch", e.DELETE = "delete", e;
|
|
569
569
|
}({}), z = /* @__PURE__ */ function(e) {
|
|
570
|
-
return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.signInWithProvider = "/auth/federated/start/", e.passwordless = "/auth/passwordless/start", e.passwordlessComplete = "/auth/passwordless/complete", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e;
|
|
570
|
+
return e.signin = "/auth/login", e.signup = "/auth/register", e.pkceExchange = "/auth/pkce_exchange", e.signInWithProvider = "/auth/federated/start/", e.passwordless = "/auth/passwordless/start", e.passwordlessComplete = "/auth/passwordless/complete", e.passwordlessStatus = "/auth/passwordless/status", e.passwordlessApprovalInfo = "/auth/passwordless/approval/info", e.passwordlessApprovalDecide = "/auth/passwordless/approval/decide", e.logout = "/user/logout", e.refresh = "/auth/refresh", e.validateSession = "/user/me", e.sendPasswordResetEmail = "/auth/password/reset", e.resetPassword = "/auth/password/change", e.appSettings = "/app/settings", e.passkeyRegisterStart = "/auth/passkey/register/start", e.passkeyRegisterComplete = "/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/auth/passkey/authenticate/complete", e.passkeyValidate = "/auth/validate", e.settingsAll = "/settings", e.settingsPasswordPolicy = "/settings/password", e.settingsPasskey = "/settings/passkey", e.userPasskey = "/user/passkey", e.addUserPasskey = "/user/passkey/add/start", e.completeAddUserPasskey = "/user/passkey/add/complete", e.joinInvitation = "/user/tenant/join", e.tenantPath = "/user/tenant", e.invitationsPath = "/user/tenant/:tenantID/invitations", e.requestInvitation = "/user/invite", e.invitationDelete = "/user/invite/:invitationID", e.invitationResend = "/user/invite/:invitationID/resend", e.invitationGetLink = "/user/invite/:invitationID/link", e.twoFactor = "/user/2fa", e.twoFactorStatus = "/user/2fa/status", e.twoFactorSetupBegin = "/user/2fa/setup/begin", e.twoFactorSetupConfirm = "/user/2fa/setup/confirm", e.twoFactorVerify = "/auth/2fa/verify", e.twoFactorRecovery = "/auth/2fa/recovery", e.twoFactorRegenerateCodes = "/user/2fa/recovery-codes/regenerate", e.twoFactorSetupMagicLink = "/auth/2fa-setup", e.TwoFactorMethodsAvailable = "/v2/user/2fa/methods/available", e.TwoFactorMethodsRegistered = "/v2/user/2fa/methods", e.TwoFactorSetupStart = "/v2/user/2fa/setup/start", e.TwoFactorSetupComplete = "/v2/user/2fa/setup/complete", e.TwoFactorMethodRemove = "/v2/user/2fa/methods/:id", e.TwoFactorChallenge = "/v2/auth/2fa/challenge", e.TwoFactorVerifyV2 = "/v2/auth/2fa/verify", e.TwoFactorAlternative = "/v2/auth/2fa/alternative", e.TwoFactorTrustedDevices = "/v2/user/2fa/trusted-devices", e.TwoFactorTrustedDeviceRevoke = "/v2/user/2fa/trusted-devices/:id", e.cliAuthStatus = "/cli/auth/status/:sessionId", e.cliAuthComplete = "/cli/auth/complete", e.upgradeStart = "/auth/upgrade/start", e;
|
|
571
571
|
}({}), Oe = /* @__PURE__ */ function(e) {
|
|
572
572
|
return e.passkeyRegisterStart = "/admin/auth/passkey/register/start", e.passkeyRegisterComplete = "/admin/auth/passkey/register/complete", e.passkeyAuthenticateStart = "/admin/auth/passkey/authenticate/start", e.passkeyAuthenticateComplete = "/admin/auth/passkey/authenticate/complete", e.passkeyValidate = "/admin/auth/validate", e.logout = "/admin/auth/logout", e;
|
|
573
573
|
}({}), ke = (e) => {
|
|
@@ -587,24 +587,28 @@ var j = /* @__PURE__ */ function(e) {
|
|
|
587
587
|
}
|
|
588
588
|
}, je = /* @__PURE__ */ function(e) {
|
|
589
589
|
return e.google = "google", e.facebook = "facebook", e;
|
|
590
|
-
}({}), Me =
|
|
590
|
+
}({}), Me = Object.freeze([
|
|
591
|
+
"debug_otp_code_for_registration",
|
|
592
|
+
"fcm_server_key",
|
|
593
|
+
"webpush_vapid_private_key"
|
|
594
|
+
]), Ne = "mask://", Pe = "error.server.update.settings.masked.value.unknown", Fe = (e) => typeof e == "string" && e.startsWith("mask://"), Ie = /* @__PURE__ */ function(e) {
|
|
591
595
|
return e.web = "web", e.ios = "ios", e.android = "android", e;
|
|
592
596
|
}({});
|
|
593
|
-
function
|
|
597
|
+
function Le(e) {
|
|
594
598
|
return e;
|
|
595
599
|
}
|
|
596
|
-
function
|
|
600
|
+
function V(e, t) {
|
|
597
601
|
let n = e;
|
|
598
602
|
return Object.entries(t).forEach(([e, t]) => {
|
|
599
603
|
n = n.replace(`:${e}`, t);
|
|
600
604
|
}), n;
|
|
601
605
|
}
|
|
602
|
-
var
|
|
606
|
+
var Re = /* @__PURE__ */ function(e) {
|
|
603
607
|
return e.Disabled = "disabled", e.Optional = "optional", e.Required = "required", e;
|
|
604
|
-
}({}),
|
|
608
|
+
}({}), ze = 3, Be = 1e3, Ve = (e) => (t) => {
|
|
605
609
|
let n = e.headers?.[t] ?? e.headers?.[t.toLowerCase()];
|
|
606
610
|
return Array.isArray(n) ? n.join(", ") : n;
|
|
607
|
-
},
|
|
611
|
+
}, He = (e) => ye(e.status, Ve(e), e.data), Ue = (e) => He(e) !== void 0, We = (e) => e?.includes(z.refresh) ?? !1, Ge = (e) => e?.includes("logout") ?? !1, H = class {
|
|
608
612
|
get origin() {
|
|
609
613
|
return this._platform.getCurrentUrl()?.origin ?? "";
|
|
610
614
|
}
|
|
@@ -641,11 +645,11 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
641
645
|
let t = this.storageManager.getCsrfToken();
|
|
642
646
|
return t && (e.headers["X-CSRF-Token"] = t), e;
|
|
643
647
|
}
|
|
644
|
-
if (
|
|
648
|
+
if (We(e.url)) return e;
|
|
645
649
|
let t = this.storageManager.getTokens();
|
|
646
650
|
if (!t?.access_token) return e;
|
|
647
651
|
let n = t.access_token;
|
|
648
|
-
if (this.refreshHandler && t.refresh_token && !
|
|
652
|
+
if (this.refreshHandler && t.refresh_token && !Ge(e.url)) {
|
|
649
653
|
let e = A(t.access_token);
|
|
650
654
|
if (k(e, 30)) {
|
|
651
655
|
let t = !k(e, 0);
|
|
@@ -661,8 +665,8 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
661
665
|
}
|
|
662
666
|
return e.headers[a] = `Bearer ${n}`, e;
|
|
663
667
|
}), this.instance.interceptors.response.use((e) => e, async (e) => {
|
|
664
|
-
if (e.response?.status === 401 && !
|
|
665
|
-
let t =
|
|
668
|
+
if (e.response?.status === 401 && !We(e.config?.url) && !this.isUpgradeTransactionError(e) && this.tokenDeliveryManager.setSessionInvalid(), e.response && this.upgradeHandler) {
|
|
669
|
+
let t = He(e.response);
|
|
666
670
|
if (t) try {
|
|
667
671
|
return await this.upgradeHandler(e, t);
|
|
668
672
|
} catch (t) {
|
|
@@ -673,7 +677,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
673
677
|
});
|
|
674
678
|
}
|
|
675
679
|
isUpgradeTransactionError(e) {
|
|
676
|
-
return we(e.config) || e.response !== void 0 &&
|
|
680
|
+
return we(e.config) || e.response !== void 0 && Ue(e.response);
|
|
677
681
|
}
|
|
678
682
|
setUpgradeInterceptor(e) {
|
|
679
683
|
this.upgradeHandler = e;
|
|
@@ -695,7 +699,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
695
699
|
}
|
|
696
700
|
async handleRateLimitError(e) {
|
|
697
701
|
let t = e.config;
|
|
698
|
-
if (!t ||
|
|
702
|
+
if (!t || We(t.url)) return Promise.reject(e);
|
|
699
703
|
let n = t.method?.toUpperCase();
|
|
700
704
|
if (![
|
|
701
705
|
"GET",
|
|
@@ -703,8 +707,8 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
703
707
|
"OPTIONS"
|
|
704
708
|
].includes(n || "")) return Promise.reject(e);
|
|
705
709
|
let r = t._retryCount || 0;
|
|
706
|
-
if (r >=
|
|
707
|
-
let i =
|
|
710
|
+
if (r >= ze) return Promise.reject(e);
|
|
711
|
+
let i = Be * 2 ** r, a = e.response?.headers?.["retry-after"];
|
|
708
712
|
if (a) {
|
|
709
713
|
let e = Number.parseInt(a, 10);
|
|
710
714
|
if (!Number.isNaN(e)) i = e * 1e3;
|
|
@@ -767,9 +771,9 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
767
771
|
[i]: e
|
|
768
772
|
}, this.instance.defaults.headers.common[i] = e;
|
|
769
773
|
}
|
|
770
|
-
},
|
|
774
|
+
}, Ke = class {
|
|
771
775
|
constructor(e, t, n) {
|
|
772
|
-
this.axiosClient = new
|
|
776
|
+
this.axiosClient = new H(e, t, n);
|
|
773
777
|
}
|
|
774
778
|
setAppId(e) {
|
|
775
779
|
this.axiosClient.setAppId(e);
|
|
@@ -777,9 +781,19 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
777
781
|
getAppSettings() {
|
|
778
782
|
return this.axiosClient.get(z.appSettings);
|
|
779
783
|
}
|
|
780
|
-
},
|
|
784
|
+
}, qe = { withCredentials: !0 }, Je = 15e3, Ye = "Sign-in failed. Start again.", Xe = "Something went wrong. Try again later.", Ze = (e, t, n, r) => {
|
|
785
|
+
if (e instanceof B) return e;
|
|
786
|
+
let i = e?.response?.data?.error;
|
|
787
|
+
return new B({
|
|
788
|
+
id: typeof i?.id == "string" ? i.id : n,
|
|
789
|
+
message: typeof i?.message == "string" ? i.message : r,
|
|
790
|
+
status: typeof i?.status == "number" ? i.status : 0,
|
|
791
|
+
location: t,
|
|
792
|
+
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
793
|
+
});
|
|
794
|
+
}, Qe = class {
|
|
781
795
|
constructor(e, t, n) {
|
|
782
|
-
this.axiosClient = new
|
|
796
|
+
this.axiosClient = new H(e, t, n);
|
|
783
797
|
}
|
|
784
798
|
setAppId(e) {
|
|
785
799
|
this.axiosClient.setAppId(e);
|
|
@@ -798,7 +812,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
798
812
|
device: t,
|
|
799
813
|
os: n
|
|
800
814
|
};
|
|
801
|
-
return this.axiosClient.post(z.signin, r,
|
|
815
|
+
return this.axiosClient.post(z.signin, r, qe);
|
|
802
816
|
}
|
|
803
817
|
signUp(e) {
|
|
804
818
|
let { create_tenant: t, anonymous: n } = e, r = {
|
|
@@ -806,31 +820,68 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
806
820
|
create_tenant: t ?? !1,
|
|
807
821
|
anonymous: n ?? !1
|
|
808
822
|
};
|
|
809
|
-
return this.axiosClient.post(z.signup, r,
|
|
823
|
+
return this.axiosClient.post(z.signup, r, qe);
|
|
810
824
|
}
|
|
811
|
-
pkceExchange(e, t) {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
825
|
+
async pkceExchange(e, t) {
|
|
826
|
+
try {
|
|
827
|
+
return await this.axiosClient.post(z.pkceExchange, {
|
|
828
|
+
authz_code: e,
|
|
829
|
+
verifier: t
|
|
830
|
+
}, qe);
|
|
831
|
+
} catch (e) {
|
|
832
|
+
throw Ze(e, z.pkceExchange, "error.pkce.exchange", Ye);
|
|
833
|
+
}
|
|
816
834
|
}
|
|
817
|
-
passwordlessSignIn(e, t, n) {
|
|
835
|
+
async passwordlessSignIn(e, t, n) {
|
|
818
836
|
let { create_tenant: r } = e, i = {
|
|
819
837
|
...e,
|
|
820
838
|
create_tenant: r ?? !1,
|
|
821
839
|
device: t,
|
|
822
840
|
os: n
|
|
823
841
|
};
|
|
824
|
-
|
|
842
|
+
try {
|
|
843
|
+
return await this.axiosClient.post(z.passwordless, i);
|
|
844
|
+
} catch (e) {
|
|
845
|
+
throw Ze(e, z.passwordless, "error.passwordless.start", Xe);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
async passwordlessSignInComplete(e) {
|
|
849
|
+
try {
|
|
850
|
+
return await this.axiosClient.post(z.passwordlessComplete, e, qe);
|
|
851
|
+
} catch (e) {
|
|
852
|
+
throw Ze(e, z.passwordlessComplete, "error.passwordless.complete", Xe);
|
|
853
|
+
}
|
|
825
854
|
}
|
|
826
|
-
|
|
827
|
-
|
|
855
|
+
async passwordlessStatus(e, t) {
|
|
856
|
+
try {
|
|
857
|
+
return await this.axiosClient.post(z.passwordlessStatus, e, {
|
|
858
|
+
...qe,
|
|
859
|
+
timeout: Je,
|
|
860
|
+
signal: t?.signal
|
|
861
|
+
});
|
|
862
|
+
} catch (e) {
|
|
863
|
+
throw Ze(e, z.passwordlessStatus, "error.passwordless.status", Ye);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
async passwordlessApprovalInfo(e) {
|
|
867
|
+
try {
|
|
868
|
+
return await this.axiosClient.post(z.passwordlessApprovalInfo, e);
|
|
869
|
+
} catch (e) {
|
|
870
|
+
throw Ze(e, z.passwordlessApprovalInfo, "error.passwordless.approval", Xe);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
async passwordlessApprovalDecide(e) {
|
|
874
|
+
try {
|
|
875
|
+
return await this.axiosClient.post(z.passwordlessApprovalDecide, e);
|
|
876
|
+
} catch (e) {
|
|
877
|
+
throw Ze(e, z.passwordlessApprovalDecide, "error.passwordless.approval", Xe);
|
|
878
|
+
}
|
|
828
879
|
}
|
|
829
880
|
validateEmailCode(e) {
|
|
830
881
|
return this.axiosClient.post(z.passkeyValidate, {
|
|
831
882
|
challenge_id: e.challenge_id,
|
|
832
883
|
otp: e.otp
|
|
833
|
-
},
|
|
884
|
+
}, qe);
|
|
834
885
|
}
|
|
835
886
|
logOut(e, t, n = !1) {
|
|
836
887
|
let r = n ? void 0 : {
|
|
@@ -871,7 +922,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
871
922
|
device: t,
|
|
872
923
|
passkey_data: e
|
|
873
924
|
}, a = r ? Oe.passkeyRegisterComplete : z.passkeyRegisterComplete;
|
|
874
|
-
return this.axiosClient.post(a, i,
|
|
925
|
+
return this.axiosClient.post(a, i, qe);
|
|
875
926
|
}
|
|
876
927
|
passkeyAuthenticateStart(e, t, n, r = !1) {
|
|
877
928
|
let i = {
|
|
@@ -888,7 +939,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
888
939
|
device: t,
|
|
889
940
|
passkey_data: e
|
|
890
941
|
}, a = r ? Oe.passkeyAuthenticateComplete : z.passkeyAuthenticateComplete;
|
|
891
|
-
return this.axiosClient.post(a, i,
|
|
942
|
+
return this.axiosClient.post(a, i, qe);
|
|
892
943
|
}
|
|
893
944
|
passkeyValidate(e, t, n, r = !1, a) {
|
|
894
945
|
let o = {
|
|
@@ -900,23 +951,23 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
900
951
|
let c = a ? { [i]: a } : {};
|
|
901
952
|
return this.axiosClient.post(s, o, { headers: c });
|
|
902
953
|
}
|
|
903
|
-
},
|
|
954
|
+
}, $e = class {
|
|
904
955
|
constructor(e, t, n) {
|
|
905
|
-
this.axiosClient = new
|
|
956
|
+
this.axiosClient = new H(e, t, n);
|
|
906
957
|
}
|
|
907
958
|
setAppId(e) {
|
|
908
959
|
this.axiosClient.setAppId(e);
|
|
909
960
|
}
|
|
910
961
|
getCLIAuthStatus(e) {
|
|
911
|
-
let t =
|
|
962
|
+
let t = V(z.cliAuthStatus, { sessionId: e });
|
|
912
963
|
return this.axiosClient.get(t);
|
|
913
964
|
}
|
|
914
965
|
completeCLIAuth(e) {
|
|
915
966
|
return this.axiosClient.post(z.cliAuthComplete, e);
|
|
916
967
|
}
|
|
917
|
-
},
|
|
968
|
+
}, et = class {
|
|
918
969
|
constructor(e, t, n) {
|
|
919
|
-
this.axiosClient = new
|
|
970
|
+
this.axiosClient = new H(e, t, n);
|
|
920
971
|
}
|
|
921
972
|
setAppId(e) {
|
|
922
973
|
this.axiosClient.setAppId(e);
|
|
@@ -927,27 +978,27 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
927
978
|
getInvitations(e) {
|
|
928
979
|
let t = {};
|
|
929
980
|
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());
|
|
930
|
-
let n =
|
|
981
|
+
let n = V(z.invitationsPath, { tenantID: e.tenantID });
|
|
931
982
|
return this.axiosClient.get(n, { params: t }).then((e) => ({
|
|
932
983
|
invites: e.invites,
|
|
933
984
|
nextPageSkip: e.next_page_skip
|
|
934
985
|
}));
|
|
935
986
|
}
|
|
936
987
|
deleteInvitation(e) {
|
|
937
|
-
let t =
|
|
988
|
+
let t = V(z.invitationDelete, { invitationID: e });
|
|
938
989
|
return this.axiosClient.delete(t);
|
|
939
990
|
}
|
|
940
991
|
resendInvitation(e) {
|
|
941
|
-
let t =
|
|
992
|
+
let t = V(z.invitationResend, { invitationID: e });
|
|
942
993
|
return this.axiosClient.post(t, {});
|
|
943
994
|
}
|
|
944
995
|
getInvitationLink(e) {
|
|
945
|
-
let t =
|
|
996
|
+
let t = V(z.invitationGetLink, { invitationID: e });
|
|
946
997
|
return this.axiosClient.get(t);
|
|
947
998
|
}
|
|
948
|
-
},
|
|
999
|
+
}, tt = class {
|
|
949
1000
|
constructor(e, t, n) {
|
|
950
|
-
this.axiosClient = new
|
|
1001
|
+
this.axiosClient = new H(e, t, n);
|
|
951
1002
|
}
|
|
952
1003
|
setAppId(e) {
|
|
953
1004
|
this.axiosClient.setAppId(e);
|
|
@@ -961,9 +1012,9 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
961
1012
|
getPasskeySettings() {
|
|
962
1013
|
return this.axiosClient.get(z.settingsPasskey);
|
|
963
1014
|
}
|
|
964
|
-
},
|
|
1015
|
+
}, nt = class {
|
|
965
1016
|
constructor(e, t, n) {
|
|
966
|
-
this.axiosClient = new
|
|
1017
|
+
this.axiosClient = new H(e, t, n);
|
|
967
1018
|
}
|
|
968
1019
|
setAppId(e) {
|
|
969
1020
|
this.axiosClient.setAppId(e);
|
|
@@ -1077,12 +1128,12 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1077
1128
|
let r = `${z.tenantPath}/${e}/group/${t}/invite/email/${n}`;
|
|
1078
1129
|
return this.axiosClient.delete(r);
|
|
1079
1130
|
}
|
|
1080
|
-
},
|
|
1131
|
+
}, rt = (e) => e ? { headers: { Authorization: `Bearer ${e}` } } : {}, it = (e) => ({
|
|
1081
1132
|
withCredentials: !0,
|
|
1082
|
-
...
|
|
1083
|
-
}),
|
|
1133
|
+
...rt(e)
|
|
1134
|
+
}), at = class {
|
|
1084
1135
|
constructor(e, t, n) {
|
|
1085
|
-
this.axiosClient = new
|
|
1136
|
+
this.axiosClient = new H(e, t, n);
|
|
1086
1137
|
}
|
|
1087
1138
|
setAppId(e) {
|
|
1088
1139
|
this.axiosClient.setAppId(e);
|
|
@@ -1101,14 +1152,14 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1101
1152
|
return this.axiosClient.post(z.twoFactorVerify, {
|
|
1102
1153
|
code: n,
|
|
1103
1154
|
...r ? { trust_device: !0 } : {}
|
|
1104
|
-
},
|
|
1155
|
+
}, it(t));
|
|
1105
1156
|
}
|
|
1106
1157
|
useRecoveryCode(e) {
|
|
1107
1158
|
let { tfa_token: t, recovery_code: n, trust_device: r } = e;
|
|
1108
1159
|
return this.axiosClient.post(z.twoFactorRecovery, {
|
|
1109
1160
|
recovery_code: n,
|
|
1110
1161
|
...r ? { trust_device: !0 } : {}
|
|
1111
|
-
},
|
|
1162
|
+
}, it(t));
|
|
1112
1163
|
}
|
|
1113
1164
|
disable(e) {
|
|
1114
1165
|
return this.axiosClient.delete(z.twoFactor, { data: e });
|
|
@@ -1185,32 +1236,32 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1185
1236
|
});
|
|
1186
1237
|
}
|
|
1187
1238
|
removeMethod(e) {
|
|
1188
|
-
let t =
|
|
1239
|
+
let t = V(z.TwoFactorMethodRemove, { id: e });
|
|
1189
1240
|
return this.axiosClient.delete(t);
|
|
1190
1241
|
}
|
|
1191
1242
|
requestChallenge(e, t) {
|
|
1192
|
-
return this.axiosClient.post(z.TwoFactorChallenge, e,
|
|
1243
|
+
return this.axiosClient.post(z.TwoFactorChallenge, e, rt(t));
|
|
1193
1244
|
}
|
|
1194
1245
|
verifyV2(e, t) {
|
|
1195
1246
|
let { trust_device: n, ...r } = e;
|
|
1196
1247
|
return this.axiosClient.post(z.TwoFactorVerifyV2, {
|
|
1197
1248
|
...r,
|
|
1198
1249
|
...n ? { trust_device: !0 } : {}
|
|
1199
|
-
},
|
|
1250
|
+
}, it(t));
|
|
1200
1251
|
}
|
|
1201
1252
|
switchToAlternative(e, t) {
|
|
1202
|
-
return this.axiosClient.post(z.TwoFactorAlternative, e,
|
|
1253
|
+
return this.axiosClient.post(z.TwoFactorAlternative, e, rt(t));
|
|
1203
1254
|
}
|
|
1204
1255
|
async getTrustedDevices() {
|
|
1205
1256
|
return (await this.axiosClient.get(z.TwoFactorTrustedDevices, { withCredentials: !0 }))?.devices ?? [];
|
|
1206
1257
|
}
|
|
1207
1258
|
revokeTrustedDevice(e) {
|
|
1208
|
-
let t =
|
|
1259
|
+
let t = V(z.TwoFactorTrustedDeviceRevoke, { id: e });
|
|
1209
1260
|
return this.axiosClient.delete(t);
|
|
1210
1261
|
}
|
|
1211
|
-
},
|
|
1262
|
+
}, ot = class {
|
|
1212
1263
|
constructor(e, t, n) {
|
|
1213
|
-
this.axiosClient = new
|
|
1264
|
+
this.axiosClient = new H(e, t, n);
|
|
1214
1265
|
}
|
|
1215
1266
|
setAppId(e) {
|
|
1216
1267
|
this.axiosClient.setAppId(e);
|
|
@@ -1218,9 +1269,9 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1218
1269
|
startUpgrade(e) {
|
|
1219
1270
|
return this.axiosClient.post(z.upgradeStart, e, Ce({}));
|
|
1220
1271
|
}
|
|
1221
|
-
},
|
|
1272
|
+
}, st = class {
|
|
1222
1273
|
constructor(e, t, n) {
|
|
1223
|
-
this.axiosClient = new
|
|
1274
|
+
this.axiosClient = new H(e, t, n);
|
|
1224
1275
|
}
|
|
1225
1276
|
setAppId(e) {
|
|
1226
1277
|
this.axiosClient.setAppId(e);
|
|
@@ -1251,50 +1302,50 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1251
1302
|
passkey_data: e
|
|
1252
1303
|
});
|
|
1253
1304
|
}
|
|
1254
|
-
},
|
|
1305
|
+
}, ct = 10, lt = 20, ut = class extends Error {
|
|
1255
1306
|
constructor(e) {
|
|
1256
1307
|
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;
|
|
1257
1308
|
}
|
|
1258
|
-
},
|
|
1309
|
+
}, dt = [], ft = 0, pt = !1, mt, ht, gt = (e, t) => e.priority - t.priority || e.seq - t.seq, _t = () => typeof globalThis > "u" ? void 0 : globalThis, vt = async (e, t, n, r) => {
|
|
1259
1310
|
if (t >= e.length) {
|
|
1260
|
-
let e =
|
|
1311
|
+
let e = mt;
|
|
1261
1312
|
if (!e) throw Error("Passflow fetch registry: no captured fetch to delegate to.");
|
|
1262
1313
|
return e(n, r);
|
|
1263
1314
|
}
|
|
1264
1315
|
let i = e[t];
|
|
1265
|
-
if (!i) return
|
|
1266
|
-
let a = !1, o = await i.middleware((n, r) => (a = !0,
|
|
1267
|
-
if (!a) throw new
|
|
1316
|
+
if (!i) return vt(e, e.length, n, r);
|
|
1317
|
+
let a = !1, o = await i.middleware((n, r) => (a = !0, vt(e, t + 1, n, r)), n, r);
|
|
1318
|
+
if (!a) throw new ut(i.name);
|
|
1268
1319
|
return o;
|
|
1269
|
-
},
|
|
1270
|
-
let e =
|
|
1320
|
+
}, yt = () => {
|
|
1321
|
+
let e = _t();
|
|
1271
1322
|
if (!e || typeof e.fetch != "function") return !1;
|
|
1272
|
-
let t = e.fetch.bind(e), n = (e, t) =>
|
|
1273
|
-
return
|
|
1274
|
-
},
|
|
1275
|
-
let e =
|
|
1276
|
-
e &&
|
|
1277
|
-
},
|
|
1278
|
-
if (!
|
|
1323
|
+
let t = e.fetch.bind(e), n = (e, t) => vt([...dt].sort(gt), 0, e, t);
|
|
1324
|
+
return mt = t, ht = n, e.fetch = n, pt = !0, !0;
|
|
1325
|
+
}, bt = () => {
|
|
1326
|
+
let e = _t();
|
|
1327
|
+
e && ht && e.fetch === ht && (mt && (e.fetch = mt), pt = !1, ht = void 0, mt = void 0);
|
|
1328
|
+
}, xt = (e, t) => {
|
|
1329
|
+
if (!pt && !yt()) return () => {};
|
|
1279
1330
|
let n = {
|
|
1280
1331
|
middleware: e,
|
|
1281
1332
|
name: t.name,
|
|
1282
1333
|
priority: t.priority,
|
|
1283
|
-
seq:
|
|
1334
|
+
seq: ft++
|
|
1284
1335
|
};
|
|
1285
|
-
|
|
1336
|
+
dt.push(n);
|
|
1286
1337
|
let r = !1;
|
|
1287
1338
|
return () => {
|
|
1288
|
-
r || (r = !0,
|
|
1339
|
+
r || (r = !0, dt = dt.filter((e) => e !== n), dt.length === 0 && bt());
|
|
1289
1340
|
};
|
|
1290
|
-
},
|
|
1291
|
-
let e =
|
|
1341
|
+
}, St = () => {
|
|
1342
|
+
let e = _t();
|
|
1292
1343
|
return {
|
|
1293
|
-
installed:
|
|
1294
|
-
names: [...
|
|
1295
|
-
foreignPatch:
|
|
1344
|
+
installed: pt,
|
|
1345
|
+
names: [...dt].sort(gt).map((e) => e.name),
|
|
1346
|
+
foreignPatch: pt && !!e && !!ht && e.fetch !== ht
|
|
1296
1347
|
};
|
|
1297
|
-
},
|
|
1348
|
+
}, U = class e extends Error {
|
|
1298
1349
|
constructor(t) {
|
|
1299
1350
|
super(t.message), this.name = "M2MError", this.code = t.code, this.status = t.status ?? 400, this.errorUri = t.errorUri, this.rateLimitInfo = t.rateLimitInfo, this.headers = t.headers, this.cause = t.cause, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this, e);
|
|
1300
1351
|
}
|
|
@@ -1363,7 +1414,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1363
1414
|
let e = `M2MError [${this.code}]: ${this.message}`;
|
|
1364
1415
|
return this.status && (e += ` (HTTP ${this.status})`), e;
|
|
1365
1416
|
}
|
|
1366
|
-
},
|
|
1417
|
+
}, Ct = class extends U {
|
|
1367
1418
|
constructor(e, t) {
|
|
1368
1419
|
super({
|
|
1369
1420
|
code: "temporarily_unavailable",
|
|
@@ -1372,7 +1423,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1372
1423
|
cause: t
|
|
1373
1424
|
}), this.name = "M2MNetworkError";
|
|
1374
1425
|
}
|
|
1375
|
-
},
|
|
1426
|
+
}, wt = class extends U {
|
|
1376
1427
|
constructor(e, t) {
|
|
1377
1428
|
super({
|
|
1378
1429
|
code: "invalid_request",
|
|
@@ -1381,7 +1432,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1381
1432
|
cause: t
|
|
1382
1433
|
}), this.name = "M2MTokenParseError";
|
|
1383
1434
|
}
|
|
1384
|
-
},
|
|
1435
|
+
}, Tt = class extends U {
|
|
1385
1436
|
constructor(e) {
|
|
1386
1437
|
super({
|
|
1387
1438
|
code: "invalid_request",
|
|
@@ -1389,7 +1440,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1389
1440
|
status: 400
|
|
1390
1441
|
}), this.name = "M2MConfigError";
|
|
1391
1442
|
}
|
|
1392
|
-
},
|
|
1443
|
+
}, Et = {
|
|
1393
1444
|
InvalidRequest: "invalid_request",
|
|
1394
1445
|
InvalidClient: "invalid_client",
|
|
1395
1446
|
InvalidGrant: "invalid_grant",
|
|
@@ -1399,14 +1450,14 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1399
1450
|
RateLimitExceeded: "rate_limit_exceeded",
|
|
1400
1451
|
ServerError: "server_error",
|
|
1401
1452
|
TemporarilyUnavailable: "temporarily_unavailable"
|
|
1402
|
-
},
|
|
1453
|
+
}, Dt = {
|
|
1403
1454
|
TOKEN_ENDPOINT: "/oauth2/token",
|
|
1404
1455
|
TIMEOUT: 1e4,
|
|
1405
1456
|
RETRIES: 3,
|
|
1406
1457
|
RETRY_DELAY: 1e3,
|
|
1407
1458
|
REFRESH_THRESHOLD: 30,
|
|
1408
1459
|
CONTENT_TYPE: "application/x-www-form-urlencoded"
|
|
1409
|
-
},
|
|
1460
|
+
}, Ot = class {
|
|
1410
1461
|
constructor() {
|
|
1411
1462
|
this.cache = /* @__PURE__ */ new Map();
|
|
1412
1463
|
}
|
|
@@ -1423,18 +1474,18 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1423
1474
|
delete(e) {
|
|
1424
1475
|
return this.cache.delete(e), Promise.resolve();
|
|
1425
1476
|
}
|
|
1426
|
-
},
|
|
1477
|
+
}, kt = {
|
|
1427
1478
|
shouldRetry(e, t) {
|
|
1428
1479
|
return t >= 3 ? !1 : e.code === "server_error" || e.code === "temporarily_unavailable" || e.code === "rate_limit_exceeded" || e.status !== void 0 && e.status >= 500;
|
|
1429
1480
|
},
|
|
1430
1481
|
getDelay(e) {
|
|
1431
1482
|
return 2 ** (e - 1) * 1e3;
|
|
1432
1483
|
}
|
|
1433
|
-
},
|
|
1484
|
+
}, At = class {
|
|
1434
1485
|
constructor(e) {
|
|
1435
|
-
if (!e.url) throw new
|
|
1436
|
-
if (!e.clientId) throw new
|
|
1437
|
-
if (!e.clientSecret) throw new
|
|
1486
|
+
if (!e.url) throw new Tt("M2M client requires a URL");
|
|
1487
|
+
if (!e.clientId) throw new Tt("M2M client requires a clientId");
|
|
1488
|
+
if (!e.clientSecret) throw new Tt("M2M client requires a clientSecret");
|
|
1438
1489
|
let t = e.url.replace(/\/$/, "");
|
|
1439
1490
|
this.config = {
|
|
1440
1491
|
url: t,
|
|
@@ -1443,16 +1494,16 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1443
1494
|
scopes: e.scopes,
|
|
1444
1495
|
audience: e.audience,
|
|
1445
1496
|
autoRefresh: e.autoRefresh ?? !1,
|
|
1446
|
-
refreshThreshold: e.refreshThreshold ??
|
|
1447
|
-
timeout: e.timeout ??
|
|
1448
|
-
retries: e.retries ??
|
|
1449
|
-
retryDelay: e.retryDelay ??
|
|
1497
|
+
refreshThreshold: e.refreshThreshold ?? Dt.REFRESH_THRESHOLD,
|
|
1498
|
+
timeout: e.timeout ?? Dt.TIMEOUT,
|
|
1499
|
+
retries: e.retries ?? Dt.RETRIES,
|
|
1500
|
+
retryDelay: e.retryDelay ?? Dt.RETRY_DELAY,
|
|
1450
1501
|
retryStrategy: e.retryStrategy,
|
|
1451
1502
|
cache: e.cache,
|
|
1452
1503
|
onTokenRequest: e.onTokenRequest,
|
|
1453
1504
|
onTokenResponse: e.onTokenResponse,
|
|
1454
1505
|
onError: e.onError
|
|
1455
|
-
}, this.cache = e.cache ?? new
|
|
1506
|
+
}, this.cache = e.cache ?? new Ot(), this.retryStrategy = e.retryStrategy ?? kt, this.tokenEndpoint = `${t}${Dt.TOKEN_ENDPOINT}`;
|
|
1456
1507
|
}
|
|
1457
1508
|
getCacheKey(e, t) {
|
|
1458
1509
|
let n = e?.sort().join(",") || "", r = t?.sort().join(",") || "";
|
|
@@ -1497,7 +1548,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1497
1548
|
let e = await fetch(this.tokenEndpoint, {
|
|
1498
1549
|
method: "POST",
|
|
1499
1550
|
headers: {
|
|
1500
|
-
"Content-Type":
|
|
1551
|
+
"Content-Type": Dt.CONTENT_TYPE,
|
|
1501
1552
|
Accept: "application/json"
|
|
1502
1553
|
},
|
|
1503
1554
|
body: t.toString(),
|
|
@@ -1510,7 +1561,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1510
1561
|
});
|
|
1511
1562
|
let a = await e.json();
|
|
1512
1563
|
if (!e.ok) {
|
|
1513
|
-
let t =
|
|
1564
|
+
let t = U.fromOAuthError({
|
|
1514
1565
|
error: a.error || "server_error",
|
|
1515
1566
|
error_description: a.error_description || a.message,
|
|
1516
1567
|
error_uri: a.error_uri
|
|
@@ -1522,7 +1573,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1522
1573
|
}
|
|
1523
1574
|
return a;
|
|
1524
1575
|
} catch (e) {
|
|
1525
|
-
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new
|
|
1576
|
+
throw clearTimeout(r), e instanceof Error && e.name === "AbortError" ? new Ct(`Request timed out after ${this.config.timeout}ms`) : e instanceof TypeError && e.message.includes("fetch") ? new Ct(`Network error: ${e.message}`, e) : e instanceof U ? e : U.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1526
1577
|
}
|
|
1527
1578
|
}
|
|
1528
1579
|
async executeWithRetry(e) {
|
|
@@ -1530,7 +1581,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1530
1581
|
for (let n = 1; n <= this.config.retries; n++) try {
|
|
1531
1582
|
return await e();
|
|
1532
1583
|
} catch (e) {
|
|
1533
|
-
if (!(e instanceof
|
|
1584
|
+
if (!(e instanceof U)) throw e;
|
|
1534
1585
|
if (t = e, n < this.config.retries && this.retryStrategy.shouldRetry({
|
|
1535
1586
|
code: e.code,
|
|
1536
1587
|
status: e.status
|
|
@@ -1541,7 +1592,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1541
1592
|
}
|
|
1542
1593
|
throw e;
|
|
1543
1594
|
}
|
|
1544
|
-
throw t ?? new
|
|
1595
|
+
throw t ?? new U({
|
|
1545
1596
|
code: "server_error",
|
|
1546
1597
|
message: "Request failed after retries"
|
|
1547
1598
|
});
|
|
@@ -1565,13 +1616,13 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1565
1616
|
parseToken(e) {
|
|
1566
1617
|
try {
|
|
1567
1618
|
let t = e.split(".");
|
|
1568
|
-
if (t.length !== 3) throw new
|
|
1619
|
+
if (t.length !== 3) throw new wt("Invalid JWT format: expected 3 parts");
|
|
1569
1620
|
let n = t[1];
|
|
1570
|
-
if (!n) throw new
|
|
1621
|
+
if (!n) throw new wt("Invalid JWT format: missing payload");
|
|
1571
1622
|
let r = atob(n.replace(/-/g, "+").replace(/_/g, "/")), i = JSON.parse(r);
|
|
1572
1623
|
return i.scopes && typeof i.scopes == "string" ? i.scopes = i.scopes.split(" ") : i.scopes || (i.scopes = []), i;
|
|
1573
1624
|
} catch (e) {
|
|
1574
|
-
throw e instanceof
|
|
1625
|
+
throw e instanceof wt ? e : new wt(`Failed to parse token: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
1575
1626
|
}
|
|
1576
1627
|
}
|
|
1577
1628
|
clearCache() {
|
|
@@ -1586,19 +1637,19 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1586
1637
|
try {
|
|
1587
1638
|
let e = await fetch(t, {
|
|
1588
1639
|
method: "POST",
|
|
1589
|
-
headers: { "Content-Type":
|
|
1640
|
+
headers: { "Content-Type": Dt.CONTENT_TYPE },
|
|
1590
1641
|
body: n.toString()
|
|
1591
1642
|
});
|
|
1592
1643
|
if (!e.ok && e.status !== 200) {
|
|
1593
1644
|
let t = await e.json().catch(() => ({}));
|
|
1594
|
-
throw
|
|
1645
|
+
throw U.fromOAuthError({
|
|
1595
1646
|
error: t.error || "server_error",
|
|
1596
1647
|
error_description: t.error_description || "Token revocation failed"
|
|
1597
1648
|
}, e.status);
|
|
1598
1649
|
}
|
|
1599
1650
|
this.clearCache();
|
|
1600
1651
|
} catch (e) {
|
|
1601
|
-
throw e instanceof
|
|
1652
|
+
throw e instanceof U ? e : U.fromError(e instanceof Error ? e : Error(String(e)));
|
|
1602
1653
|
}
|
|
1603
1654
|
}
|
|
1604
1655
|
get url() {
|
|
@@ -1613,101 +1664,101 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
1613
1664
|
get audience() {
|
|
1614
1665
|
return this.config.audience;
|
|
1615
1666
|
}
|
|
1616
|
-
},
|
|
1667
|
+
}, jt = "error", Mt = /* @__PURE__ */ new WeakMap(), Nt = (e, t) => {
|
|
1617
1668
|
if (typeof t != "object" && typeof t != "function" || t === null) return !0;
|
|
1618
|
-
let n =
|
|
1619
|
-
return n || (n = /* @__PURE__ */ new WeakSet(),
|
|
1620
|
-
},
|
|
1669
|
+
let n = Mt.get(e);
|
|
1670
|
+
return n || (n = /* @__PURE__ */ new WeakSet(), Mt.set(e, n)), !n.has(t) && (n.add(t), !0);
|
|
1671
|
+
}, W = (e, t) => Nt(e, t.originalError) ? (e.notify(jt, t), !0) : !1, Pt = "passflow-refresh", Ft = "passflow-refresh-takeover", It = "passflow-auth", Lt = Object.freeze([
|
|
1621
1672
|
1e3,
|
|
1622
1673
|
3e3,
|
|
1623
1674
|
1e4,
|
|
1624
1675
|
3e4,
|
|
1625
1676
|
6e4
|
|
1626
|
-
]),
|
|
1677
|
+
]), Rt = .2, zt = 6e5, Bt = 5e3, G = 2e4, Vt = 2e4, Ht = 1e3, Ut = 2e3, Wt = 1e3, Gt = 1e4, Kt = 5e3;
|
|
1627
1678
|
// lib/refresh/protocol.ts
|
|
1628
|
-
function
|
|
1679
|
+
function qt(e) {
|
|
1629
1680
|
let t = e ? `:${e}` : "";
|
|
1630
1681
|
return {
|
|
1631
|
-
lock: `${
|
|
1632
|
-
takeoverLock: `${
|
|
1633
|
-
channel: `${
|
|
1682
|
+
lock: `${Pt}${t}`,
|
|
1683
|
+
takeoverLock: `${Ft}${t}`,
|
|
1684
|
+
channel: `${It}${t}`
|
|
1634
1685
|
};
|
|
1635
1686
|
}
|
|
1636
|
-
function
|
|
1687
|
+
function K(e) {
|
|
1637
1688
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
1638
1689
|
}
|
|
1639
|
-
function
|
|
1690
|
+
function Jt(e) {
|
|
1640
1691
|
return typeof e == "number" && Number.isFinite(e) ? e : void 0;
|
|
1641
1692
|
}
|
|
1642
|
-
function
|
|
1693
|
+
function Yt(e) {
|
|
1643
1694
|
return typeof e == "object" && !!e;
|
|
1644
1695
|
}
|
|
1645
|
-
function
|
|
1696
|
+
function Xt(e, t) {
|
|
1646
1697
|
for (let [n, r] of Object.entries(t)) r !== void 0 && (e[n] = r);
|
|
1647
1698
|
return e;
|
|
1648
1699
|
}
|
|
1649
|
-
function
|
|
1650
|
-
if (!
|
|
1700
|
+
function Zt(e) {
|
|
1701
|
+
if (!Yt(e)) return null;
|
|
1651
1702
|
let t = Array.isArray(e.scopes) ? e.scopes.filter((e) => typeof e == "string") : void 0;
|
|
1652
|
-
return
|
|
1653
|
-
access_token:
|
|
1654
|
-
refresh_token:
|
|
1655
|
-
id_token:
|
|
1703
|
+
return Xt({}, {
|
|
1704
|
+
access_token: K(e.access_token),
|
|
1705
|
+
refresh_token: K(e.refresh_token),
|
|
1706
|
+
id_token: K(e.id_token),
|
|
1656
1707
|
scopes: Array.isArray(e.scopes) && t?.length === e.scopes.length ? t : void 0
|
|
1657
1708
|
});
|
|
1658
1709
|
}
|
|
1659
|
-
function
|
|
1660
|
-
if (!
|
|
1710
|
+
function Qt(e) {
|
|
1711
|
+
if (!Yt(e)) return null;
|
|
1661
1712
|
let { kind: t, attempt: n, nextAt: r, strikes: i } = e;
|
|
1662
|
-
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 ||
|
|
1713
|
+
return t !== "transient" && t !== "auth" || typeof n != "number" || !Number.isInteger(n) || n < 1 || Jt(r) === void 0 || typeof i != "number" || !Number.isFinite(i) || i < 0 ? null : Xt({
|
|
1663
1714
|
kind: t,
|
|
1664
1715
|
attempt: n,
|
|
1665
1716
|
nextAt: r,
|
|
1666
1717
|
strikes: i
|
|
1667
1718
|
}, {
|
|
1668
|
-
from:
|
|
1669
|
-
failingSince:
|
|
1719
|
+
from: K(e.from),
|
|
1720
|
+
failingSince: Jt(e.failingSince)
|
|
1670
1721
|
});
|
|
1671
1722
|
}
|
|
1672
|
-
function
|
|
1673
|
-
return
|
|
1674
|
-
fp:
|
|
1675
|
-
sub:
|
|
1676
|
-
sid:
|
|
1677
|
-
iat:
|
|
1723
|
+
function $t(e) {
|
|
1724
|
+
return Xt({}, {
|
|
1725
|
+
fp: K(e.fp),
|
|
1726
|
+
sub: K(e.sub),
|
|
1727
|
+
sid: K(e.sid),
|
|
1728
|
+
iat: Jt(e.iat)
|
|
1678
1729
|
});
|
|
1679
1730
|
}
|
|
1680
|
-
function
|
|
1681
|
-
if (!
|
|
1731
|
+
function en(e) {
|
|
1732
|
+
if (!Yt(e)) return null;
|
|
1682
1733
|
let t = e;
|
|
1683
1734
|
if (t.v !== void 0 && t.v !== 1) return null;
|
|
1684
|
-
let n =
|
|
1735
|
+
let n = K(t.tabId);
|
|
1685
1736
|
if (!n) return null;
|
|
1686
1737
|
switch (t.type) {
|
|
1687
1738
|
case "tokens-refreshed": {
|
|
1688
|
-
let e =
|
|
1689
|
-
return !e || !r || !i ? null :
|
|
1739
|
+
let e = Zt(t.tokens), r = K(t.from), i = K(t.to);
|
|
1740
|
+
return !e || !r || !i ? null : Xt({
|
|
1690
1741
|
type: t.type,
|
|
1691
1742
|
tabId: n,
|
|
1692
1743
|
tokens: e,
|
|
1693
1744
|
from: r,
|
|
1694
1745
|
to: i
|
|
1695
1746
|
}, {
|
|
1696
|
-
fromIat:
|
|
1747
|
+
fromIat: Jt(t.fromIat),
|
|
1697
1748
|
fromSid: typeof t.fromSid == "string" ? t.fromSid : void 0,
|
|
1698
|
-
sentAt:
|
|
1749
|
+
sentAt: Jt(t.sentAt)
|
|
1699
1750
|
});
|
|
1700
1751
|
}
|
|
1701
1752
|
case "session-refreshed": {
|
|
1702
|
-
let e =
|
|
1703
|
-
return e === void 0 ? null :
|
|
1753
|
+
let e = Jt(t.at);
|
|
1754
|
+
return e === void 0 ? null : Xt({
|
|
1704
1755
|
type: t.type,
|
|
1705
1756
|
tabId: n,
|
|
1706
1757
|
at: e
|
|
1707
|
-
}, { sub:
|
|
1758
|
+
}, { sub: K(t.sub) });
|
|
1708
1759
|
}
|
|
1709
1760
|
case "still-refreshing": {
|
|
1710
|
-
let e = t.retry === void 0 ? null :
|
|
1761
|
+
let e = t.retry === void 0 ? null : Qt(t.retry);
|
|
1711
1762
|
return e ? {
|
|
1712
1763
|
type: t.type,
|
|
1713
1764
|
tabId: n,
|
|
@@ -1718,7 +1769,7 @@ function qt(e) {
|
|
|
1718
1769
|
};
|
|
1719
1770
|
}
|
|
1720
1771
|
case "retry-scheduled": {
|
|
1721
|
-
let e =
|
|
1772
|
+
let e = Qt(t);
|
|
1722
1773
|
return e ? {
|
|
1723
1774
|
type: t.type,
|
|
1724
1775
|
tabId: n,
|
|
@@ -1739,10 +1790,10 @@ function qt(e) {
|
|
|
1739
1790
|
case "signed-out": return {
|
|
1740
1791
|
type: t.type,
|
|
1741
1792
|
tabId: n,
|
|
1742
|
-
|
|
1793
|
+
...$t(t)
|
|
1743
1794
|
};
|
|
1744
1795
|
case "rate-limited": {
|
|
1745
|
-
let e =
|
|
1796
|
+
let e = Jt(t.until);
|
|
1746
1797
|
return e === void 0 ? null : {
|
|
1747
1798
|
type: t.type,
|
|
1748
1799
|
tabId: n,
|
|
@@ -1750,7 +1801,7 @@ function qt(e) {
|
|
|
1750
1801
|
};
|
|
1751
1802
|
}
|
|
1752
1803
|
case "refresh-failed": {
|
|
1753
|
-
let e =
|
|
1804
|
+
let e = K(t.from);
|
|
1754
1805
|
return e ? {
|
|
1755
1806
|
type: t.type,
|
|
1756
1807
|
tabId: n,
|
|
@@ -1761,22 +1812,22 @@ function qt(e) {
|
|
|
1761
1812
|
default: return null;
|
|
1762
1813
|
}
|
|
1763
1814
|
}
|
|
1764
|
-
function
|
|
1815
|
+
function tn(e, t) {
|
|
1765
1816
|
let n = {
|
|
1766
1817
|
v: 1,
|
|
1767
1818
|
tabId: e
|
|
1768
1819
|
};
|
|
1769
1820
|
if (t.type === "retry-scheduled") {
|
|
1770
1821
|
let { retry: e, ...r } = t;
|
|
1771
|
-
return
|
|
1822
|
+
return Xt(n, {
|
|
1772
1823
|
...r,
|
|
1773
1824
|
...e
|
|
1774
1825
|
});
|
|
1775
1826
|
}
|
|
1776
|
-
return
|
|
1827
|
+
return Xt(n, { ...t });
|
|
1777
1828
|
}
|
|
1778
1829
|
// lib/refresh/resolve.ts
|
|
1779
|
-
var
|
|
1830
|
+
var nn = "[passflow] navigator.locks or BroadcastChannel is unavailable (they need a secure context); each tab refreshes on its own, with the save checks only", rn = {
|
|
1780
1831
|
now: () => Date.now(),
|
|
1781
1832
|
random: () => Math.random(),
|
|
1782
1833
|
setTimeout: (e, t) => {
|
|
@@ -1784,28 +1835,28 @@ var Yt = "[passflow] navigator.locks or BroadcastChannel is unavailable (they ne
|
|
|
1784
1835
|
return n.unref?.(), () => clearTimeout(n);
|
|
1785
1836
|
}
|
|
1786
1837
|
};
|
|
1787
|
-
function
|
|
1838
|
+
function an() {
|
|
1788
1839
|
let e = globalThis.crypto;
|
|
1789
1840
|
return typeof e?.randomUUID == "function" ? e.randomUUID() : `tab-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
1790
1841
|
}
|
|
1791
|
-
function
|
|
1842
|
+
function on(e) {
|
|
1792
1843
|
return e ? {
|
|
1793
1844
|
now: () => e.now(),
|
|
1794
1845
|
setTimeout: (t, n) => e.setTimeout(t, n),
|
|
1795
|
-
random: e.random ? () => e.random?.() ?? Math.random() :
|
|
1796
|
-
} :
|
|
1846
|
+
random: e.random ? () => e.random?.() ?? Math.random() : rn.random
|
|
1847
|
+
} : rn;
|
|
1797
1848
|
}
|
|
1798
|
-
function
|
|
1849
|
+
function sn(e) {
|
|
1799
1850
|
return typeof window < "u" && typeof document < "u" && e.getDeviceType() === "web";
|
|
1800
1851
|
}
|
|
1801
|
-
function
|
|
1852
|
+
function cn(e) {
|
|
1802
1853
|
try {
|
|
1803
1854
|
return e.storageSharedAcrossTabs === !0;
|
|
1804
1855
|
} catch {
|
|
1805
1856
|
return !1;
|
|
1806
1857
|
}
|
|
1807
1858
|
}
|
|
1808
|
-
function
|
|
1859
|
+
function ln() {
|
|
1809
1860
|
try {
|
|
1810
1861
|
let e = globalThis.navigator?.locks;
|
|
1811
1862
|
return e && typeof e.request == "function" ? e : void 0;
|
|
@@ -1813,7 +1864,7 @@ function tn() {
|
|
|
1813
1864
|
return;
|
|
1814
1865
|
}
|
|
1815
1866
|
}
|
|
1816
|
-
function
|
|
1867
|
+
function un(e) {
|
|
1817
1868
|
return (t) => {
|
|
1818
1869
|
let n = (n) => {
|
|
1819
1870
|
let r = n.key;
|
|
@@ -1822,20 +1873,20 @@ function nn(e) {
|
|
|
1822
1873
|
return window.addEventListener("storage", n), () => window.removeEventListener("storage", n);
|
|
1823
1874
|
};
|
|
1824
1875
|
}
|
|
1825
|
-
function
|
|
1876
|
+
function dn(e) {
|
|
1826
1877
|
return {
|
|
1827
1878
|
transports: null,
|
|
1828
|
-
names:
|
|
1829
|
-
clock:
|
|
1879
|
+
names: qt(e),
|
|
1880
|
+
clock: rn,
|
|
1830
1881
|
warnOnFirstCycle: !1
|
|
1831
1882
|
};
|
|
1832
1883
|
}
|
|
1833
|
-
function
|
|
1834
|
-
let i =
|
|
1884
|
+
function fn(e, t, n, r) {
|
|
1885
|
+
let i = qt(n), a = sn(t), o = a ? un(r.tokenKeys) : void 0, s = (e) => {
|
|
1835
1886
|
let t = {
|
|
1836
1887
|
transports: null,
|
|
1837
1888
|
names: i,
|
|
1838
|
-
clock:
|
|
1889
|
+
clock: rn,
|
|
1839
1890
|
warnOnFirstCycle: e
|
|
1840
1891
|
};
|
|
1841
1892
|
return o && (t.onStorageChange = o), t;
|
|
@@ -1845,16 +1896,16 @@ function an(e, t, n, r) {
|
|
|
1845
1896
|
transports: {
|
|
1846
1897
|
locks: e.locks,
|
|
1847
1898
|
channel: e.channel,
|
|
1848
|
-
tabId: e.tabId ??
|
|
1899
|
+
tabId: e.tabId ?? an()
|
|
1849
1900
|
},
|
|
1850
1901
|
names: i,
|
|
1851
|
-
clock:
|
|
1902
|
+
clock: on(e.clock),
|
|
1852
1903
|
warnOnFirstCycle: !1
|
|
1853
1904
|
};
|
|
1854
1905
|
return e.onStorageChange && (t.onStorageChange = e.onStorageChange), t;
|
|
1855
1906
|
}
|
|
1856
|
-
if (e === "none" || !a || !
|
|
1857
|
-
let c =
|
|
1907
|
+
if (e === "none" || !a || !cn(t)) return s(!1);
|
|
1908
|
+
let c = ln();
|
|
1858
1909
|
if (!c || typeof BroadcastChannel != "function") return s(!0);
|
|
1859
1910
|
let l;
|
|
1860
1911
|
try {
|
|
@@ -1866,36 +1917,36 @@ function an(e, t, n, r) {
|
|
|
1866
1917
|
transports: {
|
|
1867
1918
|
locks: c,
|
|
1868
1919
|
channel: l,
|
|
1869
|
-
tabId:
|
|
1920
|
+
tabId: an()
|
|
1870
1921
|
},
|
|
1871
1922
|
names: i,
|
|
1872
|
-
clock:
|
|
1923
|
+
clock: rn,
|
|
1873
1924
|
warnOnFirstCycle: !1
|
|
1874
1925
|
};
|
|
1875
1926
|
return o && (u.onStorageChange = o), u;
|
|
1876
1927
|
}
|
|
1877
1928
|
// lib/pkce.ts
|
|
1878
|
-
var
|
|
1929
|
+
var pn = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", mn = 32, hn = (e) => {
|
|
1879
1930
|
let t = "";
|
|
1880
1931
|
for (let n = 0; n < e.length; n += 3) {
|
|
1881
1932
|
let r = e[n], i = e[n + 1], a = e[n + 2];
|
|
1882
|
-
t +=
|
|
1933
|
+
t += pn.charAt(r >> 2), t += pn.charAt((r & 3) << 4 | (i ?? 0) >> 4), i !== void 0 && (t += pn.charAt((i & 15) << 2 | (a ?? 0) >> 6)), a !== void 0 && (t += pn.charAt(a & 63));
|
|
1883
1934
|
}
|
|
1884
1935
|
return t;
|
|
1885
|
-
},
|
|
1936
|
+
}, gn = () => {
|
|
1886
1937
|
let e = globalThis.crypto;
|
|
1887
1938
|
if (!e?.subtle) throw Error("PKCE needs the Web Crypto API, which is available only in a secure context (https or localhost)");
|
|
1888
1939
|
return e;
|
|
1889
|
-
},
|
|
1890
|
-
let t = await
|
|
1891
|
-
return
|
|
1892
|
-
},
|
|
1893
|
-
let e =
|
|
1940
|
+
}, _n = async (e) => {
|
|
1941
|
+
let t = await gn().subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
1942
|
+
return hn(new Uint8Array(t));
|
|
1943
|
+
}, vn = async () => {
|
|
1944
|
+
let e = hn(gn().getRandomValues(new Uint8Array(mn)));
|
|
1894
1945
|
return {
|
|
1895
1946
|
verifier: e,
|
|
1896
|
-
challenge: await
|
|
1947
|
+
challenge: await _n(e)
|
|
1897
1948
|
};
|
|
1898
|
-
},
|
|
1949
|
+
}, yn = class {
|
|
1899
1950
|
error(e, ...t) {
|
|
1900
1951
|
console.error(e, ...t);
|
|
1901
1952
|
}
|
|
@@ -1909,10 +1960,10 @@ var on = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", sn
|
|
|
1909
1960
|
console.debug(e, ...t);
|
|
1910
1961
|
}
|
|
1911
1962
|
};
|
|
1912
|
-
function
|
|
1913
|
-
return new
|
|
1963
|
+
function bn() {
|
|
1964
|
+
return new yn();
|
|
1914
1965
|
}
|
|
1915
|
-
var
|
|
1966
|
+
var xn = Object.freeze([
|
|
1916
1967
|
"error.token.invalid.error",
|
|
1917
1968
|
"error.api.token.parse.error",
|
|
1918
1969
|
"error.api.user.blocked",
|
|
@@ -1920,25 +1971,25 @@ var mn = Object.freeze([
|
|
|
1920
1971
|
"error.validation.token.invalid.subject",
|
|
1921
1972
|
"error.not.found"
|
|
1922
1973
|
]);
|
|
1923
|
-
function
|
|
1974
|
+
function Sn(e) {
|
|
1924
1975
|
if (typeof e != "object" || !e) return;
|
|
1925
1976
|
let t = e;
|
|
1926
1977
|
return typeof t.get == "function" ? t.get("retry-after") : t["retry-after"] ?? t["Retry-After"];
|
|
1927
1978
|
}
|
|
1928
|
-
function
|
|
1929
|
-
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(
|
|
1979
|
+
function Cn(e, t) {
|
|
1980
|
+
if (typeof e == "number") return !Number.isFinite(e) || e < 0 ? void 0 : Math.min(zt, Math.floor(e) * 1e3);
|
|
1930
1981
|
if (typeof e != "string") return;
|
|
1931
1982
|
let n = e.trim();
|
|
1932
1983
|
if (n === "") return;
|
|
1933
|
-
if (/^\d+$/.test(n)) return Math.min(
|
|
1984
|
+
if (/^\d+$/.test(n)) return Math.min(zt, Number.parseInt(n, 10) * 1e3);
|
|
1934
1985
|
if (!/[a-z]/i.test(n)) return;
|
|
1935
1986
|
let r = Date.parse(n);
|
|
1936
|
-
if (!Number.isNaN(r)) return Math.min(
|
|
1987
|
+
if (!Number.isNaN(r)) return Math.min(zt, Math.max(0, r - t));
|
|
1937
1988
|
}
|
|
1938
|
-
function
|
|
1989
|
+
function wn(e) {
|
|
1939
1990
|
return typeof e == "number" && Number.isInteger(e) && e >= 100 && e <= 599 ? e : void 0;
|
|
1940
1991
|
}
|
|
1941
|
-
function
|
|
1992
|
+
function Tn(e) {
|
|
1942
1993
|
if (typeof e.id == "string" && e.id !== "") return e.id;
|
|
1943
1994
|
let t = e.response?.data;
|
|
1944
1995
|
if (typeof t != "object" || !t) return;
|
|
@@ -1947,14 +1998,14 @@ function vn(e) {
|
|
|
1947
1998
|
let r = n.id;
|
|
1948
1999
|
return typeof r == "string" && r !== "" ? r : void 0;
|
|
1949
2000
|
}
|
|
1950
|
-
function
|
|
2001
|
+
function En(e, t = Date.now()) {
|
|
1951
2002
|
if (typeof e != "object" || !e) return { kind: "transient" };
|
|
1952
|
-
let n = e, r =
|
|
2003
|
+
let n = e, r = Tn(n), i = wn(n.response?.status) ?? wn(n.status), a = {};
|
|
1953
2004
|
if (i !== void 0 && (a.status = i), r !== void 0 && (a.id = r), r === "error.token.blocked") return {
|
|
1954
2005
|
kind: "blocked",
|
|
1955
2006
|
...a
|
|
1956
2007
|
};
|
|
1957
|
-
if (r !== void 0 &&
|
|
2008
|
+
if (r !== void 0 && xn.includes(r) || i !== void 0 && i >= 400 && i <= 499 && i !== 429) return {
|
|
1958
2009
|
kind: "auth",
|
|
1959
2010
|
...a
|
|
1960
2011
|
};
|
|
@@ -1962,7 +2013,7 @@ function yn(e, t = Date.now()) {
|
|
|
1962
2013
|
kind: "transient",
|
|
1963
2014
|
...a
|
|
1964
2015
|
};
|
|
1965
|
-
let o =
|
|
2016
|
+
let o = Cn(n.retryAfter ?? Sn(n.response?.headers), t);
|
|
1966
2017
|
return o === void 0 ? {
|
|
1967
2018
|
kind: "transient",
|
|
1968
2019
|
...a
|
|
@@ -1972,19 +2023,19 @@ function yn(e, t = Date.now()) {
|
|
|
1972
2023
|
retryAfterMs: o
|
|
1973
2024
|
};
|
|
1974
2025
|
}
|
|
1975
|
-
function
|
|
1976
|
-
let r =
|
|
1977
|
-
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0),
|
|
2026
|
+
function Dn(e, t, n) {
|
|
2027
|
+
let r = Lt.length, i = Lt[(Number.isFinite(e) ? Math.min(Math.max(Math.floor(e), 1), r) : 1) - 1] ?? Lt[r - 1] ?? 6e4, a = Number.isFinite(t) ? Math.min(Math.max(t, 0), .999) : 0, o = i + Math.floor(i * Rt * a);
|
|
2028
|
+
return Math.max(o, n !== void 0 && Number.isFinite(n) ? Math.min(Math.max(n, 0), zt) : 0);
|
|
1978
2029
|
}
|
|
1979
2030
|
// lib/refresh/coordinator.ts
|
|
1980
|
-
var
|
|
2031
|
+
var On = {
|
|
1981
2032
|
onGranted: () => !1,
|
|
1982
2033
|
onLockLost: () => void 0,
|
|
1983
2034
|
onMessage: () => void 0
|
|
1984
2035
|
};
|
|
1985
|
-
function
|
|
1986
|
-
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o =
|
|
1987
|
-
g || n.postMessage(
|
|
2036
|
+
function kn(e) {
|
|
2037
|
+
let { locks: t, channel: n, tabId: r, names: i, clock: a } = e, o = On, s = null, c = null, l = null, u = null, d = null, f = null, p = 0, m, h = !1, g = !1, _ = (e) => {
|
|
2038
|
+
g || n.postMessage(tn(r, e));
|
|
1988
2039
|
}, v = () => s !== null && c === null, y = () => {
|
|
1989
2040
|
f?.(), f = null;
|
|
1990
2041
|
}, b = (e) => {
|
|
@@ -1999,7 +2050,7 @@ function Sn(e) {
|
|
|
1999
2050
|
type: "still-refreshing",
|
|
2000
2051
|
retry: m
|
|
2001
2052
|
} : { type: "still-refreshing" }), S());
|
|
2002
|
-
},
|
|
2053
|
+
}, Bt);
|
|
2003
2054
|
}, C = () => {
|
|
2004
2055
|
y(), x(), u?.(), u = null;
|
|
2005
2056
|
let e = s;
|
|
@@ -2040,29 +2091,29 @@ function Sn(e) {
|
|
|
2040
2091
|
let e = s;
|
|
2041
2092
|
t.request(i.takeoverLock, { ifAvailable: !0 }, (t) => {
|
|
2042
2093
|
if (s === e && v()) {
|
|
2043
|
-
if (t === null) b(a.now() +
|
|
2094
|
+
if (t === null) b(a.now() + G);
|
|
2044
2095
|
else return _({ type: "takeover" }), new Promise((t) => {
|
|
2045
2096
|
u = t, e && (e.dead = !0, e.abort.abort()), D(!0);
|
|
2046
2097
|
});
|
|
2047
2098
|
}
|
|
2048
2099
|
}).catch(() => {
|
|
2049
|
-
v() && b(a.now() +
|
|
2100
|
+
v() && b(a.now() + G);
|
|
2050
2101
|
});
|
|
2051
2102
|
}, ee = (e) => {
|
|
2052
2103
|
if (g) return;
|
|
2053
|
-
let t =
|
|
2104
|
+
let t = en(e.data);
|
|
2054
2105
|
if (t && t.tabId !== r) {
|
|
2055
2106
|
switch (t.type) {
|
|
2056
2107
|
case "still-refreshing":
|
|
2057
|
-
h = !0, v() && (b(a.now() +
|
|
2108
|
+
h = !0, v() && (b(a.now() + G), t.retry && b(t.retry.nextAt + G));
|
|
2058
2109
|
break;
|
|
2059
2110
|
case "takeover":
|
|
2060
|
-
h = !0, v() && b(a.now() +
|
|
2111
|
+
h = !0, v() && b(a.now() + G);
|
|
2061
2112
|
break;
|
|
2062
2113
|
case "retry-scheduled":
|
|
2063
|
-
h = !0, v() && b(Math.max(a.now(), t.retry.nextAt) +
|
|
2114
|
+
h = !0, v() && b(Math.max(a.now(), t.retry.nextAt) + G);
|
|
2064
2115
|
break;
|
|
2065
|
-
case "rate-limited": v() && b(t.until +
|
|
2116
|
+
case "rate-limited": v() && b(t.until + G);
|
|
2066
2117
|
}
|
|
2067
2118
|
o.onMessage(t);
|
|
2068
2119
|
}
|
|
@@ -2080,7 +2131,7 @@ function Sn(e) {
|
|
|
2080
2131
|
o = e;
|
|
2081
2132
|
},
|
|
2082
2133
|
request: (e) => {
|
|
2083
|
-
g || s || (p = 0, b(Math.max(a.now() +
|
|
2134
|
+
g || s || (p = 0, b(Math.max(a.now() + G, e ?? 0)), D(!1));
|
|
2084
2135
|
},
|
|
2085
2136
|
release: C,
|
|
2086
2137
|
post: _,
|
|
@@ -2093,8 +2144,8 @@ function Sn(e) {
|
|
|
2093
2144
|
}
|
|
2094
2145
|
};
|
|
2095
2146
|
}
|
|
2096
|
-
function
|
|
2097
|
-
let t =
|
|
2147
|
+
function An(e = "local") {
|
|
2148
|
+
let t = On, n = !1, r = !1, i = 0, a = !1, o = () => {
|
|
2098
2149
|
n = !1, r = !1, i += 1;
|
|
2099
2150
|
};
|
|
2100
2151
|
return {
|
|
@@ -2134,7 +2185,7 @@ function Cn(e = "local") {
|
|
|
2134
2185
|
};
|
|
2135
2186
|
}
|
|
2136
2187
|
// lib/refresh/errors.ts
|
|
2137
|
-
var
|
|
2188
|
+
var q = {
|
|
2138
2189
|
unavailable: "error.refresh.unavailable",
|
|
2139
2190
|
authRetry: "error.refresh.auth_retry",
|
|
2140
2191
|
sessionEnded: "error.refresh.session_ended",
|
|
@@ -2142,7 +2193,7 @@ var K = {
|
|
|
2142
2193
|
successorTimeout: "error.refresh.successor_timeout",
|
|
2143
2194
|
identityChanged: "error.refresh.identity_changed",
|
|
2144
2195
|
disposed: "error.refresh.disposed"
|
|
2145
|
-
},
|
|
2196
|
+
}, jn = {
|
|
2146
2197
|
"error.refresh.unavailable": 503,
|
|
2147
2198
|
"error.refresh.auth_retry": 401,
|
|
2148
2199
|
"error.refresh.session_ended": 401,
|
|
@@ -2150,7 +2201,7 @@ var K = {
|
|
|
2150
2201
|
"error.refresh.successor_timeout": 401,
|
|
2151
2202
|
"error.refresh.identity_changed": 401,
|
|
2152
2203
|
"error.refresh.disposed": 499
|
|
2153
|
-
},
|
|
2204
|
+
}, Mn = {
|
|
2154
2205
|
"error.refresh.unavailable": "Token refresh is unavailable; a retry is scheduled",
|
|
2155
2206
|
"error.refresh.auth_retry": "Token refresh was refused; a retry is scheduled",
|
|
2156
2207
|
"error.refresh.session_ended": "The session has ended",
|
|
@@ -2158,23 +2209,23 @@ var K = {
|
|
|
2158
2209
|
"error.refresh.successor_timeout": "The refresh token was already used and no successor arrived",
|
|
2159
2210
|
"error.refresh.identity_changed": "Storage holds another user's tokens",
|
|
2160
2211
|
"error.refresh.disposed": "The Passflow instance was disposed"
|
|
2161
|
-
},
|
|
2212
|
+
}, J = class extends B {
|
|
2162
2213
|
constructor(e, t = {}) {
|
|
2163
2214
|
super({
|
|
2164
2215
|
id: e,
|
|
2165
|
-
message: t.message ??
|
|
2166
|
-
status:
|
|
2216
|
+
message: t.message ?? Mn[e],
|
|
2217
|
+
status: jn[e],
|
|
2167
2218
|
location: "/auth/refresh",
|
|
2168
2219
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
2169
2220
|
}), this.name = "PassflowRefreshError", t.nextRetryAt !== void 0 && (this.nextRetryAt = t.nextRetryAt), t.cause !== void 0 && (this.cause = t.cause);
|
|
2170
2221
|
}
|
|
2171
|
-
},
|
|
2222
|
+
}, Nn = class extends Error {
|
|
2172
2223
|
constructor(e, t) {
|
|
2173
2224
|
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;
|
|
2174
2225
|
}
|
|
2175
2226
|
};
|
|
2176
2227
|
// lib/refresh/lineage.ts
|
|
2177
|
-
function
|
|
2228
|
+
function Pn(e) {
|
|
2178
2229
|
if (!e) return;
|
|
2179
2230
|
let t = 3735928559, n = 1103547991;
|
|
2180
2231
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -2183,24 +2234,24 @@ function J(e) {
|
|
|
2183
2234
|
}
|
|
2184
2235
|
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);
|
|
2185
2236
|
}
|
|
2186
|
-
function
|
|
2237
|
+
function Fn(e) {
|
|
2187
2238
|
return typeof e == "string" && e !== "" ? e : void 0;
|
|
2188
2239
|
}
|
|
2189
2240
|
function Y(e) {
|
|
2190
|
-
let t =
|
|
2241
|
+
let t = Pn(e);
|
|
2191
2242
|
if (!e || !t) return;
|
|
2192
2243
|
let n = {};
|
|
2193
2244
|
try {
|
|
2194
2245
|
let t = A(e);
|
|
2195
2246
|
typeof t == "object" && t && (n = t);
|
|
2196
2247
|
} catch {}
|
|
2197
|
-
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a =
|
|
2248
|
+
let r = typeof n.iat == "number" && Number.isFinite(n.iat) ? n.iat : void 0, i = { fp: t }, a = Fn(n.sub), o = Fn(n.sid);
|
|
2198
2249
|
return a !== void 0 && (i.sub = a), o !== void 0 && (i.sid = o), r !== void 0 && (i.iat = r), i;
|
|
2199
2250
|
}
|
|
2200
|
-
var
|
|
2201
|
-
function
|
|
2251
|
+
var In = "[passflow] A refresh token carries no iat claim: it is never taken over an ordered one, and cross-tab adoption falls back to fingerprints";
|
|
2252
|
+
function Ln(e = (e) => bn().warn(e)) {
|
|
2202
2253
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1, i = [], a = !1, o = () => {
|
|
2203
|
-
a || (a = !0, e(
|
|
2254
|
+
a || (a = !0, e(In));
|
|
2204
2255
|
}, s = (e, t) => e.has(t) ? !0 : e.size >= 32 ? !1 : (e.add(t), !0), c = (e) => {
|
|
2205
2256
|
if (!e) return;
|
|
2206
2257
|
if (e.iat === void 0) {
|
|
@@ -2241,16 +2292,16 @@ function kn(e = (e) => pn().warn(e)) {
|
|
|
2241
2292
|
};
|
|
2242
2293
|
}
|
|
2243
2294
|
// lib/refresh/fence.ts
|
|
2244
|
-
var
|
|
2295
|
+
var Rn = class extends Error {
|
|
2245
2296
|
constructor(e) {
|
|
2246
2297
|
super(e === "emptied" ? "The shared token storage was emptied" : "The stored refresh token belongs to an ended session"), this.name = "SessionEnded", this.cause = e;
|
|
2247
2298
|
}
|
|
2248
|
-
},
|
|
2299
|
+
}, zn = class extends Error {
|
|
2249
2300
|
constructor() {
|
|
2250
2301
|
super("The shared token storage holds another user's tokens"), this.name = "IdentityChanged";
|
|
2251
2302
|
}
|
|
2252
2303
|
};
|
|
2253
|
-
function
|
|
2304
|
+
function Bn(e) {
|
|
2254
2305
|
if (e) try {
|
|
2255
2306
|
let t = A(e).sub;
|
|
2256
2307
|
return typeof t == "string" && t !== "" ? t : void 0;
|
|
@@ -2259,20 +2310,20 @@ function Mn(e) {
|
|
|
2259
2310
|
}
|
|
2260
2311
|
}
|
|
2261
2312
|
function X(e) {
|
|
2262
|
-
return
|
|
2313
|
+
return Bn(e?.access_token) ?? Bn(e?.refresh_token) ?? Bn(e?.id_token);
|
|
2263
2314
|
}
|
|
2264
|
-
function
|
|
2315
|
+
function Vn(e, t) {
|
|
2265
2316
|
return !t || e.iat === void 0 || t.iat === void 0 ? !1 : e.sid === t.sid && e.iat < t.iat;
|
|
2266
2317
|
}
|
|
2267
|
-
function
|
|
2318
|
+
function Hn(e) {
|
|
2268
2319
|
return typeof e == "object" && !!e;
|
|
2269
2320
|
}
|
|
2270
|
-
function
|
|
2271
|
-
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) =>
|
|
2321
|
+
function Un(e) {
|
|
2322
|
+
let { storage: t, cache: n, schedule: r } = e, i = e.identity ?? (() => void 0), a = e.warn ?? ((e) => bn().warn(e)), o = e.lineage ?? Ln(a), s = e.onSessionLost, c, l = 0, u = [], d = [], f = 0, p, m = 0, h, g, _, v, y = () => {
|
|
2272
2323
|
let e = t.getTokens(), n = e?.refresh_token;
|
|
2273
2324
|
if (!n) return p = l, e;
|
|
2274
2325
|
p !== void 0 && (f = Math.max(f, p, m), p = void 0);
|
|
2275
|
-
let r =
|
|
2326
|
+
let r = Pn(n) ?? "";
|
|
2276
2327
|
return r !== c?.fp && (c = {
|
|
2277
2328
|
fp: r,
|
|
2278
2329
|
seq: l
|
|
@@ -2305,7 +2356,7 @@ function Fn(e) {
|
|
|
2305
2356
|
let t = E();
|
|
2306
2357
|
t === "wait" && e && (t = "end"), t !== "wait" && D(), t === "wait" && !h && (h = r(() => {
|
|
2307
2358
|
h = void 0, y()?.refresh_token ? N() : O(!0) === "end" && s?.("emptied");
|
|
2308
|
-
},
|
|
2359
|
+
}, Ut));
|
|
2309
2360
|
let n = t === "keep" ? T() : void 0;
|
|
2310
2361
|
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;
|
|
2311
2362
|
}, ee = (e) => e.held !== void 0 && b()?.fp === e.held.cachedFp, k = (e) => {
|
|
@@ -2318,7 +2369,7 @@ function Fn(e) {
|
|
|
2318
2369
|
return e.iat !== void 0 && t?.iat !== void 0 && t.sid === e.sid;
|
|
2319
2370
|
}, j = (e, t) => o.isForward(e, t) ? !0 : !!e && !!t && e.iat !== void 0 && e.sid !== t.sid && o.isRetired(t) && !o.isRetired(e) && !o.isEnded(e), M = (e) => {
|
|
2320
2371
|
let t = b();
|
|
2321
|
-
t && t.fp !==
|
|
2372
|
+
t && t.fp !== Pn(e.refresh_token) && o.retire(t), n.setTokensCache(e);
|
|
2322
2373
|
}, te = (e) => {
|
|
2323
2374
|
let t = y(), n = t?.refresh_token;
|
|
2324
2375
|
if (n === e.refreshToken) return null;
|
|
@@ -2329,7 +2380,7 @@ function Fn(e) {
|
|
|
2329
2380
|
kind: "superseded",
|
|
2330
2381
|
adopted: !1
|
|
2331
2382
|
};
|
|
2332
|
-
let r =
|
|
2383
|
+
let r = Bn(t.access_token) ?? Bn(n);
|
|
2333
2384
|
if (e.sub && r && e.sub !== r) return {
|
|
2334
2385
|
kind: "identity-changed",
|
|
2335
2386
|
saved: !1
|
|
@@ -2369,22 +2420,22 @@ function Fn(e) {
|
|
|
2369
2420
|
}, re = !!s || !!e.onStoredSessionSeen, ie = re && e.onStorageChange ? e.onStorageChange(N) : void 0, ae = re && e.onWake ? e.onWake(N) : void 0, P = () => {
|
|
2370
2421
|
let e = y();
|
|
2371
2422
|
if (!e?.refresh_token) {
|
|
2372
|
-
if (O() === "end") throw new
|
|
2423
|
+
if (O() === "end") throw new Rn("emptied");
|
|
2373
2424
|
return "held";
|
|
2374
2425
|
}
|
|
2375
2426
|
let t = n.getTokens();
|
|
2376
2427
|
if (e.refresh_token === t?.refresh_token) return "send";
|
|
2377
2428
|
let r = i() ?? X(t), a = X(e);
|
|
2378
|
-
if (r && a && r !== a) throw new
|
|
2429
|
+
if (r && a && r !== a) throw new zn();
|
|
2379
2430
|
let s = Y(e.refresh_token);
|
|
2380
2431
|
if (o.isEnded(s)) {
|
|
2381
2432
|
if (s && C(s)) return "held";
|
|
2382
|
-
throw new
|
|
2433
|
+
throw new Rn("ended");
|
|
2383
2434
|
}
|
|
2384
2435
|
let c = Y(t?.refresh_token);
|
|
2385
2436
|
return j(s, c) ? (M(e), "adopted") : s && c && s.sid !== c.sid ? "send" : s && k(s) ? "held" : "send";
|
|
2386
2437
|
}, oe = (e) => {
|
|
2387
|
-
let t = i(), r =
|
|
2438
|
+
let t = i(), r = Bn(e);
|
|
2388
2439
|
if (t && r && t !== r) return { kind: "identity-changed" };
|
|
2389
2440
|
let a = Y(e) ?? { fp: e };
|
|
2390
2441
|
if (o.isEnded(a)) return C(a) ? { kind: "superseded" } : { kind: "ended" };
|
|
@@ -2392,7 +2443,7 @@ function Fn(e) {
|
|
|
2392
2443
|
let s = {
|
|
2393
2444
|
refreshToken: e,
|
|
2394
2445
|
order: a
|
|
2395
|
-
}, c = t ?? r ??
|
|
2446
|
+
}, c = t ?? r ?? Bn(n.getTokens()?.access_token);
|
|
2396
2447
|
return c !== void 0 && (s.sub = c), v && v.fp === a.fp && (s.held = { cachedFp: v.cachedFp }), {
|
|
2397
2448
|
kind: "send",
|
|
2398
2449
|
sent: s
|
|
@@ -2401,7 +2452,7 @@ function Fn(e) {
|
|
|
2401
2452
|
if (o.isEnded(e.order)) return ne(e.order);
|
|
2402
2453
|
let i = te(e);
|
|
2403
2454
|
if (i) return i;
|
|
2404
|
-
if (!ee(e) && A(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${
|
|
2455
|
+
if (!ee(e) && A(e.order)) return o.retire(e.order), a(`[passflow] Refused to save a late refresh result: it rotated ${e.order.fp} into ${Pn(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.`), {
|
|
2405
2456
|
kind: "superseded",
|
|
2406
2457
|
adopted: !1
|
|
2407
2458
|
};
|
|
@@ -2411,7 +2462,7 @@ function Fn(e) {
|
|
|
2411
2462
|
saved: !0
|
|
2412
2463
|
};
|
|
2413
2464
|
let c = Y(r.refresh_token);
|
|
2414
|
-
return c && (
|
|
2465
|
+
return c && (Vn(c, e.order) || Vn(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.`), {
|
|
2415
2466
|
kind: "superseded",
|
|
2416
2467
|
adopted: !1
|
|
2417
2468
|
}) : (o.retire(e.order), t.saveTokens(r), n.setTokensCache(r), { kind: "saved" });
|
|
@@ -2423,7 +2474,7 @@ function Fn(e) {
|
|
|
2423
2474
|
kind: "superseded",
|
|
2424
2475
|
adopted: !1
|
|
2425
2476
|
};
|
|
2426
|
-
let r =
|
|
2477
|
+
let r = En(t), i = r.kind === "blocked" || r.kind === "auth";
|
|
2427
2478
|
return ee(e) && i ? (o.retire(e.order), _ = e.order, {
|
|
2428
2479
|
kind: "own",
|
|
2429
2480
|
failure: r,
|
|
@@ -2434,11 +2485,11 @@ function Fn(e) {
|
|
|
2434
2485
|
heldRefused: !1
|
|
2435
2486
|
});
|
|
2436
2487
|
}, I = (e) => {
|
|
2437
|
-
if (!
|
|
2488
|
+
if (!Hn(e)) return !1;
|
|
2438
2489
|
let { from: t, fromIat: r, fromSid: a, to: c, tokens: l } = e;
|
|
2439
|
-
if (typeof t != "string" || typeof c != "string" || !
|
|
2490
|
+
if (typeof t != "string" || typeof c != "string" || !Hn(l)) return !1;
|
|
2440
2491
|
let u = l;
|
|
2441
|
-
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" ||
|
|
2492
|
+
if (typeof u.access_token != "string" || u.access_token === "" || typeof u.refresh_token != "string" || u.refresh_token === "" || Pn(u.refresh_token) !== c) return !1;
|
|
2442
2493
|
let d = y();
|
|
2443
2494
|
if (!d?.refresh_token) return !1;
|
|
2444
2495
|
let f = n.getTokens(), p = i() ?? X(f), m = X(u);
|
|
@@ -2455,7 +2506,7 @@ function Fn(e) {
|
|
|
2455
2506
|
}
|
|
2456
2507
|
return !0;
|
|
2457
2508
|
};
|
|
2458
|
-
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t &&
|
|
2509
|
+
return g?.fp === c ? _() : !o.isForward(h, g) || g?.fp !== t && Pn(d.refresh_token) !== c ? !1 : (M({ ...u }), _());
|
|
2459
2510
|
}, L = (e) => {
|
|
2460
2511
|
if (!e || !_) return !1;
|
|
2461
2512
|
let t = _;
|
|
@@ -2521,7 +2572,7 @@ function Fn(e) {
|
|
|
2521
2572
|
};
|
|
2522
2573
|
}
|
|
2523
2574
|
// lib/refresh/controller.ts
|
|
2524
|
-
function
|
|
2575
|
+
function Wn() {
|
|
2525
2576
|
let e, t, n = new Promise((n, r) => {
|
|
2526
2577
|
e = n, t = r;
|
|
2527
2578
|
});
|
|
@@ -2531,53 +2582,53 @@ function In() {
|
|
|
2531
2582
|
reject: t
|
|
2532
2583
|
};
|
|
2533
2584
|
}
|
|
2534
|
-
var
|
|
2535
|
-
strikes:
|
|
2536
|
-
"session-ended":
|
|
2537
|
-
"stored-ended":
|
|
2538
|
-
"signed-out":
|
|
2539
|
-
emptied:
|
|
2540
|
-
"signed-out-here":
|
|
2541
|
-
"successor-timeout":
|
|
2542
|
-
"identity-changed":
|
|
2543
|
-
disposed:
|
|
2585
|
+
var Gn = {
|
|
2586
|
+
strikes: q.sessionEnded,
|
|
2587
|
+
"session-ended": q.sessionEnded,
|
|
2588
|
+
"stored-ended": q.sessionEnded,
|
|
2589
|
+
"signed-out": q.signedOut,
|
|
2590
|
+
emptied: q.signedOut,
|
|
2591
|
+
"signed-out-here": q.signedOut,
|
|
2592
|
+
"successor-timeout": q.successorTimeout,
|
|
2593
|
+
"identity-changed": q.identityChanged,
|
|
2594
|
+
disposed: q.disposed
|
|
2544
2595
|
};
|
|
2545
|
-
function
|
|
2596
|
+
function Kn(e) {
|
|
2546
2597
|
throw Error(`Unexpected refresh state: ${JSON.stringify(e)}`);
|
|
2547
2598
|
}
|
|
2548
|
-
function
|
|
2599
|
+
function qn(e) {
|
|
2549
2600
|
if (e === void 0 || !Number.isFinite(e)) return 3;
|
|
2550
2601
|
let t = Math.floor(e);
|
|
2551
2602
|
return t >= 1 ? t : 3;
|
|
2552
2603
|
}
|
|
2553
|
-
function
|
|
2604
|
+
function Jn(e, t) {
|
|
2554
2605
|
return e instanceof Error && e.message ? e.message : t;
|
|
2555
2606
|
}
|
|
2556
|
-
function
|
|
2607
|
+
function Yn(e) {
|
|
2557
2608
|
if (typeof e != "object" || !e) return;
|
|
2558
2609
|
let t = e.id;
|
|
2559
2610
|
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
2560
2611
|
}
|
|
2561
|
-
function
|
|
2612
|
+
function Xn(e) {
|
|
2562
2613
|
let t = {};
|
|
2563
2614
|
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;
|
|
2564
2615
|
}
|
|
2565
|
-
function
|
|
2616
|
+
function Zn(e, t) {
|
|
2566
2617
|
let n = {};
|
|
2567
2618
|
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);
|
|
2568
2619
|
let r = t?.scopes ?? e.scopes;
|
|
2569
2620
|
return r && (n.scopes = r), n;
|
|
2570
2621
|
}
|
|
2571
|
-
function
|
|
2572
|
-
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ??
|
|
2622
|
+
function Qn(e) {
|
|
2623
|
+
let { emit: t, storage: n, cache: r, transport: i, coordination: a } = e, o = a.clock, s = e.logger ?? bn(), c = qn(e.strikes), l = a.transports ? kn({
|
|
2573
2624
|
locks: a.transports.locks,
|
|
2574
2625
|
channel: a.transports.channel,
|
|
2575
2626
|
tabId: a.transports.tabId,
|
|
2576
2627
|
names: a.names,
|
|
2577
2628
|
clock: o
|
|
2578
|
-
}) :
|
|
2629
|
+
}) : An(), u = { kind: "idle" }, d = 0, f = !1, p = !a.warnOnFirstCycle, m = 0, h = 0, g, _, v, y, b, x, S, C, w = !1, T = () => o.now(), E = () => i.mode(), D = () => Pn(r.getTokens()?.refresh_token), O = () => ({ ...r.getTokens() ?? {} }), ee = () => i.opaqueMarker ? i.opaqueMarker() : n.getTokens()?.id_token, k = () => (S === void 0 && (S = X(r.getTokens() ?? n.getTokens())), S), A = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Set(), M = (e) => () => {
|
|
2579
2630
|
for (let t of Array.from(e)) t();
|
|
2580
|
-
}, te = a.onStorageChange?.(M(A)), ne = e.platform?.onForeground(M(j)), N =
|
|
2631
|
+
}, te = a.onStorageChange?.(M(A)), ne = e.platform?.onForeground(M(j)), N = Un({
|
|
2581
2632
|
storage: n,
|
|
2582
2633
|
cache: r,
|
|
2583
2634
|
identity: k,
|
|
@@ -2592,13 +2643,13 @@ function Wn(e) {
|
|
|
2592
2643
|
}), re = (e) => ({
|
|
2593
2644
|
trigger: e,
|
|
2594
2645
|
startedAt: T(),
|
|
2595
|
-
plain:
|
|
2646
|
+
plain: Wn(),
|
|
2596
2647
|
fresh: []
|
|
2597
2648
|
}), ie = (e) => e.kind === "idle" || e.kind === "ended" ? void 0 : e.pending, ae = (e, t) => {
|
|
2598
2649
|
if (t === void 0) return e.plain.promise;
|
|
2599
2650
|
let n = {
|
|
2600
2651
|
callTime: t,
|
|
2601
|
-
deferred:
|
|
2652
|
+
deferred: Wn()
|
|
2602
2653
|
};
|
|
2603
2654
|
return e.fresh.push(n), n.deferred.promise;
|
|
2604
2655
|
}, P = (e, t, n = !1) => {
|
|
@@ -2617,11 +2668,11 @@ function Wn(e) {
|
|
|
2617
2668
|
}
|
|
2618
2669
|
}, F = (e, n, r, i) => {
|
|
2619
2670
|
let a = {
|
|
2620
|
-
message:
|
|
2671
|
+
message: Jn(r, "Token refresh failed"),
|
|
2621
2672
|
originalError: r,
|
|
2622
2673
|
operation: e,
|
|
2623
2674
|
source: n
|
|
2624
|
-
}, o =
|
|
2675
|
+
}, o = Yn(r);
|
|
2625
2676
|
o !== void 0 && (a.code = o), i && (a.refresh = i), t("error", a);
|
|
2626
2677
|
}, I = (e, t) => {
|
|
2627
2678
|
let n = {
|
|
@@ -2651,10 +2702,10 @@ function Wn(e) {
|
|
|
2651
2702
|
};
|
|
2652
2703
|
n !== void 0 && (i.nextRetryAt = n), t("refresh:failing", i);
|
|
2653
2704
|
}, le = (e, t) => {
|
|
2654
|
-
let n = r.getTokens(), i =
|
|
2705
|
+
let n = r.getTokens(), i = Pn(n?.refresh_token);
|
|
2655
2706
|
e.fp && i && l.post({
|
|
2656
2707
|
type: "tokens-refreshed",
|
|
2657
|
-
tokens:
|
|
2708
|
+
tokens: Xn(n),
|
|
2658
2709
|
from: e.fp,
|
|
2659
2710
|
...e.iat === void 0 ? {} : { fromIat: e.iat },
|
|
2660
2711
|
fromSid: e.sid ?? "",
|
|
@@ -2662,7 +2713,7 @@ function Wn(e) {
|
|
|
2662
2713
|
...t === void 0 ? {} : { sentAt: t }
|
|
2663
2714
|
});
|
|
2664
2715
|
}, ue = () => {
|
|
2665
|
-
p || (p = !0, s.warn(
|
|
2716
|
+
p || (p = !0, s.warn(nn));
|
|
2666
2717
|
}, de = (e) => {
|
|
2667
2718
|
(e.kind === "backoff" || e.kind === "blocked-wait") && e.cancel();
|
|
2668
2719
|
}, R = (e, n) => {
|
|
@@ -2676,7 +2727,7 @@ function Wn(e) {
|
|
|
2676
2727
|
}, e !== "disposed" && N.dropSession(), (e === "strikes" || e === "successor-timeout") && E() !== "json" && i.invalidate(), u = {
|
|
2677
2728
|
kind: "ended",
|
|
2678
2729
|
cause: e
|
|
2679
|
-
}, se(r, n ?? new
|
|
2730
|
+
}, se(r, n ?? new J(Gn[e])), e) {
|
|
2680
2731
|
case "strikes":
|
|
2681
2732
|
t("session:expired", {
|
|
2682
2733
|
reason: "refresh_failed",
|
|
@@ -2711,7 +2762,7 @@ function Wn(e) {
|
|
|
2711
2762
|
break;
|
|
2712
2763
|
case "signed-out-here":
|
|
2713
2764
|
case "disposed": break;
|
|
2714
|
-
default:
|
|
2765
|
+
default: Kn(e);
|
|
2715
2766
|
}
|
|
2716
2767
|
}, fe = () => {
|
|
2717
2768
|
if (u.kind !== "ended" || u.cause === "disposed" || f || E() !== "json") return;
|
|
@@ -2728,17 +2779,17 @@ function Wn(e) {
|
|
|
2728
2779
|
}, pe = (e) => {
|
|
2729
2780
|
u.kind === "ended" || f || E() === "json" && (R(e === "emptied" ? "emptied" : "identity-changed"), e === "identity-changed" && fe());
|
|
2730
2781
|
}, me = (e) => {
|
|
2731
|
-
e instanceof
|
|
2782
|
+
e instanceof zn ? (R("identity-changed"), fe()) : e instanceof Rn ? R(e.cause === "emptied" ? "emptied" : "stored-ended") : R("stored-ended", e);
|
|
2732
2783
|
}, he = () => {
|
|
2733
2784
|
u = { kind: "idle" }, w || l.release();
|
|
2734
|
-
}, ge = (e) => !e.from || E() !== "json" || e.from === D() || e.from ===
|
|
2785
|
+
}, ge = (e) => !e.from || E() !== "json" || e.from === D() || e.from === Pn(n.getTokens()?.refresh_token), _e = (e) => {
|
|
2735
2786
|
let t = g;
|
|
2736
2787
|
if (!t) return;
|
|
2737
2788
|
if (!l.holding) {
|
|
2738
2789
|
u = {
|
|
2739
2790
|
kind: "waiting",
|
|
2740
2791
|
pending: e
|
|
2741
|
-
}, l.request(t.nextAt +
|
|
2792
|
+
}, l.request(t.nextAt + G);
|
|
2742
2793
|
return;
|
|
2743
2794
|
}
|
|
2744
2795
|
l.setRetryInfo(t);
|
|
@@ -2757,7 +2808,7 @@ function Wn(e) {
|
|
|
2757
2808
|
!l.holding || l.foreignHolderHeard() || T() - t > 2e4 ? (l.release(), u = {
|
|
2758
2809
|
kind: "waiting",
|
|
2759
2810
|
pending: e
|
|
2760
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
2811
|
+
}, l.request((g?.nextAt ?? T()) + G)) : (u = {
|
|
2761
2812
|
kind: "waiting",
|
|
2762
2813
|
pending: e
|
|
2763
2814
|
}, be() || ye());
|
|
@@ -2797,14 +2848,14 @@ function Wn(e) {
|
|
|
2797
2848
|
case "ended": return N.endHeldSend(), R("stored-ended"), !1;
|
|
2798
2849
|
case "identity-changed": return N.endHeldSend(), R("identity-changed"), fe(), !1;
|
|
2799
2850
|
case "send": return Ce(e, t, a.sent, r);
|
|
2800
|
-
default: return
|
|
2851
|
+
default: return Kn(a);
|
|
2801
2852
|
}
|
|
2802
2853
|
}, Ce = (e, n, r, a) => {
|
|
2803
2854
|
let o = {
|
|
2804
2855
|
generation: d,
|
|
2805
2856
|
sentAt: T(),
|
|
2806
2857
|
trigger: n,
|
|
2807
|
-
settled:
|
|
2858
|
+
settled: Wn()
|
|
2808
2859
|
};
|
|
2809
2860
|
r ? o.sent = r : o.marker = ee(), a && (o.stored = a), u = {
|
|
2810
2861
|
kind: "refreshing",
|
|
@@ -2828,7 +2879,7 @@ function Wn(e) {
|
|
|
2828
2879
|
if (!e.sent) {
|
|
2829
2880
|
let o = X({ ...t.id_token ? { id_token: t.id_token } : {} }), s = k();
|
|
2830
2881
|
if (o !== void 0 && s !== void 0 && o !== s) {
|
|
2831
|
-
let t = new q
|
|
2882
|
+
let t = new J(q.identityChanged);
|
|
2832
2883
|
F("refresh", e.trigger, t, I("auth")), R("identity-changed", t);
|
|
2833
2884
|
return;
|
|
2834
2885
|
}
|
|
@@ -2841,7 +2892,7 @@ function Wn(e) {
|
|
|
2841
2892
|
if (!we(e)) return;
|
|
2842
2893
|
r.setTokensCache({
|
|
2843
2894
|
...n.getTokens() ?? {},
|
|
2844
|
-
...
|
|
2895
|
+
...Zn(t, void 0)
|
|
2845
2896
|
}), L("refresh", "this-tab");
|
|
2846
2897
|
let c = k();
|
|
2847
2898
|
l.post(c === void 0 ? {
|
|
@@ -2854,7 +2905,7 @@ function Wn(e) {
|
|
|
2854
2905
|
}), he(), P(a, e.sentAt);
|
|
2855
2906
|
return;
|
|
2856
2907
|
}
|
|
2857
|
-
let o = D(), s = N.commitSave(e.sent,
|
|
2908
|
+
let o = D(), s = N.commitSave(e.sent, Zn(t, e.stored));
|
|
2858
2909
|
switch (s.kind) {
|
|
2859
2910
|
case "saved":
|
|
2860
2911
|
L("refresh", "this-tab"), le(e.sent.order, e.sentAt), he(), P(a, e.sentAt);
|
|
@@ -2863,16 +2914,16 @@ function Wn(e) {
|
|
|
2863
2914
|
e.outcome && D() === o || L("adopted", "other-tab"), s.adopted && le(e.sent.order), he(), P(a, e.sentAt);
|
|
2864
2915
|
return;
|
|
2865
2916
|
case "ended": {
|
|
2866
|
-
let t = new
|
|
2917
|
+
let t = new J(s.cause === "emptied" ? q.signedOut : q.sessionEnded);
|
|
2867
2918
|
F("refresh", e.trigger, t, I("auth")), R(s.cause === "emptied" ? "emptied" : "stored-ended", t);
|
|
2868
2919
|
return;
|
|
2869
2920
|
}
|
|
2870
2921
|
case "identity-changed": {
|
|
2871
|
-
let t = new q
|
|
2922
|
+
let t = new J(q.identityChanged);
|
|
2872
2923
|
F("refresh", e.trigger, t, I("auth")), R("identity-changed", t), fe();
|
|
2873
2924
|
return;
|
|
2874
2925
|
}
|
|
2875
|
-
default:
|
|
2926
|
+
default: Kn(s);
|
|
2876
2927
|
}
|
|
2877
2928
|
}, Ee = (e, t) => {
|
|
2878
2929
|
if (e.sent?.held && N.endHeldSend(), !we(e) || u.kind !== "refreshing") return;
|
|
@@ -2892,9 +2943,9 @@ function Wn(e) {
|
|
|
2892
2943
|
case "own":
|
|
2893
2944
|
r = o.failure, i = o.heldRefused;
|
|
2894
2945
|
break;
|
|
2895
|
-
default:
|
|
2946
|
+
default: Kn(o);
|
|
2896
2947
|
}
|
|
2897
|
-
} else r =
|
|
2948
|
+
} else r = En(t, T());
|
|
2898
2949
|
if (i) F("refresh", e.trigger, t, I(r.kind)), L("adopted", "other-tab"), he(), P(n, void 0, !0);
|
|
2899
2950
|
else switch (r.kind) {
|
|
2900
2951
|
case "blocked":
|
|
@@ -2910,10 +2961,10 @@ function Wn(e) {
|
|
|
2910
2961
|
case "transient":
|
|
2911
2962
|
m += 1, De(e, n, t, r);
|
|
2912
2963
|
return;
|
|
2913
|
-
default:
|
|
2964
|
+
default: Kn(r.kind);
|
|
2914
2965
|
}
|
|
2915
2966
|
}, De = (e, t, n, r) => {
|
|
2916
|
-
let i = T() +
|
|
2967
|
+
let i = T() + Dn(m, o.random(), r.retryAfterMs), a = r.kind === "auth" ? "auth" : "transient";
|
|
2917
2968
|
F("refresh", e.trigger, n, I(a, i)), a === "transient" && ce(T(), i, "this-tab");
|
|
2918
2969
|
let s = {
|
|
2919
2970
|
kind: a,
|
|
@@ -2923,7 +2974,7 @@ function Wn(e) {
|
|
|
2923
2974
|
}, c = e.sent?.order.fp;
|
|
2924
2975
|
c && (s.from = c), _ && (s.failingSince = _.since), g = s, l.holding && l.post({
|
|
2925
2976
|
type: "retry-scheduled",
|
|
2926
|
-
message:
|
|
2977
|
+
message: Jn(n, "Token refresh failed"),
|
|
2927
2978
|
retry: s
|
|
2928
2979
|
}), _e(re("retry")), oe(t, n, e.sentAt);
|
|
2929
2980
|
}, z = (e, t) => {
|
|
@@ -2936,8 +2987,8 @@ function Wn(e) {
|
|
|
2936
2987
|
fp: i.fp
|
|
2937
2988
|
})), r && N.deleteIfStillDead(r), R("strikes", t);
|
|
2938
2989
|
}, Oe = (e, t, n, r) => {
|
|
2939
|
-
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${
|
|
2940
|
-
let i = d, a = T() +
|
|
2990
|
+
l.release(), s.warn(`[passflow] The refresh token was already used, most likely by another tab; waiting for its successor: ${Jn(n, "blocked")}`);
|
|
2991
|
+
let i = d, a = T() + Vt, c = {
|
|
2941
2992
|
kind: "blocked-wait",
|
|
2942
2993
|
pending: e,
|
|
2943
2994
|
deadline: a,
|
|
@@ -2950,9 +3001,9 @@ function Wn(e) {
|
|
|
2950
3001
|
i === d && u === c && (ke() || (f ? (e.cookieRetried = !0, u = {
|
|
2951
3002
|
kind: "waiting",
|
|
2952
3003
|
pending: e
|
|
2953
|
-
}, l.request()) : T() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), R("successor-timeout")) : c.cancel = o.setTimeout(p,
|
|
3004
|
+
}, l.request()) : T() >= a ? (s.warn("[passflow] No successor of the used refresh token appeared; ending the session in this tab only."), R("successor-timeout")) : c.cancel = o.setTimeout(p, Ht)));
|
|
2954
3005
|
};
|
|
2955
|
-
c.cancel = o.setTimeout(p, f ?
|
|
3006
|
+
c.cancel = o.setTimeout(p, f ? Wt : Ht);
|
|
2956
3007
|
}, ke = () => {
|
|
2957
3008
|
if (u.kind !== "blocked-wait") return !1;
|
|
2958
3009
|
let e = u;
|
|
@@ -2975,7 +3026,7 @@ function Wn(e) {
|
|
|
2975
3026
|
if (u.kind === "ended" || !ge(e)) return;
|
|
2976
3027
|
let r = g?.nextAt;
|
|
2977
3028
|
if (g = e, e.failingSince !== void 0 && ce(e.failingSince, e.nextAt, "other-tab"), !t || u.kind !== "waiting") return;
|
|
2978
|
-
let i = new
|
|
3029
|
+
let i = new J(e.kind === "transient" ? q.unavailable : q.authRetry, {
|
|
2979
3030
|
nextRetryAt: e.nextAt,
|
|
2980
3031
|
cause: n || void 0
|
|
2981
3032
|
}), a = u.pending;
|
|
@@ -2996,7 +3047,7 @@ function Wn(e) {
|
|
|
2996
3047
|
case "idle":
|
|
2997
3048
|
case "refreshing":
|
|
2998
3049
|
case "ended": return;
|
|
2999
|
-
default:
|
|
3050
|
+
default: Kn(u);
|
|
3000
3051
|
}
|
|
3001
3052
|
}, Ne = (e) => {
|
|
3002
3053
|
let t = {};
|
|
@@ -3039,10 +3090,10 @@ function Wn(e) {
|
|
|
3039
3090
|
je(e.retry, !0, e.message), Fe();
|
|
3040
3091
|
return;
|
|
3041
3092
|
case "refresh-failed":
|
|
3042
|
-
if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !==
|
|
3093
|
+
if (u.kind === "ended" || E() !== "json" || e.from !== D() && e.from !== Pn(n.getTokens()?.refresh_token)) return;
|
|
3043
3094
|
if (ce(T(), void 0, "other-tab"), u.kind === "waiting") {
|
|
3044
3095
|
let t = u.pending;
|
|
3045
|
-
u.pending = re(t.trigger), oe(t, new q
|
|
3096
|
+
u.pending = re(t.trigger), oe(t, new J(q.unavailable, { cause: e.message }), void 0);
|
|
3046
3097
|
}
|
|
3047
3098
|
return;
|
|
3048
3099
|
case "lock-wanted":
|
|
@@ -3051,7 +3102,7 @@ function Wn(e) {
|
|
|
3051
3102
|
u.cancel(), l.release(), u = {
|
|
3052
3103
|
kind: "waiting",
|
|
3053
3104
|
pending: e
|
|
3054
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
3105
|
+
}, l.request((g?.nextAt ?? T()) + G);
|
|
3055
3106
|
}
|
|
3056
3107
|
return;
|
|
3057
3108
|
case "session-ended":
|
|
@@ -3060,7 +3111,7 @@ function Wn(e) {
|
|
|
3060
3111
|
return;
|
|
3061
3112
|
case "takeover":
|
|
3062
3113
|
case "rate-limited": return;
|
|
3063
|
-
default:
|
|
3114
|
+
default: Kn(e);
|
|
3064
3115
|
}
|
|
3065
3116
|
}, Fe = () => {
|
|
3066
3117
|
C && !l.holding && l.post({
|
|
@@ -3083,7 +3134,7 @@ function Wn(e) {
|
|
|
3083
3134
|
u.cancel(), u = {
|
|
3084
3135
|
kind: "waiting",
|
|
3085
3136
|
pending: e
|
|
3086
|
-
}, l.request((g?.nextAt ?? T()) +
|
|
3137
|
+
}, l.request((g?.nextAt ?? T()) + G);
|
|
3087
3138
|
}
|
|
3088
3139
|
},
|
|
3089
3140
|
onMessage: Pe
|
|
@@ -3109,9 +3160,9 @@ function Wn(e) {
|
|
|
3109
3160
|
};
|
|
3110
3161
|
A.add(Ie), j.add(Ie);
|
|
3111
3162
|
let Le = (e, t) => {
|
|
3112
|
-
if (f) return Promise.reject(new q
|
|
3163
|
+
if (f) return Promise.reject(new J(q.disposed));
|
|
3113
3164
|
switch (u.kind) {
|
|
3114
|
-
case "ended": return Promise.reject(new q
|
|
3165
|
+
case "ended": return Promise.reject(new J(q.sessionEnded));
|
|
3115
3166
|
case "idle": {
|
|
3116
3167
|
let n = re(e);
|
|
3117
3168
|
u = {
|
|
@@ -3119,17 +3170,17 @@ function Wn(e) {
|
|
|
3119
3170
|
pending: n
|
|
3120
3171
|
};
|
|
3121
3172
|
let r = ae(n, t);
|
|
3122
|
-
return l.holding && !w ? be() || ye() : l.request(g ? g.nextAt +
|
|
3173
|
+
return l.holding && !w ? be() || ye() : l.request(g ? g.nextAt + G : void 0), r;
|
|
3123
3174
|
}
|
|
3124
3175
|
case "waiting":
|
|
3125
3176
|
case "refreshing":
|
|
3126
3177
|
case "backoff":
|
|
3127
3178
|
case "blocked-wait": return ae(u.pending, t);
|
|
3128
|
-
default: return
|
|
3179
|
+
default: return Kn(u);
|
|
3129
3180
|
}
|
|
3130
|
-
},
|
|
3131
|
-
if (f) return Promise.reject(new q
|
|
3132
|
-
if (ue(), u.kind === "ended") return Promise.reject(new q
|
|
3181
|
+
}, V = (e) => {
|
|
3182
|
+
if (f) return Promise.reject(new J(q.disposed));
|
|
3183
|
+
if (ue(), u.kind === "ended") return Promise.reject(new J(q.sessionEnded));
|
|
3133
3184
|
if (E() === "json" && !r.getTokens()?.refresh_token) {
|
|
3134
3185
|
let t = n.getTokens();
|
|
3135
3186
|
if (!t?.refresh_token) {
|
|
@@ -3138,12 +3189,12 @@ function Wn(e) {
|
|
|
3138
3189
|
}
|
|
3139
3190
|
}
|
|
3140
3191
|
return Le(e.trigger, e.fresh ? T() : void 0);
|
|
3141
|
-
},
|
|
3142
|
-
if (f) return Promise.reject(new q
|
|
3192
|
+
}, Re = (e) => {
|
|
3193
|
+
if (f) return Promise.reject(new J(q.disposed));
|
|
3143
3194
|
if (u.kind === "ended") return Promise.resolve(r.getTokens());
|
|
3144
3195
|
let t = u.kind === "backoff" || u.kind === "blocked-wait" || g !== void 0 && g.nextAt > T();
|
|
3145
|
-
return e.allowStale && t ? Promise.resolve(r.getTokens()) :
|
|
3146
|
-
},
|
|
3196
|
+
return e.allowStale && t ? Promise.resolve(r.getTokens()) : V({ trigger: e.trigger }).then(() => r.getTokens());
|
|
3197
|
+
}, ze = (e, t) => l.holding ? Promise.resolve("granted") : new Promise((n) => {
|
|
3147
3198
|
let r = () => void 0, i = {
|
|
3148
3199
|
purpose: e,
|
|
3149
3200
|
granted: () => {
|
|
@@ -3156,7 +3207,7 @@ function Wn(e) {
|
|
|
3156
3207
|
}), l.request(), r = o.setTimeout(() => {
|
|
3157
3208
|
C === i && (C = void 0, u.kind !== "waiting" && l.release(), n("timeout"));
|
|
3158
3209
|
}, Math.max(0, t));
|
|
3159
|
-
}),
|
|
3210
|
+
}), Be = async (e) => {
|
|
3160
3211
|
if (u.kind !== "refreshing") return;
|
|
3161
3212
|
let t = u.request.settled.promise;
|
|
3162
3213
|
await new Promise((n) => {
|
|
@@ -3165,7 +3216,7 @@ function Wn(e) {
|
|
|
3165
3216
|
r(), n();
|
|
3166
3217
|
});
|
|
3167
3218
|
});
|
|
3168
|
-
},
|
|
3219
|
+
}, Ve = () => {
|
|
3169
3220
|
if (w = !1, !f && l.holding) {
|
|
3170
3221
|
if (u.kind === "waiting") be() || ye();
|
|
3171
3222
|
else if (u.kind === "backoff") {
|
|
@@ -3173,19 +3224,19 @@ function Wn(e) {
|
|
|
3173
3224
|
u.cancel(), _e(e);
|
|
3174
3225
|
} else u.kind === "idle" && g && g.nextAt > T() && ge(g) ? (m = g.attempt, h = g.strikes, _e(re("retry"))) : u.kind === "idle" && l.release();
|
|
3175
3226
|
}
|
|
3176
|
-
},
|
|
3177
|
-
if (f) throw new q
|
|
3227
|
+
}, He = async (e, t) => {
|
|
3228
|
+
if (f) throw new J(q.disposed);
|
|
3178
3229
|
ue();
|
|
3179
|
-
let n = T() +
|
|
3180
|
-
if (await
|
|
3181
|
-
let e = new
|
|
3230
|
+
let n = T() + Gt;
|
|
3231
|
+
if (await Be(n - T()), (!l.holding || u.kind === "refreshing") && (u.kind === "refreshing" ? "timeout" : await ze("commit", n - T())) === "timeout") {
|
|
3232
|
+
let e = new Nn("lock-timeout");
|
|
3182
3233
|
throw F("upgrade.commit", "upgrade", e), e;
|
|
3183
3234
|
}
|
|
3184
3235
|
w = !0;
|
|
3185
3236
|
try {
|
|
3186
3237
|
return await Ue(e, t);
|
|
3187
3238
|
} finally {
|
|
3188
|
-
|
|
3239
|
+
Ve();
|
|
3189
3240
|
}
|
|
3190
3241
|
}, Ue = async (e, a) => {
|
|
3191
3242
|
let o, s;
|
|
@@ -3225,7 +3276,7 @@ function Wn(e) {
|
|
|
3225
3276
|
if (!o) {
|
|
3226
3277
|
await i.applyOpaque(u), r.setTokensCache({
|
|
3227
3278
|
...n.getTokens() ?? {},
|
|
3228
|
-
...
|
|
3279
|
+
...Zn(u, void 0)
|
|
3229
3280
|
}), We(c);
|
|
3230
3281
|
let e = k();
|
|
3231
3282
|
return l.post(e === void 0 ? {
|
|
@@ -3237,9 +3288,9 @@ function Wn(e) {
|
|
|
3237
3288
|
sub: e
|
|
3238
3289
|
}), O();
|
|
3239
3290
|
}
|
|
3240
|
-
let d = N.commitSave(o,
|
|
3291
|
+
let d = N.commitSave(o, Zn(u, s));
|
|
3241
3292
|
if (d.kind === "saved") return We(c), le(o.order, c), O();
|
|
3242
|
-
let f = new
|
|
3293
|
+
let f = new Nn("superseded");
|
|
3243
3294
|
throw F("upgrade.commit", "upgrade", f), d.kind === "superseded" && d.adopted && L("adopted", "other-tab"), f;
|
|
3244
3295
|
}, We = (e) => {
|
|
3245
3296
|
if (L("upgrade", "this-tab"), u.kind === "waiting" || u.kind === "backoff" || u.kind === "blocked-wait") {
|
|
@@ -3255,18 +3306,18 @@ function Wn(e) {
|
|
|
3255
3306
|
...t,
|
|
3256
3307
|
fp: t.fp
|
|
3257
3308
|
}));
|
|
3258
|
-
},
|
|
3309
|
+
}, H = () => {
|
|
3259
3310
|
let e = ie(u);
|
|
3260
|
-
se(e, new q
|
|
3311
|
+
se(e, new J(q.signedOut)), (u.kind === "backoff" || u.kind === "blocked-wait" || u.kind === "waiting") && (de(u), u = { kind: "idle" });
|
|
3261
3312
|
};
|
|
3262
3313
|
return {
|
|
3263
|
-
refresh:
|
|
3264
|
-
ensureFresh:
|
|
3265
|
-
commitUpgrade:
|
|
3314
|
+
refresh: V,
|
|
3315
|
+
ensureFresh: Re,
|
|
3316
|
+
commitUpgrade: He,
|
|
3266
3317
|
signOut: async (e) => {
|
|
3267
3318
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3268
|
-
let t = T() +
|
|
3269
|
-
|
|
3319
|
+
let t = T() + Kt;
|
|
3320
|
+
H(), await Be(t - T()), H(), l.coordinated && !l.holding && await ze("logout", t - T());
|
|
3270
3321
|
try {
|
|
3271
3322
|
Ge(), await e(n.getTokens()?.refresh_token);
|
|
3272
3323
|
} finally {
|
|
@@ -3275,7 +3326,7 @@ function Wn(e) {
|
|
|
3275
3326
|
},
|
|
3276
3327
|
signOutNow: (e) => {
|
|
3277
3328
|
if (f) return e(n.getTokens()?.refresh_token);
|
|
3278
|
-
|
|
3329
|
+
H();
|
|
3279
3330
|
try {
|
|
3280
3331
|
Ge(), e(n.getTokens()?.refresh_token);
|
|
3281
3332
|
} finally {
|
|
@@ -3303,14 +3354,14 @@ function Wn(e) {
|
|
|
3303
3354
|
de(u), f = !0, d += 1, u = {
|
|
3304
3355
|
kind: "ended",
|
|
3305
3356
|
cause: "disposed"
|
|
3306
|
-
}, se(e, new q
|
|
3357
|
+
}, se(e, new J(q.disposed)), C = void 0, N.stop(), l.dispose(), te?.(), ne?.();
|
|
3307
3358
|
}
|
|
3308
3359
|
};
|
|
3309
3360
|
}
|
|
3310
3361
|
// lib/store.ts
|
|
3311
3362
|
var Z = /* @__PURE__ */ function(e) {
|
|
3312
3363
|
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;
|
|
3313
|
-
}({}),
|
|
3364
|
+
}({}), $n = class {
|
|
3314
3365
|
constructor() {
|
|
3315
3366
|
this.subscribers = /* @__PURE__ */ new Map();
|
|
3316
3367
|
}
|
|
@@ -3329,12 +3380,12 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3329
3380
|
n && (t.forEach((e) => n.delete(e)), n.size === 0 && this.subscribers.delete(e));
|
|
3330
3381
|
}
|
|
3331
3382
|
notify(e, t) {
|
|
3332
|
-
e === "error" &&
|
|
3383
|
+
e === "error" && Nt(this, t?.originalError), this.subscribers.forEach((n, r) => {
|
|
3333
3384
|
(!n || n.has(e)) && r.onAuthChange?.(e, t);
|
|
3334
3385
|
});
|
|
3335
3386
|
}
|
|
3336
3387
|
notifyError(e) {
|
|
3337
|
-
return
|
|
3388
|
+
return W(this, e);
|
|
3338
3389
|
}
|
|
3339
3390
|
}, Q = {
|
|
3340
3391
|
twoFactorCodeInvalid: "error.api.request.2fa_code.invalid",
|
|
@@ -3350,18 +3401,18 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3350
3401
|
twoFactorNotEnabled: "error.2fa.not_enabled",
|
|
3351
3402
|
notImplemented: "error.not.implemented",
|
|
3352
3403
|
tokenInvalid: "error.api.request.token.invalid"
|
|
3353
|
-
},
|
|
3404
|
+
}, er = Object.freeze([
|
|
3354
3405
|
Q.twoFactorCodeInvalid,
|
|
3355
3406
|
Q.twoFactorNotEnabled,
|
|
3356
3407
|
Q.challengeInvalid,
|
|
3357
3408
|
Q.challengeSessionMismatch,
|
|
3358
3409
|
Q.challengeTooManyAttempts
|
|
3359
|
-
]),
|
|
3410
|
+
]), tr = Object.freeze([Q.tokenInvalid]), nr = Object.freeze([
|
|
3360
3411
|
"wrong_code",
|
|
3361
3412
|
"challenge_spent",
|
|
3362
3413
|
"not_registered",
|
|
3363
3414
|
"prepare_not_required"
|
|
3364
|
-
]),
|
|
3415
|
+
]), rr = (e) => nr.includes(e), ir = {
|
|
3365
3416
|
wrong_code: "That code was not accepted. Try again.",
|
|
3366
3417
|
challenge_spent: "That verification challenge is no longer valid. Start again.",
|
|
3367
3418
|
exhausted: "Too many attempts. Try again later.",
|
|
@@ -3375,16 +3426,16 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3375
3426
|
session_changed: "The session ended during verification."
|
|
3376
3427
|
}, $ = class extends Error {
|
|
3377
3428
|
constructor(e) {
|
|
3378
|
-
super(e.message ||
|
|
3429
|
+
super(e.message || ir[e.kind]), this.name = "UpgradeTransportError", this.code = "upgrade_transport", this.kind = e.kind, this.status = e.status, this.errorId = e.errorId, this.retryable = rr(e.kind), e.cause !== void 0 && (this.cause = e.cause);
|
|
3379
3430
|
}
|
|
3380
|
-
},
|
|
3431
|
+
}, ar = Object.freeze([
|
|
3381
3432
|
"upgrade_transport",
|
|
3382
3433
|
"upgrade_insufficient",
|
|
3383
3434
|
"upgrade_unavailable",
|
|
3384
3435
|
"upgrade_session_changed",
|
|
3385
3436
|
"upgrade_cancelled",
|
|
3386
3437
|
"upgrade_unsatisfiable"
|
|
3387
|
-
]),
|
|
3438
|
+
]), or = (e) => typeof e == "object" && !!e && typeof e.code == "string" && ar.includes(e.code), sr = (e) => e instanceof $ || typeof e == "object" && !!e && e.code === "upgrade_transport", cr = (e) => {
|
|
3388
3439
|
if (typeof e != "object" || !e) return {
|
|
3389
3440
|
hasResponse: !1,
|
|
3390
3441
|
message: typeof e == "string" ? e : void 0
|
|
@@ -3396,7 +3447,7 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3396
3447
|
message: typeof t.message == "string" ? t.message : void 0,
|
|
3397
3448
|
hasResponse: n !== void 0 || typeof t.status == "number"
|
|
3398
3449
|
};
|
|
3399
|
-
},
|
|
3450
|
+
}, lr = (e, t) => {
|
|
3400
3451
|
switch (e) {
|
|
3401
3452
|
case Q.twoFactorCodeInvalid: return "wrong_code";
|
|
3402
3453
|
case Q.challengeInvalid:
|
|
@@ -3413,11 +3464,11 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3413
3464
|
case Q.tokenInvalid: return t === "refresh" ? "session_changed" : "fatal";
|
|
3414
3465
|
default: return;
|
|
3415
3466
|
}
|
|
3416
|
-
},
|
|
3467
|
+
}, ur = (e, t) => e === void 0 ? "network" : e === 501 ? "unavailable" : e === 400 ? "fatal" : e === 401 || e === 403 ? t === "start" ? "challenge_spent" : "session_changed" : e >= 500 ? "network" : "fatal", dr = (e, t) => {
|
|
3417
3468
|
if (e instanceof $) return e;
|
|
3418
|
-
let n =
|
|
3469
|
+
let n = cr(e);
|
|
3419
3470
|
return n.hasResponse ? new $({
|
|
3420
|
-
kind:
|
|
3471
|
+
kind: lr(n.errorId, t) ?? ur(n.status, t),
|
|
3421
3472
|
message: n.message,
|
|
3422
3473
|
status: n.status,
|
|
3423
3474
|
errorId: n.errorId,
|
|
@@ -3427,74 +3478,85 @@ var Z = /* @__PURE__ */ function(e) {
|
|
|
3427
3478
|
message: n.message,
|
|
3428
3479
|
cause: e
|
|
3429
3480
|
});
|
|
3430
|
-
},
|
|
3481
|
+
}, fr = (e) => e.errorId !== void 0 && er.includes(e.errorId), pr = (e) => e.errorId !== void 0 && tr.includes(e.errorId), mr = class extends Error {
|
|
3431
3482
|
constructor(e, t, n) {
|
|
3432
3483
|
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;
|
|
3433
3484
|
}
|
|
3434
|
-
},
|
|
3485
|
+
}, hr = class extends Error {
|
|
3435
3486
|
constructor(e = "Step-up verification is not available on this deployment") {
|
|
3436
3487
|
super(e), this.name = "UpgradeUnavailableError", this.code = "upgrade_unavailable";
|
|
3437
3488
|
}
|
|
3438
|
-
},
|
|
3489
|
+
}, gr = class extends Error {
|
|
3439
3490
|
constructor(e = "The session changed during verification") {
|
|
3440
3491
|
super(e), this.name = "UpgradeSessionChangedError", this.code = "upgrade_session_changed";
|
|
3441
3492
|
}
|
|
3442
|
-
},
|
|
3493
|
+
}, _r = (e) => {
|
|
3443
3494
|
if (e && typeof e.sub == "string" && e.sub !== "") return typeof e.sid == "string" && e.sid !== "" ? {
|
|
3444
3495
|
sub: e.sub,
|
|
3445
3496
|
sid: e.sid
|
|
3446
3497
|
} : { sub: e.sub };
|
|
3447
|
-
},
|
|
3498
|
+
}, vr = (e, t) => !t || t.sub !== e.sub ? !1 : e.sid !== void 0 && t.sid !== void 0 ? e.sid === t.sid : !0;
|
|
3448
3499
|
// lib/utils/validation.ts
|
|
3449
|
-
function
|
|
3500
|
+
function yr(e) {
|
|
3450
3501
|
if (!e || typeof e != "string") return !1;
|
|
3451
3502
|
let t = e.split(".");
|
|
3452
3503
|
if (t.length !== 3) return !1;
|
|
3453
3504
|
let n = /^[A-Za-z0-9_-]+$/;
|
|
3454
3505
|
return t.every((e) => n.test(e) && e.length > 0);
|
|
3455
3506
|
}
|
|
3456
|
-
function
|
|
3507
|
+
function br(e) {
|
|
3457
3508
|
return e.replace(/<[^>]*>/g, "").substring(0, 200);
|
|
3458
3509
|
}
|
|
3459
|
-
function
|
|
3510
|
+
function xr(e) {
|
|
3460
3511
|
if (!e || typeof e != "string") return !1;
|
|
3461
3512
|
let t = e.trim();
|
|
3462
3513
|
return t.length !== 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
|
|
3463
3514
|
}
|
|
3464
|
-
function
|
|
3515
|
+
function Sr(e) {
|
|
3465
3516
|
if (!e || typeof e != "string") return !1;
|
|
3466
3517
|
let t = e.trim();
|
|
3467
3518
|
return /^\+[1-9]\d{1,14}$/.test(t);
|
|
3468
3519
|
}
|
|
3469
|
-
function
|
|
3520
|
+
function Cr(e) {
|
|
3470
3521
|
if (!e || typeof e != "string") return !1;
|
|
3471
3522
|
let t = e.trim();
|
|
3472
3523
|
return t.length < 3 || t.length > 30 ? !1 : /^[a-zA-Z0-9_-]+$/.test(t);
|
|
3473
3524
|
}
|
|
3474
|
-
function
|
|
3525
|
+
function wr(e, t = 6) {
|
|
3475
3526
|
return !e || typeof e != "string" ? !1 : (t === 8 ? /^\d{8}$/ : /^\d{6}$/).test(e);
|
|
3476
3527
|
}
|
|
3477
|
-
function
|
|
3528
|
+
function Tr(e) {
|
|
3478
3529
|
if (!e || typeof e != "string") return null;
|
|
3479
3530
|
let t = e.toUpperCase().replace(/\s+/g, "");
|
|
3480
3531
|
return /^[A-Z0-9-]{4,16}$/.test(t) ? t : null;
|
|
3481
3532
|
}
|
|
3482
3533
|
// lib/services/auth-service.ts
|
|
3483
|
-
var
|
|
3534
|
+
var Er = "passflow_2fa_pkce", Dr = 3e5, Or = "passflow_pwless_pending", kr = 3e3, Ar = "passflow_federated_pkce", jr = 6e5, Mr = "AppId is required for federated auth", Nr = 10, Pr = "The sign-in answered with a PKCE code, but its verifier is gone", Fr = (e, t) => new Promise((n, r) => {
|
|
3535
|
+
if (t?.aborted) {
|
|
3536
|
+
r(t.reason);
|
|
3537
|
+
return;
|
|
3538
|
+
}
|
|
3539
|
+
let i = () => {
|
|
3540
|
+
clearTimeout(a), r(t?.reason);
|
|
3541
|
+
}, a = setTimeout(() => {
|
|
3542
|
+
t?.removeEventListener("abort", i), n();
|
|
3543
|
+
}, e);
|
|
3544
|
+
t?.addEventListener("abort", i, { once: !0 });
|
|
3545
|
+
}), Ir = (e) => {
|
|
3484
3546
|
if (!e) return;
|
|
3485
3547
|
let t = new URLSearchParams(e.search).get("token");
|
|
3486
3548
|
if (t) return t;
|
|
3487
3549
|
let n = e.hash.indexOf("?");
|
|
3488
3550
|
return n < 0 ? void 0 : new URLSearchParams(e.hash.slice(n + 1)).get("token") ?? void 0;
|
|
3489
|
-
},
|
|
3551
|
+
}, Lr = (e) => {
|
|
3490
3552
|
if (e) try {
|
|
3491
3553
|
return A(e).email;
|
|
3492
3554
|
} catch {
|
|
3493
3555
|
return;
|
|
3494
3556
|
}
|
|
3495
|
-
},
|
|
3496
|
-
constructor(e, t, n, r, i, a, o, s, c, l, u, d = P, f, p = { coordination:
|
|
3497
|
-
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new ne(n), u?.enabled && this.tokenDeliveryManager.setMode(M.BFF), this.refresh =
|
|
3557
|
+
}, Rr = class {
|
|
3558
|
+
constructor(e, t, n, r, i, a, o, s, c, l, u, d = P, f, p = { coordination: dn() }) {
|
|
3559
|
+
this.authApi = e, this.deviceService = t, this.storageManager = n, this.subscribeStore = r, this.tokenCacheService = i, this.scopes = a, this.createTenantForNewUser = o, this.url = s, this.sessionCallbacks = c, this.appId = l, this.platform = d, this.readPkceEnabled = f, this.emailChallenges = /* @__PURE__ */ new Map(), this.tokenExchangeConfig = u, this.tokenDeliveryManager = new ne(n), u?.enabled && this.tokenDeliveryManager.setMode(M.BFF), this.refresh = Qn({
|
|
3498
3560
|
emit: this.createRefreshEmit(),
|
|
3499
3561
|
storage: n,
|
|
3500
3562
|
cache: i,
|
|
@@ -3502,7 +3564,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3502
3564
|
coordination: p.coordination,
|
|
3503
3565
|
platform: d,
|
|
3504
3566
|
...p.strikes === void 0 ? {} : { strikes: p.strikes },
|
|
3505
|
-
logger:
|
|
3567
|
+
logger: bn()
|
|
3506
3568
|
}), this.initializeSession();
|
|
3507
3569
|
}
|
|
3508
3570
|
async initializeSession() {
|
|
@@ -3557,7 +3619,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3557
3619
|
rememberEmailChallenge(e, t) {
|
|
3558
3620
|
this.emailChallenges.delete(e), this.emailChallenges.set(e, t);
|
|
3559
3621
|
for (let e of this.emailChallenges.keys()) {
|
|
3560
|
-
if (this.emailChallenges.size <=
|
|
3622
|
+
if (this.emailChallenges.size <= Nr) break;
|
|
3561
3623
|
this.emailChallenges.delete(e);
|
|
3562
3624
|
}
|
|
3563
3625
|
}
|
|
@@ -3565,14 +3627,14 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3565
3627
|
if (this.pendingPkce = {
|
|
3566
3628
|
verifier: e,
|
|
3567
3629
|
scopes: t,
|
|
3568
|
-
expiresAt: Date.now() +
|
|
3630
|
+
expiresAt: Date.now() + Dr
|
|
3569
3631
|
}, typeof sessionStorage < "u") try {
|
|
3570
|
-
sessionStorage.setItem(
|
|
3632
|
+
sessionStorage.setItem(Er, JSON.stringify(this.pendingPkce));
|
|
3571
3633
|
} catch {}
|
|
3572
3634
|
}
|
|
3573
3635
|
readPendingPkce() {
|
|
3574
3636
|
if (!this.pendingPkce && typeof sessionStorage < "u") try {
|
|
3575
|
-
let e = sessionStorage.getItem(
|
|
3637
|
+
let e = sessionStorage.getItem(Er);
|
|
3576
3638
|
this.pendingPkce = e ? JSON.parse(e) : void 0;
|
|
3577
3639
|
} catch {
|
|
3578
3640
|
this.pendingPkce = void 0;
|
|
@@ -3584,7 +3646,49 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3584
3646
|
}
|
|
3585
3647
|
forgetPkceSignIn() {
|
|
3586
3648
|
if (this.pendingPkce = void 0, typeof sessionStorage < "u") try {
|
|
3587
|
-
sessionStorage.removeItem(
|
|
3649
|
+
sessionStorage.removeItem(Er);
|
|
3650
|
+
} catch {}
|
|
3651
|
+
}
|
|
3652
|
+
rememberPendingPasswordless(e) {
|
|
3653
|
+
if (this.pendingPasswordless = e, typeof sessionStorage < "u") try {
|
|
3654
|
+
sessionStorage.setItem(Or, JSON.stringify(e));
|
|
3655
|
+
} catch {}
|
|
3656
|
+
}
|
|
3657
|
+
readPendingPasswordless() {
|
|
3658
|
+
if (!this.pendingPasswordless && typeof sessionStorage < "u") try {
|
|
3659
|
+
let e = sessionStorage.getItem(Or);
|
|
3660
|
+
this.pendingPasswordless = e ? JSON.parse(e) : void 0;
|
|
3661
|
+
} catch {
|
|
3662
|
+
this.pendingPasswordless = void 0;
|
|
3663
|
+
}
|
|
3664
|
+
return this.pendingPasswordless && !(Date.now() < this.pendingPasswordless.expiresAt) && this.forgetPendingPasswordless(), this.pendingPasswordless;
|
|
3665
|
+
}
|
|
3666
|
+
forgetPendingPasswordless() {
|
|
3667
|
+
if (this.pendingPasswordless = void 0, typeof sessionStorage < "u") try {
|
|
3668
|
+
sessionStorage.removeItem(Or);
|
|
3669
|
+
} catch {}
|
|
3670
|
+
}
|
|
3671
|
+
rememberFederatedSlot(e, t) {
|
|
3672
|
+
if (this.federatedSlot = {
|
|
3673
|
+
verifier: e,
|
|
3674
|
+
scopes: t,
|
|
3675
|
+
expiresAt: Date.now() + jr
|
|
3676
|
+
}, typeof sessionStorage < "u") try {
|
|
3677
|
+
sessionStorage.setItem(Ar, JSON.stringify(this.federatedSlot));
|
|
3678
|
+
} catch {}
|
|
3679
|
+
}
|
|
3680
|
+
readFederatedSlot() {
|
|
3681
|
+
if (!this.federatedSlot && typeof sessionStorage < "u") try {
|
|
3682
|
+
let e = sessionStorage.getItem(Ar);
|
|
3683
|
+
this.federatedSlot = e ? JSON.parse(e) : void 0;
|
|
3684
|
+
} catch {
|
|
3685
|
+
this.federatedSlot = void 0;
|
|
3686
|
+
}
|
|
3687
|
+
return this.federatedSlot && Date.now() < this.federatedSlot.expiresAt ? this.federatedSlot : void 0;
|
|
3688
|
+
}
|
|
3689
|
+
forgetFederatedSlot() {
|
|
3690
|
+
if (this.federatedSlot = void 0, typeof sessionStorage < "u") try {
|
|
3691
|
+
sessionStorage.removeItem(Ar);
|
|
3588
3692
|
} catch {}
|
|
3589
3693
|
}
|
|
3590
3694
|
async startPkce() {
|
|
@@ -3592,17 +3696,17 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3592
3696
|
try {
|
|
3593
3697
|
e = await this.readPkceEnabled?.() ?? !1;
|
|
3594
3698
|
} catch (e) {
|
|
3595
|
-
|
|
3699
|
+
bn().warn("Passflow: could not read the app settings, so this sign-in sends no PKCE challenge", e);
|
|
3596
3700
|
return;
|
|
3597
3701
|
}
|
|
3598
|
-
return e ?
|
|
3702
|
+
return e ? vn() : void 0;
|
|
3599
3703
|
}
|
|
3600
3704
|
async exchangeCode(e, t) {
|
|
3601
3705
|
return !e.code || !t ? e : await this.authApi.pkceExchange(e.code, t.verifier);
|
|
3602
3706
|
}
|
|
3603
3707
|
async completePkceSignIn(e) {
|
|
3604
3708
|
let t = this.readPendingPkce();
|
|
3605
|
-
if (!t) throw Error(
|
|
3709
|
+
if (!t) throw Error(Pr);
|
|
3606
3710
|
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
3607
3711
|
return await this.processAuthResponse(n, t.scopes ?? this.scopes), n;
|
|
3608
3712
|
}
|
|
@@ -3626,35 +3730,35 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3626
3730
|
if (!t.ok) throw Error(`BFF token storage failed: ${t.status}`);
|
|
3627
3731
|
}
|
|
3628
3732
|
async signIn(e) {
|
|
3629
|
-
if ("email" in e && e.email && !
|
|
3733
|
+
if ("email" in e && e.email && !xr(e.email)) {
|
|
3630
3734
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3631
3735
|
operation: "sign-in",
|
|
3632
3736
|
message: "Invalid email format",
|
|
3633
3737
|
originalError: e,
|
|
3634
3738
|
code: "VALIDATION_ERROR"
|
|
3635
3739
|
};
|
|
3636
|
-
throw
|
|
3740
|
+
throw W(this.subscribeStore, t), e;
|
|
3637
3741
|
}
|
|
3638
|
-
if ("username" in e && e.username && !
|
|
3742
|
+
if ("username" in e && e.username && !Cr(e.username)) {
|
|
3639
3743
|
let e = /* @__PURE__ */ Error("Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens"), t = {
|
|
3640
3744
|
operation: "sign-in",
|
|
3641
3745
|
message: "Invalid username format. Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens",
|
|
3642
3746
|
originalError: e,
|
|
3643
3747
|
code: "VALIDATION_ERROR"
|
|
3644
3748
|
};
|
|
3645
|
-
throw
|
|
3749
|
+
throw W(this.subscribeStore, t), e;
|
|
3646
3750
|
}
|
|
3647
|
-
if ("phone" in e && e.phone && !
|
|
3751
|
+
if ("phone" in e && e.phone && !Sr(e.phone)) {
|
|
3648
3752
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3649
3753
|
operation: "sign-in",
|
|
3650
3754
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3651
3755
|
originalError: e,
|
|
3652
3756
|
code: "VALIDATION_ERROR"
|
|
3653
3757
|
};
|
|
3654
|
-
throw
|
|
3758
|
+
throw W(this.subscribeStore, t), e;
|
|
3655
3759
|
}
|
|
3656
3760
|
this.subscribeStore.notify(Z.SignInStart, { email: e.email });
|
|
3657
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
3761
|
+
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
3658
3762
|
e.scopes = e.scopes ?? this.scopes;
|
|
3659
3763
|
try {
|
|
3660
3764
|
let r = await this.startPkce(), i = await this.authApi.signIn(r ? {
|
|
@@ -3674,27 +3778,27 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3674
3778
|
originalError: e,
|
|
3675
3779
|
code: e instanceof B ? e.id : void 0
|
|
3676
3780
|
};
|
|
3677
|
-
throw
|
|
3781
|
+
throw W(this.subscribeStore, t), e;
|
|
3678
3782
|
}
|
|
3679
3783
|
}
|
|
3680
3784
|
async signUp(e) {
|
|
3681
|
-
if (e.user.email && !
|
|
3785
|
+
if (e.user.email && !xr(e.user.email)) {
|
|
3682
3786
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3683
3787
|
operation: "sign-up",
|
|
3684
3788
|
message: "Invalid email format",
|
|
3685
3789
|
originalError: e,
|
|
3686
3790
|
code: "VALIDATION_ERROR"
|
|
3687
3791
|
};
|
|
3688
|
-
throw
|
|
3792
|
+
throw W(this.subscribeStore, t), e;
|
|
3689
3793
|
}
|
|
3690
|
-
if (e.user.phone_number && !
|
|
3794
|
+
if (e.user.phone_number && !Sr(e.user.phone_number)) {
|
|
3691
3795
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3692
3796
|
operation: "sign-up",
|
|
3693
3797
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3694
3798
|
originalError: e,
|
|
3695
3799
|
code: "VALIDATION_ERROR"
|
|
3696
3800
|
};
|
|
3697
|
-
throw
|
|
3801
|
+
throw W(this.subscribeStore, t), e;
|
|
3698
3802
|
}
|
|
3699
3803
|
this.subscribeStore.notify(Z.RegisterStart, { email: e.user.email }), e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
3700
3804
|
try {
|
|
@@ -3715,32 +3819,45 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3715
3819
|
originalError: e,
|
|
3716
3820
|
code: e instanceof B ? e.id : void 0
|
|
3717
3821
|
};
|
|
3718
|
-
throw
|
|
3822
|
+
throw W(this.subscribeStore, t), e;
|
|
3719
3823
|
}
|
|
3720
3824
|
}
|
|
3721
3825
|
async passwordlessSignIn(e) {
|
|
3722
|
-
if (e.email && !
|
|
3826
|
+
if (e.email && !xr(e.email)) {
|
|
3723
3827
|
let e = /* @__PURE__ */ Error("Invalid email format"), t = {
|
|
3724
3828
|
operation: "passwordless.start",
|
|
3725
3829
|
message: "Invalid email format",
|
|
3726
3830
|
originalError: e,
|
|
3727
3831
|
code: "VALIDATION_ERROR"
|
|
3728
3832
|
};
|
|
3729
|
-
throw
|
|
3833
|
+
throw W(this.subscribeStore, t), e;
|
|
3730
3834
|
}
|
|
3731
|
-
if (e.phone && !
|
|
3835
|
+
if (e.phone && !Sr(e.phone)) {
|
|
3732
3836
|
let e = /* @__PURE__ */ Error("Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)"), t = {
|
|
3733
3837
|
operation: "passwordless.start",
|
|
3734
3838
|
message: "Invalid phone number format. Phone must be in E.164 format (e.g., +12345678901)",
|
|
3735
3839
|
originalError: e,
|
|
3736
3840
|
code: "VALIDATION_ERROR"
|
|
3737
3841
|
};
|
|
3738
|
-
throw
|
|
3842
|
+
throw W(this.subscribeStore, t), e;
|
|
3739
3843
|
}
|
|
3740
|
-
this.subscribeStore.notify(Z.SignInStart, { email: e.email })
|
|
3741
|
-
let t = this.deviceService.getDeviceId(),
|
|
3844
|
+
this.subscribeStore.notify(Z.SignInStart, { email: e.email });
|
|
3845
|
+
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId(), r = Le(this.platform.getDeviceType());
|
|
3742
3846
|
try {
|
|
3743
|
-
|
|
3847
|
+
let i = await this.startPkce(), a = await this.authApi.passwordlessSignIn({
|
|
3848
|
+
...e,
|
|
3849
|
+
scopes: t,
|
|
3850
|
+
...i ? { code_challenge: i.challenge } : {}
|
|
3851
|
+
}, n, r);
|
|
3852
|
+
return i && a.challenge_id ? this.rememberPendingPasswordless({
|
|
3853
|
+
challengeId: a.challenge_id,
|
|
3854
|
+
verifier: i.verifier,
|
|
3855
|
+
codeChallenge: i.challenge,
|
|
3856
|
+
matchCode: a.match_code,
|
|
3857
|
+
email: e.email,
|
|
3858
|
+
scopes: t,
|
|
3859
|
+
expiresAt: new Date(a.expires_at).getTime()
|
|
3860
|
+
}) : this.forgetPendingPasswordless(), a;
|
|
3744
3861
|
} catch (e) {
|
|
3745
3862
|
let t = {
|
|
3746
3863
|
operation: "passwordless.start",
|
|
@@ -3748,39 +3865,140 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3748
3865
|
originalError: e,
|
|
3749
3866
|
code: e instanceof B ? e.id : void 0
|
|
3750
3867
|
};
|
|
3751
|
-
throw
|
|
3868
|
+
throw W(this.subscribeStore, t), e;
|
|
3752
3869
|
}
|
|
3753
3870
|
}
|
|
3754
3871
|
async passwordlessSignInComplete(e) {
|
|
3755
3872
|
this.subscribeStore.notify(Z.SignInStart, {}), e.scopes = e.scopes ?? this.scopes, e.device = this.deviceService.getDeviceId();
|
|
3873
|
+
let t = this.readPendingPasswordless(), n = t?.challengeId === e.challenge_id ? t : void 0, r = !1;
|
|
3756
3874
|
try {
|
|
3757
3875
|
let t = await this.authApi.passwordlessSignInComplete(e);
|
|
3758
|
-
|
|
3759
|
-
|
|
3876
|
+
if (r = !0, this.handlePendingSecondFactor(t, n?.email, n && { verifier: n.verifier }, n?.scopes)) return this.forgetPendingPasswordless(), t;
|
|
3877
|
+
let i = t;
|
|
3878
|
+
if (t.code) {
|
|
3879
|
+
if (!n) throw Error(Pr);
|
|
3880
|
+
if (i = await this.authApi.pkceExchange(t.code, n.verifier), this.handlePendingSecondFactor(i)) return this.forgetPendingPasswordless(), {
|
|
3881
|
+
...i,
|
|
3882
|
+
redirect_url: t.redirect_url ?? ""
|
|
3883
|
+
};
|
|
3884
|
+
}
|
|
3885
|
+
let a = t.redirect_url ? {
|
|
3886
|
+
...i,
|
|
3887
|
+
redirect_url: t.redirect_url
|
|
3888
|
+
} : i;
|
|
3889
|
+
return await this.processAuthResponse(a, n?.scopes ?? e.scopes), this.forgetPendingPasswordless(), this.subscribeStore.notify(Z.SignIn, {
|
|
3890
|
+
tokens: a,
|
|
3760
3891
|
parsedTokens: this.tokenCacheService.getParsedTokens()
|
|
3761
|
-
}), await this.submitSessionCheck()
|
|
3892
|
+
}), await this.submitSessionCheck(), {
|
|
3893
|
+
...a,
|
|
3894
|
+
redirect_url: t.redirect_url ?? ""
|
|
3895
|
+
};
|
|
3762
3896
|
} catch (e) {
|
|
3897
|
+
r && this.forgetPendingPasswordless();
|
|
3763
3898
|
let t = {
|
|
3764
3899
|
operation: "passwordless.complete",
|
|
3765
3900
|
message: e instanceof Error ? e.message : "Passwordless sign in failed",
|
|
3766
3901
|
originalError: e,
|
|
3767
3902
|
code: e instanceof B ? e.id : void 0
|
|
3768
3903
|
};
|
|
3769
|
-
throw
|
|
3904
|
+
throw W(this.subscribeStore, t), e;
|
|
3905
|
+
}
|
|
3906
|
+
}
|
|
3907
|
+
async waitForPasswordlessSignIn(e, t) {
|
|
3908
|
+
let n = t?.signal;
|
|
3909
|
+
try {
|
|
3910
|
+
let t = this.readPendingPasswordless();
|
|
3911
|
+
if (t?.challengeId !== e) throw Error(Pr);
|
|
3912
|
+
for (;;) {
|
|
3913
|
+
if (n?.aborted) throw n.reason;
|
|
3914
|
+
if (Date.now() >= t.expiresAt) return this.forgetPendingPasswordless(), { status: "expired" };
|
|
3915
|
+
if (this.readPendingPasswordless()?.challengeId !== e) throw Error(Pr);
|
|
3916
|
+
let r;
|
|
3917
|
+
try {
|
|
3918
|
+
r = await this.authApi.passwordlessStatus({
|
|
3919
|
+
challenge_id: e,
|
|
3920
|
+
code_challenge: t.codeChallenge
|
|
3921
|
+
}, { signal: n });
|
|
3922
|
+
} catch (e) {
|
|
3923
|
+
if (n?.aborted) throw n.reason;
|
|
3924
|
+
if (e instanceof B && e.status >= 400 && e.status < 500 && e.status !== 429) throw this.forgetPendingPasswordless(), e;
|
|
3925
|
+
}
|
|
3926
|
+
if (r?.status === "denied" || r?.status === "expired" || r?.status === "completed") return this.forgetPendingPasswordless(), { status: r.status };
|
|
3927
|
+
if (r?.status === "approved" && r.code) return await this.finishApprovedPasswordless(r.code, t);
|
|
3928
|
+
await Fr(kr, n);
|
|
3929
|
+
}
|
|
3930
|
+
} catch (e) {
|
|
3931
|
+
if (n?.aborted && e === n.reason) throw e;
|
|
3932
|
+
let t = {
|
|
3933
|
+
operation: "passwordless.wait",
|
|
3934
|
+
message: e instanceof Error ? e.message : "Waiting for the passwordless sign-in failed",
|
|
3935
|
+
originalError: e,
|
|
3936
|
+
code: e instanceof B ? e.id : void 0
|
|
3937
|
+
};
|
|
3938
|
+
throw W(this.subscribeStore, t), e;
|
|
3770
3939
|
}
|
|
3771
3940
|
}
|
|
3941
|
+
async finishApprovedPasswordless(e, t) {
|
|
3942
|
+
try {
|
|
3943
|
+
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
3944
|
+
return this.handlePendingSecondFactor(n, t.email) ? (this.forgetPendingPasswordless(), { status: "second-factor-required" }) : (await this.processAuthResponse(n, t.scopes), this.forgetPendingPasswordless(), this.subscribeStore.notify(Z.SignIn, {
|
|
3945
|
+
tokens: n,
|
|
3946
|
+
parsedTokens: this.tokenCacheService.getParsedTokens()
|
|
3947
|
+
}), await this.submitSessionCheck(), {
|
|
3948
|
+
status: "signed-in",
|
|
3949
|
+
tokens: n
|
|
3950
|
+
});
|
|
3951
|
+
} catch (e) {
|
|
3952
|
+
throw this.forgetPendingPasswordless(), e;
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
getPendingPasswordlessSignIn(e) {
|
|
3956
|
+
let t = this.readPendingPasswordless();
|
|
3957
|
+
if (t?.challengeId === e && t.matchCode) return {
|
|
3958
|
+
matchCode: t.matchCode,
|
|
3959
|
+
expiresAt: t.expiresAt
|
|
3960
|
+
};
|
|
3961
|
+
}
|
|
3962
|
+
async getPasswordlessApproval(e) {
|
|
3963
|
+
try {
|
|
3964
|
+
return await this.authApi.passwordlessApprovalInfo({ challenge_id: e });
|
|
3965
|
+
} catch (e) {
|
|
3966
|
+
throw this.reportApprovalFailure(e), e;
|
|
3967
|
+
}
|
|
3968
|
+
}
|
|
3969
|
+
async decidePasswordlessApproval(e, t, n, r) {
|
|
3970
|
+
try {
|
|
3971
|
+
await this.authApi.passwordlessApprovalDecide({
|
|
3972
|
+
challenge_id: e,
|
|
3973
|
+
otp: t,
|
|
3974
|
+
approve: n,
|
|
3975
|
+
match_code: r
|
|
3976
|
+
});
|
|
3977
|
+
} catch (e) {
|
|
3978
|
+
throw this.reportApprovalFailure(e), e;
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
reportApprovalFailure(e) {
|
|
3982
|
+
let t = {
|
|
3983
|
+
operation: "passwordless.approval",
|
|
3984
|
+
message: e instanceof Error ? e.message : "Passwordless approval failed",
|
|
3985
|
+
originalError: e,
|
|
3986
|
+
code: e instanceof B ? e.id : void 0
|
|
3987
|
+
};
|
|
3988
|
+
W(this.subscribeStore, t);
|
|
3989
|
+
}
|
|
3772
3990
|
async verifyEmailCode(e) {
|
|
3773
3991
|
let t = this.emailChallenges.get(e.challenge_id), n = t?.email;
|
|
3774
3992
|
try {
|
|
3775
3993
|
let r = t?.pkce === !1 ? void 0 : this.readPendingPkce();
|
|
3776
|
-
if (t?.pkce && !r) throw Error(
|
|
3994
|
+
if (t?.pkce && !r) throw Error(Pr);
|
|
3777
3995
|
let i = await this.authApi.validateEmailCode(e);
|
|
3778
3996
|
this.emailChallenges.delete(e.challenge_id);
|
|
3779
3997
|
let a = r?.scopes ?? t?.scopes ?? this.scopes;
|
|
3780
3998
|
if (this.handleEmailVerificationStep(i, t?.operation ?? "sign-in", n, r, a) || this.handlePendingSecondFactor(i, n, r, a)) return i;
|
|
3781
3999
|
let o = i;
|
|
3782
4000
|
if (i.code) {
|
|
3783
|
-
if (!r) throw Error(
|
|
4001
|
+
if (!r) throw Error(Pr);
|
|
3784
4002
|
if (o = await this.authApi.pkceExchange(i.code, r.verifier), this.handlePendingSecondFactor(o, n)) return o;
|
|
3785
4003
|
}
|
|
3786
4004
|
let s = i.redirect_url ? {
|
|
@@ -3798,13 +4016,13 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3798
4016
|
originalError: e,
|
|
3799
4017
|
code: e instanceof B ? e.id : void 0
|
|
3800
4018
|
};
|
|
3801
|
-
throw
|
|
4019
|
+
throw W(this.subscribeStore, t), e;
|
|
3802
4020
|
}
|
|
3803
4021
|
}
|
|
3804
4022
|
async logOut() {
|
|
3805
4023
|
let e = this.refresh.identity();
|
|
3806
4024
|
return await this.refresh.signOut(async (e) => {
|
|
3807
|
-
await this.callLogoutApi(e), this.forgetPkceSignIn(), this.emailChallenges.clear(), this.clearLocalSession();
|
|
4025
|
+
await this.callLogoutApi(e), this.forgetPkceSignIn(), this.forgetPendingPasswordless(), this.emailChallenges.clear(), this.clearLocalSession();
|
|
3808
4026
|
}), e;
|
|
3809
4027
|
}
|
|
3810
4028
|
resetSession() {
|
|
@@ -3834,13 +4052,13 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3834
4052
|
readSessionPin() {
|
|
3835
4053
|
try {
|
|
3836
4054
|
let e = this.storageManager.getToken(j.access_token);
|
|
3837
|
-
return e ?
|
|
4055
|
+
return e ? _r(A(e)) : void 0;
|
|
3838
4056
|
} catch {
|
|
3839
4057
|
return;
|
|
3840
4058
|
}
|
|
3841
4059
|
}
|
|
3842
4060
|
assertSessionPin(e) {
|
|
3843
|
-
if (e && !
|
|
4061
|
+
if (e && !vr(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 gr("The session changed during verification, so the elevated tokens were discarded");
|
|
3844
4062
|
}
|
|
3845
4063
|
refreshMode() {
|
|
3846
4064
|
return this.tokenDeliveryManager.isBFFMode() && this.tokenExchangeConfig?.refreshUrl ? "bff" : this.tokenDeliveryManager.isCookieMode() ? "cookie" : "json";
|
|
@@ -3868,7 +4086,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3868
4086
|
return;
|
|
3869
4087
|
}
|
|
3870
4088
|
case "error":
|
|
3871
|
-
|
|
4089
|
+
W(n, t);
|
|
3872
4090
|
return;
|
|
3873
4091
|
case "refresh:start":
|
|
3874
4092
|
n.notify(Z.RefreshStart, {});
|
|
@@ -3888,7 +4106,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3888
4106
|
case "signout":
|
|
3889
4107
|
n.notify(Z.SignOut, t);
|
|
3890
4108
|
return;
|
|
3891
|
-
default:
|
|
4109
|
+
default: bn().warn(`[passflow] Unknown refresh event: ${String(e)}`);
|
|
3892
4110
|
}
|
|
3893
4111
|
};
|
|
3894
4112
|
}
|
|
@@ -3946,7 +4164,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3946
4164
|
let e = this.storageManager.getTokens();
|
|
3947
4165
|
if (!e?.refresh_token) {
|
|
3948
4166
|
let t = /* @__PURE__ */ Error(e ? "No refresh token found" : "No tokens found");
|
|
3949
|
-
throw
|
|
4167
|
+
throw W(this.subscribeStore, {
|
|
3950
4168
|
operation: "refresh",
|
|
3951
4169
|
source: "refresh-token",
|
|
3952
4170
|
message: t.message,
|
|
@@ -3969,15 +4187,15 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3969
4187
|
originalError: e,
|
|
3970
4188
|
code: e instanceof B ? e.id : void 0
|
|
3971
4189
|
};
|
|
3972
|
-
throw
|
|
4190
|
+
throw W(this.subscribeStore, t), e;
|
|
3973
4191
|
}
|
|
3974
4192
|
}
|
|
3975
4193
|
async resetPassword(e, t, n) {
|
|
3976
4194
|
this.subscribeStore.notify(Z.SignInStart, {});
|
|
3977
|
-
let r = n ??
|
|
4195
|
+
let r = n ?? Ir(this.platform.getCurrentUrl()), i = t ?? this.scopes;
|
|
3978
4196
|
try {
|
|
3979
4197
|
let t = await this.startPkce(), n = t ? await this.authApi.resetPassword(e, i, r, t.challenge) : await this.authApi.resetPassword(e, i, r);
|
|
3980
|
-
if (this.handleEmailVerificationStep(n, "reset-password",
|
|
4198
|
+
if (this.handleEmailVerificationStep(n, "reset-password", Lr(r), t, i) || this.handlePendingSecondFactor(n, void 0, t, i)) return n;
|
|
3981
4199
|
let a = await this.exchangeCode(n, t);
|
|
3982
4200
|
if (this.handlePendingSecondFactor(a)) return a;
|
|
3983
4201
|
let o = n.redirect_url ? {
|
|
@@ -3995,13 +4213,13 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
3995
4213
|
originalError: e,
|
|
3996
4214
|
code: e instanceof B ? e.id : void 0
|
|
3997
4215
|
};
|
|
3998
|
-
throw
|
|
4216
|
+
throw W(this.subscribeStore, t), e;
|
|
3999
4217
|
}
|
|
4000
4218
|
}
|
|
4001
4219
|
async passkeyRegister(e) {
|
|
4002
4220
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4003
4221
|
this.subscribeStore.notify(Z.RegisterStart, {});
|
|
4004
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
4222
|
+
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
4005
4223
|
e.scopes = e.scopes ?? this.scopes, e.create_tenant = this.createTenantForNewUser;
|
|
4006
4224
|
try {
|
|
4007
4225
|
let r = await this.startPkce(), { challenge_id: i, publicKey: a } = await this.authApi.passkeyRegisterStart(r ? {
|
|
@@ -4025,13 +4243,13 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4025
4243
|
originalError: e,
|
|
4026
4244
|
code: e instanceof B ? e.id : void 0
|
|
4027
4245
|
};
|
|
4028
|
-
throw
|
|
4246
|
+
throw W(this.subscribeStore, t), e;
|
|
4029
4247
|
}
|
|
4030
4248
|
}
|
|
4031
4249
|
async passkeyAuthenticate(e) {
|
|
4032
4250
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4033
4251
|
this.subscribeStore.notify(Z.SignInStart, {});
|
|
4034
|
-
let t = this.deviceService.getDeviceId(), n =
|
|
4252
|
+
let t = this.deviceService.getDeviceId(), n = Le(this.platform.getDeviceType());
|
|
4035
4253
|
e.scopes = e.scopes ?? this.scopes;
|
|
4036
4254
|
try {
|
|
4037
4255
|
let r = await this.startPkce(), { challenge_id: i, publicKey: a } = await this.authApi.passkeyAuthenticateStart(r ? {
|
|
@@ -4053,63 +4271,110 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4053
4271
|
originalError: e,
|
|
4054
4272
|
code: e instanceof B ? e.id : void 0
|
|
4055
4273
|
};
|
|
4056
|
-
throw
|
|
4274
|
+
throw W(this.subscribeStore, t), e;
|
|
4057
4275
|
}
|
|
4058
4276
|
}
|
|
4059
4277
|
createFederatedAuthUrl(e) {
|
|
4060
4278
|
let t = `/auth/federated/start/${e.provider}`;
|
|
4061
|
-
if (!this.appId) throw Error(
|
|
4279
|
+
if (!this.appId) throw Error(Mr);
|
|
4062
4280
|
let n = {
|
|
4063
4281
|
scopes: (e.scopes ?? this.scopes).join(" "),
|
|
4064
4282
|
redirect_url: e.redirect_url ?? this.platform.getCurrentUrl()?.origin ?? "",
|
|
4065
4283
|
appId: this.appId,
|
|
4066
4284
|
...e.invite_token ? { invite_token: e.invite_token } : {},
|
|
4067
4285
|
...e.create_tenant ? { create_tenant: e.create_tenant.toString() } : {},
|
|
4068
|
-
...e.device ? { device: e.device } : {}
|
|
4286
|
+
...e.device ? { device: e.device } : {},
|
|
4287
|
+
...e.code_challenge ? { code_challenge: e.code_challenge } : {},
|
|
4288
|
+
...e.code_challenge_method ? { code_challenge_method: e.code_challenge_method } : {}
|
|
4069
4289
|
}, r = new URL(t, this.url);
|
|
4070
4290
|
return r.search = new URLSearchParams(n).toString(), r.toString();
|
|
4071
4291
|
}
|
|
4072
4292
|
async federatedAuthWithPopup(e) {
|
|
4073
|
-
this.subscribeStore.notify(Z.SignInStart, { provider: e.provider });
|
|
4074
|
-
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId()
|
|
4075
|
-
...e,
|
|
4076
|
-
scopes: t,
|
|
4077
|
-
device: n
|
|
4078
|
-
});
|
|
4293
|
+
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(Mr);
|
|
4294
|
+
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
|
|
4079
4295
|
try {
|
|
4080
|
-
|
|
4296
|
+
this.forgetFederatedSlot();
|
|
4297
|
+
let r = await this.startPkce(), i = this.createFederatedAuthUrl({
|
|
4298
|
+
...e,
|
|
4299
|
+
scopes: t,
|
|
4300
|
+
device: n,
|
|
4301
|
+
...r ? {
|
|
4302
|
+
code_challenge: r.challenge,
|
|
4303
|
+
code_challenge_method: "S256"
|
|
4304
|
+
} : {}
|
|
4305
|
+
}), a = this.platform.openAuthUrl(i, {
|
|
4081
4306
|
mode: "popup",
|
|
4082
4307
|
expectedReturnOrigin: this.platform.getCurrentUrl()?.origin ?? ""
|
|
4083
|
-
})
|
|
4084
|
-
|
|
4085
|
-
let
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4308
|
+
});
|
|
4309
|
+
r && this.rememberFederatedSlot(r.verifier, t);
|
|
4310
|
+
let o = await a;
|
|
4311
|
+
this.forgetFederatedSlot();
|
|
4312
|
+
let s = new URLSearchParams(o.callbackHash.replace(/^#/, ""));
|
|
4313
|
+
if (this.handlePendingSecondFactor({ tfa_token: s.get("tfa_token") ?? void 0 })) return;
|
|
4314
|
+
let c = new URLSearchParams(o.callbackSearch), l = c.get("code"), u = c.get("access_token") || "", d = c.get("refresh_token") || "", f = c.get("id_token") || "", p = {
|
|
4315
|
+
access_token: u,
|
|
4316
|
+
refresh_token: d || void 0,
|
|
4317
|
+
id_token: f || void 0,
|
|
4089
4318
|
scopes: t
|
|
4090
4319
|
};
|
|
4091
|
-
await this.
|
|
4092
|
-
|
|
4320
|
+
if (l && r && (p = await this.authApi.pkceExchange(l, r.verifier), this.handlePendingSecondFactor(p))) return;
|
|
4321
|
+
await this.processAuthResponse(p, t), this.subscribeStore.notify(Z.SignIn, {
|
|
4322
|
+
tokens: p,
|
|
4093
4323
|
parsedTokens: this.tokenCacheService.getParsedTokens()
|
|
4094
4324
|
}), this.platform.navigateTo(this.platform.getCurrentUrl()?.origin ?? "");
|
|
4095
4325
|
} catch (e) {
|
|
4326
|
+
this.forgetFederatedSlot();
|
|
4096
4327
|
let t = {
|
|
4097
4328
|
operation: "federated.popup",
|
|
4098
4329
|
message: e instanceof Error ? e.message : "Authentication failed",
|
|
4099
4330
|
code: e instanceof ie ? "POPUP_CLOSED" : "AUTH_FAILED",
|
|
4100
4331
|
originalError: e
|
|
4101
4332
|
};
|
|
4102
|
-
|
|
4333
|
+
W(this.subscribeStore, t);
|
|
4103
4334
|
}
|
|
4104
4335
|
}
|
|
4105
4336
|
federatedAuthWithRedirect(e) {
|
|
4106
|
-
this.subscribeStore.notify(Z.SignInStart, { provider: e.provider });
|
|
4107
|
-
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId()
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4337
|
+
if (this.subscribeStore.notify(Z.SignInStart, { provider: e.provider }), !this.appId) throw Error(Mr);
|
|
4338
|
+
let t = e.scopes ?? this.scopes, n = this.deviceService.getDeviceId();
|
|
4339
|
+
this.startPkce().then((r) => {
|
|
4340
|
+
let i = this.createFederatedAuthUrl({
|
|
4341
|
+
...e,
|
|
4342
|
+
scopes: t,
|
|
4343
|
+
device: n,
|
|
4344
|
+
...r ? {
|
|
4345
|
+
code_challenge: r.challenge,
|
|
4346
|
+
code_challenge_method: "S256"
|
|
4347
|
+
} : {}
|
|
4348
|
+
});
|
|
4349
|
+
r ? this.rememberFederatedSlot(r.verifier, t) : this.forgetFederatedSlot(), this.platform.navigateTo(i);
|
|
4350
|
+
}).catch((e) => this.reportFederatedRedirectFailure(e));
|
|
4351
|
+
}
|
|
4352
|
+
handleFederatedCode(e) {
|
|
4353
|
+
if (!this.appId) return !1;
|
|
4354
|
+
let t = this.readFederatedSlot();
|
|
4355
|
+
return t ? (this.forgetFederatedSlot(), this.finishFederatedLanding(e, t), !0) : !1;
|
|
4356
|
+
}
|
|
4357
|
+
async finishFederatedLanding(e, t) {
|
|
4358
|
+
try {
|
|
4359
|
+
let n = await this.authApi.pkceExchange(e, t.verifier);
|
|
4360
|
+
if (this.handlePendingSecondFactor(n)) return;
|
|
4361
|
+
await this.processAuthResponse(n, t.scopes), this.subscribeStore.notify(Z.SignIn, {
|
|
4362
|
+
tokens: n,
|
|
4363
|
+
parsedTokens: this.tokenCacheService.getParsedTokens(),
|
|
4364
|
+
source: "federated-landing"
|
|
4365
|
+
}), await this.submitSessionCheck();
|
|
4366
|
+
} catch (e) {
|
|
4367
|
+
this.reportFederatedRedirectFailure(e);
|
|
4368
|
+
}
|
|
4369
|
+
}
|
|
4370
|
+
reportFederatedRedirectFailure(e) {
|
|
4371
|
+
let t = {
|
|
4372
|
+
operation: "federated.redirect",
|
|
4373
|
+
message: e instanceof Error ? e.message : "Federated sign-in failed",
|
|
4374
|
+
originalError: e,
|
|
4375
|
+
code: e instanceof B ? e.id : void 0
|
|
4376
|
+
};
|
|
4377
|
+
W(this.subscribeStore, t);
|
|
4113
4378
|
}
|
|
4114
4379
|
authRedirectUrl(e = {}) {
|
|
4115
4380
|
try {
|
|
@@ -4127,7 +4392,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4127
4392
|
message: e instanceof Error ? e.message : "Failed to create auth redirect URL",
|
|
4128
4393
|
originalError: e
|
|
4129
4394
|
};
|
|
4130
|
-
throw
|
|
4395
|
+
throw W(this.subscribeStore, t), e;
|
|
4131
4396
|
}
|
|
4132
4397
|
}
|
|
4133
4398
|
authRedirect(e = {}) {
|
|
@@ -4139,7 +4404,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4139
4404
|
message: e instanceof Error ? e.message : "Failed to redirect to auth page",
|
|
4140
4405
|
originalError: e
|
|
4141
4406
|
};
|
|
4142
|
-
throw
|
|
4407
|
+
throw W(this.subscribeStore, t), e;
|
|
4143
4408
|
}
|
|
4144
4409
|
}
|
|
4145
4410
|
isAuthenticated(e) {
|
|
@@ -4155,7 +4420,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4155
4420
|
message: e instanceof Error ? e.message : "Failed to check authentication status",
|
|
4156
4421
|
originalError: e
|
|
4157
4422
|
};
|
|
4158
|
-
return
|
|
4423
|
+
return W(this.subscribeStore, t), !1;
|
|
4159
4424
|
}
|
|
4160
4425
|
}
|
|
4161
4426
|
async submitSessionCheck(e = !1) {
|
|
@@ -4168,7 +4433,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4168
4433
|
message: e instanceof Error || e instanceof B ? e.message : "Session check failed",
|
|
4169
4434
|
originalError: e
|
|
4170
4435
|
};
|
|
4171
|
-
|
|
4436
|
+
W(this.subscribeStore, n), t = void 0;
|
|
4172
4437
|
}
|
|
4173
4438
|
return t && this.sessionCallbacks.createSession && await this.sessionCallbacks.createSession({
|
|
4174
4439
|
tokens: t,
|
|
@@ -4195,11 +4460,11 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4195
4460
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4196
4461
|
originalError: e
|
|
4197
4462
|
};
|
|
4198
|
-
|
|
4463
|
+
W(this.subscribeStore, t);
|
|
4199
4464
|
return;
|
|
4200
4465
|
}
|
|
4201
4466
|
}
|
|
4202
|
-
},
|
|
4467
|
+
}, zr = class {
|
|
4203
4468
|
constructor(e) {
|
|
4204
4469
|
this.invitationApi = e;
|
|
4205
4470
|
}
|
|
@@ -4218,7 +4483,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4218
4483
|
getInvitationLink(e) {
|
|
4219
4484
|
return this.invitationApi.getInvitationLink(e);
|
|
4220
4485
|
}
|
|
4221
|
-
},
|
|
4486
|
+
}, Br = class {
|
|
4222
4487
|
constructor(e) {
|
|
4223
4488
|
this.data = this.normalize(e);
|
|
4224
4489
|
}
|
|
@@ -4275,9 +4540,9 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4275
4540
|
getData() {
|
|
4276
4541
|
return this.data;
|
|
4277
4542
|
}
|
|
4278
|
-
},
|
|
4543
|
+
}, Vr = class {
|
|
4279
4544
|
constructor(e, t, n) {
|
|
4280
|
-
this.tenantApi = e, this.scopes = t, this.logger = n ||
|
|
4545
|
+
this.tenantApi = e, this.scopes = t, this.logger = n || bn();
|
|
4281
4546
|
}
|
|
4282
4547
|
handlePassflowError(t, n) {
|
|
4283
4548
|
if (e.isAxiosError(t) && t.response?.data) {
|
|
@@ -4313,7 +4578,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4313
4578
|
}
|
|
4314
4579
|
async getTenantUserMembership(e) {
|
|
4315
4580
|
try {
|
|
4316
|
-
return new
|
|
4581
|
+
return new Br(await this.tenantApi.getTenantDetails(e));
|
|
4317
4582
|
} catch (t) {
|
|
4318
4583
|
this.handlePassflowError(t, `Get tenant user membership failed for tenant ID ${e}`);
|
|
4319
4584
|
}
|
|
@@ -4458,7 +4723,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4458
4723
|
this.handlePassflowError(r, `Invalidate invite by email failed for tenant ID ${e}, group ID ${t}, email ${n}`);
|
|
4459
4724
|
}
|
|
4460
4725
|
}
|
|
4461
|
-
},
|
|
4726
|
+
}, Hr = class {
|
|
4462
4727
|
constructor(e, t, n, r = P) {
|
|
4463
4728
|
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();
|
|
4464
4729
|
}
|
|
@@ -4483,7 +4748,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4483
4748
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4484
4749
|
originalError: e
|
|
4485
4750
|
};
|
|
4486
|
-
|
|
4751
|
+
W(this.subscribeStore, t), this.setTokensCache(void 0);
|
|
4487
4752
|
}
|
|
4488
4753
|
}
|
|
4489
4754
|
startTokenCheck() {
|
|
@@ -4528,7 +4793,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4528
4793
|
message: e instanceof Error ? e.message : "Failed to get tokens",
|
|
4529
4794
|
originalError: e
|
|
4530
4795
|
};
|
|
4531
|
-
|
|
4796
|
+
W(this.subscribeStore, t);
|
|
4532
4797
|
return;
|
|
4533
4798
|
}
|
|
4534
4799
|
}
|
|
@@ -4538,7 +4803,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4538
4803
|
isExpired() {
|
|
4539
4804
|
return this.tokensCache ? this.tokensCache.access_token ? k(A(this.tokensCache.access_token)) : !1 : !0;
|
|
4540
4805
|
}
|
|
4541
|
-
},
|
|
4806
|
+
}, Ur = class {
|
|
4542
4807
|
constructor(e, t, n) {
|
|
4543
4808
|
this.twoFactorApi = e, this.subscribeStore = t, this.signInCompleter = n, this.PARTIAL_AUTH_TIMEOUT_MS = 3e5, this.SESSION_STORAGE_KEY = "passflow_2fa_challenge", this.totpDigits = 6, this.subscribeStore.subscribe({ onAuthChange: (e, t) => {
|
|
4544
4809
|
if (e === Z.TwoFactorRequired) {
|
|
@@ -4559,7 +4824,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4559
4824
|
originalError: e,
|
|
4560
4825
|
code: r?.id || void 0
|
|
4561
4826
|
};
|
|
4562
|
-
throw
|
|
4827
|
+
throw W(this.subscribeStore, i), e;
|
|
4563
4828
|
}
|
|
4564
4829
|
async getStatus() {
|
|
4565
4830
|
try {
|
|
@@ -4578,7 +4843,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4578
4843
|
}
|
|
4579
4844
|
}
|
|
4580
4845
|
async confirmSetup(e) {
|
|
4581
|
-
if (!
|
|
4846
|
+
if (!wr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4582
4847
|
try {
|
|
4583
4848
|
let t = await this.twoFactorApi.confirmSetup({ code: e });
|
|
4584
4849
|
return this.subscribeStore.notify(Z.TwoFactorEnabled, {
|
|
@@ -4592,7 +4857,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4592
4857
|
}
|
|
4593
4858
|
}
|
|
4594
4859
|
async verify(e, t) {
|
|
4595
|
-
if (!
|
|
4860
|
+
if (!wr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4596
4861
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4597
4862
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
4598
4863
|
try {
|
|
@@ -4608,7 +4873,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4608
4873
|
}
|
|
4609
4874
|
async useRecoveryCode(e, t) {
|
|
4610
4875
|
try {
|
|
4611
|
-
let n =
|
|
4876
|
+
let n = Tr(e);
|
|
4612
4877
|
if (!n) throw Error("Invalid recovery code format. Expected format: XXXX-XXXX or XXXXXXXX (alphanumeric).");
|
|
4613
4878
|
if (this.recoverPartialAuthState(), !this.isVerificationRequired()) throw Error("2FA verification expired or not required. User must sign in first.");
|
|
4614
4879
|
if (!this.partialAuthState?.tfaToken) throw Error("No TFA token found. User must sign in first.");
|
|
@@ -4629,7 +4894,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4629
4894
|
}
|
|
4630
4895
|
}
|
|
4631
4896
|
async disable(e) {
|
|
4632
|
-
if (!
|
|
4897
|
+
if (!wr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4633
4898
|
try {
|
|
4634
4899
|
let t = await this.twoFactorApi.disable({ code: e });
|
|
4635
4900
|
return this.subscribeStore.notify(Z.TwoFactorDisabled, {}), t;
|
|
@@ -4638,7 +4903,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4638
4903
|
}
|
|
4639
4904
|
}
|
|
4640
4905
|
async regenerateRecoveryCodes(e) {
|
|
4641
|
-
if (!
|
|
4906
|
+
if (!wr(e, this.totpDigits)) throw Error(`Invalid TOTP code format. Code must be exactly ${this.totpDigits} digits.`);
|
|
4642
4907
|
try {
|
|
4643
4908
|
let t = await this.twoFactorApi.regenerateRecoveryCodes({ code: e }), n = [...t.recovery_codes];
|
|
4644
4909
|
return t.recovery_codes = [], t.recovery_codes = n, t;
|
|
@@ -4822,7 +5087,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4822
5087
|
this.emitErrorAndThrow(e, "2fa.trusted-devices.revoke", "Revoke trusted device");
|
|
4823
5088
|
}
|
|
4824
5089
|
}
|
|
4825
|
-
},
|
|
5090
|
+
}, Wr = class {
|
|
4826
5091
|
constructor(e, t, n = P) {
|
|
4827
5092
|
this.userAPI = e, this.deviceService = t, this.platform = n;
|
|
4828
5093
|
}
|
|
@@ -4837,7 +5102,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4837
5102
|
}
|
|
4838
5103
|
async addUserPasskey({ relyingPartyId: e, passkeyUsername: t, passkeyDisplayName: n } = {}) {
|
|
4839
5104
|
if (!this.platform.passkeys) throw Error("Passkeys are not supported on this platform");
|
|
4840
|
-
let r = this.deviceService.getDeviceId(), i =
|
|
5105
|
+
let r = this.deviceService.getDeviceId(), i = Le(this.platform.getDeviceType()), { challenge_id: a, publicKey: o } = await this.userAPI.addUserPasskeyStart({
|
|
4841
5106
|
relyingPartyId: (e || this.platform.getCurrentUrl()?.hostname) ?? "",
|
|
4842
5107
|
deviceId: r,
|
|
4843
5108
|
os: i,
|
|
@@ -4849,69 +5114,69 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4849
5114
|
if (!s) throw Error("Passkey registration was not completed");
|
|
4850
5115
|
return await this.userAPI.addUserPasskeyComplete(s, r, a);
|
|
4851
5116
|
}
|
|
4852
|
-
},
|
|
5117
|
+
}, Gr = class extends Error {
|
|
4853
5118
|
constructor(e, t, n = !1) {
|
|
4854
5119
|
super(t), this.name = "UpgradeFactorError", this.factor = e, this.cancelled = n;
|
|
4855
5120
|
}
|
|
4856
|
-
},
|
|
5121
|
+
}, Kr = (e, t) => {
|
|
4857
5122
|
let n = t?.trim();
|
|
4858
|
-
if (!n) throw new
|
|
5123
|
+
if (!n) throw new Gr(e, "A verification code is required");
|
|
4859
5124
|
return n;
|
|
4860
|
-
},
|
|
5125
|
+
}, qr = {
|
|
4861
5126
|
type: "totp",
|
|
4862
5127
|
requiresPrepare: !1,
|
|
4863
5128
|
input: "code",
|
|
4864
|
-
assert: async ({ code: e }) => ({ code:
|
|
4865
|
-
},
|
|
5129
|
+
assert: async ({ code: e }) => ({ code: Kr("totp", e) })
|
|
5130
|
+
}, Jr = {
|
|
4866
5131
|
type: "recovery_codes",
|
|
4867
5132
|
requiresPrepare: !1,
|
|
4868
5133
|
input: "code",
|
|
4869
|
-
assert: async ({ code: e }) => ({ code:
|
|
4870
|
-
},
|
|
5134
|
+
assert: async ({ code: e }) => ({ code: Kr("recovery_codes", e) })
|
|
5135
|
+
}, Yr = {
|
|
4871
5136
|
type: "passkey",
|
|
4872
5137
|
requiresPrepare: !0,
|
|
4873
5138
|
input: "none",
|
|
4874
5139
|
assert: async ({ prepared: e, platform: t }) => {
|
|
4875
|
-
if (!e?.webauthn) throw new
|
|
5140
|
+
if (!e?.webauthn) throw new Gr("passkey", "The upgrade challenge carried no WebAuthn options");
|
|
4876
5141
|
let n = t.passkeys;
|
|
4877
|
-
if (!n) throw new
|
|
5142
|
+
if (!n) throw new Gr("passkey", "This platform does not support passkeys");
|
|
4878
5143
|
let r;
|
|
4879
5144
|
try {
|
|
4880
5145
|
r = await n.startAuthentication(e.webauthn);
|
|
4881
5146
|
} catch (e) {
|
|
4882
|
-
throw new
|
|
5147
|
+
throw new Gr("passkey", e?.message || "Passkey verification was cancelled", !0);
|
|
4883
5148
|
}
|
|
4884
|
-
if (!r) throw new
|
|
5149
|
+
if (!r) throw new Gr("passkey", "Passkey verification was cancelled", !0);
|
|
4885
5150
|
return {
|
|
4886
5151
|
challenge_id: e.challengeId,
|
|
4887
5152
|
credential: r
|
|
4888
5153
|
};
|
|
4889
5154
|
}
|
|
4890
|
-
},
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
]),
|
|
5155
|
+
}, Xr = Object.freeze([
|
|
5156
|
+
qr,
|
|
5157
|
+
Yr,
|
|
5158
|
+
Jr
|
|
5159
|
+
]), Zr = (e = Xr) => new Map(e.map((e) => [e.type, e])), Qr = 3, $r = {
|
|
4895
5160
|
passkey: 0,
|
|
4896
5161
|
totp: 1,
|
|
4897
5162
|
email_otp: 2,
|
|
4898
5163
|
sms_otp: 3,
|
|
4899
5164
|
recovery_codes: 9
|
|
4900
|
-
},
|
|
4901
|
-
let n =
|
|
5165
|
+
}, ei = (e) => e.requiredLevel ?? L(e.acrValues), ti = (e, t) => {
|
|
5166
|
+
let n = $r[e.type] ?? 5, r = t !== void 0 && t >= Qr, i = e.type === "passkey";
|
|
4902
5167
|
return (r && !i ? 100 : 0) + n;
|
|
4903
|
-
},
|
|
4904
|
-
let n =
|
|
4905
|
-
return [...e].sort((e, t) =>
|
|
4906
|
-
},
|
|
5168
|
+
}, ni = (e, t) => {
|
|
5169
|
+
let n = ei(t);
|
|
5170
|
+
return [...e].sort((e, t) => ti(e, n) - ti(t, n));
|
|
5171
|
+
}, ri = class extends Error {
|
|
4907
5172
|
constructor(e) {
|
|
4908
5173
|
super("Upgrade authentication was cancelled"), this.code = "upgrade_cancelled", this.name = "UpgradeCancelledError", e !== void 0 && (this.cause = e);
|
|
4909
5174
|
}
|
|
4910
|
-
},
|
|
5175
|
+
}, ii = class extends Error {
|
|
4911
5176
|
constructor(e = "No available authentication factor can satisfy this challenge") {
|
|
4912
5177
|
super(e), this.code = "upgrade_unsatisfiable", this.name = "UpgradeUnsatisfiableError";
|
|
4913
5178
|
}
|
|
4914
|
-
},
|
|
5179
|
+
}, ai = 4, oi = 3e4, si = () => {
|
|
4915
5180
|
let e = () => void 0, t = () => void 0;
|
|
4916
5181
|
return {
|
|
4917
5182
|
promise: new Promise((n, r) => {
|
|
@@ -4920,11 +5185,11 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4920
5185
|
resolve: e,
|
|
4921
5186
|
reject: t
|
|
4922
5187
|
};
|
|
4923
|
-
},
|
|
5188
|
+
}, ci = (e) => ({
|
|
4924
5189
|
acrValues: e.acrValues,
|
|
4925
5190
|
level: e.requiredLevel,
|
|
4926
5191
|
maxAge: e.maxAge
|
|
4927
|
-
}),
|
|
5192
|
+
}), li = (e, t) => t.level === void 0 || e.level !== void 0 && e.level >= t.level, ui = (e, t) => {
|
|
4928
5193
|
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 ?? []]));
|
|
4929
5194
|
return {
|
|
4930
5195
|
acrValues: r,
|
|
@@ -4933,12 +5198,12 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4933
5198
|
status: e.status,
|
|
4934
5199
|
...a.length > 0 ? { channels: a } : {}
|
|
4935
5200
|
};
|
|
4936
|
-
},
|
|
5201
|
+
}, di = (e, t) => {
|
|
4937
5202
|
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);
|
|
4938
5203
|
return n || r;
|
|
4939
|
-
},
|
|
5204
|
+
}, fi = class {
|
|
4940
5205
|
constructor(e) {
|
|
4941
|
-
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 ??
|
|
5206
|
+
this.state = "idle", this.inFlight = null, this.requirement = null, this.selected = null, this.rankedRequirement = null, this.registrations = [], this.proof = null, this.pruned = /* @__PURE__ */ new Set(), this.openPrompt = null, this.transport = e.transport, this.prompt = e.prompt, this.platform = e.platform, this.available = e.factors ?? Xr, this.registry = Zr(this.available), this.maxAttempts = e.maxAttempts ?? ai, this.readObtainedBar = e.readObtainedBar, this.onFlightSettled = e.onFlightSettled, this.settleTimeoutMs = e.replaySettleTimeoutMs ?? oi;
|
|
4942
5207
|
}
|
|
4943
5208
|
get currentState() {
|
|
4944
5209
|
return this.state;
|
|
@@ -4958,9 +5223,9 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4958
5223
|
}
|
|
4959
5224
|
register(e, t) {
|
|
4960
5225
|
let n = t.kind === "imperative" && t.requested !== void 0, r = {
|
|
4961
|
-
demanded: t.kind === "imperative" && t.requested ? t.requested :
|
|
5226
|
+
demanded: t.kind === "imperative" && t.requested ? t.requested : ci(e),
|
|
4962
5227
|
statedBar: n,
|
|
4963
|
-
settlement:
|
|
5228
|
+
settlement: si(),
|
|
4964
5229
|
reported: !1,
|
|
4965
5230
|
entry: {
|
|
4966
5231
|
...t,
|
|
@@ -4976,15 +5241,15 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
4976
5241
|
this.requirement = e;
|
|
4977
5242
|
return;
|
|
4978
5243
|
}
|
|
4979
|
-
let n =
|
|
4980
|
-
this.requirement =
|
|
5244
|
+
let n = di(t, e);
|
|
5245
|
+
this.requirement = ui(t, e), n && this.state === "collecting" && this.selected === null && this.openPrompt?.onRequirementRaised?.({
|
|
4981
5246
|
challenge: this.requirement,
|
|
4982
5247
|
factors: this.offeredFactors()
|
|
4983
5248
|
});
|
|
4984
5249
|
}
|
|
4985
5250
|
offeredFactors() {
|
|
4986
5251
|
let e = this.available.filter((e) => !this.pruned.has(e.type)), t = this.requirement;
|
|
4987
|
-
return t ?
|
|
5252
|
+
return t ? ni(e, t) : e;
|
|
4988
5253
|
}
|
|
4989
5254
|
receiveReport(e, t) {
|
|
4990
5255
|
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());
|
|
@@ -5019,12 +5284,12 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5019
5284
|
}
|
|
5020
5285
|
release(e, t) {
|
|
5021
5286
|
if (e.entry.kind === "imperative") {
|
|
5022
|
-
if (e.statedBar && !
|
|
5287
|
+
if (e.statedBar && !li(t, e.demanded)) {
|
|
5023
5288
|
this.receiveReport(e, {
|
|
5024
5289
|
outcome: "insufficient",
|
|
5025
5290
|
obtained: t,
|
|
5026
5291
|
required: e.demanded
|
|
5027
|
-
}), e.settlement.reject(new
|
|
5292
|
+
}), e.settlement.reject(new mr(t, e.demanded));
|
|
5028
5293
|
return;
|
|
5029
5294
|
}
|
|
5030
5295
|
this.receiveReport(e, {
|
|
@@ -5097,7 +5362,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5097
5362
|
let t = this.offeredFactors();
|
|
5098
5363
|
if (t.length === 0) return {
|
|
5099
5364
|
status: "failed",
|
|
5100
|
-
reason: new
|
|
5365
|
+
reason: new ii()
|
|
5101
5366
|
};
|
|
5102
5367
|
let n = this.requirement, r;
|
|
5103
5368
|
try {
|
|
@@ -5105,24 +5370,24 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5105
5370
|
} catch (e) {
|
|
5106
5371
|
return {
|
|
5107
5372
|
status: "failed",
|
|
5108
|
-
reason: new
|
|
5373
|
+
reason: new ri(e)
|
|
5109
5374
|
};
|
|
5110
5375
|
}
|
|
5111
5376
|
if (r.type === "cancel") return {
|
|
5112
5377
|
status: "failed",
|
|
5113
|
-
reason: new
|
|
5378
|
+
reason: new ri()
|
|
5114
5379
|
};
|
|
5115
5380
|
let i = this.registry.get(r.factor);
|
|
5116
|
-
if (!i) e = new
|
|
5381
|
+
if (!i) e = new ii(`Unknown authentication factor: ${r.factor}`), this.state = "collecting", this.selected = null;
|
|
5117
5382
|
else try {
|
|
5118
5383
|
return await this.proveAndCommit(i, r.code), {
|
|
5119
5384
|
status: "proven",
|
|
5120
|
-
obtained: this.readObtainedBar?.() ??
|
|
5385
|
+
obtained: this.readObtainedBar?.() ?? ci(this.rankedRequirement ?? n)
|
|
5121
5386
|
};
|
|
5122
5387
|
} catch (t) {
|
|
5123
|
-
if (t instanceof
|
|
5388
|
+
if (t instanceof Gr && t.cancelled) return {
|
|
5124
5389
|
status: "failed",
|
|
5125
|
-
reason: new
|
|
5390
|
+
reason: new ri()
|
|
5126
5391
|
};
|
|
5127
5392
|
let n = this.classifyProofFailure(t);
|
|
5128
5393
|
if (n) return {
|
|
@@ -5152,15 +5417,15 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5152
5417
|
return this.openPrompt = r, this.prompt(r);
|
|
5153
5418
|
}
|
|
5154
5419
|
classifyProofFailure(e) {
|
|
5155
|
-
if (e instanceof
|
|
5420
|
+
if (e instanceof mr || e instanceof hr || e instanceof gr) return e;
|
|
5156
5421
|
if (e instanceof $) switch (e.kind) {
|
|
5157
|
-
case "unavailable": return new
|
|
5422
|
+
case "unavailable": return new hr(e.message);
|
|
5158
5423
|
case "exhausted":
|
|
5159
5424
|
case "attempts_exhausted":
|
|
5160
5425
|
case "fatal":
|
|
5161
5426
|
case "protocol":
|
|
5162
5427
|
case "network": return e;
|
|
5163
|
-
case "session_changed": return new
|
|
5428
|
+
case "session_changed": return new gr(e.message);
|
|
5164
5429
|
default: return;
|
|
5165
5430
|
}
|
|
5166
5431
|
}
|
|
@@ -5172,28 +5437,28 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5172
5437
|
});
|
|
5173
5438
|
await this.transport.commit(e.type, r);
|
|
5174
5439
|
}
|
|
5175
|
-
},
|
|
5440
|
+
}, pi = (e) => typeof e == "function" ? e() : e, mi = (e) => {
|
|
5176
5441
|
try {
|
|
5177
5442
|
return new URL(e);
|
|
5178
5443
|
} catch {
|
|
5179
5444
|
return;
|
|
5180
5445
|
}
|
|
5181
|
-
},
|
|
5446
|
+
}, hi = (e, t) => {
|
|
5182
5447
|
if (!t || t === "/") return !0;
|
|
5183
5448
|
let n = t.replace(/\/+$/, "");
|
|
5184
5449
|
return e === n || e.startsWith(`${n}/`);
|
|
5185
|
-
},
|
|
5450
|
+
}, gi = (e, t) => !t || e.origin === void 0 ? !1 : e.origin === t.origin && hi(e.pathname, t.pathPrefix), _i = (e, t) => {
|
|
5186
5451
|
for (let n of t) {
|
|
5187
5452
|
if (n === "") continue;
|
|
5188
5453
|
if (n.startsWith("/")) {
|
|
5189
|
-
if (e.relativeToBase &&
|
|
5454
|
+
if (e.relativeToBase && hi(e.pathname, n)) return !0;
|
|
5190
5455
|
continue;
|
|
5191
5456
|
}
|
|
5192
|
-
let t =
|
|
5193
|
-
if (t && e.origin !== void 0 && e.origin === t.origin &&
|
|
5457
|
+
let t = mi(n) ?? mi(`https://${n}`);
|
|
5458
|
+
if (t && e.origin !== void 0 && e.origin === t.origin && hi(e.pathname, t.pathname)) return !0;
|
|
5194
5459
|
}
|
|
5195
5460
|
return !1;
|
|
5196
|
-
},
|
|
5461
|
+
}, vi = (e, t, n) => gi(e, t.passflow) || _i(e, t.backend) ? !n || n(e.href) !== !1 : !1, yi = (e) => {
|
|
5197
5462
|
let t = e.detail, n = t?.message ?? `[passflow] upgrade challenge not actioned: ${e.reason}`;
|
|
5198
5463
|
console.warn(n, {
|
|
5199
5464
|
status: e.status,
|
|
@@ -5201,8 +5466,8 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5201
5466
|
reason: e.reason,
|
|
5202
5467
|
detail: t
|
|
5203
5468
|
});
|
|
5204
|
-
},
|
|
5205
|
-
let n = t.onUpgradeDiagnostic ??
|
|
5469
|
+
}, bi = (e, t) => {
|
|
5470
|
+
let n = t.onUpgradeDiagnostic ?? yi;
|
|
5206
5471
|
return (t, r) => {
|
|
5207
5472
|
n({
|
|
5208
5473
|
status: e.status,
|
|
@@ -5214,8 +5479,8 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5214
5479
|
}
|
|
5215
5480
|
});
|
|
5216
5481
|
};
|
|
5217
|
-
},
|
|
5218
|
-
let r = n.onUpgradeDiagnostic ??
|
|
5482
|
+
}, xi = (e, t, n) => {
|
|
5483
|
+
let r = n.onUpgradeDiagnostic ?? yi;
|
|
5219
5484
|
for (let n of e) r({
|
|
5220
5485
|
...n,
|
|
5221
5486
|
url: t.request.href,
|
|
@@ -5224,8 +5489,8 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5224
5489
|
...n.detail ?? {}
|
|
5225
5490
|
}
|
|
5226
5491
|
});
|
|
5227
|
-
},
|
|
5228
|
-
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n &&
|
|
5492
|
+
}, Si = /\bjson\b/i, Ci = async (e, t) => {
|
|
5493
|
+
let n = t.requireChallengeChannel === "header", r = e.getHeader("content-type") ?? "", i = !n && Si.test(r), a;
|
|
5229
5494
|
if (i) try {
|
|
5230
5495
|
a = await e.readBody();
|
|
5231
5496
|
} catch {
|
|
@@ -5239,10 +5504,10 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5239
5504
|
status: e.status,
|
|
5240
5505
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5241
5506
|
}, { requireChallengeChannel: t.requireChallengeChannel });
|
|
5242
|
-
},
|
|
5507
|
+
}, wi = (e) => ve({
|
|
5243
5508
|
status: e.status,
|
|
5244
5509
|
getHeader: (t) => e.getHeader(t) ?? void 0
|
|
5245
|
-
}, { requireChallengeChannel: "header" }).challenge,
|
|
5510
|
+
}, { requireChallengeChannel: "header" }).challenge, Ti = (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.`, Ei = (e, t) => e instanceof ri ? { kind: "cancelled" } : e instanceof ii ? { kind: "unsatisfiable" } : e instanceof hr ? { kind: "unavailable" } : e instanceof gr ? { kind: "session-changed" } : e instanceof mr ? {
|
|
5246
5511
|
kind: "insufficient",
|
|
5247
5512
|
obtained: e.obtained,
|
|
5248
5513
|
required: e.required
|
|
@@ -5258,17 +5523,17 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5258
5523
|
kind: "transport-failure",
|
|
5259
5524
|
retryable: !1,
|
|
5260
5525
|
error: e instanceof Error ? e : Error(String(e))
|
|
5261
|
-
},
|
|
5526
|
+
}, Di = async (e, t, n, r) => {
|
|
5262
5527
|
if (e.status !== 401 && e.status !== 403) return {
|
|
5263
5528
|
kind: "replayed",
|
|
5264
5529
|
response: e
|
|
5265
5530
|
};
|
|
5266
|
-
let { challenge: i, diagnostics: a } = await
|
|
5267
|
-
if (
|
|
5531
|
+
let { challenge: i, diagnostics: a } = await Ci(e, t);
|
|
5532
|
+
if (xi(a, e, t), !i) return {
|
|
5268
5533
|
kind: "replayed",
|
|
5269
5534
|
response: e
|
|
5270
5535
|
};
|
|
5271
|
-
let o =
|
|
5536
|
+
let o = ci(i);
|
|
5272
5537
|
return r("elevated-insufficient", {
|
|
5273
5538
|
obtained: n,
|
|
5274
5539
|
required: o
|
|
@@ -5278,7 +5543,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5278
5543
|
required: o,
|
|
5279
5544
|
response: e
|
|
5280
5545
|
};
|
|
5281
|
-
},
|
|
5546
|
+
}, Oi = async (e, t) => {
|
|
5282
5547
|
if (!t) return {
|
|
5283
5548
|
aborted: !1,
|
|
5284
5549
|
value: await e
|
|
@@ -5305,14 +5570,14 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5305
5570
|
} finally {
|
|
5306
5571
|
n && t.removeEventListener?.("abort", n);
|
|
5307
5572
|
}
|
|
5308
|
-
},
|
|
5573
|
+
}, ki = async (e, t) => {
|
|
5309
5574
|
if (e.status !== 401 && e.status !== 403 || e.markers.upgradeTransaction) return { kind: "not-a-challenge" };
|
|
5310
|
-
let n =
|
|
5575
|
+
let n = bi(e, t);
|
|
5311
5576
|
if (e.markers.replayed) {
|
|
5312
|
-
if (!
|
|
5313
|
-
let { challenge: r, diagnostics: i } = await
|
|
5314
|
-
if (
|
|
5315
|
-
let a = t.readObtainedBar?.() ?? {}, o =
|
|
5577
|
+
if (!vi(e.request, t.scope, t.shouldIntercept)) return { kind: "not-a-challenge" };
|
|
5578
|
+
let { challenge: r, diagnostics: i } = await Ci(e, t);
|
|
5579
|
+
if (xi(i, e, t), !r) return { kind: "not-a-challenge" };
|
|
5580
|
+
let a = t.readObtainedBar?.() ?? {}, o = ci(r);
|
|
5316
5581
|
return n("elevated-insufficient", {
|
|
5317
5582
|
obtained: a,
|
|
5318
5583
|
required: o
|
|
@@ -5323,12 +5588,12 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5323
5588
|
response: e
|
|
5324
5589
|
};
|
|
5325
5590
|
}
|
|
5326
|
-
if (!
|
|
5591
|
+
if (!vi(e.request, t.scope, t.shouldIntercept)) return wi(e) ? (n("challenge-out-of-scope", {
|
|
5327
5592
|
header: e.getHeader("www-authenticate") ?? void 0,
|
|
5328
|
-
message:
|
|
5593
|
+
message: Ti(e.request.href, t.scope)
|
|
5329
5594
|
}), { kind: "out-of-scope" }) : { kind: "not-a-challenge" };
|
|
5330
|
-
let { challenge: r, diagnostics: i } = await
|
|
5331
|
-
if (
|
|
5595
|
+
let { challenge: r, diagnostics: i } = await Ci(e, t);
|
|
5596
|
+
if (xi(i, e, t), !r) {
|
|
5332
5597
|
let r = e.getHeader("www-authenticate");
|
|
5333
5598
|
return t.requireChallengeChannel !== "header" && n("no-channel", {
|
|
5334
5599
|
...r ? { header: r } : {},
|
|
@@ -5342,9 +5607,9 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5342
5607
|
method: e.request.method
|
|
5343
5608
|
}, s, c;
|
|
5344
5609
|
try {
|
|
5345
|
-
s = Promise.resolve(t.elevate(r, o)), c = await
|
|
5610
|
+
s = Promise.resolve(t.elevate(r, o)), c = await Oi(s, e.signal);
|
|
5346
5611
|
} catch (e) {
|
|
5347
|
-
return
|
|
5612
|
+
return Ei(e, void 0);
|
|
5348
5613
|
}
|
|
5349
5614
|
if (c.aborted) return s?.then((e) => e?.waiter.report({ outcome: "failed" }), () => {}), {
|
|
5350
5615
|
kind: "aborted",
|
|
@@ -5355,7 +5620,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5355
5620
|
kind: "aborted",
|
|
5356
5621
|
reason: e.signal.reason
|
|
5357
5622
|
};
|
|
5358
|
-
let u = l?.obtained ?? t.readObtainedBar?.() ??
|
|
5623
|
+
let u = l?.obtained ?? t.readObtainedBar?.() ?? ci(r), d = t.authorizationSwap?.(), f = d ? {
|
|
5359
5624
|
from: a?.from ?? d.from,
|
|
5360
5625
|
to: d.to
|
|
5361
5626
|
} : void 0;
|
|
@@ -5364,7 +5629,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5364
5629
|
try {
|
|
5365
5630
|
p = await e.replay(f ? { authorizationSwap: f } : void 0);
|
|
5366
5631
|
} catch (t) {
|
|
5367
|
-
if (t instanceof
|
|
5632
|
+
if (t instanceof mr) return l?.waiter.report({
|
|
5368
5633
|
outcome: "insufficient",
|
|
5369
5634
|
obtained: t.obtained,
|
|
5370
5635
|
required: t.required
|
|
@@ -5382,7 +5647,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5382
5647
|
};
|
|
5383
5648
|
throw t;
|
|
5384
5649
|
}
|
|
5385
|
-
let m = await
|
|
5650
|
+
let m = await Di(p, t, u, n);
|
|
5386
5651
|
return m.kind === "insufficient" ? l?.waiter.report({
|
|
5387
5652
|
outcome: "insufficient",
|
|
5388
5653
|
obtained: m.obtained,
|
|
@@ -5391,18 +5656,18 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5391
5656
|
outcome: "replayed",
|
|
5392
5657
|
obtained: u
|
|
5393
5658
|
}), m;
|
|
5394
|
-
},
|
|
5659
|
+
}, Ai = (e) => {
|
|
5395
5660
|
switch (e.kind) {
|
|
5396
|
-
case "cancelled": return new
|
|
5397
|
-
case "unsatisfiable": return new
|
|
5398
|
-
case "unavailable": return new
|
|
5399
|
-
case "session-changed": return new
|
|
5400
|
-
case "insufficient": return new
|
|
5661
|
+
case "cancelled": return new ri();
|
|
5662
|
+
case "unsatisfiable": return new ii();
|
|
5663
|
+
case "unavailable": return new hr();
|
|
5664
|
+
case "session-changed": return new gr();
|
|
5665
|
+
case "insufficient": return new mr(e.obtained, e.required);
|
|
5401
5666
|
case "exhausted": return e.error;
|
|
5402
5667
|
case "transport-failure": return e.error;
|
|
5403
5668
|
default: return;
|
|
5404
5669
|
}
|
|
5405
|
-
},
|
|
5670
|
+
}, ji = (e, t, n) => {
|
|
5406
5671
|
switch (e.kind) {
|
|
5407
5672
|
case "replayed": return {
|
|
5408
5673
|
settle: "resolve",
|
|
@@ -5420,21 +5685,21 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5420
5685
|
};
|
|
5421
5686
|
case "cancelled": return n.onCancel === "reject" ? {
|
|
5422
5687
|
settle: "reject",
|
|
5423
|
-
error: new
|
|
5688
|
+
error: new ri()
|
|
5424
5689
|
} : {
|
|
5425
5690
|
settle: "resolve",
|
|
5426
|
-
value:
|
|
5691
|
+
value: Bi(t, e)
|
|
5427
5692
|
};
|
|
5428
5693
|
case "insufficient": return {
|
|
5429
5694
|
settle: "resolve",
|
|
5430
|
-
value:
|
|
5695
|
+
value: Bi(e.response?.raw ?? t, e)
|
|
5431
5696
|
};
|
|
5432
5697
|
default: return {
|
|
5433
5698
|
settle: "resolve",
|
|
5434
|
-
value:
|
|
5699
|
+
value: Bi(t, e)
|
|
5435
5700
|
};
|
|
5436
5701
|
}
|
|
5437
|
-
},
|
|
5702
|
+
}, Mi = (e, t) => {
|
|
5438
5703
|
switch (e.kind) {
|
|
5439
5704
|
case "replayed": return e.response.rejected ? {
|
|
5440
5705
|
settle: "reject",
|
|
@@ -5449,39 +5714,39 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5449
5714
|
};
|
|
5450
5715
|
default: return {
|
|
5451
5716
|
settle: "reject",
|
|
5452
|
-
error:
|
|
5717
|
+
error: Ai(e) ?? t
|
|
5453
5718
|
};
|
|
5454
5719
|
}
|
|
5455
|
-
},
|
|
5720
|
+
}, Ni = /* @__PURE__ */ new WeakSet(), Pi = /* @__PURE__ */ new WeakSet(), Fi = /* @__PURE__ */ new WeakSet(), Ii = /* @__PURE__ */ new WeakSet(), Li = /* @__PURE__ */ new WeakSet(), Ri = /* @__PURE__ */ new WeakSet(), zi = /* @__PURE__ */ new WeakSet(), Bi = (e, t) => {
|
|
5456
5721
|
switch (t.kind) {
|
|
5457
5722
|
case "cancelled":
|
|
5458
|
-
|
|
5723
|
+
Ni.add(e);
|
|
5459
5724
|
break;
|
|
5460
5725
|
case "exhausted":
|
|
5461
|
-
|
|
5726
|
+
Pi.add(e);
|
|
5462
5727
|
break;
|
|
5463
5728
|
case "insufficient":
|
|
5464
|
-
|
|
5729
|
+
Fi.add(e);
|
|
5465
5730
|
break;
|
|
5466
5731
|
case "unsatisfiable":
|
|
5467
|
-
|
|
5732
|
+
Ii.add(e);
|
|
5468
5733
|
break;
|
|
5469
5734
|
case "unavailable":
|
|
5470
|
-
|
|
5735
|
+
Li.add(e);
|
|
5471
5736
|
break;
|
|
5472
5737
|
case "session-changed":
|
|
5473
|
-
|
|
5738
|
+
Ri.add(e);
|
|
5474
5739
|
break;
|
|
5475
|
-
case "transport-failure":
|
|
5740
|
+
case "transport-failure": zi.add(e);
|
|
5476
5741
|
}
|
|
5477
5742
|
return e;
|
|
5478
|
-
},
|
|
5743
|
+
}, Vi = (e) => Ni.has(e), Hi = (e) => Pi.has(e), Ui = (e) => Fi.has(e), Wi = (e) => Ii.has(e), Gi = (e) => Li.has(e), Ki = (e) => Ri.has(e), qi = (e) => zi.has(e), Ji = "https://passflow-relative.invalid", Yi = () => {
|
|
5479
5744
|
let e = globalThis, t = e.document?.baseURI;
|
|
5480
5745
|
if (typeof t == "string" && t !== "") return t;
|
|
5481
5746
|
let n = e.location?.href;
|
|
5482
|
-
return typeof n == "string" && n !== "" && n !== "about:blank" ? n :
|
|
5483
|
-
},
|
|
5484
|
-
let n = t ===
|
|
5747
|
+
return typeof n == "string" && n !== "" && n !== "about:blank" ? n : Ji;
|
|
5748
|
+
}, Xi = (e, t = Yi()) => {
|
|
5749
|
+
let n = t === Ji, r;
|
|
5485
5750
|
try {
|
|
5486
5751
|
r = new URL(t).origin;
|
|
5487
5752
|
} catch {
|
|
@@ -5507,28 +5772,28 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5507
5772
|
relativeToBase: !1,
|
|
5508
5773
|
sentinelBase: n
|
|
5509
5774
|
};
|
|
5510
|
-
},
|
|
5775
|
+
}, Zi = (e, t) => typeof t == "string" ? [e.toLowerCase(), t] : void 0, Qi = (e) => {
|
|
5511
5776
|
let t = [];
|
|
5512
5777
|
if (e == null) return Object.freeze(t);
|
|
5513
5778
|
let n = e;
|
|
5514
5779
|
if (typeof n.forEach == "function" && typeof n.entries == "function") return e.forEach((e, n) => {
|
|
5515
|
-
let r =
|
|
5780
|
+
let r = Zi(n, e);
|
|
5516
5781
|
r && t.push(r);
|
|
5517
5782
|
}), Object.freeze(t);
|
|
5518
5783
|
if (Array.isArray(e)) {
|
|
5519
5784
|
for (let n of e) if (Array.isArray(n) && n.length >= 2) {
|
|
5520
|
-
let e =
|
|
5785
|
+
let e = Zi(String(n[0]), n[1]);
|
|
5521
5786
|
e && t.push(e);
|
|
5522
5787
|
}
|
|
5523
5788
|
return Object.freeze(t);
|
|
5524
5789
|
}
|
|
5525
5790
|
if (typeof e == "object") for (let [n, r] of Object.entries(e)) {
|
|
5526
|
-
let e =
|
|
5791
|
+
let e = Zi(n, Array.isArray(r) ? r.join(", ") : r);
|
|
5527
5792
|
e && t.push(e);
|
|
5528
5793
|
}
|
|
5529
5794
|
return Object.freeze(t);
|
|
5530
|
-
},
|
|
5531
|
-
let t = e.base === void 0 ?
|
|
5795
|
+
}, $i = (e) => {
|
|
5796
|
+
let t = e.base === void 0 ? Xi(e.url) : Xi(e.url, e.base), n = {
|
|
5532
5797
|
raw: e.url,
|
|
5533
5798
|
href: t.href,
|
|
5534
5799
|
dispatchUrl: t.sentinelBase || !t.resolved ? e.url : t.href,
|
|
@@ -5537,29 +5802,29 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5537
5802
|
resolved: t.resolved,
|
|
5538
5803
|
relativeToBase: t.relativeToBase,
|
|
5539
5804
|
method: (e.method ?? "GET").toUpperCase(),
|
|
5540
|
-
headers:
|
|
5805
|
+
headers: Qi(e.headers),
|
|
5541
5806
|
bodyKind: e.bodyKind,
|
|
5542
5807
|
..."body" in e ? { body: e.body } : {}
|
|
5543
5808
|
};
|
|
5544
5809
|
return Object.freeze(n);
|
|
5545
|
-
},
|
|
5810
|
+
}, ea = (e, t) => {
|
|
5546
5811
|
if (!t || t.from === t.to) return e;
|
|
5547
5812
|
let n = !1, r = e.map(([e, r]) => e === "authorization" && r === t.from ? (n = !0, [e, t.to]) : [e, r]);
|
|
5548
5813
|
return n ? Object.freeze(r) : e;
|
|
5549
|
-
},
|
|
5814
|
+
}, ta = (e) => {
|
|
5550
5815
|
let t = {};
|
|
5551
5816
|
for (let [n, r] of e) t[n] = r;
|
|
5552
5817
|
return t;
|
|
5553
|
-
},
|
|
5818
|
+
}, na = /* @__PURE__ */ new Set([
|
|
5554
5819
|
"GET",
|
|
5555
5820
|
"HEAD",
|
|
5556
5821
|
"OPTIONS"
|
|
5557
|
-
]),
|
|
5822
|
+
]), ra = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.clone == "function" && "method" in e, ia = (e) => typeof e == "string" ? e : ra(e) ? e.url : String(e), aa = (e, t) => (t?.method ?? (ra(e) ? e.method : void 0) ?? "GET").toUpperCase(), oa = (e) => e == null ? "none" : typeof e == "string" ? "reusable" : typeof e.getReader == "function" ? "one-shot" : "reusable", sa = (e) => {
|
|
5558
5823
|
if (typeof e == "string") return e.length;
|
|
5559
5824
|
let t = e;
|
|
5560
5825
|
if (typeof t?.size == "number") return t.size;
|
|
5561
5826
|
if (typeof t?.byteLength == "number") return t.byteLength;
|
|
5562
|
-
},
|
|
5827
|
+
}, ca = (e, t, n) => e === void 0 || e === "always" ? !0 : e === "idempotent-only" ? na.has(t.method) : typeof e == "function" ? e(t) : !(e.maxBodyBytes !== void 0 && n !== void 0 && n > e.maxBodyBytes), la = (e, t, n, r, i) => ({
|
|
5563
5828
|
replayable: !1,
|
|
5564
5829
|
bodyKind: e,
|
|
5565
5830
|
reason: t,
|
|
@@ -5567,11 +5832,11 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5567
5832
|
forwardInit: i,
|
|
5568
5833
|
snapshot: r,
|
|
5569
5834
|
replay: () => Promise.reject(/* @__PURE__ */ Error(`This request cannot be replayed: ${t}`))
|
|
5570
|
-
}),
|
|
5835
|
+
}), ua = (e, t) => ta(ea(e.headers, t?.authorizationSwap)), da = (e) => {
|
|
5571
5836
|
if (!e || !("headers" in e)) return e;
|
|
5572
5837
|
let { headers: t, ...n } = e;
|
|
5573
5838
|
return n;
|
|
5574
|
-
},
|
|
5839
|
+
}, fa = (e, t) => t && "headers" in t && t.headers !== void 0 ? t.headers : ra(e) ? e.headers : void 0, pa = (e) => {
|
|
5575
5840
|
if (e === null || typeof e == "string") return e;
|
|
5576
5841
|
if (typeof FormData < "u" && e instanceof FormData) {
|
|
5577
5842
|
let t = new FormData();
|
|
@@ -5579,18 +5844,18 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5579
5844
|
return t;
|
|
5580
5845
|
}
|
|
5581
5846
|
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;
|
|
5582
|
-
},
|
|
5583
|
-
let r =
|
|
5847
|
+
}, ma = (e, t, n) => new Request(e, { headers: ua(t, n) }), ha = (e, t, n) => {
|
|
5848
|
+
let r = ia(e), i = aa(e, t), a = fa(e, t), o = (e, t) => $i({
|
|
5584
5849
|
url: r,
|
|
5585
5850
|
method: i,
|
|
5586
5851
|
headers: a,
|
|
5587
5852
|
bodyKind: e,
|
|
5588
5853
|
...t === void 0 ? {} : { body: t }
|
|
5589
5854
|
});
|
|
5590
|
-
if (
|
|
5855
|
+
if (ra(e)) {
|
|
5591
5856
|
if (e.body === null || e.body === void 0) {
|
|
5592
5857
|
let a = o("none");
|
|
5593
|
-
return
|
|
5858
|
+
return ca(n, {
|
|
5594
5859
|
url: r,
|
|
5595
5860
|
method: i,
|
|
5596
5861
|
bodyKind: "none"
|
|
@@ -5600,20 +5865,20 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5600
5865
|
forwardInput: e,
|
|
5601
5866
|
forwardInit: t,
|
|
5602
5867
|
snapshot: a,
|
|
5603
|
-
replay: (n, r) => n(
|
|
5604
|
-
} :
|
|
5868
|
+
replay: (n, r) => n(ma(e, a, r), da(t))
|
|
5869
|
+
} : la("none", "the replay policy refused this request", e, a, t);
|
|
5605
5870
|
}
|
|
5606
5871
|
let a = o("request-clone");
|
|
5607
|
-
if (!
|
|
5872
|
+
if (!ca(n, {
|
|
5608
5873
|
url: r,
|
|
5609
5874
|
method: i,
|
|
5610
5875
|
bodyKind: "request-clone"
|
|
5611
|
-
})) return
|
|
5876
|
+
})) return la("request-clone", "the replay policy refused this request", e, a, t);
|
|
5612
5877
|
let s;
|
|
5613
5878
|
try {
|
|
5614
5879
|
s = e.clone();
|
|
5615
5880
|
} catch {
|
|
5616
|
-
return
|
|
5881
|
+
return la("one-shot", "the Request body was already consumed and cannot be cloned", e, a, t);
|
|
5617
5882
|
}
|
|
5618
5883
|
return {
|
|
5619
5884
|
replayable: !0,
|
|
@@ -5621,17 +5886,17 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5621
5886
|
forwardInput: e,
|
|
5622
5887
|
forwardInit: t,
|
|
5623
5888
|
snapshot: a,
|
|
5624
|
-
replay: (e, n) => e(
|
|
5889
|
+
replay: (e, n) => e(ma(s, a, n), da(t))
|
|
5625
5890
|
};
|
|
5626
5891
|
}
|
|
5627
|
-
let s =
|
|
5628
|
-
if (s === "one-shot") return
|
|
5629
|
-
if (!
|
|
5892
|
+
let s = oa(t?.body);
|
|
5893
|
+
if (s === "one-shot") return la("one-shot", "a streaming request body is consumed by the first send", e, o("one-shot"), t);
|
|
5894
|
+
if (!ca(n, {
|
|
5630
5895
|
url: r,
|
|
5631
5896
|
method: i,
|
|
5632
5897
|
bodyKind: s
|
|
5633
|
-
},
|
|
5634
|
-
let c = t && "body" in t ?
|
|
5898
|
+
}, sa(t?.body))) return la(s, "the replay policy refused this request", e, o(s), t);
|
|
5899
|
+
let c = t && "body" in t ? pa(t.body ?? null) : void 0, l = o(s, c);
|
|
5635
5900
|
return {
|
|
5636
5901
|
replayable: !0,
|
|
5637
5902
|
bodyKind: s,
|
|
@@ -5639,21 +5904,21 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5639
5904
|
forwardInit: t,
|
|
5640
5905
|
snapshot: l,
|
|
5641
5906
|
replay: (e, n) => e(l.dispatchUrl, {
|
|
5642
|
-
...
|
|
5907
|
+
...da(t),
|
|
5643
5908
|
...c === void 0 ? {} : { body: c },
|
|
5644
|
-
headers:
|
|
5909
|
+
headers: ua(l, n),
|
|
5645
5910
|
method: l.method
|
|
5646
5911
|
})
|
|
5647
5912
|
};
|
|
5648
|
-
},
|
|
5649
|
-
if (!
|
|
5913
|
+
}, ga = (e) => typeof e == "object" && !!e, _a = (e) => (t) => {
|
|
5914
|
+
if (!ga(e)) return;
|
|
5650
5915
|
let n = e[t] ?? e[t.toLowerCase()] ?? (typeof e.get == "function" ? e.get(t) : void 0);
|
|
5651
5916
|
return Array.isArray(n) ? n.join(", ") : typeof n == "string" ? n : void 0;
|
|
5652
|
-
},
|
|
5917
|
+
}, va = (e) => {
|
|
5653
5918
|
let t = e?.url ?? "", n = e?.baseURL;
|
|
5654
5919
|
return !n || /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : `${n.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
5655
|
-
},
|
|
5656
|
-
let r =
|
|
5920
|
+
}, ya = (e) => (e?.method ?? "GET").toUpperCase(), ba = (e) => e == null ? "none" : ga(e) && (typeof e.pipe == "function" || typeof e.getReader == "function") ? "one-shot" : "reusable", xa = (e, t, n) => {
|
|
5921
|
+
let r = ta(ea(t.headers, n?.authorizationSwap)), i = t.dispatchUrl === t.href && t.resolved;
|
|
5657
5922
|
return {
|
|
5658
5923
|
...e,
|
|
5659
5924
|
...i ? { baseURL: void 0 } : {},
|
|
@@ -5662,10 +5927,10 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5662
5927
|
headers: r,
|
|
5663
5928
|
..."body" in t ? { data: t.body } : {}
|
|
5664
5929
|
};
|
|
5665
|
-
},
|
|
5666
|
-
let o = t ?? e?.config, s =
|
|
5667
|
-
url:
|
|
5668
|
-
method:
|
|
5930
|
+
}, Sa = (e, t, n, r, i, a) => {
|
|
5931
|
+
let o = t ?? e?.config, s = ba(o?.data), c = a ?? $i({
|
|
5932
|
+
url: va(o),
|
|
5933
|
+
method: ya(o),
|
|
5669
5934
|
headers: o?.headers,
|
|
5670
5935
|
bodyKind: s,
|
|
5671
5936
|
body: o?.data
|
|
@@ -5673,22 +5938,22 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5673
5938
|
url: c.href,
|
|
5674
5939
|
method: c.method,
|
|
5675
5940
|
bodyKind: s
|
|
5676
|
-
}, u = s !== "one-shot" &&
|
|
5941
|
+
}, u = s !== "one-shot" && ca(i.replay, l);
|
|
5677
5942
|
return {
|
|
5678
5943
|
status: e?.status ?? 0,
|
|
5679
|
-
getHeader:
|
|
5944
|
+
getHeader: _a(e?.headers),
|
|
5680
5945
|
readBody: async () => e?.data,
|
|
5681
5946
|
request: c,
|
|
5682
5947
|
replay: async (e) => {
|
|
5683
|
-
let t = Te(
|
|
5948
|
+
let t = Te(xa(o ?? {}, c, e));
|
|
5684
5949
|
try {
|
|
5685
5950
|
let e = await r(t);
|
|
5686
|
-
return
|
|
5951
|
+
return Sa(e, e?.config ?? t, e, r, i, c);
|
|
5687
5952
|
} catch (e) {
|
|
5688
|
-
let n =
|
|
5689
|
-
if (!n.response || typeof n.response.status != "number" ||
|
|
5953
|
+
let n = ga(e) ? e : {};
|
|
5954
|
+
if (!n.response || typeof n.response.status != "number" || or(e)) throw e;
|
|
5690
5955
|
return {
|
|
5691
|
-
...
|
|
5956
|
+
...Sa(n.response, n.config ?? t, e, r, i, c),
|
|
5692
5957
|
rejected: !0
|
|
5693
5958
|
};
|
|
5694
5959
|
}
|
|
@@ -5702,19 +5967,19 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5702
5967
|
replayUnsupportedReason: s === "one-shot" ? "a streaming request body is consumed by the first send" : "the replay policy refused this request",
|
|
5703
5968
|
signal: o?.signal
|
|
5704
5969
|
};
|
|
5705
|
-
},
|
|
5706
|
-
let r =
|
|
5970
|
+
}, Ca = (e, t) => async (n) => {
|
|
5971
|
+
let r = pi(e), i = ga(n) ? n : {}, a = Mi(await ki(Sa(i.response, i.config, i.response, t, r), r), n);
|
|
5707
5972
|
if (a.settle === "reject") throw a.error;
|
|
5708
5973
|
return a.value;
|
|
5709
|
-
},
|
|
5710
|
-
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,
|
|
5974
|
+
}, wa = (e, t, n) => {
|
|
5975
|
+
let r = e.request, i = n ?? (typeof r == "function" ? (t) => r.call(e, t) : () => Promise.reject(/* @__PURE__ */ Error("Passflow: this client exposes no request() to replay through."))), a = e.interceptors.response.use(void 0, Ca(t, i)), o = !1;
|
|
5711
5976
|
return () => {
|
|
5712
5977
|
o || (o = !0, e.interceptors.response.eject(a));
|
|
5713
5978
|
};
|
|
5714
|
-
},
|
|
5979
|
+
}, Ta = (t, n) => {
|
|
5715
5980
|
let r = e.create(t);
|
|
5716
5981
|
return n(r), r;
|
|
5717
|
-
},
|
|
5982
|
+
}, Ea = 0, Da = (e, t) => {
|
|
5718
5983
|
let n = t?.signal ?? (typeof e == "object" && e ? e.signal : void 0) ?? void 0;
|
|
5719
5984
|
if (n) return {
|
|
5720
5985
|
get aborted() {
|
|
@@ -5728,34 +5993,34 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5728
5993
|
removeEventListener: (e, t) => n.removeEventListener(e, t)
|
|
5729
5994
|
} : {}
|
|
5730
5995
|
};
|
|
5731
|
-
},
|
|
5996
|
+
}, Oa = (e) => (t) => e.headers?.get(t), ka = (e, t, n, r, i) => ({
|
|
5732
5997
|
status: e.status,
|
|
5733
|
-
getHeader:
|
|
5998
|
+
getHeader: Oa(e),
|
|
5734
5999
|
readBody: () => e.clone().json(),
|
|
5735
6000
|
request: t.snapshot,
|
|
5736
|
-
replay: async (e) =>
|
|
6001
|
+
replay: async (e) => ka(await t.replay(n, e), t, n, r, i),
|
|
5737
6002
|
markers: r,
|
|
5738
6003
|
raw: e,
|
|
5739
6004
|
replayable: t.replayable,
|
|
5740
6005
|
replayUnsupportedReason: t.reason,
|
|
5741
6006
|
signal: i,
|
|
5742
6007
|
responseType: e.type
|
|
5743
|
-
}),
|
|
6008
|
+
}), Aa = (e, t) => {
|
|
5744
6009
|
let n = (t, n) => {
|
|
5745
|
-
|
|
6010
|
+
Ea += 1;
|
|
5746
6011
|
try {
|
|
5747
6012
|
return e(t, n);
|
|
5748
6013
|
} finally {
|
|
5749
|
-
--
|
|
6014
|
+
--Ea;
|
|
5750
6015
|
}
|
|
5751
6016
|
};
|
|
5752
6017
|
return async (e, r) => {
|
|
5753
|
-
if (
|
|
5754
|
-
let i =
|
|
6018
|
+
if (Ea > 0) return n(e, r);
|
|
6019
|
+
let i = pi(t), a = ha(e, r, i.replay), o = await n(a.forwardInput, a.forwardInit), s = ji(await ki(ka(o, a, n, {}, Da(e, r)), i), o, i);
|
|
5755
6020
|
if (s.settle === "reject") throw s.error;
|
|
5756
6021
|
return s.value;
|
|
5757
6022
|
};
|
|
5758
|
-
},
|
|
6023
|
+
}, ja = new Set(Xr.filter((e) => !e.requiresPrepare).map((e) => e.type)), Ma = (e) => {
|
|
5759
6024
|
if (!e || typeof e != "object" || !e.challenge_id || !e.expires_at) throw new $({
|
|
5760
6025
|
kind: "protocol",
|
|
5761
6026
|
message: "The upgrade start response is missing challenge_id or expires_at"
|
|
@@ -5767,17 +6032,17 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5767
6032
|
webauthn: e.webauthn,
|
|
5768
6033
|
codeSentTo: e.code_sent_to
|
|
5769
6034
|
};
|
|
5770
|
-
},
|
|
6035
|
+
}, Na = (e) => or(e) && !sr(e), Pa = (e) => ({
|
|
5771
6036
|
async prepare(t) {
|
|
5772
|
-
if (!
|
|
6037
|
+
if (!ja.has(t)) try {
|
|
5773
6038
|
let n = e.relyingPartyId?.();
|
|
5774
|
-
return
|
|
6039
|
+
return Ma(await e.startUpgrade(n ? {
|
|
5775
6040
|
method: t,
|
|
5776
6041
|
relying_party_id: n
|
|
5777
6042
|
} : { method: t }));
|
|
5778
6043
|
} catch (e) {
|
|
5779
|
-
if (
|
|
5780
|
-
let t =
|
|
6044
|
+
if (Na(e)) throw e;
|
|
6045
|
+
let t = dr(e, "start");
|
|
5781
6046
|
if (t.kind === "prepare_not_required") return;
|
|
5782
6047
|
throw t;
|
|
5783
6048
|
}
|
|
@@ -5794,17 +6059,17 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5794
6059
|
assertion: n
|
|
5795
6060
|
});
|
|
5796
6061
|
} catch (t) {
|
|
5797
|
-
if (
|
|
5798
|
-
let n =
|
|
5799
|
-
throw n.status === 401 &&
|
|
6062
|
+
if (Na(t)) throw t;
|
|
6063
|
+
let n = dr(t, "refresh");
|
|
6064
|
+
throw n.status === 401 && pr(n) && e.markSessionInvalid?.(), n;
|
|
5800
6065
|
}
|
|
5801
6066
|
}
|
|
5802
|
-
}),
|
|
6067
|
+
}), Fa = (e) => e === void 0 ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e !== ""), Ia = (e) => {
|
|
5803
6068
|
let t, n = (e) => e !== void 0 && t === e, r = (r) => {
|
|
5804
6069
|
let i = () => {
|
|
5805
6070
|
if (!n(r())) throw new $({ kind: "session_changed" });
|
|
5806
6071
|
};
|
|
5807
|
-
return
|
|
6072
|
+
return Pa({
|
|
5808
6073
|
...e,
|
|
5809
6074
|
relyingPartyId: () => t?.options.relyingPartyId ?? e.relyingPartyId?.(),
|
|
5810
6075
|
startUpgrade: (t) => (i(), e.startUpgrade(t)),
|
|
@@ -5815,7 +6080,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5815
6080
|
});
|
|
5816
6081
|
}, i = (t, n) => {
|
|
5817
6082
|
let i = {}, a = {
|
|
5818
|
-
controller: new
|
|
6083
|
+
controller: new fi({
|
|
5819
6084
|
transport: r(() => i.current),
|
|
5820
6085
|
prompt: t.prompt,
|
|
5821
6086
|
platform: e.platform,
|
|
@@ -5827,17 +6092,17 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5827
6092
|
options: t,
|
|
5828
6093
|
scope: {
|
|
5829
6094
|
passflow: e.passflowDomain,
|
|
5830
|
-
backend:
|
|
6095
|
+
backend: Fa(t.backend)
|
|
5831
6096
|
},
|
|
5832
6097
|
generation: n
|
|
5833
6098
|
};
|
|
5834
6099
|
return i.current = a, a;
|
|
5835
6100
|
}, a = async (r, i) => {
|
|
5836
6101
|
let a = t;
|
|
5837
|
-
if (!a) throw new
|
|
6102
|
+
if (!a) throw new hr("Step-up verification is not enabled on this Passflow instance");
|
|
5838
6103
|
a.controller.active || (a.pin = e.readSessionPin?.());
|
|
5839
6104
|
let o = await a.controller.elevate(r, i);
|
|
5840
|
-
if (!n(a)) throw new
|
|
6105
|
+
if (!n(a)) throw new gr();
|
|
5841
6106
|
return o;
|
|
5842
6107
|
}, o = () => {
|
|
5843
6108
|
let n = t, r = n?.scope ?? {
|
|
@@ -5881,9 +6146,9 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5881
6146
|
let r = [];
|
|
5882
6147
|
if (e.attachInternalSeam) {
|
|
5883
6148
|
let t = e.attachInternalSeam;
|
|
5884
|
-
t((e) =>
|
|
6149
|
+
t((e) => Ca(o, e)), r.push(() => t(void 0));
|
|
5885
6150
|
}
|
|
5886
|
-
n.interceptFetch && r.push(
|
|
6151
|
+
n.interceptFetch && r.push(xt((e, t, n) => Aa(e, o)(t, n), {
|
|
5887
6152
|
priority: 20,
|
|
5888
6153
|
name: "passflow-upgrade"
|
|
5889
6154
|
})), e.onSessionChange && r.push(e.onSessionChange(() => {
|
|
@@ -5914,18 +6179,18 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5914
6179
|
withAuth: {
|
|
5915
6180
|
enumerable: !0,
|
|
5916
6181
|
value: (e) => {
|
|
5917
|
-
if (e) return
|
|
6182
|
+
if (e) return Aa(e, o);
|
|
5918
6183
|
let t = typeof globalThis > "u" ? void 0 : globalThis;
|
|
5919
6184
|
if (!t || typeof t.fetch != "function") throw Error("Passflow: withAuth() needs a fetch to wrap — this runtime has none.");
|
|
5920
|
-
return
|
|
6185
|
+
return Aa(t.fetch.bind(t), o);
|
|
5921
6186
|
}
|
|
5922
6187
|
},
|
|
5923
6188
|
attachAuth: {
|
|
5924
6189
|
enumerable: !0,
|
|
5925
|
-
value: (e) =>
|
|
6190
|
+
value: (e) => wa(e, o)
|
|
5926
6191
|
}
|
|
5927
6192
|
});
|
|
5928
|
-
},
|
|
6193
|
+
}, La, Ra = class {
|
|
5929
6194
|
get origin() {
|
|
5930
6195
|
return this.platform.getCurrentUrl()?.origin ?? "";
|
|
5931
6196
|
}
|
|
@@ -5934,12 +6199,12 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5934
6199
|
this.createSessionCallback = e, this.expiredSessionCallback = t, this.doRefreshTokens = n, await this.submitSessionCheck();
|
|
5935
6200
|
};
|
|
5936
6201
|
let { url: t, appId: n, scopes: r } = e;
|
|
5937
|
-
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? P, this.storageManager = new N({
|
|
6202
|
+
this.url = t || "https://auth.passflow.cloud", this.appId = n, this.platform = e.platform ?? P, this.deferFederatedLanding = e.deferFederatedLanding ?? !1, this.storageManager = new N({
|
|
5938
6203
|
prefix: e.keyStoragePrefix ?? "",
|
|
5939
6204
|
storage: this.platform.storage
|
|
5940
|
-
}), this.deviceService = new re(this.storageManager), this.authApi = new
|
|
5941
|
-
let i =
|
|
5942
|
-
this.authService = new
|
|
6205
|
+
}), this.deviceService = new re(this.storageManager), this.authApi = new Qe(e, this.storageManager, this.deviceService), this.appApi = new Ke(e, this.storageManager, this.deviceService), this.userApi = new st(e, this.storageManager, this.deviceService), this.settingApi = new tt(e, this.storageManager, this.deviceService), this.tenantApi = new nt(e, this.storageManager, this.deviceService), this.invitationApi = new et(e, this.storageManager, this.deviceService), this.twoFactorApi = new at(e, this.storageManager, this.deviceService), this.upgradeApi = new ot(e, this.storageManager, this.deviceService), this.upgradeDomain = ke(e.url), this.subscribeStore = new $n(), this.tokenCacheService = new Hr(this.storageManager, this.authApi, this.subscribeStore, this.platform), this.scopes = r ?? u, this.createTenantForNewUser = e.createTenantForNewUser ?? !1;
|
|
6206
|
+
let i = fn(e.refreshCoordination, this.platform, e.keyStoragePrefix, { tokenKeys: () => this.storageManager.tokenKeys() });
|
|
6207
|
+
this.authService = new Rr(this.authApi, this.deviceService, this.storageManager, this.subscribeStore, this.tokenCacheService, this.scopes, this.createTenantForNewUser, this.url, {
|
|
5943
6208
|
createSession: this.createSessionCallback,
|
|
5944
6209
|
expiredSession: this.expiredSessionCallback
|
|
5945
6210
|
}, this.appId ?? "", e.tokenExchange, this.platform, () => this.readPkceEnabled(), {
|
|
@@ -5947,7 +6212,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5947
6212
|
...e.refreshStrikes === void 0 ? {} : { strikes: e.refreshStrikes }
|
|
5948
6213
|
}), this.tokenCacheService.attachRefreshController(this.authService.refresh);
|
|
5949
6214
|
for (let e of this.axiosClients()) e.setRefreshHandler((e) => this.authService.refresh.ensureFresh(e));
|
|
5950
|
-
this.userService = new
|
|
6215
|
+
this.userService = new Wr(this.userApi, this.deviceService, this.platform), this.tenantService = new Vr(this.tenantApi, this.scopes), this.tenant = this.tenantService, this.invitationService = new zr(this.invitationApi), this.twoFactorService = new Ur(this.twoFactorApi, this.subscribeStore, this.authService), this.twoFactor = this.twoFactorService, this.upgrade = Ia({
|
|
5951
6216
|
startUpgrade: (e) => this.upgradeApi.startUpgrade(e),
|
|
5952
6217
|
commitRefresh: async (e, t) => {
|
|
5953
6218
|
await this.authService.refreshToken(e, t);
|
|
@@ -5994,7 +6259,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
5994
6259
|
return this.upgrade.attachAuth(e);
|
|
5995
6260
|
}
|
|
5996
6261
|
createClient(e) {
|
|
5997
|
-
return
|
|
6262
|
+
return Ta(e, (e) => this.upgrade.attachAuth(e));
|
|
5998
6263
|
}
|
|
5999
6264
|
readAssuranceBar() {
|
|
6000
6265
|
let e = this.storageManager.getToken(j.access_token);
|
|
@@ -6046,7 +6311,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6046
6311
|
message: t instanceof Error || t instanceof B ? t.message : "Session check failed",
|
|
6047
6312
|
originalError: t
|
|
6048
6313
|
};
|
|
6049
|
-
|
|
6314
|
+
W(this.subscribeStore, n), e = void 0;
|
|
6050
6315
|
}
|
|
6051
6316
|
e && this.createSessionCallback && await this.createSessionCallback({
|
|
6052
6317
|
tokens: e,
|
|
@@ -6062,6 +6327,9 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6062
6327
|
handleTokensRedirect() {
|
|
6063
6328
|
return this.checkAndSetTokens();
|
|
6064
6329
|
}
|
|
6330
|
+
completeFederatedLanding() {
|
|
6331
|
+
return this.takeFederatedLanding();
|
|
6332
|
+
}
|
|
6065
6333
|
checkAndSetTokens() {
|
|
6066
6334
|
let e = this.platform.getCurrentUrl(), t = new URLSearchParams(e?.search ?? ""), n = !1;
|
|
6067
6335
|
if (!t.get("access_token") && e?.hash) {
|
|
@@ -6074,24 +6342,24 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6074
6342
|
}
|
|
6075
6343
|
let r = t.get("access_token"), i = t.get("refresh_token"), a = t.get("id_token"), o = t.get("scopes")?.split(",") ?? this.scopes, s;
|
|
6076
6344
|
if (r) {
|
|
6077
|
-
if (!
|
|
6078
|
-
|
|
6345
|
+
if (!yr(r)) {
|
|
6346
|
+
W(this.subscribeStore, {
|
|
6079
6347
|
operation: "tokens.from-url",
|
|
6080
6348
|
message: "Invalid access token format received",
|
|
6081
6349
|
code: "INVALID_TOKEN_FORMAT"
|
|
6082
6350
|
}), this.cleanupUrlParams(n, e);
|
|
6083
6351
|
return;
|
|
6084
6352
|
}
|
|
6085
|
-
if (i && !
|
|
6086
|
-
|
|
6353
|
+
if (i && !yr(i)) {
|
|
6354
|
+
W(this.subscribeStore, {
|
|
6087
6355
|
operation: "tokens.from-url",
|
|
6088
6356
|
message: "Invalid refresh token format received",
|
|
6089
6357
|
code: "INVALID_TOKEN_FORMAT"
|
|
6090
6358
|
}), this.cleanupUrlParams(n, e);
|
|
6091
6359
|
return;
|
|
6092
6360
|
}
|
|
6093
|
-
if (a && !
|
|
6094
|
-
|
|
6361
|
+
if (a && !yr(a)) {
|
|
6362
|
+
W(this.subscribeStore, {
|
|
6095
6363
|
operation: "tokens.from-url",
|
|
6096
6364
|
message: "Invalid ID token format received",
|
|
6097
6365
|
code: "INVALID_TOKEN_FORMAT"
|
|
@@ -6108,7 +6376,16 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6108
6376
|
parsedTokens: this.getParsedTokens()
|
|
6109
6377
|
}), this.submitSessionCheck(), this.cleanupUrlParams(n, e), this.error = void 0, s;
|
|
6110
6378
|
}
|
|
6111
|
-
this.error = this.checkErrorsFromURL();
|
|
6379
|
+
this.deferFederatedLanding || this.takeFederatedLanding(), this.error = this.checkErrorsFromURL();
|
|
6380
|
+
}
|
|
6381
|
+
takeFederatedLanding() {
|
|
6382
|
+
let e = this.platform.getCurrentUrl();
|
|
6383
|
+
if (!e) return !1;
|
|
6384
|
+
let t = new URLSearchParams(e.search), n = t.get("code");
|
|
6385
|
+
if (t.get("access_token") || new URLSearchParams(e.hash?.substring(1)).get("access_token") || !n || !t.get("user_state") || !this.authService.handleFederatedCode(n)) return !1;
|
|
6386
|
+
t.delete("code"), t.delete("user_state");
|
|
6387
|
+
let r = t.toString();
|
|
6388
|
+
return this.platform.replaceUrl(e.pathname + (r ? `?${r}` : "") + e.hash), !0;
|
|
6112
6389
|
}
|
|
6113
6390
|
adoptTwoFactorTokenFromUrl(e) {
|
|
6114
6391
|
if (!e?.hash) return !1;
|
|
@@ -6116,11 +6393,11 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6116
6393
|
if (!n) return !1;
|
|
6117
6394
|
t.delete("tfa_token");
|
|
6118
6395
|
let r = t.toString();
|
|
6119
|
-
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")),
|
|
6396
|
+
return this.platform.replaceUrl(e.pathname + e.search + (r ? `#${r}` : "")), yr(n) ? (this.subscribeStore.notify(Z.TwoFactorRequired, {
|
|
6120
6397
|
email: "",
|
|
6121
6398
|
challengeId: "",
|
|
6122
6399
|
tfaToken: n
|
|
6123
|
-
}), !0) : (
|
|
6400
|
+
}), !0) : (W(this.subscribeStore, {
|
|
6124
6401
|
operation: "tokens.from-url",
|
|
6125
6402
|
message: "Invalid 2FA token format received",
|
|
6126
6403
|
code: "INVALID_TOKEN_FORMAT"
|
|
@@ -6129,7 +6406,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6129
6406
|
checkErrorsFromURL() {
|
|
6130
6407
|
let e = new URLSearchParams(this.platform.getCurrentUrl()?.search ?? "").get("error");
|
|
6131
6408
|
if (e) {
|
|
6132
|
-
let t =
|
|
6409
|
+
let t = br(e);
|
|
6133
6410
|
return Error(t);
|
|
6134
6411
|
}
|
|
6135
6412
|
}
|
|
@@ -6190,6 +6467,18 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6190
6467
|
async passwordlessSignInComplete(e) {
|
|
6191
6468
|
return await this.authService.passwordlessSignInComplete(e);
|
|
6192
6469
|
}
|
|
6470
|
+
waitForPasswordlessSignIn(e, t) {
|
|
6471
|
+
return this.authService.waitForPasswordlessSignIn(e, t);
|
|
6472
|
+
}
|
|
6473
|
+
getPendingPasswordlessSignIn(e) {
|
|
6474
|
+
return this.authService.getPendingPasswordlessSignIn(e);
|
|
6475
|
+
}
|
|
6476
|
+
getPasswordlessApproval(e) {
|
|
6477
|
+
return this.authService.getPasswordlessApproval(e);
|
|
6478
|
+
}
|
|
6479
|
+
decidePasswordlessApproval(e, t, n, r) {
|
|
6480
|
+
return this.authService.decidePasswordlessApproval(e, t, n, r);
|
|
6481
|
+
}
|
|
6193
6482
|
async verifyEmailCode(e) {
|
|
6194
6483
|
return await this.authService.verifyEmailCode(e);
|
|
6195
6484
|
}
|
|
@@ -6200,7 +6489,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6200
6489
|
originalError: e,
|
|
6201
6490
|
code: e instanceof B ? e.id : void 0
|
|
6202
6491
|
};
|
|
6203
|
-
throw
|
|
6492
|
+
throw W(this.subscribeStore, r), e;
|
|
6204
6493
|
}
|
|
6205
6494
|
async logOut() {
|
|
6206
6495
|
try {
|
|
@@ -6224,7 +6513,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6224
6513
|
message: e,
|
|
6225
6514
|
code: "RESET_ERROR"
|
|
6226
6515
|
};
|
|
6227
|
-
throw
|
|
6516
|
+
throw W(this.subscribeStore, t), this.error;
|
|
6228
6517
|
}
|
|
6229
6518
|
}
|
|
6230
6519
|
notifySignedOut(e) {
|
|
@@ -6473,7 +6762,7 @@ var vr = "passflow_2fa_pkce", yr = 3e5, br = 10, xr = "The sign-in answered with
|
|
|
6473
6762
|
this.twoFactorService.clearMagicLinkSession();
|
|
6474
6763
|
}
|
|
6475
6764
|
};
|
|
6476
|
-
|
|
6477
|
-
export { i as APP_ID_HEADER_KEY, a as AUTHORIZATION_HEADER_KEY,
|
|
6765
|
+
La = Ra, La.version = c;
|
|
6766
|
+
export { i as APP_ID_HEADER_KEY, Me as APP_SECRET_NAMES, a as AUTHORIZATION_HEADER_KEY, Ke as AppAPI, Qe as AuthAPI, Rr as AuthService, $e as CLIAuthAPI, f as DEFAULT_GROUP_NAME, u as DEFAULT_SCOPES, Xr as DEFAULT_UPGRADE_FACTORS, o as DEVICE_ID_HEADER_KEY, s as DEVICE_TYPE_HEADER_KEY, b as ERROR_MESSAGE_MAX_LENGTH, ct as FETCH_PRIORITY_OIDC, lt as FETCH_PRIORITY_UPGRADE, ut as FetchMiddlewareContractError, ce as INSUFFICIENT_USER_AUTHENTICATION, et as InvitationAPI, zr as InvitationService, At as M2MClient, Tt as M2MConfigError, U as M2MError, Et as M2MErrorCodes, Ct as M2MNetworkError, wt as M2MTokenParseError, Dt as M2M_DEFAULTS, Ne as MASKED_SECRET_PREFIX, l as MINIMAL_DEFAULT_SCOPES, Ie as OS, d as PASSFLOW_CLOUD_URL, m as POPUP_HEIGHT, h as POPUP_POLL_INTERVAL_MS, g as POPUP_TIMEOUT_MS, p as POPUP_WIDTH, Ra as Passflow, Oe as PassflowAdminEndpointPaths, z as PassflowEndpointPaths, B as PassflowError, Z as PassflowEvent, J as PassflowRefreshError, ie as PopupClosedError, je as Providers, er as RECOVERABLE_COMMIT_ERROR_IDS, xn as REFRESH_AUTH_FAILURE_IDS, q as RefreshErrorId, De as RequestMethod, c as SDK_VERSION, tr as SESSION_INVALIDATING_COMMIT_ERROR_IDS, Pe as SETTINGS_MASKED_VALUE_UNKNOWN_ERROR_ID, te as SessionState, tt as SettingAPI, _ as TOKEN_EXPIRY_BUFFER_SECONDS, nt as TenantAPI, Vr as TenantService, Br as TenantUserMembership, Hr as TokenCacheService, M as TokenDeliveryMode, j as TokenType, at as TwoFactorApiClient, Re as TwoFactorPolicy, Ur as TwoFactorService, le as UPGRADE_REQUIRED, y as USERNAME_MAX_LENGTH, v as USERNAME_MIN_LENGTH, ot as UpgradeAPI, ri as UpgradeCancelledError, Nn as UpgradeCommitInterruptedError, fi as UpgradeController, Q as UpgradeErrorIds, Gr as UpgradeFactorError, mr as UpgradeInsufficientError, gr as UpgradeSessionChangedError, $ as UpgradeTransportError, hr as UpgradeUnavailableError, ii as UpgradeUnsatisfiableError, st as UserAPI, Wr as UserService, ae as WebAdapter, dr as classifyUpgradeError, Zr as factorRegistry, St as fetchRegistryState, Le as getOSFromDeviceType, pr as invalidatesSessionOnCommit, Ae as isEmailVerificationStep, Fe as isMaskedSecret, fr as isRecoverableCommitFailure, rr as isRetryableUpgradeKind, k as isTokenExpired, Vi as isUpgradeCancelled, Hi as isUpgradeExhausted, Ui as isUpgradeInsufficient, Ki as isUpgradeSessionChanged, sr as isUpgradeTransportError, qi as isUpgradeTransportFailure, Gi as isUpgradeUnavailable, Wi as isUpgradeUnsatisfiable, xr as isValidEmail, yr as isValidJWTFormat, Sr as isValidPhoneNumber, Cr as isValidUsername, he as parseChallengeBody, me as parseChallengeHeader, A as parseToken, ye as parseUpgradeChallenge, Yr as passkeyFactor, V as pathWithParams, Jr as recoveryCodesFactor, xt as registerFetchMiddleware, L as requiredAcrLevel, ke as resolveUpgradeDomain, br as sanitizeErrorMessage, ni as selectFactors, qr as totpFactor, P as webAdapter };
|
|
6478
6767
|
|
|
6479
6768
|
//# sourceMappingURL=index.mjs.map
|