@axa-fr/oidc-client 7.27.16 → 7.27.18
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 +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +245 -205
- package/dist/index.umd.cjs +2 -2
- package/dist/login.d.ts.map +1 -1
- package/dist/login.spec.d.ts +2 -0
- package/dist/login.spec.d.ts.map +1 -0
- package/dist/logout.d.ts +14 -0
- package/dist/logout.d.ts.map +1 -1
- package/dist/oidc.d.ts +20 -0
- package/dist/oidc.d.ts.map +1 -1
- package/dist/oidcClient.d.ts +20 -0
- package/dist/oidcClient.d.ts.map +1 -1
- package/dist/oidcStateError.d.ts +33 -0
- package/dist/oidcStateError.d.ts.map +1 -0
- package/dist/oidcStateError.spec.d.ts +2 -0
- package/dist/oidcStateError.spec.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/login.spec.ts +151 -0
- package/src/login.ts +23 -2
- package/src/logout.spec.ts +208 -1
- package/src/logout.ts +149 -80
- package/src/oidc.ts +30 -1
- package/src/oidcClient.ts +26 -0
- package/src/oidcStateError.spec.ts +33 -0
- package/src/oidcStateError.ts +50 -0
- package/src/renewTokens.ts +13 -0
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -327,53 +327,53 @@ var _ = {
|
|
|
327
327
|
}
|
|
328
328
|
let i = await e.crypto.subtle.digest(n, f(r));
|
|
329
329
|
return h(new Uint8Array(i));
|
|
330
|
-
} }, x = (e) => async (t) => await y.generate(e)(t),
|
|
330
|
+
} }, x = (e) => async (t) => await y.generate(e)(t), ee = (e) => (t) => async (n, r = "POST", i, a = {}) => {
|
|
331
331
|
let o = {
|
|
332
|
-
jti: btoa(
|
|
332
|
+
jti: btoa(S()),
|
|
333
333
|
htm: r,
|
|
334
334
|
htu: i,
|
|
335
335
|
iat: Math.round(Date.now() / 1e3),
|
|
336
336
|
...a
|
|
337
337
|
}, s = await b.thumbprint(e)(n, t.digestAlgorithm);
|
|
338
338
|
return await v.sign(e)(n, { kid: s }, o, t);
|
|
339
|
-
},
|
|
339
|
+
}, S = () => {
|
|
340
340
|
let e = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", t = "0123456789abcdef", n = 0, r = "";
|
|
341
341
|
for (let i = 0; i < 36; i++) e[i] !== "-" && e[i] !== "4" && (n = Math.random() * 16 | 0), e[i] === "x" ? r += t[n] : e[i] === "y" ? (n &= 3, n |= 8, r += t[n]) : r += e[i];
|
|
342
342
|
return r;
|
|
343
|
-
},
|
|
343
|
+
}, C = () => {
|
|
344
344
|
let e = typeof window < "u" && !!window.crypto;
|
|
345
345
|
return {
|
|
346
346
|
hasCrypto: e,
|
|
347
347
|
hasSubtleCrypto: e && !!window.crypto.subtle
|
|
348
348
|
};
|
|
349
|
-
},
|
|
349
|
+
}, w = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", T = (e) => {
|
|
350
350
|
let t = [];
|
|
351
351
|
for (let n = 0; n < e.byteLength; n += 1) {
|
|
352
352
|
let r = e[n] % 62;
|
|
353
|
-
t.push(
|
|
353
|
+
t.push(w[r]);
|
|
354
354
|
}
|
|
355
355
|
return t.join("");
|
|
356
|
-
},
|
|
357
|
-
let t = new Uint8Array(e), { hasCrypto: n } =
|
|
356
|
+
}, E = (e) => {
|
|
357
|
+
let t = new Uint8Array(e), { hasCrypto: n } = C();
|
|
358
358
|
if (n) window.crypto.getRandomValues(t);
|
|
359
359
|
else for (let n = 0; n < e; n += 1) t[n] = Math.random() * 62 | 0;
|
|
360
|
-
return
|
|
360
|
+
return T(t);
|
|
361
361
|
};
|
|
362
|
-
function
|
|
362
|
+
function te(e) {
|
|
363
363
|
let t = new ArrayBuffer(e.length), n = new Uint8Array(t);
|
|
364
364
|
for (let t = 0; t < e.length; t++) n[t] = e.charCodeAt(t);
|
|
365
365
|
return n;
|
|
366
366
|
}
|
|
367
|
-
function
|
|
367
|
+
function ne(e) {
|
|
368
368
|
return new Promise((t, n) => {
|
|
369
|
-
crypto.subtle.digest("SHA-256",
|
|
369
|
+
crypto.subtle.digest("SHA-256", te(e)).then((e) => t(h(new Uint8Array(e))), (e) => n(e));
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
|
-
var
|
|
372
|
+
var re = (e) => {
|
|
373
373
|
if (e.length < 43 || e.length > 128) return Promise.reject(/* @__PURE__ */ Error("Invalid code length."));
|
|
374
|
-
let { hasSubtleCrypto: t } =
|
|
375
|
-
return t ?
|
|
376
|
-
},
|
|
374
|
+
let { hasSubtleCrypto: t } = C();
|
|
375
|
+
return t ? ne(e) : Promise.reject(/* @__PURE__ */ Error("window.crypto.subtle is unavailable."));
|
|
376
|
+
}, ie = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), ae = (e) => {
|
|
377
377
|
let t = e.appVersion, n = e.userAgent, r = "-", i = [
|
|
378
378
|
{
|
|
379
379
|
s: "Windows 10",
|
|
@@ -509,7 +509,7 @@ var ne = (e) => {
|
|
|
509
509
|
osVersion: a
|
|
510
510
|
};
|
|
511
511
|
};
|
|
512
|
-
function
|
|
512
|
+
function oe() {
|
|
513
513
|
let e = navigator.userAgent, t, n = e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
514
514
|
if (/trident/i.test(n[1])) return t = /\brv[ :]+(\d+)/g.exec(e) || [], {
|
|
515
515
|
name: "ie",
|
|
@@ -535,10 +535,10 @@ function ae() {
|
|
|
535
535
|
version: n[1]
|
|
536
536
|
};
|
|
537
537
|
}
|
|
538
|
-
var
|
|
539
|
-
let { name: e, version: t } =
|
|
540
|
-
return e === "chrome" && parseInt(t) <= 70 || e === "opera" && (!t || parseInt(t.split(".")[0]) < 80) || e === "ie" ? !1 : !
|
|
541
|
-
},
|
|
538
|
+
var se = () => {
|
|
539
|
+
let { name: e, version: t } = oe();
|
|
540
|
+
return e === "chrome" && parseInt(t) <= 70 || e === "opera" && (!t || parseInt(t.split(".")[0]) < 80) || e === "ie" ? !1 : !ie(ae(navigator));
|
|
541
|
+
}, ce = async (t) => {
|
|
542
542
|
let n;
|
|
543
543
|
if (t.tokens != null) return !1;
|
|
544
544
|
t.publishEvent(e.tryKeepExistingSessionAsync_begin, {});
|
|
@@ -581,7 +581,7 @@ var oe = () => {
|
|
|
581
581
|
} catch (r) {
|
|
582
582
|
return console.error(r), n && await n.clearAsync(), t.publishEvent(e.tryKeepExistingSessionAsync_error, "tokens inside ServiceWorker are invalid"), !1;
|
|
583
583
|
}
|
|
584
|
-
},
|
|
584
|
+
}, D = class {
|
|
585
585
|
open(e) {
|
|
586
586
|
window.location.href = e;
|
|
587
587
|
}
|
|
@@ -598,30 +598,38 @@ var oe = () => {
|
|
|
598
598
|
getOrigin() {
|
|
599
599
|
return window.origin;
|
|
600
600
|
}
|
|
601
|
-
},
|
|
602
|
-
|
|
601
|
+
}, O = {
|
|
602
|
+
STATE_MISSING: "STATE_MISSING",
|
|
603
|
+
STATE_MISMATCH: "STATE_MISMATCH",
|
|
604
|
+
NONCE_MISSING: "NONCE_MISSING"
|
|
605
|
+
}, k = class e extends Error {
|
|
606
|
+
constructor(t, n) {
|
|
607
|
+
super(n), this.name = "OidcStateError", this.code = t, Object.setPrototypeOf(this, e.prototype);
|
|
608
|
+
}
|
|
609
|
+
}, le = (e) => e instanceof k, A = {}, ue = (e, t = window.sessionStorage, n) => {
|
|
610
|
+
if (!A[e] && t) {
|
|
603
611
|
let n = t.getItem(e);
|
|
604
|
-
n && (
|
|
612
|
+
n && (A[e] = JSON.parse(n));
|
|
605
613
|
}
|
|
606
614
|
let r = 1e3 * n;
|
|
607
|
-
return
|
|
608
|
-
},
|
|
615
|
+
return A[e] && A[e].timestamp + r > Date.now() ? A[e].result : null;
|
|
616
|
+
}, de = (e, t, n = window.sessionStorage) => {
|
|
609
617
|
let r = Date.now();
|
|
610
|
-
|
|
618
|
+
A[e] = {
|
|
611
619
|
result: t,
|
|
612
620
|
timestamp: r
|
|
613
621
|
}, n && n.setItem(e, JSON.stringify({
|
|
614
622
|
result: t,
|
|
615
623
|
timestamp: r
|
|
616
624
|
}));
|
|
617
|
-
},
|
|
618
|
-
let a = `${t}/.well-known/openid-configuration`, o = `oidc.server:${t}`, s =
|
|
619
|
-
if (s) return new
|
|
620
|
-
let c = await
|
|
625
|
+
}, fe = 3600, pe = (e) => async (t, n = fe, r = window.sessionStorage, i = 1e4) => {
|
|
626
|
+
let a = `${t}/.well-known/openid-configuration`, o = `oidc.server:${t}`, s = ue(o, r, n);
|
|
627
|
+
if (s) return new Me(s);
|
|
628
|
+
let c = await j(e)(a, {}, i);
|
|
621
629
|
if (c.status !== 200) return null;
|
|
622
630
|
let l = await c.json();
|
|
623
|
-
return
|
|
624
|
-
},
|
|
631
|
+
return de(o, l, r), new Me(l);
|
|
632
|
+
}, j = (e) => async (t, n = {}, r = 1e4, i = 0) => {
|
|
625
633
|
let a;
|
|
626
634
|
try {
|
|
627
635
|
let i = new AbortController();
|
|
@@ -631,15 +639,15 @@ var oe = () => {
|
|
|
631
639
|
});
|
|
632
640
|
} catch (a) {
|
|
633
641
|
if (a.name === "AbortError" || a.message === "Network request failed") {
|
|
634
|
-
if (i <= 1) return await
|
|
642
|
+
if (i <= 1) return await j(e)(t, n, r, i + 1);
|
|
635
643
|
throw a;
|
|
636
644
|
} else throw console.error(a.message), a;
|
|
637
645
|
}
|
|
638
646
|
return a;
|
|
639
|
-
},
|
|
647
|
+
}, me = {
|
|
640
648
|
refresh_token: "refresh_token",
|
|
641
649
|
access_token: "access_token"
|
|
642
|
-
},
|
|
650
|
+
}, he = (e) => async (t, n, r = me.refresh_token, i, a = {}, o = 1e4) => {
|
|
643
651
|
let s = {
|
|
644
652
|
token: n,
|
|
645
653
|
token_type_hint: r,
|
|
@@ -652,19 +660,19 @@ var oe = () => {
|
|
|
652
660
|
c.push(`${t}=${n}`);
|
|
653
661
|
}
|
|
654
662
|
let l = c.join("&");
|
|
655
|
-
return (await
|
|
663
|
+
return (await j(e)(t, {
|
|
656
664
|
method: "POST",
|
|
657
665
|
headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
|
|
658
666
|
body: l
|
|
659
667
|
}, o)).status === 200 ? { success: !0 } : { success: !1 };
|
|
660
|
-
},
|
|
668
|
+
}, ge = (e) => async (t, n, r, i, a = {}, o, s = 1e4) => {
|
|
661
669
|
for (let [e, t] of Object.entries(r)) n[e] === void 0 && (n[e] = t);
|
|
662
670
|
let c = [];
|
|
663
671
|
for (let e in n) {
|
|
664
672
|
let t = encodeURIComponent(e), r = encodeURIComponent(n[e]);
|
|
665
673
|
c.push(`${t}=${r}`);
|
|
666
674
|
}
|
|
667
|
-
let l = c.join("&"), u = await
|
|
675
|
+
let l = c.join("&"), u = await j(e)(t, {
|
|
668
676
|
method: "POST",
|
|
669
677
|
headers: {
|
|
670
678
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
@@ -684,21 +692,21 @@ var oe = () => {
|
|
|
684
692
|
data: G(d, i, o),
|
|
685
693
|
demonstratingProofOfPossessionNonce: f
|
|
686
694
|
};
|
|
687
|
-
},
|
|
695
|
+
}, _e = (e, t) => async (n, r) => {
|
|
688
696
|
r = r ? { ...r } : {};
|
|
689
|
-
let i =
|
|
697
|
+
let i = E(128), a = await re(i);
|
|
690
698
|
await e.setCodeVerifierAsync(i), await e.setStateAsync(r.state), r.code_challenge = a, r.code_challenge_method = "S256";
|
|
691
699
|
let o = "";
|
|
692
700
|
if (r) for (let [e, t] of Object.entries(r)) o === "" ? o += "?" : o += "&", o += `${e}=${encodeURIComponent(t)}`;
|
|
693
701
|
t.open(`${n}${o}`);
|
|
694
|
-
}, M = "DPoP-Nonce",
|
|
702
|
+
}, M = "DPoP-Nonce", ve = (e) => async (t, n, r, i, a = 1e4) => {
|
|
695
703
|
n = n ? { ...n } : {}, n.code_verifier = await e.getCodeVerifierAsync();
|
|
696
704
|
let o = [];
|
|
697
705
|
for (let e in n) {
|
|
698
706
|
let t = encodeURIComponent(e), r = encodeURIComponent(n[e]);
|
|
699
707
|
o.push(`${t}=${r}`);
|
|
700
708
|
}
|
|
701
|
-
let s = o.join("&"), c = await
|
|
709
|
+
let s = o.join("&"), c = await j(fetch)(t, {
|
|
702
710
|
method: "POST",
|
|
703
711
|
headers: {
|
|
704
712
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
@@ -721,7 +729,7 @@ var oe = () => {
|
|
|
721
729
|
demonstratingProofOfPossessionNonce: l
|
|
722
730
|
}
|
|
723
731
|
};
|
|
724
|
-
},
|
|
732
|
+
}, ye = (e) => {
|
|
725
733
|
let t = e.match(/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
726
734
|
if (!t) throw Error("Invalid URL");
|
|
727
735
|
let n = t[6], r = t[7];
|
|
@@ -739,23 +747,23 @@ var oe = () => {
|
|
|
739
747
|
search: n,
|
|
740
748
|
hash: r
|
|
741
749
|
};
|
|
742
|
-
},
|
|
743
|
-
let t =
|
|
750
|
+
}, be = (e) => {
|
|
751
|
+
let t = ye(e), { path: n } = t;
|
|
744
752
|
n.endsWith("/") && (n = n.slice(0, -1));
|
|
745
753
|
let { hash: r } = t;
|
|
746
754
|
return r === "#_=_" && (r = ""), r && (n += r), n;
|
|
747
755
|
}, N = (e) => {
|
|
748
|
-
let { search: t } =
|
|
749
|
-
return
|
|
750
|
-
},
|
|
756
|
+
let { search: t } = ye(e);
|
|
757
|
+
return xe(t);
|
|
758
|
+
}, xe = (e) => {
|
|
751
759
|
let t = {}, n, r, i, a = e.split("&");
|
|
752
760
|
for (r = 0, i = a.length; r < i; r++) n = a[r].split("="), t[decodeURIComponent(n[0])] = decodeURIComponent(n[1]);
|
|
753
761
|
return t;
|
|
754
|
-
},
|
|
762
|
+
}, Se = (t, n, r, a, o) => (s = void 0, c = null, l = !1, u = void 0) => {
|
|
755
763
|
let d = c;
|
|
756
764
|
return c = { ...c }, (async () => {
|
|
757
765
|
let f = s || o.getPath();
|
|
758
|
-
if ("state" in c || (c.state =
|
|
766
|
+
if ("state" in c || (c.state = E(16)), r(e.loginAsync_begin, {}), c) for (let e of Object.keys(c)) e.endsWith(":token_request") && delete c[e];
|
|
759
767
|
try {
|
|
760
768
|
let e = l ? n.silent_redirect_uri : n.redirect_uri;
|
|
761
769
|
u ||= n.scope;
|
|
@@ -763,7 +771,7 @@ var oe = () => {
|
|
|
763
771
|
...n.extras,
|
|
764
772
|
...c
|
|
765
773
|
} : c;
|
|
766
|
-
r.nonce ||=
|
|
774
|
+
r.nonce ||= E(12);
|
|
767
775
|
let s = { nonce: r.nonce }, p = await $(n, t), m = await a(n.authority, n.authority_configuration), h;
|
|
768
776
|
if (p) p.setLoginParams({
|
|
769
777
|
callbackPath: f,
|
|
@@ -785,12 +793,12 @@ var oe = () => {
|
|
|
785
793
|
response_type: "code",
|
|
786
794
|
...r
|
|
787
795
|
};
|
|
788
|
-
await
|
|
796
|
+
await _e(h, o)(m.authorizationEndpoint, g);
|
|
789
797
|
} catch (t) {
|
|
790
798
|
throw r(e.loginAsync_error, t), t;
|
|
791
799
|
}
|
|
792
800
|
})();
|
|
793
|
-
},
|
|
801
|
+
}, Ce = (t) => async (n = !1) => {
|
|
794
802
|
try {
|
|
795
803
|
t.publishEvent(e.loginCallbackAsync_begin, {});
|
|
796
804
|
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 = N(t.location.getCurrentHref()), d = u.session_state, f = await $(r, t.configurationName), p, m, h, g;
|
|
@@ -801,7 +809,11 @@ var oe = () => {
|
|
|
801
809
|
}
|
|
802
810
|
if (u.error || u.error_description) throw Error(`Error from OIDC server: ${u.error} - ${u.error_description}`);
|
|
803
811
|
if (u.iss && u.iss !== l.issuer) throw console.error(), Error(`Issuer not valid (expected: ${l.issuer}, received: ${u.iss})`);
|
|
804
|
-
if (u.state
|
|
812
|
+
if (u.state) {
|
|
813
|
+
if (!g) throw new k(O.STATE_MISSING, "OIDC state is missing from storage. The login state may have been cleared between the authorization redirect and the callback (e.g., private browsing, storage cleared, or browser eviction).");
|
|
814
|
+
if (u.state !== g) throw new k(O.STATE_MISMATCH, `OIDC state does not match the stored one (expected: ${g}, received: ${u.state}).`);
|
|
815
|
+
}
|
|
816
|
+
if (!m || !m.nonce) throw new k(O.NONCE_MISSING, "OIDC nonce is missing from storage. The login state may have been cleared between the authorization redirect and the callback (e.g., private browsing, storage cleared, or browser eviction).");
|
|
805
817
|
let _ = {
|
|
806
818
|
code: u.code,
|
|
807
819
|
grant_type: "authorization_code",
|
|
@@ -814,37 +826,37 @@ var oe = () => {
|
|
|
814
826
|
if (r.demonstrating_proof_of_possession) if (f) b.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${t.configurationName}`;
|
|
815
827
|
else {
|
|
816
828
|
let e = await x(window)(r.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm);
|
|
817
|
-
await i(t.configurationName, r.storage, r.login_state_storage ?? r.storage).setDemonstratingProofOfPossessionJwkAsync(e), b.DPoP = await
|
|
829
|
+
await i(t.configurationName, r.storage, r.login_state_storage ?? r.storage).setDemonstratingProofOfPossessionJwkAsync(e), b.DPoP = await ee(window)(r.demonstrating_proof_of_possession_configuration)(e, "POST", y);
|
|
818
830
|
}
|
|
819
|
-
let
|
|
831
|
+
let S = await ve(p)(y, {
|
|
820
832
|
..._,
|
|
821
833
|
...v
|
|
822
834
|
}, b, t.configuration.token_renew_mode, c);
|
|
823
|
-
if (!
|
|
824
|
-
let
|
|
825
|
-
if (
|
|
826
|
-
let { isValid:
|
|
827
|
-
if (!
|
|
835
|
+
if (!S.success) throw Error("Token request failed");
|
|
836
|
+
let C, w = S.data.tokens, T = S.data.demonstratingProofOfPossessionNonce;
|
|
837
|
+
if (S.data.state !== v.state) throw Error("state is not valid");
|
|
838
|
+
let { isValid: E, reason: te } = Ge(w, m.nonce, l);
|
|
839
|
+
if (!E) throw Error(`Tokens are not OpenID valid, reason: ${te}`);
|
|
828
840
|
if (f) {
|
|
829
|
-
if (
|
|
830
|
-
if (
|
|
841
|
+
if (w.refreshToken && !w.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER")) throw Error("Refresh token should be hidden by service worker");
|
|
842
|
+
if (T && w?.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER")) throw Error("Demonstration of proof of possession require Access token not hidden by service worker");
|
|
831
843
|
}
|
|
832
|
-
if (f) await f.initAsync(l, "syncTokensAsync", r),
|
|
844
|
+
if (f) await f.initAsync(l, "syncTokensAsync", r), C = f.getLoginParams(), T && await f.setDemonstratingProofOfPossessionNonce(T);
|
|
833
845
|
else {
|
|
834
846
|
let e = i(t.configurationName, r.storage, r.login_state_storage ?? r.storage);
|
|
835
|
-
|
|
847
|
+
C = e.getLoginParams(), T && await e.setDemonstratingProofOfPossessionNonce(T);
|
|
836
848
|
}
|
|
837
849
|
return await t.startCheckSessionAsync(l.checkSessionIframe, a, d, n), t.publishEvent(e.loginCallbackAsync_end, {}), {
|
|
838
|
-
tokens:
|
|
850
|
+
tokens: w,
|
|
839
851
|
state: "request.state",
|
|
840
|
-
callbackPath:
|
|
852
|
+
callbackPath: C.callbackPath,
|
|
841
853
|
scope: u.scope,
|
|
842
|
-
extras:
|
|
854
|
+
extras: C.extras
|
|
843
855
|
};
|
|
844
856
|
} catch (n) {
|
|
845
857
|
throw console.error(n), t.publishEvent(e.loginCallbackAsync_error, n), n;
|
|
846
858
|
}
|
|
847
|
-
},
|
|
859
|
+
}, we = {
|
|
848
860
|
access_token: "access_token",
|
|
849
861
|
refresh_token: "refresh_token"
|
|
850
862
|
}, P = (e, t) => {
|
|
@@ -857,59 +869,72 @@ var oe = () => {
|
|
|
857
869
|
return n;
|
|
858
870
|
}
|
|
859
871
|
return n;
|
|
860
|
-
},
|
|
872
|
+
}, Te = (e) => {
|
|
861
873
|
let t = {};
|
|
862
874
|
if (e) {
|
|
863
875
|
for (let [n, r] of Object.entries(e)) n.includes(":") || (t[n] = r);
|
|
864
876
|
return t;
|
|
865
877
|
}
|
|
866
878
|
return t;
|
|
867
|
-
},
|
|
879
|
+
}, Ee = (e) => async (t) => {
|
|
868
880
|
c.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
869
881
|
let n = await $(e.configuration, e.configurationName);
|
|
870
882
|
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
|
-
|
|
883
|
+
}, F = (t, n) => async () => {
|
|
884
|
+
let r = t.tokens?.idTokenPayload?.sub ?? null;
|
|
885
|
+
await t.destroyAsync("LOGGED_OUT");
|
|
886
|
+
for (let [, i] of Object.entries(n)) i === t ? t.publishEvent(e.logout_from_same_tab, {}) : await t.logoutSameTabAsync(t.configuration.client_id, r);
|
|
887
|
+
}, De = (e, t, n, r) => {
|
|
888
|
+
"id_token_hint" in t || (t.id_token_hint = n), !("post_logout_redirect_uri" in t) && r !== null && (t.post_logout_redirect_uri = r);
|
|
889
|
+
let i = "";
|
|
890
|
+
for (let [e, n] of Object.entries(t)) n != null && (i === "" ? i += "?" : i += "&", i += `${e}=${encodeURIComponent(n)}`);
|
|
891
|
+
return `${e}${i}`;
|
|
892
|
+
}, Oe = (e, t, n, r, i) => async (a = void 0, o = null) => {
|
|
893
|
+
let s = e.configuration, c = await e.initAsync(s.authority, s.authority_configuration);
|
|
894
|
+
a && typeof a != "string" && (a = void 0, r.warn("callbackPathOrUrl path is not a string"));
|
|
895
|
+
let l = a ?? i.getPath(), u = !1;
|
|
896
|
+
a && (u = a.includes("https://") || a.includes("http://"));
|
|
897
|
+
let d = a === null ? null : u ? a : i.getOrigin() + l, f = e.tokens ? e.tokens.idToken : "";
|
|
898
|
+
e.isLoggingOut = !0;
|
|
877
899
|
try {
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
900
|
+
try {
|
|
901
|
+
let t = c.revocationEndpoint;
|
|
902
|
+
if (t) {
|
|
903
|
+
let r = [], i = e.tokens ? e.tokens.accessToken : null;
|
|
904
|
+
if (i && s.logout_tokens_to_invalidate.includes(we.access_token)) {
|
|
905
|
+
let e = P(o, ":revoke_access_token"), a = he(n)(t, i, me.access_token, s.client_id, e);
|
|
906
|
+
r.push(a);
|
|
907
|
+
}
|
|
908
|
+
let a = e.tokens ? e.tokens.refreshToken : null;
|
|
909
|
+
if (a && s.logout_tokens_to_invalidate.includes(we.refresh_token)) {
|
|
910
|
+
let e = P(o, ":revoke_refresh_token"), i = he(n)(t, a, me.refresh_token, s.client_id, e);
|
|
911
|
+
r.push(i);
|
|
912
|
+
}
|
|
913
|
+
r.length > 0 && await Promise.all(r);
|
|
889
914
|
}
|
|
890
|
-
|
|
915
|
+
} catch (e) {
|
|
916
|
+
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
917
|
}
|
|
892
|
-
|
|
893
|
-
|
|
918
|
+
let a = P(o, ":oidc");
|
|
919
|
+
if (a && a.no_reload === "true") {
|
|
920
|
+
await F(e, t)(), e.isLoggingOut = !1;
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
let l = Te(o);
|
|
924
|
+
if (c.endSessionEndpoint) {
|
|
925
|
+
let e = De(c.endSessionEndpoint, l, f, d);
|
|
926
|
+
i.open(e);
|
|
927
|
+
} else i.reload();
|
|
928
|
+
await F(e, t)();
|
|
929
|
+
} catch (t) {
|
|
930
|
+
throw e.isLoggingOut = !1, t;
|
|
894
931
|
}
|
|
895
|
-
|
|
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
|
-
}, F = /* @__PURE__ */ function(e) {
|
|
932
|
+
}, I = /* @__PURE__ */ function(e) {
|
|
908
933
|
return e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e;
|
|
909
|
-
}({}),
|
|
934
|
+
}({}), ke = (e, t, n = !1) => async (...r) => {
|
|
910
935
|
let [i, a, ...o] = r, s = a ? { ...a } : { method: "GET" }, c = new Headers();
|
|
911
936
|
s.headers && (c = s.headers instanceof Headers ? s.headers : new Headers(s.headers));
|
|
912
|
-
let l = (await
|
|
937
|
+
let l = (await We({
|
|
913
938
|
getTokens: () => t.tokens,
|
|
914
939
|
configuration: {
|
|
915
940
|
token_automatic_renew_mode: t.configuration.token_automatic_renew_mode,
|
|
@@ -932,32 +957,32 @@ var oe = () => {
|
|
|
932
957
|
...s,
|
|
933
958
|
headers: c
|
|
934
959
|
}, ...o);
|
|
935
|
-
},
|
|
960
|
+
}, Ae = (e) => async (t = !1, n = !1) => {
|
|
936
961
|
if (e.userInfo != null && !t) return e.userInfo;
|
|
937
962
|
let r = !t && e.configuration.storage?.getItem(`oidc.${e.configurationName}.userInfo`);
|
|
938
963
|
if (r) return e.userInfo = JSON.parse(r), e.userInfo;
|
|
939
964
|
let i = e.configuration, a = (await e.initAsync(i.authority, i.authority_configuration)).userInfoEndpoint, o = await (async () => {
|
|
940
|
-
let t = await
|
|
965
|
+
let t = await ke(fetch, e, n)(a);
|
|
941
966
|
return t.status === 200 ? t.json() : null;
|
|
942
967
|
})();
|
|
943
968
|
return e.userInfo = o, o && e.configuration.storage?.setItem(`oidc.${e.configurationName}.userInfo`, JSON.stringify(o)), o;
|
|
944
|
-
},
|
|
969
|
+
}, je = () => fetch, Me = class {
|
|
945
970
|
constructor(e) {
|
|
946
971
|
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
972
|
}
|
|
948
|
-
}, L = {},
|
|
973
|
+
}, L = {}, Ne = (e, t = new D()) => (n, r = "default") => (L[r] || (L[r] = new R(n, r, e, t)), L[r]), Pe = async (e) => {
|
|
949
974
|
let { parsedTokens: t, callbackPath: n, extras: r, scope: i } = await e.loginCallbackAsync();
|
|
950
975
|
return e.timeoutId = z(e, t.expiresAt, r, i), { callbackPath: n };
|
|
951
|
-
},
|
|
952
|
-
constructor(e, t = "default", n, r = new
|
|
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;
|
|
976
|
+
}, Fe = (e) => Math.floor(Math.random() * e), R = class t {
|
|
977
|
+
constructor(e, t = "default", n, r = new D()) {
|
|
978
|
+
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
979
|
let i = e.silent_login_uri;
|
|
955
980
|
e.silent_redirect_uri && !e.silent_login_uri && (i = `${e.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
|
|
956
981
|
let a = e.refresh_time_before_tokens_expiration_in_second ?? 120;
|
|
957
|
-
a > 60 && (a -= Math.floor(Math.random() * 40)), this.location = r ?? new
|
|
982
|
+
a > 60 && (a -= Math.floor(Math.random() * 40)), this.location = r ?? new D(), this.configuration = {
|
|
958
983
|
...e,
|
|
959
984
|
silent_login_uri: i,
|
|
960
|
-
token_automatic_renew_mode: e.token_automatic_renew_mode ??
|
|
985
|
+
token_automatic_renew_mode: e.token_automatic_renew_mode ?? I.AutomaticBeforeTokenExpiration,
|
|
961
986
|
monitor_session: e.monitor_session ?? !1,
|
|
962
987
|
refresh_time_before_tokens_expiration_in_second: a,
|
|
963
988
|
silent_login_timeout: e.silent_login_timeout ?? 12e3,
|
|
@@ -965,13 +990,13 @@ var oe = () => {
|
|
|
965
990
|
demonstrating_proof_of_possession: e.demonstrating_proof_of_possession ?? !1,
|
|
966
991
|
authority_timeout_wellknowurl_in_millisecond: e.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
967
992
|
logout_tokens_to_invalidate: e.logout_tokens_to_invalidate ?? ["access_token", "refresh_token"],
|
|
968
|
-
service_worker_activate: e.service_worker_activate ??
|
|
993
|
+
service_worker_activate: e.service_worker_activate ?? se,
|
|
969
994
|
demonstrating_proof_of_possession_configuration: e.demonstrating_proof_of_possession_configuration ?? _,
|
|
970
995
|
preload_user_info: e.preload_user_info ?? !1
|
|
971
|
-
}, this.getFetch = n ??
|
|
996
|
+
}, this.getFetch = n ?? je, 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
997
|
}
|
|
973
998
|
subscribeEvents(e) {
|
|
974
|
-
let t =
|
|
999
|
+
let t = Fe(9999999999999).toString();
|
|
975
1000
|
return this.events.push({
|
|
976
1001
|
id: t,
|
|
977
1002
|
func: e
|
|
@@ -987,7 +1012,7 @@ var oe = () => {
|
|
|
987
1012
|
});
|
|
988
1013
|
}
|
|
989
1014
|
static {
|
|
990
|
-
this.getOrCreate = (e, t) => (n, r = "default") =>
|
|
1015
|
+
this.getOrCreate = (e, t) => (n, r = "default") => Ne(e, t)(n, r);
|
|
991
1016
|
}
|
|
992
1017
|
static get(e = "default") {
|
|
993
1018
|
return Object.prototype.hasOwnProperty.call(L, e) ? L[e] : null;
|
|
@@ -1026,7 +1051,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1026
1051
|
async initAsync(e, t) {
|
|
1027
1052
|
if (this.initPromise !== null) return this.initPromise;
|
|
1028
1053
|
let n = async () => {
|
|
1029
|
-
if (t != null) return new
|
|
1054
|
+
if (t != null) return new Me({
|
|
1030
1055
|
authorization_endpoint: t.authorization_endpoint,
|
|
1031
1056
|
end_session_endpoint: t.end_session_endpoint,
|
|
1032
1057
|
revocation_endpoint: t.revocation_endpoint,
|
|
@@ -1036,14 +1061,14 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1036
1061
|
issuer: t.issuer
|
|
1037
1062
|
});
|
|
1038
1063
|
let n = await $(this.configuration, this.configurationName) ? this.configuration.storage || window.sessionStorage : this.configuration.storage;
|
|
1039
|
-
return await
|
|
1064
|
+
return await pe(this.getFetch())(e, this.configuration.authority_time_cache_wellknowurl_in_second ?? 3600, n, this.configuration.authority_timeout_wellknowurl_in_millisecond);
|
|
1040
1065
|
};
|
|
1041
1066
|
return this.initPromise = n(), this.initPromise.finally(() => {
|
|
1042
1067
|
this.initPromise = null;
|
|
1043
1068
|
});
|
|
1044
1069
|
}
|
|
1045
1070
|
async tryKeepExistingSessionAsync() {
|
|
1046
|
-
return this.tryKeepExistingSessionPromise === null ? (this.tryKeepExistingSessionPromise =
|
|
1071
|
+
return this.tryKeepExistingSessionPromise === null ? (this.tryKeepExistingSessionPromise = ce(this), this.tryKeepExistingSessionPromise.finally(() => {
|
|
1047
1072
|
this.tryKeepExistingSessionPromise = null;
|
|
1048
1073
|
})) : this.tryKeepExistingSessionPromise;
|
|
1049
1074
|
}
|
|
@@ -1051,14 +1076,14 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1051
1076
|
await d(this, L, this.configuration)(e, t, n, r);
|
|
1052
1077
|
}
|
|
1053
1078
|
async loginAsync(e = void 0, t = null, n = !1, r = void 0, i = !1) {
|
|
1054
|
-
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 =
|
|
1079
|
+
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 = Se(this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this), this.location)(e, t, n, r), this.loginPromise.finally(() => {
|
|
1055
1080
|
this.loginPromise = null;
|
|
1056
1081
|
})) : this.loginPromise;
|
|
1057
1082
|
}
|
|
1058
1083
|
async loginCallbackAsync(e = !1) {
|
|
1059
1084
|
if (this.loginCallbackPromise !== null) return this.loginCallbackPromise;
|
|
1060
1085
|
let n = async () => {
|
|
1061
|
-
let n = await
|
|
1086
|
+
let n = await Ce(this)(e), r = n.tokens;
|
|
1062
1087
|
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(), {
|
|
1063
1088
|
parsedTokens: r,
|
|
1064
1089
|
state: n.state,
|
|
@@ -1073,31 +1098,36 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1073
1098
|
}
|
|
1074
1099
|
async generateDemonstrationOfProofOfPossessionAsync(e, t, n, r = {}) {
|
|
1075
1100
|
let a = this.configuration, o = {
|
|
1076
|
-
ath: await
|
|
1101
|
+
ath: await ne(e),
|
|
1077
1102
|
...r
|
|
1078
1103
|
};
|
|
1079
|
-
if (await $(a, this.configurationName)) return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${
|
|
1104
|
+
if (await $(a, this.configurationName)) return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${Ye(this.configurationName)}`;
|
|
1080
1105
|
let s = i(this.configurationName, a.storage, a.login_state_storage ?? a.storage), c = await s.getDemonstratingProofOfPossessionJwkAsync(), l = s.getDemonstratingProofOfPossessionNonce();
|
|
1081
|
-
return l && (o.nonce = l), await
|
|
1106
|
+
return l && (o.nonce = l), await ee(window)(a.demonstrating_proof_of_possession_configuration)(c, n, t, o);
|
|
1082
1107
|
}
|
|
1083
1108
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1084
|
-
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1109
|
+
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise = Pe(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
|
|
1085
1110
|
this.loginCallbackWithAutoTokensRenewPromise = null;
|
|
1086
1111
|
})) : this.loginCallbackWithAutoTokensRenewPromise;
|
|
1087
1112
|
}
|
|
1088
1113
|
userInfoAsync(e = !1, t = !1) {
|
|
1089
|
-
return this.userInfoPromise === null ? (this.userInfoPromise =
|
|
1114
|
+
return this.userInfoPromise === null ? (this.userInfoPromise = Ae(this)(e, t), this.userInfoPromise.finally(() => {
|
|
1090
1115
|
this.userInfoPromise = null;
|
|
1091
1116
|
})) : this.userInfoPromise;
|
|
1092
1117
|
}
|
|
1093
1118
|
async renewTokensAsync(e = null, t = null) {
|
|
1094
1119
|
if (this.renewTokensPromise !== null) return this.renewTokensPromise;
|
|
1095
|
-
if (this.timeoutId) return c.clearTimeout(this.timeoutId), this.renewTokensPromise =
|
|
1120
|
+
if (this.timeoutId) return c.clearTimeout(this.timeoutId), this.renewTokensPromise = Le(this, !0, e, t), this.renewTokensPromise.finally(() => {
|
|
1096
1121
|
this.renewTokensPromise = null;
|
|
1097
1122
|
});
|
|
1098
1123
|
}
|
|
1099
1124
|
async destroyAsync(e) {
|
|
1100
|
-
return await
|
|
1125
|
+
return await Ee(this)(e);
|
|
1126
|
+
}
|
|
1127
|
+
async clearSessionAsync() {
|
|
1128
|
+
return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise = F(this, L)(), this.clearSessionPromise.finally(() => {
|
|
1129
|
+
this.clearSessionPromise = null;
|
|
1130
|
+
}));
|
|
1101
1131
|
}
|
|
1102
1132
|
async logoutSameTabAsync(t, n) {
|
|
1103
1133
|
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, {
|
|
@@ -1112,25 +1142,25 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1112
1142
|
}));
|
|
1113
1143
|
}
|
|
1114
1144
|
async logoutAsync(e = void 0, t = null) {
|
|
1115
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1145
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = Oe(this, L, this.getFetch(), console, this.location)(e, t), this.logoutPromise.finally(() => {
|
|
1116
1146
|
this.logoutPromise = null;
|
|
1117
1147
|
}));
|
|
1118
1148
|
}
|
|
1119
1149
|
};
|
|
1120
1150
|
//#endregion
|
|
1121
1151
|
//#region src/renewTokens.ts
|
|
1122
|
-
async function
|
|
1152
|
+
async function Ie(e, t, n, r = null) {
|
|
1123
1153
|
let { tokens: a, status: o } = await H(e)((t) => {
|
|
1124
1154
|
e.tokens = t;
|
|
1125
1155
|
}, 0, 0, t, n, r);
|
|
1126
1156
|
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);
|
|
1127
1157
|
}
|
|
1128
|
-
async function
|
|
1158
|
+
async function Le(e, t = !1, n = null, r = null) {
|
|
1129
1159
|
let i = e.configuration, a = `${i.client_id}_${e.configurationName}_${i.authority}`, o, s = await $(e.configuration, e.configurationName);
|
|
1130
|
-
if (i?.storage === window?.sessionStorage && !s || !navigator.locks) o = await
|
|
1160
|
+
if (i?.storage === window?.sessionStorage && !s || !navigator.locks) o = await Ie(e, t, n, r);
|
|
1131
1161
|
else {
|
|
1132
1162
|
let i = "retry";
|
|
1133
|
-
for (; i === "retry";) i = await navigator.locks.request(a, { ifAvailable: !0 }, async (i) => i ? await
|
|
1163
|
+
for (; i === "retry";) i = await navigator.locks.request(a, { ifAvailable: !0 }, async (i) => i ? await Ie(e, t, n, r) : (e.publishEvent(R.eventNames.syncTokensAsync_lock_not_available, { lock: "lock not available" }), "retry"));
|
|
1134
1164
|
o = i;
|
|
1135
1165
|
}
|
|
1136
1166
|
return o ? (e.timeoutId &&= z(e, e.tokens.expiresAt, n, r), e.tokens) : null;
|
|
@@ -1139,7 +1169,7 @@ var z = (e, t, n = null, r = null) => {
|
|
|
1139
1169
|
let i = e.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
1140
1170
|
return e.timeoutId && c.clearTimeout(e.timeoutId), c.setTimeout(async () => {
|
|
1141
1171
|
let a = { timeLeft: K(i, t) };
|
|
1142
|
-
e.publishEvent(R.eventNames.token_timer, a), await
|
|
1172
|
+
e.publishEvent(R.eventNames.token_timer, a), await Le(e, !1, n, r);
|
|
1143
1173
|
}, 1e3);
|
|
1144
1174
|
}, B = {
|
|
1145
1175
|
FORCE_REFRESH: "FORCE_REFRESH",
|
|
@@ -1276,12 +1306,12 @@ var z = (e, t, n = null, r = null) => {
|
|
|
1276
1306
|
tokens: null,
|
|
1277
1307
|
status: "LOGGED_OUT"
|
|
1278
1308
|
};
|
|
1279
|
-
case B.REQUIRE_SYNC_TOKENS: return h.token_automatic_renew_mode ==
|
|
1309
|
+
case B.REQUIRE_SYNC_TOKENS: return h.token_automatic_renew_mode == I.AutomaticOnlyWhenFetchExecuted && !o ? (t.publishEvent(e.tokensInvalidAndWaitingActionsToRefresh, {}), {
|
|
1280
1310
|
tokens: t.tokens,
|
|
1281
1311
|
status: "GIVE_UP"
|
|
1282
1312
|
}) : (t.publishEvent(e.refreshTokensAsync_begin, { tryNumber: r }), await _());
|
|
1283
1313
|
default: {
|
|
1284
|
-
if (h.token_automatic_renew_mode ==
|
|
1314
|
+
if (h.token_automatic_renew_mode == I.AutomaticOnlyWhenFetchExecuted && B.FORCE_REFRESH !== l) return t.publishEvent(e.tokensInvalidAndWaitingActionsToRefresh, {}), {
|
|
1285
1315
|
tokens: t.tokens,
|
|
1286
1316
|
status: "GIVE_UP"
|
|
1287
1317
|
};
|
|
@@ -1301,9 +1331,13 @@ var z = (e, t, n = null, r = null) => {
|
|
|
1301
1331
|
refresh_token: u.refreshToken
|
|
1302
1332
|
}, a = await t.initAsync(v, h.authority_configuration), l = document.hidden ? 1e4 : 3e4 * 10, _ = a.tokenEndpoint, b = {};
|
|
1303
1333
|
h.demonstrating_proof_of_possession && (b.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(u.accessToken, _, "POST"));
|
|
1304
|
-
let x = await
|
|
1334
|
+
let x = await ge(t.getFetch())(_, r, y, u, b, h.token_renew_mode, l);
|
|
1305
1335
|
if (x.success) {
|
|
1306
|
-
|
|
1336
|
+
if (!d || !d.nonce) return n(null), t.publishEvent(e.refreshTokensAsync_error, { message: "refresh token: nonce missing from storage" }), {
|
|
1337
|
+
tokens: null,
|
|
1338
|
+
status: "SESSION_LOST"
|
|
1339
|
+
};
|
|
1340
|
+
let { isValid: r, reason: o } = Ge(x.data, d.nonce, a);
|
|
1307
1341
|
if (!r) return n(null), t.publishEvent(e.refreshTokensAsync_error, { message: `refresh token return not valid tokens, reason: ${o}` }), {
|
|
1308
1342
|
tokens: null,
|
|
1309
1343
|
status: "SESSION_LOST"
|
|
@@ -1336,29 +1370,29 @@ var z = (e, t, n = null, r = null) => {
|
|
|
1336
1370
|
}, 1e3);
|
|
1337
1371
|
});
|
|
1338
1372
|
}
|
|
1339
|
-
},
|
|
1373
|
+
}, Re = (e) => decodeURIComponent(Array.prototype.map.call(atob(e), (e) => "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2)).join("")), ze = (e) => JSON.parse(Re(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), Be = (e) => {
|
|
1340
1374
|
try {
|
|
1341
|
-
return e &&
|
|
1375
|
+
return e && Ve(e, ".") === 2 ? ze(e.split(".")[1]) : null;
|
|
1342
1376
|
} catch (e) {
|
|
1343
1377
|
console.warn(e);
|
|
1344
1378
|
}
|
|
1345
1379
|
return null;
|
|
1346
|
-
},
|
|
1380
|
+
}, Ve = (e, t) => e.split(t).length - 1, U = {
|
|
1347
1381
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
1348
1382
|
access_token_invalid: "access_token_invalid",
|
|
1349
1383
|
id_token_invalid: "id_token_invalid"
|
|
1350
1384
|
};
|
|
1351
|
-
function
|
|
1385
|
+
function He(e, t, n) {
|
|
1352
1386
|
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;
|
|
1353
1387
|
}
|
|
1354
1388
|
var W = (e, t = null, n) => {
|
|
1355
1389
|
if (!e) return null;
|
|
1356
1390
|
let r, i = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
|
|
1357
|
-
r = e.accessTokenPayload === void 0 ?
|
|
1391
|
+
r = e.accessTokenPayload === void 0 ? Be(e.accessToken) : e.accessTokenPayload;
|
|
1358
1392
|
let a;
|
|
1359
1393
|
a = t != null && "idToken" in t && !("idToken" in e) ? t.idToken : e.idToken;
|
|
1360
|
-
let o = e.idTokenPayload ? e.idTokenPayload :
|
|
1361
|
-
e.issuedAt =
|
|
1394
|
+
let o = e.idTokenPayload ? e.idTokenPayload : Be(a), s = o && o.exp ? o.exp : Number.MAX_VALUE, c = r && r.exp ? r.exp : e.issuedAt + i;
|
|
1395
|
+
e.issuedAt = He(e, r, o);
|
|
1362
1396
|
let l;
|
|
1363
1397
|
l = e.expiresAt ? e.expiresAt : n === U.access_token_invalid ? c : n === U.id_token_invalid || s < c ? s : c;
|
|
1364
1398
|
let u = {
|
|
@@ -1391,25 +1425,25 @@ var W = (e, t = null, n) => {
|
|
|
1391
1425
|
}, K = (e, t) => {
|
|
1392
1426
|
let n = t - (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
1393
1427
|
return Math.round(n - e);
|
|
1394
|
-
},
|
|
1428
|
+
}, Ue = (e, t = 0) => e ? K(t, e.expiresAt) > 0 : !1, We = async (e, t = 200, n = 50) => {
|
|
1395
1429
|
let r = n, i = await e.syncTokensInfoAsync();
|
|
1396
1430
|
for (; [
|
|
1397
1431
|
B.REQUIRE_SYNC_TOKENS,
|
|
1398
1432
|
B.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
|
|
1399
1433
|
B.TOKENS_INVALID
|
|
1400
1434
|
].includes(i) && r > 0;) {
|
|
1401
|
-
if (e.configuration.token_automatic_renew_mode ==
|
|
1435
|
+
if (e.configuration.token_automatic_renew_mode == I.AutomaticOnlyWhenFetchExecuted) {
|
|
1402
1436
|
await e.renewTokensAsync({});
|
|
1403
1437
|
break;
|
|
1404
1438
|
} else await J({ milliseconds: t });
|
|
1405
1439
|
--r, i = await e.syncTokensInfoAsync();
|
|
1406
1440
|
}
|
|
1407
1441
|
return {
|
|
1408
|
-
isTokensValid:
|
|
1442
|
+
isTokensValid: Ue(e.getTokens()),
|
|
1409
1443
|
tokens: e.getTokens(),
|
|
1410
1444
|
numberWaited: r - n
|
|
1411
1445
|
};
|
|
1412
|
-
},
|
|
1446
|
+
}, Ge = (e, t, n) => {
|
|
1413
1447
|
if (e.idTokenPayload) {
|
|
1414
1448
|
let r = e.idTokenPayload;
|
|
1415
1449
|
if (n.issuer !== r.iss) return {
|
|
@@ -1435,25 +1469,25 @@ var W = (e, t = null, n) => {
|
|
|
1435
1469
|
isValid: !0,
|
|
1436
1470
|
reason: ""
|
|
1437
1471
|
};
|
|
1438
|
-
},
|
|
1472
|
+
}, Ke = "7.27.18", qe = null, q, J = ({ milliseconds: e }) => new Promise((t) => c.setTimeout(t, e)), Je = (e = "/") => {
|
|
1439
1473
|
try {
|
|
1440
1474
|
q = new AbortController(), fetch(`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: q.signal }).catch((e) => {
|
|
1441
1475
|
console.log(e);
|
|
1442
|
-
}), J({ milliseconds: 150 * 1e3 }).then(() =>
|
|
1476
|
+
}), J({ milliseconds: 150 * 1e3 }).then(() => Je(e));
|
|
1443
1477
|
} catch (e) {
|
|
1444
1478
|
console.log(e);
|
|
1445
1479
|
}
|
|
1446
1480
|
}, Y = () => {
|
|
1447
1481
|
q && q.abort();
|
|
1448
|
-
},
|
|
1482
|
+
}, Ye = (e) => {
|
|
1449
1483
|
let t = `oidc.tabId.${e}`, n = sessionStorage.getItem(t);
|
|
1450
1484
|
if (n) return n;
|
|
1451
1485
|
let r = globalThis.crypto.randomUUID();
|
|
1452
1486
|
return sessionStorage.setItem(t, r), r;
|
|
1453
|
-
},
|
|
1487
|
+
}, Xe = (e) => navigator.serviceWorker.controller ?? e.active ?? e.waiting ?? e.installing ?? null, X = (e, t) => (n) => {
|
|
1454
1488
|
let r = t?.timeoutMs ?? 5e3;
|
|
1455
1489
|
return new Promise((t, i) => {
|
|
1456
|
-
let a =
|
|
1490
|
+
let a = Xe(e);
|
|
1457
1491
|
if (!a) {
|
|
1458
1492
|
i(/* @__PURE__ */ Error("Service worker target not available (controller/active/waiting/installing missing)"));
|
|
1459
1493
|
return;
|
|
@@ -1474,39 +1508,39 @@ var W = (e, t = null, n) => {
|
|
|
1474
1508
|
let e = n?.configurationName;
|
|
1475
1509
|
a.postMessage({
|
|
1476
1510
|
...n,
|
|
1477
|
-
tabId:
|
|
1511
|
+
tabId: Ye(e ?? "default")
|
|
1478
1512
|
}, [o.port2]);
|
|
1479
1513
|
} catch (e) {
|
|
1480
1514
|
l(), i(e);
|
|
1481
1515
|
}
|
|
1482
1516
|
});
|
|
1483
|
-
},
|
|
1517
|
+
}, Ze = async (e) => navigator.serviceWorker.controller ? navigator.serviceWorker.controller : new Promise((t) => {
|
|
1484
1518
|
let n = !1, r = () => {
|
|
1485
1519
|
n || (n = !0, navigator.serviceWorker.removeEventListener("controllerchange", r), t(navigator.serviceWorker.controller ?? null));
|
|
1486
1520
|
};
|
|
1487
1521
|
navigator.serviceWorker.addEventListener("controllerchange", r), c.setTimeout(() => {
|
|
1488
1522
|
n || (n = !0, navigator.serviceWorker.removeEventListener("controllerchange", r), t(navigator.serviceWorker.controller ?? null));
|
|
1489
1523
|
}, e);
|
|
1490
|
-
}),
|
|
1524
|
+
}), Qe = !1, Z = !1, Q = /* @__PURE__ */ new Map(), $e = "oidc.sw.controllerchange_reload_count", et = 3, tt = () => {
|
|
1491
1525
|
try {
|
|
1492
|
-
return parseInt(sessionStorage.getItem(
|
|
1526
|
+
return parseInt(sessionStorage.getItem($e) ?? "0", 10);
|
|
1493
1527
|
} catch {
|
|
1494
1528
|
return 0;
|
|
1495
1529
|
}
|
|
1496
|
-
},
|
|
1497
|
-
let e =
|
|
1530
|
+
}, nt = () => {
|
|
1531
|
+
let e = tt() + 1;
|
|
1498
1532
|
try {
|
|
1499
|
-
sessionStorage.setItem(
|
|
1533
|
+
sessionStorage.setItem($e, String(e));
|
|
1500
1534
|
} catch {}
|
|
1501
1535
|
return e;
|
|
1502
|
-
},
|
|
1536
|
+
}, rt = () => {
|
|
1503
1537
|
try {
|
|
1504
|
-
sessionStorage.removeItem(
|
|
1538
|
+
sessionStorage.removeItem($e);
|
|
1505
1539
|
} catch {}
|
|
1506
1540
|
}, $ = async (e, t) => {
|
|
1507
1541
|
let n = e.service_worker_relative_url;
|
|
1508
1542
|
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !n || e.service_worker_activate() === !1) return null;
|
|
1509
|
-
let r = `${n}?v=${
|
|
1543
|
+
let r = `${n}?v=${Ke}`, i = null;
|
|
1510
1544
|
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));
|
|
1511
1545
|
let a = `oidc.sw.version_mismatch_reload.${t}`, o = async (e) => {
|
|
1512
1546
|
Y(), console.log("New SW waiting – SKIP_WAITING");
|
|
@@ -1529,7 +1563,7 @@ var W = (e, t = null, n) => {
|
|
|
1529
1563
|
type: "SKIP_WAITING",
|
|
1530
1564
|
configurationName: t,
|
|
1531
1565
|
data: null,
|
|
1532
|
-
tabId:
|
|
1566
|
+
tabId: Ye(t ?? "default")
|
|
1533
1567
|
}, [i.port2]);
|
|
1534
1568
|
} catch (e) {
|
|
1535
1569
|
o(), r(e);
|
|
@@ -1544,7 +1578,7 @@ var W = (e, t = null, n) => {
|
|
|
1544
1578
|
}, l = (e) => {
|
|
1545
1579
|
Y(), e.addEventListener("statechange", async () => {
|
|
1546
1580
|
if (e.state === "installed" && navigator.serviceWorker.controller) {
|
|
1547
|
-
if (
|
|
1581
|
+
if (tt() >= et) {
|
|
1548
1582
|
console.warn("SW trackInstallingWorker: skipping SKIP_WAITING because the reload budget is exhausted");
|
|
1549
1583
|
return;
|
|
1550
1584
|
}
|
|
@@ -1555,7 +1589,7 @@ var W = (e, t = null, n) => {
|
|
|
1555
1589
|
i.addEventListener("updatefound", () => {
|
|
1556
1590
|
let e = i.installing;
|
|
1557
1591
|
e && l(e);
|
|
1558
|
-
}), i.installing ? l(i.installing) : i.waiting && navigator.serviceWorker.controller && (
|
|
1592
|
+
}), i.installing ? l(i.installing) : i.waiting && navigator.serviceWorker.controller && (tt() < et ? s() : console.warn("SW: a waiting worker exists but reload budget is exhausted – skipping activation")), i.update().catch((e) => {
|
|
1559
1593
|
console.error(e);
|
|
1560
1594
|
});
|
|
1561
1595
|
try {
|
|
@@ -1563,14 +1597,14 @@ var W = (e, t = null, n) => {
|
|
|
1563
1597
|
type: "claim",
|
|
1564
1598
|
configurationName: t,
|
|
1565
1599
|
data: null
|
|
1566
|
-
}), await
|
|
1600
|
+
}), await Ze(2e3));
|
|
1567
1601
|
} catch (e) {
|
|
1568
1602
|
return console.warn(`Failed init ServiceWorker ${e?.toString?.() ?? String(e)}`), null;
|
|
1569
1603
|
}
|
|
1570
|
-
|
|
1604
|
+
Qe || (Qe = !0, navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
1571
1605
|
if (Z) return;
|
|
1572
|
-
let e =
|
|
1573
|
-
if (e >
|
|
1606
|
+
let e = nt();
|
|
1607
|
+
if (e > et) {
|
|
1574
1608
|
console.warn(`SW controllerchange: reload budget exhausted (${e - 1} reloads). Skipping reload to avoid infinite loop.`);
|
|
1575
1609
|
return;
|
|
1576
1610
|
}
|
|
@@ -1593,8 +1627,8 @@ var W = (e, t = null, n) => {
|
|
|
1593
1627
|
},
|
|
1594
1628
|
configurationName: t
|
|
1595
1629
|
}), c = o.version;
|
|
1596
|
-
if (c !== "7.27.
|
|
1597
|
-
console.warn(`Service worker ${c} version mismatch with js client version ${
|
|
1630
|
+
if (c !== "7.27.18") {
|
|
1631
|
+
console.warn(`Service worker ${c} version mismatch with js client version ${Ke}, unregistering and reloading`);
|
|
1598
1632
|
let e = parseInt(sessionStorage.getItem(a) ?? "0", 10);
|
|
1599
1633
|
if (e < 3) {
|
|
1600
1634
|
if (sessionStorage.setItem(a, String(e + 1)), i.waiting) return await s(), await J({ milliseconds: 500 }), Z || (Z = !0, window.location.reload()), new Promise(() => {});
|
|
@@ -1609,13 +1643,13 @@ var W = (e, t = null, n) => {
|
|
|
1609
1643
|
return console.log(`Service worker unregistering ${e}`), await J({ milliseconds: 500 }), Z || (Z = !0, window.location.reload()), new Promise(() => {});
|
|
1610
1644
|
}
|
|
1611
1645
|
} else console.error(`Service worker version mismatch persists after ${e} attempt(s). Continuing with mismatched version.`);
|
|
1612
|
-
} else sessionStorage.removeItem(a),
|
|
1646
|
+
} else sessionStorage.removeItem(a), rt();
|
|
1613
1647
|
return {
|
|
1614
1648
|
tokens: G(o.tokens, null, r.token_renew_mode),
|
|
1615
1649
|
status: o.status
|
|
1616
1650
|
};
|
|
1617
1651
|
}, f = (e = "/") => {
|
|
1618
|
-
|
|
1652
|
+
qe ?? (qe = "not_null", Je(e));
|
|
1619
1653
|
}, p = (e) => X(i)({
|
|
1620
1654
|
type: "setSessionState",
|
|
1621
1655
|
data: { sessionState: e },
|
|
@@ -1661,39 +1695,39 @@ var W = (e, t = null, n) => {
|
|
|
1661
1695
|
type: "getDemonstratingProofOfPossessionNonce",
|
|
1662
1696
|
data: null,
|
|
1663
1697
|
configurationName: t
|
|
1664
|
-
})).demonstratingProofOfPossessionNonce,
|
|
1698
|
+
})).demonstratingProofOfPossessionNonce, ee = async (e) => {
|
|
1665
1699
|
let n = JSON.stringify(e);
|
|
1666
1700
|
await X(i)({
|
|
1667
1701
|
type: "setDemonstratingProofOfPossessionJwk",
|
|
1668
1702
|
data: { demonstratingProofOfPossessionJwkJson: n },
|
|
1669
1703
|
configurationName: t
|
|
1670
1704
|
});
|
|
1671
|
-
},
|
|
1705
|
+
}, S = async () => {
|
|
1672
1706
|
let e = await X(i)({
|
|
1673
1707
|
type: "getDemonstratingProofOfPossessionJwk",
|
|
1674
1708
|
data: null,
|
|
1675
1709
|
configurationName: t
|
|
1676
1710
|
});
|
|
1677
1711
|
return e.demonstratingProofOfPossessionJwkJson ? JSON.parse(e.demonstratingProofOfPossessionJwkJson) : null;
|
|
1678
|
-
},
|
|
1712
|
+
}, C = async (e = !0) => {
|
|
1679
1713
|
let n = (await X(i)({
|
|
1680
1714
|
type: "getState",
|
|
1681
1715
|
data: null,
|
|
1682
1716
|
configurationName: t
|
|
1683
1717
|
})).state;
|
|
1684
|
-
return n || (n = sessionStorage[`oidc.state.${t}`], console.warn("state not found in service worker, using sessionStorage"), e && (await
|
|
1685
|
-
},
|
|
1718
|
+
return n || (n = sessionStorage[`oidc.state.${t}`], console.warn("state not found in service worker, using sessionStorage"), e && (await w(n), n = await C(!1))), n;
|
|
1719
|
+
}, w = async (e) => (sessionStorage[`oidc.state.${t}`] = e, X(i)({
|
|
1686
1720
|
type: "setState",
|
|
1687
1721
|
data: { state: e },
|
|
1688
1722
|
configurationName: t
|
|
1689
|
-
})),
|
|
1723
|
+
})), T = async (e = !0) => {
|
|
1690
1724
|
let n = (await X(i)({
|
|
1691
1725
|
type: "getCodeVerifier",
|
|
1692
1726
|
data: null,
|
|
1693
1727
|
configurationName: t
|
|
1694
1728
|
})).codeVerifier;
|
|
1695
|
-
return n || (n = sessionStorage[`oidc.code_verifier.${t}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), e && (await
|
|
1696
|
-
},
|
|
1729
|
+
return n || (n = sessionStorage[`oidc.code_verifier.${t}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), e && (await E(n), n = await T(!1))), n;
|
|
1730
|
+
}, E = async (e) => (sessionStorage[`oidc.code_verifier.${t}`] = e, X(i)({
|
|
1697
1731
|
type: "setCodeVerifier",
|
|
1698
1732
|
data: { codeVerifier: e },
|
|
1699
1733
|
configurationName: t
|
|
@@ -1708,24 +1742,24 @@ var W = (e, t = null, n) => {
|
|
|
1708
1742
|
getNonceAsync: g,
|
|
1709
1743
|
setLoginParams: v,
|
|
1710
1744
|
getLoginParams: y,
|
|
1711
|
-
getStateAsync:
|
|
1712
|
-
setStateAsync:
|
|
1713
|
-
getCodeVerifierAsync:
|
|
1714
|
-
setCodeVerifierAsync:
|
|
1745
|
+
getStateAsync: C,
|
|
1746
|
+
setStateAsync: w,
|
|
1747
|
+
getCodeVerifierAsync: T,
|
|
1748
|
+
setCodeVerifierAsync: E,
|
|
1715
1749
|
setDemonstratingProofOfPossessionNonce: b,
|
|
1716
1750
|
getDemonstratingProofOfPossessionNonce: x,
|
|
1717
|
-
setDemonstratingProofOfPossessionJwkAsync:
|
|
1718
|
-
getDemonstratingProofOfPossessionJwkAsync:
|
|
1751
|
+
setDemonstratingProofOfPossessionJwkAsync: ee,
|
|
1752
|
+
getDemonstratingProofOfPossessionJwkAsync: S,
|
|
1719
1753
|
signalAsync: (e, n) => X(i, n)({
|
|
1720
1754
|
...e,
|
|
1721
1755
|
configurationName: e.configurationName ?? t
|
|
1722
1756
|
})
|
|
1723
1757
|
};
|
|
1724
|
-
},
|
|
1758
|
+
}, it = async (e, t, n, r) => {
|
|
1725
1759
|
let i = await $(e, t);
|
|
1726
1760
|
if (!i) throw Error(`signalServiceWorkerAsync: no service worker registered for configuration "${t}"`);
|
|
1727
1761
|
return i.signalAsync(n, r);
|
|
1728
|
-
},
|
|
1762
|
+
}, at = class e {
|
|
1729
1763
|
constructor(e) {
|
|
1730
1764
|
this._oidc = e;
|
|
1731
1765
|
}
|
|
@@ -1739,7 +1773,7 @@ var W = (e, t = null, n) => {
|
|
|
1739
1773
|
this._oidc.publishEvent(e, t);
|
|
1740
1774
|
}
|
|
1741
1775
|
static {
|
|
1742
|
-
this.getOrCreate = (t, n = new
|
|
1776
|
+
this.getOrCreate = (t, n = new D()) => (r, i = "default") => new e(R.getOrCreate(t, n)(r, i));
|
|
1743
1777
|
}
|
|
1744
1778
|
static get(t = "default") {
|
|
1745
1779
|
let n = R.get(t);
|
|
@@ -1760,6 +1794,12 @@ var W = (e, t = null, n) => {
|
|
|
1760
1794
|
logoutAsync(e = void 0, t = null) {
|
|
1761
1795
|
return this._oidc.logoutAsync(e, t);
|
|
1762
1796
|
}
|
|
1797
|
+
clearSessionAsync() {
|
|
1798
|
+
return this._oidc.clearSessionAsync();
|
|
1799
|
+
}
|
|
1800
|
+
get isLoggingOut() {
|
|
1801
|
+
return this._oidc.isLoggingOut === !0;
|
|
1802
|
+
}
|
|
1763
1803
|
silentLoginCallbackAsync() {
|
|
1764
1804
|
return this._oidc.silentLoginCallbackAsync();
|
|
1765
1805
|
}
|
|
@@ -1780,7 +1820,7 @@ var W = (e, t = null, n) => {
|
|
|
1780
1820
|
}
|
|
1781
1821
|
async getValidTokenAsync(e = 200, t = 50) {
|
|
1782
1822
|
let n = this._oidc;
|
|
1783
|
-
return
|
|
1823
|
+
return We({
|
|
1784
1824
|
getTokens: () => n.tokens,
|
|
1785
1825
|
configuration: {
|
|
1786
1826
|
token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
|
|
@@ -1794,7 +1834,7 @@ var W = (e, t = null, n) => {
|
|
|
1794
1834
|
}, e, t);
|
|
1795
1835
|
}
|
|
1796
1836
|
fetchWithTokens(e, t = !1) {
|
|
1797
|
-
return
|
|
1837
|
+
return ke(e, this._oidc, t);
|
|
1798
1838
|
}
|
|
1799
1839
|
async userInfoAsync(e = !1, t = !1) {
|
|
1800
1840
|
return this._oidc.userInfoAsync(e, t);
|
|
@@ -1803,9 +1843,9 @@ var W = (e, t = null, n) => {
|
|
|
1803
1843
|
return this._oidc.userInfo;
|
|
1804
1844
|
}
|
|
1805
1845
|
async signalServiceWorker(e, t) {
|
|
1806
|
-
return
|
|
1846
|
+
return it(this._oidc.configuration, this._oidc.configurationName, e, t);
|
|
1807
1847
|
}
|
|
1808
|
-
},
|
|
1848
|
+
}, ot = "1.0.0", st = {
|
|
1809
1849
|
SKIP_WAITING: "SKIP_WAITING",
|
|
1810
1850
|
CLAIM: "claim",
|
|
1811
1851
|
CLEAR: "clear",
|
|
@@ -1822,18 +1862,18 @@ var W = (e, t = null, n) => {
|
|
|
1822
1862
|
GET_DPOP_NONCE: "getDemonstratingProofOfPossessionNonce",
|
|
1823
1863
|
SET_DPOP_JWK: "setDemonstratingProofOfPossessionJwk",
|
|
1824
1864
|
GET_DPOP_JWK: "getDemonstratingProofOfPossessionJwk"
|
|
1825
|
-
},
|
|
1865
|
+
}, ct = {
|
|
1826
1866
|
ACCESS_TOKEN: "ACCESS_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
1827
1867
|
REFRESH_TOKEN: "REFRESH_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
1828
1868
|
NONCE_TOKEN: "NONCE_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
1829
1869
|
CODE_VERIFIER: "CODE_VERIFIER_SECURED_BY_OIDC_SERVICE_WORKER"
|
|
1830
|
-
},
|
|
1870
|
+
}, lt = "DPOP_SECURED_BY_OIDC_SERVICE_WORKER", ut = {
|
|
1831
1871
|
TAB_ID: "oidc.tabId.",
|
|
1832
1872
|
STATE: "oidc.state.",
|
|
1833
1873
|
NONCE: "oidc.nonce.",
|
|
1834
1874
|
CODE_VERIFIER: "oidc.code_verifier.",
|
|
1835
1875
|
LOGIN_PARAMS: "oidc.login.",
|
|
1836
1876
|
SW_VERSION_MISMATCH_RELOAD: "oidc.sw.version_mismatch_reload."
|
|
1837
|
-
},
|
|
1877
|
+
}, dt = "oidc.sw.controllerchange_reload_count", ft = (e, t) => `${e}${t}`, pt = (e, t, n = "default") => `${e}_${t}#tabId=${n}`, mt = (e, t = "default") => `${lt}_${e}#tabId=${t}`, ht = (e) => typeof e == "string" ? Object.values(st).includes(e) : !1;
|
|
1838
1878
|
//#endregion
|
|
1839
|
-
export {
|
|
1879
|
+
export { lt as DPOP_TOKEN_PLACEHOLDER_PREFIX, at as OidcClient, D as OidcLocation, k as OidcStateError, O as OidcStateErrorCode, ot as PROTOCOL_VERSION, ut as STORAGE_KEY_PREFIX, dt as SW_CONTROLLER_CHANGE_RELOAD_COUNT_KEY, st as ServiceWorkerMessageType, ct as TOKEN_PLACEHOLDERS, I as TokenAutomaticRenewMode, U as TokenRenewMode, mt as buildDpopSecuredPlaceholder, pt as buildSecuredTokenPlaceholder, ft as buildStorageKey, je as getFetchDefault, N as getParseQueryStringFromLocation, be as getPath, le as isOidcStateError, ht as isServiceWorkerMessageType, it as signalServiceWorkerAsync };
|