@axa-fr/oidc-client 7.30.2 → 7.30.4
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 +20 -1
- package/dist/index.js +339 -334
- package/dist/index.umd.cjs +2 -2
- package/dist/initWorker.d.ts.map +1 -1
- package/dist/initWorkerUpdates.spec.d.ts +2 -0
- package/dist/initWorkerUpdates.spec.d.ts.map +1 -0
- package/dist/keepSession.d.ts.map +1 -1
- package/dist/node_modules/@axa-fr/oidc-client-service-worker/dist/OidcServiceWorker.js +18 -35
- package/dist/version.d.ts +1 -1
- package/package.json +7 -7
- package/src/initWorker.ts +27 -11
- package/src/initWorkerUpdates.spec.ts +136 -0
- package/src/keepSession.spec.ts +98 -0
- package/src/keepSession.ts +24 -2
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/oidcError.ts
|
|
2
2
|
var e = {
|
|
3
3
|
INVALID_RESOURCE: "INVALID_RESOURCE",
|
|
4
4
|
INVALID_TARGET: "INVALID_TARGET",
|
|
@@ -296,7 +296,7 @@ var e = {
|
|
|
296
296
|
phase: "login",
|
|
297
297
|
retryable: !1
|
|
298
298
|
});
|
|
299
|
-
return o.timeoutId && b.clearTimeout(o.timeoutId), o.tokens = u.tokens, a(f.token_acquired, {}), o.timeoutId =
|
|
299
|
+
return o.timeoutId && b.clearTimeout(o.timeoutId), o.tokens = u.tokens, a(f.token_acquired, {}), o.timeoutId = Tt(o, o.tokens.expiresAt, t, s), {};
|
|
300
300
|
}
|
|
301
301
|
})().catch((e) => e);
|
|
302
302
|
}, C = (e, t, n) => (r, i, a, o = !1) => {
|
|
@@ -329,8 +329,7 @@ var e = {
|
|
|
329
329
|
})) : c(null);
|
|
330
330
|
});
|
|
331
331
|
};
|
|
332
|
-
|
|
333
|
-
//#region src/jwt.ts
|
|
332
|
+
// src/jwt.ts
|
|
334
333
|
function w(e) {
|
|
335
334
|
return new TextEncoder().encode(e);
|
|
336
335
|
}
|
|
@@ -414,7 +413,7 @@ var O = {
|
|
|
414
413
|
}
|
|
415
414
|
let i = await e.crypto.subtle.digest(n, w(r));
|
|
416
415
|
return D(new Uint8Array(i));
|
|
417
|
-
} }, te = (e) => async (t) => await A.generate(e)(t),
|
|
416
|
+
} }, te = (e) => async (t) => await A.generate(e)(t), M = (e) => (t) => async (n, r = "POST", i, a = {}) => {
|
|
418
417
|
let o = new URL(i, e.location?.href);
|
|
419
418
|
o.search = "", o.hash = "";
|
|
420
419
|
let s = {
|
|
@@ -425,39 +424,39 @@ var O = {
|
|
|
425
424
|
...a
|
|
426
425
|
}, c = await j.thumbprint(e)(n, t.digestAlgorithm);
|
|
427
426
|
return await k.sign(e)(n, { kid: c }, s, t);
|
|
428
|
-
},
|
|
429
|
-
let e =
|
|
427
|
+
}, N = () => typeof globalThis < "u" ? globalThis.crypto : void 0, ne = () => {
|
|
428
|
+
let e = N();
|
|
430
429
|
return {
|
|
431
430
|
hasCrypto: !!e,
|
|
432
431
|
hasSubtleCrypto: !!e?.subtle
|
|
433
432
|
};
|
|
434
|
-
},
|
|
433
|
+
}, re = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", ie = (e) => {
|
|
435
434
|
let t = [];
|
|
436
435
|
for (let n = 0; n < e.byteLength; n += 1) {
|
|
437
436
|
let r = e[n] % 62;
|
|
438
|
-
t.push(
|
|
437
|
+
t.push(re[r]);
|
|
439
438
|
}
|
|
440
439
|
return t.join("");
|
|
441
|
-
},
|
|
442
|
-
let t = new Uint8Array(e), n =
|
|
440
|
+
}, ae = (e) => {
|
|
441
|
+
let t = new Uint8Array(e), n = N();
|
|
443
442
|
if (!n?.getRandomValues) throw Error("Web Crypto API is unavailable; secure random values cannot be generated.");
|
|
444
|
-
return n.getRandomValues(t),
|
|
443
|
+
return n.getRandomValues(t), ie(t);
|
|
445
444
|
};
|
|
446
|
-
function
|
|
445
|
+
function oe(e) {
|
|
447
446
|
let t = new ArrayBuffer(e.length), n = new Uint8Array(t);
|
|
448
447
|
for (let t = 0; t < e.length; t++) n[t] = e.charCodeAt(t);
|
|
449
448
|
return n;
|
|
450
449
|
}
|
|
451
|
-
function
|
|
450
|
+
function se(e) {
|
|
452
451
|
return new Promise((t, n) => {
|
|
453
|
-
crypto.subtle.digest("SHA-256",
|
|
452
|
+
crypto.subtle.digest("SHA-256", oe(e)).then((e) => t(D(new Uint8Array(e))), (e) => n(e));
|
|
454
453
|
});
|
|
455
454
|
}
|
|
456
|
-
var
|
|
455
|
+
var ce = (e) => {
|
|
457
456
|
if (e.length < 43 || e.length > 128) return Promise.reject(/* @__PURE__ */ Error("Invalid code length."));
|
|
458
|
-
let { hasSubtleCrypto: t } =
|
|
459
|
-
return t ?
|
|
460
|
-
},
|
|
457
|
+
let { hasSubtleCrypto: t } = ne();
|
|
458
|
+
return t ? se(e) : Promise.reject(/* @__PURE__ */ Error("window.crypto.subtle is unavailable."));
|
|
459
|
+
}, le = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), ue = (e) => {
|
|
461
460
|
let t = e.appVersion, n = e.userAgent, r = "-", i = [
|
|
462
461
|
{
|
|
463
462
|
s: "Windows 10",
|
|
@@ -593,7 +592,7 @@ var ue = (e) => {
|
|
|
593
592
|
osVersion: a
|
|
594
593
|
};
|
|
595
594
|
};
|
|
596
|
-
function
|
|
595
|
+
function de() {
|
|
597
596
|
let e = navigator.userAgent, t, n = e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
598
597
|
if (/trident/i.test(n[1])) return t = /\brv[ :]+(\d+)/g.exec(e) || [], {
|
|
599
598
|
name: "ie",
|
|
@@ -619,10 +618,13 @@ function pe() {
|
|
|
619
618
|
version: n[1]
|
|
620
619
|
};
|
|
621
620
|
}
|
|
622
|
-
var
|
|
623
|
-
let { name: e, version: t } =
|
|
624
|
-
return e === "chrome" && parseInt(t) <= 70 || e === "opera" && (!t || parseInt(t.split(".")[0]) < 80) || e === "ie" ? !1 : !
|
|
625
|
-
},
|
|
621
|
+
var fe = () => {
|
|
622
|
+
let { name: e, version: t } = de();
|
|
623
|
+
return e === "chrome" && parseInt(t) <= 70 || e === "opera" && (!t || parseInt(t.split(".")[0]) < 80) || e === "ie" ? !1 : !le(ue(navigator));
|
|
624
|
+
}, pe = async (e, t) => X(e.tokens) || X(await wt(e, !0, t?.extras, t?.scope)) ? !0 : (e.tokens = null, e.userInfo = null, e.publishEvent(f.tryKeepExistingSessionAsync_end, {
|
|
625
|
+
success: !1,
|
|
626
|
+
message: "stored tokens could not be renewed"
|
|
627
|
+
}), !1), me = async (e) => {
|
|
626
628
|
let t;
|
|
627
629
|
if (e.tokens != null) return !1;
|
|
628
630
|
e.publishEvent(f.tryKeepExistingSessionAsync_begin, {});
|
|
@@ -633,7 +635,8 @@ var me = () => {
|
|
|
633
635
|
if (i) {
|
|
634
636
|
t.startKeepAliveServiceWorker(), e.tokens = i;
|
|
635
637
|
let a = t.getLoginParams(e.configurationName);
|
|
636
|
-
|
|
638
|
+
if (!await pe(e, a)) return !1;
|
|
639
|
+
e.timeoutId = Tt(e, e.tokens.expiresAt, a?.extras, a?.scope);
|
|
637
640
|
let o = await t.getSessionStateAsync();
|
|
638
641
|
return await e.startCheckSessionAsync(r.checkSessionIframe, n.client_id, o), n.preload_user_info && await e.userInfoAsync(), e.publishEvent(f.tryKeepExistingSessionAsync_end, {
|
|
639
642
|
success: !0,
|
|
@@ -648,9 +651,10 @@ var me = () => {
|
|
|
648
651
|
n.service_worker_relative_url && e.publishEvent(f.service_worker_not_supported_by_browser, { message: "service worker is not supported by this browser" });
|
|
649
652
|
let t = g(e.configurationName, n.storage ?? sessionStorage, n.login_state_storage ?? n.storage ?? sessionStorage), { tokens: i } = await t.initAsync();
|
|
650
653
|
if (i) {
|
|
651
|
-
e.tokens =
|
|
654
|
+
e.tokens = Nt(i, null, n.token_renew_mode);
|
|
652
655
|
let a = t.getLoginParams();
|
|
653
|
-
|
|
656
|
+
if (!await pe(e, a)) return !1;
|
|
657
|
+
e.timeoutId = Tt(e, e.tokens.expiresAt, a?.extras, a?.scope);
|
|
654
658
|
let o = await t.getSessionStateAsync();
|
|
655
659
|
return await e.startCheckSessionAsync(r.checkSessionIframe, n.client_id, o), n.preload_user_info && await e.userInfoAsync(), e.publishEvent(f.tryKeepExistingSessionAsync_end, {
|
|
656
660
|
success: !0,
|
|
@@ -665,7 +669,7 @@ var me = () => {
|
|
|
665
669
|
} catch (n) {
|
|
666
670
|
return e.tokens = null, e.userInfo = null, b.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame?.stop(), console.error(n), t && await t.clearAsync(), e.publishEvent(f.tryKeepExistingSessionAsync_error, "tokens inside ServiceWorker are invalid"), !1;
|
|
667
671
|
}
|
|
668
|
-
},
|
|
672
|
+
}, he = class {
|
|
669
673
|
open(e) {
|
|
670
674
|
window.location.href = e;
|
|
671
675
|
}
|
|
@@ -682,22 +686,22 @@ var me = () => {
|
|
|
682
686
|
getOrigin() {
|
|
683
687
|
return window.origin;
|
|
684
688
|
}
|
|
685
|
-
},
|
|
689
|
+
}, P = {
|
|
686
690
|
STATE_MISSING: "STATE_MISSING",
|
|
687
691
|
STATE_MISMATCH: "STATE_MISMATCH",
|
|
688
692
|
NONCE_MISSING: "NONCE_MISSING"
|
|
689
|
-
}, ge = new Set(Object.values(
|
|
693
|
+
}, ge = new Set(Object.values(P)), _e = (e) => typeof e == "string" && ge.has(e), F = class e extends r {
|
|
690
694
|
constructor(t, n, r = "callback") {
|
|
691
695
|
super(t, n, {
|
|
692
696
|
phase: r,
|
|
693
697
|
retryable: !1
|
|
694
698
|
}), this.name = "OidcStateError", Object.setPrototypeOf(this, e.prototype);
|
|
695
699
|
}
|
|
696
|
-
}, ve = (e) => e instanceof
|
|
700
|
+
}, ve = (e) => e instanceof F || i(e) && _e(e.code), I = {
|
|
697
701
|
ENDPOINT_UNAVAILABLE: "ENDPOINT_UNAVAILABLE",
|
|
698
702
|
REQUEST_FAILED: "REQUEST_FAILED",
|
|
699
703
|
INVALID_RESPONSE: "INVALID_RESPONSE"
|
|
700
|
-
},
|
|
704
|
+
}, L = class e extends r {
|
|
701
705
|
constructor(t, n, r = {}) {
|
|
702
706
|
super(t, n, {
|
|
703
707
|
phase: "login",
|
|
@@ -708,7 +712,7 @@ var me = () => {
|
|
|
708
712
|
cause: r.cause
|
|
709
713
|
}), this.name = "PushedAuthorizationRequestError", Object.setPrototypeOf(this, e.prototype);
|
|
710
714
|
}
|
|
711
|
-
}, ye = (e) => e instanceof
|
|
715
|
+
}, ye = (e) => e instanceof L, be = {}, xe = (e, t = window.sessionStorage, n) => {
|
|
712
716
|
if (!be[e] && t) {
|
|
713
717
|
let n = t.getItem(e);
|
|
714
718
|
n && (be[e] = JSON.parse(n));
|
|
@@ -723,12 +727,12 @@ var me = () => {
|
|
|
723
727
|
be[e] = r, n && n.setItem(e, JSON.stringify(r));
|
|
724
728
|
}, Ce = 3600, we = (e) => async (t, n = Ce, r = window.sessionStorage, i = 1e4) => {
|
|
725
729
|
let a = `${t}/.well-known/openid-configuration`, o = `oidc.server:${t}`, s = xe(o, r, n);
|
|
726
|
-
if (s) return new
|
|
727
|
-
let c = await
|
|
730
|
+
if (s) return new vt(s);
|
|
731
|
+
let c = await R(e)(a, {}, i);
|
|
728
732
|
if (c.status !== 200) return null;
|
|
729
733
|
let l = await c.json();
|
|
730
|
-
return Se(o, l, r), new
|
|
731
|
-
},
|
|
734
|
+
return Se(o, l, r), new vt(l);
|
|
735
|
+
}, R = (e) => async (t, n = {}, r = 1e4, i = 0) => {
|
|
732
736
|
let a;
|
|
733
737
|
try {
|
|
734
738
|
let i = new AbortController(), o = setTimeout(() => i.abort(), r);
|
|
@@ -742,13 +746,13 @@ var me = () => {
|
|
|
742
746
|
}
|
|
743
747
|
} catch (a) {
|
|
744
748
|
if (a.name === "AbortError" || a.message === "Network request failed") {
|
|
745
|
-
if (i <= 1) return await
|
|
749
|
+
if (i <= 1) return await R(e)(t, n, r, i + 1);
|
|
746
750
|
throw a;
|
|
747
751
|
}
|
|
748
752
|
throw console.error(a.message), a;
|
|
749
753
|
}
|
|
750
754
|
return a;
|
|
751
|
-
},
|
|
755
|
+
}, z = {
|
|
752
756
|
refresh_token: "refresh_token",
|
|
753
757
|
access_token: "access_token"
|
|
754
758
|
}, Te = (e) => {
|
|
@@ -758,14 +762,14 @@ var me = () => {
|
|
|
758
762
|
for (let e of i) t.push(`${encodeURIComponent(n)}=${encodeURIComponent(e)}`);
|
|
759
763
|
}
|
|
760
764
|
return t.join("&");
|
|
761
|
-
}, Ee = (e) => async (t, n, r =
|
|
765
|
+
}, Ee = (e) => async (t, n, r = z.refresh_token, i, a = {}, o = 1e4) => {
|
|
762
766
|
let s = {
|
|
763
767
|
token: n,
|
|
764
768
|
token_type_hint: r,
|
|
765
769
|
client_id: i
|
|
766
770
|
};
|
|
767
771
|
for (let [e, t] of Object.entries(a)) s[e] === void 0 && (s[e] = t);
|
|
768
|
-
let c = Te(s), l = await
|
|
772
|
+
let c = Te(s), l = await R(e)(t, {
|
|
769
773
|
method: "POST",
|
|
770
774
|
headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
|
|
771
775
|
body: c
|
|
@@ -790,34 +794,34 @@ var me = () => {
|
|
|
790
794
|
return null;
|
|
791
795
|
}
|
|
792
796
|
}, Oe = (e) => async (t, n, r = 1e4) => {
|
|
793
|
-
if (n.request_uri !== void 0) throw new I
|
|
797
|
+
if (n.request_uri !== void 0) throw new L(I.REQUEST_FAILED, "The request_uri parameter must not be included in a pushed authorization request.");
|
|
794
798
|
let i = Te(n), a;
|
|
795
799
|
try {
|
|
796
|
-
a = await
|
|
800
|
+
a = await R(e)(t, {
|
|
797
801
|
method: "POST",
|
|
798
802
|
headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
|
|
799
803
|
body: i
|
|
800
804
|
}, r);
|
|
801
805
|
} catch (e) {
|
|
802
|
-
throw new I
|
|
806
|
+
throw new L(I.REQUEST_FAILED, "The pushed authorization request could not be sent.", { cause: e });
|
|
803
807
|
}
|
|
804
808
|
let o = await De(a);
|
|
805
809
|
if (a.status !== 201) {
|
|
806
810
|
let e = typeof o?.error == "string" ? o.error : void 0, t = typeof o?.error_description == "string" ? o.error_description : void 0, n = [e, t].filter(Boolean).join(": ");
|
|
807
|
-
throw new I
|
|
811
|
+
throw new L(I.REQUEST_FAILED, `The pushed authorization request failed with HTTP status ${a.status}${n ? ` (${n})` : ""}.`, {
|
|
808
812
|
status: a.status,
|
|
809
813
|
oauthError: e,
|
|
810
814
|
oauthErrorDescription: t
|
|
811
815
|
});
|
|
812
816
|
}
|
|
813
|
-
if (typeof o?.request_uri != "string" || o.request_uri.length === 0 || !Number.isInteger(o?.expires_in) || o.expires_in <= 0) throw new I
|
|
817
|
+
if (typeof o?.request_uri != "string" || o.request_uri.length === 0 || !Number.isInteger(o?.expires_in) || o.expires_in <= 0) throw new L(I.INVALID_RESPONSE, "The pushed authorization response must contain a non-empty request_uri and a positive integer expires_in.", { status: a.status });
|
|
814
818
|
return {
|
|
815
819
|
request_uri: o.request_uri,
|
|
816
820
|
expires_in: o.expires_in
|
|
817
821
|
};
|
|
818
822
|
}, ke = (e) => async (t, n, r, i, a = {}, o, s = 1e4) => {
|
|
819
823
|
for (let [e, t] of Object.entries(r)) n[e] === void 0 && (n[e] = t);
|
|
820
|
-
let c = Te(n), l = await
|
|
824
|
+
let c = Te(n), l = await R(e)(t, {
|
|
821
825
|
method: "POST",
|
|
822
826
|
headers: {
|
|
823
827
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
@@ -833,19 +837,19 @@ var me = () => {
|
|
|
833
837
|
data: e,
|
|
834
838
|
oauthError: typeof e?.error == "string" ? e.error : void 0,
|
|
835
839
|
oauthErrorDescription: typeof e?.error_description == "string" ? e.error_description : void 0,
|
|
836
|
-
demonstratingProofOfPossessionNonce: l.headers?.has(
|
|
840
|
+
demonstratingProofOfPossessionNonce: l.headers?.has(B) ? l.headers.get(B) : null
|
|
837
841
|
};
|
|
838
842
|
}
|
|
839
843
|
let u = await l.json(), d = null;
|
|
840
|
-
return l.headers.has(
|
|
844
|
+
return l.headers.has(B) && (d = l.headers.get(B)), {
|
|
841
845
|
success: !0,
|
|
842
846
|
status: l.status,
|
|
843
|
-
data:
|
|
847
|
+
data: Pt(u, i, o),
|
|
844
848
|
demonstratingProofOfPossessionNonce: d
|
|
845
849
|
};
|
|
846
850
|
}, Ae = (e, t) => async (n, r, i) => {
|
|
847
851
|
r = r ? { ...r } : {};
|
|
848
|
-
let a =
|
|
852
|
+
let a = ae(128), o = await ce(a);
|
|
849
853
|
if (await e.setCodeVerifierAsync(a), await e.setStateAsync(r.state), r.code_challenge = o, r.code_challenge_method = "S256", i) {
|
|
850
854
|
let e = await Oe(i.fetch)(i.endpoint, r, i.timeoutMs);
|
|
851
855
|
t.open(`${n}?client_id=${encodeURIComponent(String(r.client_id))}&request_uri=${encodeURIComponent(e.request_uri)}`);
|
|
@@ -854,9 +858,9 @@ var me = () => {
|
|
|
854
858
|
let s = "";
|
|
855
859
|
if (r) for (let [e, t] of Object.entries(r)) for (let n of Array.isArray(t) ? t : [String(t)]) s += s === "" ? "?" : "&", s += `${e}=${encodeURIComponent(n)}`;
|
|
856
860
|
t.open(`${n}${s}`);
|
|
857
|
-
},
|
|
861
|
+
}, B = "DPoP-Nonce", je = (e) => async (t, n, r, i, a = 1e4, o = !1) => {
|
|
858
862
|
n = n ? { ...n } : {}, n.code_verifier = await e.getCodeVerifierAsync();
|
|
859
|
-
let s = Te(n), c = await
|
|
863
|
+
let s = Te(n), c = await R(fetch)(t, {
|
|
860
864
|
method: "POST",
|
|
861
865
|
headers: {
|
|
862
866
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
@@ -872,18 +876,18 @@ var me = () => {
|
|
|
872
876
|
data: t,
|
|
873
877
|
oauthError: n,
|
|
874
878
|
oauthErrorDescription: typeof t?.error_description == "string" ? t.error_description : void 0,
|
|
875
|
-
demonstratingProofOfPossessionNonce: c.headers?.has(
|
|
879
|
+
demonstratingProofOfPossessionNonce: c.headers?.has(B) ? c.headers.get(B) : null
|
|
876
880
|
};
|
|
877
881
|
}
|
|
878
882
|
await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]);
|
|
879
883
|
let l = null;
|
|
880
|
-
c.headers.has(
|
|
884
|
+
c.headers.has(B) && (l = c.headers.get(B));
|
|
881
885
|
let u = await c.json();
|
|
882
886
|
return {
|
|
883
887
|
success: !0,
|
|
884
888
|
data: {
|
|
885
889
|
state: n.state,
|
|
886
|
-
tokens:
|
|
890
|
+
tokens: Pt(u, null, i),
|
|
887
891
|
demonstratingProofOfPossessionNonce: l
|
|
888
892
|
}
|
|
889
893
|
};
|
|
@@ -910,7 +914,7 @@ var me = () => {
|
|
|
910
914
|
let t = Le(e), r = t.pathname.replace(/\/+$/, "");
|
|
911
915
|
return n.origin === t.origin && (r === "" || n.pathname === r || n.pathname.startsWith(`${r}/`));
|
|
912
916
|
});
|
|
913
|
-
},
|
|
917
|
+
}, V = (e, t) => {
|
|
914
918
|
Fe(t);
|
|
915
919
|
let n = e?.filter((e) => e.resource === t) ?? [];
|
|
916
920
|
if (n.length !== 1 || n[0].allowedUrlPrefixes.length === 0) throw Error("The resource must be registered exactly once with permitted API URL prefixes.");
|
|
@@ -968,7 +972,7 @@ var me = () => {
|
|
|
968
972
|
n.endsWith("/") && (n = n.slice(0, -1));
|
|
969
973
|
let { hash: r } = t;
|
|
970
974
|
return (r === "#" || r === "#_=_") && (r = ""), r && (n += r), n;
|
|
971
|
-
},
|
|
975
|
+
}, H = (e) => {
|
|
972
976
|
let { search: t } = Xe(e);
|
|
973
977
|
return Qe(t);
|
|
974
978
|
}, Qe = (e) => {
|
|
@@ -978,7 +982,7 @@ var me = () => {
|
|
|
978
982
|
t[decodeURIComponent(e)] = decodeURIComponent(r);
|
|
979
983
|
}
|
|
980
984
|
return t;
|
|
981
|
-
}, $e = "_oidc_resource", et = "oidc.resource_transaction.",
|
|
985
|
+
}, $e = "_oidc_resource", et = "oidc.resource_transaction.", U = (e, t) => t === void 0 ? e : Ne(e, t), W = (t, n, i) => {
|
|
982
986
|
let a = i ?? n.resource;
|
|
983
987
|
if (a === void 0) return t;
|
|
984
988
|
let o = typeof a == "string" ? [a] : a;
|
|
@@ -986,7 +990,7 @@ var me = () => {
|
|
|
986
990
|
phase: "login",
|
|
987
991
|
retryable: !1
|
|
988
992
|
});
|
|
989
|
-
for (let e of o) Fe(e), n.resources &&
|
|
993
|
+
for (let e of o) Fe(e), n.resources && V(n.resources, e);
|
|
990
994
|
let s = t.resource;
|
|
991
995
|
if (s !== void 0 && JSON.stringify(typeof s == "string" ? [s] : s) !== JSON.stringify(o)) throw new r(e.INVALID_RESOURCE, "Resource extras conflict with the selected resource.", {
|
|
992
996
|
phase: "login",
|
|
@@ -996,34 +1000,34 @@ var me = () => {
|
|
|
996
1000
|
...t,
|
|
997
1001
|
resource: a
|
|
998
1002
|
};
|
|
999
|
-
},
|
|
1003
|
+
}, tt = (e, t, n) => {
|
|
1000
1004
|
sessionStorage.setItem(`${et}${e}.${t}`, n);
|
|
1001
|
-
},
|
|
1002
|
-
let { state: n } =
|
|
1005
|
+
}, nt = (e, t) => {
|
|
1006
|
+
let { state: n } = H(t);
|
|
1003
1007
|
return n ? sessionStorage.getItem(`${et}${e}.${n}`) ?? void 0 : void 0;
|
|
1004
|
-
},
|
|
1005
|
-
let { state: n } =
|
|
1008
|
+
}, rt = (e, t) => {
|
|
1009
|
+
let { state: n } = H(t);
|
|
1006
1010
|
n && sessionStorage.removeItem(`${et}${e}.${n}`);
|
|
1007
|
-
},
|
|
1011
|
+
}, it = (e, t) => {
|
|
1008
1012
|
let n = `${et}${e}.`;
|
|
1009
1013
|
for (let e of Object.keys(sessionStorage)) e.startsWith(n) && (t === void 0 || sessionStorage.getItem(e) === t) && sessionStorage.removeItem(e);
|
|
1010
|
-
},
|
|
1014
|
+
}, at = (e, t, n, r, i, a = () => window.fetch) => (o = void 0, s = null, u = !1, d = void 0) => {
|
|
1011
1015
|
let p = s;
|
|
1012
1016
|
s = { ...s };
|
|
1013
1017
|
let m = s[$e];
|
|
1014
1018
|
delete s[$e];
|
|
1015
|
-
let h =
|
|
1019
|
+
let h = U(e, m);
|
|
1016
1020
|
return (async () => {
|
|
1017
1021
|
let _ = o || i.getPath();
|
|
1018
|
-
if ("state" in s || (s.state =
|
|
1022
|
+
if ("state" in s || (s.state = ae(16)), m !== void 0 && tt(e, s.state, m), n(f.loginAsync_begin, {}), s) for (let e of Object.keys(s)) e.endsWith(":token_request") && delete s[e];
|
|
1019
1023
|
try {
|
|
1020
1024
|
let e = u ? t.silent_redirect_uri : t.redirect_uri;
|
|
1021
1025
|
d ||= t.scope;
|
|
1022
|
-
let n =
|
|
1026
|
+
let n = W(t.extras ? {
|
|
1023
1027
|
...t.extras,
|
|
1024
1028
|
...s
|
|
1025
1029
|
} : s, t, m);
|
|
1026
|
-
typeof n.scope == "string" && (d = n.scope), n.nonce ||=
|
|
1030
|
+
typeof n.scope == "string" && (d = n.scope), n.nonce ||= ae(12);
|
|
1027
1031
|
let o = { nonce: n.nonce }, c = await $(t, h), l = await r(t.authority, t.authority_configuration), f;
|
|
1028
1032
|
if (c) c.setLoginParams({
|
|
1029
1033
|
callbackPath: _,
|
|
@@ -1050,7 +1054,7 @@ var me = () => {
|
|
|
1050
1054
|
response_type: "code",
|
|
1051
1055
|
...n
|
|
1052
1056
|
}, y = t.par ?? "disabled", b = l.pushedAuthorizationRequestEndpoint, x = l.requirePushedAuthorizationRequests;
|
|
1053
|
-
if (!b && (y === "required" || y === "auto" && x)) throw new I
|
|
1057
|
+
if (!b && (y === "required" || y === "auto" && x)) throw new L(I.ENDPOINT_UNAVAILABLE, "Pushed Authorization Requests are required, but the authorization server metadata does not provide a pushed_authorization_request_endpoint.");
|
|
1054
1058
|
let S = y !== "disabled" && b ? {
|
|
1055
1059
|
endpoint: b,
|
|
1056
1060
|
fetch: a(),
|
|
@@ -1062,10 +1066,10 @@ var me = () => {
|
|
|
1062
1066
|
throw n(f.loginAsync_error, t), t;
|
|
1063
1067
|
}
|
|
1064
1068
|
})();
|
|
1065
|
-
},
|
|
1069
|
+
}, ot = (t) => async (n = !1, o) => {
|
|
1066
1070
|
try {
|
|
1067
1071
|
t.publishEvent(f.loginCallbackAsync_begin, {});
|
|
1068
|
-
let i = t.configuration, c =
|
|
1072
|
+
let i = t.configuration, c = U(t.configurationName, o), l = i.client_id, u = n ? i.silent_redirect_uri : i.redirect_uri, d = i.authority, p = i.token_request_timeout, m = await t.initAsync(d, i.authority_configuration), h = H(t.location.getCurrentHref()), _ = h.session_state, v = await $(i, c), y, b, x, S;
|
|
1069
1073
|
if (v) await v.initAsync(m, "loginCallbackAsync", i), await v.setSessionStateAsync(_), b = await v.getNonceAsync(), x = v.getLoginParams(), S = await v.getStateAsync(), v.startKeepAliveServiceWorker(), y = v;
|
|
1070
1074
|
else {
|
|
1071
1075
|
let e = g(c, i.storage ?? sessionStorage, i.login_state_storage ?? i.storage ?? sessionStorage);
|
|
@@ -1074,11 +1078,11 @@ var me = () => {
|
|
|
1074
1078
|
if (h.error || h.error_description) throw s(h.error, h.error_description, `Error from OIDC server: ${h.error} - ${h.error_description}`, n ? "refresh" : "callback");
|
|
1075
1079
|
if (h.iss && h.iss !== m.issuer) throw console.error(), Error(`Issuer not valid (expected: ${m.issuer}, received: ${h.iss})`);
|
|
1076
1080
|
if (h.state) {
|
|
1077
|
-
if (!S) throw new P
|
|
1078
|
-
if (h.state !== S) throw new P
|
|
1081
|
+
if (!S) throw new F(P.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).", n ? "refresh" : "callback");
|
|
1082
|
+
if (h.state !== S) throw new F(P.STATE_MISMATCH, `OIDC state does not match the stored one (expected: ${S}, received: ${h.state}).`, n ? "refresh" : "callback");
|
|
1079
1083
|
}
|
|
1080
|
-
if (!b || !b.nonce) throw new P
|
|
1081
|
-
let C =
|
|
1084
|
+
if (!b || !b.nonce) throw new F(P.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).", n ? "refresh" : "callback");
|
|
1085
|
+
let C = W({
|
|
1082
1086
|
code: h.code,
|
|
1083
1087
|
grant_type: "authorization_code",
|
|
1084
1088
|
client_id: i.client_id,
|
|
@@ -1094,14 +1098,14 @@ var me = () => {
|
|
|
1094
1098
|
phase: "callback",
|
|
1095
1099
|
retryable: !1
|
|
1096
1100
|
});
|
|
1097
|
-
await g(c, i.storage, i.login_state_storage ?? i.storage).setDemonstratingProofOfPossessionJwkAsync(D), E.DPoP = await
|
|
1101
|
+
await g(c, i.storage, i.login_state_storage ?? i.storage).setDemonstratingProofOfPossessionJwkAsync(D), E.DPoP = await M(window)(i.demonstrating_proof_of_possession_configuration)(D, "POST", T);
|
|
1098
1102
|
}
|
|
1099
1103
|
}
|
|
1100
|
-
let ee =
|
|
1104
|
+
let ee = W({
|
|
1101
1105
|
...C,
|
|
1102
1106
|
...w
|
|
1103
1107
|
}, i, o), O = await je(y)(T, ee, E, t.configuration.token_renew_mode, p, i.demonstrating_proof_of_possession);
|
|
1104
|
-
if (!O.success && O.oauthError === "use_dpop_nonce" && O.demonstratingProofOfPossessionNonce && i.demonstrating_proof_of_possession ? (await y.setDemonstratingProofOfPossessionNonce(O.demonstratingProofOfPossessionNonce), v || (E.DPoP = await
|
|
1108
|
+
if (!O.success && O.oauthError === "use_dpop_nonce" && O.demonstratingProofOfPossessionNonce && i.demonstrating_proof_of_possession ? (await y.setDemonstratingProofOfPossessionNonce(O.demonstratingProofOfPossessionNonce), v || (E.DPoP = await M(window)(i.demonstrating_proof_of_possession_configuration)(D, "POST", T, { nonce: O.demonstratingProofOfPossessionNonce })), O = await je(y)(T, ee, E, t.configuration.token_renew_mode, p)) : !O.success && i.demonstrating_proof_of_possession && await Promise.all([y.setCodeVerifierAsync(null), y.setStateAsync(null)]), !O.success) {
|
|
1105
1109
|
let t = O.oauthError === "use_dpop_nonce" ? e.DPOP_NONCE_REQUIRED : e.TOKEN_REQUEST_FAILED;
|
|
1106
1110
|
throw new r(t, "Token request failed", {
|
|
1107
1111
|
phase: n ? "refresh" : "callback",
|
|
@@ -1122,10 +1126,10 @@ var me = () => {
|
|
|
1122
1126
|
phase: n ? "refresh" : "callback",
|
|
1123
1127
|
retryable: !1
|
|
1124
1128
|
});
|
|
1125
|
-
let { isValid:
|
|
1126
|
-
if (!
|
|
1127
|
-
let t = `Tokens are not OpenID valid, reason: ${
|
|
1128
|
-
throw
|
|
1129
|
+
let { isValid: N, reason: ne } = Lt(A, b.nonce, m);
|
|
1130
|
+
if (!N) {
|
|
1131
|
+
let t = `Tokens are not OpenID valid, reason: ${ne}`;
|
|
1132
|
+
throw ne.startsWith("Nonce does not match") ? new r(e.INVALID_NONCE, t, {
|
|
1129
1133
|
phase: n ? "refresh" : "callback",
|
|
1130
1134
|
retryable: !1
|
|
1131
1135
|
}) : Error(t);
|
|
@@ -1151,10 +1155,10 @@ var me = () => {
|
|
|
1151
1155
|
let r = !i(e) && l(e) ? c(e, n ? "refresh" : "callback") : e;
|
|
1152
1156
|
throw console.error(r), t.publishEvent(f.loginCallbackAsync_error, r), r;
|
|
1153
1157
|
}
|
|
1154
|
-
},
|
|
1158
|
+
}, st = {
|
|
1155
1159
|
access_token: "access_token",
|
|
1156
1160
|
refresh_token: "refresh_token"
|
|
1157
|
-
},
|
|
1161
|
+
}, ct = (e, t) => {
|
|
1158
1162
|
let n = {};
|
|
1159
1163
|
if (e) {
|
|
1160
1164
|
for (let [r, i] of Object.entries(e)) if (r.endsWith(t)) {
|
|
@@ -1164,27 +1168,27 @@ var me = () => {
|
|
|
1164
1168
|
return n;
|
|
1165
1169
|
}
|
|
1166
1170
|
return n;
|
|
1167
|
-
},
|
|
1171
|
+
}, lt = (e) => {
|
|
1168
1172
|
let t = {};
|
|
1169
1173
|
if (e) {
|
|
1170
1174
|
for (let [n, r] of Object.entries(e)) n.includes(":") || (t[n] = r);
|
|
1171
1175
|
return t;
|
|
1172
1176
|
}
|
|
1173
1177
|
return t;
|
|
1174
|
-
},
|
|
1178
|
+
}, ut = (e) => async (t) => {
|
|
1175
1179
|
e.resourceTokens && await e.resourceTokens.clearAllAsync(), b.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
1176
1180
|
let n = await $(e.configuration, e.configurationName);
|
|
1177
1181
|
n ? await n.clearAsync(t) : await g(e.configurationName, e.configuration.storage, e.configuration.login_state_storage ?? e.configuration.storage).clearAsync(t), e.tokens = null, e.userInfo = null;
|
|
1178
|
-
},
|
|
1182
|
+
}, dt = (e, t) => async () => {
|
|
1179
1183
|
let n = e.tokens?.idTokenPayload?.sub ?? null;
|
|
1180
1184
|
await e.destroyAsync("LOGGED_OUT");
|
|
1181
1185
|
for (let [, r] of Object.entries(t)) r === e ? e.publishEvent(f.logout_from_same_tab, {}) : await e.logoutSameTabAsync(e.configuration.client_id, n);
|
|
1182
|
-
},
|
|
1186
|
+
}, ft = (e, t, n, r) => {
|
|
1183
1187
|
"id_token_hint" in t || (t.id_token_hint = n), !("post_logout_redirect_uri" in t) && r !== null && (t.post_logout_redirect_uri = r);
|
|
1184
1188
|
let i = "";
|
|
1185
1189
|
for (let [e, n] of Object.entries(t)) n != null && (i += i === "" ? "?" : "&", i += `${e}=${encodeURIComponent(n)}`);
|
|
1186
1190
|
return `${e}${i}`;
|
|
1187
|
-
},
|
|
1191
|
+
}, pt = (t, n, o, s, u) => async (d = void 0, p = null) => {
|
|
1188
1192
|
let m = t.configuration, h;
|
|
1189
1193
|
try {
|
|
1190
1194
|
h = await t.initAsync(m.authority, m.authority_configuration);
|
|
@@ -1203,18 +1207,18 @@ var me = () => {
|
|
|
1203
1207
|
let n = h.revocationEndpoint;
|
|
1204
1208
|
if (n) {
|
|
1205
1209
|
let i = [], s = t.tokens ? t.tokens.accessToken : null;
|
|
1206
|
-
if (s && m.logout_tokens_to_invalidate.includes(
|
|
1207
|
-
let e =
|
|
1210
|
+
if (s && m.logout_tokens_to_invalidate.includes(st.access_token)) {
|
|
1211
|
+
let e = ct(p, ":revoke_access_token"), t = Ee(o)(n, s, z.access_token, m.client_id, e);
|
|
1208
1212
|
i.push(t);
|
|
1209
1213
|
}
|
|
1210
1214
|
let c = t.tokens ? t.tokens.refreshToken : null;
|
|
1211
|
-
if (c && m.logout_tokens_to_invalidate.includes(
|
|
1212
|
-
let e =
|
|
1215
|
+
if (c && m.logout_tokens_to_invalidate.includes(st.refresh_token)) {
|
|
1216
|
+
let e = ct(p, ":revoke_refresh_token"), t = Ee(o)(n, c, z.refresh_token, m.client_id, e);
|
|
1213
1217
|
i.push(t);
|
|
1214
1218
|
}
|
|
1215
1219
|
if (t.resourceTokens) {
|
|
1216
1220
|
let e = await t.resourceTokens.getTokensToRevokeAsync(), r = new Set([s, c].filter(Boolean));
|
|
1217
|
-
for (let t of e) for (let [e, a] of [[
|
|
1221
|
+
for (let t of e) for (let [e, a] of [[z.access_token, t.accessToken], [z.refresh_token, t.refreshToken]]) a && !r.has(a) && m.logout_tokens_to_invalidate.includes(e) && (r.add(a), i.push(Ee(o)(n, a, e, m.client_id, ct(p, e === z.access_token ? ":revoke_access_token" : ":revoke_refresh_token"))));
|
|
1218
1222
|
}
|
|
1219
1223
|
if (i.length > 0) {
|
|
1220
1224
|
let n = await Promise.all(i);
|
|
@@ -1231,33 +1235,33 @@ var me = () => {
|
|
|
1231
1235
|
let n = !i(e) && l(e) ? c(e, "logout") : e;
|
|
1232
1236
|
t.publishEvent(f.logoutAsync_error, n), s.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"), s.warn(n);
|
|
1233
1237
|
}
|
|
1234
|
-
let d =
|
|
1238
|
+
let d = ct(p, ":oidc");
|
|
1235
1239
|
if (d && d.no_reload === "true") {
|
|
1236
|
-
await
|
|
1240
|
+
await dt(t, n)(), t.isLoggingOut = !1;
|
|
1237
1241
|
return;
|
|
1238
1242
|
}
|
|
1239
|
-
let g =
|
|
1243
|
+
let g = lt(p);
|
|
1240
1244
|
if (h.endSessionEndpoint) {
|
|
1241
|
-
let e =
|
|
1245
|
+
let e = ft(h.endSessionEndpoint, g, y, v);
|
|
1242
1246
|
u.open(e);
|
|
1243
1247
|
} else u.reload();
|
|
1244
|
-
await
|
|
1248
|
+
await dt(t, n)();
|
|
1245
1249
|
} catch (e) {
|
|
1246
1250
|
t.isLoggingOut = !1;
|
|
1247
1251
|
let n = !i(e) && l(e) ? c(e, "logout") : e;
|
|
1248
1252
|
throw t.publishEvent(f.logoutAsync_error, n), n;
|
|
1249
1253
|
}
|
|
1250
|
-
},
|
|
1254
|
+
}, G = (t) => new r(e.RESOURCE_TOKEN_UNAVAILABLE, t, {
|
|
1251
1255
|
phase: "refresh",
|
|
1252
1256
|
retryable: !1
|
|
1253
|
-
}),
|
|
1257
|
+
}), mt = class {
|
|
1254
1258
|
constructor(e) {
|
|
1255
1259
|
this.oidc = e, this.pending = /* @__PURE__ */ new Map(), this.cached = /* @__PURE__ */ new Map(), this.generations = /* @__PURE__ */ new Map(), this.generation = 0, this.refreshQueue = Promise.resolve(), this.renewalTimers = /* @__PURE__ */ new Map();
|
|
1256
1260
|
}
|
|
1257
1261
|
async contextAsync(e) {
|
|
1258
|
-
let { oidc: t } = this, n =
|
|
1262
|
+
let { oidc: t } = this, n = U(t.configurationName, e), r = await t.initAsync(t.configuration.authority, t.configuration.authority_configuration), i = await $(t.configuration, n), a = g(n, t.configuration.storage, t.configuration.login_state_storage ?? t.configuration.storage), o = i ? await i.initAsync(r, "resource-token", t.configuration) : await a.initAsync(), s = [];
|
|
1259
1263
|
if ("resourceContexts" in o && o.resourceContexts !== void 0) {
|
|
1260
|
-
if (!Array.isArray(o.resourceContexts) || o.resourceContexts.some((e) => typeof e != "string")) throw
|
|
1264
|
+
if (!Array.isArray(o.resourceContexts) || o.resourceContexts.some((e) => typeof e != "string")) throw G("The worker returned invalid resource context metadata.");
|
|
1261
1265
|
s.push(...o.resourceContexts);
|
|
1262
1266
|
}
|
|
1263
1267
|
return {
|
|
@@ -1269,7 +1273,7 @@ var me = () => {
|
|
|
1269
1273
|
};
|
|
1270
1274
|
}
|
|
1271
1275
|
validate(t, n, i, a = this.oidc.tokens?.idTokenPayload?.sub) {
|
|
1272
|
-
let { oidc: o } = this, s =
|
|
1276
|
+
let { oidc: o } = this, s = V(o.configuration.resources, t), c = n.resourceContext;
|
|
1273
1277
|
if (!c || c.resource !== t || c.issuer !== i || c.clientId !== o.configuration.client_id || c.configurationName !== o.configurationName || c.subject !== a) throw new r(e.RESOURCE_CONTEXT_MISMATCH, "The token does not belong to this resource and OIDC session.", {
|
|
1274
1278
|
phase: "refresh",
|
|
1275
1279
|
retryable: !1
|
|
@@ -1279,8 +1283,8 @@ var me = () => {
|
|
|
1279
1283
|
phase: "refresh",
|
|
1280
1284
|
retryable: !1
|
|
1281
1285
|
});
|
|
1282
|
-
if (typeof n.accessToken != "string" || !n.accessToken || !Number.isFinite(n.expiresAt) || !Number.isFinite(n.issuedAt) || n.refreshToken != null && (typeof n.refreshToken != "string" || !n.refreshToken)) throw
|
|
1283
|
-
if (s.scope && !s.scope.split(/\s+/).filter(Boolean).every((e) => (n.scope ?? "").split(/\s+/).includes(e))) throw
|
|
1286
|
+
if (typeof n.accessToken != "string" || !n.accessToken || !Number.isFinite(n.expiresAt) || !Number.isFinite(n.issuedAt) || n.refreshToken != null && (typeof n.refreshToken != "string" || !n.refreshToken)) throw G("The provider did not return a usable resource token response.");
|
|
1287
|
+
if (s.scope && !s.scope.split(/\s+/).filter(Boolean).every((e) => (n.scope ?? "").split(/\s+/).includes(e))) throw G("The provider did not grant the required resource scopes.");
|
|
1284
1288
|
}
|
|
1285
1289
|
publicToken(e, t) {
|
|
1286
1290
|
return {
|
|
@@ -1328,16 +1332,16 @@ var me = () => {
|
|
|
1328
1332
|
}
|
|
1329
1333
|
async acceptAuthorizationAsync(t, n) {
|
|
1330
1334
|
let i = this.generation, a = this.generations.get(t) ?? 0, o = await this.contextAsync(t), s = await this.contextAsync();
|
|
1331
|
-
if (i !== this.generation || a !== (this.generations.get(t) ?? 0)) throw
|
|
1335
|
+
if (i !== this.generation || a !== (this.generations.get(t) ?? 0)) throw G("The resource authorization was cleared.");
|
|
1332
1336
|
let c = n.idTokenPayload?.sub;
|
|
1333
1337
|
if (typeof c != "string" || (this.oidc.tokens?.idTokenPayload?.sub ?? s.tokens?.idTokenPayload?.sub) !== c) throw new r(e.RESOURCE_CONTEXT_MISMATCH, "Resource authorization must preserve the authenticated subject.", {
|
|
1334
1338
|
phase: "callback",
|
|
1335
1339
|
retryable: !1
|
|
1336
1340
|
});
|
|
1337
|
-
if (n.refreshToken && n.refreshToken === s.tokens?.refreshToken) throw
|
|
1341
|
+
if (n.refreshToken && n.refreshToken === s.tokens?.refreshToken) throw G("The provider reused a refresh token across separate authorization transactions; use a multi-resource authorization grant instead.");
|
|
1338
1342
|
let l = {
|
|
1339
1343
|
...n,
|
|
1340
|
-
scope: n.scope ??
|
|
1344
|
+
scope: n.scope ?? V(this.oidc.configuration.resources, t).scope ?? this.oidc.configuration.scope,
|
|
1341
1345
|
resourceContext: {
|
|
1342
1346
|
resource: t,
|
|
1343
1347
|
issuer: o.server.issuer,
|
|
@@ -1347,30 +1351,30 @@ var me = () => {
|
|
|
1347
1351
|
grantResource: t
|
|
1348
1352
|
}
|
|
1349
1353
|
};
|
|
1350
|
-
this.validate(t, l, o.server.issuer, c), o.isWorker || g(
|
|
1354
|
+
this.validate(t, l, o.server.issuer, c), o.isWorker || g(U(this.oidc.configurationName, t), this.oidc.configuration.storage).setTokens(l), this.cached.set(t, l);
|
|
1351
1355
|
}
|
|
1352
1356
|
getAccessTokenAsync(t, n = {}) {
|
|
1353
1357
|
let a = this.pending.get(t);
|
|
1354
1358
|
if (a) return a;
|
|
1355
1359
|
let o = this.generation, u = this.generations.get(t) ?? 0, d = this.oidc.tokens?.idTokenPayload?.sub, p = this.oidc.tokens?.idTokenPayload?.nonce, m = () => this.generation === o && (this.generations.get(t) ?? 0) === u && !this.oidc.isLoggingOut && this.oidc.tokens?.idTokenPayload?.sub === d && this.oidc.tokens?.idTokenPayload?.nonce === p, h = this.withRefreshLockAsync(async () => {
|
|
1356
|
-
let { oidc: i } = this, a =
|
|
1357
|
-
if (!Number.isFinite(i.configuration.refresh_time_before_tokens_expiration_in_second) || i.configuration.refresh_time_before_tokens_expiration_in_second < 0) throw
|
|
1358
|
-
if (!i.tokens || typeof i.tokens.idTokenPayload?.sub != "string" || !m()) throw
|
|
1360
|
+
let { oidc: i } = this, a = V(i.configuration.resources, t);
|
|
1361
|
+
if (!Number.isFinite(i.configuration.refresh_time_before_tokens_expiration_in_second) || i.configuration.refresh_time_before_tokens_expiration_in_second < 0) throw G("Configure a finite, non-negative renewal margin.");
|
|
1362
|
+
if (!i.tokens || typeof i.tokens.idTokenPayload?.sub != "string" || !m()) throw G("Sign in before requesting a resource token.");
|
|
1359
1363
|
if (i.configuration.token_request_extras?.resource !== void 0 && i.configuration.token_request_extras.resource !== t) throw new r(e.INVALID_RESOURCE, "Token extras conflict with the selected resource.", {
|
|
1360
1364
|
phase: "refresh",
|
|
1361
1365
|
retryable: !1
|
|
1362
1366
|
});
|
|
1363
1367
|
let c = await this.contextAsync(t), l = await this.contextAsync();
|
|
1364
|
-
if (!m()) throw
|
|
1368
|
+
if (!m()) throw G("The resource transaction was cleared.");
|
|
1365
1369
|
let h = l.tokens?.idTokenPayload?.nonce;
|
|
1366
|
-
if (!l.tokens || l.tokens.idTokenPayload?.sub !== d || !l.isWorker && h !== i.tokens.idTokenPayload?.nonce) throw
|
|
1370
|
+
if (!l.tokens || l.tokens.idTokenPayload?.sub !== d || !l.isWorker && h !== i.tokens.idTokenPayload?.nonce) throw G("The original OIDC session changed or is unavailable; restore it before requesting resource tokens.");
|
|
1367
1371
|
let _ = c.tokens;
|
|
1368
|
-
if (_ && (this.validate(t, _, c.server.issuer), !n.forceRenew &&
|
|
1372
|
+
if (_ && (this.validate(t, _, c.server.issuer), !n.forceRenew && X(_, this.renewalMargin(_)))) {
|
|
1369
1373
|
let e = this.cached.get(t);
|
|
1370
1374
|
return this.cached.set(t, _), this.scheduleRenewal(t, _), (e?.accessToken !== _.accessToken || e?.expiresAt !== _.expiresAt || e?.scope !== _.scope || e?.tokenType !== _.tokenType) && i.publishEvent(f.resource_token_acquired, { resource: t }), this.publicToken(t, _);
|
|
1371
1375
|
}
|
|
1372
1376
|
let v = typeof i.configuration.resource == "string" ? [i.configuration.resource] : i.configuration.resource ?? [], y = (l.tokens.scope ?? i.configuration.scope).split(/\s+/), b = !a.scope || a.scope.split(/\s+/).filter(Boolean).every((e) => y.includes(e)), S = _?.resourceContext ? _.resourceContext.grantResource : v.includes(t) && b ? null : t, C = S === null ? await this.contextAsync() : c, w = S === null && !b ? void 0 : C.tokens?.refreshToken, T = i.configuration.demonstrating_proof_of_possession || C.tokens?.tokenType?.toLowerCase() === "dpop";
|
|
1373
|
-
if (!m()) throw
|
|
1377
|
+
if (!m()) throw G("The resource transaction was cleared.");
|
|
1374
1378
|
if (w) {
|
|
1375
1379
|
let n = await C.storage.getNonceAsync(), l = c.isWorker ? { [Me]: encodeURIComponent(t) } : {};
|
|
1376
1380
|
T && (l.DPoP = await this.generateProofAsync(t, {
|
|
@@ -1385,7 +1389,7 @@ var me = () => {
|
|
|
1385
1389
|
refresh_token: w,
|
|
1386
1390
|
resource: t,
|
|
1387
1391
|
...a.scope ? { scope: a.scope } : {}
|
|
1388
|
-
}, v = () => ke(i.getFetch())(c.server.tokenEndpoint, f, i.configuration.token_request_extras ?? {}, _, l,
|
|
1392
|
+
}, v = () => ke(i.getFetch())(c.server.tokenEndpoint, f, i.configuration.token_request_extras ?? {}, _, l, jt.access_token_invalid, i.configuration.token_request_timeout), y = await v();
|
|
1389
1393
|
if (!y.success && y.oauthError === "use_dpop_nonce" && y.demonstratingProofOfPossessionNonce && T && (await C.storage.setDemonstratingProofOfPossessionNonce(y.demonstratingProofOfPossessionNonce), l.DPoP = await this.generateProofAsync(t, {
|
|
1390
1394
|
accessToken: C.tokens.accessToken,
|
|
1391
1395
|
url: c.server.tokenEndpoint,
|
|
@@ -1393,15 +1397,15 @@ var me = () => {
|
|
|
1393
1397
|
grantResource: S
|
|
1394
1398
|
}), y = await v()), y.success) {
|
|
1395
1399
|
let s = await this.contextAsync();
|
|
1396
|
-
if (!s.tokens || s.tokens.idTokenPayload?.sub !== d || !s.isWorker && s.tokens.idTokenPayload?.nonce !== h) throw
|
|
1400
|
+
if (!s.tokens || s.tokens.idTokenPayload?.sub !== d || !s.isWorker && s.tokens.idTokenPayload?.nonce !== h) throw G("The original OIDC session changed during resource renewal.");
|
|
1397
1401
|
_ = y.data;
|
|
1398
1402
|
let l = this.generation === o && i.tokens?.idTokenPayload?.sub === d && i.tokens?.idTokenPayload?.nonce === p;
|
|
1399
1403
|
if (l && S === null && this.updateSharedRefreshToken(_, c.isWorker), _.idTokenPayload?.sub !== void 0 && _.idTokenPayload.sub !== d) throw new r(e.RESOURCE_CONTEXT_MISMATCH, "Resource renewal changed the authenticated subject.", {
|
|
1400
1404
|
phase: "refresh",
|
|
1401
1405
|
retryable: !1
|
|
1402
1406
|
});
|
|
1403
|
-
let f =
|
|
1404
|
-
if (!f.isValid) throw
|
|
1407
|
+
let f = Lt(_, n?.nonce, c.server);
|
|
1408
|
+
if (!f.isValid) throw G(f.reason);
|
|
1405
1409
|
if (_ = {
|
|
1406
1410
|
..._,
|
|
1407
1411
|
scope: _.scope ?? a.scope ?? C.tokens.scope ?? i.configuration.scope,
|
|
@@ -1413,26 +1417,26 @@ var me = () => {
|
|
|
1413
1417
|
subject: d,
|
|
1414
1418
|
grantResource: S
|
|
1415
1419
|
}
|
|
1416
|
-
}, this.validate(t, _, c.server.issuer, d), !m()) throw l && i.isLoggingOut && u === (this.generations.get(t) ?? 0) && !c.isWorker && g(
|
|
1417
|
-
y.demonstratingProofOfPossessionNonce && await C.storage.setDemonstratingProofOfPossessionNonce(y.demonstratingProofOfPossessionNonce), c.isWorker || g(
|
|
1420
|
+
}, this.validate(t, _, c.server.issuer, d), !m()) throw l && i.isLoggingOut && u === (this.generations.get(t) ?? 0) && !c.isWorker && g(U(i.configurationName, t), i.configuration.storage).setTokens(_), G("The resource transaction was cleared.");
|
|
1421
|
+
y.demonstratingProofOfPossessionNonce && await C.storage.setDemonstratingProofOfPossessionNonce(y.demonstratingProofOfPossessionNonce), c.isWorker || g(U(i.configurationName, t), i.configuration.storage).setTokens(_), S === null && this.updateSharedRefreshToken(_, c.isWorker);
|
|
1418
1422
|
} else if (y.oauthError !== "invalid_grant") throw s(y.oauthError, y.oauthErrorDescription, "Resource token request failed.", "refresh", y.status);
|
|
1419
1423
|
else _ = null;
|
|
1420
1424
|
} else _ = null;
|
|
1421
1425
|
if (!_) {
|
|
1422
|
-
if (!m()) throw
|
|
1426
|
+
if (!m()) throw G("The resource transaction was cleared.");
|
|
1423
1427
|
let e = a.scope ? [.../* @__PURE__ */ new Set(["openid", ...a.scope.split(" ")])].join(" ") : i.configuration.scope, n = await x(i.configurationName, i.configuration, i.publishEvent.bind(i), "refresh")({
|
|
1424
1428
|
...i.configuration.extras,
|
|
1425
1429
|
prompt: "none",
|
|
1426
1430
|
resource: t,
|
|
1427
1431
|
[$e]: t
|
|
1428
1432
|
}, null, e);
|
|
1429
|
-
if (!n) throw
|
|
1433
|
+
if (!n) throw G("Configure silent_redirect_uri and silent_login_uri for resource authorization.");
|
|
1430
1434
|
if (n.error) throw n.oidcError ?? s(n.error, void 0, "Resource silent authorization failed.", "refresh");
|
|
1431
|
-
if (!m() || n.resource !== t) throw
|
|
1435
|
+
if (!m() || n.resource !== t) throw G("The resource authorization transaction is no longer current.");
|
|
1432
1436
|
await this.acceptAuthorizationAsync(t, n.tokens), c = await this.contextAsync(t), _ = c.tokens ?? this.cached.get(t);
|
|
1433
1437
|
}
|
|
1434
|
-
if (!m()) throw
|
|
1435
|
-
if (this.validate(t, _, c.server.issuer), !
|
|
1438
|
+
if (!m()) throw G("The resource transaction was cleared.");
|
|
1439
|
+
if (this.validate(t, _, c.server.issuer), !X(_)) throw G("The resource access token is expired.");
|
|
1436
1440
|
return this.cached.set(t, _), this.scheduleRenewal(t, _), i.publishEvent(f.resource_token_acquired, { resource: t }), this.publicToken(t, _);
|
|
1437
1441
|
}).catch((n) => {
|
|
1438
1442
|
let a = i(n) ? n : l(n) ? c(n, "refresh") : new r(e.RESOURCE_TOKEN_UNAVAILABLE, n instanceof Error ? n.message : "Resource token acquisition failed.", {
|
|
@@ -1451,24 +1455,24 @@ var me = () => {
|
|
|
1451
1455
|
}
|
|
1452
1456
|
async generateProofAsync(e, t) {
|
|
1453
1457
|
let n = this.cached.get(e)?.resourceContext, r = t.grantResource === void 0 ? n ? n.grantResource : e : t.grantResource, i = await this.contextAsync(r ?? void 0);
|
|
1454
|
-
if (i.isWorker) return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${
|
|
1458
|
+
if (i.isWorker) return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${U(this.oidc.configurationName, e)}`;
|
|
1455
1459
|
let a = await i.storage.getDemonstratingProofOfPossessionJwkAsync();
|
|
1456
|
-
if (!a) throw
|
|
1457
|
-
let o = t.url === i.server.tokenEndpoint ? await i.storage.getDemonstratingProofOfPossessionNonce() : g(
|
|
1458
|
-
return
|
|
1459
|
-
ath: await
|
|
1460
|
+
if (!a) throw G("The resource DPoP grant key is unavailable.");
|
|
1461
|
+
let o = t.url === i.server.tokenEndpoint ? await i.storage.getDemonstratingProofOfPossessionNonce() : g(U(this.oidc.configurationName, e), this.oidc.configuration.storage).getDemonstratingProofOfPossessionApiNonce();
|
|
1462
|
+
return M(window)(this.oidc.configuration.demonstrating_proof_of_possession_configuration)(a, t.method, t.url, {
|
|
1463
|
+
ath: await se(t.accessToken),
|
|
1460
1464
|
...o ? { nonce: o } : {}
|
|
1461
1465
|
});
|
|
1462
1466
|
}
|
|
1463
1467
|
peek(e) {
|
|
1464
1468
|
if (this.oidc.isLoggingOut) return null;
|
|
1465
1469
|
let t = this.cached.get(e);
|
|
1466
|
-
return t && t.resourceContext?.subject === this.oidc.tokens?.idTokenPayload?.sub &&
|
|
1470
|
+
return t && t.resourceContext?.subject === this.oidc.tokens?.idTokenPayload?.sub && X(t) ? this.publicToken(e, t) : null;
|
|
1467
1471
|
}
|
|
1468
1472
|
createApiNonceRecorder(e) {
|
|
1469
1473
|
let t = this.generation, n = this.generations.get(e) ?? 0;
|
|
1470
1474
|
return async (r) => {
|
|
1471
|
-
t !== this.generation || n !== (this.generations.get(e) ?? 0) || !this.peek(e) ? console.warn("Ignoring a resource API nonce response after its session was cleared.") : this.oidc.configuration.service_worker_relative_url || await g(
|
|
1475
|
+
t !== this.generation || n !== (this.generations.get(e) ?? 0) || !this.peek(e) ? console.warn("Ignoring a resource API nonce response after its session was cleared.") : this.oidc.configuration.service_worker_relative_url || await g(U(this.oidc.configurationName, e), this.oidc.configuration.storage).setDemonstratingProofOfPossessionApiNonce(r);
|
|
1472
1476
|
};
|
|
1473
1477
|
}
|
|
1474
1478
|
async getTokensToRevokeAsync() {
|
|
@@ -1481,11 +1485,11 @@ var me = () => {
|
|
|
1481
1485
|
return n;
|
|
1482
1486
|
}
|
|
1483
1487
|
async clearAsync(e) {
|
|
1484
|
-
|
|
1488
|
+
V(this.oidc.configuration.resources, e), this.generations.set(e, (this.generations.get(e) ?? 0) + 1), it(this.oidc.configurationName, e), this.pending.delete(e), this.cached.delete(e);
|
|
1485
1489
|
let t = this.renewalTimers.get(e);
|
|
1486
1490
|
t && b.clearTimeout(t), this.renewalTimers.delete(e);
|
|
1487
1491
|
let n = await this.contextAsync(e);
|
|
1488
|
-
await n.storage.clearAsync("LOGGED_OUT"), n.storage.setLoginParams(null), n.isWorker || (await g(
|
|
1492
|
+
await n.storage.clearAsync("LOGGED_OUT"), n.storage.setLoginParams(null), n.isWorker || (await g(U(this.oidc.configurationName, e), this.oidc.configuration.storage).setDemonstratingProofOfPossessionApiNonce(null), await Promise.all([
|
|
1489
1493
|
n.storage.setStateAsync(null),
|
|
1490
1494
|
n.storage.setCodeVerifierAsync(null),
|
|
1491
1495
|
n.storage.setNonceAsync(null),
|
|
@@ -1495,10 +1499,10 @@ var me = () => {
|
|
|
1495
1499
|
}
|
|
1496
1500
|
async clearAllAsync() {
|
|
1497
1501
|
if (this.oidc.configuration.resources?.length) {
|
|
1498
|
-
this.generation++,
|
|
1502
|
+
this.generation++, it(this.oidc.configurationName), this.pending.clear(), this.cached.clear();
|
|
1499
1503
|
for (let e of this.renewalTimers.values()) b.clearTimeout(e);
|
|
1500
1504
|
if (this.renewalTimers.clear(), !this.oidc.configuration.service_worker_relative_url) for (let e of this.oidc.configuration.resources ?? []) {
|
|
1501
|
-
let t = g(
|
|
1505
|
+
let t = g(U(this.oidc.configurationName, e.resource), this.oidc.configuration.storage, this.oidc.configuration.login_state_storage ?? this.oidc.configuration.storage);
|
|
1502
1506
|
await t.clearAsync("LOGGED_OUT"), t.setLoginParams(null), await Promise.all([
|
|
1503
1507
|
t.setStateAsync(null),
|
|
1504
1508
|
t.setCodeVerifierAsync(null),
|
|
@@ -1510,9 +1514,9 @@ var me = () => {
|
|
|
1510
1514
|
}
|
|
1511
1515
|
}
|
|
1512
1516
|
}
|
|
1513
|
-
},
|
|
1517
|
+
}, K = /* @__PURE__ */ function(e) {
|
|
1514
1518
|
return e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e;
|
|
1515
|
-
}({}),
|
|
1519
|
+
}({}), ht = (t, n, i = !1, a = "api_request") => async (...o) => {
|
|
1516
1520
|
let [s, l, ...u] = o, d = typeof a == "string" ? a : "api_request", p = typeof a == "string" ? void 0 : a.resource, m;
|
|
1517
1521
|
if (p === void 0 && d === "api_request" && n.configuration.resources?.length) try {
|
|
1518
1522
|
let e = new URL(s instanceof Request ? s.url : s.toString(), window.location.href).toString();
|
|
@@ -1527,7 +1531,7 @@ var me = () => {
|
|
|
1527
1531
|
}
|
|
1528
1532
|
if (typeof a != "string" && Object.prototype.hasOwnProperty.call(a, "resource")) try {
|
|
1529
1533
|
if (typeof p != "string") throw Error("An explicit resource identifier is required.");
|
|
1530
|
-
if (m = new URL(s instanceof Request ? s.url : s.toString(), window.location.href).toString(), !ze(
|
|
1534
|
+
if (m = new URL(s instanceof Request ? s.url : s.toString(), window.location.href).toString(), !ze(V(n.configuration.resources, p), m)) throw Error("The destination does not belong to the selected resource.");
|
|
1531
1535
|
if (l?.redirect === "follow") throw Error("Resource fetch cannot automatically follow redirects.");
|
|
1532
1536
|
} catch (t) {
|
|
1533
1537
|
let i = new r(e.INVALID_RESOURCE, t instanceof Error ? t.message : "Invalid resource destination.", {
|
|
@@ -1558,7 +1562,7 @@ var me = () => {
|
|
|
1558
1562
|
return e;
|
|
1559
1563
|
},
|
|
1560
1564
|
renewTokensAsync: n.renewTokensAsync.bind(n)
|
|
1561
|
-
}, v = p === void 0 ? void 0 : await n.resourceTokens.getAccessTokenAsync(p), y = p === void 0 ? await
|
|
1565
|
+
}, v = p === void 0 ? void 0 : await n.resourceTokens.getAccessTokenAsync(p), y = p === void 0 ? await It(_) : void 0, b = v?.accessToken ?? y?.tokens?.accessToken;
|
|
1562
1566
|
if (g.has("Accept") || g.set("Accept", "application/json"), b) {
|
|
1563
1567
|
if (n.configuration.demonstrating_proof_of_possession && i || v?.tokenType?.toLowerCase() === "dpop") {
|
|
1564
1568
|
let e = p === void 0 ? await n.generateDemonstrationOfProofOfPossessionAsync(b, s.toString(), h.method) : await n.resourceTokens.generateProofAsync(p, {
|
|
@@ -1599,13 +1603,13 @@ var me = () => {
|
|
|
1599
1603
|
d === "api_request" && n.publishEvent(f.apiRequest_error, t);
|
|
1600
1604
|
}
|
|
1601
1605
|
return C;
|
|
1602
|
-
},
|
|
1606
|
+
}, gt = (t) => async (n = !1, o = !1) => {
|
|
1603
1607
|
try {
|
|
1604
1608
|
if (t.userInfo != null && !n) return t.userInfo;
|
|
1605
1609
|
let i = !n && t.configuration.storage?.getItem(`oidc.${t.configurationName}.userInfo`);
|
|
1606
1610
|
if (i) return t.userInfo = JSON.parse(i), t.userInfo;
|
|
1607
1611
|
let s = t.configuration, c = (await t.initAsync(s.authority, s.authority_configuration)).userInfoEndpoint, l = await (async () => {
|
|
1608
|
-
let n = await
|
|
1612
|
+
let n = await ht(fetch, t, o, "userinfo")(c);
|
|
1609
1613
|
if (n.status !== 200) {
|
|
1610
1614
|
let i = n.headers?.has("DPoP-Nonce") && (n.status === 400 || n.status === 401 || n.headers.get("WWW-Authenticate")?.includes("use_dpop_nonce")), o = new r(i ? e.DPOP_NONCE_REQUIRED : e.REQUEST_FAILED, "UserInfo request failed", {
|
|
1611
1615
|
phase: "userinfo",
|
|
@@ -1622,39 +1626,39 @@ var me = () => {
|
|
|
1622
1626
|
let n = i(e) ? e : l(e) ? c(e, "userinfo") : e;
|
|
1623
1627
|
throw t.publishEvent(f.userInfoAsync_error, n), n;
|
|
1624
1628
|
}
|
|
1625
|
-
},
|
|
1629
|
+
}, _t = () => fetch, vt = class {
|
|
1626
1630
|
constructor(e) {
|
|
1627
1631
|
this.authorizationEndpoint = e.authorization_endpoint, this.tokenEndpoint = e.token_endpoint, this.revocationEndpoint = e.revocation_endpoint, this.userInfoEndpoint = e.userinfo_endpoint, this.checkSessionIframe = e.check_session_iframe, this.issuer = e.issuer, this.endSessionEndpoint = e.end_session_endpoint, this.pushedAuthorizationRequestEndpoint = e.pushed_authorization_request_endpoint, this.requirePushedAuthorizationRequests = e.require_pushed_authorization_requests ?? !1;
|
|
1628
1632
|
}
|
|
1629
|
-
},
|
|
1633
|
+
}, q = {}, yt = (e, t = new he()) => (n, r = "default") => (q[r] || (q[r] = new J(n, r, e, t)), q[r]), bt = async (e) => {
|
|
1630
1634
|
let { parsedTokens: t, callbackPath: n, extras: r, scope: i } = await e.loginCallbackAsync();
|
|
1631
|
-
return e.timeoutId =
|
|
1632
|
-
},
|
|
1633
|
-
constructor(e, t = "default", n, r = new
|
|
1635
|
+
return e.timeoutId = Tt(e, t.expiresAt, r, i), { callbackPath: n };
|
|
1636
|
+
}, J = class t {
|
|
1637
|
+
constructor(e, t = "default", n, r = new he()) {
|
|
1634
1638
|
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;
|
|
1635
1639
|
let i = e.silent_login_uri;
|
|
1636
1640
|
e.silent_redirect_uri && !e.silent_login_uri && (i = `${e.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
|
|
1637
1641
|
let a = e.refresh_time_before_tokens_expiration_in_second ?? 120;
|
|
1638
|
-
a > 60 && (a -= Math.floor(Math.random() * 40)), this.location = r ?? new
|
|
1642
|
+
a > 60 && (a -= Math.floor(Math.random() * 40)), this.location = r ?? new he(), this.configuration = {
|
|
1639
1643
|
...e,
|
|
1640
1644
|
silent_login_uri: i,
|
|
1641
|
-
token_automatic_renew_mode: e.token_automatic_renew_mode ??
|
|
1645
|
+
token_automatic_renew_mode: e.token_automatic_renew_mode ?? K.AutomaticBeforeTokenExpiration,
|
|
1642
1646
|
monitor_session: e.monitor_session ?? !1,
|
|
1643
1647
|
refresh_time_before_tokens_expiration_in_second: a,
|
|
1644
1648
|
silent_login_timeout: e.silent_login_timeout ?? 12e3,
|
|
1645
|
-
token_renew_mode: e.token_renew_mode ??
|
|
1649
|
+
token_renew_mode: e.token_renew_mode ?? jt.access_token_or_id_token_invalid,
|
|
1646
1650
|
demonstrating_proof_of_possession: e.demonstrating_proof_of_possession ?? !1,
|
|
1647
1651
|
authority_timeout_wellknowurl_in_millisecond: e.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
1648
1652
|
logout_tokens_to_invalidate: e.logout_tokens_to_invalidate ?? ["access_token", "refresh_token"],
|
|
1649
|
-
service_worker_activate: e.service_worker_activate ??
|
|
1653
|
+
service_worker_activate: e.service_worker_activate ?? fe,
|
|
1650
1654
|
demonstrating_proof_of_possession_configuration: e.demonstrating_proof_of_possession_configuration ?? O,
|
|
1651
1655
|
preload_user_info: e.preload_user_info ?? !1,
|
|
1652
1656
|
par: e.par ?? "disabled",
|
|
1653
1657
|
par_request_timeout: e.par_request_timeout ?? 1e4
|
|
1654
|
-
}, this.getFetch = n ??
|
|
1658
|
+
}, this.getFetch = n ?? _t, this.configurationName = t, this.tokens = null, this.userInfo = null, this.events = [], this.timeoutId = null, this.resourceTokens = new mt(this), this.loginCallbackWithAutoTokensRenewAsync.bind(this), this.initAsync.bind(this), this.loginCallbackAsync.bind(this), this.subscribeEvents.bind(this), this.removeEventSubscription.bind(this), this.publishEvent.bind(this), this.destroyAsync.bind(this), this.logoutAsync.bind(this), this.renewTokensAsync.bind(this), this.renewTokensOrThrowAsync.bind(this), this.initAsync(this.configuration.authority, this.configuration.authority_configuration);
|
|
1655
1659
|
}
|
|
1656
1660
|
subscribeEvents(e) {
|
|
1657
|
-
let t =
|
|
1661
|
+
let t = ae(16);
|
|
1658
1662
|
return this.events.push({
|
|
1659
1663
|
id: t,
|
|
1660
1664
|
func: e
|
|
@@ -1670,10 +1674,10 @@ var me = () => {
|
|
|
1670
1674
|
});
|
|
1671
1675
|
}
|
|
1672
1676
|
static {
|
|
1673
|
-
this.getOrCreate = (e, t) => (n, r = "default") =>
|
|
1677
|
+
this.getOrCreate = (e, t) => (n, r = "default") => yt(e, t)(n, r);
|
|
1674
1678
|
}
|
|
1675
1679
|
static get(e = "default") {
|
|
1676
|
-
return Object.prototype.hasOwnProperty.call(
|
|
1680
|
+
return Object.prototype.hasOwnProperty.call(q, e) ? q[e] : null;
|
|
1677
1681
|
}
|
|
1678
1682
|
static getOrThrow(e = "default") {
|
|
1679
1683
|
let n = t.get(e);
|
|
@@ -1686,7 +1690,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1686
1690
|
}
|
|
1687
1691
|
_silentLoginCallbackFromIFrame(e = this.tokens, t) {
|
|
1688
1692
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1689
|
-
let n = this.location, r =
|
|
1693
|
+
let n = this.location, r = H(n.getCurrentHref());
|
|
1690
1694
|
window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({
|
|
1691
1695
|
tokens: e,
|
|
1692
1696
|
resource: t,
|
|
@@ -1696,7 +1700,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1696
1700
|
}
|
|
1697
1701
|
_silentLoginErrorCallbackFromIFrame(e = null) {
|
|
1698
1702
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1699
|
-
let t = this.location, n =
|
|
1703
|
+
let t = this.location, n = H(t.getCurrentHref());
|
|
1700
1704
|
if (n.error) {
|
|
1701
1705
|
let e = s(n.error, n.error_description, `Error from OIDC server: ${n.error} - ${n.error_description}`, "refresh");
|
|
1702
1706
|
window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({
|
|
@@ -1712,7 +1716,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1712
1716
|
}
|
|
1713
1717
|
async silentLoginCallbackAsync() {
|
|
1714
1718
|
try {
|
|
1715
|
-
let e = this.configuration.resources?.length ?
|
|
1719
|
+
let e = this.configuration.resources?.length ? nt(this.configurationName, this.location.getCurrentHref()) : void 0, t = await this.loginCallbackAsync(!0);
|
|
1716
1720
|
this._silentLoginCallbackFromIFrame(t.parsedTokens, e);
|
|
1717
1721
|
} catch (e) {
|
|
1718
1722
|
console.error(e), this._silentLoginErrorCallbackFromIFrame(e);
|
|
@@ -1721,7 +1725,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1721
1725
|
async initAsync(e, t) {
|
|
1722
1726
|
if (this.initPromise !== null) return this.initPromise;
|
|
1723
1727
|
let n = async () => {
|
|
1724
|
-
if (t != null) return new
|
|
1728
|
+
if (t != null) return new vt({
|
|
1725
1729
|
authorization_endpoint: t.authorization_endpoint,
|
|
1726
1730
|
end_session_endpoint: t.end_session_endpoint,
|
|
1727
1731
|
revocation_endpoint: t.revocation_endpoint,
|
|
@@ -1740,15 +1744,15 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1740
1744
|
});
|
|
1741
1745
|
}
|
|
1742
1746
|
async tryKeepExistingSessionAsync() {
|
|
1743
|
-
return this.tryKeepExistingSessionPromise === null ? (this.tryKeepExistingSessionPromise =
|
|
1747
|
+
return this.tryKeepExistingSessionPromise === null ? (this.tryKeepExistingSessionPromise = me(this), this.tryKeepExistingSessionPromise.finally(() => {
|
|
1744
1748
|
this.tryKeepExistingSessionPromise = null;
|
|
1745
1749
|
})) : this.tryKeepExistingSessionPromise;
|
|
1746
1750
|
}
|
|
1747
1751
|
async startCheckSessionAsync(e, t, n, r = !1) {
|
|
1748
|
-
await C(this,
|
|
1752
|
+
await C(this, q, this.configuration)(e, t, n, r);
|
|
1749
1753
|
}
|
|
1750
1754
|
async loginAsync(e = void 0, t = null, n = !1, r = void 0, i = !1) {
|
|
1751
|
-
return this.logoutPromise && await this.logoutPromise, this.loginPromise === null ? (this.loginPromise = (async () => (t?._oidc_resource === void 0 && this.configuration.resources?.length && await this.resourceTokens.clearAllAsync(), i ? S(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(t, r) :
|
|
1755
|
+
return this.logoutPromise && await this.logoutPromise, this.loginPromise === null ? (this.loginPromise = (async () => (t?._oidc_resource === void 0 && this.configuration.resources?.length && await this.resourceTokens.clearAllAsync(), i ? S(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(t, r) : at(this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this), this.location, this.getFetch)(e, t, n, r)))(), this.loginPromise.catch((e) => {
|
|
1752
1756
|
throw n && this._silentLoginErrorCallbackFromIFrame(e), e;
|
|
1753
1757
|
}).finally(() => {
|
|
1754
1758
|
this.loginPromise = null;
|
|
@@ -1757,13 +1761,13 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1757
1761
|
async loginCallbackAsync(n = !1) {
|
|
1758
1762
|
if (this.loginCallbackPromise !== null) return this.loginCallbackPromise;
|
|
1759
1763
|
let i = async () => {
|
|
1760
|
-
let i = this.configuration.resources?.length ?
|
|
1764
|
+
let i = this.configuration.resources?.length ? nt(this.configurationName, this.location.getCurrentHref()) : void 0, a = await ot(this)(n, i), o = a.tokens;
|
|
1761
1765
|
if (i !== void 0) {
|
|
1762
|
-
if (
|
|
1766
|
+
if (nt(this.configurationName, this.location.getCurrentHref()) !== i) throw new r(e.RESOURCE_TOKEN_UNAVAILABLE, "The resource authorization was cleared.", {
|
|
1763
1767
|
phase: "callback",
|
|
1764
1768
|
retryable: !1
|
|
1765
1769
|
});
|
|
1766
|
-
return await this.resourceTokens.acceptAuthorizationAsync(i, o),
|
|
1770
|
+
return await this.resourceTokens.acceptAuthorizationAsync(i, o), rt(this.configurationName, this.location.getCurrentHref()), {
|
|
1767
1771
|
parsedTokens: o,
|
|
1768
1772
|
state: a.state,
|
|
1769
1773
|
callbackPath: a.callbackPath,
|
|
@@ -1771,7 +1775,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1771
1775
|
extras: a.extras
|
|
1772
1776
|
};
|
|
1773
1777
|
}
|
|
1774
|
-
return await this.resourceTokens.clearAllAsync(), this.tokens = o, await $(this.configuration,
|
|
1778
|
+
return await this.resourceTokens.clearAllAsync(), this.tokens = o, await $(this.configuration, U(this.configurationName, i)) || g(this.configurationName, this.configuration.storage, this.configuration.login_state_storage ?? this.configuration.storage).setTokens(o), this.publishEvent(t.eventNames.token_acquired, o), this.configuration.preload_user_info && await this.userInfoAsync(), {
|
|
1775
1779
|
parsedTokens: o,
|
|
1776
1780
|
state: a.state,
|
|
1777
1781
|
callbackPath: a.callbackPath,
|
|
@@ -1785,20 +1789,20 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1785
1789
|
}
|
|
1786
1790
|
async generateDemonstrationOfProofOfPossessionAsync(e, t, n, r = {}) {
|
|
1787
1791
|
let i = this.configuration, a = {
|
|
1788
|
-
ath: await
|
|
1792
|
+
ath: await se(e),
|
|
1789
1793
|
...r
|
|
1790
1794
|
};
|
|
1791
|
-
if (await $(i, this.configurationName)) return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${
|
|
1795
|
+
if (await $(i, this.configurationName)) return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${Wt(this.configurationName)}`;
|
|
1792
1796
|
let o = g(this.configurationName, i.storage, i.login_state_storage ?? i.storage), s = await o.getDemonstratingProofOfPossessionJwkAsync(), c = o.getDemonstratingProofOfPossessionNonce();
|
|
1793
|
-
return c && (a.nonce = c), await
|
|
1797
|
+
return c && (a.nonce = c), await M(window)(i.demonstrating_proof_of_possession_configuration)(s, n, t, a);
|
|
1794
1798
|
}
|
|
1795
1799
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1796
|
-
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1800
|
+
return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise = bt(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
|
|
1797
1801
|
this.loginCallbackWithAutoTokensRenewPromise = null;
|
|
1798
1802
|
})) : this.loginCallbackWithAutoTokensRenewPromise;
|
|
1799
1803
|
}
|
|
1800
1804
|
userInfoAsync(e = !1, t = !1) {
|
|
1801
|
-
return this.userInfoPromise === null ? (this.userInfoPromise =
|
|
1805
|
+
return this.userInfoPromise === null ? (this.userInfoPromise = gt(this)(e, t), this.userInfoPromise.finally(() => {
|
|
1802
1806
|
this.userInfoPromise = null;
|
|
1803
1807
|
})) : this.userInfoPromise;
|
|
1804
1808
|
}
|
|
@@ -1806,7 +1810,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1806
1810
|
if (this.renewTokensPromise !== null) return this.renewTokensPromise;
|
|
1807
1811
|
if (!this.timeoutId) return null;
|
|
1808
1812
|
b.clearTimeout(this.timeoutId);
|
|
1809
|
-
let n =
|
|
1813
|
+
let n = Ct(this, !0, e, t);
|
|
1810
1814
|
return this.renewTokensPromise = n, n.finally(() => {
|
|
1811
1815
|
this.renewTokensPromise === n && (this.renewTokensPromise = null);
|
|
1812
1816
|
});
|
|
@@ -1824,10 +1828,10 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1824
1828
|
return i.tokens;
|
|
1825
1829
|
}
|
|
1826
1830
|
async destroyAsync(e) {
|
|
1827
|
-
return await
|
|
1831
|
+
return await ut(this)(e);
|
|
1828
1832
|
}
|
|
1829
1833
|
async clearSessionAsync() {
|
|
1830
|
-
return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise =
|
|
1834
|
+
return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise = dt(this, q)(), this.clearSessionPromise.finally(() => {
|
|
1831
1835
|
this.clearSessionPromise = null;
|
|
1832
1836
|
}));
|
|
1833
1837
|
}
|
|
@@ -1844,11 +1848,11 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1844
1848
|
}));
|
|
1845
1849
|
}
|
|
1846
1850
|
async logoutAsync(e = void 0, t = null) {
|
|
1847
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1851
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = pt(this, q, this.getFetch(), console, this.location)(e, t), this.logoutPromise.finally(() => {
|
|
1848
1852
|
this.logoutPromise = null;
|
|
1849
1853
|
}));
|
|
1850
1854
|
}
|
|
1851
|
-
},
|
|
1855
|
+
}, xt = (t, n) => {
|
|
1852
1856
|
let i = n?.oauthError === "use_dpop_nonce" ? e.DPOP_NONCE_REQUIRED : e.TOKEN_REQUEST_FAILED;
|
|
1853
1857
|
return new r(i, t, {
|
|
1854
1858
|
phase: "refresh",
|
|
@@ -1858,23 +1862,23 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1858
1862
|
oauthErrorDescription: n?.oauthErrorDescription
|
|
1859
1863
|
});
|
|
1860
1864
|
};
|
|
1861
|
-
async function
|
|
1865
|
+
async function St(e, t, n, r = null) {
|
|
1862
1866
|
let a = (t) => {
|
|
1863
1867
|
e.tokens = t;
|
|
1864
1868
|
};
|
|
1865
|
-
e.publishEvent(
|
|
1869
|
+
e.publishEvent(J.eventNames.syncTokensAsync_begin, {});
|
|
1866
1870
|
let o;
|
|
1867
1871
|
try {
|
|
1868
1872
|
o = await Dt(e)(a, 0, 0, t, n, r);
|
|
1869
1873
|
} catch (t) {
|
|
1870
|
-
throw e.publishEvent(
|
|
1874
|
+
throw e.publishEvent(J.eventNames.syncTokensAsync_error, {
|
|
1871
1875
|
message: "sync tokens error",
|
|
1872
1876
|
error: i(t) ? t : void 0,
|
|
1873
1877
|
exception: t
|
|
1874
1878
|
}), t;
|
|
1875
1879
|
}
|
|
1876
1880
|
let { tokens: s, status: c } = o;
|
|
1877
|
-
return e.publishEvent(
|
|
1881
|
+
return e.publishEvent(J.eventNames.syncTokensAsync_end, { status: c }), await $(e.configuration, e.configurationName) || g(e.configurationName, e.configuration.storage, e.configuration.login_state_storage ?? e.configuration.storage).setTokens(e.tokens), e.tokens ? {
|
|
1878
1882
|
...o,
|
|
1879
1883
|
tokens: s
|
|
1880
1884
|
} : (await e.destroyAsync(c), {
|
|
@@ -1882,30 +1886,30 @@ async function Ct(e, t, n, r = null) {
|
|
|
1882
1886
|
tokens: null
|
|
1883
1887
|
});
|
|
1884
1888
|
}
|
|
1885
|
-
async function
|
|
1889
|
+
async function Ct(e, t = !1, n = null, r = null) {
|
|
1886
1890
|
let i = e.configuration, a = `${i.client_id}_${e.configurationName}_${i.authority}`, o, s = await $(e.configuration, e.configurationName);
|
|
1887
|
-
if (i.resources?.length && e.resourceTokens) o = await e.resourceTokens.withRefreshLockAsync(() =>
|
|
1888
|
-
else if (i?.storage === window?.sessionStorage && !s || !navigator.locks) o = await
|
|
1891
|
+
if (i.resources?.length && e.resourceTokens) o = await e.resourceTokens.withRefreshLockAsync(() => St(e, t, n, r));
|
|
1892
|
+
else if (i?.storage === window?.sessionStorage && !s || !navigator.locks) o = await St(e, t, n, r);
|
|
1889
1893
|
else {
|
|
1890
1894
|
let i = "retry";
|
|
1891
|
-
for (; i === "retry";) i = await navigator.locks.request(a, { ifAvailable: !0 }, async (i) => i ? await
|
|
1895
|
+
for (; i === "retry";) i = await navigator.locks.request(a, { ifAvailable: !0 }, async (i) => i ? await St(e, t, n, r) : (e.publishEvent(J.eventNames.syncTokensAsync_lock_not_available, { lock: "lock not available" }), "retry"));
|
|
1892
1896
|
o = i;
|
|
1893
1897
|
}
|
|
1894
|
-
return o.tokens ? (e.timeoutId &&=
|
|
1898
|
+
return o.tokens ? (e.timeoutId &&= Tt(e, e.tokens.expiresAt, n, r), {
|
|
1895
1899
|
...o,
|
|
1896
1900
|
tokens: e.tokens
|
|
1897
1901
|
}) : o;
|
|
1898
1902
|
}
|
|
1899
|
-
async function
|
|
1900
|
-
return (await
|
|
1903
|
+
async function wt(e, t = !1, n = null, r = null) {
|
|
1904
|
+
return (await Ct(e, t, n, r)).tokens;
|
|
1901
1905
|
}
|
|
1902
|
-
var
|
|
1906
|
+
var Tt = (e, t, n = null, r = null) => {
|
|
1903
1907
|
let i = e.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
1904
1908
|
return e.timeoutId && b.clearTimeout(e.timeoutId), b.setTimeout(async () => {
|
|
1905
|
-
let a = { timeLeft:
|
|
1906
|
-
e.publishEvent(
|
|
1909
|
+
let a = { timeLeft: Ft(i, t) };
|
|
1910
|
+
e.publishEvent(J.eventNames.token_timer, a), await wt(e, !1, n, r);
|
|
1907
1911
|
}, 1e3);
|
|
1908
|
-
},
|
|
1912
|
+
}, Y = {
|
|
1909
1913
|
FORCE_REFRESH: "FORCE_REFRESH",
|
|
1910
1914
|
SESSION_LOST: "SESSION_LOST",
|
|
1911
1915
|
NOT_CONNECTED: "NOT_CONNECTED",
|
|
@@ -1919,7 +1923,7 @@ var q = (e, t, n = null, r = null) => {
|
|
|
1919
1923
|
let a = { nonce: null };
|
|
1920
1924
|
if (!r) return {
|
|
1921
1925
|
tokens: null,
|
|
1922
|
-
status:
|
|
1926
|
+
status: Y.NOT_CONNECTED,
|
|
1923
1927
|
nonce: a
|
|
1924
1928
|
};
|
|
1925
1929
|
let o, s = await e.initAsync(t.authority, t.authority_configuration), c = await $(t, n);
|
|
@@ -1927,39 +1931,39 @@ var q = (e, t, n = null, r = null) => {
|
|
|
1927
1931
|
let { status: e, tokens: n } = await c.initAsync(s, "syncTokensAsync", t);
|
|
1928
1932
|
if (e === "LOGGED_OUT") return {
|
|
1929
1933
|
tokens: null,
|
|
1930
|
-
status:
|
|
1934
|
+
status: Y.LOGOUT_FROM_ANOTHER_TAB,
|
|
1931
1935
|
nonce: a
|
|
1932
1936
|
};
|
|
1933
1937
|
if (e === "SESSIONS_LOST") return {
|
|
1934
1938
|
tokens: null,
|
|
1935
|
-
status:
|
|
1939
|
+
status: Y.SESSION_LOST,
|
|
1936
1940
|
nonce: a
|
|
1937
1941
|
};
|
|
1938
1942
|
if (!e || !n) return {
|
|
1939
1943
|
tokens: null,
|
|
1940
|
-
status:
|
|
1944
|
+
status: Y.REQUIRE_SYNC_TOKENS,
|
|
1941
1945
|
nonce: a
|
|
1942
1946
|
};
|
|
1943
1947
|
if (n.issuedAt !== r.issuedAt) return {
|
|
1944
1948
|
tokens: n,
|
|
1945
|
-
status:
|
|
1949
|
+
status: Ft(t.refresh_time_before_tokens_expiration_in_second, n.expiresAt) > 0 ? Y.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : Y.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
|
|
1946
1950
|
nonce: await c.getNonceAsync()
|
|
1947
1951
|
};
|
|
1948
1952
|
o = await c.getNonceAsync();
|
|
1949
1953
|
} else {
|
|
1950
1954
|
let i = g(n, t.storage ?? sessionStorage, t.login_state_storage ?? t.storage ?? sessionStorage), s = await i.initAsync(), { tokens: c } = s, { status: l } = s;
|
|
1951
|
-
if (c &&=
|
|
1955
|
+
if (c &&= Nt(c, e.tokens, t.token_renew_mode), !c) return {
|
|
1952
1956
|
tokens: null,
|
|
1953
|
-
status:
|
|
1957
|
+
status: Y.LOGOUT_FROM_ANOTHER_TAB,
|
|
1954
1958
|
nonce: a
|
|
1955
1959
|
};
|
|
1956
1960
|
if (l === "SESSIONS_LOST") return {
|
|
1957
1961
|
tokens: null,
|
|
1958
|
-
status:
|
|
1962
|
+
status: Y.SESSION_LOST,
|
|
1959
1963
|
nonce: a
|
|
1960
1964
|
};
|
|
1961
1965
|
if (c.issuedAt !== r.issuedAt) {
|
|
1962
|
-
let e =
|
|
1966
|
+
let e = Ft(t.refresh_time_before_tokens_expiration_in_second, c.expiresAt) > 0 ? Y.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : Y.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, n = await i.getNonceAsync();
|
|
1963
1967
|
return {
|
|
1964
1968
|
tokens: c,
|
|
1965
1969
|
status: e,
|
|
@@ -1968,7 +1972,7 @@ var q = (e, t, n = null, r = null) => {
|
|
|
1968
1972
|
}
|
|
1969
1973
|
o = await i.getNonceAsync();
|
|
1970
1974
|
}
|
|
1971
|
-
let l =
|
|
1975
|
+
let l = Ft(t.refresh_time_before_tokens_expiration_in_second, r.expiresAt) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
|
|
1972
1976
|
return i ? {
|
|
1973
1977
|
tokens: r,
|
|
1974
1978
|
status: "FORCE_REFRESH",
|
|
@@ -1984,11 +1988,11 @@ var q = (e, t, n = null, r = null) => {
|
|
|
1984
1988
|
status: "GIVE_UP"
|
|
1985
1989
|
};
|
|
1986
1990
|
let m = 6, h = s ? 2 : 5;
|
|
1987
|
-
for (; !navigator.onLine && m > 0;) await
|
|
1991
|
+
for (; !navigator.onLine && m > 0;) await Vt({ milliseconds: 1e3 }), m--, t.publishEvent(f.refreshTokensAsync, { message: `wait because navigator is offline try ${m}` });
|
|
1988
1992
|
let _ = document.hidden, v = _ ? a : a + 1, y = _ ? o + 1 : o;
|
|
1989
1993
|
if (a >= h || o >= 5) {
|
|
1990
1994
|
n(null);
|
|
1991
|
-
let e = p ??
|
|
1995
|
+
let e = p ?? xt("refresh token");
|
|
1992
1996
|
return t.publishEvent(f.refreshTokensAsync_error, {
|
|
1993
1997
|
message: "refresh token",
|
|
1994
1998
|
error: e
|
|
@@ -2010,7 +2014,7 @@ var q = (e, t, n = null, r = null) => {
|
|
|
2010
2014
|
let s = await S(o);
|
|
2011
2015
|
if (!s) {
|
|
2012
2016
|
n(null);
|
|
2013
|
-
let e =
|
|
2017
|
+
let e = xt("refresh token silent not active");
|
|
2014
2018
|
return t.publishEvent(f.refreshTokensAsync_error, {
|
|
2015
2019
|
message: "refresh token silent not active",
|
|
2016
2020
|
error: e
|
|
@@ -2036,7 +2040,7 @@ var q = (e, t, n = null, r = null) => {
|
|
|
2036
2040
|
error: i
|
|
2037
2041
|
};
|
|
2038
2042
|
}
|
|
2039
|
-
return n(s.tokens), t.publishEvent(
|
|
2043
|
+
return n(s.tokens), t.publishEvent(J.eventNames.token_renewed, {}), {
|
|
2040
2044
|
tokens: s.tokens,
|
|
2041
2045
|
status: "LOGGED"
|
|
2042
2046
|
};
|
|
@@ -2052,10 +2056,10 @@ var q = (e, t, n = null, r = null) => {
|
|
|
2052
2056
|
try {
|
|
2053
2057
|
let { status: i, tokens: c, nonce: l } = await Et(t)(b, t.configurationName, t.tokens, s);
|
|
2054
2058
|
switch (i) {
|
|
2055
|
-
case
|
|
2059
|
+
case Y.SESSION_LOST:
|
|
2056
2060
|
n(null);
|
|
2057
2061
|
{
|
|
2058
|
-
let e = p ??
|
|
2062
|
+
let e = p ?? xt("refresh token session lost");
|
|
2059
2063
|
return t.publishEvent(f.refreshTokensAsync_error, {
|
|
2060
2064
|
message: "refresh token session lost",
|
|
2061
2065
|
error: e
|
|
@@ -2065,28 +2069,28 @@ var q = (e, t, n = null, r = null) => {
|
|
|
2065
2069
|
error: e
|
|
2066
2070
|
};
|
|
2067
2071
|
}
|
|
2068
|
-
case
|
|
2072
|
+
case Y.NOT_CONNECTED: return n(null), {
|
|
2069
2073
|
tokens: null,
|
|
2070
2074
|
status: null
|
|
2071
2075
|
};
|
|
2072
|
-
case
|
|
2076
|
+
case Y.TOKENS_VALID: return n(c), {
|
|
2073
2077
|
tokens: c,
|
|
2074
2078
|
status: "LOGGED_IN"
|
|
2075
2079
|
};
|
|
2076
|
-
case
|
|
2080
|
+
case Y.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID: return n(c), t.publishEvent(J.eventNames.token_renewed, { reason: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" }), {
|
|
2077
2081
|
tokens: c,
|
|
2078
2082
|
status: "LOGGED_IN"
|
|
2079
2083
|
};
|
|
2080
|
-
case
|
|
2084
|
+
case Y.LOGOUT_FROM_ANOTHER_TAB: return n(null), t.publishEvent(f.logout_from_another_tab, { status: "session syncTokensAsync" }), {
|
|
2081
2085
|
tokens: null,
|
|
2082
2086
|
status: "LOGGED_OUT"
|
|
2083
2087
|
};
|
|
2084
|
-
case
|
|
2088
|
+
case Y.REQUIRE_SYNC_TOKENS: return b.token_automatic_renew_mode == K.AutomaticOnlyWhenFetchExecuted && !s ? (t.publishEvent(f.tokensInvalidAndWaitingActionsToRefresh, {}), {
|
|
2085
2089
|
tokens: t.tokens,
|
|
2086
2090
|
status: "GIVE_UP"
|
|
2087
2091
|
}) : (t.publishEvent(f.refreshTokensAsync_begin, { tryNumber: a }), await C());
|
|
2088
2092
|
default: {
|
|
2089
|
-
if (b.token_automatic_renew_mode ==
|
|
2093
|
+
if (b.token_automatic_renew_mode == K.AutomaticOnlyWhenFetchExecuted && Y.FORCE_REFRESH !== i) return t.publishEvent(f.tokensInvalidAndWaitingActionsToRefresh, {}), {
|
|
2090
2094
|
tokens: t.tokens,
|
|
2091
2095
|
status: "GIVE_UP"
|
|
2092
2096
|
};
|
|
@@ -2099,14 +2103,14 @@ var q = (e, t, n = null, r = null) => {
|
|
|
2099
2103
|
let p = b.client_id, m = b.redirect_uri, h = b.authority, _ = { ...b.token_request_extras ? b.token_request_extras : {} };
|
|
2100
2104
|
for (let [e, t] of Object.entries(u)) e.endsWith(":token_request") && (_[e.replace(":token_request", "")] = t);
|
|
2101
2105
|
return await (async () => {
|
|
2102
|
-
let i =
|
|
2106
|
+
let i = W({
|
|
2103
2107
|
client_id: p,
|
|
2104
2108
|
redirect_uri: m,
|
|
2105
2109
|
grant_type: "refresh_token",
|
|
2106
2110
|
refresh_token: c.refreshToken
|
|
2107
2111
|
}, b), a = await t.initAsync(h, b.authority_configuration), o = document.hidden ? 1e4 : 3e5, x = a.tokenEndpoint, S = {};
|
|
2108
2112
|
b.demonstrating_proof_of_possession && (S.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(c.accessToken, x, "POST"));
|
|
2109
|
-
let C = await ke(t.getFetch())(x, i,
|
|
2113
|
+
let C = await ke(t.getFetch())(x, i, W(_, b), c, S, b.token_renew_mode, o);
|
|
2110
2114
|
if (!C.success && C.oauthError === "use_dpop_nonce" && C.demonstratingProofOfPossessionNonce && b.demonstrating_proof_of_possession) {
|
|
2111
2115
|
let e = await $(b, t.configurationName);
|
|
2112
2116
|
e ? await e.setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce) : await g(t.configurationName, b.storage, b.login_state_storage ?? b.storage).setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce), S.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(c.accessToken, x, "POST"), C = await ke(t.getFetch())(x, i, _, c, S, b.token_renew_mode, o);
|
|
@@ -2114,7 +2118,7 @@ var q = (e, t, n = null, r = null) => {
|
|
|
2114
2118
|
if (C.success) {
|
|
2115
2119
|
if (!l || !l.nonce) {
|
|
2116
2120
|
n(null);
|
|
2117
|
-
let e = new P
|
|
2121
|
+
let e = new F(P.NONCE_MISSING, "refresh token: nonce missing from storage", "refresh");
|
|
2118
2122
|
return t.publishEvent(f.refreshTokensAsync_error, {
|
|
2119
2123
|
message: "refresh token: nonce missing from storage",
|
|
2120
2124
|
error: e
|
|
@@ -2124,7 +2128,7 @@ var q = (e, t, n = null, r = null) => {
|
|
|
2124
2128
|
error: e
|
|
2125
2129
|
};
|
|
2126
2130
|
}
|
|
2127
|
-
let { isValid: i, reason: o } =
|
|
2131
|
+
let { isValid: i, reason: o } = Lt(C.data, l.nonce, a);
|
|
2128
2132
|
if (!i) {
|
|
2129
2133
|
n(null);
|
|
2130
2134
|
let i = new r(o.startsWith("Nonce does not match") ? e.INVALID_NONCE : e.TOKEN_REQUEST_FAILED, `refresh token return not valid tokens, reason: ${o}`, {
|
|
@@ -2144,13 +2148,13 @@ var q = (e, t, n = null, r = null) => {
|
|
|
2144
2148
|
let e = await $(b, t.configurationName);
|
|
2145
2149
|
e ? await e.setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce) : await g(t.configurationName, b.storage, b.login_state_storage ?? b.storage).setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce);
|
|
2146
2150
|
}
|
|
2147
|
-
return t.publishEvent(f.refreshTokensAsync_end, { success: C.success }), t.publishEvent(
|
|
2151
|
+
return t.publishEvent(f.refreshTokensAsync_end, { success: C.success }), t.publishEvent(J.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), {
|
|
2148
2152
|
tokens: C.data,
|
|
2149
2153
|
status: "LOGGED_IN"
|
|
2150
2154
|
};
|
|
2151
2155
|
}
|
|
2152
2156
|
{
|
|
2153
|
-
let e =
|
|
2157
|
+
let e = xt("Token request failed", C);
|
|
2154
2158
|
return t.publishEvent(f.refreshTokensAsync_silent_error, {
|
|
2155
2159
|
message: "bad request",
|
|
2156
2160
|
tokenResponse: C,
|
|
@@ -2188,24 +2192,24 @@ var q = (e, t, n = null, r = null) => {
|
|
|
2188
2192
|
console.warn(e);
|
|
2189
2193
|
}
|
|
2190
2194
|
return null;
|
|
2191
|
-
},
|
|
2195
|
+
}, jt = {
|
|
2192
2196
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
2193
2197
|
access_token_invalid: "access_token_invalid",
|
|
2194
2198
|
id_token_invalid: "id_token_invalid"
|
|
2195
2199
|
};
|
|
2196
|
-
function
|
|
2200
|
+
function Mt(e, t, n) {
|
|
2197
2201
|
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;
|
|
2198
2202
|
}
|
|
2199
|
-
var
|
|
2203
|
+
var Nt = (e, t = null, n) => {
|
|
2200
2204
|
if (!e) return null;
|
|
2201
2205
|
let r, i = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
|
|
2202
2206
|
r = e.accessTokenPayload === void 0 ? At(e.accessToken) : e.accessTokenPayload;
|
|
2203
2207
|
let a;
|
|
2204
2208
|
a = t != null && "idToken" in t && !("idToken" in e) ? t.idToken : e.idToken;
|
|
2205
2209
|
let o = e.idTokenPayload ? e.idTokenPayload : At(a), s = o && o.exp ? o.exp : Number.MAX_VALUE, c = r && r.exp ? r.exp : e.issuedAt + i;
|
|
2206
|
-
e.issuedAt =
|
|
2210
|
+
e.issuedAt = Mt(e, r, o);
|
|
2207
2211
|
let l;
|
|
2208
|
-
l = e.expiresAt ? e.expiresAt : n ===
|
|
2212
|
+
l = e.expiresAt ? e.expiresAt : n === jt.access_token_invalid ? c : n === jt.id_token_invalid || s < c ? s : c;
|
|
2209
2213
|
let u = {
|
|
2210
2214
|
...e,
|
|
2211
2215
|
idTokenPayload: o,
|
|
@@ -2221,7 +2225,7 @@ var Mt = (e, t = null, n) => {
|
|
|
2221
2225
|
};
|
|
2222
2226
|
}
|
|
2223
2227
|
return u;
|
|
2224
|
-
},
|
|
2228
|
+
}, Pt = (e, t, n) => {
|
|
2225
2229
|
if (!e) return null;
|
|
2226
2230
|
e.issued_at ||= (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
2227
2231
|
let r = {
|
|
@@ -2232,29 +2236,29 @@ var Mt = (e, t = null, n) => {
|
|
|
2232
2236
|
tokenType: e.token_type,
|
|
2233
2237
|
issuedAt: e.issued_at
|
|
2234
2238
|
};
|
|
2235
|
-
return e.resourceContext !== void 0 && Object.assign(r, { resourceContext: e.resourceContext }), "refresh_token" in e && (r.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (r.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (r.idTokenPayload = e.idTokenPayload),
|
|
2236
|
-
},
|
|
2239
|
+
return e.resourceContext !== void 0 && Object.assign(r, { resourceContext: e.resourceContext }), "refresh_token" in e && (r.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (r.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (r.idTokenPayload = e.idTokenPayload), Nt(r, t, n);
|
|
2240
|
+
}, Ft = (e, t) => {
|
|
2237
2241
|
let n = t - (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
2238
2242
|
return Math.round(n - e);
|
|
2239
|
-
},
|
|
2243
|
+
}, X = (e, t = 0) => e ? Ft(t, e.expiresAt) > 0 : !1, It = async (e, t = 200, n = 50) => {
|
|
2240
2244
|
let r = n, i = await e.syncTokensInfoAsync();
|
|
2241
2245
|
for (; [
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2246
|
+
Y.REQUIRE_SYNC_TOKENS,
|
|
2247
|
+
Y.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
|
|
2248
|
+
Y.TOKENS_INVALID
|
|
2245
2249
|
].includes(i) && r > 0;) {
|
|
2246
|
-
if (e.configuration.token_automatic_renew_mode ==
|
|
2250
|
+
if (e.configuration.token_automatic_renew_mode == K.AutomaticOnlyWhenFetchExecuted) {
|
|
2247
2251
|
await e.renewTokensAsync({});
|
|
2248
2252
|
break;
|
|
2249
2253
|
}
|
|
2250
|
-
await
|
|
2254
|
+
await Vt({ milliseconds: t }), --r, i = await e.syncTokensInfoAsync();
|
|
2251
2255
|
}
|
|
2252
2256
|
return {
|
|
2253
|
-
isTokensValid:
|
|
2257
|
+
isTokensValid: X(e.getTokens()),
|
|
2254
2258
|
tokens: e.getTokens(),
|
|
2255
2259
|
numberWaited: r - n
|
|
2256
2260
|
};
|
|
2257
|
-
},
|
|
2261
|
+
}, Lt = (e, t, n) => {
|
|
2258
2262
|
if (e.idTokenPayload) {
|
|
2259
2263
|
let r = e.idTokenPayload;
|
|
2260
2264
|
if (n.issuer !== r.iss) return {
|
|
@@ -2280,26 +2284,26 @@ var Mt = (e, t = null, n) => {
|
|
|
2280
2284
|
isValid: !0,
|
|
2281
2285
|
reason: ""
|
|
2282
2286
|
};
|
|
2283
|
-
},
|
|
2287
|
+
}, Rt = "7.30.4", zt = null, Bt, Vt = ({ milliseconds: e }) => new Promise((t) => b.setTimeout(t, e)), Ht = (e = "/") => {
|
|
2284
2288
|
try {
|
|
2285
|
-
|
|
2289
|
+
Bt = new AbortController(), fetch(`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: Bt.signal }).catch((e) => {
|
|
2286
2290
|
console.log(e);
|
|
2287
|
-
}),
|
|
2291
|
+
}), Vt({ milliseconds: 15e4 }).then(() => Ht(e));
|
|
2288
2292
|
} catch (e) {
|
|
2289
2293
|
console.log(e);
|
|
2290
2294
|
}
|
|
2291
|
-
},
|
|
2292
|
-
|
|
2293
|
-
},
|
|
2295
|
+
}, Ut = () => {
|
|
2296
|
+
Bt && Bt.abort();
|
|
2297
|
+
}, Wt = (e) => {
|
|
2294
2298
|
Pe(e) !== void 0 && (e = e.split("#resource=")[0]);
|
|
2295
2299
|
let t = `oidc.tabId.${e}`, n = sessionStorage.getItem(t);
|
|
2296
2300
|
if (n) return n;
|
|
2297
2301
|
let r = globalThis.crypto.randomUUID();
|
|
2298
2302
|
return sessionStorage.setItem(t, r), r;
|
|
2299
|
-
},
|
|
2303
|
+
}, Gt = (e) => navigator.serviceWorker.controller ?? e.active ?? e.waiting ?? e.installing ?? null, Z = (e, t) => (n) => {
|
|
2300
2304
|
let r = t?.timeoutMs ?? 5e3;
|
|
2301
2305
|
return new Promise((t, i) => {
|
|
2302
|
-
let a =
|
|
2306
|
+
let a = Gt(e);
|
|
2303
2307
|
if (!a) {
|
|
2304
2308
|
i(/* @__PURE__ */ Error("Service worker target not available (controller/active/waiting/installing missing)"));
|
|
2305
2309
|
return;
|
|
@@ -2320,34 +2324,34 @@ var Mt = (e, t = null, n) => {
|
|
|
2320
2324
|
let e = n?.configurationName;
|
|
2321
2325
|
a.postMessage({
|
|
2322
2326
|
...n,
|
|
2323
|
-
tabId:
|
|
2327
|
+
tabId: Wt(e ?? "default")
|
|
2324
2328
|
}, [o.port2]);
|
|
2325
2329
|
} catch (e) {
|
|
2326
2330
|
c(), i(e);
|
|
2327
2331
|
}
|
|
2328
2332
|
});
|
|
2329
|
-
},
|
|
2333
|
+
}, Kt = async (e) => navigator.serviceWorker.controller ? navigator.serviceWorker.controller : new Promise((t) => {
|
|
2330
2334
|
let n = !1, r = () => {
|
|
2331
2335
|
n || (n = !0, navigator.serviceWorker.removeEventListener("controllerchange", r), t(navigator.serviceWorker.controller ?? null));
|
|
2332
2336
|
};
|
|
2333
2337
|
navigator.serviceWorker.addEventListener("controllerchange", r), b.setTimeout(() => {
|
|
2334
2338
|
n || (n = !0, navigator.serviceWorker.removeEventListener("controllerchange", r), t(navigator.serviceWorker.controller ?? null));
|
|
2335
2339
|
}, e);
|
|
2336
|
-
}),
|
|
2340
|
+
}), qt = !1, Q = !1, Jt = /* @__PURE__ */ new Map(), Yt = /* @__PURE__ */ new WeakMap(), Xt = /* @__PURE__ */ new WeakSet(), Zt = /* @__PURE__ */ new WeakSet(), Qt = 36e5, $t = (e) => e instanceof DOMException ? e.name === "AbortError" : e?.name === "AbortError", en = "oidc.sw.controllerchange_reload_count", tn = 3, nn = () => {
|
|
2337
2341
|
try {
|
|
2338
|
-
return parseInt(sessionStorage.getItem(
|
|
2342
|
+
return parseInt(sessionStorage.getItem(en) ?? "0", 10);
|
|
2339
2343
|
} catch {
|
|
2340
2344
|
return 0;
|
|
2341
2345
|
}
|
|
2342
|
-
},
|
|
2343
|
-
let e =
|
|
2346
|
+
}, rn = () => {
|
|
2347
|
+
let e = nn() + 1;
|
|
2344
2348
|
try {
|
|
2345
|
-
sessionStorage.setItem(
|
|
2349
|
+
sessionStorage.setItem(en, String(e));
|
|
2346
2350
|
} catch {}
|
|
2347
2351
|
return e;
|
|
2348
|
-
},
|
|
2352
|
+
}, an = () => {
|
|
2349
2353
|
try {
|
|
2350
|
-
sessionStorage.removeItem(
|
|
2354
|
+
sessionStorage.removeItem(en);
|
|
2351
2355
|
} catch {}
|
|
2352
2356
|
}, $ = async (t, n) => {
|
|
2353
2357
|
let i = t.service_worker_relative_url, a = Pe(n), o = n.split("#resource=")[0], s = () => {
|
|
@@ -2358,17 +2362,17 @@ var Mt = (e, t = null, n) => {
|
|
|
2358
2362
|
return null;
|
|
2359
2363
|
};
|
|
2360
2364
|
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !i || t.service_worker_activate() === !1) return s();
|
|
2361
|
-
let c = `${i}${i.includes("?") ? "&" : "?"}v=${
|
|
2362
|
-
|
|
2365
|
+
let c = `${i}${i.includes("?") ? "&" : "?"}v=${Rt}`, l = t.service_worker_register ? i : c;
|
|
2366
|
+
Jt.has(l) || Jt.set(l, t.service_worker_register ? t.service_worker_register(i) : navigator.serviceWorker.register(c, { updateViaCache: "none" }));
|
|
2363
2367
|
let u = null;
|
|
2364
2368
|
try {
|
|
2365
|
-
u = await
|
|
2369
|
+
u = await Jt.get(l);
|
|
2366
2370
|
} catch (e) {
|
|
2367
|
-
if (
|
|
2371
|
+
if ($t(e)) return Jt.delete(l), console.warn("oidc-client: service worker registration was aborted (likely tab shutdown or backgrounding); falling back to non–service-worker mode.", e), s();
|
|
2368
2372
|
throw e;
|
|
2369
2373
|
}
|
|
2370
2374
|
let d = `oidc.sw.version_mismatch_reload.${n}`, f = async (e) => {
|
|
2371
|
-
|
|
2375
|
+
Ut(), console.log("New SW waiting – SKIP_WAITING");
|
|
2372
2376
|
try {
|
|
2373
2377
|
await new Promise((t, r) => {
|
|
2374
2378
|
let i = new MessageChannel(), a = null, o = () => {
|
|
@@ -2388,7 +2392,7 @@ var Mt = (e, t = null, n) => {
|
|
|
2388
2392
|
type: "SKIP_WAITING",
|
|
2389
2393
|
configurationName: n,
|
|
2390
2394
|
data: null,
|
|
2391
|
-
tabId:
|
|
2395
|
+
tabId: Wt(n ?? "default")
|
|
2392
2396
|
}, [i.port2]);
|
|
2393
2397
|
} catch (e) {
|
|
2394
2398
|
o(), r(e);
|
|
@@ -2401,41 +2405,43 @@ var Mt = (e, t = null, n) => {
|
|
|
2401
2405
|
let e = u.waiting;
|
|
2402
2406
|
e ? await f(e) : console.warn("sendSkipWaiting called but no waiting service worker found");
|
|
2403
2407
|
}, m = (e) => {
|
|
2404
|
-
|
|
2408
|
+
Zt.has(e) || (Zt.add(e), Ut(), e.addEventListener("statechange", async () => {
|
|
2405
2409
|
if (e.state === "installed" && navigator.serviceWorker.controller) {
|
|
2406
|
-
if (
|
|
2410
|
+
if (nn() >= tn) {
|
|
2407
2411
|
console.warn("SW trackInstallingWorker: skipping SKIP_WAITING because the reload budget is exhausted");
|
|
2408
2412
|
return;
|
|
2409
2413
|
}
|
|
2410
2414
|
await f(e);
|
|
2411
2415
|
}
|
|
2412
|
-
});
|
|
2416
|
+
}));
|
|
2413
2417
|
};
|
|
2414
|
-
u.addEventListener("updatefound", () => {
|
|
2418
|
+
Xt.has(u) || (Xt.add(u), u.addEventListener("updatefound", () => {
|
|
2415
2419
|
let e = u.installing;
|
|
2416
2420
|
e && m(e);
|
|
2417
|
-
}), u.installing ? m(u.installing) : u.waiting && navigator.serviceWorker.controller && (
|
|
2421
|
+
})), u.installing ? m(u.installing) : u.waiting && navigator.serviceWorker.controller && (nn() < tn ? p() : console.warn("SW: a waiting worker exists but reload budget is exhausted – skipping activation"));
|
|
2422
|
+
let h = Date.now(), g = Yt.get(u);
|
|
2423
|
+
(g === void 0 || h - g >= Qt) && (Yt.set(u, h), u.update().catch((e) => {
|
|
2418
2424
|
console.error(e);
|
|
2419
|
-
});
|
|
2425
|
+
}));
|
|
2420
2426
|
try {
|
|
2421
2427
|
await navigator.serviceWorker.ready, navigator.serviceWorker.controller || (await Z(u, { timeoutMs: 8e3 })({
|
|
2422
2428
|
type: "claim",
|
|
2423
2429
|
configurationName: n,
|
|
2424
2430
|
data: null
|
|
2425
|
-
}), await
|
|
2431
|
+
}), await Kt(2e3));
|
|
2426
2432
|
} catch (e) {
|
|
2427
2433
|
return console.warn(`Failed init ServiceWorker ${e?.toString?.() ?? String(e)}`), s();
|
|
2428
2434
|
}
|
|
2429
|
-
|
|
2435
|
+
qt || (qt = !0, navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
2430
2436
|
if (Q) return;
|
|
2431
|
-
let e =
|
|
2432
|
-
e >
|
|
2437
|
+
let e = rn();
|
|
2438
|
+
e > tn ? console.warn(`SW controllerchange: reload budget exhausted (${e - 1} reloads). Skipping reload to avoid infinite loop.`) : (Q = !0, console.log("SW controller changed – reloading page"), Ut(), window.location.reload());
|
|
2433
2439
|
}));
|
|
2434
|
-
let
|
|
2440
|
+
let _ = async (e) => Z(u)({
|
|
2435
2441
|
type: "clear",
|
|
2436
2442
|
data: { status: e },
|
|
2437
2443
|
configurationName: n
|
|
2438
|
-
}),
|
|
2444
|
+
}), v = async (t, i, s) => {
|
|
2439
2445
|
let c = {
|
|
2440
2446
|
token_renew_mode: s.token_renew_mode,
|
|
2441
2447
|
client_id: s.client_id,
|
|
@@ -2465,137 +2471,137 @@ var Mt = (e, t = null, n) => {
|
|
|
2465
2471
|
},
|
|
2466
2472
|
configurationName: n
|
|
2467
2473
|
}), f = l.version;
|
|
2468
|
-
if (f !== "7.30.
|
|
2469
|
-
console.warn(`Service worker ${f} version mismatch with js client version ${
|
|
2474
|
+
if (f !== "7.30.4") {
|
|
2475
|
+
console.warn(`Service worker ${f} version mismatch with js client version ${Rt}, unregistering and reloading`);
|
|
2470
2476
|
let e = parseInt(sessionStorage.getItem(d) ?? "0", 10);
|
|
2471
2477
|
if (e < 3) {
|
|
2472
|
-
if (sessionStorage.setItem(d, String(e + 1)), u.waiting) return await p(), await
|
|
2478
|
+
if (sessionStorage.setItem(d, String(e + 1)), u.waiting) return await p(), await Vt({ milliseconds: 500 }), Q || (Q = !0, window.location.reload()), new Promise(() => {});
|
|
2473
2479
|
{
|
|
2474
|
-
|
|
2480
|
+
Ut();
|
|
2475
2481
|
try {
|
|
2476
2482
|
await u.update();
|
|
2477
2483
|
} catch (e) {
|
|
2478
2484
|
console.error(e);
|
|
2479
2485
|
}
|
|
2480
2486
|
let e = await u.unregister();
|
|
2481
|
-
return console.log(`Service worker unregistering ${e}`), await
|
|
2487
|
+
return console.log(`Service worker unregistering ${e}`), await Vt({ milliseconds: 500 }), Q || (Q = !0, window.location.reload()), new Promise(() => {});
|
|
2482
2488
|
}
|
|
2483
2489
|
}
|
|
2484
2490
|
console.error(`Service worker version mismatch persists after ${e} attempt(s). Continuing with mismatched version.`);
|
|
2485
|
-
} else sessionStorage.removeItem(d),
|
|
2491
|
+
} else sessionStorage.removeItem(d), an();
|
|
2486
2492
|
return {
|
|
2487
|
-
tokens:
|
|
2493
|
+
tokens: Pt(l.tokens, null, s.token_renew_mode),
|
|
2488
2494
|
status: l.status,
|
|
2489
2495
|
resourceContexts: l.resourceContexts
|
|
2490
2496
|
};
|
|
2491
|
-
},
|
|
2492
|
-
|
|
2493
|
-
},
|
|
2497
|
+
}, y = (e = "/") => {
|
|
2498
|
+
zt ?? (zt = "not_null", Ht(e));
|
|
2499
|
+
}, x = (e) => Z(u)({
|
|
2494
2500
|
type: "setSessionState",
|
|
2495
2501
|
data: { sessionState: e },
|
|
2496
2502
|
configurationName: n
|
|
2497
|
-
}),
|
|
2503
|
+
}), S = async () => (await Z(u)({
|
|
2498
2504
|
type: "getSessionState",
|
|
2499
2505
|
data: null,
|
|
2500
2506
|
configurationName: n
|
|
2501
|
-
})).sessionState,
|
|
2507
|
+
})).sessionState, C = (e) => (a === void 0 && (sessionStorage[`oidc.nonce.${n}`] = e.nonce), Z(u)({
|
|
2502
2508
|
type: "setNonce",
|
|
2503
2509
|
data: { nonce: e },
|
|
2504
2510
|
configurationName: n
|
|
2505
|
-
})),
|
|
2511
|
+
})), w = async (e = !0) => {
|
|
2506
2512
|
let t = (await Z(u)({
|
|
2507
2513
|
type: "getNonce",
|
|
2508
2514
|
data: null,
|
|
2509
2515
|
configurationName: n
|
|
2510
2516
|
})).nonce;
|
|
2511
|
-
return a === void 0 && (t || (t = sessionStorage[`oidc.nonce.${n}`], console.warn("nonce not found in service worker, using sessionStorage"), e && (await
|
|
2512
|
-
},
|
|
2513
|
-
e == null ? (delete
|
|
2514
|
-
},
|
|
2515
|
-
if (
|
|
2517
|
+
return a === void 0 && (t || (t = sessionStorage[`oidc.nonce.${n}`], console.warn("nonce not found in service worker, using sessionStorage"), e && (await C(t), t = (await w(!1)).nonce))), { nonce: t };
|
|
2518
|
+
}, T = {}, E = (e) => {
|
|
2519
|
+
e == null ? (delete T[n], delete localStorage[`oidc.login.${n}`]) : (T[n] = e, localStorage[`oidc.login.${n}`] = JSON.stringify(e));
|
|
2520
|
+
}, D = () => {
|
|
2521
|
+
if (T[n]) return T[n];
|
|
2516
2522
|
let e = localStorage[`oidc.login.${n}`];
|
|
2517
2523
|
if (typeof e != "string" || e === "" || e === "undefined" || e === "null") return null;
|
|
2518
2524
|
try {
|
|
2519
|
-
|
|
2525
|
+
T[n] = JSON.parse(e);
|
|
2520
2526
|
} catch {
|
|
2521
2527
|
return null;
|
|
2522
2528
|
}
|
|
2523
|
-
return
|
|
2524
|
-
},
|
|
2529
|
+
return T[n];
|
|
2530
|
+
}, ee = async (e) => {
|
|
2525
2531
|
await Z(u)({
|
|
2526
2532
|
type: "setDemonstratingProofOfPossessionNonce",
|
|
2527
2533
|
data: { demonstratingProofOfPossessionNonce: e },
|
|
2528
2534
|
configurationName: n
|
|
2529
2535
|
});
|
|
2530
|
-
},
|
|
2536
|
+
}, O = async () => (await Z(u)({
|
|
2531
2537
|
type: "getDemonstratingProofOfPossessionNonce",
|
|
2532
2538
|
data: null,
|
|
2533
2539
|
configurationName: n
|
|
2534
|
-
})).demonstratingProofOfPossessionNonce,
|
|
2540
|
+
})).demonstratingProofOfPossessionNonce, k = async (e) => {
|
|
2535
2541
|
let t = JSON.stringify(e);
|
|
2536
2542
|
await Z(u)({
|
|
2537
2543
|
type: "setDemonstratingProofOfPossessionJwk",
|
|
2538
2544
|
data: { demonstratingProofOfPossessionJwkJson: t },
|
|
2539
2545
|
configurationName: n
|
|
2540
2546
|
});
|
|
2541
|
-
},
|
|
2547
|
+
}, A = async () => {
|
|
2542
2548
|
let e = await Z(u)({
|
|
2543
2549
|
type: "getDemonstratingProofOfPossessionJwk",
|
|
2544
2550
|
data: null,
|
|
2545
2551
|
configurationName: n
|
|
2546
2552
|
});
|
|
2547
2553
|
return e.demonstratingProofOfPossessionJwkJson ? JSON.parse(e.demonstratingProofOfPossessionJwkJson) : null;
|
|
2548
|
-
},
|
|
2554
|
+
}, j = async (e = !0) => {
|
|
2549
2555
|
let t = (await Z(u)({
|
|
2550
2556
|
type: "getState",
|
|
2551
2557
|
data: null,
|
|
2552
2558
|
configurationName: n
|
|
2553
2559
|
})).state;
|
|
2554
|
-
return a === void 0 && (t || (t = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"), e && (await
|
|
2555
|
-
},
|
|
2560
|
+
return a === void 0 && (t || (t = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"), e && (await te(t), t = await j(!1)))), t;
|
|
2561
|
+
}, te = async (e) => (a === void 0 && (sessionStorage[`oidc.state.${n}`] = e), Z(u)({
|
|
2556
2562
|
type: "setState",
|
|
2557
2563
|
data: { state: e },
|
|
2558
2564
|
configurationName: n
|
|
2559
|
-
})),
|
|
2565
|
+
})), M = async (e = !0) => {
|
|
2560
2566
|
let t = (await Z(u)({
|
|
2561
2567
|
type: "getCodeVerifier",
|
|
2562
2568
|
data: null,
|
|
2563
2569
|
configurationName: n
|
|
2564
2570
|
})).codeVerifier;
|
|
2565
|
-
return a === void 0 && (t || (t = sessionStorage[`oidc.code_verifier.${n}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), e && (await
|
|
2566
|
-
},
|
|
2571
|
+
return a === void 0 && (t || (t = sessionStorage[`oidc.code_verifier.${n}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), e && (await N(t), t = await M(!1)))), t;
|
|
2572
|
+
}, N = async (e) => (a === void 0 && (sessionStorage[`oidc.code_verifier.${n}`] = e), Z(u)({
|
|
2567
2573
|
type: "setCodeVerifier",
|
|
2568
2574
|
data: { codeVerifier: e },
|
|
2569
2575
|
configurationName: n
|
|
2570
2576
|
}));
|
|
2571
2577
|
return {
|
|
2572
|
-
clearAsync:
|
|
2573
|
-
initAsync:
|
|
2574
|
-
startKeepAliveServiceWorker: () =>
|
|
2575
|
-
setSessionStateAsync:
|
|
2576
|
-
getSessionStateAsync:
|
|
2577
|
-
setNonceAsync:
|
|
2578
|
-
getNonceAsync:
|
|
2579
|
-
setLoginParams:
|
|
2580
|
-
getLoginParams:
|
|
2581
|
-
getStateAsync:
|
|
2582
|
-
setStateAsync:
|
|
2583
|
-
getCodeVerifierAsync:
|
|
2584
|
-
setCodeVerifierAsync:
|
|
2585
|
-
setDemonstratingProofOfPossessionNonce:
|
|
2586
|
-
getDemonstratingProofOfPossessionNonce:
|
|
2587
|
-
setDemonstratingProofOfPossessionJwkAsync:
|
|
2588
|
-
getDemonstratingProofOfPossessionJwkAsync:
|
|
2578
|
+
clearAsync: _,
|
|
2579
|
+
initAsync: v,
|
|
2580
|
+
startKeepAliveServiceWorker: () => y(t.service_worker_keep_alive_path),
|
|
2581
|
+
setSessionStateAsync: x,
|
|
2582
|
+
getSessionStateAsync: S,
|
|
2583
|
+
setNonceAsync: C,
|
|
2584
|
+
getNonceAsync: w,
|
|
2585
|
+
setLoginParams: E,
|
|
2586
|
+
getLoginParams: D,
|
|
2587
|
+
getStateAsync: j,
|
|
2588
|
+
setStateAsync: te,
|
|
2589
|
+
getCodeVerifierAsync: M,
|
|
2590
|
+
setCodeVerifierAsync: N,
|
|
2591
|
+
setDemonstratingProofOfPossessionNonce: ee,
|
|
2592
|
+
getDemonstratingProofOfPossessionNonce: O,
|
|
2593
|
+
setDemonstratingProofOfPossessionJwkAsync: k,
|
|
2594
|
+
getDemonstratingProofOfPossessionJwkAsync: A,
|
|
2589
2595
|
signalAsync: (e, t) => Z(u, t)({
|
|
2590
2596
|
...e,
|
|
2591
2597
|
configurationName: e.configurationName ?? n
|
|
2592
2598
|
})
|
|
2593
2599
|
};
|
|
2594
|
-
},
|
|
2600
|
+
}, on = async (e, t, n, r) => {
|
|
2595
2601
|
let i = await $(e, t);
|
|
2596
2602
|
if (!i) throw Error(`signalServiceWorkerAsync: no service worker registered for configuration "${t}"`);
|
|
2597
2603
|
return i.signalAsync(n, r);
|
|
2598
|
-
},
|
|
2604
|
+
}, sn = class e {
|
|
2599
2605
|
constructor(e) {
|
|
2600
2606
|
this._oidc = e;
|
|
2601
2607
|
}
|
|
@@ -2609,17 +2615,17 @@ var Mt = (e, t = null, n) => {
|
|
|
2609
2615
|
this._oidc.publishEvent(e, t);
|
|
2610
2616
|
}
|
|
2611
2617
|
static {
|
|
2612
|
-
this.getOrCreate = (t, n = new
|
|
2618
|
+
this.getOrCreate = (t, n = new he()) => (r, i = "default") => new e(J.getOrCreate(t, n)(r, i));
|
|
2613
2619
|
}
|
|
2614
2620
|
static get(t = "default") {
|
|
2615
|
-
let n =
|
|
2621
|
+
let n = J.get(t);
|
|
2616
2622
|
return n ? new e(n) : null;
|
|
2617
2623
|
}
|
|
2618
2624
|
static getOrThrow(t = "default") {
|
|
2619
|
-
return new e(
|
|
2625
|
+
return new e(J.getOrThrow(t));
|
|
2620
2626
|
}
|
|
2621
2627
|
static {
|
|
2622
|
-
this.eventNames =
|
|
2628
|
+
this.eventNames = J.eventNames;
|
|
2623
2629
|
}
|
|
2624
2630
|
tryKeepExistingSessionAsync() {
|
|
2625
2631
|
return this._oidc.tryKeepExistingSessionAsync();
|
|
@@ -2659,7 +2665,7 @@ var Mt = (e, t = null, n) => {
|
|
|
2659
2665
|
}
|
|
2660
2666
|
async getValidTokenAsync(e = 200, t = 50) {
|
|
2661
2667
|
let n = this._oidc;
|
|
2662
|
-
return
|
|
2668
|
+
return It({
|
|
2663
2669
|
getTokens: () => n.tokens,
|
|
2664
2670
|
configuration: {
|
|
2665
2671
|
token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
|
|
@@ -2685,7 +2691,7 @@ var Mt = (e, t = null, n) => {
|
|
|
2685
2691
|
return this.fetchWithTokens(t, n.demonstratingProofOfPossession ?? !1, { resource: e });
|
|
2686
2692
|
}
|
|
2687
2693
|
fetchWithTokens(e, t = !1, n = {}) {
|
|
2688
|
-
return
|
|
2694
|
+
return ht(e, this._oidc, n.demonstratingProofOfPossession ?? t, n);
|
|
2689
2695
|
}
|
|
2690
2696
|
async userInfoAsync(e = !1, t = !1) {
|
|
2691
2697
|
return this._oidc.userInfoAsync(e, t);
|
|
@@ -2694,8 +2700,7 @@ var Mt = (e, t = null, n) => {
|
|
|
2694
2700
|
return this._oidc.userInfo;
|
|
2695
2701
|
}
|
|
2696
2702
|
async signalServiceWorker(e, t) {
|
|
2697
|
-
return
|
|
2703
|
+
return on(this._oidc.configuration, this._oidc.configurationName, e, t);
|
|
2698
2704
|
}
|
|
2699
2705
|
};
|
|
2700
|
-
|
|
2701
|
-
export { Ue as DPOP_TOKEN_PLACEHOLDER_PREFIX, tn as OidcClient, r as OidcError, e as OidcErrorCode, M as OidcLocation, P as OidcStateError, N as OidcStateErrorCode, Be as PROTOCOL_VERSION, I as PushedAuthorizationRequestError, F as PushedAuthorizationRequestErrorCode, We as STORAGE_KEY_PREFIX, Ge as SW_CONTROLLER_CHANGE_RELOAD_COUNT_KEY, Ve as ServiceWorkerMessageType, He as TOKEN_PLACEHOLDERS, W as TokenAutomaticRenewMode, Y as TokenRenewMode, Je as buildDpopSecuredPlaceholder, qe as buildSecuredTokenPlaceholder, Ke as buildStorageKey, vt as getFetchDefault, V as getParseQueryStringFromLocation, Ze as getPath, i as isOidcError, ve as isOidcStateError, ye as isPushedAuthorizationRequestError, Ye as isServiceWorkerMessageType, en as signalServiceWorkerAsync };
|
|
2706
|
+
export { Ue as DPOP_TOKEN_PLACEHOLDER_PREFIX, sn as OidcClient, r as OidcError, e as OidcErrorCode, he as OidcLocation, F as OidcStateError, P as OidcStateErrorCode, Be as PROTOCOL_VERSION, L as PushedAuthorizationRequestError, I as PushedAuthorizationRequestErrorCode, We as STORAGE_KEY_PREFIX, Ge as SW_CONTROLLER_CHANGE_RELOAD_COUNT_KEY, Ve as ServiceWorkerMessageType, He as TOKEN_PLACEHOLDERS, K as TokenAutomaticRenewMode, jt as TokenRenewMode, Je as buildDpopSecuredPlaceholder, qe as buildSecuredTokenPlaceholder, Ke as buildStorageKey, _t as getFetchDefault, H as getParseQueryStringFromLocation, Ze as getPath, i as isOidcError, ve as isOidcStateError, ye as isPushedAuthorizationRequestError, Ye as isServiceWorkerMessageType, on as signalServiceWorkerAsync };
|