@axa-fr/oidc-client 7.1.0-alpha.1004 → 7.1.0-alpha.1005
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 +1 -0
- package/dist/OidcServiceWorker.js +1 -1
- package/dist/index.js +281 -283
- package/dist/index.umd.cjs +2 -2
- package/dist/initWorker.d.ts +0 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/initWorker.ts +25 -26
- package/src/types.ts +3 -0
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const F = console;
|
|
2
|
-
class
|
|
2
|
+
class ge {
|
|
3
3
|
constructor(e, t, s, i = 2e3, o = !0) {
|
|
4
4
|
this._callback = e, this._client_id = t, this._url = s, this._interval = i || 2e3, this._stopOnError = o;
|
|
5
5
|
const r = s.indexOf("/", s.indexOf("//") + 2);
|
|
@@ -53,7 +53,7 @@ const m = {
|
|
|
53
53
|
syncTokensAsync_begin: "syncTokensAsync_begin",
|
|
54
54
|
syncTokensAsync_end: "syncTokensAsync_end",
|
|
55
55
|
syncTokensAsync_error: "syncTokensAsync_error"
|
|
56
|
-
},
|
|
56
|
+
}, P = (n, e = sessionStorage) => {
|
|
57
57
|
const t = (k) => (e[`oidc.${n}`] = JSON.stringify({ tokens: null, status: k }), Promise.resolve()), s = async () => {
|
|
58
58
|
if (!e[`oidc.${n}`])
|
|
59
59
|
return e[`oidc.${n}`] = JSON.stringify({ tokens: null, status: null }), { tokens: null, status: null };
|
|
@@ -92,18 +92,18 @@ const m = {
|
|
|
92
92
|
e[`oidc.code_verifier.${n}`] = k;
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
|
-
},
|
|
95
|
+
}, ke = (n) => decodeURIComponent(Array.prototype.map.call(atob(n), (e) => "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2)).join("")), me = (n) => JSON.parse(ke(n.split(".")[1].replace("-", "+").replace("_", "/"))), Z = (n) => {
|
|
96
96
|
try {
|
|
97
|
-
return n &&
|
|
97
|
+
return n && pe(n, ".") === 2 ? me(n) : null;
|
|
98
98
|
} catch (e) {
|
|
99
99
|
console.warn(e);
|
|
100
100
|
}
|
|
101
101
|
return null;
|
|
102
|
-
},
|
|
102
|
+
}, pe = (n, e) => n.split(e).length - 1, j = {
|
|
103
103
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
104
104
|
access_token_invalid: "access_token_invalid",
|
|
105
105
|
id_token_invalid: "id_token_invalid"
|
|
106
|
-
},
|
|
106
|
+
}, ae = (n, e = null, t) => {
|
|
107
107
|
if (!n)
|
|
108
108
|
return null;
|
|
109
109
|
let s;
|
|
@@ -114,8 +114,8 @@ const m = {
|
|
|
114
114
|
const a = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
115
115
|
n.issuedAt = a;
|
|
116
116
|
}
|
|
117
|
-
n.accessTokenPayload !== void 0 ? s = n.accessTokenPayload : s =
|
|
118
|
-
const o = n.idTokenPayload ? n.idTokenPayload :
|
|
117
|
+
n.accessTokenPayload !== void 0 ? s = n.accessTokenPayload : s = Z(n.accessToken);
|
|
118
|
+
const o = n.idTokenPayload ? n.idTokenPayload : Z(n.idToken), r = o && o.exp ? o.exp : Number.MAX_VALUE, l = s && s.exp ? s.exp : n.issuedAt + i;
|
|
119
119
|
let c;
|
|
120
120
|
n.expiresAt ? c = n.expiresAt : t === j.access_token_invalid ? c = l : t === j.id_token_invalid ? c = r : c = r < l ? r : l;
|
|
121
121
|
const d = { ...n, idTokenPayload: o, accessTokenPayload: s, expiresAt: c };
|
|
@@ -124,7 +124,7 @@ const m = {
|
|
|
124
124
|
return { ...d, refreshToken: a };
|
|
125
125
|
}
|
|
126
126
|
return d;
|
|
127
|
-
},
|
|
127
|
+
}, Y = (n, e, t) => {
|
|
128
128
|
if (!n)
|
|
129
129
|
return null;
|
|
130
130
|
if (!n.issued_at) {
|
|
@@ -139,22 +139,22 @@ const m = {
|
|
|
139
139
|
tokenType: n.token_type,
|
|
140
140
|
issuedAt: n.issued_at
|
|
141
141
|
};
|
|
142
|
-
return "refresh_token" in n && (s.refreshToken = n.refresh_token), n.accessTokenPayload !== void 0 && (s.accessTokenPayload = n.accessTokenPayload), n.idTokenPayload !== void 0 && (s.idTokenPayload = n.idTokenPayload),
|
|
143
|
-
},
|
|
142
|
+
return "refresh_token" in n && (s.refreshToken = n.refresh_token), n.accessTokenPayload !== void 0 && (s.accessTokenPayload = n.accessTokenPayload), n.idTokenPayload !== void 0 && (s.idTokenPayload = n.idTokenPayload), ae(s, e, t);
|
|
143
|
+
}, V = (n, e) => {
|
|
144
144
|
const t = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
145
145
|
return Math.round(e - n - t);
|
|
146
|
-
},
|
|
146
|
+
}, G = (n) => n ? V(0, n.expiresAt) > 0 : !1, we = async (n, e = 200, t = 50) => {
|
|
147
147
|
let s = t;
|
|
148
148
|
if (!n.tokens)
|
|
149
149
|
return null;
|
|
150
|
-
for (; !
|
|
151
|
-
await
|
|
150
|
+
for (; !G(n.tokens) && s > 0; )
|
|
151
|
+
await W(e), s = s - 1;
|
|
152
152
|
return {
|
|
153
|
-
isTokensValid:
|
|
153
|
+
isTokensValid: G(n.tokens),
|
|
154
154
|
tokens: n.tokens,
|
|
155
155
|
numberWaited: s - t
|
|
156
156
|
};
|
|
157
|
-
},
|
|
157
|
+
}, ce = (n, e, t) => {
|
|
158
158
|
if (n.idTokenPayload) {
|
|
159
159
|
const s = n.idTokenPayload;
|
|
160
160
|
if (t.issuer !== s.iss)
|
|
@@ -169,44 +169,44 @@ const m = {
|
|
|
169
169
|
return { isValid: !1, reason: "Nonce does not match" };
|
|
170
170
|
}
|
|
171
171
|
return { isValid: !0, reason: "" };
|
|
172
|
-
},
|
|
172
|
+
}, M = function() {
|
|
173
173
|
const n = function() {
|
|
174
174
|
let c, d;
|
|
175
175
|
const a = (function() {
|
|
176
|
-
const
|
|
176
|
+
const f = {}, u = {
|
|
177
177
|
setTimeout: function(_, g, k) {
|
|
178
|
-
|
|
179
|
-
_.postMessage(g),
|
|
178
|
+
f[g] = setTimeout(function() {
|
|
179
|
+
_.postMessage(g), f[g] = null;
|
|
180
180
|
}, k);
|
|
181
181
|
},
|
|
182
182
|
setInterval: function(_, g, k) {
|
|
183
|
-
|
|
183
|
+
f[g] = setInterval(function() {
|
|
184
184
|
_.postMessage(g);
|
|
185
185
|
}, k);
|
|
186
186
|
},
|
|
187
187
|
clearTimeout: function(_, g) {
|
|
188
|
-
clearTimeout(
|
|
188
|
+
clearTimeout(f[g]), f[g] = null;
|
|
189
189
|
},
|
|
190
190
|
clearInterval: function(_, g) {
|
|
191
|
-
clearInterval(
|
|
191
|
+
clearInterval(f[g]), f[g] = null;
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
|
-
function
|
|
194
|
+
function y(_, g) {
|
|
195
195
|
const k = g.data[0], w = g.data[1], S = g.data[2];
|
|
196
196
|
u[k] && u[k](_, w, S);
|
|
197
197
|
}
|
|
198
198
|
this.onmessage = function(_) {
|
|
199
|
-
|
|
199
|
+
y(self, _);
|
|
200
200
|
}, this.onconnect = function(_) {
|
|
201
201
|
const g = _.ports[0];
|
|
202
202
|
g.onmessage = function(k) {
|
|
203
|
-
|
|
203
|
+
y(g, k);
|
|
204
204
|
};
|
|
205
205
|
};
|
|
206
206
|
}).toString();
|
|
207
207
|
try {
|
|
208
|
-
const
|
|
209
|
-
d = URL.createObjectURL(
|
|
208
|
+
const f = new Blob(["(", a, ")()"], { type: "application/javascript" });
|
|
209
|
+
d = URL.createObjectURL(f);
|
|
210
210
|
} catch {
|
|
211
211
|
return null;
|
|
212
212
|
}
|
|
@@ -269,7 +269,7 @@ const m = {
|
|
|
269
269
|
setInterval: r,
|
|
270
270
|
clearInterval: l
|
|
271
271
|
};
|
|
272
|
-
}(),
|
|
272
|
+
}(), ee = "7.1.0-alpha.1005", le = (n) => {
|
|
273
273
|
const e = n.appVersion, t = n.userAgent, s = "-";
|
|
274
274
|
let i = s;
|
|
275
275
|
const o = [
|
|
@@ -326,7 +326,7 @@ const m = {
|
|
|
326
326
|
osVersion: r
|
|
327
327
|
};
|
|
328
328
|
};
|
|
329
|
-
function
|
|
329
|
+
function Ae() {
|
|
330
330
|
const n = navigator.userAgent;
|
|
331
331
|
let e, t = n.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
332
332
|
if (/trident/i.test(t[1]))
|
|
@@ -344,35 +344,39 @@ function pe() {
|
|
|
344
344
|
version: t[1]
|
|
345
345
|
};
|
|
346
346
|
}
|
|
347
|
-
let
|
|
348
|
-
const
|
|
347
|
+
let ne = null;
|
|
348
|
+
const W = (n) => new Promise((e) => M.setTimeout(e, n));
|
|
349
|
+
let B;
|
|
350
|
+
const ue = () => {
|
|
349
351
|
try {
|
|
350
|
-
const e =
|
|
351
|
-
fetch(`/OidcKeepAliveServiceWorker.json?minSleepSeconds=${e}
|
|
352
|
+
const e = le(navigator).os === "Android" ? 240 : 150;
|
|
353
|
+
B = new AbortController(), fetch(`/OidcKeepAliveServiceWorker.json?minSleepSeconds=${e}`, { signal: B.signal }).catch((s) => {
|
|
352
354
|
console.log(s);
|
|
353
|
-
}),
|
|
355
|
+
}), W(e * 1e3).then(ue);
|
|
354
356
|
} catch (n) {
|
|
355
357
|
console.log(n);
|
|
356
358
|
}
|
|
357
|
-
},
|
|
359
|
+
}, te = () => {
|
|
360
|
+
B && B.abort();
|
|
361
|
+
}, ve = () => fetch("/OidcKeepAliveServiceWorker.json", {
|
|
358
362
|
headers: {
|
|
359
363
|
"oidc-vanilla": "true"
|
|
360
364
|
}
|
|
361
365
|
}).then((n) => n.statusText === "oidc-service-worker").catch((n) => {
|
|
362
366
|
console.log(n);
|
|
363
|
-
}),
|
|
367
|
+
}), Se = (n) => !!(n.os === "iOS" && n.osVersion.startsWith("12") || n.os === "Mac OS X" && n.osVersion.startsWith("10_15_6")), b = (n) => (e) => new Promise(function(t, s) {
|
|
364
368
|
const i = new MessageChannel();
|
|
365
369
|
i.port1.onmessage = function(o) {
|
|
366
370
|
o.data && o.data.error ? s(o.data.error) : t(o.data);
|
|
367
371
|
}, n.active.postMessage(e, [i.port2]);
|
|
368
|
-
}),
|
|
372
|
+
}), I = async (n, e) => {
|
|
369
373
|
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !n)
|
|
370
374
|
return null;
|
|
371
|
-
const { name: t, version: s } =
|
|
375
|
+
const { name: t, version: s } = Ae();
|
|
372
376
|
if (t === "chrome" && parseInt(s) < 90 || t === "opera" && (!s || parseInt(s.split(".")[0]) < 80) || t === "ie")
|
|
373
377
|
return null;
|
|
374
|
-
const i =
|
|
375
|
-
if (
|
|
378
|
+
const i = le(navigator);
|
|
379
|
+
if (Se(i))
|
|
376
380
|
return null;
|
|
377
381
|
const o = await navigator.serviceWorker.register(n);
|
|
378
382
|
try {
|
|
@@ -380,56 +384,50 @@ const N = (n) => new Promise((e) => V.setTimeout(e, n)), ae = () => {
|
|
|
380
384
|
} catch {
|
|
381
385
|
return null;
|
|
382
386
|
}
|
|
383
|
-
const r = async () =>
|
|
384
|
-
|
|
385
|
-
const p = o.installing;
|
|
386
|
-
p.addEventListener("statechange", () => {
|
|
387
|
-
switch (p.state) {
|
|
388
|
-
case "installed":
|
|
389
|
-
navigator.serviceWorker.controller && o.unregister().then(() => {
|
|
390
|
-
window.location.reload();
|
|
391
|
-
});
|
|
392
|
-
break;
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
const l = async (p) => b(o)({ type: "clear", data: { status: p }, configurationName: e }), c = async (p, A, v) => {
|
|
397
|
-
const I = await b(o)({
|
|
387
|
+
const r = async (p) => b(o)({ type: "clear", data: { status: p }, configurationName: e }), l = async (p, A, T) => {
|
|
388
|
+
const v = await b(o)({
|
|
398
389
|
type: "init",
|
|
399
390
|
data: {
|
|
400
391
|
oidcServerConfiguration: p,
|
|
401
392
|
where: A,
|
|
402
393
|
oidcConfiguration: {
|
|
403
|
-
token_renew_mode:
|
|
404
|
-
service_worker_convert_all_requests_to_cors:
|
|
394
|
+
token_renew_mode: T.token_renew_mode,
|
|
395
|
+
service_worker_convert_all_requests_to_cors: T.service_worker_convert_all_requests_to_cors
|
|
405
396
|
}
|
|
406
397
|
},
|
|
407
398
|
configurationName: e
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
399
|
+
}), O = v.version;
|
|
400
|
+
if (O !== ee)
|
|
401
|
+
if (console.warn(`Service worker ${O} version mismatch with js client version ${ee}, unregistering and reloading`), T.service_worker_update_require_callback)
|
|
402
|
+
await T.service_worker_update_require_callback(o, te);
|
|
403
|
+
else {
|
|
404
|
+
te(), await o.update();
|
|
405
|
+
const C = await o.unregister();
|
|
406
|
+
console.log(`Service worker unregistering ${C}`), await W(2e3), window.location.reload();
|
|
407
|
+
}
|
|
408
|
+
return { tokens: Y(v.tokens, null, T.token_renew_mode), status: v.status };
|
|
409
|
+
}, c = () => {
|
|
410
|
+
ne == null && (ne = "not_null", ue());
|
|
411
|
+
}, d = (p) => b(o)({ type: "setSessionState", data: { sessionState: p }, configurationName: e }), a = async () => (await b(o)({ type: "getSessionState", data: null, configurationName: e })).sessionState, h = (p) => (sessionStorage["oidc.nonce"] = p.nonce, b(o)({ type: "setNonce", data: { nonce: p }, configurationName: e })), f = async () => {
|
|
413
412
|
let A = (await b(o)({ type: "getNonce", data: null, configurationName: e })).nonce;
|
|
414
413
|
return A || (A = sessionStorage["oidc.nonce"], console.warn("nonce not found in service worker, using sessionStorage")), { nonce: A };
|
|
415
414
|
};
|
|
416
|
-
let
|
|
415
|
+
let u = null;
|
|
417
416
|
return {
|
|
418
|
-
clearAsync:
|
|
419
|
-
initAsync:
|
|
420
|
-
startKeepAliveServiceWorker:
|
|
421
|
-
isServiceWorkerProxyActiveAsync:
|
|
422
|
-
setSessionStateAsync:
|
|
423
|
-
getSessionStateAsync:
|
|
424
|
-
setNonceAsync:
|
|
425
|
-
getNonceAsync:
|
|
426
|
-
unregisterAsync: r,
|
|
417
|
+
clearAsync: r,
|
|
418
|
+
initAsync: l,
|
|
419
|
+
startKeepAliveServiceWorker: c,
|
|
420
|
+
isServiceWorkerProxyActiveAsync: ve,
|
|
421
|
+
setSessionStateAsync: d,
|
|
422
|
+
getSessionStateAsync: a,
|
|
423
|
+
setNonceAsync: h,
|
|
424
|
+
getNonceAsync: f,
|
|
427
425
|
setLoginParams: (p, A) => {
|
|
428
|
-
|
|
426
|
+
u = A, localStorage[`oidc.login.${p}`] = JSON.stringify(A);
|
|
429
427
|
},
|
|
430
428
|
getLoginParams: (p) => {
|
|
431
429
|
const A = localStorage[`oidc.login.${p}`];
|
|
432
|
-
return
|
|
430
|
+
return u || (u = JSON.parse(A)), u;
|
|
433
431
|
},
|
|
434
432
|
getStateAsync: async () => {
|
|
435
433
|
let A = (await b(o)({ type: "getState", data: null, configurationName: e })).state;
|
|
@@ -443,33 +441,33 @@ const N = (n) => new Promise((e) => V.setTimeout(e, n)), ae = () => {
|
|
|
443
441
|
setCodeVerifierAsync: async (p) => (sessionStorage[`oidc.code_verifier.${e}`] = p, b(o)({ type: "setCodeVerifier", data: { codeVerifier: p }, configurationName: e }))
|
|
444
442
|
};
|
|
445
443
|
};
|
|
446
|
-
async function
|
|
444
|
+
async function de(n, e, t = !1, s = null) {
|
|
447
445
|
const i = (c) => {
|
|
448
446
|
n.tokens = c;
|
|
449
447
|
}, { tokens: o, status: r } = await n.synchroniseTokensAsync(e, 0, t, s, i);
|
|
450
|
-
if (await
|
|
448
|
+
if (await I(n.configuration.service_worker_relative_url, n.configurationName) || await P(n.configurationName, n.configuration.storage).setTokens(n.tokens), !n.tokens) {
|
|
451
449
|
await n.destroyAsync(r);
|
|
452
450
|
return;
|
|
453
451
|
}
|
|
454
|
-
return n.timeoutId && (n.timeoutId =
|
|
452
|
+
return n.timeoutId && (n.timeoutId = D(n, o.refreshToken, n.tokens.expiresAt, s)), n.tokens;
|
|
455
453
|
}
|
|
456
|
-
const
|
|
454
|
+
const D = (n, e, t, s = null) => {
|
|
457
455
|
const i = n.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
458
|
-
return
|
|
459
|
-
const r = { timeLeft:
|
|
460
|
-
n.publishEvent(
|
|
456
|
+
return M.setTimeout(async () => {
|
|
457
|
+
const r = { timeLeft: V(i, t) };
|
|
458
|
+
n.publishEvent(x.eventNames.token_timer, r), await de(n, e, !1, s);
|
|
461
459
|
}, 1e3);
|
|
462
|
-
},
|
|
460
|
+
}, Q = (n, e, t) => (s = null, i = null, o = null) => {
|
|
463
461
|
if (!e.silent_redirect_uri || !e.silent_login_uri)
|
|
464
462
|
return Promise.resolve(null);
|
|
465
463
|
try {
|
|
466
464
|
t(m.silentLoginAsync_begin, {});
|
|
467
465
|
let r = "";
|
|
468
466
|
if (i && (s == null && (s = {}), s.state = i), o && (s == null && (s = {}), s.scope = o), s != null)
|
|
469
|
-
for (const [h,
|
|
470
|
-
r === "" ? r = `?${encodeURIComponent(h)}=${encodeURIComponent(
|
|
467
|
+
for (const [h, f] of Object.entries(s))
|
|
468
|
+
r === "" ? r = `?${encodeURIComponent(h)}=${encodeURIComponent(f)}` : r += `&${encodeURIComponent(h)}=${encodeURIComponent(f)}`;
|
|
471
469
|
const l = e.silent_login_uri + r, c = l.indexOf("/", l.indexOf("//") + 2), d = l.substr(0, c), a = document.createElement("iframe");
|
|
472
|
-
return a.width = "0px", a.height = "0px", a.id = `${n}_oidc_iframe`, a.setAttribute("src", l), document.body.appendChild(a), new Promise((h,
|
|
470
|
+
return a.width = "0px", a.height = "0px", a.id = `${n}_oidc_iframe`, a.setAttribute("src", l), document.body.appendChild(a), new Promise((h, f) => {
|
|
473
471
|
try {
|
|
474
472
|
let u = !1;
|
|
475
473
|
window.onmessage = (_) => {
|
|
@@ -481,27 +479,27 @@ const M = (n, e, t, s = null) => {
|
|
|
481
479
|
t(m.silentLoginAsync_end, {}), a.remove(), u = !0, h(S);
|
|
482
480
|
} else if (w.startsWith(k)) {
|
|
483
481
|
const S = JSON.parse(_.data.replace(k, ""));
|
|
484
|
-
t(m.silentLoginAsync_error, S), a.remove(), u = !0,
|
|
482
|
+
t(m.silentLoginAsync_error, S), a.remove(), u = !0, f(new Error("oidc_" + S.error));
|
|
485
483
|
}
|
|
486
484
|
}
|
|
487
485
|
}
|
|
488
486
|
};
|
|
489
|
-
const
|
|
487
|
+
const y = e.silent_login_timeout;
|
|
490
488
|
setTimeout(() => {
|
|
491
|
-
u || (t(m.silentLoginAsync_error, { reason: "timeout" }), a.remove(), u = !0,
|
|
492
|
-
},
|
|
489
|
+
u || (t(m.silentLoginAsync_error, { reason: "timeout" }), a.remove(), u = !0, f(new Error("timeout")));
|
|
490
|
+
}, y);
|
|
493
491
|
} catch (u) {
|
|
494
|
-
a.remove(), t(m.silentLoginAsync_error, u),
|
|
492
|
+
a.remove(), t(m.silentLoginAsync_error, u), f(u);
|
|
495
493
|
}
|
|
496
494
|
});
|
|
497
495
|
} catch (r) {
|
|
498
496
|
throw t(m.silentLoginAsync_error, r), r;
|
|
499
497
|
}
|
|
500
|
-
},
|
|
498
|
+
}, Te = (n, e, t, s, i) => (o = null, r = void 0) => {
|
|
501
499
|
o = { ...o };
|
|
502
|
-
const l = (d, a, h) =>
|
|
500
|
+
const l = (d, a, h) => Q(e, t, s.bind(i))(d, a, h);
|
|
503
501
|
return (async () => {
|
|
504
|
-
i.timeoutId &&
|
|
502
|
+
i.timeoutId && M.clearTimeout(i.timeoutId);
|
|
505
503
|
let d;
|
|
506
504
|
o && "state" in o && (d = o.state, delete o.state);
|
|
507
505
|
try {
|
|
@@ -510,13 +508,13 @@ const M = (n, e, t, s = null) => {
|
|
|
510
508
|
prompt: "none"
|
|
511
509
|
}, d, r);
|
|
512
510
|
if (h)
|
|
513
|
-
return i.tokens = h.tokens, s(m.token_aquired, {}), i.timeoutId =
|
|
511
|
+
return i.tokens = h.tokens, s(m.token_aquired, {}), i.timeoutId = D(i, i.tokens.refreshToken, i.tokens.expiresAt, o), {};
|
|
514
512
|
} catch (a) {
|
|
515
513
|
return a;
|
|
516
514
|
}
|
|
517
515
|
})();
|
|
518
|
-
},
|
|
519
|
-
const l = (c, d = void 0, a = void 0) =>
|
|
516
|
+
}, be = (n, e, t) => (s, i, o, r = !1) => {
|
|
517
|
+
const l = (c, d = void 0, a = void 0) => Q(n.configurationName, t, n.publishEvent.bind(n))(c, d, a);
|
|
520
518
|
return new Promise((c, d) => {
|
|
521
519
|
if (t.silent_login_uri && t.silent_redirect_uri && t.monitor_session && s && o && !r) {
|
|
522
520
|
const a = () => {
|
|
@@ -524,25 +522,25 @@ const M = (n, e, t, s = null) => {
|
|
|
524
522
|
const h = n.tokens;
|
|
525
523
|
if (h === null)
|
|
526
524
|
return;
|
|
527
|
-
const
|
|
525
|
+
const f = h.idToken, u = h.idTokenPayload;
|
|
528
526
|
return l({
|
|
529
527
|
prompt: "none",
|
|
530
|
-
id_token_hint:
|
|
528
|
+
id_token_hint: f,
|
|
531
529
|
scope: t.scope || "openid"
|
|
532
|
-
}).then((
|
|
533
|
-
const _ =
|
|
530
|
+
}).then((y) => {
|
|
531
|
+
const _ = y.tokens.idTokenPayload;
|
|
534
532
|
if (u.sub === _.sub) {
|
|
535
|
-
const g =
|
|
536
|
-
n.checkSessionIFrame.start(
|
|
533
|
+
const g = y.sessionState;
|
|
534
|
+
n.checkSessionIFrame.start(y.sessionState), u.sid === _.sid ? console.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:", g) : console.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:", g);
|
|
537
535
|
} else
|
|
538
536
|
console.debug("SessionMonitor._callback: Different subject signed into OP:", _.sub);
|
|
539
|
-
}).catch(async (
|
|
540
|
-
console.warn("SessionMonitor._callback: Silent login failed, logging out other tabs:",
|
|
537
|
+
}).catch(async (y) => {
|
|
538
|
+
console.warn("SessionMonitor._callback: Silent login failed, logging out other tabs:", y);
|
|
541
539
|
for (const [_, g] of Object.entries(e))
|
|
542
540
|
await g.logoutOtherTabAsync(t.client_id, u.sub);
|
|
543
541
|
});
|
|
544
542
|
};
|
|
545
|
-
n.checkSessionIFrame = new
|
|
543
|
+
n.checkSessionIFrame = new ge(a, i, s), n.checkSessionIFrame.load().then(() => {
|
|
546
544
|
n.checkSessionIFrame.start(o), c(n.checkSessionIFrame);
|
|
547
545
|
}).catch((h) => {
|
|
548
546
|
d(h);
|
|
@@ -551,77 +549,77 @@ const M = (n, e, t, s = null) => {
|
|
|
551
549
|
c(null);
|
|
552
550
|
});
|
|
553
551
|
};
|
|
554
|
-
var
|
|
555
|
-
for (var U = 0,
|
|
556
|
-
E[U] =
|
|
557
|
-
function
|
|
552
|
+
var Ee = Ce, E = [], se = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
553
|
+
for (var U = 0, Ie = se.length; U < Ie; ++U)
|
|
554
|
+
E[U] = se[U];
|
|
555
|
+
function Pe(n) {
|
|
558
556
|
return E[n >> 18 & 63] + E[n >> 12 & 63] + E[n >> 6 & 63] + E[n & 63];
|
|
559
557
|
}
|
|
560
|
-
function
|
|
558
|
+
function Oe(n, e, t) {
|
|
561
559
|
for (var s, i = [], o = e; o < t; o += 3)
|
|
562
|
-
s = (n[o] << 16 & 16711680) + (n[o + 1] << 8 & 65280) + (n[o + 2] & 255), i.push(
|
|
560
|
+
s = (n[o] << 16 & 16711680) + (n[o + 1] << 8 & 65280) + (n[o + 2] & 255), i.push(Pe(s));
|
|
563
561
|
return i.join("");
|
|
564
562
|
}
|
|
565
|
-
function
|
|
563
|
+
function Ce(n) {
|
|
566
564
|
for (var e, t = n.length, s = t % 3, i = [], o = 16383, r = 0, l = t - s; r < l; r += o)
|
|
567
|
-
i.push(
|
|
565
|
+
i.push(Oe(n, r, r + o > l ? l : r + o));
|
|
568
566
|
return s === 1 ? (e = n[t - 1], i.push(
|
|
569
567
|
E[e >> 2] + E[e << 4 & 63] + "=="
|
|
570
568
|
)) : s === 2 && (e = (n[t - 2] << 8) + n[t - 1], i.push(
|
|
571
569
|
E[e >> 10] + E[e >> 4 & 63] + E[e << 2 & 63] + "="
|
|
572
570
|
)), i.join("");
|
|
573
571
|
}
|
|
574
|
-
const
|
|
572
|
+
const he = () => {
|
|
575
573
|
const n = typeof window < "u" && !!window.crypto, e = n && !!window.crypto.subtle;
|
|
576
574
|
return { hasCrypto: n, hasSubtleCrypto: e };
|
|
577
|
-
},
|
|
575
|
+
}, J = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", Le = (n) => {
|
|
578
576
|
const e = [];
|
|
579
577
|
for (let t = 0; t < n.byteLength; t += 1) {
|
|
580
|
-
const s = n[t] %
|
|
581
|
-
e.push(
|
|
578
|
+
const s = n[t] % J.length;
|
|
579
|
+
e.push(J[s]);
|
|
582
580
|
}
|
|
583
581
|
return e.join("");
|
|
584
|
-
},
|
|
585
|
-
const e = new Uint8Array(n), { hasCrypto: t } =
|
|
582
|
+
}, Ne = (n) => Ee(new Uint8Array(n)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""), H = (n) => {
|
|
583
|
+
const e = new Uint8Array(n), { hasCrypto: t } = he();
|
|
586
584
|
if (t)
|
|
587
585
|
window.crypto.getRandomValues(e);
|
|
588
586
|
else
|
|
589
587
|
for (let s = 0; s < n; s += 1)
|
|
590
|
-
e[s] = Math.random() *
|
|
591
|
-
return
|
|
588
|
+
e[s] = Math.random() * J.length | 0;
|
|
589
|
+
return Le(e);
|
|
592
590
|
};
|
|
593
|
-
function
|
|
591
|
+
function We(n) {
|
|
594
592
|
const e = new ArrayBuffer(n.length), t = new Uint8Array(e);
|
|
595
593
|
for (let s = 0; s < n.length; s++)
|
|
596
594
|
t[s] = n.charCodeAt(s);
|
|
597
595
|
return t;
|
|
598
596
|
}
|
|
599
|
-
const
|
|
597
|
+
const xe = (n) => {
|
|
600
598
|
if (n.length < 43 || n.length > 128)
|
|
601
599
|
return Promise.reject(new Error("Invalid code length."));
|
|
602
|
-
const { hasSubtleCrypto: e } =
|
|
600
|
+
const { hasSubtleCrypto: e } = he();
|
|
603
601
|
return e ? new Promise((t, s) => {
|
|
604
|
-
crypto.subtle.digest("SHA-256",
|
|
602
|
+
crypto.subtle.digest("SHA-256", We(n)).then((i) => t(Ne(new Uint8Array(i))), (i) => s(i));
|
|
605
603
|
}) : Promise.reject(new Error("window.crypto.subtle is unavailable."));
|
|
606
|
-
},
|
|
607
|
-
if (
|
|
604
|
+
}, $ = {}, Fe = (n, e = window.sessionStorage, t) => {
|
|
605
|
+
if (!$[n] && e) {
|
|
608
606
|
const i = e.getItem(n);
|
|
609
|
-
i && (
|
|
607
|
+
i && ($[n] = JSON.parse(i));
|
|
610
608
|
}
|
|
611
609
|
const s = 1e3 * t;
|
|
612
|
-
return
|
|
613
|
-
},
|
|
610
|
+
return $[n] && $[n].timestamp + s > Date.now() ? $[n].result : null;
|
|
611
|
+
}, $e = (n, e, t = window.sessionStorage) => {
|
|
614
612
|
const s = Date.now();
|
|
615
|
-
|
|
616
|
-
},
|
|
617
|
-
const o = `${e}/.well-known/openid-configuration`, r = `oidc.server:${e}`, l =
|
|
613
|
+
$[n] = { result: e, timestamp: s }, t && t.setItem(n, JSON.stringify({ result: e, timestamp: s }));
|
|
614
|
+
}, Re = 60 * 60, Ve = (n) => async (e, t = Re, s = window.sessionStorage, i = 1e4) => {
|
|
615
|
+
const o = `${e}/.well-known/openid-configuration`, r = `oidc.server:${e}`, l = Fe(r, s, t);
|
|
618
616
|
if (l)
|
|
619
|
-
return new
|
|
617
|
+
return new z(l);
|
|
620
618
|
const c = await K(n)(o, {}, i);
|
|
621
619
|
if (c.status !== 200)
|
|
622
620
|
return null;
|
|
623
621
|
const d = await c.json();
|
|
624
|
-
return
|
|
622
|
+
return $e(r, d, s), new z(d);
|
|
625
623
|
}, K = (n) => async (e, t = {}, s = 1e4, i = 0) => {
|
|
626
624
|
let o;
|
|
627
625
|
try {
|
|
@@ -636,18 +634,18 @@ const Ne = (n) => {
|
|
|
636
634
|
throw console.error(r.message), r;
|
|
637
635
|
}
|
|
638
636
|
return o;
|
|
639
|
-
},
|
|
637
|
+
}, X = {
|
|
640
638
|
refresh_token: "refresh_token",
|
|
641
639
|
access_token: "access_token"
|
|
642
|
-
},
|
|
640
|
+
}, oe = (n) => async (e, t, s = X.refresh_token, i, o = 1e4) => {
|
|
643
641
|
const r = {
|
|
644
642
|
token: t,
|
|
645
643
|
token_type_hint: s,
|
|
646
644
|
client_id: i
|
|
647
645
|
}, l = [];
|
|
648
646
|
for (const a in r) {
|
|
649
|
-
const h = encodeURIComponent(a),
|
|
650
|
-
l.push(`${h}=${
|
|
647
|
+
const h = encodeURIComponent(a), f = encodeURIComponent(r[a]);
|
|
648
|
+
l.push(`${h}=${f}`);
|
|
651
649
|
}
|
|
652
650
|
const c = l.join("&");
|
|
653
651
|
return (await K(n)(e, {
|
|
@@ -659,13 +657,13 @@ const Ne = (n) => {
|
|
|
659
657
|
}, o)).status !== 200 ? { success: !1 } : {
|
|
660
658
|
success: !0
|
|
661
659
|
};
|
|
662
|
-
},
|
|
663
|
-
for (const [h,
|
|
664
|
-
t[h] === void 0 && (t[h] =
|
|
660
|
+
}, De = (n) => async (e, t, s, i, o, r = 1e4) => {
|
|
661
|
+
for (const [h, f] of Object.entries(s))
|
|
662
|
+
t[h] === void 0 && (t[h] = f);
|
|
665
663
|
const l = [];
|
|
666
664
|
for (const h in t) {
|
|
667
|
-
const
|
|
668
|
-
l.push(`${
|
|
665
|
+
const f = encodeURIComponent(h), u = encodeURIComponent(t[h]);
|
|
666
|
+
l.push(`${f}=${u}`);
|
|
669
667
|
}
|
|
670
668
|
const c = l.join("&"), d = await K(n)(e, {
|
|
671
669
|
method: "POST",
|
|
@@ -679,18 +677,18 @@ const Ne = (n) => {
|
|
|
679
677
|
const a = await d.json();
|
|
680
678
|
return {
|
|
681
679
|
success: !0,
|
|
682
|
-
data:
|
|
680
|
+
data: Y(a, i, o)
|
|
683
681
|
};
|
|
684
|
-
},
|
|
682
|
+
}, Me = (n) => async (e, t) => {
|
|
685
683
|
t = t ? { ...t } : {};
|
|
686
|
-
const s =
|
|
684
|
+
const s = H(128), i = await xe(s);
|
|
687
685
|
await n.setCodeVerifierAsync(s), await n.setStateAsync(t.state), t.code_challenge = i, t.code_challenge_method = "S256";
|
|
688
686
|
let o = "";
|
|
689
687
|
if (t)
|
|
690
688
|
for (const [r, l] of Object.entries(t))
|
|
691
689
|
o === "" ? o += "?" : o += "&", o += `${r}=${encodeURIComponent(l)}`;
|
|
692
690
|
window.location.href = `${e}${o}`;
|
|
693
|
-
},
|
|
691
|
+
}, Ke = (n) => async (e, t, s, i = 1e4) => {
|
|
694
692
|
t = t ? { ...t } : {}, t.code_verifier = await n.getCodeVerifierAsync();
|
|
695
693
|
const o = [];
|
|
696
694
|
for (const d in t) {
|
|
@@ -711,10 +709,10 @@ const Ne = (n) => {
|
|
|
711
709
|
success: !0,
|
|
712
710
|
data: {
|
|
713
711
|
state: t.state,
|
|
714
|
-
tokens:
|
|
712
|
+
tokens: Y(c, null, s)
|
|
715
713
|
}
|
|
716
714
|
};
|
|
717
|
-
},
|
|
715
|
+
}, _e = (n) => {
|
|
718
716
|
const e = n.match(
|
|
719
717
|
// eslint-disable-next-line no-useless-escape
|
|
720
718
|
/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/
|
|
@@ -736,69 +734,69 @@ const Ne = (n) => {
|
|
|
736
734
|
search: t,
|
|
737
735
|
hash: s
|
|
738
736
|
};
|
|
739
|
-
},
|
|
740
|
-
const e =
|
|
737
|
+
}, Qe = (n) => {
|
|
738
|
+
const e = _e(n);
|
|
741
739
|
let { path: t } = e;
|
|
742
740
|
t.endsWith("/") && (t = t.slice(0, -1));
|
|
743
741
|
let { hash: s } = e;
|
|
744
742
|
return s === "#_=_" && (s = ""), s && (t += s), t;
|
|
745
|
-
},
|
|
746
|
-
const e =
|
|
747
|
-
return
|
|
748
|
-
},
|
|
743
|
+
}, q = (n) => {
|
|
744
|
+
const e = _e(n), { search: t } = e;
|
|
745
|
+
return Ue(t);
|
|
746
|
+
}, Ue = (n) => {
|
|
749
747
|
const e = {};
|
|
750
748
|
let t, s, i;
|
|
751
749
|
const o = n.split("&");
|
|
752
750
|
for (s = 0, i = o.length; s < i; s++)
|
|
753
751
|
t = o[s].split("="), e[decodeURIComponent(t[0])] = decodeURIComponent(t[1]);
|
|
754
752
|
return e;
|
|
755
|
-
},
|
|
753
|
+
}, Be = (n, e, t, s, i) => (o = void 0, r = null, l = !1, c = void 0) => {
|
|
756
754
|
const d = r;
|
|
757
755
|
return r = { ...r }, (async () => {
|
|
758
|
-
const h = n.location,
|
|
759
|
-
if ("state" in r || (r.state =
|
|
756
|
+
const h = n.location, f = o || h.pathname + (h.search || "") + (h.hash || "");
|
|
757
|
+
if ("state" in r || (r.state = H(16)), s(m.loginAsync_begin, {}), r)
|
|
760
758
|
for (const u of Object.keys(r))
|
|
761
759
|
u.endsWith(":token_request") && delete r[u];
|
|
762
760
|
try {
|
|
763
761
|
const u = l ? t.silent_redirect_uri : t.redirect_uri;
|
|
764
762
|
c || (c = t.scope);
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
const _ = { nonce:
|
|
763
|
+
const y = t.extras ? { ...t.extras, ...r } : r;
|
|
764
|
+
y.nonce || (y.nonce = H(12));
|
|
765
|
+
const _ = { nonce: y.nonce }, g = await I(t.service_worker_relative_url, e), k = await i(t.authority, t.authority_configuration);
|
|
768
766
|
let w;
|
|
769
767
|
if (g)
|
|
770
|
-
g.setLoginParams(e, { callbackPath:
|
|
768
|
+
g.setLoginParams(e, { callbackPath: f, extras: d }), await g.initAsync(k, "loginAsync", t), await g.setNonceAsync(_), g.startKeepAliveServiceWorker(), w = g;
|
|
771
769
|
else {
|
|
772
|
-
const
|
|
773
|
-
|
|
770
|
+
const p = P(e, t.storage ?? sessionStorage);
|
|
771
|
+
p.setLoginParams(e, { callbackPath: f, extras: d }), await p.setNonceAsync(_), w = p;
|
|
774
772
|
}
|
|
775
773
|
const S = {
|
|
776
774
|
client_id: t.client_id,
|
|
777
775
|
redirect_uri: u,
|
|
778
776
|
scope: c,
|
|
779
777
|
response_type: "code",
|
|
780
|
-
...
|
|
778
|
+
...y
|
|
781
779
|
};
|
|
782
|
-
await
|
|
780
|
+
await Me(w)(k.authorizationEndpoint, S);
|
|
783
781
|
} catch (u) {
|
|
784
782
|
throw s(m.loginAsync_error, u), u;
|
|
785
783
|
}
|
|
786
784
|
})();
|
|
787
|
-
},
|
|
785
|
+
}, qe = (n) => async (e = !1) => {
|
|
788
786
|
try {
|
|
789
787
|
n.publishEvent(m.loginCallbackAsync_begin, {});
|
|
790
|
-
const t = n.configuration, s = t.client_id, i = e ? t.silent_redirect_uri : t.redirect_uri, o = t.authority, r = t.token_request_timeout, l = await n.initAsync(o, t.authority_configuration), d =
|
|
791
|
-
let h,
|
|
788
|
+
const t = n.configuration, s = t.client_id, i = e ? t.silent_redirect_uri : t.redirect_uri, o = t.authority, r = t.token_request_timeout, l = await n.initAsync(o, t.authority_configuration), d = q(window.location.href).session_state, a = await I(t.service_worker_relative_url, n.configurationName);
|
|
789
|
+
let h, f, u, y;
|
|
792
790
|
if (a)
|
|
793
|
-
await a.initAsync(l, "loginCallbackAsync", t), await a.setSessionStateAsync(d),
|
|
791
|
+
await a.initAsync(l, "loginCallbackAsync", t), await a.setSessionStateAsync(d), f = await a.getNonceAsync(), u = a.getLoginParams(n.configurationName), y = await a.getStateAsync(), a.startKeepAliveServiceWorker(), h = a;
|
|
794
792
|
else {
|
|
795
|
-
const v =
|
|
796
|
-
await v.setSessionStateAsync(d),
|
|
793
|
+
const v = P(n.configurationName, t.storage ?? sessionStorage);
|
|
794
|
+
await v.setSessionStateAsync(d), f = await v.getNonceAsync(), u = v.getLoginParams(n.configurationName), y = await v.getStateAsync(), h = v;
|
|
797
795
|
}
|
|
798
|
-
const _ =
|
|
796
|
+
const _ = q(window.location.toString());
|
|
799
797
|
if (_.iss && _.iss !== l.issuer)
|
|
800
798
|
throw new Error("issuer not valid");
|
|
801
|
-
if (_.state && _.state !==
|
|
799
|
+
if (_.state && _.state !== y)
|
|
802
800
|
throw new Error("state not valid");
|
|
803
801
|
const g = {
|
|
804
802
|
code: _.code,
|
|
@@ -807,81 +805,81 @@ const Ne = (n) => {
|
|
|
807
805
|
redirect_uri: i
|
|
808
806
|
}, k = {};
|
|
809
807
|
if (t.token_request_extras)
|
|
810
|
-
for (const [v,
|
|
811
|
-
k[v] =
|
|
808
|
+
for (const [v, O] of Object.entries(t.token_request_extras))
|
|
809
|
+
k[v] = O;
|
|
812
810
|
if (u && u.extras)
|
|
813
|
-
for (const [v,
|
|
814
|
-
v.endsWith(":token_request") && (k[v.replace(":token_request", "")] =
|
|
815
|
-
const w = await
|
|
811
|
+
for (const [v, O] of Object.entries(u.extras))
|
|
812
|
+
v.endsWith(":token_request") && (k[v.replace(":token_request", "")] = O);
|
|
813
|
+
const w = await Ke(h)(l.tokenEndpoint, { ...g, ...k }, n.configuration.token_renew_mode, r);
|
|
816
814
|
if (!w.success)
|
|
817
815
|
throw new Error("Token request failed");
|
|
818
816
|
let S;
|
|
819
|
-
const
|
|
820
|
-
if (a ? (await a.initAsync(i, "syncTokensAsync", t), S = a.getLoginParams(n.configurationName)) : S =
|
|
817
|
+
const p = w.data.tokens;
|
|
818
|
+
if (a ? (await a.initAsync(i, "syncTokensAsync", t), S = a.getLoginParams(n.configurationName)) : S = P(n.configurationName, t.storage).getLoginParams(n.configurationName), w.data.state !== k.state)
|
|
821
819
|
throw new Error("state is not valid");
|
|
822
|
-
const { isValid:
|
|
823
|
-
if (!
|
|
824
|
-
throw new Error(`Tokens are not OpenID valid, reason: ${
|
|
820
|
+
const { isValid: A, reason: T } = ce(p, f.nonce, l);
|
|
821
|
+
if (!A)
|
|
822
|
+
throw new Error(`Tokens are not OpenID valid, reason: ${T}`);
|
|
825
823
|
return await n.startCheckSessionAsync(l.checkSessionIframe, s, d, e), n.publishEvent(m.loginCallbackAsync_end, {}), {
|
|
826
|
-
tokens:
|
|
824
|
+
tokens: p,
|
|
827
825
|
state: "request.state",
|
|
828
826
|
callbackPath: S.callbackPath
|
|
829
827
|
};
|
|
830
828
|
} catch (t) {
|
|
831
829
|
throw console.error(t), n.publishEvent(m.loginCallbackAsync_error, t), t;
|
|
832
830
|
}
|
|
833
|
-
},
|
|
831
|
+
}, ie = {
|
|
834
832
|
access_token: "access_token",
|
|
835
833
|
refresh_token: "refresh_token"
|
|
836
|
-
},
|
|
837
|
-
|
|
838
|
-
const t = await
|
|
839
|
-
t ? await t.clearAsync(e) : await
|
|
840
|
-
},
|
|
834
|
+
}, je = (n) => async (e) => {
|
|
835
|
+
M.clearTimeout(n.timeoutId), n.timeoutId = null, n.checkSessionIFrame && n.checkSessionIFrame.stop();
|
|
836
|
+
const t = await I(n.configuration.service_worker_relative_url, n.configurationName);
|
|
837
|
+
t ? await t.clearAsync(e) : await P(n.configurationName, n.configuration.storage).clearAsync(e), n.tokens = null, n.userInfo = null;
|
|
838
|
+
}, Ge = (n, e, t, s, i) => async (o = void 0, r = null) => {
|
|
841
839
|
const l = n.configuration, c = await n.initAsync(l.authority, l.authority_configuration);
|
|
842
840
|
o && typeof o != "string" && (o = void 0, i.warn("callbackPathOrUrl path is not a string"));
|
|
843
841
|
const d = o ?? location.pathname + (location.search || "") + (location.hash || "");
|
|
844
842
|
let a = !1;
|
|
845
843
|
o && (a = o.includes("https://") || o.includes("http://"));
|
|
846
|
-
const h = a ? o : s.location.origin + d,
|
|
844
|
+
const h = a ? o : s.location.origin + d, f = n.tokens ? n.tokens.idToken : "";
|
|
847
845
|
try {
|
|
848
|
-
const
|
|
849
|
-
if (
|
|
846
|
+
const y = c.revocationEndpoint;
|
|
847
|
+
if (y) {
|
|
850
848
|
const _ = [], g = n.tokens.accessToken;
|
|
851
|
-
if (g && l.logout_tokens_to_invalidate.includes(
|
|
852
|
-
const w =
|
|
849
|
+
if (g && l.logout_tokens_to_invalidate.includes(ie.access_token)) {
|
|
850
|
+
const w = oe(t)(y, g, X.access_token, l.client_id);
|
|
853
851
|
_.push(w);
|
|
854
852
|
}
|
|
855
853
|
const k = n.tokens.refreshToken;
|
|
856
|
-
if (k && l.logout_tokens_to_invalidate.includes(
|
|
857
|
-
const w =
|
|
854
|
+
if (k && l.logout_tokens_to_invalidate.includes(ie.refresh_token)) {
|
|
855
|
+
const w = oe(t)(y, k, X.refresh_token, l.client_id);
|
|
858
856
|
_.push(w);
|
|
859
857
|
}
|
|
860
858
|
_.length > 0 && await Promise.all(_);
|
|
861
859
|
}
|
|
862
|
-
} catch (
|
|
863
|
-
i.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"), i.warn(
|
|
860
|
+
} catch (y) {
|
|
861
|
+
i.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"), i.warn(y);
|
|
864
862
|
}
|
|
865
863
|
const u = n.tokens && n.tokens.idTokenPayload ? n.tokens.idTokenPayload.sub : null;
|
|
866
864
|
await n.destroyAsync("LOGGED_OUT");
|
|
867
|
-
for (const [
|
|
865
|
+
for (const [y, _] of Object.entries(e))
|
|
868
866
|
_ !== n && await n.logoutSameTabAsync(n.configuration.client_id, u);
|
|
869
867
|
if (c.endSessionEndpoint) {
|
|
870
868
|
r || (r = {
|
|
871
|
-
id_token_hint:
|
|
869
|
+
id_token_hint: f
|
|
872
870
|
}, o !== null && (r.post_logout_redirect_uri = h));
|
|
873
|
-
let
|
|
871
|
+
let y = "";
|
|
874
872
|
if (r)
|
|
875
873
|
for (const [_, g] of Object.entries(r))
|
|
876
|
-
|
|
877
|
-
s.location.href = `${c.endSessionEndpoint}${
|
|
874
|
+
y === "" ? y += "?" : y += "&", y += `${_}=${encodeURIComponent(g)}`;
|
|
875
|
+
s.location.href = `${c.endSessionEndpoint}${y}`;
|
|
878
876
|
} else
|
|
879
877
|
s.location.reload();
|
|
880
|
-
},
|
|
878
|
+
}, Je = (n) => async (e = !1) => {
|
|
881
879
|
if (n.userInfo != null && !e)
|
|
882
880
|
return n.userInfo;
|
|
883
|
-
for (; n.tokens && !
|
|
884
|
-
await
|
|
881
|
+
for (; n.tokens && !G(n.tokens); )
|
|
882
|
+
await W(200);
|
|
885
883
|
if (!n.tokens)
|
|
886
884
|
return null;
|
|
887
885
|
const t = n.tokens.accessToken;
|
|
@@ -896,16 +894,16 @@ const Ne = (n) => {
|
|
|
896
894
|
return c.status !== 200 ? null : c.json();
|
|
897
895
|
})(t);
|
|
898
896
|
return n.userInfo = r, r;
|
|
899
|
-
},
|
|
900
|
-
class
|
|
897
|
+
}, He = () => fetch;
|
|
898
|
+
class z {
|
|
901
899
|
constructor(e) {
|
|
902
900
|
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;
|
|
903
901
|
}
|
|
904
902
|
}
|
|
905
|
-
const
|
|
903
|
+
const N = {}, Xe = (n) => (e, t = "default") => (N[t] || (N[t] = new x(e, t, n)), N[t]), ze = async (n) => {
|
|
906
904
|
const { parsedTokens: e, callbackPath: t } = await n.loginCallbackAsync();
|
|
907
|
-
return n.timeoutId =
|
|
908
|
-
},
|
|
905
|
+
return n.timeoutId = D(n, e.refreshToken, e.expiresAt), { callbackPath: t };
|
|
906
|
+
}, Ye = (n) => Math.floor(Math.random() * n), L = class L {
|
|
909
907
|
constructor(e, t = "default", s) {
|
|
910
908
|
this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.logoutPromise = null;
|
|
911
909
|
let i = e.silent_login_uri;
|
|
@@ -918,10 +916,10 @@ const L = {}, Je = (n) => (e, t = "default") => (L[t] || (L[t] = new W(e, t, n))
|
|
|
918
916
|
refresh_time_before_tokens_expiration_in_second: o,
|
|
919
917
|
silent_login_timeout: e.silent_login_timeout ?? 12e3,
|
|
920
918
|
token_renew_mode: e.token_renew_mode ?? j.access_token_or_id_token_invalid
|
|
921
|
-
}, this.getFetch = s ??
|
|
919
|
+
}, this.getFetch = s ?? He, this.configurationName = t, this.tokens = null, this.userInfo = null, this.events = [], this.timeoutId = null, this.synchroniseTokensAsync.bind(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.initAsync(this.configuration.authority, this.configuration.authority_configuration);
|
|
922
920
|
}
|
|
923
921
|
subscribeEvents(e) {
|
|
924
|
-
const t =
|
|
922
|
+
const t = Ye(9999999999999).toString();
|
|
925
923
|
return this.events.push({ id: t, func: e }), t;
|
|
926
924
|
}
|
|
927
925
|
removeEventSubscription(e) {
|
|
@@ -935,20 +933,20 @@ const L = {}, Je = (n) => (e, t = "default") => (L[t] || (L[t] = new W(e, t, n))
|
|
|
935
933
|
}
|
|
936
934
|
static get(e = "default") {
|
|
937
935
|
const t = typeof process > "u";
|
|
938
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
936
|
+
if (!Object.prototype.hasOwnProperty.call(N, e) && t)
|
|
939
937
|
throw Error(`OIDC library does seem initialized.
|
|
940
938
|
Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${e}"></OidcProvider> compoment.`);
|
|
941
|
-
return
|
|
939
|
+
return N[e];
|
|
942
940
|
}
|
|
943
941
|
_silentLoginCallbackFromIFrame() {
|
|
944
942
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
945
|
-
const e =
|
|
943
|
+
const e = q(window.location.href);
|
|
946
944
|
window.top.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState: e.session_state })}`, window.location.origin);
|
|
947
945
|
}
|
|
948
946
|
}
|
|
949
947
|
_silentLoginErrorCallbackFromIFrame() {
|
|
950
948
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
951
|
-
const e =
|
|
949
|
+
const e = q(window.location.href);
|
|
952
950
|
window.top.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({ error: e.error })}`, window.location.origin);
|
|
953
951
|
}
|
|
954
952
|
}
|
|
@@ -964,7 +962,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
964
962
|
return this.initPromise;
|
|
965
963
|
const s = async () => {
|
|
966
964
|
if (t != null)
|
|
967
|
-
return new
|
|
965
|
+
return new z({
|
|
968
966
|
authorization_endpoint: t.authorization_endpoint,
|
|
969
967
|
end_session_endpoint: t.end_session_endpoint,
|
|
970
968
|
revocation_endpoint: t.revocation_endpoint,
|
|
@@ -973,8 +971,8 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
973
971
|
check_session_iframe: t.check_session_iframe,
|
|
974
972
|
issuer: t.issuer
|
|
975
973
|
});
|
|
976
|
-
const o = await
|
|
977
|
-
return await
|
|
974
|
+
const o = await I(this.configuration.service_worker_relative_url, this.configurationName) ? window.localStorage : null;
|
|
975
|
+
return await Ve(this.getFetch())(e, this.configuration.authority_time_cache_wellknowurl_in_second ?? 60 * 60, o, this.configuration.authority_timeout_wellknowurl_in_millisecond);
|
|
978
976
|
};
|
|
979
977
|
return this.initPromise = s(), this.initPromise.then((i) => (this.initPromise = null, i));
|
|
980
978
|
}
|
|
@@ -988,12 +986,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
988
986
|
this.publishEvent(m.tryKeepExistingSessionAsync_begin, {});
|
|
989
987
|
try {
|
|
990
988
|
const s = this.configuration, i = await this.initAsync(s.authority, s.authority_configuration);
|
|
991
|
-
if (t = await
|
|
989
|
+
if (t = await I(s.service_worker_relative_url, this.configurationName), t) {
|
|
992
990
|
const { tokens: o } = await t.initAsync(i, "tryKeepExistingSessionAsync", s);
|
|
993
991
|
if (o) {
|
|
994
992
|
t.startKeepAliveServiceWorker(), this.tokens = o;
|
|
995
993
|
const r = t.getLoginParams(this.configurationName);
|
|
996
|
-
this.timeoutId =
|
|
994
|
+
this.timeoutId = D(this, this.tokens.refreshToken, this.tokens.expiresAt, r.extras);
|
|
997
995
|
const l = await t.getSessionStateAsync();
|
|
998
996
|
return await this.startCheckSessionAsync(i.check_session_iframe, s.client_id, l), this.publishEvent(m.tryKeepExistingSessionAsync_end, {
|
|
999
997
|
success: !0,
|
|
@@ -1008,11 +1006,11 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1008
1006
|
s.service_worker_relative_url && this.publishEvent(m.service_worker_not_supported_by_browser, {
|
|
1009
1007
|
message: "service worker is not supported by this browser"
|
|
1010
1008
|
});
|
|
1011
|
-
const o =
|
|
1009
|
+
const o = P(this.configurationName, s.storage ?? sessionStorage), { tokens: r } = await o.initAsync();
|
|
1012
1010
|
if (r) {
|
|
1013
|
-
this.tokens =
|
|
1011
|
+
this.tokens = ae(r, null, s.token_renew_mode);
|
|
1014
1012
|
const l = o.getLoginParams(this.configurationName);
|
|
1015
|
-
this.timeoutId =
|
|
1013
|
+
this.timeoutId = D(this, r.refreshToken, this.tokens.expiresAt, l.extras);
|
|
1016
1014
|
const c = await o.getSessionStateAsync();
|
|
1017
1015
|
return await this.startCheckSessionAsync(i.check_session_iframe, s.client_id, c), this.publishEvent(m.tryKeepExistingSessionAsync_end, {
|
|
1018
1016
|
success: !0,
|
|
@@ -1031,43 +1029,43 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1031
1029
|
return this.tryKeepExistingSessionPromise = e(), this.tryKeepExistingSessionPromise.then((t) => (this.tryKeepExistingSessionPromise = null, t));
|
|
1032
1030
|
}
|
|
1033
1031
|
async startCheckSessionAsync(e, t, s, i = !1) {
|
|
1034
|
-
await
|
|
1032
|
+
await be(this, N, this.configuration)(e, t, s, i);
|
|
1035
1033
|
}
|
|
1036
1034
|
async loginAsync(e = void 0, t = null, s = !1, i = void 0, o = !1) {
|
|
1037
|
-
return this.loginPromise !== null ? this.loginPromise : o ?
|
|
1035
|
+
return this.loginPromise !== null ? this.loginPromise : o ? Te(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(t, i) : (this.loginPromise = Be(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this))(e, t, s, i), this.loginPromise.then((r) => (this.loginPromise = null, r)));
|
|
1038
1036
|
}
|
|
1039
1037
|
async loginCallbackAsync(e = !1) {
|
|
1040
1038
|
if (this.loginCallbackPromise !== null)
|
|
1041
1039
|
return this.loginCallbackPromise;
|
|
1042
1040
|
const t = async () => {
|
|
1043
|
-
const s = await
|
|
1044
|
-
return this.tokens = i, await
|
|
1041
|
+
const s = await qe(this)(e), i = s.tokens;
|
|
1042
|
+
return this.tokens = i, await I(this.configuration.service_worker_relative_url, this.configurationName) || P(this.configurationName, this.configuration.storage).setTokens(i), this.publishEvent(L.eventNames.token_aquired, i), { parsedTokens: i, state: s.state, callbackPath: s.callbackPath };
|
|
1045
1043
|
};
|
|
1046
1044
|
return this.loginCallbackPromise = t(), this.loginCallbackPromise.then((s) => (this.loginCallbackPromise = null, s));
|
|
1047
1045
|
}
|
|
1048
1046
|
async synchroniseTokensAsync(e, t = 0, s = !1, i = null, o) {
|
|
1049
1047
|
for (; !navigator.onLine && document.hidden; )
|
|
1050
|
-
await
|
|
1048
|
+
await W(1e3), this.publishEvent(m.refreshTokensAsync, { message: "wait because navigator is offline and hidden" });
|
|
1051
1049
|
let r = 6;
|
|
1052
1050
|
for (; !navigator.onLine && r > 0; )
|
|
1053
|
-
await
|
|
1051
|
+
await W(1e3), r--, this.publishEvent(m.refreshTokensAsync, { message: `wait because navigator is offline try ${r}` });
|
|
1054
1052
|
let l = Math.floor(Math.random() * 15) + 10;
|
|
1055
1053
|
for (; document.hidden && l > 0; )
|
|
1056
|
-
await
|
|
1054
|
+
await W(1e3), l--, this.publishEvent(m.refreshTokensAsync, { message: `wait because navigator is hidden try ${l}` });
|
|
1057
1055
|
const d = document.hidden ? t : t + 1;
|
|
1058
1056
|
i || (i = {});
|
|
1059
|
-
const a = this.configuration, h = (u,
|
|
1057
|
+
const a = this.configuration, h = (u, y, _ = null) => Q(this.configurationName, this.configuration, this.publishEvent.bind(this))(u, y, _), f = async () => {
|
|
1060
1058
|
try {
|
|
1061
1059
|
let u;
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1060
|
+
const y = await I(a.service_worker_relative_url, this.configurationName);
|
|
1061
|
+
y ? u = y.getLoginParams(this.configurationName) : u = P(this.configurationName, a.storage).getLoginParams(this.configurationName);
|
|
1064
1062
|
const _ = await h({
|
|
1065
1063
|
...u.extras,
|
|
1066
1064
|
...i,
|
|
1067
1065
|
prompt: "none"
|
|
1068
1066
|
}, u.state);
|
|
1069
1067
|
if (_)
|
|
1070
|
-
return o(_.tokens), this.publishEvent(
|
|
1068
|
+
return o(_.tokens), this.publishEvent(L.eventNames.token_renewed, {}), { tokens: _.tokens, status: "LOGGED" };
|
|
1071
1069
|
} catch (u) {
|
|
1072
1070
|
if (console.error(u), this.publishEvent(m.refreshTokensAsync_silent_error, { message: "exceptionSilent", exception: u.message }), u && u.message && u.message.startsWith("oidc"))
|
|
1073
1071
|
return o(null), this.publishEvent(m.refreshTokensAsync_error, { message: "refresh token silent" }), { tokens: null, status: "SESSION_LOST" };
|
|
@@ -1077,40 +1075,40 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1077
1075
|
if (t > 4)
|
|
1078
1076
|
return o(null), this.publishEvent(m.refreshTokensAsync_error, { message: "refresh token" }), { tokens: null, status: "SESSION_LOST" };
|
|
1079
1077
|
try {
|
|
1080
|
-
const { status: u, tokens:
|
|
1078
|
+
const { status: u, tokens: y, nonce: _ } = await this.syncTokensInfoAsync(a, this.configurationName, this.tokens, s);
|
|
1081
1079
|
switch (u) {
|
|
1082
1080
|
case "SESSION_LOST":
|
|
1083
1081
|
return o(null), this.publishEvent(m.refreshTokensAsync_error, { message: "refresh token session lost" }), { tokens: null, status: "SESSION_LOST" };
|
|
1084
1082
|
case "NOT_CONNECTED":
|
|
1085
1083
|
return o(null), { tokens: null, status: null };
|
|
1086
1084
|
case "TOKENS_VALID":
|
|
1087
|
-
return o(
|
|
1085
|
+
return o(y), { tokens: y, status: "LOGGED_IN" };
|
|
1088
1086
|
case "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID":
|
|
1089
|
-
return o(
|
|
1087
|
+
return o(y), this.publishEvent(L.eventNames.token_renewed, { reason: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" }), { tokens: y, status: "LOGGED_IN" };
|
|
1090
1088
|
case "LOGOUT_FROM_ANOTHER_TAB":
|
|
1091
1089
|
return o(null), this.publishEvent(m.logout_from_another_tab, { status: "session syncTokensAsync" }), { tokens: null, status: "LOGGED_OUT" };
|
|
1092
1090
|
case "REQUIRE_SYNC_TOKENS":
|
|
1093
|
-
return this.publishEvent(m.refreshTokensAsync_begin, { refreshToken: e, status: u, tryNumber: t }), await
|
|
1091
|
+
return this.publishEvent(m.refreshTokensAsync_begin, { refreshToken: e, status: u, tryNumber: t }), await f();
|
|
1094
1092
|
default: {
|
|
1095
1093
|
if (this.publishEvent(m.refreshTokensAsync_begin, { refreshToken: e, status: u, tryNumber: t }), !e)
|
|
1096
|
-
return await
|
|
1097
|
-
const g = a.client_id, k = a.redirect_uri, w = a.authority,
|
|
1098
|
-
for (const [
|
|
1099
|
-
|
|
1094
|
+
return await f();
|
|
1095
|
+
const g = a.client_id, k = a.redirect_uri, w = a.authority, p = { ...a.token_request_extras ? a.token_request_extras : {} };
|
|
1096
|
+
for (const [T, v] of Object.entries(i))
|
|
1097
|
+
T.endsWith(":token_request") && (p[T.replace(":token_request", "")] = v);
|
|
1100
1098
|
return await (async () => {
|
|
1101
|
-
const
|
|
1099
|
+
const T = {
|
|
1102
1100
|
client_id: g,
|
|
1103
1101
|
redirect_uri: k,
|
|
1104
1102
|
grant_type: "refresh_token",
|
|
1105
|
-
refresh_token:
|
|
1106
|
-
}, v = await this.initAsync(w, a.authority_configuration),
|
|
1107
|
-
if (
|
|
1108
|
-
const { isValid:
|
|
1109
|
-
return
|
|
1103
|
+
refresh_token: y.refreshToken
|
|
1104
|
+
}, v = await this.initAsync(w, a.authority_configuration), O = document.hidden ? 1e4 : 3e4 * 10, C = await De(this.getFetch())(v.tokenEndpoint, T, p, y, a.token_renew_mode, O);
|
|
1105
|
+
if (C.success) {
|
|
1106
|
+
const { isValid: fe, reason: ye } = ce(C.data, _.nonce, v);
|
|
1107
|
+
return fe ? (o(C.data), this.publishEvent(m.refreshTokensAsync_end, { success: C.success }), this.publishEvent(L.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), { tokens: C.data, status: "LOGGED_IN" }) : (o(null), this.publishEvent(m.refreshTokensAsync_error, { message: `refresh token return not valid tokens, reason: ${ye}` }), { tokens: null, status: "SESSION_LOST" });
|
|
1110
1108
|
} else
|
|
1111
1109
|
return this.publishEvent(m.refreshTokensAsync_silent_error, {
|
|
1112
1110
|
message: "bad request",
|
|
1113
|
-
tokenResponse:
|
|
1111
|
+
tokenResponse: C
|
|
1114
1112
|
}), await this.synchroniseTokensAsync(e, d, s, i, o);
|
|
1115
1113
|
})();
|
|
1116
1114
|
}
|
|
@@ -1124,50 +1122,50 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1124
1122
|
if (!s)
|
|
1125
1123
|
return { tokens: null, status: "NOT_CONNECTED", nonce: o };
|
|
1126
1124
|
let r = o;
|
|
1127
|
-
const l = await this.initAsync(e.authority, e.authority_configuration), c = await
|
|
1125
|
+
const l = await this.initAsync(e.authority, e.authority_configuration), c = await I(e.service_worker_relative_url, t);
|
|
1128
1126
|
if (c) {
|
|
1129
|
-
const { status: h, tokens:
|
|
1127
|
+
const { status: h, tokens: f } = await c.initAsync(l, "syncTokensAsync", e);
|
|
1130
1128
|
if (h === "LOGGED_OUT")
|
|
1131
1129
|
return { tokens: null, status: "LOGOUT_FROM_ANOTHER_TAB", nonce: o };
|
|
1132
1130
|
if (h === "SESSIONS_LOST")
|
|
1133
1131
|
return { tokens: null, status: "SESSIONS_LOST", nonce: o };
|
|
1134
|
-
if (!h || !
|
|
1132
|
+
if (!h || !f)
|
|
1135
1133
|
return { tokens: null, status: "REQUIRE_SYNC_TOKENS", nonce: o };
|
|
1136
|
-
if (
|
|
1137
|
-
const
|
|
1138
|
-
return { tokens:
|
|
1134
|
+
if (f.issuedAt !== s.issuedAt) {
|
|
1135
|
+
const y = V(e.refresh_time_before_tokens_expiration_in_second, f.expiresAt) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", _ = await c.getNonceAsync();
|
|
1136
|
+
return { tokens: f, status: y, nonce: _ };
|
|
1139
1137
|
}
|
|
1140
1138
|
r = await c.getNonceAsync();
|
|
1141
1139
|
} else {
|
|
1142
|
-
const h =
|
|
1143
|
-
if (
|
|
1140
|
+
const h = P(t, e.storage ?? sessionStorage), { tokens: f, status: u } = await h.initAsync();
|
|
1141
|
+
if (f) {
|
|
1144
1142
|
if (u === "SESSIONS_LOST")
|
|
1145
1143
|
return { tokens: null, status: "SESSIONS_LOST", nonce: o };
|
|
1146
|
-
if (
|
|
1147
|
-
const _ =
|
|
1148
|
-
return { tokens:
|
|
1144
|
+
if (f.issuedAt !== s.issuedAt) {
|
|
1145
|
+
const _ = V(e.refresh_time_before_tokens_expiration_in_second, f.expiresAt) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", g = await h.getNonceAsync();
|
|
1146
|
+
return { tokens: f, status: _, nonce: g };
|
|
1149
1147
|
}
|
|
1150
1148
|
} else
|
|
1151
1149
|
return { tokens: null, status: "LOGOUT_FROM_ANOTHER_TAB", nonce: o };
|
|
1152
1150
|
r = await h.getNonceAsync();
|
|
1153
1151
|
}
|
|
1154
|
-
const a =
|
|
1152
|
+
const a = V(e.refresh_time_before_tokens_expiration_in_second, s.expiresAt) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
|
|
1155
1153
|
return i ? { tokens: s, status: "FORCE_REFRESH", nonce: r } : { tokens: s, status: a, nonce: r };
|
|
1156
1154
|
}
|
|
1157
1155
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1158
|
-
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1156
|
+
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise = ze(this), this.loginCallbackWithAutoTokensRenewPromise.then((e) => (this.loginCallbackWithAutoTokensRenewPromise = null, e)));
|
|
1159
1157
|
}
|
|
1160
1158
|
userInfoAsync(e = !1) {
|
|
1161
|
-
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise =
|
|
1159
|
+
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise = Je(this)(e), this.userInfoPromise.then((t) => (this.userInfoPromise = null, t)));
|
|
1162
1160
|
}
|
|
1163
1161
|
async renewTokensAsync(e = null) {
|
|
1164
1162
|
if (this.renewTokensPromise !== null)
|
|
1165
1163
|
return this.renewTokensPromise;
|
|
1166
1164
|
if (this.timeoutId)
|
|
1167
|
-
return
|
|
1165
|
+
return M.clearTimeout(this.timeoutId), this.renewTokensPromise = de(this, this.tokens.refreshToken, !0, e), this.renewTokensPromise.then((t) => (this.renewTokensPromise = null, t));
|
|
1168
1166
|
}
|
|
1169
1167
|
async destroyAsync(e) {
|
|
1170
|
-
return await
|
|
1168
|
+
return await je(this)(e);
|
|
1171
1169
|
}
|
|
1172
1170
|
async logoutSameTabAsync(e, t) {
|
|
1173
1171
|
this.configuration.monitor_session && this.configuration.client_id === e && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (this.publishEvent(m.logout_from_same_tab, { message: t }), await this.destroyAsync("LOGGED_OUT"));
|
|
@@ -1176,12 +1174,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1176
1174
|
this.configuration.monitor_session && this.configuration.client_id === e && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(m.logout_from_another_tab, { message: "SessionMonitor", sub: t }));
|
|
1177
1175
|
}
|
|
1178
1176
|
async logoutAsync(e = void 0, t = null) {
|
|
1179
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1177
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = Ge(this, N, this.getFetch(), window, console)(e, t), this.logoutPromise.then((s) => (this.logoutPromise = null, s)));
|
|
1180
1178
|
}
|
|
1181
1179
|
};
|
|
1182
|
-
|
|
1183
|
-
let
|
|
1184
|
-
const
|
|
1180
|
+
L.getOrCreate = (e) => (t, s = "default") => Xe(e)(t, s), L.eventNames = m;
|
|
1181
|
+
let x = L;
|
|
1182
|
+
const R = class R {
|
|
1185
1183
|
constructor(e) {
|
|
1186
1184
|
this._oidc = e;
|
|
1187
1185
|
}
|
|
@@ -1195,7 +1193,7 @@ const $ = class $ {
|
|
|
1195
1193
|
this._oidc.publishEvent(e, t);
|
|
1196
1194
|
}
|
|
1197
1195
|
static get(e = "default") {
|
|
1198
|
-
return new
|
|
1196
|
+
return new R(x.get(e));
|
|
1199
1197
|
}
|
|
1200
1198
|
tryKeepExistingSessionAsync() {
|
|
1201
1199
|
return this._oidc.tryKeepExistingSessionAsync();
|
|
@@ -1222,18 +1220,18 @@ const $ = class $ {
|
|
|
1222
1220
|
return this._oidc.configuration;
|
|
1223
1221
|
}
|
|
1224
1222
|
async getValidTokenAsync(e = 200, t = 50) {
|
|
1225
|
-
return
|
|
1223
|
+
return we(this._oidc, e, t);
|
|
1226
1224
|
}
|
|
1227
1225
|
async userInfoAsync(e = !1) {
|
|
1228
1226
|
return this._oidc.userInfoAsync(e);
|
|
1229
1227
|
}
|
|
1230
1228
|
};
|
|
1231
|
-
|
|
1232
|
-
let
|
|
1229
|
+
R.getOrCreate = (e) => (t, s = "default") => new R(x.getOrCreate(e)(t, s)), R.eventNames = x.eventNames;
|
|
1230
|
+
let re = R;
|
|
1233
1231
|
export {
|
|
1234
|
-
|
|
1232
|
+
re as OidcClient,
|
|
1235
1233
|
j as TokenRenewMode,
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1234
|
+
He as getFetchDefault,
|
|
1235
|
+
q as getParseQueryStringFromLocation,
|
|
1236
|
+
Qe as getPath
|
|
1239
1237
|
};
|