@axa-fr/oidc-client 7.29.4 → 7.29.5
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/dist/cache.d.ts.map +1 -1
- package/dist/cache.spec.d.ts +2 -0
- package/dist/cache.spec.d.ts.map +1 -0
- package/dist/index.js +160 -174
- package/dist/index.umd.cjs +2 -2
- package/dist/parseTokens.d.ts.map +1 -1
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.form.spec.d.ts +2 -0
- package/dist/requests.form.spec.d.ts.map +1 -0
- package/dist/route-utils.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/cache.spec.ts +118 -0
- package/src/cache.ts +11 -16
- package/src/parseTokens.spec.ts +59 -1
- package/src/parseTokens.ts +2 -9
- package/src/requests.form.spec.ts +139 -0
- package/src/requests.ts +13 -28
- package/src/route-utils.spec.ts +56 -1
- package/src/route-utils.ts +13 -23
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -643,7 +643,7 @@ var he = () => {
|
|
|
643
643
|
r.service_worker_relative_url && t.publishEvent(e.service_worker_not_supported_by_browser, { message: "service worker is not supported by this browser" });
|
|
644
644
|
let n = i(t.configurationName, r.storage ?? sessionStorage, r.login_state_storage ?? r.storage ?? sessionStorage), { tokens: o } = await n.initAsync();
|
|
645
645
|
if (o) {
|
|
646
|
-
t.tokens =
|
|
646
|
+
t.tokens = at(o, null, r.token_renew_mode);
|
|
647
647
|
let i = n.getLoginParams();
|
|
648
648
|
t.timeoutId = W(t, t.tokens.expiresAt, i.extras, i.scope);
|
|
649
649
|
let s = await n.getSessionStateAsync();
|
|
@@ -708,24 +708,21 @@ var he = () => {
|
|
|
708
708
|
let n = t.getItem(e);
|
|
709
709
|
n && (I[e] = JSON.parse(n));
|
|
710
710
|
}
|
|
711
|
-
let r = 1e3 * n;
|
|
712
|
-
return
|
|
711
|
+
let r = I[e], i = 1e3 * n;
|
|
712
|
+
return r && r.timestamp + i > Date.now() ? r.result : null;
|
|
713
713
|
}, Se = (e, t, n = window.sessionStorage) => {
|
|
714
|
-
let r =
|
|
715
|
-
I[e] = {
|
|
716
|
-
result: t,
|
|
717
|
-
timestamp: r
|
|
718
|
-
}, n && n.setItem(e, JSON.stringify({
|
|
714
|
+
let r = {
|
|
719
715
|
result: t,
|
|
720
|
-
timestamp:
|
|
721
|
-
}
|
|
716
|
+
timestamp: Date.now()
|
|
717
|
+
};
|
|
718
|
+
I[e] = r, n && n.setItem(e, JSON.stringify(r));
|
|
722
719
|
}, Ce = 3600, we = (e) => async (t, n = Ce, r = window.sessionStorage, i = 1e4) => {
|
|
723
720
|
let a = `${t}/.well-known/openid-configuration`, o = `oidc.server:${t}`, s = xe(o, r, n);
|
|
724
|
-
if (s) return new
|
|
721
|
+
if (s) return new Je(s);
|
|
725
722
|
let c = await L(e)(a, {}, i);
|
|
726
723
|
if (c.status !== 200) return null;
|
|
727
724
|
let l = await c.json();
|
|
728
|
-
return Se(o, l, r), new
|
|
725
|
+
return Se(o, l, r), new Je(l);
|
|
729
726
|
}, L = (e) => async (t, n = {}, r = 1e4, i = 0) => {
|
|
730
727
|
let a;
|
|
731
728
|
try {
|
|
@@ -749,60 +746,54 @@ var he = () => {
|
|
|
749
746
|
}, Te = {
|
|
750
747
|
refresh_token: "refresh_token",
|
|
751
748
|
access_token: "access_token"
|
|
752
|
-
}, Ee = (e) =>
|
|
749
|
+
}, Ee = (e) => {
|
|
750
|
+
let t = [];
|
|
751
|
+
for (let n in e) t.push(`${encodeURIComponent(n)}=${encodeURIComponent(e[n])}`);
|
|
752
|
+
return t.join("&");
|
|
753
|
+
}, De = (e) => async (t, n, r = Te.refresh_token, i, a = {}, o = 1e4) => {
|
|
753
754
|
let s = {
|
|
754
755
|
token: n,
|
|
755
756
|
token_type_hint: r,
|
|
756
757
|
client_id: i
|
|
757
758
|
};
|
|
758
759
|
for (let [e, t] of Object.entries(a)) s[e] === void 0 && (s[e] = t);
|
|
759
|
-
let c =
|
|
760
|
-
for (let e in s) {
|
|
761
|
-
let t = encodeURIComponent(e), n = encodeURIComponent(s[e]);
|
|
762
|
-
c.push(`${t}=${n}`);
|
|
763
|
-
}
|
|
764
|
-
let l = c.join("&"), u = await L(e)(t, {
|
|
760
|
+
let c = Ee(s), l = await L(e)(t, {
|
|
765
761
|
method: "POST",
|
|
766
762
|
headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
|
|
767
|
-
body:
|
|
763
|
+
body: c
|
|
768
764
|
}, o);
|
|
769
|
-
if (
|
|
770
|
-
let e = await
|
|
765
|
+
if (l.status !== 200) {
|
|
766
|
+
let e = await Oe(l);
|
|
771
767
|
return {
|
|
772
768
|
success: !1,
|
|
773
|
-
status:
|
|
769
|
+
status: l.status,
|
|
774
770
|
oauthError: typeof e?.error == "string" ? e.error : void 0,
|
|
775
771
|
oauthErrorDescription: typeof e?.error_description == "string" ? e.error_description : void 0
|
|
776
772
|
};
|
|
777
773
|
}
|
|
778
774
|
return {
|
|
779
775
|
success: !0,
|
|
780
|
-
status:
|
|
776
|
+
status: l.status
|
|
781
777
|
};
|
|
782
|
-
},
|
|
778
|
+
}, Oe = async (e) => {
|
|
783
779
|
try {
|
|
784
780
|
return await e.json();
|
|
785
781
|
} catch {
|
|
786
782
|
return null;
|
|
787
783
|
}
|
|
788
|
-
},
|
|
784
|
+
}, ke = (e) => async (t, n, r = 1e4) => {
|
|
789
785
|
if (n.request_uri !== void 0) throw new F(P.REQUEST_FAILED, "The request_uri parameter must not be included in a pushed authorization request.");
|
|
790
|
-
let i =
|
|
791
|
-
for (let e in n) {
|
|
792
|
-
let t = encodeURIComponent(e), r = encodeURIComponent(n[e]);
|
|
793
|
-
i.push(`${t}=${r}`);
|
|
794
|
-
}
|
|
795
|
-
let a;
|
|
786
|
+
let i = Ee(n), a;
|
|
796
787
|
try {
|
|
797
788
|
a = await L(e)(t, {
|
|
798
789
|
method: "POST",
|
|
799
790
|
headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
|
|
800
|
-
body: i
|
|
791
|
+
body: i
|
|
801
792
|
}, r);
|
|
802
793
|
} catch (e) {
|
|
803
794
|
throw new F(P.REQUEST_FAILED, "The pushed authorization request could not be sent.", { cause: e });
|
|
804
795
|
}
|
|
805
|
-
let o = await
|
|
796
|
+
let o = await Oe(a);
|
|
806
797
|
if (a.status !== 201) {
|
|
807
798
|
let e = typeof o?.error == "string" ? o.error : void 0, t = typeof o?.error_description == "string" ? o.error_description : void 0, n = [e, t].filter(Boolean).join(": ");
|
|
808
799
|
throw new F(P.REQUEST_FAILED, `The pushed authorization request failed with HTTP status ${a.status}${n ? ` (${n})` : ""}.`, {
|
|
@@ -816,89 +807,79 @@ var he = () => {
|
|
|
816
807
|
request_uri: o.request_uri,
|
|
817
808
|
expires_in: o.expires_in
|
|
818
809
|
};
|
|
819
|
-
},
|
|
810
|
+
}, Ae = (e) => async (t, n, r, i, a = {}, o, s = 1e4) => {
|
|
820
811
|
for (let [e, t] of Object.entries(r)) n[e] === void 0 && (n[e] = t);
|
|
821
|
-
let c =
|
|
822
|
-
for (let e in n) {
|
|
823
|
-
let t = encodeURIComponent(e), r = encodeURIComponent(n[e]);
|
|
824
|
-
c.push(`${t}=${r}`);
|
|
825
|
-
}
|
|
826
|
-
let l = c.join("&"), u = await L(e)(t, {
|
|
812
|
+
let c = Ee(n), l = await L(e)(t, {
|
|
827
813
|
method: "POST",
|
|
828
814
|
headers: {
|
|
829
815
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
830
816
|
...a
|
|
831
817
|
},
|
|
832
|
-
body:
|
|
818
|
+
body: c
|
|
833
819
|
}, s);
|
|
834
|
-
if (
|
|
835
|
-
let e = await
|
|
820
|
+
if (l.status !== 200) {
|
|
821
|
+
let e = await Oe(l);
|
|
836
822
|
return {
|
|
837
823
|
success: !1,
|
|
838
|
-
status:
|
|
824
|
+
status: l.status,
|
|
839
825
|
data: e,
|
|
840
826
|
oauthError: typeof e?.error == "string" ? e.error : void 0,
|
|
841
827
|
oauthErrorDescription: typeof e?.error_description == "string" ? e.error_description : void 0,
|
|
842
|
-
demonstratingProofOfPossessionNonce:
|
|
828
|
+
demonstratingProofOfPossessionNonce: l.headers?.has(R) ? l.headers.get(R) : null
|
|
843
829
|
};
|
|
844
830
|
}
|
|
845
|
-
let
|
|
846
|
-
return
|
|
831
|
+
let u = await l.json(), d = null;
|
|
832
|
+
return l.headers.has(R) && (d = l.headers.get(R)), {
|
|
847
833
|
success: !0,
|
|
848
|
-
status:
|
|
849
|
-
data:
|
|
850
|
-
demonstratingProofOfPossessionNonce:
|
|
834
|
+
status: l.status,
|
|
835
|
+
data: ot(u, i, o),
|
|
836
|
+
demonstratingProofOfPossessionNonce: d
|
|
851
837
|
};
|
|
852
|
-
},
|
|
838
|
+
}, je = (e, t) => async (n, r, i) => {
|
|
853
839
|
r = r ? { ...r } : {};
|
|
854
840
|
let a = A(128), o = await de(a);
|
|
855
841
|
if (await e.setCodeVerifierAsync(a), await e.setStateAsync(r.state), r.code_challenge = o, r.code_challenge_method = "S256", i) {
|
|
856
|
-
let e = await
|
|
842
|
+
let e = await ke(i.fetch)(i.endpoint, r, i.timeoutMs);
|
|
857
843
|
t.open(`${n}?client_id=${encodeURIComponent(r.client_id)}&request_uri=${encodeURIComponent(e.request_uri)}`);
|
|
858
844
|
return;
|
|
859
845
|
}
|
|
860
846
|
let s = "";
|
|
861
847
|
if (r) for (let [e, t] of Object.entries(r)) s += s === "" ? "?" : "&", s += `${e}=${encodeURIComponent(t)}`;
|
|
862
848
|
t.open(`${n}${s}`);
|
|
863
|
-
}, R = "DPoP-Nonce",
|
|
849
|
+
}, R = "DPoP-Nonce", Me = (e) => async (t, n, r, i, a = 1e4, o = !1) => {
|
|
864
850
|
n = n ? { ...n } : {}, n.code_verifier = await e.getCodeVerifierAsync();
|
|
865
|
-
let s =
|
|
866
|
-
for (let e in n) {
|
|
867
|
-
let t = encodeURIComponent(e), r = encodeURIComponent(n[e]);
|
|
868
|
-
s.push(`${t}=${r}`);
|
|
869
|
-
}
|
|
870
|
-
let c = s.join("&"), l = await L(fetch)(t, {
|
|
851
|
+
let s = Ee(n), c = await L(fetch)(t, {
|
|
871
852
|
method: "POST",
|
|
872
853
|
headers: {
|
|
873
854
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
874
855
|
...r
|
|
875
856
|
},
|
|
876
|
-
body:
|
|
857
|
+
body: s
|
|
877
858
|
}, a);
|
|
878
|
-
if (
|
|
879
|
-
let t = await
|
|
859
|
+
if (c.status !== 200) {
|
|
860
|
+
let t = await Oe(c), n = typeof t?.error == "string" ? t.error : void 0;
|
|
880
861
|
return o && n === "use_dpop_nonce" || await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]), {
|
|
881
862
|
success: !1,
|
|
882
|
-
status:
|
|
863
|
+
status: c.status,
|
|
883
864
|
data: t,
|
|
884
865
|
oauthError: n,
|
|
885
866
|
oauthErrorDescription: typeof t?.error_description == "string" ? t.error_description : void 0,
|
|
886
|
-
demonstratingProofOfPossessionNonce:
|
|
867
|
+
demonstratingProofOfPossessionNonce: c.headers?.has(R) ? c.headers.get(R) : null
|
|
887
868
|
};
|
|
888
869
|
}
|
|
889
870
|
await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]);
|
|
890
|
-
let
|
|
891
|
-
|
|
892
|
-
let
|
|
871
|
+
let l = null;
|
|
872
|
+
c.headers.has(R) && (l = c.headers.get(R));
|
|
873
|
+
let u = await c.json();
|
|
893
874
|
return {
|
|
894
875
|
success: !0,
|
|
895
876
|
data: {
|
|
896
877
|
state: n.state,
|
|
897
|
-
tokens:
|
|
898
|
-
demonstratingProofOfPossessionNonce:
|
|
878
|
+
tokens: ot(u, null, i),
|
|
879
|
+
demonstratingProofOfPossessionNonce: l
|
|
899
880
|
}
|
|
900
881
|
};
|
|
901
|
-
},
|
|
882
|
+
}, Ne = (e) => {
|
|
902
883
|
let t = e.match(/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
903
884
|
if (!t) throw Error("Invalid URL");
|
|
904
885
|
let n = t[6], r = t[7];
|
|
@@ -906,7 +887,7 @@ var he = () => {
|
|
|
906
887
|
let e = r.split("?");
|
|
907
888
|
e.length === 2 && (r = e[0], n = e[1]);
|
|
908
889
|
}
|
|
909
|
-
return n.startsWith("?") && (n = n.slice(1)),
|
|
890
|
+
return n.startsWith("?") && (n = n.slice(1)), {
|
|
910
891
|
href: e,
|
|
911
892
|
protocol: t[1],
|
|
912
893
|
host: t[2],
|
|
@@ -916,19 +897,22 @@ var he = () => {
|
|
|
916
897
|
search: n,
|
|
917
898
|
hash: r
|
|
918
899
|
};
|
|
919
|
-
},
|
|
920
|
-
let t =
|
|
900
|
+
}, Pe = (e) => {
|
|
901
|
+
let t = Ne(e), { path: n } = t;
|
|
921
902
|
n.endsWith("/") && (n = n.slice(0, -1));
|
|
922
903
|
let { hash: r } = t;
|
|
923
904
|
return (r === "#" || r === "#_=_") && (r = ""), r && (n += r), n;
|
|
924
905
|
}, z = (e) => {
|
|
925
|
-
let { search: t } =
|
|
926
|
-
return
|
|
927
|
-
},
|
|
928
|
-
let t = {}
|
|
929
|
-
for (
|
|
906
|
+
let { search: t } = Ne(e);
|
|
907
|
+
return Fe(t);
|
|
908
|
+
}, Fe = (e) => {
|
|
909
|
+
let t = {};
|
|
910
|
+
for (let n of e.split("&")) {
|
|
911
|
+
let [e, r] = n.split("=");
|
|
912
|
+
t[decodeURIComponent(e)] = decodeURIComponent(r);
|
|
913
|
+
}
|
|
930
914
|
return t;
|
|
931
|
-
},
|
|
915
|
+
}, Ie = (t, n, r, a, o, s = () => window.fetch) => (c = void 0, l = null, u = !1, d = void 0) => {
|
|
932
916
|
let f = l;
|
|
933
917
|
return l = { ...l }, (async () => {
|
|
934
918
|
let p = c || o.getPath();
|
|
@@ -968,13 +952,13 @@ var he = () => {
|
|
|
968
952
|
fetch: s(),
|
|
969
953
|
timeoutMs: n.par_request_timeout
|
|
970
954
|
} : void 0;
|
|
971
|
-
await
|
|
955
|
+
await je(g, o)(h.authorizationEndpoint, _, x);
|
|
972
956
|
} catch (t) {
|
|
973
957
|
let n = _(t) ? g(t, "login") : t;
|
|
974
958
|
throw r(e.loginAsync_error, n), n;
|
|
975
959
|
}
|
|
976
960
|
})();
|
|
977
|
-
},
|
|
961
|
+
}, Le = (t) => async (n = !1) => {
|
|
978
962
|
try {
|
|
979
963
|
t.publishEvent(e.loginCallbackAsync_begin, {});
|
|
980
964
|
let r = t.configuration, a = r.client_id, o = n ? r.silent_redirect_uri : r.redirect_uri, s = r.authority, l = r.token_request_timeout, u = await t.initAsync(s, r.authority_configuration), f = z(t.location.getCurrentHref()), m = f.session_state, g = await $(r, t.configurationName), _, v, y, b;
|
|
@@ -1000,11 +984,11 @@ var he = () => {
|
|
|
1000
984
|
if (y?.extras) for (let [e, t] of Object.entries(y.extras)) e.endsWith(":token_request") && (S[e.replace(":token_request", "")] = t);
|
|
1001
985
|
let C = u.tokenEndpoint, w = {}, T;
|
|
1002
986
|
r.demonstrating_proof_of_possession && (g ? w.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${t.configurationName}` : (T = await re(window)(r.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm), await i(t.configurationName, r.storage, r.login_state_storage ?? r.storage).setDemonstratingProofOfPossessionJwkAsync(T), w.DPoP = await ie(window)(r.demonstrating_proof_of_possession_configuration)(T, "POST", C)));
|
|
1003
|
-
let E = await
|
|
987
|
+
let E = await Me(_)(C, {
|
|
1004
988
|
...x,
|
|
1005
989
|
...S
|
|
1006
990
|
}, w, t.configuration.token_renew_mode, l, r.demonstrating_proof_of_possession);
|
|
1007
|
-
if (!E.success && E.oauthError === "use_dpop_nonce" && E.demonstratingProofOfPossessionNonce && r.demonstrating_proof_of_possession ? (await _.setDemonstratingProofOfPossessionNonce(E.demonstratingProofOfPossessionNonce), g || (w.DPoP = await ie(window)(r.demonstrating_proof_of_possession_configuration)(T, "POST", C, { nonce: E.demonstratingProofOfPossessionNonce })), E = await
|
|
991
|
+
if (!E.success && E.oauthError === "use_dpop_nonce" && E.demonstratingProofOfPossessionNonce && r.demonstrating_proof_of_possession ? (await _.setDemonstratingProofOfPossessionNonce(E.demonstratingProofOfPossessionNonce), g || (w.DPoP = await ie(window)(r.demonstrating_proof_of_possession_configuration)(T, "POST", C, { nonce: E.demonstratingProofOfPossessionNonce })), E = await Me(_)(C, {
|
|
1008
992
|
...x,
|
|
1009
993
|
...S
|
|
1010
994
|
}, w, t.configuration.token_renew_mode, l)) : !E.success && r.demonstrating_proof_of_possession && await Promise.all([_.setCodeVerifierAsync(null), _.setStateAsync(null)]), !E.success) {
|
|
@@ -1022,7 +1006,7 @@ var he = () => {
|
|
|
1022
1006
|
phase: n ? "refresh" : "callback",
|
|
1023
1007
|
retryable: !1
|
|
1024
1008
|
});
|
|
1025
|
-
let { isValid: ee, reason: te } =
|
|
1009
|
+
let { isValid: ee, reason: te } = lt(O, v.nonce, u);
|
|
1026
1010
|
if (!ee) {
|
|
1027
1011
|
let e = `Tokens are not OpenID valid, reason: ${te}`;
|
|
1028
1012
|
throw te.startsWith("Nonce does not match") ? new d(c.INVALID_NONCE, e, {
|
|
@@ -1050,10 +1034,10 @@ var he = () => {
|
|
|
1050
1034
|
let i = !f(r) && _(r) ? g(r, n ? "refresh" : "callback") : r;
|
|
1051
1035
|
throw console.error(i), t.publishEvent(e.loginCallbackAsync_error, i), i;
|
|
1052
1036
|
}
|
|
1053
|
-
},
|
|
1037
|
+
}, Re = {
|
|
1054
1038
|
access_token: "access_token",
|
|
1055
1039
|
refresh_token: "refresh_token"
|
|
1056
|
-
},
|
|
1040
|
+
}, ze = (e, t) => {
|
|
1057
1041
|
let n = {};
|
|
1058
1042
|
if (e) {
|
|
1059
1043
|
for (let [r, i] of Object.entries(e)) if (r.endsWith(t)) {
|
|
@@ -1063,27 +1047,27 @@ var he = () => {
|
|
|
1063
1047
|
return n;
|
|
1064
1048
|
}
|
|
1065
1049
|
return n;
|
|
1066
|
-
},
|
|
1050
|
+
}, Be = (e) => {
|
|
1067
1051
|
let t = {};
|
|
1068
1052
|
if (e) {
|
|
1069
1053
|
for (let [n, r] of Object.entries(e)) n.includes(":") || (t[n] = r);
|
|
1070
1054
|
return t;
|
|
1071
1055
|
}
|
|
1072
1056
|
return t;
|
|
1073
|
-
},
|
|
1057
|
+
}, Ve = (e) => async (t) => {
|
|
1074
1058
|
b.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
1075
1059
|
let n = await $(e.configuration, e.configurationName);
|
|
1076
1060
|
n ? await n.clearAsync(t) : await i(e.configurationName, e.configuration.storage, e.configuration.login_state_storage ?? e.configuration.storage).clearAsync(t), e.tokens = null, e.userInfo = null;
|
|
1077
|
-
},
|
|
1061
|
+
}, He = (t, n) => async () => {
|
|
1078
1062
|
let r = t.tokens?.idTokenPayload?.sub ?? null;
|
|
1079
1063
|
await t.destroyAsync("LOGGED_OUT");
|
|
1080
1064
|
for (let [, i] of Object.entries(n)) i === t ? t.publishEvent(e.logout_from_same_tab, {}) : await t.logoutSameTabAsync(t.configuration.client_id, r);
|
|
1081
|
-
},
|
|
1065
|
+
}, Ue = (e, t, n, r) => {
|
|
1082
1066
|
"id_token_hint" in t || (t.id_token_hint = n), !("post_logout_redirect_uri" in t) && r !== null && (t.post_logout_redirect_uri = r);
|
|
1083
1067
|
let i = "";
|
|
1084
1068
|
for (let [e, n] of Object.entries(t)) n != null && (i += i === "" ? "?" : "&", i += `${e}=${encodeURIComponent(n)}`);
|
|
1085
1069
|
return `${e}${i}`;
|
|
1086
|
-
},
|
|
1070
|
+
}, We = (t, n, r, i, a) => async (o = void 0, s = null) => {
|
|
1087
1071
|
let l = t.configuration, u;
|
|
1088
1072
|
try {
|
|
1089
1073
|
u = await t.initAsync(l.authority, l.authority_configuration);
|
|
@@ -1101,13 +1085,13 @@ var he = () => {
|
|
|
1101
1085
|
let n = u.revocationEndpoint;
|
|
1102
1086
|
if (n) {
|
|
1103
1087
|
let i = [], a = t.tokens ? t.tokens.accessToken : null;
|
|
1104
|
-
if (a && l.logout_tokens_to_invalidate.includes(
|
|
1105
|
-
let e =
|
|
1088
|
+
if (a && l.logout_tokens_to_invalidate.includes(Re.access_token)) {
|
|
1089
|
+
let e = ze(s, ":revoke_access_token"), t = De(r)(n, a, Te.access_token, l.client_id, e);
|
|
1106
1090
|
i.push(t);
|
|
1107
1091
|
}
|
|
1108
1092
|
let o = t.tokens ? t.tokens.refreshToken : null;
|
|
1109
|
-
if (o && l.logout_tokens_to_invalidate.includes(
|
|
1110
|
-
let e =
|
|
1093
|
+
if (o && l.logout_tokens_to_invalidate.includes(Re.refresh_token)) {
|
|
1094
|
+
let e = ze(s, ":revoke_refresh_token"), t = De(r)(n, o, Te.refresh_token, l.client_id, e);
|
|
1111
1095
|
i.push(t);
|
|
1112
1096
|
}
|
|
1113
1097
|
if (i.length > 0) {
|
|
@@ -1125,17 +1109,17 @@ var he = () => {
|
|
|
1125
1109
|
let r = !f(n) && _(n) ? g(n, "logout") : n;
|
|
1126
1110
|
t.publishEvent(e.logoutAsync_error, r), i.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"), i.warn(r);
|
|
1127
1111
|
}
|
|
1128
|
-
let o =
|
|
1112
|
+
let o = ze(s, ":oidc");
|
|
1129
1113
|
if (o && o.no_reload === "true") {
|
|
1130
|
-
await
|
|
1114
|
+
await He(t, n)(), t.isLoggingOut = !1;
|
|
1131
1115
|
return;
|
|
1132
1116
|
}
|
|
1133
|
-
let m =
|
|
1117
|
+
let m = Be(s);
|
|
1134
1118
|
if (u.endSessionEndpoint) {
|
|
1135
|
-
let e =
|
|
1119
|
+
let e = Ue(u.endSessionEndpoint, m, y, v);
|
|
1136
1120
|
a.open(e);
|
|
1137
1121
|
} else a.reload();
|
|
1138
|
-
await
|
|
1122
|
+
await He(t, n)();
|
|
1139
1123
|
} catch (n) {
|
|
1140
1124
|
t.isLoggingOut = !1;
|
|
1141
1125
|
let r = !f(n) && _(n) ? g(n, "logout") : n;
|
|
@@ -1143,17 +1127,17 @@ var he = () => {
|
|
|
1143
1127
|
}
|
|
1144
1128
|
}, B = /* @__PURE__ */ function(e) {
|
|
1145
1129
|
return e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e;
|
|
1146
|
-
}({}),
|
|
1130
|
+
}({}), Ge = (t, n, r = !1, i = "api_request") => async (...a) => {
|
|
1147
1131
|
let [o, s, ...l] = a, u = s ? { ...s } : { method: "GET" }, f = new Headers();
|
|
1148
1132
|
u.headers && (f = u.headers instanceof Headers ? u.headers : new Headers(u.headers));
|
|
1149
|
-
let p = (await
|
|
1133
|
+
let p = (await ct({
|
|
1150
1134
|
getTokens: () => n.tokens,
|
|
1151
1135
|
configuration: {
|
|
1152
1136
|
token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
|
|
1153
1137
|
refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
|
|
1154
1138
|
},
|
|
1155
1139
|
syncTokensInfoAsync: async () => {
|
|
1156
|
-
let { status: e } = await
|
|
1140
|
+
let { status: e } = await et(n)(n.configuration, n.configurationName, n.tokens, !1);
|
|
1157
1141
|
return e;
|
|
1158
1142
|
},
|
|
1159
1143
|
renewTokensAsync: n.renewTokensAsync.bind(n)
|
|
@@ -1185,13 +1169,13 @@ var he = () => {
|
|
|
1185
1169
|
i === "api_request" && n.publishEvent(e.apiRequest_error, t);
|
|
1186
1170
|
}
|
|
1187
1171
|
return h;
|
|
1188
|
-
},
|
|
1172
|
+
}, Ke = (t) => async (n = !1, r = !1) => {
|
|
1189
1173
|
try {
|
|
1190
1174
|
if (t.userInfo != null && !n) return t.userInfo;
|
|
1191
1175
|
let i = !n && t.configuration.storage?.getItem(`oidc.${t.configurationName}.userInfo`);
|
|
1192
1176
|
if (i) return t.userInfo = JSON.parse(i), t.userInfo;
|
|
1193
1177
|
let a = t.configuration, o = (await t.initAsync(a.authority, a.authority_configuration)).userInfoEndpoint, s = await (async () => {
|
|
1194
|
-
let n = await
|
|
1178
|
+
let n = await Ge(fetch, t, r, "userinfo")(o);
|
|
1195
1179
|
if (n.status !== 200) {
|
|
1196
1180
|
let r = n.headers?.has("DPoP-Nonce") && (n.status === 400 || n.status === 401 || n.headers.get("WWW-Authenticate")?.includes("use_dpop_nonce")), i = new d(r ? c.DPOP_NONCE_REQUIRED : c.REQUEST_FAILED, "UserInfo request failed", {
|
|
1197
1181
|
phase: "userinfo",
|
|
@@ -1208,11 +1192,11 @@ var he = () => {
|
|
|
1208
1192
|
let r = f(n) ? n : _(n) ? g(n, "userinfo") : n;
|
|
1209
1193
|
throw t.publishEvent(e.userInfoAsync_error, r), r;
|
|
1210
1194
|
}
|
|
1211
|
-
},
|
|
1195
|
+
}, qe = () => fetch, Je = class {
|
|
1212
1196
|
constructor(e) {
|
|
1213
1197
|
this.authorizationEndpoint = e.authorization_endpoint, this.tokenEndpoint = e.token_endpoint, this.revocationEndpoint = e.revocation_endpoint, this.userInfoEndpoint = e.userinfo_endpoint, this.checkSessionIframe = e.check_session_iframe, this.issuer = e.issuer, this.endSessionEndpoint = e.end_session_endpoint, this.pushedAuthorizationRequestEndpoint = e.pushed_authorization_request_endpoint, this.requirePushedAuthorizationRequests = e.require_pushed_authorization_requests ?? !1;
|
|
1214
1198
|
}
|
|
1215
|
-
}, V = {},
|
|
1199
|
+
}, V = {}, Ye = (e, t = new j()) => (n, r = "default") => (V[r] || (V[r] = new H(n, r, e, t)), V[r]), Xe = async (e) => {
|
|
1216
1200
|
let { parsedTokens: t, callbackPath: n, extras: r, scope: i } = await e.loginCallbackAsync();
|
|
1217
1201
|
return e.timeoutId = W(e, t.expiresAt, r, i), { callbackPath: n };
|
|
1218
1202
|
}, H = class t {
|
|
@@ -1228,7 +1212,7 @@ var he = () => {
|
|
|
1228
1212
|
monitor_session: e.monitor_session ?? !1,
|
|
1229
1213
|
refresh_time_before_tokens_expiration_in_second: a,
|
|
1230
1214
|
silent_login_timeout: e.silent_login_timeout ?? 12e3,
|
|
1231
|
-
token_renew_mode: e.token_renew_mode ??
|
|
1215
|
+
token_renew_mode: e.token_renew_mode ?? q.access_token_or_id_token_invalid,
|
|
1232
1216
|
demonstrating_proof_of_possession: e.demonstrating_proof_of_possession ?? !1,
|
|
1233
1217
|
authority_timeout_wellknowurl_in_millisecond: e.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
1234
1218
|
logout_tokens_to_invalidate: e.logout_tokens_to_invalidate ?? ["access_token", "refresh_token"],
|
|
@@ -1237,7 +1221,7 @@ var he = () => {
|
|
|
1237
1221
|
preload_user_info: e.preload_user_info ?? !1,
|
|
1238
1222
|
par: e.par ?? "disabled",
|
|
1239
1223
|
par_request_timeout: e.par_request_timeout ?? 1e4
|
|
1240
|
-
}, this.getFetch = n ??
|
|
1224
|
+
}, this.getFetch = n ?? qe, this.configurationName = t, this.tokens = null, this.userInfo = null, this.events = [], this.timeoutId = null, this.loginCallbackWithAutoTokensRenewAsync.bind(this), this.initAsync.bind(this), this.loginCallbackAsync.bind(this), this.subscribeEvents.bind(this), this.removeEventSubscription.bind(this), this.publishEvent.bind(this), this.destroyAsync.bind(this), this.logoutAsync.bind(this), this.renewTokensAsync.bind(this), this.renewTokensOrThrowAsync.bind(this), this.initAsync(this.configuration.authority, this.configuration.authority_configuration);
|
|
1241
1225
|
}
|
|
1242
1226
|
subscribeEvents(e) {
|
|
1243
1227
|
let t = A(16);
|
|
@@ -1256,7 +1240,7 @@ var he = () => {
|
|
|
1256
1240
|
});
|
|
1257
1241
|
}
|
|
1258
1242
|
static {
|
|
1259
|
-
this.getOrCreate = (e, t) => (n, r = "default") =>
|
|
1243
|
+
this.getOrCreate = (e, t) => (n, r = "default") => Ye(e, t)(n, r);
|
|
1260
1244
|
}
|
|
1261
1245
|
static get(e = "default") {
|
|
1262
1246
|
return Object.prototype.hasOwnProperty.call(V, e) ? V[e] : null;
|
|
@@ -1305,7 +1289,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1305
1289
|
async initAsync(e, t) {
|
|
1306
1290
|
if (this.initPromise !== null) return this.initPromise;
|
|
1307
1291
|
let n = async () => {
|
|
1308
|
-
if (t != null) return new
|
|
1292
|
+
if (t != null) return new Je({
|
|
1309
1293
|
authorization_endpoint: t.authorization_endpoint,
|
|
1310
1294
|
end_session_endpoint: t.end_session_endpoint,
|
|
1311
1295
|
revocation_endpoint: t.revocation_endpoint,
|
|
@@ -1332,14 +1316,14 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1332
1316
|
await C(this, V, this.configuration)(e, t, n, r);
|
|
1333
1317
|
}
|
|
1334
1318
|
async loginAsync(e = void 0, t = null, n = !1, r = void 0, i = !1) {
|
|
1335
|
-
return this.logoutPromise && await this.logoutPromise, this.loginPromise === null ? (this.loginPromise = i ? S(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(t, r) :
|
|
1319
|
+
return this.logoutPromise && await this.logoutPromise, this.loginPromise === null ? (this.loginPromise = i ? S(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(t, r) : Ie(this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this), this.location, this.getFetch)(e, t, n, r), this.loginPromise.finally(() => {
|
|
1336
1320
|
this.loginPromise = null;
|
|
1337
1321
|
})) : this.loginPromise;
|
|
1338
1322
|
}
|
|
1339
1323
|
async loginCallbackAsync(e = !1) {
|
|
1340
1324
|
if (this.loginCallbackPromise !== null) return this.loginCallbackPromise;
|
|
1341
1325
|
let n = async () => {
|
|
1342
|
-
let n = await
|
|
1326
|
+
let n = await Le(this)(e), r = n.tokens;
|
|
1343
1327
|
return this.tokens = r, await $(this.configuration, this.configurationName) || i(this.configurationName, this.configuration.storage, this.configuration.login_state_storage ?? this.configuration.storage).setTokens(r), this.publishEvent(t.eventNames.token_acquired, r), this.configuration.preload_user_info && await this.userInfoAsync(), {
|
|
1344
1328
|
parsedTokens: r,
|
|
1345
1329
|
state: n.state,
|
|
@@ -1362,12 +1346,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1362
1346
|
return l && (o.nonce = l), await ie(window)(a.demonstrating_proof_of_possession_configuration)(c, n, t, o);
|
|
1363
1347
|
}
|
|
1364
1348
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1365
|
-
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1349
|
+
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise = Xe(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
|
|
1366
1350
|
this.loginCallbackWithAutoTokensRenewPromise = null;
|
|
1367
1351
|
})) : this.loginCallbackWithAutoTokensRenewPromise;
|
|
1368
1352
|
}
|
|
1369
1353
|
userInfoAsync(e = !1, t = !1) {
|
|
1370
|
-
return this.userInfoPromise === null ? (this.userInfoPromise =
|
|
1354
|
+
return this.userInfoPromise === null ? (this.userInfoPromise = Ke(this)(e, t), this.userInfoPromise.finally(() => {
|
|
1371
1355
|
this.userInfoPromise = null;
|
|
1372
1356
|
})) : this.userInfoPromise;
|
|
1373
1357
|
}
|
|
@@ -1375,7 +1359,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1375
1359
|
if (this.renewTokensPromise !== null) return this.renewTokensPromise;
|
|
1376
1360
|
if (!this.timeoutId) return null;
|
|
1377
1361
|
b.clearTimeout(this.timeoutId);
|
|
1378
|
-
let n =
|
|
1362
|
+
let n = Qe(this, !0, e, t);
|
|
1379
1363
|
return this.renewTokensPromise = n, n.finally(() => {
|
|
1380
1364
|
this.renewTokensPromise === n && (this.renewTokensPromise = null);
|
|
1381
1365
|
});
|
|
@@ -1393,10 +1377,10 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1393
1377
|
return n.tokens;
|
|
1394
1378
|
}
|
|
1395
1379
|
async destroyAsync(e) {
|
|
1396
|
-
return await
|
|
1380
|
+
return await Ve(this)(e);
|
|
1397
1381
|
}
|
|
1398
1382
|
async clearSessionAsync() {
|
|
1399
|
-
return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise =
|
|
1383
|
+
return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise = He(this, V)(), this.clearSessionPromise.finally(() => {
|
|
1400
1384
|
this.clearSessionPromise = null;
|
|
1401
1385
|
}));
|
|
1402
1386
|
}
|
|
@@ -1413,7 +1397,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1413
1397
|
}));
|
|
1414
1398
|
}
|
|
1415
1399
|
async logoutAsync(e = void 0, t = null) {
|
|
1416
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1400
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = We(this, V, this.getFetch(), console, this.location)(e, t), this.logoutPromise.finally(() => {
|
|
1417
1401
|
this.logoutPromise = null;
|
|
1418
1402
|
}));
|
|
1419
1403
|
}
|
|
@@ -1427,7 +1411,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1427
1411
|
oauthErrorDescription: t?.oauthErrorDescription
|
|
1428
1412
|
});
|
|
1429
1413
|
};
|
|
1430
|
-
async function
|
|
1414
|
+
async function Ze(e, t, n, r = null) {
|
|
1431
1415
|
let a = await K(e)((t) => {
|
|
1432
1416
|
e.tokens = t;
|
|
1433
1417
|
}, 0, 0, t, n, r), { tokens: o, status: s } = a;
|
|
@@ -1439,12 +1423,12 @@ async function Xe(e, t, n, r = null) {
|
|
|
1439
1423
|
tokens: null
|
|
1440
1424
|
});
|
|
1441
1425
|
}
|
|
1442
|
-
async function
|
|
1426
|
+
async function Qe(e, t = !1, n = null, r = null) {
|
|
1443
1427
|
let i = e.configuration, a = `${i.client_id}_${e.configurationName}_${i.authority}`, o, s = await $(e.configuration, e.configurationName);
|
|
1444
|
-
if (i?.storage === window?.sessionStorage && !s || !navigator.locks) o = await
|
|
1428
|
+
if (i?.storage === window?.sessionStorage && !s || !navigator.locks) o = await Ze(e, t, n, r);
|
|
1445
1429
|
else {
|
|
1446
1430
|
let i = "retry";
|
|
1447
|
-
for (; i === "retry";) i = await navigator.locks.request(a, { ifAvailable: !0 }, async (i) => i ? await
|
|
1431
|
+
for (; i === "retry";) i = await navigator.locks.request(a, { ifAvailable: !0 }, async (i) => i ? await Ze(e, t, n, r) : (e.publishEvent(H.eventNames.syncTokensAsync_lock_not_available, { lock: "lock not available" }), "retry"));
|
|
1448
1432
|
o = i;
|
|
1449
1433
|
}
|
|
1450
1434
|
return o.tokens ? (e.timeoutId &&= W(e, e.tokens.expiresAt, n, r), {
|
|
@@ -1452,14 +1436,14 @@ async function Ze(e, t = !1, n = null, r = null) {
|
|
|
1452
1436
|
tokens: e.tokens
|
|
1453
1437
|
}) : o;
|
|
1454
1438
|
}
|
|
1455
|
-
async function
|
|
1456
|
-
return (await
|
|
1439
|
+
async function $e(e, t = !1, n = null, r = null) {
|
|
1440
|
+
return (await Qe(e, t, n, r)).tokens;
|
|
1457
1441
|
}
|
|
1458
1442
|
var W = (e, t, n = null, r = null) => {
|
|
1459
1443
|
let i = e.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
1460
1444
|
return e.timeoutId && b.clearTimeout(e.timeoutId), b.setTimeout(async () => {
|
|
1461
|
-
let a = { timeLeft:
|
|
1462
|
-
e.publishEvent(H.eventNames.token_timer, a), await
|
|
1445
|
+
let a = { timeLeft: J(i, t) };
|
|
1446
|
+
e.publishEvent(H.eventNames.token_timer, a), await $e(e, !1, n, r);
|
|
1463
1447
|
}, 1e3);
|
|
1464
1448
|
}, G = {
|
|
1465
1449
|
FORCE_REFRESH: "FORCE_REFRESH",
|
|
@@ -1471,7 +1455,7 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1471
1455
|
LOGOUT_FROM_ANOTHER_TAB: "LOGOUT_FROM_ANOTHER_TAB",
|
|
1472
1456
|
REQUIRE_SYNC_TOKENS: "REQUIRE_SYNC_TOKENS",
|
|
1473
1457
|
TOKENS_INVALID: "TOKENS_INVALID"
|
|
1474
|
-
},
|
|
1458
|
+
}, et = (e) => async (t, n, r, a = !1) => {
|
|
1475
1459
|
let o = { nonce: null };
|
|
1476
1460
|
if (!r) return {
|
|
1477
1461
|
tokens: null,
|
|
@@ -1498,13 +1482,13 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1498
1482
|
};
|
|
1499
1483
|
if (n.issuedAt !== r.issuedAt) return {
|
|
1500
1484
|
tokens: n,
|
|
1501
|
-
status:
|
|
1485
|
+
status: J(t.refresh_time_before_tokens_expiration_in_second, n.expiresAt) > 0 ? G.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : G.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
|
|
1502
1486
|
nonce: await l.getNonceAsync()
|
|
1503
1487
|
};
|
|
1504
1488
|
s = await l.getNonceAsync();
|
|
1505
1489
|
} else {
|
|
1506
1490
|
let a = i(n, t.storage ?? sessionStorage, t.login_state_storage ?? t.storage ?? sessionStorage), c = await a.initAsync(), { tokens: l } = c, { status: u } = c;
|
|
1507
|
-
if (l &&=
|
|
1491
|
+
if (l &&= at(l, e.tokens, t.token_renew_mode), !l) return {
|
|
1508
1492
|
tokens: null,
|
|
1509
1493
|
status: G.LOGOUT_FROM_ANOTHER_TAB,
|
|
1510
1494
|
nonce: o
|
|
@@ -1515,7 +1499,7 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1515
1499
|
nonce: o
|
|
1516
1500
|
};
|
|
1517
1501
|
if (l.issuedAt !== r.issuedAt) {
|
|
1518
|
-
let e =
|
|
1502
|
+
let e = J(t.refresh_time_before_tokens_expiration_in_second, l.expiresAt) > 0 ? G.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : G.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, n = await a.getNonceAsync();
|
|
1519
1503
|
return {
|
|
1520
1504
|
tokens: l,
|
|
1521
1505
|
status: e,
|
|
@@ -1524,7 +1508,7 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1524
1508
|
}
|
|
1525
1509
|
s = await a.getNonceAsync();
|
|
1526
1510
|
}
|
|
1527
|
-
let u =
|
|
1511
|
+
let u = J(t.refresh_time_before_tokens_expiration_in_second, r.expiresAt) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
|
|
1528
1512
|
return a ? {
|
|
1529
1513
|
tokens: r,
|
|
1530
1514
|
status: "FORCE_REFRESH",
|
|
@@ -1540,7 +1524,7 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1540
1524
|
status: "GIVE_UP"
|
|
1541
1525
|
};
|
|
1542
1526
|
let p = 6, m = o ? 2 : 5;
|
|
1543
|
-
for (; !navigator.onLine && p > 0;) await
|
|
1527
|
+
for (; !navigator.onLine && p > 0;) await X({ milliseconds: 1e3 }), p--, t.publishEvent(e.refreshTokensAsync, { message: `wait because navigator is offline try ${p}` });
|
|
1544
1528
|
let h = document.hidden, v = h ? r : r + 1, y = h ? a + 1 : a;
|
|
1545
1529
|
if (r >= m || a >= 5) {
|
|
1546
1530
|
n(null);
|
|
@@ -1606,7 +1590,7 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1606
1590
|
}
|
|
1607
1591
|
};
|
|
1608
1592
|
try {
|
|
1609
|
-
let { status: f, tokens: p, nonce: m } = await
|
|
1593
|
+
let { status: f, tokens: p, nonce: m } = await et(t)(b, t.configurationName, t.tokens, o);
|
|
1610
1594
|
switch (f) {
|
|
1611
1595
|
case G.SESSION_LOST:
|
|
1612
1596
|
n(null);
|
|
@@ -1662,10 +1646,10 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1662
1646
|
refresh_token: p.refreshToken
|
|
1663
1647
|
}, a = await t.initAsync(g, b.authority_configuration), f = document.hidden ? 1e4 : 3e5, x = a.tokenEndpoint, S = {};
|
|
1664
1648
|
b.demonstrating_proof_of_possession && (S.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(p.accessToken, x, "POST"));
|
|
1665
|
-
let C = await
|
|
1649
|
+
let C = await Ae(t.getFetch())(x, r, _, p, S, b.token_renew_mode, f);
|
|
1666
1650
|
if (!C.success && C.oauthError === "use_dpop_nonce" && C.demonstratingProofOfPossessionNonce && b.demonstrating_proof_of_possession) {
|
|
1667
1651
|
let e = await $(b, t.configurationName);
|
|
1668
|
-
e ? await e.setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce) : await i(t.configurationName, b.storage, b.login_state_storage ?? b.storage).setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce), S.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(p.accessToken, x, "POST"), C = await
|
|
1652
|
+
e ? await e.setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce) : await i(t.configurationName, b.storage, b.login_state_storage ?? b.storage).setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce), S.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(p.accessToken, x, "POST"), C = await Ae(t.getFetch())(x, r, _, p, S, b.token_renew_mode, f);
|
|
1669
1653
|
}
|
|
1670
1654
|
if (C.success) {
|
|
1671
1655
|
if (!m || !m.nonce) {
|
|
@@ -1680,7 +1664,7 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1680
1664
|
error: r
|
|
1681
1665
|
};
|
|
1682
1666
|
}
|
|
1683
|
-
let { isValid: r, reason: o } =
|
|
1667
|
+
let { isValid: r, reason: o } = lt(C.data, m.nonce, a);
|
|
1684
1668
|
if (!r) {
|
|
1685
1669
|
n(null);
|
|
1686
1670
|
let r = new d(o.startsWith("Nonce does not match") ? c.INVALID_NONCE : c.TOKEN_REQUEST_FAILED, `refresh token return not valid tokens, reason: ${o}`, {
|
|
@@ -1735,31 +1719,33 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1735
1719
|
}, 1e3);
|
|
1736
1720
|
});
|
|
1737
1721
|
}
|
|
1738
|
-
},
|
|
1722
|
+
}, tt = (e) => decodeURIComponent(Array.prototype.map.call(atob(e), (e) => "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2)).join("")), nt = (e) => JSON.parse(tt(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), rt = (e) => {
|
|
1739
1723
|
try {
|
|
1740
|
-
|
|
1724
|
+
if (!e) return null;
|
|
1725
|
+
let t = e.split(".");
|
|
1726
|
+
return t.length === 3 ? nt(t[1]) : null;
|
|
1741
1727
|
} catch (e) {
|
|
1742
1728
|
console.warn(e);
|
|
1743
1729
|
}
|
|
1744
1730
|
return null;
|
|
1745
|
-
},
|
|
1731
|
+
}, q = {
|
|
1746
1732
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
1747
1733
|
access_token_invalid: "access_token_invalid",
|
|
1748
1734
|
id_token_invalid: "id_token_invalid"
|
|
1749
1735
|
};
|
|
1750
|
-
function
|
|
1736
|
+
function it(e, t, n) {
|
|
1751
1737
|
return e.issuedAt ? typeof e.issuedAt == "string" ? parseInt(e.issuedAt, 10) : e.issuedAt : t && t.iat ? t.iat : n && n.iat ? n.iat : (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
1752
1738
|
}
|
|
1753
|
-
var
|
|
1739
|
+
var at = (e, t = null, n) => {
|
|
1754
1740
|
if (!e) return null;
|
|
1755
1741
|
let r, i = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
|
|
1756
|
-
r = e.accessTokenPayload === void 0 ?
|
|
1742
|
+
r = e.accessTokenPayload === void 0 ? rt(e.accessToken) : e.accessTokenPayload;
|
|
1757
1743
|
let a;
|
|
1758
1744
|
a = t != null && "idToken" in t && !("idToken" in e) ? t.idToken : e.idToken;
|
|
1759
|
-
let o = e.idTokenPayload ? e.idTokenPayload :
|
|
1760
|
-
e.issuedAt =
|
|
1745
|
+
let o = e.idTokenPayload ? e.idTokenPayload : rt(a), s = o && o.exp ? o.exp : Number.MAX_VALUE, c = r && r.exp ? r.exp : e.issuedAt + i;
|
|
1746
|
+
e.issuedAt = it(e, r, o);
|
|
1761
1747
|
let l;
|
|
1762
|
-
l = e.expiresAt ? e.expiresAt : n ===
|
|
1748
|
+
l = e.expiresAt ? e.expiresAt : n === q.access_token_invalid ? c : n === q.id_token_invalid || s < c ? s : c;
|
|
1763
1749
|
let u = {
|
|
1764
1750
|
...e,
|
|
1765
1751
|
idTokenPayload: o,
|
|
@@ -1775,7 +1761,7 @@ var ot = (e, t = null, n) => {
|
|
|
1775
1761
|
};
|
|
1776
1762
|
}
|
|
1777
1763
|
return u;
|
|
1778
|
-
},
|
|
1764
|
+
}, ot = (e, t, n) => {
|
|
1779
1765
|
if (!e) return null;
|
|
1780
1766
|
e.issued_at ||= (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
1781
1767
|
let r = {
|
|
@@ -1786,11 +1772,11 @@ var ot = (e, t = null, n) => {
|
|
|
1786
1772
|
tokenType: e.token_type,
|
|
1787
1773
|
issuedAt: e.issued_at
|
|
1788
1774
|
};
|
|
1789
|
-
return "refresh_token" in e && (r.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (r.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (r.idTokenPayload = e.idTokenPayload),
|
|
1790
|
-
},
|
|
1775
|
+
return "refresh_token" in e && (r.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (r.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (r.idTokenPayload = e.idTokenPayload), at(r, t, n);
|
|
1776
|
+
}, J = (e, t) => {
|
|
1791
1777
|
let n = t - (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
1792
1778
|
return Math.round(n - e);
|
|
1793
|
-
},
|
|
1779
|
+
}, st = (e, t = 0) => e ? J(t, e.expiresAt) > 0 : !1, ct = async (e, t = 200, n = 50) => {
|
|
1794
1780
|
let r = n, i = await e.syncTokensInfoAsync();
|
|
1795
1781
|
for (; [
|
|
1796
1782
|
G.REQUIRE_SYNC_TOKENS,
|
|
@@ -1801,14 +1787,14 @@ var ot = (e, t = null, n) => {
|
|
|
1801
1787
|
await e.renewTokensAsync({});
|
|
1802
1788
|
break;
|
|
1803
1789
|
}
|
|
1804
|
-
await
|
|
1790
|
+
await X({ milliseconds: t }), --r, i = await e.syncTokensInfoAsync();
|
|
1805
1791
|
}
|
|
1806
1792
|
return {
|
|
1807
|
-
isTokensValid:
|
|
1793
|
+
isTokensValid: st(e.getTokens()),
|
|
1808
1794
|
tokens: e.getTokens(),
|
|
1809
1795
|
numberWaited: r - n
|
|
1810
1796
|
};
|
|
1811
|
-
},
|
|
1797
|
+
}, lt = (e, t, n) => {
|
|
1812
1798
|
if (e.idTokenPayload) {
|
|
1813
1799
|
let r = e.idTokenPayload;
|
|
1814
1800
|
if (n.issuer !== r.iss) return {
|
|
@@ -1834,16 +1820,16 @@ var ot = (e, t = null, n) => {
|
|
|
1834
1820
|
isValid: !0,
|
|
1835
1821
|
reason: ""
|
|
1836
1822
|
};
|
|
1837
|
-
},
|
|
1823
|
+
}, ut = "7.29.5", dt = null, Y, X = ({ milliseconds: e }) => new Promise((t) => b.setTimeout(t, e)), ft = (e = "/") => {
|
|
1838
1824
|
try {
|
|
1839
|
-
|
|
1825
|
+
Y = new AbortController(), fetch(`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: Y.signal }).catch((e) => {
|
|
1840
1826
|
console.log(e);
|
|
1841
|
-
}),
|
|
1827
|
+
}), X({ milliseconds: 15e4 }).then(() => ft(e));
|
|
1842
1828
|
} catch (e) {
|
|
1843
1829
|
console.log(e);
|
|
1844
1830
|
}
|
|
1845
|
-
},
|
|
1846
|
-
|
|
1831
|
+
}, pt = () => {
|
|
1832
|
+
Y && Y.abort();
|
|
1847
1833
|
}, mt = (e) => {
|
|
1848
1834
|
let t = `oidc.tabId.${e}`, n = sessionStorage.getItem(t);
|
|
1849
1835
|
if (n) return n;
|
|
@@ -1905,7 +1891,7 @@ var ot = (e, t = null, n) => {
|
|
|
1905
1891
|
}, $ = async (e, t) => {
|
|
1906
1892
|
let n = e.service_worker_relative_url;
|
|
1907
1893
|
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !n || e.service_worker_activate() === !1) return null;
|
|
1908
|
-
let r = `${n}?v=${
|
|
1894
|
+
let r = `${n}?v=${ut}`, i = e.service_worker_register ? n : r;
|
|
1909
1895
|
vt.has(i) || vt.set(i, e.service_worker_register ? e.service_worker_register(n) : navigator.serviceWorker.register(r, { updateViaCache: "none" }));
|
|
1910
1896
|
let a = null;
|
|
1911
1897
|
try {
|
|
@@ -1915,7 +1901,7 @@ var ot = (e, t = null, n) => {
|
|
|
1915
1901
|
throw e;
|
|
1916
1902
|
}
|
|
1917
1903
|
let o = `oidc.sw.version_mismatch_reload.${t}`, s = async (e) => {
|
|
1918
|
-
|
|
1904
|
+
pt(), console.log("New SW waiting – SKIP_WAITING");
|
|
1919
1905
|
try {
|
|
1920
1906
|
await new Promise((n, r) => {
|
|
1921
1907
|
let i = new MessageChannel(), a = null, o = () => {
|
|
@@ -1948,7 +1934,7 @@ var ot = (e, t = null, n) => {
|
|
|
1948
1934
|
let e = a.waiting;
|
|
1949
1935
|
e ? await s(e) : console.warn("sendSkipWaiting called but no waiting service worker found");
|
|
1950
1936
|
}, l = (e) => {
|
|
1951
|
-
|
|
1937
|
+
pt(), e.addEventListener("statechange", async () => {
|
|
1952
1938
|
if (e.state === "installed" && navigator.serviceWorker.controller) {
|
|
1953
1939
|
if (St() >= xt) {
|
|
1954
1940
|
console.warn("SW trackInstallingWorker: skipping SKIP_WAITING because the reload budget is exhausted");
|
|
@@ -1980,7 +1966,7 @@ var ot = (e, t = null, n) => {
|
|
|
1980
1966
|
console.warn(`SW controllerchange: reload budget exhausted (${e - 1} reloads). Skipping reload to avoid infinite loop.`);
|
|
1981
1967
|
return;
|
|
1982
1968
|
}
|
|
1983
|
-
Q = !0, console.log("SW controller changed – reloading page"),
|
|
1969
|
+
Q = !0, console.log("SW controller changed – reloading page"), pt(), window.location.reload();
|
|
1984
1970
|
}));
|
|
1985
1971
|
let u = async (e) => Z(a)({
|
|
1986
1972
|
type: "clear",
|
|
@@ -1999,30 +1985,30 @@ var ot = (e, t = null, n) => {
|
|
|
1999
1985
|
},
|
|
2000
1986
|
configurationName: t
|
|
2001
1987
|
}), s = i.version;
|
|
2002
|
-
if (s !== "7.29.
|
|
2003
|
-
console.warn(`Service worker ${s} version mismatch with js client version ${
|
|
1988
|
+
if (s !== "7.29.5") {
|
|
1989
|
+
console.warn(`Service worker ${s} version mismatch with js client version ${ut}, unregistering and reloading`);
|
|
2004
1990
|
let e = parseInt(sessionStorage.getItem(o) ?? "0", 10);
|
|
2005
1991
|
if (e < 3) {
|
|
2006
|
-
if (sessionStorage.setItem(o, String(e + 1)), a.waiting) return await c(), await
|
|
1992
|
+
if (sessionStorage.setItem(o, String(e + 1)), a.waiting) return await c(), await X({ milliseconds: 500 }), Q || (Q = !0, window.location.reload()), new Promise(() => {});
|
|
2007
1993
|
{
|
|
2008
|
-
|
|
1994
|
+
pt();
|
|
2009
1995
|
try {
|
|
2010
1996
|
await a.update();
|
|
2011
1997
|
} catch (e) {
|
|
2012
1998
|
console.error(e);
|
|
2013
1999
|
}
|
|
2014
2000
|
let e = await a.unregister();
|
|
2015
|
-
return console.log(`Service worker unregistering ${e}`), await
|
|
2001
|
+
return console.log(`Service worker unregistering ${e}`), await X({ milliseconds: 500 }), Q || (Q = !0, window.location.reload()), new Promise(() => {});
|
|
2016
2002
|
}
|
|
2017
2003
|
}
|
|
2018
2004
|
console.error(`Service worker version mismatch persists after ${e} attempt(s). Continuing with mismatched version.`);
|
|
2019
2005
|
} else sessionStorage.removeItem(o), wt();
|
|
2020
2006
|
return {
|
|
2021
|
-
tokens:
|
|
2007
|
+
tokens: ot(i.tokens, null, r.token_renew_mode),
|
|
2022
2008
|
status: i.status
|
|
2023
2009
|
};
|
|
2024
2010
|
}, f = (e = "/") => {
|
|
2025
|
-
|
|
2011
|
+
dt ?? (dt = "not_null", ft(e));
|
|
2026
2012
|
}, p = (e) => Z(a)({
|
|
2027
2013
|
type: "setSessionState",
|
|
2028
2014
|
data: { sessionState: e },
|
|
@@ -2196,21 +2182,21 @@ var ot = (e, t = null, n) => {
|
|
|
2196
2182
|
}
|
|
2197
2183
|
async getValidTokenAsync(e = 200, t = 50) {
|
|
2198
2184
|
let n = this._oidc;
|
|
2199
|
-
return
|
|
2185
|
+
return ct({
|
|
2200
2186
|
getTokens: () => n.tokens,
|
|
2201
2187
|
configuration: {
|
|
2202
2188
|
token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
|
|
2203
2189
|
refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
|
|
2204
2190
|
},
|
|
2205
2191
|
syncTokensInfoAsync: async () => {
|
|
2206
|
-
let { status: e } = await
|
|
2192
|
+
let { status: e } = await et(n)(n.configuration, n.configurationName, n.tokens, !1);
|
|
2207
2193
|
return e;
|
|
2208
2194
|
},
|
|
2209
2195
|
renewTokensAsync: n.renewTokensAsync.bind(n)
|
|
2210
2196
|
}, e, t);
|
|
2211
2197
|
}
|
|
2212
2198
|
fetchWithTokens(e, t = !1) {
|
|
2213
|
-
return
|
|
2199
|
+
return Ge(e, this._oidc, t);
|
|
2214
2200
|
}
|
|
2215
2201
|
async userInfoAsync(e = !1, t = !1) {
|
|
2216
2202
|
return this._oidc.userInfoAsync(e, t);
|
|
@@ -2252,4 +2238,4 @@ var ot = (e, t = null, n) => {
|
|
|
2252
2238
|
SW_VERSION_MISMATCH_RELOAD: "oidc.sw.version_mismatch_reload."
|
|
2253
2239
|
}, Mt = "oidc.sw.controllerchange_reload_count", Nt = (e, t) => `${e}${t}`, Pt = (e, t, n = "default") => `${e}_${t}#tabId=${n}`, Ft = (e, t = "default") => `${At}_${e}#tabId=${t}`, It = (e) => typeof e == "string" && Object.values(Ot).includes(e);
|
|
2254
2240
|
//#endregion
|
|
2255
|
-
export { At as DPOP_TOKEN_PLACEHOLDER_PREFIX, Et as OidcClient, d as OidcError, c as OidcErrorCode, j as OidcLocation, N as OidcStateError, M as OidcStateErrorCode, Dt as PROTOCOL_VERSION, F as PushedAuthorizationRequestError, P as PushedAuthorizationRequestErrorCode, jt as STORAGE_KEY_PREFIX, Mt as SW_CONTROLLER_CHANGE_RELOAD_COUNT_KEY, Ot as ServiceWorkerMessageType, kt as TOKEN_PLACEHOLDERS, B as TokenAutomaticRenewMode,
|
|
2241
|
+
export { At as DPOP_TOKEN_PLACEHOLDER_PREFIX, Et as OidcClient, d as OidcError, c as OidcErrorCode, j as OidcLocation, N as OidcStateError, M as OidcStateErrorCode, Dt as PROTOCOL_VERSION, F as PushedAuthorizationRequestError, P as PushedAuthorizationRequestErrorCode, jt as STORAGE_KEY_PREFIX, Mt as SW_CONTROLLER_CHANGE_RELOAD_COUNT_KEY, Ot as ServiceWorkerMessageType, kt as TOKEN_PLACEHOLDERS, B as TokenAutomaticRenewMode, q as TokenRenewMode, Ft as buildDpopSecuredPlaceholder, Pt as buildSecuredTokenPlaceholder, Nt as buildStorageKey, qe as getFetchDefault, z as getParseQueryStringFromLocation, Pe as getPath, f as isOidcError, ye as isOidcStateError, be as isPushedAuthorizationRequestError, It as isServiceWorkerMessageType, Tt as signalServiceWorkerAsync };
|