@axa-fr/oidc-client 7.29.3 → 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/README.md +302 -565
- 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 +180 -191
- 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 +12 -12
- 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
|
@@ -160,7 +160,7 @@ var e = {
|
|
|
160
160
|
ENDPOINT_UNAVAILABLE: "ENDPOINT_UNAVAILABLE",
|
|
161
161
|
REQUEST_FAILED: "REQUEST_FAILED",
|
|
162
162
|
INVALID_RESPONSE: "INVALID_RESPONSE"
|
|
163
|
-
}, l = new Set(Object.values(c)), u = new Set([
|
|
163
|
+
}, l = new Set(Object.values(c)), u = /* @__PURE__ */ new Set([
|
|
164
164
|
"login",
|
|
165
165
|
"callback",
|
|
166
166
|
"refresh",
|
|
@@ -183,7 +183,7 @@ var e = {
|
|
|
183
183
|
let a = m(e);
|
|
184
184
|
return new d(a, n, {
|
|
185
185
|
phase: r,
|
|
186
|
-
retryable:
|
|
186
|
+
retryable: a !== c.LOGIN_REQUIRED && a !== c.CONSENT_REQUIRED && a !== c.INTERACTION_REQUIRED && (a === c.DPOP_NONCE_REQUIRED || e === "server_error" || e === "temporarily_unavailable" || p(i)),
|
|
187
187
|
oauthError: e,
|
|
188
188
|
oauthErrorDescription: t,
|
|
189
189
|
status: i
|
|
@@ -284,14 +284,14 @@ var e = {
|
|
|
284
284
|
let n;
|
|
285
285
|
t && "state" in t && (n = t.state, delete t.state);
|
|
286
286
|
try {
|
|
287
|
-
let c =
|
|
288
|
-
...r.extras
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
287
|
+
let c = r.extras ? {
|
|
288
|
+
...r.extras,
|
|
289
|
+
...t
|
|
290
|
+
} : t, l = await s({
|
|
291
|
+
...c,
|
|
292
292
|
prompt: "none"
|
|
293
293
|
}, n, o);
|
|
294
|
-
if (
|
|
294
|
+
if (l) return a.tokens = l.tokens, i(e.token_acquired, {}), a.timeoutId = W(a, a.tokens.expiresAt, t, o), {};
|
|
295
295
|
} catch (e) {
|
|
296
296
|
return e;
|
|
297
297
|
}
|
|
@@ -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 {
|
|
@@ -742,66 +739,61 @@ var he = () => {
|
|
|
742
739
|
if (a.name === "AbortError" || a.message === "Network request failed") {
|
|
743
740
|
if (i <= 1) return await L(e)(t, n, r, i + 1);
|
|
744
741
|
throw a;
|
|
745
|
-
}
|
|
742
|
+
}
|
|
743
|
+
throw console.error(a.message), a;
|
|
746
744
|
}
|
|
747
745
|
return a;
|
|
748
746
|
}, Te = {
|
|
749
747
|
refresh_token: "refresh_token",
|
|
750
748
|
access_token: "access_token"
|
|
751
|
-
}, 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) => {
|
|
752
754
|
let s = {
|
|
753
755
|
token: n,
|
|
754
756
|
token_type_hint: r,
|
|
755
757
|
client_id: i
|
|
756
758
|
};
|
|
757
759
|
for (let [e, t] of Object.entries(a)) s[e] === void 0 && (s[e] = t);
|
|
758
|
-
let c =
|
|
759
|
-
for (let e in s) {
|
|
760
|
-
let t = encodeURIComponent(e), n = encodeURIComponent(s[e]);
|
|
761
|
-
c.push(`${t}=${n}`);
|
|
762
|
-
}
|
|
763
|
-
let l = c.join("&"), u = await L(e)(t, {
|
|
760
|
+
let c = Ee(s), l = await L(e)(t, {
|
|
764
761
|
method: "POST",
|
|
765
762
|
headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
|
|
766
|
-
body:
|
|
763
|
+
body: c
|
|
767
764
|
}, o);
|
|
768
|
-
if (
|
|
769
|
-
let e = await
|
|
765
|
+
if (l.status !== 200) {
|
|
766
|
+
let e = await Oe(l);
|
|
770
767
|
return {
|
|
771
768
|
success: !1,
|
|
772
|
-
status:
|
|
769
|
+
status: l.status,
|
|
773
770
|
oauthError: typeof e?.error == "string" ? e.error : void 0,
|
|
774
771
|
oauthErrorDescription: typeof e?.error_description == "string" ? e.error_description : void 0
|
|
775
772
|
};
|
|
776
773
|
}
|
|
777
774
|
return {
|
|
778
775
|
success: !0,
|
|
779
|
-
status:
|
|
776
|
+
status: l.status
|
|
780
777
|
};
|
|
781
|
-
},
|
|
778
|
+
}, Oe = async (e) => {
|
|
782
779
|
try {
|
|
783
780
|
return await e.json();
|
|
784
781
|
} catch {
|
|
785
782
|
return null;
|
|
786
783
|
}
|
|
787
|
-
},
|
|
784
|
+
}, ke = (e) => async (t, n, r = 1e4) => {
|
|
788
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.");
|
|
789
|
-
let i =
|
|
790
|
-
for (let e in n) {
|
|
791
|
-
let t = encodeURIComponent(e), r = encodeURIComponent(n[e]);
|
|
792
|
-
i.push(`${t}=${r}`);
|
|
793
|
-
}
|
|
794
|
-
let a;
|
|
786
|
+
let i = Ee(n), a;
|
|
795
787
|
try {
|
|
796
788
|
a = await L(e)(t, {
|
|
797
789
|
method: "POST",
|
|
798
790
|
headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
|
|
799
|
-
body: i
|
|
791
|
+
body: i
|
|
800
792
|
}, r);
|
|
801
793
|
} catch (e) {
|
|
802
794
|
throw new F(P.REQUEST_FAILED, "The pushed authorization request could not be sent.", { cause: e });
|
|
803
795
|
}
|
|
804
|
-
let o = await
|
|
796
|
+
let o = await Oe(a);
|
|
805
797
|
if (a.status !== 201) {
|
|
806
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(": ");
|
|
807
799
|
throw new F(P.REQUEST_FAILED, `The pushed authorization request failed with HTTP status ${a.status}${n ? ` (${n})` : ""}.`, {
|
|
@@ -815,89 +807,79 @@ var he = () => {
|
|
|
815
807
|
request_uri: o.request_uri,
|
|
816
808
|
expires_in: o.expires_in
|
|
817
809
|
};
|
|
818
|
-
},
|
|
810
|
+
}, Ae = (e) => async (t, n, r, i, a = {}, o, s = 1e4) => {
|
|
819
811
|
for (let [e, t] of Object.entries(r)) n[e] === void 0 && (n[e] = t);
|
|
820
|
-
let c =
|
|
821
|
-
for (let e in n) {
|
|
822
|
-
let t = encodeURIComponent(e), r = encodeURIComponent(n[e]);
|
|
823
|
-
c.push(`${t}=${r}`);
|
|
824
|
-
}
|
|
825
|
-
let l = c.join("&"), u = await L(e)(t, {
|
|
812
|
+
let c = Ee(n), l = await L(e)(t, {
|
|
826
813
|
method: "POST",
|
|
827
814
|
headers: {
|
|
828
815
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
829
816
|
...a
|
|
830
817
|
},
|
|
831
|
-
body:
|
|
818
|
+
body: c
|
|
832
819
|
}, s);
|
|
833
|
-
if (
|
|
834
|
-
let e = await
|
|
820
|
+
if (l.status !== 200) {
|
|
821
|
+
let e = await Oe(l);
|
|
835
822
|
return {
|
|
836
823
|
success: !1,
|
|
837
|
-
status:
|
|
824
|
+
status: l.status,
|
|
838
825
|
data: e,
|
|
839
826
|
oauthError: typeof e?.error == "string" ? e.error : void 0,
|
|
840
827
|
oauthErrorDescription: typeof e?.error_description == "string" ? e.error_description : void 0,
|
|
841
|
-
demonstratingProofOfPossessionNonce:
|
|
828
|
+
demonstratingProofOfPossessionNonce: l.headers?.has(R) ? l.headers.get(R) : null
|
|
842
829
|
};
|
|
843
830
|
}
|
|
844
|
-
let
|
|
845
|
-
return
|
|
831
|
+
let u = await l.json(), d = null;
|
|
832
|
+
return l.headers.has(R) && (d = l.headers.get(R)), {
|
|
846
833
|
success: !0,
|
|
847
|
-
status:
|
|
848
|
-
data:
|
|
849
|
-
demonstratingProofOfPossessionNonce:
|
|
834
|
+
status: l.status,
|
|
835
|
+
data: ot(u, i, o),
|
|
836
|
+
demonstratingProofOfPossessionNonce: d
|
|
850
837
|
};
|
|
851
|
-
},
|
|
838
|
+
}, je = (e, t) => async (n, r, i) => {
|
|
852
839
|
r = r ? { ...r } : {};
|
|
853
840
|
let a = A(128), o = await de(a);
|
|
854
841
|
if (await e.setCodeVerifierAsync(a), await e.setStateAsync(r.state), r.code_challenge = o, r.code_challenge_method = "S256", i) {
|
|
855
|
-
let e = await
|
|
842
|
+
let e = await ke(i.fetch)(i.endpoint, r, i.timeoutMs);
|
|
856
843
|
t.open(`${n}?client_id=${encodeURIComponent(r.client_id)}&request_uri=${encodeURIComponent(e.request_uri)}`);
|
|
857
844
|
return;
|
|
858
845
|
}
|
|
859
846
|
let s = "";
|
|
860
|
-
if (r) for (let [e, t] of Object.entries(r)) s === "" ?
|
|
847
|
+
if (r) for (let [e, t] of Object.entries(r)) s += s === "" ? "?" : "&", s += `${e}=${encodeURIComponent(t)}`;
|
|
861
848
|
t.open(`${n}${s}`);
|
|
862
|
-
}, R = "DPoP-Nonce",
|
|
849
|
+
}, R = "DPoP-Nonce", Me = (e) => async (t, n, r, i, a = 1e4, o = !1) => {
|
|
863
850
|
n = n ? { ...n } : {}, n.code_verifier = await e.getCodeVerifierAsync();
|
|
864
|
-
let s =
|
|
865
|
-
for (let e in n) {
|
|
866
|
-
let t = encodeURIComponent(e), r = encodeURIComponent(n[e]);
|
|
867
|
-
s.push(`${t}=${r}`);
|
|
868
|
-
}
|
|
869
|
-
let c = s.join("&"), l = await L(fetch)(t, {
|
|
851
|
+
let s = Ee(n), c = await L(fetch)(t, {
|
|
870
852
|
method: "POST",
|
|
871
853
|
headers: {
|
|
872
854
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
873
855
|
...r
|
|
874
856
|
},
|
|
875
|
-
body:
|
|
857
|
+
body: s
|
|
876
858
|
}, a);
|
|
877
|
-
if (
|
|
878
|
-
let t = await
|
|
859
|
+
if (c.status !== 200) {
|
|
860
|
+
let t = await Oe(c), n = typeof t?.error == "string" ? t.error : void 0;
|
|
879
861
|
return o && n === "use_dpop_nonce" || await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]), {
|
|
880
862
|
success: !1,
|
|
881
|
-
status:
|
|
863
|
+
status: c.status,
|
|
882
864
|
data: t,
|
|
883
865
|
oauthError: n,
|
|
884
866
|
oauthErrorDescription: typeof t?.error_description == "string" ? t.error_description : void 0,
|
|
885
|
-
demonstratingProofOfPossessionNonce:
|
|
867
|
+
demonstratingProofOfPossessionNonce: c.headers?.has(R) ? c.headers.get(R) : null
|
|
886
868
|
};
|
|
887
869
|
}
|
|
888
870
|
await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]);
|
|
889
|
-
let
|
|
890
|
-
|
|
891
|
-
let
|
|
871
|
+
let l = null;
|
|
872
|
+
c.headers.has(R) && (l = c.headers.get(R));
|
|
873
|
+
let u = await c.json();
|
|
892
874
|
return {
|
|
893
875
|
success: !0,
|
|
894
876
|
data: {
|
|
895
877
|
state: n.state,
|
|
896
|
-
tokens:
|
|
897
|
-
demonstratingProofOfPossessionNonce:
|
|
878
|
+
tokens: ot(u, null, i),
|
|
879
|
+
demonstratingProofOfPossessionNonce: l
|
|
898
880
|
}
|
|
899
881
|
};
|
|
900
|
-
},
|
|
882
|
+
}, Ne = (e) => {
|
|
901
883
|
let t = e.match(/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
902
884
|
if (!t) throw Error("Invalid URL");
|
|
903
885
|
let n = t[6], r = t[7];
|
|
@@ -905,7 +887,7 @@ var he = () => {
|
|
|
905
887
|
let e = r.split("?");
|
|
906
888
|
e.length === 2 && (r = e[0], n = e[1]);
|
|
907
889
|
}
|
|
908
|
-
return n.startsWith("?") && (n = n.slice(1)),
|
|
890
|
+
return n.startsWith("?") && (n = n.slice(1)), {
|
|
909
891
|
href: e,
|
|
910
892
|
protocol: t[1],
|
|
911
893
|
host: t[2],
|
|
@@ -915,19 +897,22 @@ var he = () => {
|
|
|
915
897
|
search: n,
|
|
916
898
|
hash: r
|
|
917
899
|
};
|
|
918
|
-
},
|
|
919
|
-
let t =
|
|
900
|
+
}, Pe = (e) => {
|
|
901
|
+
let t = Ne(e), { path: n } = t;
|
|
920
902
|
n.endsWith("/") && (n = n.slice(0, -1));
|
|
921
903
|
let { hash: r } = t;
|
|
922
904
|
return (r === "#" || r === "#_=_") && (r = ""), r && (n += r), n;
|
|
923
905
|
}, z = (e) => {
|
|
924
|
-
let { search: t } =
|
|
925
|
-
return
|
|
926
|
-
},
|
|
927
|
-
let t = {}
|
|
928
|
-
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
|
+
}
|
|
929
914
|
return t;
|
|
930
|
-
},
|
|
915
|
+
}, Ie = (t, n, r, a, o, s = () => window.fetch) => (c = void 0, l = null, u = !1, d = void 0) => {
|
|
931
916
|
let f = l;
|
|
932
917
|
return l = { ...l }, (async () => {
|
|
933
918
|
let p = c || o.getPath();
|
|
@@ -967,13 +952,13 @@ var he = () => {
|
|
|
967
952
|
fetch: s(),
|
|
968
953
|
timeoutMs: n.par_request_timeout
|
|
969
954
|
} : void 0;
|
|
970
|
-
await
|
|
955
|
+
await je(g, o)(h.authorizationEndpoint, _, x);
|
|
971
956
|
} catch (t) {
|
|
972
957
|
let n = _(t) ? g(t, "login") : t;
|
|
973
958
|
throw r(e.loginAsync_error, n), n;
|
|
974
959
|
}
|
|
975
960
|
})();
|
|
976
|
-
},
|
|
961
|
+
}, Le = (t) => async (n = !1) => {
|
|
977
962
|
try {
|
|
978
963
|
t.publishEvent(e.loginCallbackAsync_begin, {});
|
|
979
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;
|
|
@@ -999,11 +984,11 @@ var he = () => {
|
|
|
999
984
|
if (y?.extras) for (let [e, t] of Object.entries(y.extras)) e.endsWith(":token_request") && (S[e.replace(":token_request", "")] = t);
|
|
1000
985
|
let C = u.tokenEndpoint, w = {}, T;
|
|
1001
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)));
|
|
1002
|
-
let E = await
|
|
987
|
+
let E = await Me(_)(C, {
|
|
1003
988
|
...x,
|
|
1004
989
|
...S
|
|
1005
990
|
}, w, t.configuration.token_renew_mode, l, r.demonstrating_proof_of_possession);
|
|
1006
|
-
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, {
|
|
1007
992
|
...x,
|
|
1008
993
|
...S
|
|
1009
994
|
}, w, t.configuration.token_renew_mode, l)) : !E.success && r.demonstrating_proof_of_possession && await Promise.all([_.setCodeVerifierAsync(null), _.setStateAsync(null)]), !E.success) {
|
|
@@ -1021,7 +1006,7 @@ var he = () => {
|
|
|
1021
1006
|
phase: n ? "refresh" : "callback",
|
|
1022
1007
|
retryable: !1
|
|
1023
1008
|
});
|
|
1024
|
-
let { isValid: ee, reason: te } =
|
|
1009
|
+
let { isValid: ee, reason: te } = lt(O, v.nonce, u);
|
|
1025
1010
|
if (!ee) {
|
|
1026
1011
|
let e = `Tokens are not OpenID valid, reason: ${te}`;
|
|
1027
1012
|
throw te.startsWith("Nonce does not match") ? new d(c.INVALID_NONCE, e, {
|
|
@@ -1049,10 +1034,10 @@ var he = () => {
|
|
|
1049
1034
|
let i = !f(r) && _(r) ? g(r, n ? "refresh" : "callback") : r;
|
|
1050
1035
|
throw console.error(i), t.publishEvent(e.loginCallbackAsync_error, i), i;
|
|
1051
1036
|
}
|
|
1052
|
-
},
|
|
1037
|
+
}, Re = {
|
|
1053
1038
|
access_token: "access_token",
|
|
1054
1039
|
refresh_token: "refresh_token"
|
|
1055
|
-
},
|
|
1040
|
+
}, ze = (e, t) => {
|
|
1056
1041
|
let n = {};
|
|
1057
1042
|
if (e) {
|
|
1058
1043
|
for (let [r, i] of Object.entries(e)) if (r.endsWith(t)) {
|
|
@@ -1062,27 +1047,27 @@ var he = () => {
|
|
|
1062
1047
|
return n;
|
|
1063
1048
|
}
|
|
1064
1049
|
return n;
|
|
1065
|
-
},
|
|
1050
|
+
}, Be = (e) => {
|
|
1066
1051
|
let t = {};
|
|
1067
1052
|
if (e) {
|
|
1068
1053
|
for (let [n, r] of Object.entries(e)) n.includes(":") || (t[n] = r);
|
|
1069
1054
|
return t;
|
|
1070
1055
|
}
|
|
1071
1056
|
return t;
|
|
1072
|
-
},
|
|
1057
|
+
}, Ve = (e) => async (t) => {
|
|
1073
1058
|
b.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
1074
1059
|
let n = await $(e.configuration, e.configurationName);
|
|
1075
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;
|
|
1076
|
-
},
|
|
1061
|
+
}, He = (t, n) => async () => {
|
|
1077
1062
|
let r = t.tokens?.idTokenPayload?.sub ?? null;
|
|
1078
1063
|
await t.destroyAsync("LOGGED_OUT");
|
|
1079
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);
|
|
1080
|
-
},
|
|
1065
|
+
}, Ue = (e, t, n, r) => {
|
|
1081
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);
|
|
1082
1067
|
let i = "";
|
|
1083
|
-
for (let [e, n] of Object.entries(t)) n != null && (i === "" ?
|
|
1068
|
+
for (let [e, n] of Object.entries(t)) n != null && (i += i === "" ? "?" : "&", i += `${e}=${encodeURIComponent(n)}`);
|
|
1084
1069
|
return `${e}${i}`;
|
|
1085
|
-
},
|
|
1070
|
+
}, We = (t, n, r, i, a) => async (o = void 0, s = null) => {
|
|
1086
1071
|
let l = t.configuration, u;
|
|
1087
1072
|
try {
|
|
1088
1073
|
u = await t.initAsync(l.authority, l.authority_configuration);
|
|
@@ -1100,13 +1085,13 @@ var he = () => {
|
|
|
1100
1085
|
let n = u.revocationEndpoint;
|
|
1101
1086
|
if (n) {
|
|
1102
1087
|
let i = [], a = t.tokens ? t.tokens.accessToken : null;
|
|
1103
|
-
if (a && l.logout_tokens_to_invalidate.includes(
|
|
1104
|
-
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);
|
|
1105
1090
|
i.push(t);
|
|
1106
1091
|
}
|
|
1107
1092
|
let o = t.tokens ? t.tokens.refreshToken : null;
|
|
1108
|
-
if (o && l.logout_tokens_to_invalidate.includes(
|
|
1109
|
-
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);
|
|
1110
1095
|
i.push(t);
|
|
1111
1096
|
}
|
|
1112
1097
|
if (i.length > 0) {
|
|
@@ -1124,17 +1109,17 @@ var he = () => {
|
|
|
1124
1109
|
let r = !f(n) && _(n) ? g(n, "logout") : n;
|
|
1125
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);
|
|
1126
1111
|
}
|
|
1127
|
-
let o =
|
|
1112
|
+
let o = ze(s, ":oidc");
|
|
1128
1113
|
if (o && o.no_reload === "true") {
|
|
1129
|
-
await
|
|
1114
|
+
await He(t, n)(), t.isLoggingOut = !1;
|
|
1130
1115
|
return;
|
|
1131
1116
|
}
|
|
1132
|
-
let m =
|
|
1117
|
+
let m = Be(s);
|
|
1133
1118
|
if (u.endSessionEndpoint) {
|
|
1134
|
-
let e =
|
|
1119
|
+
let e = Ue(u.endSessionEndpoint, m, y, v);
|
|
1135
1120
|
a.open(e);
|
|
1136
1121
|
} else a.reload();
|
|
1137
|
-
await
|
|
1122
|
+
await He(t, n)();
|
|
1138
1123
|
} catch (n) {
|
|
1139
1124
|
t.isLoggingOut = !1;
|
|
1140
1125
|
let r = !f(n) && _(n) ? g(n, "logout") : n;
|
|
@@ -1142,17 +1127,17 @@ var he = () => {
|
|
|
1142
1127
|
}
|
|
1143
1128
|
}, B = /* @__PURE__ */ function(e) {
|
|
1144
1129
|
return e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e;
|
|
1145
|
-
}({}),
|
|
1130
|
+
}({}), Ge = (t, n, r = !1, i = "api_request") => async (...a) => {
|
|
1146
1131
|
let [o, s, ...l] = a, u = s ? { ...s } : { method: "GET" }, f = new Headers();
|
|
1147
1132
|
u.headers && (f = u.headers instanceof Headers ? u.headers : new Headers(u.headers));
|
|
1148
|
-
let p = (await
|
|
1133
|
+
let p = (await ct({
|
|
1149
1134
|
getTokens: () => n.tokens,
|
|
1150
1135
|
configuration: {
|
|
1151
1136
|
token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
|
|
1152
1137
|
refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
|
|
1153
1138
|
},
|
|
1154
1139
|
syncTokensInfoAsync: async () => {
|
|
1155
|
-
let { status: e } = await
|
|
1140
|
+
let { status: e } = await et(n)(n.configuration, n.configurationName, n.tokens, !1);
|
|
1156
1141
|
return e;
|
|
1157
1142
|
},
|
|
1158
1143
|
renewTokensAsync: n.renewTokensAsync.bind(n)
|
|
@@ -1184,13 +1169,13 @@ var he = () => {
|
|
|
1184
1169
|
i === "api_request" && n.publishEvent(e.apiRequest_error, t);
|
|
1185
1170
|
}
|
|
1186
1171
|
return h;
|
|
1187
|
-
},
|
|
1172
|
+
}, Ke = (t) => async (n = !1, r = !1) => {
|
|
1188
1173
|
try {
|
|
1189
1174
|
if (t.userInfo != null && !n) return t.userInfo;
|
|
1190
1175
|
let i = !n && t.configuration.storage?.getItem(`oidc.${t.configurationName}.userInfo`);
|
|
1191
1176
|
if (i) return t.userInfo = JSON.parse(i), t.userInfo;
|
|
1192
1177
|
let a = t.configuration, o = (await t.initAsync(a.authority, a.authority_configuration)).userInfoEndpoint, s = await (async () => {
|
|
1193
|
-
let n = await
|
|
1178
|
+
let n = await Ge(fetch, t, r, "userinfo")(o);
|
|
1194
1179
|
if (n.status !== 200) {
|
|
1195
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", {
|
|
1196
1181
|
phase: "userinfo",
|
|
@@ -1207,11 +1192,11 @@ var he = () => {
|
|
|
1207
1192
|
let r = f(n) ? n : _(n) ? g(n, "userinfo") : n;
|
|
1208
1193
|
throw t.publishEvent(e.userInfoAsync_error, r), r;
|
|
1209
1194
|
}
|
|
1210
|
-
},
|
|
1195
|
+
}, qe = () => fetch, Je = class {
|
|
1211
1196
|
constructor(e) {
|
|
1212
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;
|
|
1213
1198
|
}
|
|
1214
|
-
}, 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) => {
|
|
1215
1200
|
let { parsedTokens: t, callbackPath: n, extras: r, scope: i } = await e.loginCallbackAsync();
|
|
1216
1201
|
return e.timeoutId = W(e, t.expiresAt, r, i), { callbackPath: n };
|
|
1217
1202
|
}, H = class t {
|
|
@@ -1227,7 +1212,7 @@ var he = () => {
|
|
|
1227
1212
|
monitor_session: e.monitor_session ?? !1,
|
|
1228
1213
|
refresh_time_before_tokens_expiration_in_second: a,
|
|
1229
1214
|
silent_login_timeout: e.silent_login_timeout ?? 12e3,
|
|
1230
|
-
token_renew_mode: e.token_renew_mode ??
|
|
1215
|
+
token_renew_mode: e.token_renew_mode ?? q.access_token_or_id_token_invalid,
|
|
1231
1216
|
demonstrating_proof_of_possession: e.demonstrating_proof_of_possession ?? !1,
|
|
1232
1217
|
authority_timeout_wellknowurl_in_millisecond: e.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
1233
1218
|
logout_tokens_to_invalidate: e.logout_tokens_to_invalidate ?? ["access_token", "refresh_token"],
|
|
@@ -1236,7 +1221,7 @@ var he = () => {
|
|
|
1236
1221
|
preload_user_info: e.preload_user_info ?? !1,
|
|
1237
1222
|
par: e.par ?? "disabled",
|
|
1238
1223
|
par_request_timeout: e.par_request_timeout ?? 1e4
|
|
1239
|
-
}, 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);
|
|
1240
1225
|
}
|
|
1241
1226
|
subscribeEvents(e) {
|
|
1242
1227
|
let t = A(16);
|
|
@@ -1255,7 +1240,7 @@ var he = () => {
|
|
|
1255
1240
|
});
|
|
1256
1241
|
}
|
|
1257
1242
|
static {
|
|
1258
|
-
this.getOrCreate = (e, t) => (n, r = "default") =>
|
|
1243
|
+
this.getOrCreate = (e, t) => (n, r = "default") => Ye(e, t)(n, r);
|
|
1259
1244
|
}
|
|
1260
1245
|
static get(e = "default") {
|
|
1261
1246
|
return Object.prototype.hasOwnProperty.call(V, e) ? V[e] : null;
|
|
@@ -1304,7 +1289,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1304
1289
|
async initAsync(e, t) {
|
|
1305
1290
|
if (this.initPromise !== null) return this.initPromise;
|
|
1306
1291
|
let n = async () => {
|
|
1307
|
-
if (t != null) return new
|
|
1292
|
+
if (t != null) return new Je({
|
|
1308
1293
|
authorization_endpoint: t.authorization_endpoint,
|
|
1309
1294
|
end_session_endpoint: t.end_session_endpoint,
|
|
1310
1295
|
revocation_endpoint: t.revocation_endpoint,
|
|
@@ -1331,14 +1316,14 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1331
1316
|
await C(this, V, this.configuration)(e, t, n, r);
|
|
1332
1317
|
}
|
|
1333
1318
|
async loginAsync(e = void 0, t = null, n = !1, r = void 0, i = !1) {
|
|
1334
|
-
return this.logoutPromise && await this.logoutPromise, this.loginPromise === null ? (
|
|
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(() => {
|
|
1335
1320
|
this.loginPromise = null;
|
|
1336
1321
|
})) : this.loginPromise;
|
|
1337
1322
|
}
|
|
1338
1323
|
async loginCallbackAsync(e = !1) {
|
|
1339
1324
|
if (this.loginCallbackPromise !== null) return this.loginCallbackPromise;
|
|
1340
1325
|
let n = async () => {
|
|
1341
|
-
let n = await
|
|
1326
|
+
let n = await Le(this)(e), r = n.tokens;
|
|
1342
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(), {
|
|
1343
1328
|
parsedTokens: r,
|
|
1344
1329
|
state: n.state,
|
|
@@ -1361,12 +1346,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1361
1346
|
return l && (o.nonce = l), await ie(window)(a.demonstrating_proof_of_possession_configuration)(c, n, t, o);
|
|
1362
1347
|
}
|
|
1363
1348
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1364
|
-
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1349
|
+
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise = Xe(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
|
|
1365
1350
|
this.loginCallbackWithAutoTokensRenewPromise = null;
|
|
1366
1351
|
})) : this.loginCallbackWithAutoTokensRenewPromise;
|
|
1367
1352
|
}
|
|
1368
1353
|
userInfoAsync(e = !1, t = !1) {
|
|
1369
|
-
return this.userInfoPromise === null ? (this.userInfoPromise =
|
|
1354
|
+
return this.userInfoPromise === null ? (this.userInfoPromise = Ke(this)(e, t), this.userInfoPromise.finally(() => {
|
|
1370
1355
|
this.userInfoPromise = null;
|
|
1371
1356
|
})) : this.userInfoPromise;
|
|
1372
1357
|
}
|
|
@@ -1374,7 +1359,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1374
1359
|
if (this.renewTokensPromise !== null) return this.renewTokensPromise;
|
|
1375
1360
|
if (!this.timeoutId) return null;
|
|
1376
1361
|
b.clearTimeout(this.timeoutId);
|
|
1377
|
-
let n =
|
|
1362
|
+
let n = Qe(this, !0, e, t);
|
|
1378
1363
|
return this.renewTokensPromise = n, n.finally(() => {
|
|
1379
1364
|
this.renewTokensPromise === n && (this.renewTokensPromise = null);
|
|
1380
1365
|
});
|
|
@@ -1392,10 +1377,10 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1392
1377
|
return n.tokens;
|
|
1393
1378
|
}
|
|
1394
1379
|
async destroyAsync(e) {
|
|
1395
|
-
return await
|
|
1380
|
+
return await Ve(this)(e);
|
|
1396
1381
|
}
|
|
1397
1382
|
async clearSessionAsync() {
|
|
1398
|
-
return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise =
|
|
1383
|
+
return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise = He(this, V)(), this.clearSessionPromise.finally(() => {
|
|
1399
1384
|
this.clearSessionPromise = null;
|
|
1400
1385
|
}));
|
|
1401
1386
|
}
|
|
@@ -1412,7 +1397,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1412
1397
|
}));
|
|
1413
1398
|
}
|
|
1414
1399
|
async logoutAsync(e = void 0, t = null) {
|
|
1415
|
-
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(() => {
|
|
1416
1401
|
this.logoutPromise = null;
|
|
1417
1402
|
}));
|
|
1418
1403
|
}
|
|
@@ -1426,7 +1411,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1426
1411
|
oauthErrorDescription: t?.oauthErrorDescription
|
|
1427
1412
|
});
|
|
1428
1413
|
};
|
|
1429
|
-
async function
|
|
1414
|
+
async function Ze(e, t, n, r = null) {
|
|
1430
1415
|
let a = await K(e)((t) => {
|
|
1431
1416
|
e.tokens = t;
|
|
1432
1417
|
}, 0, 0, t, n, r), { tokens: o, status: s } = a;
|
|
@@ -1438,12 +1423,12 @@ async function Xe(e, t, n, r = null) {
|
|
|
1438
1423
|
tokens: null
|
|
1439
1424
|
});
|
|
1440
1425
|
}
|
|
1441
|
-
async function
|
|
1426
|
+
async function Qe(e, t = !1, n = null, r = null) {
|
|
1442
1427
|
let i = e.configuration, a = `${i.client_id}_${e.configurationName}_${i.authority}`, o, s = await $(e.configuration, e.configurationName);
|
|
1443
|
-
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);
|
|
1444
1429
|
else {
|
|
1445
1430
|
let i = "retry";
|
|
1446
|
-
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"));
|
|
1447
1432
|
o = i;
|
|
1448
1433
|
}
|
|
1449
1434
|
return o.tokens ? (e.timeoutId &&= W(e, e.tokens.expiresAt, n, r), {
|
|
@@ -1451,14 +1436,14 @@ async function Ze(e, t = !1, n = null, r = null) {
|
|
|
1451
1436
|
tokens: e.tokens
|
|
1452
1437
|
}) : o;
|
|
1453
1438
|
}
|
|
1454
|
-
async function
|
|
1455
|
-
return (await
|
|
1439
|
+
async function $e(e, t = !1, n = null, r = null) {
|
|
1440
|
+
return (await Qe(e, t, n, r)).tokens;
|
|
1456
1441
|
}
|
|
1457
1442
|
var W = (e, t, n = null, r = null) => {
|
|
1458
1443
|
let i = e.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
1459
1444
|
return e.timeoutId && b.clearTimeout(e.timeoutId), b.setTimeout(async () => {
|
|
1460
|
-
let a = { timeLeft:
|
|
1461
|
-
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);
|
|
1462
1447
|
}, 1e3);
|
|
1463
1448
|
}, G = {
|
|
1464
1449
|
FORCE_REFRESH: "FORCE_REFRESH",
|
|
@@ -1470,7 +1455,7 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1470
1455
|
LOGOUT_FROM_ANOTHER_TAB: "LOGOUT_FROM_ANOTHER_TAB",
|
|
1471
1456
|
REQUIRE_SYNC_TOKENS: "REQUIRE_SYNC_TOKENS",
|
|
1472
1457
|
TOKENS_INVALID: "TOKENS_INVALID"
|
|
1473
|
-
},
|
|
1458
|
+
}, et = (e) => async (t, n, r, a = !1) => {
|
|
1474
1459
|
let o = { nonce: null };
|
|
1475
1460
|
if (!r) return {
|
|
1476
1461
|
tokens: null,
|
|
@@ -1497,13 +1482,13 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1497
1482
|
};
|
|
1498
1483
|
if (n.issuedAt !== r.issuedAt) return {
|
|
1499
1484
|
tokens: n,
|
|
1500
|
-
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,
|
|
1501
1486
|
nonce: await l.getNonceAsync()
|
|
1502
1487
|
};
|
|
1503
1488
|
s = await l.getNonceAsync();
|
|
1504
1489
|
} else {
|
|
1505
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;
|
|
1506
|
-
if (l &&=
|
|
1491
|
+
if (l &&= at(l, e.tokens, t.token_renew_mode), !l) return {
|
|
1507
1492
|
tokens: null,
|
|
1508
1493
|
status: G.LOGOUT_FROM_ANOTHER_TAB,
|
|
1509
1494
|
nonce: o
|
|
@@ -1514,7 +1499,7 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1514
1499
|
nonce: o
|
|
1515
1500
|
};
|
|
1516
1501
|
if (l.issuedAt !== r.issuedAt) {
|
|
1517
|
-
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();
|
|
1518
1503
|
return {
|
|
1519
1504
|
tokens: l,
|
|
1520
1505
|
status: e,
|
|
@@ -1523,7 +1508,7 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1523
1508
|
}
|
|
1524
1509
|
s = await a.getNonceAsync();
|
|
1525
1510
|
}
|
|
1526
|
-
let u =
|
|
1511
|
+
let u = J(t.refresh_time_before_tokens_expiration_in_second, r.expiresAt) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
|
|
1527
1512
|
return a ? {
|
|
1528
1513
|
tokens: r,
|
|
1529
1514
|
status: "FORCE_REFRESH",
|
|
@@ -1539,7 +1524,7 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1539
1524
|
status: "GIVE_UP"
|
|
1540
1525
|
};
|
|
1541
1526
|
let p = 6, m = o ? 2 : 5;
|
|
1542
|
-
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}` });
|
|
1543
1528
|
let h = document.hidden, v = h ? r : r + 1, y = h ? a + 1 : a;
|
|
1544
1529
|
if (r >= m || a >= 5) {
|
|
1545
1530
|
n(null);
|
|
@@ -1605,7 +1590,7 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1605
1590
|
}
|
|
1606
1591
|
};
|
|
1607
1592
|
try {
|
|
1608
|
-
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);
|
|
1609
1594
|
switch (f) {
|
|
1610
1595
|
case G.SESSION_LOST:
|
|
1611
1596
|
n(null);
|
|
@@ -1659,12 +1644,12 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1659
1644
|
redirect_uri: h,
|
|
1660
1645
|
grant_type: "refresh_token",
|
|
1661
1646
|
refresh_token: p.refreshToken
|
|
1662
|
-
}, a = await t.initAsync(g, b.authority_configuration), f = document.hidden ? 1e4 :
|
|
1647
|
+
}, a = await t.initAsync(g, b.authority_configuration), f = document.hidden ? 1e4 : 3e5, x = a.tokenEndpoint, S = {};
|
|
1663
1648
|
b.demonstrating_proof_of_possession && (S.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(p.accessToken, x, "POST"));
|
|
1664
|
-
let C = await
|
|
1649
|
+
let C = await Ae(t.getFetch())(x, r, _, p, S, b.token_renew_mode, f);
|
|
1665
1650
|
if (!C.success && C.oauthError === "use_dpop_nonce" && C.demonstratingProofOfPossessionNonce && b.demonstrating_proof_of_possession) {
|
|
1666
1651
|
let e = await $(b, t.configurationName);
|
|
1667
|
-
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);
|
|
1668
1653
|
}
|
|
1669
1654
|
if (C.success) {
|
|
1670
1655
|
if (!m || !m.nonce) {
|
|
@@ -1679,7 +1664,7 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1679
1664
|
error: r
|
|
1680
1665
|
};
|
|
1681
1666
|
}
|
|
1682
|
-
let { isValid: r, reason: o } =
|
|
1667
|
+
let { isValid: r, reason: o } = lt(C.data, m.nonce, a);
|
|
1683
1668
|
if (!r) {
|
|
1684
1669
|
n(null);
|
|
1685
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}`, {
|
|
@@ -1703,7 +1688,8 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1703
1688
|
tokens: C.data,
|
|
1704
1689
|
status: "LOGGED_IN"
|
|
1705
1690
|
};
|
|
1706
|
-
}
|
|
1691
|
+
}
|
|
1692
|
+
{
|
|
1707
1693
|
let r = U("Token request failed", C);
|
|
1708
1694
|
return t.publishEvent(e.refreshTokensAsync_silent_error, {
|
|
1709
1695
|
message: "bad request",
|
|
@@ -1733,31 +1719,33 @@ var W = (e, t, n = null, r = null) => {
|
|
|
1733
1719
|
}, 1e3);
|
|
1734
1720
|
});
|
|
1735
1721
|
}
|
|
1736
|
-
},
|
|
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) => {
|
|
1737
1723
|
try {
|
|
1738
|
-
|
|
1724
|
+
if (!e) return null;
|
|
1725
|
+
let t = e.split(".");
|
|
1726
|
+
return t.length === 3 ? nt(t[1]) : null;
|
|
1739
1727
|
} catch (e) {
|
|
1740
1728
|
console.warn(e);
|
|
1741
1729
|
}
|
|
1742
1730
|
return null;
|
|
1743
|
-
},
|
|
1731
|
+
}, q = {
|
|
1744
1732
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
1745
1733
|
access_token_invalid: "access_token_invalid",
|
|
1746
1734
|
id_token_invalid: "id_token_invalid"
|
|
1747
1735
|
};
|
|
1748
|
-
function
|
|
1736
|
+
function it(e, t, n) {
|
|
1749
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;
|
|
1750
1738
|
}
|
|
1751
|
-
var
|
|
1739
|
+
var at = (e, t = null, n) => {
|
|
1752
1740
|
if (!e) return null;
|
|
1753
1741
|
let r, i = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
|
|
1754
|
-
r = e.accessTokenPayload === void 0 ?
|
|
1742
|
+
r = e.accessTokenPayload === void 0 ? rt(e.accessToken) : e.accessTokenPayload;
|
|
1755
1743
|
let a;
|
|
1756
1744
|
a = t != null && "idToken" in t && !("idToken" in e) ? t.idToken : e.idToken;
|
|
1757
|
-
let o = e.idTokenPayload ? e.idTokenPayload :
|
|
1758
|
-
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);
|
|
1759
1747
|
let l;
|
|
1760
|
-
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;
|
|
1761
1749
|
let u = {
|
|
1762
1750
|
...e,
|
|
1763
1751
|
idTokenPayload: o,
|
|
@@ -1773,7 +1761,7 @@ var ot = (e, t = null, n) => {
|
|
|
1773
1761
|
};
|
|
1774
1762
|
}
|
|
1775
1763
|
return u;
|
|
1776
|
-
},
|
|
1764
|
+
}, ot = (e, t, n) => {
|
|
1777
1765
|
if (!e) return null;
|
|
1778
1766
|
e.issued_at ||= (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
1779
1767
|
let r = {
|
|
@@ -1784,11 +1772,11 @@ var ot = (e, t = null, n) => {
|
|
|
1784
1772
|
tokenType: e.token_type,
|
|
1785
1773
|
issuedAt: e.issued_at
|
|
1786
1774
|
};
|
|
1787
|
-
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),
|
|
1788
|
-
},
|
|
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) => {
|
|
1789
1777
|
let n = t - (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
1790
1778
|
return Math.round(n - e);
|
|
1791
|
-
},
|
|
1779
|
+
}, st = (e, t = 0) => e ? J(t, e.expiresAt) > 0 : !1, ct = async (e, t = 200, n = 50) => {
|
|
1792
1780
|
let r = n, i = await e.syncTokensInfoAsync();
|
|
1793
1781
|
for (; [
|
|
1794
1782
|
G.REQUIRE_SYNC_TOKENS,
|
|
@@ -1798,15 +1786,15 @@ var ot = (e, t = null, n) => {
|
|
|
1798
1786
|
if (e.configuration.token_automatic_renew_mode == B.AutomaticOnlyWhenFetchExecuted) {
|
|
1799
1787
|
await e.renewTokensAsync({});
|
|
1800
1788
|
break;
|
|
1801
|
-
}
|
|
1802
|
-
--r, i = await e.syncTokensInfoAsync();
|
|
1789
|
+
}
|
|
1790
|
+
await X({ milliseconds: t }), --r, i = await e.syncTokensInfoAsync();
|
|
1803
1791
|
}
|
|
1804
1792
|
return {
|
|
1805
|
-
isTokensValid:
|
|
1793
|
+
isTokensValid: st(e.getTokens()),
|
|
1806
1794
|
tokens: e.getTokens(),
|
|
1807
1795
|
numberWaited: r - n
|
|
1808
1796
|
};
|
|
1809
|
-
},
|
|
1797
|
+
}, lt = (e, t, n) => {
|
|
1810
1798
|
if (e.idTokenPayload) {
|
|
1811
1799
|
let r = e.idTokenPayload;
|
|
1812
1800
|
if (n.issuer !== r.iss) return {
|
|
@@ -1818,7 +1806,7 @@ var ot = (e, t = null, n) => {
|
|
|
1818
1806
|
isValid: !1,
|
|
1819
1807
|
reason: `Token expired (idTokenPayload exp) ${r.exp} < (currentTimeUnixSecond) ${i}`
|
|
1820
1808
|
};
|
|
1821
|
-
let a =
|
|
1809
|
+
let a = 604800;
|
|
1822
1810
|
if (r.iat && r.iat + a < i) return {
|
|
1823
1811
|
isValid: !1,
|
|
1824
1812
|
reason: `Token is used from too long time (idTokenPayload iat + timeInSevenDays) ${r.iat + a} < (currentTimeUnixSecond) ${i}`
|
|
@@ -1832,16 +1820,16 @@ var ot = (e, t = null, n) => {
|
|
|
1832
1820
|
isValid: !0,
|
|
1833
1821
|
reason: ""
|
|
1834
1822
|
};
|
|
1835
|
-
},
|
|
1823
|
+
}, ut = "7.29.5", dt = null, Y, X = ({ milliseconds: e }) => new Promise((t) => b.setTimeout(t, e)), ft = (e = "/") => {
|
|
1836
1824
|
try {
|
|
1837
|
-
|
|
1825
|
+
Y = new AbortController(), fetch(`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: Y.signal }).catch((e) => {
|
|
1838
1826
|
console.log(e);
|
|
1839
|
-
}),
|
|
1827
|
+
}), X({ milliseconds: 15e4 }).then(() => ft(e));
|
|
1840
1828
|
} catch (e) {
|
|
1841
1829
|
console.log(e);
|
|
1842
1830
|
}
|
|
1843
|
-
},
|
|
1844
|
-
|
|
1831
|
+
}, pt = () => {
|
|
1832
|
+
Y && Y.abort();
|
|
1845
1833
|
}, mt = (e) => {
|
|
1846
1834
|
let t = `oidc.tabId.${e}`, n = sessionStorage.getItem(t);
|
|
1847
1835
|
if (n) return n;
|
|
@@ -1903,7 +1891,7 @@ var ot = (e, t = null, n) => {
|
|
|
1903
1891
|
}, $ = async (e, t) => {
|
|
1904
1892
|
let n = e.service_worker_relative_url;
|
|
1905
1893
|
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !n || e.service_worker_activate() === !1) return null;
|
|
1906
|
-
let r = `${n}?v=${
|
|
1894
|
+
let r = `${n}?v=${ut}`, i = e.service_worker_register ? n : r;
|
|
1907
1895
|
vt.has(i) || vt.set(i, e.service_worker_register ? e.service_worker_register(n) : navigator.serviceWorker.register(r, { updateViaCache: "none" }));
|
|
1908
1896
|
let a = null;
|
|
1909
1897
|
try {
|
|
@@ -1913,7 +1901,7 @@ var ot = (e, t = null, n) => {
|
|
|
1913
1901
|
throw e;
|
|
1914
1902
|
}
|
|
1915
1903
|
let o = `oidc.sw.version_mismatch_reload.${t}`, s = async (e) => {
|
|
1916
|
-
|
|
1904
|
+
pt(), console.log("New SW waiting – SKIP_WAITING");
|
|
1917
1905
|
try {
|
|
1918
1906
|
await new Promise((n, r) => {
|
|
1919
1907
|
let i = new MessageChannel(), a = null, o = () => {
|
|
@@ -1946,7 +1934,7 @@ var ot = (e, t = null, n) => {
|
|
|
1946
1934
|
let e = a.waiting;
|
|
1947
1935
|
e ? await s(e) : console.warn("sendSkipWaiting called but no waiting service worker found");
|
|
1948
1936
|
}, l = (e) => {
|
|
1949
|
-
|
|
1937
|
+
pt(), e.addEventListener("statechange", async () => {
|
|
1950
1938
|
if (e.state === "installed" && navigator.serviceWorker.controller) {
|
|
1951
1939
|
if (St() >= xt) {
|
|
1952
1940
|
console.warn("SW trackInstallingWorker: skipping SKIP_WAITING because the reload budget is exhausted");
|
|
@@ -1978,7 +1966,7 @@ var ot = (e, t = null, n) => {
|
|
|
1978
1966
|
console.warn(`SW controllerchange: reload budget exhausted (${e - 1} reloads). Skipping reload to avoid infinite loop.`);
|
|
1979
1967
|
return;
|
|
1980
1968
|
}
|
|
1981
|
-
Q = !0, console.log("SW controller changed – reloading page"),
|
|
1969
|
+
Q = !0, console.log("SW controller changed – reloading page"), pt(), window.location.reload();
|
|
1982
1970
|
}));
|
|
1983
1971
|
let u = async (e) => Z(a)({
|
|
1984
1972
|
type: "clear",
|
|
@@ -1997,29 +1985,30 @@ var ot = (e, t = null, n) => {
|
|
|
1997
1985
|
},
|
|
1998
1986
|
configurationName: t
|
|
1999
1987
|
}), s = i.version;
|
|
2000
|
-
if (s !== "7.29.
|
|
2001
|
-
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`);
|
|
2002
1990
|
let e = parseInt(sessionStorage.getItem(o) ?? "0", 10);
|
|
2003
1991
|
if (e < 3) {
|
|
2004
|
-
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(() => {});
|
|
2005
1993
|
{
|
|
2006
|
-
|
|
1994
|
+
pt();
|
|
2007
1995
|
try {
|
|
2008
1996
|
await a.update();
|
|
2009
1997
|
} catch (e) {
|
|
2010
1998
|
console.error(e);
|
|
2011
1999
|
}
|
|
2012
2000
|
let e = await a.unregister();
|
|
2013
|
-
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(() => {});
|
|
2014
2002
|
}
|
|
2015
|
-
}
|
|
2003
|
+
}
|
|
2004
|
+
console.error(`Service worker version mismatch persists after ${e} attempt(s). Continuing with mismatched version.`);
|
|
2016
2005
|
} else sessionStorage.removeItem(o), wt();
|
|
2017
2006
|
return {
|
|
2018
|
-
tokens:
|
|
2007
|
+
tokens: ot(i.tokens, null, r.token_renew_mode),
|
|
2019
2008
|
status: i.status
|
|
2020
2009
|
};
|
|
2021
2010
|
}, f = (e = "/") => {
|
|
2022
|
-
|
|
2011
|
+
dt ?? (dt = "not_null", ft(e));
|
|
2023
2012
|
}, p = (e) => Z(a)({
|
|
2024
2013
|
type: "setSessionState",
|
|
2025
2014
|
data: { sessionState: e },
|
|
@@ -2193,21 +2182,21 @@ var ot = (e, t = null, n) => {
|
|
|
2193
2182
|
}
|
|
2194
2183
|
async getValidTokenAsync(e = 200, t = 50) {
|
|
2195
2184
|
let n = this._oidc;
|
|
2196
|
-
return
|
|
2185
|
+
return ct({
|
|
2197
2186
|
getTokens: () => n.tokens,
|
|
2198
2187
|
configuration: {
|
|
2199
2188
|
token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
|
|
2200
2189
|
refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
|
|
2201
2190
|
},
|
|
2202
2191
|
syncTokensInfoAsync: async () => {
|
|
2203
|
-
let { status: e } = await
|
|
2192
|
+
let { status: e } = await et(n)(n.configuration, n.configurationName, n.tokens, !1);
|
|
2204
2193
|
return e;
|
|
2205
2194
|
},
|
|
2206
2195
|
renewTokensAsync: n.renewTokensAsync.bind(n)
|
|
2207
2196
|
}, e, t);
|
|
2208
2197
|
}
|
|
2209
2198
|
fetchWithTokens(e, t = !1) {
|
|
2210
|
-
return
|
|
2199
|
+
return Ge(e, this._oidc, t);
|
|
2211
2200
|
}
|
|
2212
2201
|
async userInfoAsync(e = !1, t = !1) {
|
|
2213
2202
|
return this._oidc.userInfoAsync(e, t);
|
|
@@ -2247,6 +2236,6 @@ var ot = (e, t = null, n) => {
|
|
|
2247
2236
|
CODE_VERIFIER: "oidc.code_verifier.",
|
|
2248
2237
|
LOGIN_PARAMS: "oidc.login.",
|
|
2249
2238
|
SW_VERSION_MISMATCH_RELOAD: "oidc.sw.version_mismatch_reload."
|
|
2250
|
-
}, 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"
|
|
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);
|
|
2251
2240
|
//#endregion
|
|
2252
|
-
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 };
|