@axa-fr/oidc-client 7.27.17 → 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 +208 -192
- 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/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/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",
|
|
@@ -678,27 +686,27 @@ var oe = () => {
|
|
|
678
686
|
demonstratingProofOfPossessionNonce: null
|
|
679
687
|
};
|
|
680
688
|
let d = await u.json(), f = null;
|
|
681
|
-
return u.headers.has(
|
|
689
|
+
return u.headers.has(M) && (f = u.headers.get(M)), {
|
|
682
690
|
success: !0,
|
|
683
691
|
status: u.status,
|
|
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
|
-
},
|
|
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",
|
|
@@ -711,7 +719,7 @@ var oe = () => {
|
|
|
711
719
|
status: c.status
|
|
712
720
|
};
|
|
713
721
|
let l = null;
|
|
714
|
-
c.headers.has(
|
|
722
|
+
c.headers.has(M) && (l = c.headers.get(M));
|
|
715
723
|
let u = await c.json();
|
|
716
724
|
return {
|
|
717
725
|
success: !0,
|
|
@@ -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
|
-
},
|
|
748
|
-
let { search: t } =
|
|
749
|
-
return
|
|
750
|
-
},
|
|
755
|
+
}, N = (e) => {
|
|
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,15 +793,15 @@ 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
|
-
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 =
|
|
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;
|
|
797
805
|
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
806
|
else {
|
|
799
807
|
let e = i(t.configurationName, r.storage ?? sessionStorage, r.login_state_storage ?? r.storage ?? sessionStorage);
|
|
@@ -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,40 +826,40 @@ 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) => {
|
|
851
863
|
let n = {};
|
|
852
864
|
if (e) {
|
|
853
865
|
for (let [r, i] of Object.entries(e)) if (r.endsWith(t)) {
|
|
@@ -857,27 +869,27 @@ 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
|
-
},
|
|
883
|
+
}, F = (t, n) => async () => {
|
|
872
884
|
let r = t.tokens?.idTokenPayload?.sub ?? null;
|
|
873
885
|
await t.destroyAsync("LOGGED_OUT");
|
|
874
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);
|
|
875
|
-
},
|
|
887
|
+
}, De = (e, t, n, r) => {
|
|
876
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);
|
|
877
889
|
let i = "";
|
|
878
890
|
for (let [e, n] of Object.entries(t)) n != null && (i === "" ? i += "?" : i += "&", i += `${e}=${encodeURIComponent(n)}`);
|
|
879
891
|
return `${e}${i}`;
|
|
880
|
-
},
|
|
892
|
+
}, Oe = (e, t, n, r, i) => async (a = void 0, o = null) => {
|
|
881
893
|
let s = e.configuration, c = await e.initAsync(s.authority, s.authority_configuration);
|
|
882
894
|
a && typeof a != "string" && (a = void 0, r.warn("callbackPathOrUrl path is not a string"));
|
|
883
895
|
let l = a ?? i.getPath(), u = !1;
|
|
@@ -889,13 +901,13 @@ var oe = () => {
|
|
|
889
901
|
let t = c.revocationEndpoint;
|
|
890
902
|
if (t) {
|
|
891
903
|
let r = [], i = e.tokens ? e.tokens.accessToken : null;
|
|
892
|
-
if (i && s.logout_tokens_to_invalidate.includes(
|
|
893
|
-
let e =
|
|
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);
|
|
894
906
|
r.push(a);
|
|
895
907
|
}
|
|
896
908
|
let a = e.tokens ? e.tokens.refreshToken : null;
|
|
897
|
-
if (a && s.logout_tokens_to_invalidate.includes(
|
|
898
|
-
let e =
|
|
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);
|
|
899
911
|
r.push(i);
|
|
900
912
|
}
|
|
901
913
|
r.length > 0 && await Promise.all(r);
|
|
@@ -903,26 +915,26 @@ var oe = () => {
|
|
|
903
915
|
} catch (e) {
|
|
904
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);
|
|
905
917
|
}
|
|
906
|
-
let a =
|
|
918
|
+
let a = P(o, ":oidc");
|
|
907
919
|
if (a && a.no_reload === "true") {
|
|
908
|
-
await
|
|
920
|
+
await F(e, t)(), e.isLoggingOut = !1;
|
|
909
921
|
return;
|
|
910
922
|
}
|
|
911
|
-
let l =
|
|
923
|
+
let l = Te(o);
|
|
912
924
|
if (c.endSessionEndpoint) {
|
|
913
|
-
let e =
|
|
925
|
+
let e = De(c.endSessionEndpoint, l, f, d);
|
|
914
926
|
i.open(e);
|
|
915
927
|
} else i.reload();
|
|
916
|
-
await
|
|
928
|
+
await F(e, t)();
|
|
917
929
|
} catch (t) {
|
|
918
930
|
throw e.isLoggingOut = !1, t;
|
|
919
931
|
}
|
|
920
|
-
},
|
|
932
|
+
}, I = /* @__PURE__ */ function(e) {
|
|
921
933
|
return e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e;
|
|
922
|
-
}({}),
|
|
934
|
+
}({}), ke = (e, t, n = !1) => async (...r) => {
|
|
923
935
|
let [i, a, ...o] = r, s = a ? { ...a } : { method: "GET" }, c = new Headers();
|
|
924
936
|
s.headers && (c = s.headers instanceof Headers ? s.headers : new Headers(s.headers));
|
|
925
|
-
let l = (await
|
|
937
|
+
let l = (await We({
|
|
926
938
|
getTokens: () => t.tokens,
|
|
927
939
|
configuration: {
|
|
928
940
|
token_automatic_renew_mode: t.configuration.token_automatic_renew_mode,
|
|
@@ -945,32 +957,32 @@ var oe = () => {
|
|
|
945
957
|
...s,
|
|
946
958
|
headers: c
|
|
947
959
|
}, ...o);
|
|
948
|
-
},
|
|
960
|
+
}, Ae = (e) => async (t = !1, n = !1) => {
|
|
949
961
|
if (e.userInfo != null && !t) return e.userInfo;
|
|
950
962
|
let r = !t && e.configuration.storage?.getItem(`oidc.${e.configurationName}.userInfo`);
|
|
951
963
|
if (r) return e.userInfo = JSON.parse(r), e.userInfo;
|
|
952
964
|
let i = e.configuration, a = (await e.initAsync(i.authority, i.authority_configuration)).userInfoEndpoint, o = await (async () => {
|
|
953
|
-
let t = await
|
|
965
|
+
let t = await ke(fetch, e, n)(a);
|
|
954
966
|
return t.status === 200 ? t.json() : null;
|
|
955
967
|
})();
|
|
956
968
|
return e.userInfo = o, o && e.configuration.storage?.setItem(`oidc.${e.configurationName}.userInfo`, JSON.stringify(o)), o;
|
|
957
|
-
},
|
|
969
|
+
}, je = () => fetch, Me = class {
|
|
958
970
|
constructor(e) {
|
|
959
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;
|
|
960
972
|
}
|
|
961
|
-
}, 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) => {
|
|
962
974
|
let { parsedTokens: t, callbackPath: n, extras: r, scope: i } = await e.loginCallbackAsync();
|
|
963
975
|
return e.timeoutId = z(e, t.expiresAt, r, i), { callbackPath: n };
|
|
964
|
-
},
|
|
965
|
-
constructor(e, t = "default", n, r = new
|
|
976
|
+
}, Fe = (e) => Math.floor(Math.random() * e), R = class t {
|
|
977
|
+
constructor(e, t = "default", n, r = new D()) {
|
|
966
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;
|
|
967
979
|
let i = e.silent_login_uri;
|
|
968
980
|
e.silent_redirect_uri && !e.silent_login_uri && (i = `${e.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
|
|
969
981
|
let a = e.refresh_time_before_tokens_expiration_in_second ?? 120;
|
|
970
|
-
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 = {
|
|
971
983
|
...e,
|
|
972
984
|
silent_login_uri: i,
|
|
973
|
-
token_automatic_renew_mode: e.token_automatic_renew_mode ??
|
|
985
|
+
token_automatic_renew_mode: e.token_automatic_renew_mode ?? I.AutomaticBeforeTokenExpiration,
|
|
974
986
|
monitor_session: e.monitor_session ?? !1,
|
|
975
987
|
refresh_time_before_tokens_expiration_in_second: a,
|
|
976
988
|
silent_login_timeout: e.silent_login_timeout ?? 12e3,
|
|
@@ -978,13 +990,13 @@ var oe = () => {
|
|
|
978
990
|
demonstrating_proof_of_possession: e.demonstrating_proof_of_possession ?? !1,
|
|
979
991
|
authority_timeout_wellknowurl_in_millisecond: e.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
980
992
|
logout_tokens_to_invalidate: e.logout_tokens_to_invalidate ?? ["access_token", "refresh_token"],
|
|
981
|
-
service_worker_activate: e.service_worker_activate ??
|
|
993
|
+
service_worker_activate: e.service_worker_activate ?? se,
|
|
982
994
|
demonstrating_proof_of_possession_configuration: e.demonstrating_proof_of_possession_configuration ?? _,
|
|
983
995
|
preload_user_info: e.preload_user_info ?? !1
|
|
984
|
-
}, 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);
|
|
985
997
|
}
|
|
986
998
|
subscribeEvents(e) {
|
|
987
|
-
let t =
|
|
999
|
+
let t = Fe(9999999999999).toString();
|
|
988
1000
|
return this.events.push({
|
|
989
1001
|
id: t,
|
|
990
1002
|
func: e
|
|
@@ -1000,7 +1012,7 @@ var oe = () => {
|
|
|
1000
1012
|
});
|
|
1001
1013
|
}
|
|
1002
1014
|
static {
|
|
1003
|
-
this.getOrCreate = (e, t) => (n, r = "default") =>
|
|
1015
|
+
this.getOrCreate = (e, t) => (n, r = "default") => Ne(e, t)(n, r);
|
|
1004
1016
|
}
|
|
1005
1017
|
static get(e = "default") {
|
|
1006
1018
|
return Object.prototype.hasOwnProperty.call(L, e) ? L[e] : null;
|
|
@@ -1016,7 +1028,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1016
1028
|
}
|
|
1017
1029
|
_silentLoginCallbackFromIFrame() {
|
|
1018
1030
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1019
|
-
let e = this.location, t =
|
|
1031
|
+
let e = this.location, t = N(e.getCurrentHref());
|
|
1020
1032
|
window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({
|
|
1021
1033
|
tokens: this.tokens,
|
|
1022
1034
|
sessionState: t.session_state
|
|
@@ -1025,7 +1037,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1025
1037
|
}
|
|
1026
1038
|
_silentLoginErrorCallbackFromIFrame(e = null) {
|
|
1027
1039
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1028
|
-
let t = this.location, n =
|
|
1040
|
+
let t = this.location, n = N(t.getCurrentHref());
|
|
1029
1041
|
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());
|
|
1030
1042
|
}
|
|
1031
1043
|
}
|
|
@@ -1039,7 +1051,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1039
1051
|
async initAsync(e, t) {
|
|
1040
1052
|
if (this.initPromise !== null) return this.initPromise;
|
|
1041
1053
|
let n = async () => {
|
|
1042
|
-
if (t != null) return new
|
|
1054
|
+
if (t != null) return new Me({
|
|
1043
1055
|
authorization_endpoint: t.authorization_endpoint,
|
|
1044
1056
|
end_session_endpoint: t.end_session_endpoint,
|
|
1045
1057
|
revocation_endpoint: t.revocation_endpoint,
|
|
@@ -1049,14 +1061,14 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1049
1061
|
issuer: t.issuer
|
|
1050
1062
|
});
|
|
1051
1063
|
let n = await $(this.configuration, this.configurationName) ? this.configuration.storage || window.sessionStorage : this.configuration.storage;
|
|
1052
|
-
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);
|
|
1053
1065
|
};
|
|
1054
1066
|
return this.initPromise = n(), this.initPromise.finally(() => {
|
|
1055
1067
|
this.initPromise = null;
|
|
1056
1068
|
});
|
|
1057
1069
|
}
|
|
1058
1070
|
async tryKeepExistingSessionAsync() {
|
|
1059
|
-
return this.tryKeepExistingSessionPromise === null ? (this.tryKeepExistingSessionPromise =
|
|
1071
|
+
return this.tryKeepExistingSessionPromise === null ? (this.tryKeepExistingSessionPromise = ce(this), this.tryKeepExistingSessionPromise.finally(() => {
|
|
1060
1072
|
this.tryKeepExistingSessionPromise = null;
|
|
1061
1073
|
})) : this.tryKeepExistingSessionPromise;
|
|
1062
1074
|
}
|
|
@@ -1064,14 +1076,14 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1064
1076
|
await d(this, L, this.configuration)(e, t, n, r);
|
|
1065
1077
|
}
|
|
1066
1078
|
async loginAsync(e = void 0, t = null, n = !1, r = void 0, i = !1) {
|
|
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 =
|
|
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(() => {
|
|
1068
1080
|
this.loginPromise = null;
|
|
1069
1081
|
})) : this.loginPromise;
|
|
1070
1082
|
}
|
|
1071
1083
|
async loginCallbackAsync(e = !1) {
|
|
1072
1084
|
if (this.loginCallbackPromise !== null) return this.loginCallbackPromise;
|
|
1073
1085
|
let n = async () => {
|
|
1074
|
-
let n = await
|
|
1086
|
+
let n = await Ce(this)(e), r = n.tokens;
|
|
1075
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(), {
|
|
1076
1088
|
parsedTokens: r,
|
|
1077
1089
|
state: n.state,
|
|
@@ -1086,34 +1098,34 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1086
1098
|
}
|
|
1087
1099
|
async generateDemonstrationOfProofOfPossessionAsync(e, t, n, r = {}) {
|
|
1088
1100
|
let a = this.configuration, o = {
|
|
1089
|
-
ath: await
|
|
1101
|
+
ath: await ne(e),
|
|
1090
1102
|
...r
|
|
1091
1103
|
};
|
|
1092
|
-
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)}`;
|
|
1093
1105
|
let s = i(this.configurationName, a.storage, a.login_state_storage ?? a.storage), c = await s.getDemonstratingProofOfPossessionJwkAsync(), l = s.getDemonstratingProofOfPossessionNonce();
|
|
1094
|
-
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);
|
|
1095
1107
|
}
|
|
1096
1108
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1097
|
-
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1109
|
+
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise = Pe(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
|
|
1098
1110
|
this.loginCallbackWithAutoTokensRenewPromise = null;
|
|
1099
1111
|
})) : this.loginCallbackWithAutoTokensRenewPromise;
|
|
1100
1112
|
}
|
|
1101
1113
|
userInfoAsync(e = !1, t = !1) {
|
|
1102
|
-
return this.userInfoPromise === null ? (this.userInfoPromise =
|
|
1114
|
+
return this.userInfoPromise === null ? (this.userInfoPromise = Ae(this)(e, t), this.userInfoPromise.finally(() => {
|
|
1103
1115
|
this.userInfoPromise = null;
|
|
1104
1116
|
})) : this.userInfoPromise;
|
|
1105
1117
|
}
|
|
1106
1118
|
async renewTokensAsync(e = null, t = null) {
|
|
1107
1119
|
if (this.renewTokensPromise !== null) return this.renewTokensPromise;
|
|
1108
|
-
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(() => {
|
|
1109
1121
|
this.renewTokensPromise = null;
|
|
1110
1122
|
});
|
|
1111
1123
|
}
|
|
1112
1124
|
async destroyAsync(e) {
|
|
1113
|
-
return await
|
|
1125
|
+
return await Ee(this)(e);
|
|
1114
1126
|
}
|
|
1115
1127
|
async clearSessionAsync() {
|
|
1116
|
-
return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise =
|
|
1128
|
+
return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise = F(this, L)(), this.clearSessionPromise.finally(() => {
|
|
1117
1129
|
this.clearSessionPromise = null;
|
|
1118
1130
|
}));
|
|
1119
1131
|
}
|
|
@@ -1130,25 +1142,25 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1130
1142
|
}));
|
|
1131
1143
|
}
|
|
1132
1144
|
async logoutAsync(e = void 0, t = null) {
|
|
1133
|
-
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(() => {
|
|
1134
1146
|
this.logoutPromise = null;
|
|
1135
1147
|
}));
|
|
1136
1148
|
}
|
|
1137
1149
|
};
|
|
1138
1150
|
//#endregion
|
|
1139
1151
|
//#region src/renewTokens.ts
|
|
1140
|
-
async function
|
|
1152
|
+
async function Ie(e, t, n, r = null) {
|
|
1141
1153
|
let { tokens: a, status: o } = await H(e)((t) => {
|
|
1142
1154
|
e.tokens = t;
|
|
1143
1155
|
}, 0, 0, t, n, r);
|
|
1144
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);
|
|
1145
1157
|
}
|
|
1146
|
-
async function
|
|
1158
|
+
async function Le(e, t = !1, n = null, r = null) {
|
|
1147
1159
|
let i = e.configuration, a = `${i.client_id}_${e.configurationName}_${i.authority}`, o, s = await $(e.configuration, e.configurationName);
|
|
1148
|
-
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);
|
|
1149
1161
|
else {
|
|
1150
1162
|
let i = "retry";
|
|
1151
|
-
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"));
|
|
1152
1164
|
o = i;
|
|
1153
1165
|
}
|
|
1154
1166
|
return o ? (e.timeoutId &&= z(e, e.tokens.expiresAt, n, r), e.tokens) : null;
|
|
@@ -1157,7 +1169,7 @@ var z = (e, t, n = null, r = null) => {
|
|
|
1157
1169
|
let i = e.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
1158
1170
|
return e.timeoutId && c.clearTimeout(e.timeoutId), c.setTimeout(async () => {
|
|
1159
1171
|
let a = { timeLeft: K(i, t) };
|
|
1160
|
-
e.publishEvent(R.eventNames.token_timer, a), await
|
|
1172
|
+
e.publishEvent(R.eventNames.token_timer, a), await Le(e, !1, n, r);
|
|
1161
1173
|
}, 1e3);
|
|
1162
1174
|
}, B = {
|
|
1163
1175
|
FORCE_REFRESH: "FORCE_REFRESH",
|
|
@@ -1294,12 +1306,12 @@ var z = (e, t, n = null, r = null) => {
|
|
|
1294
1306
|
tokens: null,
|
|
1295
1307
|
status: "LOGGED_OUT"
|
|
1296
1308
|
};
|
|
1297
|
-
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, {}), {
|
|
1298
1310
|
tokens: t.tokens,
|
|
1299
1311
|
status: "GIVE_UP"
|
|
1300
1312
|
}) : (t.publishEvent(e.refreshTokensAsync_begin, { tryNumber: r }), await _());
|
|
1301
1313
|
default: {
|
|
1302
|
-
if (h.token_automatic_renew_mode ==
|
|
1314
|
+
if (h.token_automatic_renew_mode == I.AutomaticOnlyWhenFetchExecuted && B.FORCE_REFRESH !== l) return t.publishEvent(e.tokensInvalidAndWaitingActionsToRefresh, {}), {
|
|
1303
1315
|
tokens: t.tokens,
|
|
1304
1316
|
status: "GIVE_UP"
|
|
1305
1317
|
};
|
|
@@ -1319,9 +1331,13 @@ var z = (e, t, n = null, r = null) => {
|
|
|
1319
1331
|
refresh_token: u.refreshToken
|
|
1320
1332
|
}, a = await t.initAsync(v, h.authority_configuration), l = document.hidden ? 1e4 : 3e4 * 10, _ = a.tokenEndpoint, b = {};
|
|
1321
1333
|
h.demonstrating_proof_of_possession && (b.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(u.accessToken, _, "POST"));
|
|
1322
|
-
let x = await
|
|
1334
|
+
let x = await ge(t.getFetch())(_, r, y, u, b, h.token_renew_mode, l);
|
|
1323
1335
|
if (x.success) {
|
|
1324
|
-
|
|
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);
|
|
1325
1341
|
if (!r) return n(null), t.publishEvent(e.refreshTokensAsync_error, { message: `refresh token return not valid tokens, reason: ${o}` }), {
|
|
1326
1342
|
tokens: null,
|
|
1327
1343
|
status: "SESSION_LOST"
|
|
@@ -1354,29 +1370,29 @@ var z = (e, t, n = null, r = null) => {
|
|
|
1354
1370
|
}, 1e3);
|
|
1355
1371
|
});
|
|
1356
1372
|
}
|
|
1357
|
-
},
|
|
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) => {
|
|
1358
1374
|
try {
|
|
1359
|
-
return e &&
|
|
1375
|
+
return e && Ve(e, ".") === 2 ? ze(e.split(".")[1]) : null;
|
|
1360
1376
|
} catch (e) {
|
|
1361
1377
|
console.warn(e);
|
|
1362
1378
|
}
|
|
1363
1379
|
return null;
|
|
1364
|
-
},
|
|
1380
|
+
}, Ve = (e, t) => e.split(t).length - 1, U = {
|
|
1365
1381
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
1366
1382
|
access_token_invalid: "access_token_invalid",
|
|
1367
1383
|
id_token_invalid: "id_token_invalid"
|
|
1368
1384
|
};
|
|
1369
|
-
function
|
|
1385
|
+
function He(e, t, n) {
|
|
1370
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;
|
|
1371
1387
|
}
|
|
1372
1388
|
var W = (e, t = null, n) => {
|
|
1373
1389
|
if (!e) return null;
|
|
1374
1390
|
let r, i = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
|
|
1375
|
-
r = e.accessTokenPayload === void 0 ?
|
|
1391
|
+
r = e.accessTokenPayload === void 0 ? Be(e.accessToken) : e.accessTokenPayload;
|
|
1376
1392
|
let a;
|
|
1377
1393
|
a = t != null && "idToken" in t && !("idToken" in e) ? t.idToken : e.idToken;
|
|
1378
|
-
let o = e.idTokenPayload ? e.idTokenPayload :
|
|
1379
|
-
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);
|
|
1380
1396
|
let l;
|
|
1381
1397
|
l = e.expiresAt ? e.expiresAt : n === U.access_token_invalid ? c : n === U.id_token_invalid || s < c ? s : c;
|
|
1382
1398
|
let u = {
|
|
@@ -1409,25 +1425,25 @@ var W = (e, t = null, n) => {
|
|
|
1409
1425
|
}, K = (e, t) => {
|
|
1410
1426
|
let n = t - (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
1411
1427
|
return Math.round(n - e);
|
|
1412
|
-
},
|
|
1428
|
+
}, Ue = (e, t = 0) => e ? K(t, e.expiresAt) > 0 : !1, We = async (e, t = 200, n = 50) => {
|
|
1413
1429
|
let r = n, i = await e.syncTokensInfoAsync();
|
|
1414
1430
|
for (; [
|
|
1415
1431
|
B.REQUIRE_SYNC_TOKENS,
|
|
1416
1432
|
B.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
|
|
1417
1433
|
B.TOKENS_INVALID
|
|
1418
1434
|
].includes(i) && r > 0;) {
|
|
1419
|
-
if (e.configuration.token_automatic_renew_mode ==
|
|
1435
|
+
if (e.configuration.token_automatic_renew_mode == I.AutomaticOnlyWhenFetchExecuted) {
|
|
1420
1436
|
await e.renewTokensAsync({});
|
|
1421
1437
|
break;
|
|
1422
1438
|
} else await J({ milliseconds: t });
|
|
1423
1439
|
--r, i = await e.syncTokensInfoAsync();
|
|
1424
1440
|
}
|
|
1425
1441
|
return {
|
|
1426
|
-
isTokensValid:
|
|
1442
|
+
isTokensValid: Ue(e.getTokens()),
|
|
1427
1443
|
tokens: e.getTokens(),
|
|
1428
1444
|
numberWaited: r - n
|
|
1429
1445
|
};
|
|
1430
|
-
},
|
|
1446
|
+
}, Ge = (e, t, n) => {
|
|
1431
1447
|
if (e.idTokenPayload) {
|
|
1432
1448
|
let r = e.idTokenPayload;
|
|
1433
1449
|
if (n.issuer !== r.iss) return {
|
|
@@ -1453,25 +1469,25 @@ var W = (e, t = null, n) => {
|
|
|
1453
1469
|
isValid: !0,
|
|
1454
1470
|
reason: ""
|
|
1455
1471
|
};
|
|
1456
|
-
},
|
|
1472
|
+
}, Ke = "7.27.18", qe = null, q, J = ({ milliseconds: e }) => new Promise((t) => c.setTimeout(t, e)), Je = (e = "/") => {
|
|
1457
1473
|
try {
|
|
1458
1474
|
q = new AbortController(), fetch(`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: q.signal }).catch((e) => {
|
|
1459
1475
|
console.log(e);
|
|
1460
|
-
}), J({ milliseconds: 150 * 1e3 }).then(() =>
|
|
1476
|
+
}), J({ milliseconds: 150 * 1e3 }).then(() => Je(e));
|
|
1461
1477
|
} catch (e) {
|
|
1462
1478
|
console.log(e);
|
|
1463
1479
|
}
|
|
1464
1480
|
}, Y = () => {
|
|
1465
1481
|
q && q.abort();
|
|
1466
|
-
},
|
|
1482
|
+
}, Ye = (e) => {
|
|
1467
1483
|
let t = `oidc.tabId.${e}`, n = sessionStorage.getItem(t);
|
|
1468
1484
|
if (n) return n;
|
|
1469
1485
|
let r = globalThis.crypto.randomUUID();
|
|
1470
1486
|
return sessionStorage.setItem(t, r), r;
|
|
1471
|
-
},
|
|
1487
|
+
}, Xe = (e) => navigator.serviceWorker.controller ?? e.active ?? e.waiting ?? e.installing ?? null, X = (e, t) => (n) => {
|
|
1472
1488
|
let r = t?.timeoutMs ?? 5e3;
|
|
1473
1489
|
return new Promise((t, i) => {
|
|
1474
|
-
let a =
|
|
1490
|
+
let a = Xe(e);
|
|
1475
1491
|
if (!a) {
|
|
1476
1492
|
i(/* @__PURE__ */ Error("Service worker target not available (controller/active/waiting/installing missing)"));
|
|
1477
1493
|
return;
|
|
@@ -1492,39 +1508,39 @@ var W = (e, t = null, n) => {
|
|
|
1492
1508
|
let e = n?.configurationName;
|
|
1493
1509
|
a.postMessage({
|
|
1494
1510
|
...n,
|
|
1495
|
-
tabId:
|
|
1511
|
+
tabId: Ye(e ?? "default")
|
|
1496
1512
|
}, [o.port2]);
|
|
1497
1513
|
} catch (e) {
|
|
1498
1514
|
l(), i(e);
|
|
1499
1515
|
}
|
|
1500
1516
|
});
|
|
1501
|
-
},
|
|
1517
|
+
}, Ze = async (e) => navigator.serviceWorker.controller ? navigator.serviceWorker.controller : new Promise((t) => {
|
|
1502
1518
|
let n = !1, r = () => {
|
|
1503
1519
|
n || (n = !0, navigator.serviceWorker.removeEventListener("controllerchange", r), t(navigator.serviceWorker.controller ?? null));
|
|
1504
1520
|
};
|
|
1505
1521
|
navigator.serviceWorker.addEventListener("controllerchange", r), c.setTimeout(() => {
|
|
1506
1522
|
n || (n = !0, navigator.serviceWorker.removeEventListener("controllerchange", r), t(navigator.serviceWorker.controller ?? null));
|
|
1507
1523
|
}, e);
|
|
1508
|
-
}),
|
|
1524
|
+
}), Qe = !1, Z = !1, Q = /* @__PURE__ */ new Map(), $e = "oidc.sw.controllerchange_reload_count", et = 3, tt = () => {
|
|
1509
1525
|
try {
|
|
1510
|
-
return parseInt(sessionStorage.getItem(
|
|
1526
|
+
return parseInt(sessionStorage.getItem($e) ?? "0", 10);
|
|
1511
1527
|
} catch {
|
|
1512
1528
|
return 0;
|
|
1513
1529
|
}
|
|
1514
|
-
},
|
|
1515
|
-
let e =
|
|
1530
|
+
}, nt = () => {
|
|
1531
|
+
let e = tt() + 1;
|
|
1516
1532
|
try {
|
|
1517
|
-
sessionStorage.setItem(
|
|
1533
|
+
sessionStorage.setItem($e, String(e));
|
|
1518
1534
|
} catch {}
|
|
1519
1535
|
return e;
|
|
1520
|
-
},
|
|
1536
|
+
}, rt = () => {
|
|
1521
1537
|
try {
|
|
1522
|
-
sessionStorage.removeItem(
|
|
1538
|
+
sessionStorage.removeItem($e);
|
|
1523
1539
|
} catch {}
|
|
1524
1540
|
}, $ = async (e, t) => {
|
|
1525
1541
|
let n = e.service_worker_relative_url;
|
|
1526
1542
|
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !n || e.service_worker_activate() === !1) return null;
|
|
1527
|
-
let r = `${n}?v=${
|
|
1543
|
+
let r = `${n}?v=${Ke}`, i = null;
|
|
1528
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));
|
|
1529
1545
|
let a = `oidc.sw.version_mismatch_reload.${t}`, o = async (e) => {
|
|
1530
1546
|
Y(), console.log("New SW waiting – SKIP_WAITING");
|
|
@@ -1547,7 +1563,7 @@ var W = (e, t = null, n) => {
|
|
|
1547
1563
|
type: "SKIP_WAITING",
|
|
1548
1564
|
configurationName: t,
|
|
1549
1565
|
data: null,
|
|
1550
|
-
tabId:
|
|
1566
|
+
tabId: Ye(t ?? "default")
|
|
1551
1567
|
}, [i.port2]);
|
|
1552
1568
|
} catch (e) {
|
|
1553
1569
|
o(), r(e);
|
|
@@ -1562,7 +1578,7 @@ var W = (e, t = null, n) => {
|
|
|
1562
1578
|
}, l = (e) => {
|
|
1563
1579
|
Y(), e.addEventListener("statechange", async () => {
|
|
1564
1580
|
if (e.state === "installed" && navigator.serviceWorker.controller) {
|
|
1565
|
-
if (
|
|
1581
|
+
if (tt() >= et) {
|
|
1566
1582
|
console.warn("SW trackInstallingWorker: skipping SKIP_WAITING because the reload budget is exhausted");
|
|
1567
1583
|
return;
|
|
1568
1584
|
}
|
|
@@ -1573,7 +1589,7 @@ var W = (e, t = null, n) => {
|
|
|
1573
1589
|
i.addEventListener("updatefound", () => {
|
|
1574
1590
|
let e = i.installing;
|
|
1575
1591
|
e && l(e);
|
|
1576
|
-
}), 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) => {
|
|
1577
1593
|
console.error(e);
|
|
1578
1594
|
});
|
|
1579
1595
|
try {
|
|
@@ -1581,14 +1597,14 @@ var W = (e, t = null, n) => {
|
|
|
1581
1597
|
type: "claim",
|
|
1582
1598
|
configurationName: t,
|
|
1583
1599
|
data: null
|
|
1584
|
-
}), await
|
|
1600
|
+
}), await Ze(2e3));
|
|
1585
1601
|
} catch (e) {
|
|
1586
1602
|
return console.warn(`Failed init ServiceWorker ${e?.toString?.() ?? String(e)}`), null;
|
|
1587
1603
|
}
|
|
1588
|
-
|
|
1604
|
+
Qe || (Qe = !0, navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
1589
1605
|
if (Z) return;
|
|
1590
|
-
let e =
|
|
1591
|
-
if (e >
|
|
1606
|
+
let e = nt();
|
|
1607
|
+
if (e > et) {
|
|
1592
1608
|
console.warn(`SW controllerchange: reload budget exhausted (${e - 1} reloads). Skipping reload to avoid infinite loop.`);
|
|
1593
1609
|
return;
|
|
1594
1610
|
}
|
|
@@ -1611,8 +1627,8 @@ var W = (e, t = null, n) => {
|
|
|
1611
1627
|
},
|
|
1612
1628
|
configurationName: t
|
|
1613
1629
|
}), c = o.version;
|
|
1614
|
-
if (c !== "7.27.
|
|
1615
|
-
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`);
|
|
1616
1632
|
let e = parseInt(sessionStorage.getItem(a) ?? "0", 10);
|
|
1617
1633
|
if (e < 3) {
|
|
1618
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(() => {});
|
|
@@ -1627,13 +1643,13 @@ var W = (e, t = null, n) => {
|
|
|
1627
1643
|
return console.log(`Service worker unregistering ${e}`), await J({ milliseconds: 500 }), Z || (Z = !0, window.location.reload()), new Promise(() => {});
|
|
1628
1644
|
}
|
|
1629
1645
|
} else console.error(`Service worker version mismatch persists after ${e} attempt(s). Continuing with mismatched version.`);
|
|
1630
|
-
} else sessionStorage.removeItem(a),
|
|
1646
|
+
} else sessionStorage.removeItem(a), rt();
|
|
1631
1647
|
return {
|
|
1632
1648
|
tokens: G(o.tokens, null, r.token_renew_mode),
|
|
1633
1649
|
status: o.status
|
|
1634
1650
|
};
|
|
1635
1651
|
}, f = (e = "/") => {
|
|
1636
|
-
|
|
1652
|
+
qe ?? (qe = "not_null", Je(e));
|
|
1637
1653
|
}, p = (e) => X(i)({
|
|
1638
1654
|
type: "setSessionState",
|
|
1639
1655
|
data: { sessionState: e },
|
|
@@ -1679,39 +1695,39 @@ var W = (e, t = null, n) => {
|
|
|
1679
1695
|
type: "getDemonstratingProofOfPossessionNonce",
|
|
1680
1696
|
data: null,
|
|
1681
1697
|
configurationName: t
|
|
1682
|
-
})).demonstratingProofOfPossessionNonce,
|
|
1698
|
+
})).demonstratingProofOfPossessionNonce, ee = async (e) => {
|
|
1683
1699
|
let n = JSON.stringify(e);
|
|
1684
1700
|
await X(i)({
|
|
1685
1701
|
type: "setDemonstratingProofOfPossessionJwk",
|
|
1686
1702
|
data: { demonstratingProofOfPossessionJwkJson: n },
|
|
1687
1703
|
configurationName: t
|
|
1688
1704
|
});
|
|
1689
|
-
},
|
|
1705
|
+
}, S = async () => {
|
|
1690
1706
|
let e = await X(i)({
|
|
1691
1707
|
type: "getDemonstratingProofOfPossessionJwk",
|
|
1692
1708
|
data: null,
|
|
1693
1709
|
configurationName: t
|
|
1694
1710
|
});
|
|
1695
1711
|
return e.demonstratingProofOfPossessionJwkJson ? JSON.parse(e.demonstratingProofOfPossessionJwkJson) : null;
|
|
1696
|
-
},
|
|
1712
|
+
}, C = async (e = !0) => {
|
|
1697
1713
|
let n = (await X(i)({
|
|
1698
1714
|
type: "getState",
|
|
1699
1715
|
data: null,
|
|
1700
1716
|
configurationName: t
|
|
1701
1717
|
})).state;
|
|
1702
|
-
return n || (n = sessionStorage[`oidc.state.${t}`], console.warn("state not found in service worker, using sessionStorage"), e && (await
|
|
1703
|
-
},
|
|
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)({
|
|
1704
1720
|
type: "setState",
|
|
1705
1721
|
data: { state: e },
|
|
1706
1722
|
configurationName: t
|
|
1707
|
-
})),
|
|
1723
|
+
})), T = async (e = !0) => {
|
|
1708
1724
|
let n = (await X(i)({
|
|
1709
1725
|
type: "getCodeVerifier",
|
|
1710
1726
|
data: null,
|
|
1711
1727
|
configurationName: t
|
|
1712
1728
|
})).codeVerifier;
|
|
1713
|
-
return n || (n = sessionStorage[`oidc.code_verifier.${t}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), e && (await
|
|
1714
|
-
},
|
|
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)({
|
|
1715
1731
|
type: "setCodeVerifier",
|
|
1716
1732
|
data: { codeVerifier: e },
|
|
1717
1733
|
configurationName: t
|
|
@@ -1726,24 +1742,24 @@ var W = (e, t = null, n) => {
|
|
|
1726
1742
|
getNonceAsync: g,
|
|
1727
1743
|
setLoginParams: v,
|
|
1728
1744
|
getLoginParams: y,
|
|
1729
|
-
getStateAsync:
|
|
1730
|
-
setStateAsync:
|
|
1731
|
-
getCodeVerifierAsync:
|
|
1732
|
-
setCodeVerifierAsync:
|
|
1745
|
+
getStateAsync: C,
|
|
1746
|
+
setStateAsync: w,
|
|
1747
|
+
getCodeVerifierAsync: T,
|
|
1748
|
+
setCodeVerifierAsync: E,
|
|
1733
1749
|
setDemonstratingProofOfPossessionNonce: b,
|
|
1734
1750
|
getDemonstratingProofOfPossessionNonce: x,
|
|
1735
|
-
setDemonstratingProofOfPossessionJwkAsync:
|
|
1736
|
-
getDemonstratingProofOfPossessionJwkAsync:
|
|
1751
|
+
setDemonstratingProofOfPossessionJwkAsync: ee,
|
|
1752
|
+
getDemonstratingProofOfPossessionJwkAsync: S,
|
|
1737
1753
|
signalAsync: (e, n) => X(i, n)({
|
|
1738
1754
|
...e,
|
|
1739
1755
|
configurationName: e.configurationName ?? t
|
|
1740
1756
|
})
|
|
1741
1757
|
};
|
|
1742
|
-
},
|
|
1758
|
+
}, it = async (e, t, n, r) => {
|
|
1743
1759
|
let i = await $(e, t);
|
|
1744
1760
|
if (!i) throw Error(`signalServiceWorkerAsync: no service worker registered for configuration "${t}"`);
|
|
1745
1761
|
return i.signalAsync(n, r);
|
|
1746
|
-
},
|
|
1762
|
+
}, at = class e {
|
|
1747
1763
|
constructor(e) {
|
|
1748
1764
|
this._oidc = e;
|
|
1749
1765
|
}
|
|
@@ -1757,7 +1773,7 @@ var W = (e, t = null, n) => {
|
|
|
1757
1773
|
this._oidc.publishEvent(e, t);
|
|
1758
1774
|
}
|
|
1759
1775
|
static {
|
|
1760
|
-
this.getOrCreate = (t, n = new
|
|
1776
|
+
this.getOrCreate = (t, n = new D()) => (r, i = "default") => new e(R.getOrCreate(t, n)(r, i));
|
|
1761
1777
|
}
|
|
1762
1778
|
static get(t = "default") {
|
|
1763
1779
|
let n = R.get(t);
|
|
@@ -1804,7 +1820,7 @@ var W = (e, t = null, n) => {
|
|
|
1804
1820
|
}
|
|
1805
1821
|
async getValidTokenAsync(e = 200, t = 50) {
|
|
1806
1822
|
let n = this._oidc;
|
|
1807
|
-
return
|
|
1823
|
+
return We({
|
|
1808
1824
|
getTokens: () => n.tokens,
|
|
1809
1825
|
configuration: {
|
|
1810
1826
|
token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
|
|
@@ -1818,7 +1834,7 @@ var W = (e, t = null, n) => {
|
|
|
1818
1834
|
}, e, t);
|
|
1819
1835
|
}
|
|
1820
1836
|
fetchWithTokens(e, t = !1) {
|
|
1821
|
-
return
|
|
1837
|
+
return ke(e, this._oidc, t);
|
|
1822
1838
|
}
|
|
1823
1839
|
async userInfoAsync(e = !1, t = !1) {
|
|
1824
1840
|
return this._oidc.userInfoAsync(e, t);
|
|
@@ -1827,9 +1843,9 @@ var W = (e, t = null, n) => {
|
|
|
1827
1843
|
return this._oidc.userInfo;
|
|
1828
1844
|
}
|
|
1829
1845
|
async signalServiceWorker(e, t) {
|
|
1830
|
-
return
|
|
1846
|
+
return it(this._oidc.configuration, this._oidc.configurationName, e, t);
|
|
1831
1847
|
}
|
|
1832
|
-
},
|
|
1848
|
+
}, ot = "1.0.0", st = {
|
|
1833
1849
|
SKIP_WAITING: "SKIP_WAITING",
|
|
1834
1850
|
CLAIM: "claim",
|
|
1835
1851
|
CLEAR: "clear",
|
|
@@ -1846,18 +1862,18 @@ var W = (e, t = null, n) => {
|
|
|
1846
1862
|
GET_DPOP_NONCE: "getDemonstratingProofOfPossessionNonce",
|
|
1847
1863
|
SET_DPOP_JWK: "setDemonstratingProofOfPossessionJwk",
|
|
1848
1864
|
GET_DPOP_JWK: "getDemonstratingProofOfPossessionJwk"
|
|
1849
|
-
},
|
|
1865
|
+
}, ct = {
|
|
1850
1866
|
ACCESS_TOKEN: "ACCESS_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
1851
1867
|
REFRESH_TOKEN: "REFRESH_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
1852
1868
|
NONCE_TOKEN: "NONCE_SECURED_BY_OIDC_SERVICE_WORKER",
|
|
1853
1869
|
CODE_VERIFIER: "CODE_VERIFIER_SECURED_BY_OIDC_SERVICE_WORKER"
|
|
1854
|
-
},
|
|
1870
|
+
}, lt = "DPOP_SECURED_BY_OIDC_SERVICE_WORKER", ut = {
|
|
1855
1871
|
TAB_ID: "oidc.tabId.",
|
|
1856
1872
|
STATE: "oidc.state.",
|
|
1857
1873
|
NONCE: "oidc.nonce.",
|
|
1858
1874
|
CODE_VERIFIER: "oidc.code_verifier.",
|
|
1859
1875
|
LOGIN_PARAMS: "oidc.login.",
|
|
1860
1876
|
SW_VERSION_MISMATCH_RELOAD: "oidc.sw.version_mismatch_reload."
|
|
1861
|
-
},
|
|
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;
|
|
1862
1878
|
//#endregion
|
|
1863
|
-
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 };
|