@axa-fr/oidc-client 7.27.15 → 7.27.17
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 +15 -3
- package/dist/index.js +165 -134
- package/dist/index.umd.cjs +2 -2
- package/dist/logout.d.ts +14 -0
- package/dist/logout.d.ts.map +1 -1
- package/dist/oidc.d.ts +40 -1
- package/dist/oidc.d.ts.map +1 -1
- package/dist/oidcClient.d.ts +37 -1
- package/dist/oidcClient.d.ts.map +1 -1
- package/dist/oidcClient.spec.d.ts +2 -0
- package/dist/oidcClient.spec.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/logout.spec.ts +208 -1
- package/src/logout.ts +149 -80
- package/src/oidc.ts +59 -5
- package/src/oidcClient.spec.ts +34 -0
- package/src/oidcClient.ts +48 -2
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -636,10 +636,10 @@ var oe = () => {
|
|
|
636
636
|
} else throw console.error(a.message), a;
|
|
637
637
|
}
|
|
638
638
|
return a;
|
|
639
|
-
},
|
|
639
|
+
}, fe = {
|
|
640
640
|
refresh_token: "refresh_token",
|
|
641
641
|
access_token: "access_token"
|
|
642
|
-
},
|
|
642
|
+
}, pe = (e) => async (t, n, r = fe.refresh_token, i, a = {}, o = 1e4) => {
|
|
643
643
|
let s = {
|
|
644
644
|
token: n,
|
|
645
645
|
token_type_hint: r,
|
|
@@ -657,7 +657,7 @@ var oe = () => {
|
|
|
657
657
|
headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
|
|
658
658
|
body: l
|
|
659
659
|
}, o)).status === 200 ? { success: !0 } : { success: !1 };
|
|
660
|
-
},
|
|
660
|
+
}, me = (e) => async (t, n, r, i, a = {}, o, s = 1e4) => {
|
|
661
661
|
for (let [e, t] of Object.entries(r)) n[e] === void 0 && (n[e] = t);
|
|
662
662
|
let c = [];
|
|
663
663
|
for (let e in n) {
|
|
@@ -678,20 +678,20 @@ var oe = () => {
|
|
|
678
678
|
demonstratingProofOfPossessionNonce: null
|
|
679
679
|
};
|
|
680
680
|
let d = await u.json(), f = null;
|
|
681
|
-
return u.headers.has(
|
|
681
|
+
return u.headers.has(j) && (f = u.headers.get(j)), {
|
|
682
682
|
success: !0,
|
|
683
683
|
status: u.status,
|
|
684
684
|
data: G(d, i, o),
|
|
685
685
|
demonstratingProofOfPossessionNonce: f
|
|
686
686
|
};
|
|
687
|
-
},
|
|
687
|
+
}, he = (e, t) => async (n, r) => {
|
|
688
688
|
r = r ? { ...r } : {};
|
|
689
689
|
let i = D(128), a = await ne(i);
|
|
690
690
|
await e.setCodeVerifierAsync(i), await e.setStateAsync(r.state), r.code_challenge = a, r.code_challenge_method = "S256";
|
|
691
691
|
let o = "";
|
|
692
692
|
if (r) for (let [e, t] of Object.entries(r)) o === "" ? o += "?" : o += "&", o += `${e}=${encodeURIComponent(t)}`;
|
|
693
693
|
t.open(`${n}${o}`);
|
|
694
|
-
},
|
|
694
|
+
}, j = "DPoP-Nonce", ge = (e) => async (t, n, r, i, a = 1e4) => {
|
|
695
695
|
n = n ? { ...n } : {}, n.code_verifier = await e.getCodeVerifierAsync();
|
|
696
696
|
let o = [];
|
|
697
697
|
for (let e in n) {
|
|
@@ -711,7 +711,7 @@ var oe = () => {
|
|
|
711
711
|
status: c.status
|
|
712
712
|
};
|
|
713
713
|
let l = null;
|
|
714
|
-
c.headers.has(
|
|
714
|
+
c.headers.has(j) && (l = c.headers.get(j));
|
|
715
715
|
let u = await c.json();
|
|
716
716
|
return {
|
|
717
717
|
success: !0,
|
|
@@ -721,7 +721,7 @@ var oe = () => {
|
|
|
721
721
|
demonstratingProofOfPossessionNonce: l
|
|
722
722
|
}
|
|
723
723
|
};
|
|
724
|
-
},
|
|
724
|
+
}, _e = (e) => {
|
|
725
725
|
let t = e.match(/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
726
726
|
if (!t) throw Error("Invalid URL");
|
|
727
727
|
let n = t[6], r = t[7];
|
|
@@ -739,19 +739,19 @@ var oe = () => {
|
|
|
739
739
|
search: n,
|
|
740
740
|
hash: r
|
|
741
741
|
};
|
|
742
|
-
},
|
|
743
|
-
let t =
|
|
742
|
+
}, ve = (e) => {
|
|
743
|
+
let t = _e(e), { path: n } = t;
|
|
744
744
|
n.endsWith("/") && (n = n.slice(0, -1));
|
|
745
745
|
let { hash: r } = t;
|
|
746
746
|
return r === "#_=_" && (r = ""), r && (n += r), n;
|
|
747
|
-
},
|
|
748
|
-
let { search: t } =
|
|
749
|
-
return
|
|
750
|
-
},
|
|
747
|
+
}, M = (e) => {
|
|
748
|
+
let { search: t } = _e(e);
|
|
749
|
+
return ye(t);
|
|
750
|
+
}, ye = (e) => {
|
|
751
751
|
let t = {}, n, r, i, a = e.split("&");
|
|
752
752
|
for (r = 0, i = a.length; r < i; r++) n = a[r].split("="), t[decodeURIComponent(n[0])] = decodeURIComponent(n[1]);
|
|
753
753
|
return t;
|
|
754
|
-
},
|
|
754
|
+
}, be = (t, n, r, a, o) => (s = void 0, c = null, l = !1, u = void 0) => {
|
|
755
755
|
let d = c;
|
|
756
756
|
return c = { ...c }, (async () => {
|
|
757
757
|
let f = s || o.getPath();
|
|
@@ -785,15 +785,15 @@ var oe = () => {
|
|
|
785
785
|
response_type: "code",
|
|
786
786
|
...r
|
|
787
787
|
};
|
|
788
|
-
await
|
|
788
|
+
await he(h, o)(m.authorizationEndpoint, g);
|
|
789
789
|
} catch (t) {
|
|
790
790
|
throw r(e.loginAsync_error, t), t;
|
|
791
791
|
}
|
|
792
792
|
})();
|
|
793
|
-
},
|
|
793
|
+
}, xe = (t) => async (n = !1) => {
|
|
794
794
|
try {
|
|
795
795
|
t.publishEvent(e.loginCallbackAsync_begin, {});
|
|
796
|
-
let r = t.configuration, a = r.client_id, o = n ? r.silent_redirect_uri : r.redirect_uri, s = r.authority, c = r.token_request_timeout, l = await t.initAsync(s, r.authority_configuration), u =
|
|
796
|
+
let r = t.configuration, a = r.client_id, o = n ? r.silent_redirect_uri : r.redirect_uri, s = r.authority, c = r.token_request_timeout, l = await t.initAsync(s, r.authority_configuration), u = M(t.location.getCurrentHref()), d = u.session_state, f = await $(r, t.configurationName), p, m, h, g;
|
|
797
797
|
if (f) await f.initAsync(l, "loginCallbackAsync", r), await f.setSessionStateAsync(d), m = await f.getNonceAsync(), h = f.getLoginParams(), g = await f.getStateAsync(), f.startKeepAliveServiceWorker(), p = f;
|
|
798
798
|
else {
|
|
799
799
|
let e = i(t.configurationName, r.storage ?? sessionStorage, r.login_state_storage ?? r.storage ?? sessionStorage);
|
|
@@ -816,14 +816,14 @@ var oe = () => {
|
|
|
816
816
|
let e = await x(window)(r.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm);
|
|
817
817
|
await i(t.configurationName, r.storage, r.login_state_storage ?? r.storage).setDemonstratingProofOfPossessionJwkAsync(e), b.DPoP = await S(window)(r.demonstrating_proof_of_possession_configuration)(e, "POST", y);
|
|
818
818
|
}
|
|
819
|
-
let C = await
|
|
819
|
+
let C = await ge(p)(y, {
|
|
820
820
|
..._,
|
|
821
821
|
...v
|
|
822
822
|
}, b, t.configuration.token_renew_mode, c);
|
|
823
823
|
if (!C.success) throw Error("Token request failed");
|
|
824
824
|
let w, T = C.data.tokens, E = C.data.demonstratingProofOfPossessionNonce;
|
|
825
825
|
if (C.data.state !== v.state) throw Error("state is not valid");
|
|
826
|
-
let { isValid: D, reason: ee } =
|
|
826
|
+
let { isValid: D, reason: ee } = He(T, m.nonce, l);
|
|
827
827
|
if (!D) throw Error(`Tokens are not OpenID valid, reason: ${ee}`);
|
|
828
828
|
if (f) {
|
|
829
829
|
if (T.refreshToken && !T.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER")) throw Error("Refresh token should be hidden by service worker");
|
|
@@ -844,10 +844,10 @@ var oe = () => {
|
|
|
844
844
|
} catch (n) {
|
|
845
845
|
throw console.error(n), t.publishEvent(e.loginCallbackAsync_error, n), n;
|
|
846
846
|
}
|
|
847
|
-
},
|
|
847
|
+
}, Se = {
|
|
848
848
|
access_token: "access_token",
|
|
849
849
|
refresh_token: "refresh_token"
|
|
850
|
-
},
|
|
850
|
+
}, N = (e, t) => {
|
|
851
851
|
let n = {};
|
|
852
852
|
if (e) {
|
|
853
853
|
for (let [r, i] of Object.entries(e)) if (r.endsWith(t)) {
|
|
@@ -857,59 +857,72 @@ var oe = () => {
|
|
|
857
857
|
return n;
|
|
858
858
|
}
|
|
859
859
|
return n;
|
|
860
|
-
},
|
|
860
|
+
}, Ce = (e) => {
|
|
861
861
|
let t = {};
|
|
862
862
|
if (e) {
|
|
863
863
|
for (let [n, r] of Object.entries(e)) n.includes(":") || (t[n] = r);
|
|
864
864
|
return t;
|
|
865
865
|
}
|
|
866
866
|
return t;
|
|
867
|
-
},
|
|
867
|
+
}, we = (e) => async (t) => {
|
|
868
868
|
c.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
869
869
|
let n = await $(e.configuration, e.configurationName);
|
|
870
870
|
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;
|
|
871
|
-
},
|
|
872
|
-
let
|
|
873
|
-
|
|
874
|
-
let
|
|
875
|
-
|
|
876
|
-
|
|
871
|
+
}, P = (t, n) => async () => {
|
|
872
|
+
let r = t.tokens?.idTokenPayload?.sub ?? null;
|
|
873
|
+
await t.destroyAsync("LOGGED_OUT");
|
|
874
|
+
for (let [, i] of Object.entries(n)) i === t ? t.publishEvent(e.logout_from_same_tab, {}) : await t.logoutSameTabAsync(t.configuration.client_id, r);
|
|
875
|
+
}, Te = (e, t, n, r) => {
|
|
876
|
+
"id_token_hint" in t || (t.id_token_hint = n), !("post_logout_redirect_uri" in t) && r !== null && (t.post_logout_redirect_uri = r);
|
|
877
|
+
let i = "";
|
|
878
|
+
for (let [e, n] of Object.entries(t)) n != null && (i === "" ? i += "?" : i += "&", i += `${e}=${encodeURIComponent(n)}`);
|
|
879
|
+
return `${e}${i}`;
|
|
880
|
+
}, Ee = (e, t, n, r, i) => async (a = void 0, o = null) => {
|
|
881
|
+
let s = e.configuration, c = await e.initAsync(s.authority, s.authority_configuration);
|
|
882
|
+
a && typeof a != "string" && (a = void 0, r.warn("callbackPathOrUrl path is not a string"));
|
|
883
|
+
let l = a ?? i.getPath(), u = !1;
|
|
884
|
+
a && (u = a.includes("https://") || a.includes("http://"));
|
|
885
|
+
let d = a === null ? null : u ? a : i.getOrigin() + l, f = e.tokens ? e.tokens.idToken : "";
|
|
886
|
+
e.isLoggingOut = !0;
|
|
877
887
|
try {
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
888
|
+
try {
|
|
889
|
+
let t = c.revocationEndpoint;
|
|
890
|
+
if (t) {
|
|
891
|
+
let r = [], i = e.tokens ? e.tokens.accessToken : null;
|
|
892
|
+
if (i && s.logout_tokens_to_invalidate.includes(Se.access_token)) {
|
|
893
|
+
let e = N(o, ":revoke_access_token"), a = pe(n)(t, i, fe.access_token, s.client_id, e);
|
|
894
|
+
r.push(a);
|
|
895
|
+
}
|
|
896
|
+
let a = e.tokens ? e.tokens.refreshToken : null;
|
|
897
|
+
if (a && s.logout_tokens_to_invalidate.includes(Se.refresh_token)) {
|
|
898
|
+
let e = N(o, ":revoke_refresh_token"), i = pe(n)(t, a, fe.refresh_token, s.client_id, e);
|
|
899
|
+
r.push(i);
|
|
900
|
+
}
|
|
901
|
+
r.length > 0 && await Promise.all(r);
|
|
889
902
|
}
|
|
890
|
-
|
|
903
|
+
} catch (e) {
|
|
904
|
+
r.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"), r.warn(e);
|
|
891
905
|
}
|
|
892
|
-
|
|
893
|
-
|
|
906
|
+
let a = N(o, ":oidc");
|
|
907
|
+
if (a && a.no_reload === "true") {
|
|
908
|
+
await P(e, t)(), e.isLoggingOut = !1;
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
let l = Ce(o);
|
|
912
|
+
if (c.endSessionEndpoint) {
|
|
913
|
+
let e = Te(c.endSessionEndpoint, l, f, d);
|
|
914
|
+
i.open(e);
|
|
915
|
+
} else i.reload();
|
|
916
|
+
await P(e, t)();
|
|
917
|
+
} catch (t) {
|
|
918
|
+
throw e.isLoggingOut = !1, t;
|
|
894
919
|
}
|
|
895
|
-
let m = t.tokens?.idTokenPayload?.sub ?? null;
|
|
896
|
-
await t.destroyAsync("LOGGED_OUT");
|
|
897
|
-
for (let [, r] of Object.entries(n)) r === t ? t.publishEvent(e.logout_from_same_tab, {}) : await t.logoutSameTabAsync(t.configuration.client_id, m);
|
|
898
|
-
let h = P(s, ":oidc");
|
|
899
|
-
if (h && h.no_reload === "true") return;
|
|
900
|
-
let g = Se(s);
|
|
901
|
-
if (l.endSessionEndpoint) {
|
|
902
|
-
"id_token_hint" in g || (g.id_token_hint = p), !("post_logout_redirect_uri" in g) && o !== null && (g.post_logout_redirect_uri = f);
|
|
903
|
-
let e = "";
|
|
904
|
-
for (let [t, n] of Object.entries(g)) n != null && (e === "" ? e += "?" : e += "&", e += `${t}=${encodeURIComponent(n)}`);
|
|
905
|
-
a.open(`${l.endSessionEndpoint}${e}`);
|
|
906
|
-
} else a.reload();
|
|
907
920
|
}, F = /* @__PURE__ */ function(e) {
|
|
908
921
|
return e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e;
|
|
909
|
-
}({}),
|
|
922
|
+
}({}), De = (e, t, n = !1) => async (...r) => {
|
|
910
923
|
let [i, a, ...o] = r, s = a ? { ...a } : { method: "GET" }, c = new Headers();
|
|
911
924
|
s.headers && (c = s.headers instanceof Headers ? s.headers : new Headers(s.headers));
|
|
912
|
-
let l = (await
|
|
925
|
+
let l = (await Ve({
|
|
913
926
|
getTokens: () => t.tokens,
|
|
914
927
|
configuration: {
|
|
915
928
|
token_automatic_renew_mode: t.configuration.token_automatic_renew_mode,
|
|
@@ -932,25 +945,25 @@ var oe = () => {
|
|
|
932
945
|
...s,
|
|
933
946
|
headers: c
|
|
934
947
|
}, ...o);
|
|
935
|
-
},
|
|
948
|
+
}, Oe = (e) => async (t = !1, n = !1) => {
|
|
936
949
|
if (e.userInfo != null && !t) return e.userInfo;
|
|
937
950
|
let r = !t && e.configuration.storage?.getItem(`oidc.${e.configurationName}.userInfo`);
|
|
938
951
|
if (r) return e.userInfo = JSON.parse(r), e.userInfo;
|
|
939
952
|
let i = e.configuration, a = (await e.initAsync(i.authority, i.authority_configuration)).userInfoEndpoint, o = await (async () => {
|
|
940
|
-
let t = await
|
|
953
|
+
let t = await De(fetch, e, n)(a);
|
|
941
954
|
return t.status === 200 ? t.json() : null;
|
|
942
955
|
})();
|
|
943
956
|
return e.userInfo = o, o && e.configuration.storage?.setItem(`oidc.${e.configurationName}.userInfo`, JSON.stringify(o)), o;
|
|
944
|
-
},
|
|
957
|
+
}, ke = () => fetch, I = class {
|
|
945
958
|
constructor(e) {
|
|
946
959
|
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;
|
|
947
960
|
}
|
|
948
|
-
}, L = {},
|
|
961
|
+
}, L = {}, Ae = (e, t = new O()) => (n, r = "default") => (L[r] || (L[r] = new R(n, r, e, t)), L[r]), je = async (e) => {
|
|
949
962
|
let { parsedTokens: t, callbackPath: n, extras: r, scope: i } = await e.loginCallbackAsync();
|
|
950
963
|
return e.timeoutId = z(e, t.expiresAt, r, i), { callbackPath: n };
|
|
951
|
-
},
|
|
964
|
+
}, Me = (e) => Math.floor(Math.random() * e), R = class t {
|
|
952
965
|
constructor(e, t = "default", n, r = new O()) {
|
|
953
|
-
this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.logoutPromise = null;
|
|
966
|
+
this.isLoggingOut = !1, this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.clearSessionPromise = null, this.logoutPromise = null;
|
|
954
967
|
let i = e.silent_login_uri;
|
|
955
968
|
e.silent_redirect_uri && !e.silent_login_uri && (i = `${e.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
|
|
956
969
|
let a = e.refresh_time_before_tokens_expiration_in_second ?? 120;
|
|
@@ -968,10 +981,10 @@ var oe = () => {
|
|
|
968
981
|
service_worker_activate: e.service_worker_activate ?? oe,
|
|
969
982
|
demonstrating_proof_of_possession_configuration: e.demonstrating_proof_of_possession_configuration ?? _,
|
|
970
983
|
preload_user_info: e.preload_user_info ?? !1
|
|
971
|
-
}, this.getFetch = n ??
|
|
984
|
+
}, this.getFetch = n ?? ke, 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.initAsync(this.configuration.authority, this.configuration.authority_configuration);
|
|
972
985
|
}
|
|
973
986
|
subscribeEvents(e) {
|
|
974
|
-
let t =
|
|
987
|
+
let t = Me(9999999999999).toString();
|
|
975
988
|
return this.events.push({
|
|
976
989
|
id: t,
|
|
977
990
|
func: e
|
|
@@ -987,20 +1000,23 @@ var oe = () => {
|
|
|
987
1000
|
});
|
|
988
1001
|
}
|
|
989
1002
|
static {
|
|
990
|
-
this.getOrCreate = (e, t) => (n, r = "default") =>
|
|
1003
|
+
this.getOrCreate = (e, t) => (n, r = "default") => Ae(e, t)(n, r);
|
|
991
1004
|
}
|
|
992
1005
|
static get(e = "default") {
|
|
993
|
-
|
|
994
|
-
|
|
1006
|
+
return Object.prototype.hasOwnProperty.call(L, e) ? L[e] : null;
|
|
1007
|
+
}
|
|
1008
|
+
static getOrThrow(e = "default") {
|
|
1009
|
+
let n = t.get(e);
|
|
1010
|
+
if (!n) throw Error(`OIDC library does seem initialized.
|
|
995
1011
|
Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${e}"></OidcProvider> component.`);
|
|
996
|
-
return
|
|
1012
|
+
return n;
|
|
997
1013
|
}
|
|
998
1014
|
static {
|
|
999
1015
|
this.eventNames = e;
|
|
1000
1016
|
}
|
|
1001
1017
|
_silentLoginCallbackFromIFrame() {
|
|
1002
1018
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1003
|
-
let e = this.location, t =
|
|
1019
|
+
let e = this.location, t = M(e.getCurrentHref());
|
|
1004
1020
|
window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({
|
|
1005
1021
|
tokens: this.tokens,
|
|
1006
1022
|
sessionState: t.session_state
|
|
@@ -1009,7 +1025,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1009
1025
|
}
|
|
1010
1026
|
_silentLoginErrorCallbackFromIFrame(e = null) {
|
|
1011
1027
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1012
|
-
let t = this.location, n =
|
|
1028
|
+
let t = this.location, n = M(t.getCurrentHref());
|
|
1013
1029
|
n.error ? window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({ error: n.error })}`, t.getOrigin()) : window.parent.postMessage(`${this.configurationName}_oidc_exception:${JSON.stringify({ error: e == null ? "" : e.toString() })}`, t.getOrigin());
|
|
1014
1030
|
}
|
|
1015
1031
|
}
|
|
@@ -1048,14 +1064,14 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1048
1064
|
await d(this, L, this.configuration)(e, t, n, r);
|
|
1049
1065
|
}
|
|
1050
1066
|
async loginAsync(e = void 0, t = null, n = !1, r = void 0, i = !1) {
|
|
1051
|
-
return this.logoutPromise && await this.logoutPromise, this.loginPromise === null ? (i ? this.loginPromise = u(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(t, r) : this.loginPromise =
|
|
1067
|
+
return this.logoutPromise && await this.logoutPromise, this.loginPromise === null ? (i ? this.loginPromise = u(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(t, r) : this.loginPromise = be(this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this), this.location)(e, t, n, r), this.loginPromise.finally(() => {
|
|
1052
1068
|
this.loginPromise = null;
|
|
1053
1069
|
})) : this.loginPromise;
|
|
1054
1070
|
}
|
|
1055
1071
|
async loginCallbackAsync(e = !1) {
|
|
1056
1072
|
if (this.loginCallbackPromise !== null) return this.loginCallbackPromise;
|
|
1057
1073
|
let n = async () => {
|
|
1058
|
-
let n = await
|
|
1074
|
+
let n = await xe(this)(e), r = n.tokens;
|
|
1059
1075
|
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(), {
|
|
1060
1076
|
parsedTokens: r,
|
|
1061
1077
|
state: n.state,
|
|
@@ -1073,28 +1089,33 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1073
1089
|
ath: await te(e),
|
|
1074
1090
|
...r
|
|
1075
1091
|
};
|
|
1076
|
-
if (await $(a, this.configurationName)) return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${
|
|
1092
|
+
if (await $(a, this.configurationName)) return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${Ke(this.configurationName)}`;
|
|
1077
1093
|
let s = i(this.configurationName, a.storage, a.login_state_storage ?? a.storage), c = await s.getDemonstratingProofOfPossessionJwkAsync(), l = s.getDemonstratingProofOfPossessionNonce();
|
|
1078
1094
|
return l && (o.nonce = l), await S(window)(a.demonstrating_proof_of_possession_configuration)(c, n, t, o);
|
|
1079
1095
|
}
|
|
1080
1096
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1081
|
-
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1097
|
+
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise = je(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
|
|
1082
1098
|
this.loginCallbackWithAutoTokensRenewPromise = null;
|
|
1083
1099
|
})) : this.loginCallbackWithAutoTokensRenewPromise;
|
|
1084
1100
|
}
|
|
1085
1101
|
userInfoAsync(e = !1, t = !1) {
|
|
1086
|
-
return this.userInfoPromise === null ? (this.userInfoPromise =
|
|
1102
|
+
return this.userInfoPromise === null ? (this.userInfoPromise = Oe(this)(e, t), this.userInfoPromise.finally(() => {
|
|
1087
1103
|
this.userInfoPromise = null;
|
|
1088
1104
|
})) : this.userInfoPromise;
|
|
1089
1105
|
}
|
|
1090
1106
|
async renewTokensAsync(e = null, t = null) {
|
|
1091
1107
|
if (this.renewTokensPromise !== null) return this.renewTokensPromise;
|
|
1092
|
-
if (this.timeoutId) return c.clearTimeout(this.timeoutId), this.renewTokensPromise =
|
|
1108
|
+
if (this.timeoutId) return c.clearTimeout(this.timeoutId), this.renewTokensPromise = Pe(this, !0, e, t), this.renewTokensPromise.finally(() => {
|
|
1093
1109
|
this.renewTokensPromise = null;
|
|
1094
1110
|
});
|
|
1095
1111
|
}
|
|
1096
1112
|
async destroyAsync(e) {
|
|
1097
|
-
return await
|
|
1113
|
+
return await we(this)(e);
|
|
1114
|
+
}
|
|
1115
|
+
async clearSessionAsync() {
|
|
1116
|
+
return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise = P(this, L)(), this.clearSessionPromise.finally(() => {
|
|
1117
|
+
this.clearSessionPromise = null;
|
|
1118
|
+
}));
|
|
1098
1119
|
}
|
|
1099
1120
|
async logoutSameTabAsync(t, n) {
|
|
1100
1121
|
this.configuration.monitor_session && this.configuration.client_id === t && n && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === n && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(e.logout_from_same_tab, {
|
|
@@ -1109,25 +1130,25 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1109
1130
|
}));
|
|
1110
1131
|
}
|
|
1111
1132
|
async logoutAsync(e = void 0, t = null) {
|
|
1112
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1133
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = Ee(this, L, this.getFetch(), console, this.location)(e, t), this.logoutPromise.finally(() => {
|
|
1113
1134
|
this.logoutPromise = null;
|
|
1114
1135
|
}));
|
|
1115
1136
|
}
|
|
1116
1137
|
};
|
|
1117
1138
|
//#endregion
|
|
1118
1139
|
//#region src/renewTokens.ts
|
|
1119
|
-
async function
|
|
1140
|
+
async function Ne(e, t, n, r = null) {
|
|
1120
1141
|
let { tokens: a, status: o } = await H(e)((t) => {
|
|
1121
1142
|
e.tokens = t;
|
|
1122
1143
|
}, 0, 0, t, n, r);
|
|
1123
1144
|
return await $(e.configuration, e.configurationName) || i(e.configurationName, e.configuration.storage, e.configuration.login_state_storage ?? e.configuration.storage).setTokens(e.tokens), e.tokens ? a : (await e.destroyAsync(o), null);
|
|
1124
1145
|
}
|
|
1125
|
-
async function
|
|
1146
|
+
async function Pe(e, t = !1, n = null, r = null) {
|
|
1126
1147
|
let i = e.configuration, a = `${i.client_id}_${e.configurationName}_${i.authority}`, o, s = await $(e.configuration, e.configurationName);
|
|
1127
|
-
if (i?.storage === window?.sessionStorage && !s || !navigator.locks) o = await
|
|
1148
|
+
if (i?.storage === window?.sessionStorage && !s || !navigator.locks) o = await Ne(e, t, n, r);
|
|
1128
1149
|
else {
|
|
1129
1150
|
let i = "retry";
|
|
1130
|
-
for (; i === "retry";) i = await navigator.locks.request(a, { ifAvailable: !0 }, async (i) => i ? await
|
|
1151
|
+
for (; i === "retry";) i = await navigator.locks.request(a, { ifAvailable: !0 }, async (i) => i ? await Ne(e, t, n, r) : (e.publishEvent(R.eventNames.syncTokensAsync_lock_not_available, { lock: "lock not available" }), "retry"));
|
|
1131
1152
|
o = i;
|
|
1132
1153
|
}
|
|
1133
1154
|
return o ? (e.timeoutId &&= z(e, e.tokens.expiresAt, n, r), e.tokens) : null;
|
|
@@ -1136,7 +1157,7 @@ var z = (e, t, n = null, r = null) => {
|
|
|
1136
1157
|
let i = e.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
1137
1158
|
return e.timeoutId && c.clearTimeout(e.timeoutId), c.setTimeout(async () => {
|
|
1138
1159
|
let a = { timeLeft: K(i, t) };
|
|
1139
|
-
e.publishEvent(R.eventNames.token_timer, a), await
|
|
1160
|
+
e.publishEvent(R.eventNames.token_timer, a), await Pe(e, !1, n, r);
|
|
1140
1161
|
}, 1e3);
|
|
1141
1162
|
}, B = {
|
|
1142
1163
|
FORCE_REFRESH: "FORCE_REFRESH",
|
|
@@ -1298,9 +1319,9 @@ var z = (e, t, n = null, r = null) => {
|
|
|
1298
1319
|
refresh_token: u.refreshToken
|
|
1299
1320
|
}, a = await t.initAsync(v, h.authority_configuration), l = document.hidden ? 1e4 : 3e4 * 10, _ = a.tokenEndpoint, b = {};
|
|
1300
1321
|
h.demonstrating_proof_of_possession && (b.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(u.accessToken, _, "POST"));
|
|
1301
|
-
let x = await
|
|
1322
|
+
let x = await me(t.getFetch())(_, r, y, u, b, h.token_renew_mode, l);
|
|
1302
1323
|
if (x.success) {
|
|
1303
|
-
let { isValid: r, reason: o } =
|
|
1324
|
+
let { isValid: r, reason: o } = He(x.data, d.nonce, a);
|
|
1304
1325
|
if (!r) return n(null), t.publishEvent(e.refreshTokensAsync_error, { message: `refresh token return not valid tokens, reason: ${o}` }), {
|
|
1305
1326
|
tokens: null,
|
|
1306
1327
|
status: "SESSION_LOST"
|
|
@@ -1333,29 +1354,29 @@ var z = (e, t, n = null, r = null) => {
|
|
|
1333
1354
|
}, 1e3);
|
|
1334
1355
|
});
|
|
1335
1356
|
}
|
|
1336
|
-
},
|
|
1357
|
+
}, Fe = (e) => decodeURIComponent(Array.prototype.map.call(atob(e), (e) => "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2)).join("")), Ie = (e) => JSON.parse(Fe(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), Le = (e) => {
|
|
1337
1358
|
try {
|
|
1338
|
-
return e &&
|
|
1359
|
+
return e && Re(e, ".") === 2 ? Ie(e.split(".")[1]) : null;
|
|
1339
1360
|
} catch (e) {
|
|
1340
1361
|
console.warn(e);
|
|
1341
1362
|
}
|
|
1342
1363
|
return null;
|
|
1343
|
-
},
|
|
1364
|
+
}, Re = (e, t) => e.split(t).length - 1, U = {
|
|
1344
1365
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
1345
1366
|
access_token_invalid: "access_token_invalid",
|
|
1346
1367
|
id_token_invalid: "id_token_invalid"
|
|
1347
1368
|
};
|
|
1348
|
-
function
|
|
1369
|
+
function ze(e, t, n) {
|
|
1349
1370
|
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;
|
|
1350
1371
|
}
|
|
1351
1372
|
var W = (e, t = null, n) => {
|
|
1352
1373
|
if (!e) return null;
|
|
1353
1374
|
let r, i = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
|
|
1354
|
-
r = e.accessTokenPayload === void 0 ?
|
|
1375
|
+
r = e.accessTokenPayload === void 0 ? Le(e.accessToken) : e.accessTokenPayload;
|
|
1355
1376
|
let a;
|
|
1356
1377
|
a = t != null && "idToken" in t && !("idToken" in e) ? t.idToken : e.idToken;
|
|
1357
|
-
let o = e.idTokenPayload ? e.idTokenPayload :
|
|
1358
|
-
e.issuedAt =
|
|
1378
|
+
let o = e.idTokenPayload ? e.idTokenPayload : Le(a), s = o && o.exp ? o.exp : Number.MAX_VALUE, c = r && r.exp ? r.exp : e.issuedAt + i;
|
|
1379
|
+
e.issuedAt = ze(e, r, o);
|
|
1359
1380
|
let l;
|
|
1360
1381
|
l = e.expiresAt ? e.expiresAt : n === U.access_token_invalid ? c : n === U.id_token_invalid || s < c ? s : c;
|
|
1361
1382
|
let u = {
|
|
@@ -1388,7 +1409,7 @@ var W = (e, t = null, n) => {
|
|
|
1388
1409
|
}, K = (e, t) => {
|
|
1389
1410
|
let n = t - (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
1390
1411
|
return Math.round(n - e);
|
|
1391
|
-
},
|
|
1412
|
+
}, Be = (e, t = 0) => e ? K(t, e.expiresAt) > 0 : !1, Ve = async (e, t = 200, n = 50) => {
|
|
1392
1413
|
let r = n, i = await e.syncTokensInfoAsync();
|
|
1393
1414
|
for (; [
|
|
1394
1415
|
B.REQUIRE_SYNC_TOKENS,
|
|
@@ -1402,11 +1423,11 @@ var W = (e, t = null, n) => {
|
|
|
1402
1423
|
--r, i = await e.syncTokensInfoAsync();
|
|
1403
1424
|
}
|
|
1404
1425
|
return {
|
|
1405
|
-
isTokensValid:
|
|
1426
|
+
isTokensValid: Be(e.getTokens()),
|
|
1406
1427
|
tokens: e.getTokens(),
|
|
1407
1428
|
numberWaited: r - n
|
|
1408
1429
|
};
|
|
1409
|
-
},
|
|
1430
|
+
}, He = (e, t, n) => {
|
|
1410
1431
|
if (e.idTokenPayload) {
|
|
1411
1432
|
let r = e.idTokenPayload;
|
|
1412
1433
|
if (n.issuer !== r.iss) return {
|
|
@@ -1432,25 +1453,25 @@ var W = (e, t = null, n) => {
|
|
|
1432
1453
|
isValid: !0,
|
|
1433
1454
|
reason: ""
|
|
1434
1455
|
};
|
|
1435
|
-
},
|
|
1456
|
+
}, Ue = "7.27.17", We = null, q, J = ({ milliseconds: e }) => new Promise((t) => c.setTimeout(t, e)), Ge = (e = "/") => {
|
|
1436
1457
|
try {
|
|
1437
1458
|
q = new AbortController(), fetch(`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: q.signal }).catch((e) => {
|
|
1438
1459
|
console.log(e);
|
|
1439
|
-
}), J({ milliseconds: 150 * 1e3 }).then(() =>
|
|
1460
|
+
}), J({ milliseconds: 150 * 1e3 }).then(() => Ge(e));
|
|
1440
1461
|
} catch (e) {
|
|
1441
1462
|
console.log(e);
|
|
1442
1463
|
}
|
|
1443
1464
|
}, Y = () => {
|
|
1444
1465
|
q && q.abort();
|
|
1445
|
-
},
|
|
1466
|
+
}, Ke = (e) => {
|
|
1446
1467
|
let t = `oidc.tabId.${e}`, n = sessionStorage.getItem(t);
|
|
1447
1468
|
if (n) return n;
|
|
1448
1469
|
let r = globalThis.crypto.randomUUID();
|
|
1449
1470
|
return sessionStorage.setItem(t, r), r;
|
|
1450
|
-
},
|
|
1471
|
+
}, qe = (e) => navigator.serviceWorker.controller ?? e.active ?? e.waiting ?? e.installing ?? null, X = (e, t) => (n) => {
|
|
1451
1472
|
let r = t?.timeoutMs ?? 5e3;
|
|
1452
1473
|
return new Promise((t, i) => {
|
|
1453
|
-
let a =
|
|
1474
|
+
let a = qe(e);
|
|
1454
1475
|
if (!a) {
|
|
1455
1476
|
i(/* @__PURE__ */ Error("Service worker target not available (controller/active/waiting/installing missing)"));
|
|
1456
1477
|
return;
|
|
@@ -1471,39 +1492,39 @@ var W = (e, t = null, n) => {
|
|
|
1471
1492
|
let e = n?.configurationName;
|
|
1472
1493
|
a.postMessage({
|
|
1473
1494
|
...n,
|
|
1474
|
-
tabId:
|
|
1495
|
+
tabId: Ke(e ?? "default")
|
|
1475
1496
|
}, [o.port2]);
|
|
1476
1497
|
} catch (e) {
|
|
1477
1498
|
l(), i(e);
|
|
1478
1499
|
}
|
|
1479
1500
|
});
|
|
1480
|
-
},
|
|
1501
|
+
}, Je = async (e) => navigator.serviceWorker.controller ? navigator.serviceWorker.controller : new Promise((t) => {
|
|
1481
1502
|
let n = !1, r = () => {
|
|
1482
1503
|
n || (n = !0, navigator.serviceWorker.removeEventListener("controllerchange", r), t(navigator.serviceWorker.controller ?? null));
|
|
1483
1504
|
};
|
|
1484
1505
|
navigator.serviceWorker.addEventListener("controllerchange", r), c.setTimeout(() => {
|
|
1485
1506
|
n || (n = !0, navigator.serviceWorker.removeEventListener("controllerchange", r), t(navigator.serviceWorker.controller ?? null));
|
|
1486
1507
|
}, e);
|
|
1487
|
-
}),
|
|
1508
|
+
}), Ye = !1, Z = !1, Q = /* @__PURE__ */ new Map(), Xe = "oidc.sw.controllerchange_reload_count", Ze = 3, Qe = () => {
|
|
1488
1509
|
try {
|
|
1489
|
-
return parseInt(sessionStorage.getItem(
|
|
1510
|
+
return parseInt(sessionStorage.getItem(Xe) ?? "0", 10);
|
|
1490
1511
|
} catch {
|
|
1491
1512
|
return 0;
|
|
1492
1513
|
}
|
|
1493
|
-
},
|
|
1494
|
-
let e =
|
|
1514
|
+
}, $e = () => {
|
|
1515
|
+
let e = Qe() + 1;
|
|
1495
1516
|
try {
|
|
1496
|
-
sessionStorage.setItem(
|
|
1517
|
+
sessionStorage.setItem(Xe, String(e));
|
|
1497
1518
|
} catch {}
|
|
1498
1519
|
return e;
|
|
1499
|
-
},
|
|
1520
|
+
}, et = () => {
|
|
1500
1521
|
try {
|
|
1501
|
-
sessionStorage.removeItem(
|
|
1522
|
+
sessionStorage.removeItem(Xe);
|
|
1502
1523
|
} catch {}
|
|
1503
1524
|
}, $ = async (e, t) => {
|
|
1504
1525
|
let n = e.service_worker_relative_url;
|
|
1505
1526
|
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !n || e.service_worker_activate() === !1) return null;
|
|
1506
|
-
let r = `${n}?v=${
|
|
1527
|
+
let r = `${n}?v=${Ue}`, i = null;
|
|
1507
1528
|
e.service_worker_register ? (Q.has(n) || Q.set(n, e.service_worker_register(n)), i = await Q.get(n)) : (Q.has(r) || Q.set(r, navigator.serviceWorker.register(r, { updateViaCache: "none" })), i = await Q.get(r));
|
|
1508
1529
|
let a = `oidc.sw.version_mismatch_reload.${t}`, o = async (e) => {
|
|
1509
1530
|
Y(), console.log("New SW waiting – SKIP_WAITING");
|
|
@@ -1526,7 +1547,7 @@ var W = (e, t = null, n) => {
|
|
|
1526
1547
|
type: "SKIP_WAITING",
|
|
1527
1548
|
configurationName: t,
|
|
1528
1549
|
data: null,
|
|
1529
|
-
tabId:
|
|
1550
|
+
tabId: Ke(t ?? "default")
|
|
1530
1551
|
}, [i.port2]);
|
|
1531
1552
|
} catch (e) {
|
|
1532
1553
|
o(), r(e);
|
|
@@ -1541,7 +1562,7 @@ var W = (e, t = null, n) => {
|
|
|
1541
1562
|
}, l = (e) => {
|
|
1542
1563
|
Y(), e.addEventListener("statechange", async () => {
|
|
1543
1564
|
if (e.state === "installed" && navigator.serviceWorker.controller) {
|
|
1544
|
-
if (
|
|
1565
|
+
if (Qe() >= Ze) {
|
|
1545
1566
|
console.warn("SW trackInstallingWorker: skipping SKIP_WAITING because the reload budget is exhausted");
|
|
1546
1567
|
return;
|
|
1547
1568
|
}
|
|
@@ -1552,7 +1573,7 @@ var W = (e, t = null, n) => {
|
|
|
1552
1573
|
i.addEventListener("updatefound", () => {
|
|
1553
1574
|
let e = i.installing;
|
|
1554
1575
|
e && l(e);
|
|
1555
|
-
}), i.installing ? l(i.installing) : i.waiting && navigator.serviceWorker.controller && (
|
|
1576
|
+
}), i.installing ? l(i.installing) : i.waiting && navigator.serviceWorker.controller && (Qe() < Ze ? s() : console.warn("SW: a waiting worker exists but reload budget is exhausted – skipping activation")), i.update().catch((e) => {
|
|
1556
1577
|
console.error(e);
|
|
1557
1578
|
});
|
|
1558
1579
|
try {
|
|
@@ -1560,14 +1581,14 @@ var W = (e, t = null, n) => {
|
|
|
1560
1581
|
type: "claim",
|
|
1561
1582
|
configurationName: t,
|
|
1562
1583
|
data: null
|
|
1563
|
-
}), await
|
|
1584
|
+
}), await Je(2e3));
|
|
1564
1585
|
} catch (e) {
|
|
1565
1586
|
return console.warn(`Failed init ServiceWorker ${e?.toString?.() ?? String(e)}`), null;
|
|
1566
1587
|
}
|
|
1567
|
-
|
|
1588
|
+
Ye || (Ye = !0, navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
1568
1589
|
if (Z) return;
|
|
1569
|
-
let e =
|
|
1570
|
-
if (e >
|
|
1590
|
+
let e = $e();
|
|
1591
|
+
if (e > Ze) {
|
|
1571
1592
|
console.warn(`SW controllerchange: reload budget exhausted (${e - 1} reloads). Skipping reload to avoid infinite loop.`);
|
|
1572
1593
|
return;
|
|
1573
1594
|
}
|
|
@@ -1590,8 +1611,8 @@ var W = (e, t = null, n) => {
|
|
|
1590
1611
|
},
|
|
1591
1612
|
configurationName: t
|
|
1592
1613
|
}), c = o.version;
|
|
1593
|
-
if (c !== "7.27.
|
|
1594
|
-
console.warn(`Service worker ${c} version mismatch with js client version ${
|
|
1614
|
+
if (c !== "7.27.17") {
|
|
1615
|
+
console.warn(`Service worker ${c} version mismatch with js client version ${Ue}, unregistering and reloading`);
|
|
1595
1616
|
let e = parseInt(sessionStorage.getItem(a) ?? "0", 10);
|
|
1596
1617
|
if (e < 3) {
|
|
1597
1618
|
if (sessionStorage.setItem(a, String(e + 1)), i.waiting) return await s(), await J({ milliseconds: 500 }), Z || (Z = !0, window.location.reload()), new Promise(() => {});
|
|
@@ -1606,13 +1627,13 @@ var W = (e, t = null, n) => {
|
|
|
1606
1627
|
return console.log(`Service worker unregistering ${e}`), await J({ milliseconds: 500 }), Z || (Z = !0, window.location.reload()), new Promise(() => {});
|
|
1607
1628
|
}
|
|
1608
1629
|
} else console.error(`Service worker version mismatch persists after ${e} attempt(s). Continuing with mismatched version.`);
|
|
1609
|
-
} else sessionStorage.removeItem(a),
|
|
1630
|
+
} else sessionStorage.removeItem(a), et();
|
|
1610
1631
|
return {
|
|
1611
1632
|
tokens: G(o.tokens, null, r.token_renew_mode),
|
|
1612
1633
|
status: o.status
|
|
1613
1634
|
};
|
|
1614
1635
|
}, f = (e = "/") => {
|
|
1615
|
-
|
|
1636
|
+
We ?? (We = "not_null", Ge(e));
|
|
1616
1637
|
}, p = (e) => X(i)({
|
|
1617
1638
|
type: "setSessionState",
|
|
1618
1639
|
data: { sessionState: e },
|
|
@@ -1718,11 +1739,11 @@ var W = (e, t = null, n) => {
|
|
|
1718
1739
|
configurationName: e.configurationName ?? t
|
|
1719
1740
|
})
|
|
1720
1741
|
};
|
|
1721
|
-
},
|
|
1742
|
+
}, tt = async (e, t, n, r) => {
|
|
1722
1743
|
let i = await $(e, t);
|
|
1723
1744
|
if (!i) throw Error(`signalServiceWorkerAsync: no service worker registered for configuration "${t}"`);
|
|
1724
1745
|
return i.signalAsync(n, r);
|
|
1725
|
-
},
|
|
1746
|
+
}, nt = class e {
|
|
1726
1747
|
constructor(e) {
|
|
1727
1748
|
this._oidc = e;
|
|
1728
1749
|
}
|
|
@@ -1739,7 +1760,11 @@ var W = (e, t = null, n) => {
|
|
|
1739
1760
|
this.getOrCreate = (t, n = new O()) => (r, i = "default") => new e(R.getOrCreate(t, n)(r, i));
|
|
1740
1761
|
}
|
|
1741
1762
|
static get(t = "default") {
|
|
1742
|
-
|
|
1763
|
+
let n = R.get(t);
|
|
1764
|
+
return n ? new e(n) : null;
|
|
1765
|
+
}
|
|
1766
|
+
static getOrThrow(t = "default") {
|
|
1767
|
+
return new e(R.getOrThrow(t));
|
|
1743
1768
|
}
|
|
1744
1769
|
static {
|
|
1745
1770
|
this.eventNames = R.eventNames;
|
|
@@ -1753,6 +1778,12 @@ var W = (e, t = null, n) => {
|
|
|
1753
1778
|
logoutAsync(e = void 0, t = null) {
|
|
1754
1779
|
return this._oidc.logoutAsync(e, t);
|
|
1755
1780
|
}
|
|
1781
|
+
clearSessionAsync() {
|
|
1782
|
+
return this._oidc.clearSessionAsync();
|
|
1783
|
+
}
|
|
1784
|
+
get isLoggingOut() {
|
|
1785
|
+
return this._oidc.isLoggingOut === !0;
|
|
1786
|
+
}
|
|
1756
1787
|
silentLoginCallbackAsync() {
|
|
1757
1788
|
return this._oidc.silentLoginCallbackAsync();
|
|
1758
1789
|
}
|
|
@@ -1773,7 +1804,7 @@ var W = (e, t = null, n) => {
|
|
|
1773
1804
|
}
|
|
1774
1805
|
async getValidTokenAsync(e = 200, t = 50) {
|
|
1775
1806
|
let n = this._oidc;
|
|
1776
|
-
return
|
|
1807
|
+
return Ve({
|
|
1777
1808
|
getTokens: () => n.tokens,
|
|
1778
1809
|
configuration: {
|
|
1779
1810
|
token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
|
|
@@ -1787,7 +1818,7 @@ var W = (e, t = null, n) => {
|
|
|
1787
1818
|
}, e, t);
|
|
1788
1819
|
}
|
|
1789
1820
|
fetchWithTokens(e, t = !1) {
|
|
1790
|
-
return
|
|
1821
|
+
return De(e, this._oidc, t);
|
|
1791
1822
|
}
|
|
1792
1823
|
async userInfoAsync(e = !1, t = !1) {
|
|
1793
1824
|
return this._oidc.userInfoAsync(e, t);
|
|
@@ -1796,9 +1827,9 @@ var W = (e, t = null, n) => {
|
|
|
1796
1827
|
return this._oidc.userInfo;
|
|
1797
1828
|
}
|
|
1798
1829
|
async signalServiceWorker(e, t) {
|
|
1799
|
-
return
|
|
1830
|
+
return tt(this._oidc.configuration, this._oidc.configurationName, e, t);
|
|
1800
1831
|
}
|
|
1801
|
-
},
|
|
1832
|
+
}, rt = "1.0.0", it = {
|
|
1802
1833
|
SKIP_WAITING: "SKIP_WAITING",
|
|
1803
1834
|
CLAIM: "claim",
|
|
1804
1835
|
CLEAR: "clear",
|
|
@@ -1815,18 +1846,18 @@ var W = (e, t = null, n) => {
|
|
|
1815
1846
|
GET_DPOP_NONCE: "getDemonstratingProofOfPossessionNonce",
|
|
1816
1847
|
SET_DPOP_JWK: "setDemonstratingProofOfPossessionJwk",
|
|
1817
1848
|
GET_DPOP_JWK: "getDemonstratingProofOfPossessionJwk"
|
|
1818
|
-
},
|
|
1849
|
+
}, at = {
|
|
1819
1850
|
ACCESS_TOKEN: "ACCESS_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
1820
1851
|
REFRESH_TOKEN: "REFRESH_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
1821
1852
|
NONCE_TOKEN: "NONCE_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
1822
1853
|
CODE_VERIFIER: "CODE_VERIFIER_SECURED_BY_OIDC_SERVICE_WORKER"
|
|
1823
|
-
},
|
|
1854
|
+
}, ot = "DPOP_SECURED_BY_OIDC_SERVICE_WORKER", st = {
|
|
1824
1855
|
TAB_ID: "oidc.tabId.",
|
|
1825
1856
|
STATE: "oidc.state.",
|
|
1826
1857
|
NONCE: "oidc.nonce.",
|
|
1827
1858
|
CODE_VERIFIER: "oidc.code_verifier.",
|
|
1828
1859
|
LOGIN_PARAMS: "oidc.login.",
|
|
1829
1860
|
SW_VERSION_MISMATCH_RELOAD: "oidc.sw.version_mismatch_reload."
|
|
1830
|
-
},
|
|
1861
|
+
}, ct = "oidc.sw.controllerchange_reload_count", lt = (e, t) => `${e}${t}`, ut = (e, t, n = "default") => `${e}_${t}#tabId=${n}`, dt = (e, t = "default") => `${ot}_${e}#tabId=${t}`, ft = (e) => typeof e == "string" ? Object.values(it).includes(e) : !1;
|
|
1831
1862
|
//#endregion
|
|
1832
|
-
export {
|
|
1863
|
+
export { ot as DPOP_TOKEN_PLACEHOLDER_PREFIX, nt as OidcClient, O as OidcLocation, rt as PROTOCOL_VERSION, st as STORAGE_KEY_PREFIX, ct as SW_CONTROLLER_CHANGE_RELOAD_COUNT_KEY, it as ServiceWorkerMessageType, at as TOKEN_PLACEHOLDERS, F as TokenAutomaticRenewMode, U as TokenRenewMode, dt as buildDpopSecuredPlaceholder, ut as buildSecuredTokenPlaceholder, lt as buildStorageKey, ke as getFetchDefault, M as getParseQueryStringFromLocation, ve as getPath, ft as isServiceWorkerMessageType, tt as signalServiceWorkerAsync };
|