@axa-fr/oidc-client 7.15.4 → 7.15.5-alpha.1318
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/dist/index.js +242 -244
- package/dist/index.umd.cjs +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -101,19 +101,19 @@ const m = {
|
|
|
101
101
|
setDemonstratingProofOfPossessionJwkAsync: a,
|
|
102
102
|
getDemonstratingProofOfPossessionJwkAsync: d
|
|
103
103
|
};
|
|
104
|
-
},
|
|
104
|
+
}, Oe = (e) => decodeURIComponent(Array.prototype.map.call(atob(e), (n) => "%" + ("00" + n.charCodeAt(0).toString(16)).slice(-2)).join("")), Ee = (e) => JSON.parse(Oe(e.replace(/-/g, "+").replace(/_/g, "/"))), ae = (e) => {
|
|
105
105
|
try {
|
|
106
|
-
return e &&
|
|
106
|
+
return e && Ie(e, ".") === 2 ? Ee(e.split(".")[1]) : null;
|
|
107
107
|
} catch (n) {
|
|
108
108
|
console.warn(n);
|
|
109
109
|
}
|
|
110
110
|
return null;
|
|
111
|
-
},
|
|
111
|
+
}, Ie = (e, n) => e.split(n).length - 1, Z = {
|
|
112
112
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
113
113
|
access_token_invalid: "access_token_invalid",
|
|
114
114
|
id_token_invalid: "id_token_invalid"
|
|
115
115
|
};
|
|
116
|
-
function
|
|
116
|
+
function Ce(e, n, s) {
|
|
117
117
|
if (e.issuedAt) {
|
|
118
118
|
if (typeof e.issuedAt == "string")
|
|
119
119
|
return parseInt(e.issuedAt, 10);
|
|
@@ -121,7 +121,7 @@ function Ne(e, n, s) {
|
|
|
121
121
|
return n && n.iat ? n.iat : s && s.iat ? s.iat : (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
122
122
|
return e.issuedAt;
|
|
123
123
|
}
|
|
124
|
-
const
|
|
124
|
+
const Q = (e, n = null, s) => {
|
|
125
125
|
if (!e)
|
|
126
126
|
return null;
|
|
127
127
|
let t;
|
|
@@ -130,16 +130,16 @@ const z = (e, n = null, s) => {
|
|
|
130
130
|
let r;
|
|
131
131
|
n != null && "idToken" in n && !("idToken" in e) ? r = n.idToken : r = e.idToken;
|
|
132
132
|
const i = e.idTokenPayload ? e.idTokenPayload : ae(r), c = i && i.exp ? i.exp : Number.MAX_VALUE, a = t && t.exp ? t.exp : e.issuedAt + o;
|
|
133
|
-
e.issuedAt =
|
|
133
|
+
e.issuedAt = Ce(e, t, i);
|
|
134
134
|
let d;
|
|
135
|
-
e.expiresAt ? d = e.expiresAt : s ===
|
|
135
|
+
e.expiresAt ? d = e.expiresAt : s === Z.access_token_invalid ? d = a : s === Z.id_token_invalid ? d = c : d = c < a ? c : a;
|
|
136
136
|
const f = { ...e, idTokenPayload: i, accessTokenPayload: t, expiresAt: d, idToken: r };
|
|
137
137
|
if (n != null && "refreshToken" in n && !("refreshToken" in e)) {
|
|
138
138
|
const l = n.refreshToken;
|
|
139
139
|
return { ...f, refreshToken: l };
|
|
140
140
|
}
|
|
141
141
|
return f;
|
|
142
|
-
},
|
|
142
|
+
}, re = (e, n, s) => {
|
|
143
143
|
if (!e)
|
|
144
144
|
return null;
|
|
145
145
|
if (!e.issued_at) {
|
|
@@ -154,22 +154,22 @@ const z = (e, n = null, s) => {
|
|
|
154
154
|
tokenType: e.token_type,
|
|
155
155
|
issuedAt: e.issued_at
|
|
156
156
|
};
|
|
157
|
-
return "refresh_token" in e && (t.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (t.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (t.idTokenPayload = e.idTokenPayload),
|
|
158
|
-
},
|
|
157
|
+
return "refresh_token" in e && (t.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (t.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (t.idTokenPayload = e.idTokenPayload), Q(t, n, s);
|
|
158
|
+
}, V = (e, n) => {
|
|
159
159
|
const s = (/* @__PURE__ */ new Date()).getTime() / 1e3, t = n - s;
|
|
160
160
|
return Math.round(t - e);
|
|
161
|
-
},
|
|
161
|
+
}, ee = (e) => e ? V(0, e.expiresAt) > 0 : !1, Ne = async (e, n = 200, s = 50) => {
|
|
162
162
|
let t = s;
|
|
163
163
|
if (!e.tokens)
|
|
164
164
|
return null;
|
|
165
|
-
for (; !
|
|
166
|
-
await
|
|
165
|
+
for (; !ee(e.tokens) && t > 0; )
|
|
166
|
+
await F({ milliseconds: n }), t = t - 1;
|
|
167
167
|
return {
|
|
168
|
-
isTokensValid:
|
|
168
|
+
isTokensValid: ee(e.tokens),
|
|
169
169
|
tokens: e.tokens,
|
|
170
170
|
numberWaited: t - s
|
|
171
171
|
};
|
|
172
|
-
},
|
|
172
|
+
}, ge = (e, n, s) => {
|
|
173
173
|
if (e.idTokenPayload) {
|
|
174
174
|
const t = e.idTokenPayload;
|
|
175
175
|
if (s.issuer !== t.iss)
|
|
@@ -184,7 +184,7 @@ const z = (e, n = null, s) => {
|
|
|
184
184
|
return { isValid: !1, reason: `Nonce does not match (idTokenPayload nonce) ${t.nonce} !== (nonce) ${n}` };
|
|
185
185
|
}
|
|
186
186
|
return { isValid: !0, reason: "" };
|
|
187
|
-
},
|
|
187
|
+
}, B = function() {
|
|
188
188
|
const e = function() {
|
|
189
189
|
let a, d;
|
|
190
190
|
const f = (function() {
|
|
@@ -249,7 +249,7 @@ const z = (e, n = null, s) => {
|
|
|
249
249
|
clearInterval: clearInterval.bind(a)
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
|
-
const n = function() {
|
|
252
|
+
const n = /* @__PURE__ */ function() {
|
|
253
253
|
let a = 0;
|
|
254
254
|
return function() {
|
|
255
255
|
return a++, a;
|
|
@@ -284,29 +284,29 @@ const z = (e, n = null, s) => {
|
|
|
284
284
|
setInterval: i,
|
|
285
285
|
clearInterval: c
|
|
286
286
|
};
|
|
287
|
-
}(), ce = "7.15.
|
|
288
|
-
let le = null,
|
|
289
|
-
const
|
|
287
|
+
}(), ce = "7.15.5-alpha.1318";
|
|
288
|
+
let le = null, G;
|
|
289
|
+
const F = ({ milliseconds: e }) => new Promise((n) => B.setTimeout(n, e)), ke = (e = "/") => {
|
|
290
290
|
try {
|
|
291
|
-
|
|
291
|
+
G = new AbortController(), fetch(`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: G.signal }).catch((t) => {
|
|
292
292
|
console.log(t);
|
|
293
|
-
}),
|
|
293
|
+
}), F({ milliseconds: 150 * 1e3 }).then(ke);
|
|
294
294
|
} catch (n) {
|
|
295
295
|
console.log(n);
|
|
296
296
|
}
|
|
297
|
-
},
|
|
298
|
-
|
|
299
|
-
},
|
|
297
|
+
}, xe = () => {
|
|
298
|
+
G && G.abort();
|
|
299
|
+
}, Le = (e = "/") => fetch(`${e}OidcKeepAliveServiceWorker.json`, {
|
|
300
300
|
headers: {
|
|
301
301
|
"oidc-vanilla": "true"
|
|
302
302
|
}
|
|
303
303
|
}).then((n) => n.statusText === "oidc-service-worker").catch((n) => {
|
|
304
304
|
console.log(n);
|
|
305
|
-
}),
|
|
305
|
+
}), We = (e) => async (n, s) => {
|
|
306
306
|
s(), await n.update();
|
|
307
307
|
const t = await n.unregister();
|
|
308
|
-
console.log(`Service worker unregistering ${t}`), await
|
|
309
|
-
},
|
|
308
|
+
console.log(`Service worker unregistering ${t}`), await F({ milliseconds: 2e3 }), e.reload();
|
|
309
|
+
}, O = (e) => (n) => new Promise(function(s, t) {
|
|
310
310
|
const o = new MessageChannel();
|
|
311
311
|
o.port1.onmessage = function(r) {
|
|
312
312
|
r.data && r.data.error ? t(r.data.error) : s(r.data);
|
|
@@ -318,12 +318,12 @@ const U = ({ milliseconds: e }) => new Promise((n) => M.setTimeout(n, e)), ge =
|
|
|
318
318
|
let t = null;
|
|
319
319
|
e.register ? t = await e.service_worker_register(s) : t = await navigator.serviceWorker.register(s);
|
|
320
320
|
try {
|
|
321
|
-
await navigator.serviceWorker.ready, navigator.serviceWorker.controller || await
|
|
321
|
+
await navigator.serviceWorker.ready, navigator.serviceWorker.controller || await O(t)({ type: "claim" });
|
|
322
322
|
} catch {
|
|
323
323
|
return null;
|
|
324
324
|
}
|
|
325
|
-
const o = async (k) =>
|
|
326
|
-
const T = await
|
|
325
|
+
const o = async (k) => O(t)({ type: "clear", data: { status: k }, configurationName: n }), r = async (k, w, E) => {
|
|
326
|
+
const T = await O(t)({
|
|
327
327
|
type: "init",
|
|
328
328
|
data: {
|
|
329
329
|
oidcServerConfiguration: k,
|
|
@@ -335,11 +335,11 @@ const U = ({ milliseconds: e }) => new Promise((n) => M.setTimeout(n, e)), ge =
|
|
|
335
335
|
},
|
|
336
336
|
configurationName: n
|
|
337
337
|
}), D = T.version;
|
|
338
|
-
return D !== ce && (console.warn(`Service worker ${D} version mismatch with js client version ${ce}, unregistering and reloading`), await E.service_worker_update_require_callback(t,
|
|
338
|
+
return D !== ce && (console.warn(`Service worker ${D} version mismatch with js client version ${ce}, unregistering and reloading`), await E.service_worker_update_require_callback(t, xe)), { tokens: re(T.tokens, null, E.token_renew_mode), status: T.status };
|
|
339
339
|
}, i = (k = "/") => {
|
|
340
|
-
le == null && (le = "not_null",
|
|
341
|
-
}, c = (k) =>
|
|
342
|
-
let w = (await
|
|
340
|
+
le == null && (le = "not_null", ke(k));
|
|
341
|
+
}, c = (k) => O(t)({ type: "setSessionState", data: { sessionState: k }, configurationName: n }), a = async () => (await O(t)({ type: "getSessionState", data: null, configurationName: n })).sessionState, d = (k) => (sessionStorage[`oidc.nonce.${n}`] = k.nonce, O(t)({ type: "setNonce", data: { nonce: k }, configurationName: n })), f = async () => {
|
|
342
|
+
let w = (await O(t)({ type: "getNonce", data: null, configurationName: n })).nonce;
|
|
343
343
|
return w || (w = sessionStorage[`oidc.nonce.${n}`], console.warn("nonce not found in service worker, using sessionStorage")), { nonce: w };
|
|
344
344
|
};
|
|
345
345
|
let l = {};
|
|
@@ -347,7 +347,7 @@ const U = ({ milliseconds: e }) => new Promise((n) => M.setTimeout(n, e)), ge =
|
|
|
347
347
|
clearAsync: o,
|
|
348
348
|
initAsync: r,
|
|
349
349
|
startKeepAliveServiceWorker: () => i(e.service_worker_keep_alive_path),
|
|
350
|
-
isServiceWorkerProxyActiveAsync: () =>
|
|
350
|
+
isServiceWorkerProxyActiveAsync: () => Le(e.service_worker_keep_alive_path),
|
|
351
351
|
setSessionStateAsync: c,
|
|
352
352
|
getSessionStateAsync: a,
|
|
353
353
|
setNonceAsync: d,
|
|
@@ -360,104 +360,104 @@ const U = ({ milliseconds: e }) => new Promise((n) => M.setTimeout(n, e)), ge =
|
|
|
360
360
|
return l[n] || (l[n] = JSON.parse(k)), l[n];
|
|
361
361
|
},
|
|
362
362
|
getStateAsync: async () => {
|
|
363
|
-
let w = (await
|
|
363
|
+
let w = (await O(t)({ type: "getState", data: null, configurationName: n })).state;
|
|
364
364
|
return w || (w = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage")), w;
|
|
365
365
|
},
|
|
366
|
-
setStateAsync: async (k) => (sessionStorage[`oidc.state.${n}`] = k,
|
|
366
|
+
setStateAsync: async (k) => (sessionStorage[`oidc.state.${n}`] = k, O(t)({ type: "setState", data: { state: k }, configurationName: n })),
|
|
367
367
|
getCodeVerifierAsync: async () => {
|
|
368
|
-
let w = (await
|
|
368
|
+
let w = (await O(t)({ type: "getCodeVerifier", data: null, configurationName: n })).codeVerifier;
|
|
369
369
|
return w || (w = sessionStorage[`oidc.code_verifier.${n}`], console.warn("codeVerifier not found in service worker, using sessionStorage")), w;
|
|
370
370
|
},
|
|
371
|
-
setCodeVerifierAsync: async (k) => (sessionStorage[`oidc.code_verifier.${n}`] = k,
|
|
371
|
+
setCodeVerifierAsync: async (k) => (sessionStorage[`oidc.code_verifier.${n}`] = k, O(t)({ type: "setCodeVerifier", data: { codeVerifier: k }, configurationName: n })),
|
|
372
372
|
setDemonstratingProofOfPossessionNonce: async (k) => {
|
|
373
|
-
await
|
|
373
|
+
await O(t)({ type: "setDemonstratingProofOfPossessionNonce", data: { demonstratingProofOfPossessionNonce: k }, configurationName: n });
|
|
374
374
|
},
|
|
375
|
-
getDemonstratingProofOfPossessionNonce: async () => (await
|
|
375
|
+
getDemonstratingProofOfPossessionNonce: async () => (await O(t)({ type: "getDemonstratingProofOfPossessionNonce", data: null, configurationName: n })).demonstratingProofOfPossessionNonce,
|
|
376
376
|
setDemonstratingProofOfPossessionJwkAsync: async (k) => {
|
|
377
377
|
const w = JSON.stringify(k);
|
|
378
|
-
|
|
378
|
+
O(t)({ type: "setDemonstratingProofOfPossessionJwk", data: { demonstratingProofOfPossessionJwkJson: w }, configurationName: n });
|
|
379
379
|
},
|
|
380
380
|
getDemonstratingProofOfPossessionJwkAsync: async () => {
|
|
381
|
-
const k = await
|
|
381
|
+
const k = await O(t)({ type: "getDemonstratingProofOfPossessionJwk", data: null, configurationName: n });
|
|
382
382
|
return k.demonstratingProofOfPossessionJwkJson ? JSON.parse(k.demonstratingProofOfPossessionJwkJson) : null;
|
|
383
383
|
}
|
|
384
384
|
};
|
|
385
|
-
}, K = {},
|
|
385
|
+
}, K = {}, De = (e, n = window.sessionStorage, s) => {
|
|
386
386
|
if (!K[e] && n) {
|
|
387
387
|
const o = n.getItem(e);
|
|
388
388
|
o && (K[e] = JSON.parse(o));
|
|
389
389
|
}
|
|
390
390
|
const t = 1e3 * s;
|
|
391
391
|
return K[e] && K[e].timestamp + t > Date.now() ? K[e].result : null;
|
|
392
|
-
},
|
|
392
|
+
}, $e = (e, n, s = window.sessionStorage) => {
|
|
393
393
|
const t = Date.now();
|
|
394
394
|
K[e] = { result: n, timestamp: t }, s && s.setItem(e, JSON.stringify({ result: n, timestamp: t }));
|
|
395
395
|
};
|
|
396
|
-
var
|
|
397
|
-
for (var
|
|
398
|
-
|
|
399
|
-
function
|
|
400
|
-
return
|
|
396
|
+
var Re = Ve, x = [], ue = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
397
|
+
for (var q = 0, Ke = ue.length; q < Ke; ++q)
|
|
398
|
+
x[q] = ue[q];
|
|
399
|
+
function Ue(e) {
|
|
400
|
+
return x[e >> 18 & 63] + x[e >> 12 & 63] + x[e >> 6 & 63] + x[e & 63];
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function Fe(e, n, s) {
|
|
403
403
|
for (var t, o = [], r = n; r < s; r += 3)
|
|
404
|
-
t = (e[r] << 16 & 16711680) + (e[r + 1] << 8 & 65280) + (e[r + 2] & 255), o.push(
|
|
404
|
+
t = (e[r] << 16 & 16711680) + (e[r + 1] << 8 & 65280) + (e[r + 2] & 255), o.push(Ue(t));
|
|
405
405
|
return o.join("");
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function Ve(e) {
|
|
408
408
|
for (var n, s = e.length, t = s % 3, o = [], r = 16383, i = 0, c = s - t; i < c; i += r)
|
|
409
|
-
o.push(
|
|
409
|
+
o.push(Fe(e, i, i + r > c ? c : i + r));
|
|
410
410
|
return t === 1 ? (n = e[s - 1], o.push(
|
|
411
|
-
|
|
411
|
+
x[n >> 2] + x[n << 4 & 63] + "=="
|
|
412
412
|
)) : t === 2 && (n = (e[s - 2] << 8) + e[s - 1], o.push(
|
|
413
|
-
|
|
413
|
+
x[n >> 10] + x[n >> 4 & 63] + x[n << 2 & 63] + "="
|
|
414
414
|
)), o.join("");
|
|
415
415
|
}
|
|
416
|
-
const
|
|
416
|
+
const me = () => {
|
|
417
417
|
const e = typeof window < "u" && !!window.crypto, n = e && !!window.crypto.subtle;
|
|
418
418
|
return { hasCrypto: e, hasSubtleCrypto: n };
|
|
419
|
-
},
|
|
419
|
+
}, ne = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", Me = (e) => {
|
|
420
420
|
const n = [];
|
|
421
421
|
for (let s = 0; s < e.byteLength; s += 1) {
|
|
422
|
-
const t = e[s] %
|
|
423
|
-
n.push(
|
|
422
|
+
const t = e[s] % ne.length;
|
|
423
|
+
n.push(ne[t]);
|
|
424
424
|
}
|
|
425
425
|
return n.join("");
|
|
426
|
-
},
|
|
427
|
-
const n = new Uint8Array(e), { hasCrypto: s } =
|
|
426
|
+
}, Je = (e) => Re(new Uint8Array(e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""), se = (e) => {
|
|
427
|
+
const n = new Uint8Array(e), { hasCrypto: s } = me();
|
|
428
428
|
if (s)
|
|
429
429
|
window.crypto.getRandomValues(n);
|
|
430
430
|
else
|
|
431
431
|
for (let t = 0; t < e; t += 1)
|
|
432
|
-
n[t] = Math.random() *
|
|
433
|
-
return
|
|
432
|
+
n[t] = Math.random() * ne.length | 0;
|
|
433
|
+
return Me(n);
|
|
434
434
|
};
|
|
435
|
-
function
|
|
435
|
+
function Be(e) {
|
|
436
436
|
const n = new ArrayBuffer(e.length), s = new Uint8Array(n);
|
|
437
437
|
for (let t = 0; t < e.length; t++)
|
|
438
438
|
s[t] = e.charCodeAt(t);
|
|
439
439
|
return s;
|
|
440
440
|
}
|
|
441
|
-
function
|
|
441
|
+
function pe(e) {
|
|
442
442
|
return new Promise((n, s) => {
|
|
443
|
-
crypto.subtle.digest("SHA-256",
|
|
443
|
+
crypto.subtle.digest("SHA-256", Be(e)).then((t) => n(Je(new Uint8Array(t))), (t) => s(t));
|
|
444
444
|
});
|
|
445
445
|
}
|
|
446
|
-
const
|
|
446
|
+
const je = (e) => {
|
|
447
447
|
if (e.length < 43 || e.length > 128)
|
|
448
448
|
return Promise.reject(new Error("Invalid code length."));
|
|
449
|
-
const { hasSubtleCrypto: n } =
|
|
450
|
-
return n ?
|
|
451
|
-
},
|
|
452
|
-
const r = `${n}/.well-known/openid-configuration`, i = `oidc.server:${n}`, c =
|
|
449
|
+
const { hasSubtleCrypto: n } = me();
|
|
450
|
+
return n ? pe(e) : Promise.reject(new Error("window.crypto.subtle is unavailable."));
|
|
451
|
+
}, qe = 60 * 60, He = (e) => async (n, s = qe, t = window.sessionStorage, o = 1e4) => {
|
|
452
|
+
const r = `${n}/.well-known/openid-configuration`, i = `oidc.server:${n}`, c = De(i, t, s);
|
|
453
453
|
if (c)
|
|
454
|
-
return new
|
|
455
|
-
const a = await
|
|
454
|
+
return new oe(c);
|
|
455
|
+
const a = await j(e)(r, {}, o);
|
|
456
456
|
if (a.status !== 200)
|
|
457
457
|
return null;
|
|
458
458
|
const d = await a.json();
|
|
459
|
-
return
|
|
460
|
-
},
|
|
459
|
+
return $e(i, d, t), new oe(d);
|
|
460
|
+
}, j = (e) => async (n, s = {}, t = 1e4, o = 0) => {
|
|
461
461
|
let r;
|
|
462
462
|
try {
|
|
463
463
|
const i = new AbortController();
|
|
@@ -465,16 +465,16 @@ const qe = (e) => {
|
|
|
465
465
|
} catch (i) {
|
|
466
466
|
if (i.name === "AbortError" || i.message === "Network request failed") {
|
|
467
467
|
if (o <= 1)
|
|
468
|
-
return await
|
|
468
|
+
return await j(e)(n, s, t, o + 1);
|
|
469
469
|
throw i;
|
|
470
470
|
} else
|
|
471
471
|
throw console.error(i.message), i;
|
|
472
472
|
}
|
|
473
473
|
return r;
|
|
474
|
-
},
|
|
474
|
+
}, te = {
|
|
475
475
|
refresh_token: "refresh_token",
|
|
476
476
|
access_token: "access_token"
|
|
477
|
-
}, fe = (e) => async (n, s, t =
|
|
477
|
+
}, fe = (e) => async (n, s, t = te.refresh_token, o, r = 1e4) => {
|
|
478
478
|
const i = {
|
|
479
479
|
token: s,
|
|
480
480
|
token_type_hint: t,
|
|
@@ -485,7 +485,7 @@ const qe = (e) => {
|
|
|
485
485
|
c.push(`${l}=${u}`);
|
|
486
486
|
}
|
|
487
487
|
const a = c.join("&");
|
|
488
|
-
return (await
|
|
488
|
+
return (await j(e)(n, {
|
|
489
489
|
method: "POST",
|
|
490
490
|
headers: {
|
|
491
491
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
|
|
@@ -494,7 +494,7 @@ const qe = (e) => {
|
|
|
494
494
|
}, r)).status !== 200 ? { success: !1 } : {
|
|
495
495
|
success: !0
|
|
496
496
|
};
|
|
497
|
-
},
|
|
497
|
+
}, Ge = (e) => async (n, s, t, o, r = {}, i, c = 1e4) => {
|
|
498
498
|
for (const [y, g] of Object.entries(t))
|
|
499
499
|
s[y] === void 0 && (s[y] = g);
|
|
500
500
|
const a = [];
|
|
@@ -502,7 +502,7 @@ const qe = (e) => {
|
|
|
502
502
|
const g = encodeURIComponent(y), _ = encodeURIComponent(s[y]);
|
|
503
503
|
a.push(`${g}=${_}`);
|
|
504
504
|
}
|
|
505
|
-
const d = a.join("&"), f = await
|
|
505
|
+
const d = a.join("&"), f = await j(e)(n, {
|
|
506
506
|
method: "POST",
|
|
507
507
|
headers: {
|
|
508
508
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
@@ -518,29 +518,29 @@ const qe = (e) => {
|
|
|
518
518
|
};
|
|
519
519
|
const l = await f.json();
|
|
520
520
|
let u = null;
|
|
521
|
-
return f.headers.has(
|
|
521
|
+
return f.headers.has(Y) && (u = f.headers.get(Y)), {
|
|
522
522
|
success: !0,
|
|
523
523
|
status: f.status,
|
|
524
|
-
data:
|
|
524
|
+
data: re(l, o, i),
|
|
525
525
|
demonstratingProofOfPossessionNonce: u
|
|
526
526
|
};
|
|
527
|
-
},
|
|
527
|
+
}, Ye = (e, n) => async (s, t) => {
|
|
528
528
|
t = t ? { ...t } : {};
|
|
529
|
-
const o =
|
|
529
|
+
const o = se(128), r = await je(o);
|
|
530
530
|
await e.setCodeVerifierAsync(o), await e.setStateAsync(t.state), t.code_challenge = r, t.code_challenge_method = "S256";
|
|
531
531
|
let i = "";
|
|
532
532
|
if (t)
|
|
533
533
|
for (const [c, a] of Object.entries(t))
|
|
534
534
|
i === "" ? i += "?" : i += "&", i += `${c}=${encodeURIComponent(a)}`;
|
|
535
535
|
n.open(`${s}${i}`);
|
|
536
|
-
},
|
|
536
|
+
}, Y = "DPoP-Nonce", Xe = (e) => async (n, s, t, o, r = 1e4) => {
|
|
537
537
|
s = s ? { ...s } : {}, s.code_verifier = await e.getCodeVerifierAsync();
|
|
538
538
|
const i = [];
|
|
539
539
|
for (const l in s) {
|
|
540
540
|
const u = encodeURIComponent(l), y = encodeURIComponent(s[l]);
|
|
541
541
|
i.push(`${u}=${y}`);
|
|
542
542
|
}
|
|
543
|
-
const c = i.join("&"), a = await
|
|
543
|
+
const c = i.join("&"), a = await j(fetch)(n, {
|
|
544
544
|
method: "POST",
|
|
545
545
|
headers: {
|
|
546
546
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
@@ -551,13 +551,13 @@ const qe = (e) => {
|
|
|
551
551
|
if (await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]), a.status !== 200)
|
|
552
552
|
return { success: !1, status: a.status };
|
|
553
553
|
let d = null;
|
|
554
|
-
a.headers.has(
|
|
554
|
+
a.headers.has(Y) && (d = a.headers.get(Y));
|
|
555
555
|
const f = await a.json();
|
|
556
556
|
return {
|
|
557
557
|
success: !0,
|
|
558
558
|
data: {
|
|
559
559
|
state: s.state,
|
|
560
|
-
tokens:
|
|
560
|
+
tokens: re(f, null, o),
|
|
561
561
|
demonstratingProofOfPossessionNonce: d
|
|
562
562
|
}
|
|
563
563
|
};
|
|
@@ -565,10 +565,10 @@ const qe = (e) => {
|
|
|
565
565
|
async function de(e, n, s) {
|
|
566
566
|
const t = (c) => {
|
|
567
567
|
e.tokens = c;
|
|
568
|
-
}, { tokens: o, status: r } = await
|
|
568
|
+
}, { tokens: o, status: r } = await H(e)(0, n, s, t);
|
|
569
569
|
return await C(e.configuration, e.configurationName) || await I(e.configurationName, e.configuration.storage).setTokens(e.tokens), e.tokens ? o : (await e.destroyAsync(r), null);
|
|
570
570
|
}
|
|
571
|
-
const
|
|
571
|
+
const ze = async (e, n) => {
|
|
572
572
|
const s = await C(n, e.configurationName);
|
|
573
573
|
if (s) {
|
|
574
574
|
const t = await e.initAsync(n.authority, n.authority_configuration), { tokens: o } = await s.initAsync(t, "tryKeepExistingSessionAsync", n);
|
|
@@ -576,20 +576,20 @@ const Qe = async (e, n) => {
|
|
|
576
576
|
} else {
|
|
577
577
|
const t = I(e.configurationName, n.storage ?? sessionStorage);
|
|
578
578
|
let { tokens: o } = await t.initAsync();
|
|
579
|
-
return o =
|
|
579
|
+
return o = Q(o, e.tokens, n.token_renew_mode), o;
|
|
580
580
|
}
|
|
581
581
|
};
|
|
582
|
-
async function
|
|
582
|
+
async function we(e, n = !1, s = null) {
|
|
583
583
|
const t = e.configuration, o = `${t.client_id}_${e.configurationName}_${t.authority}`;
|
|
584
584
|
let r;
|
|
585
585
|
const i = await C(e.configuration, e.configurationName);
|
|
586
|
-
return (t == null ? void 0 : t.storage) === (window == null ? void 0 : window.sessionStorage) && !i ? r = await de(e, n, s) : r = await navigator.locks.request(o, { ifAvailable: !0 }, async (c) => c ? await de(e, n, s) : (e.publishEvent(
|
|
586
|
+
return (t == null ? void 0 : t.storage) === (window == null ? void 0 : window.sessionStorage) && !i ? r = await de(e, n, s) : r = await navigator.locks.request(o, { ifAvailable: !0 }, async (c) => c ? await de(e, n, s) : (e.publishEvent(N.eventNames.syncTokensAsync_lock_not_available, { lock: "lock not available" }), await ze(e, t))), r ? (e.timeoutId && (e.timeoutId = J(e, e.tokens.expiresAt, s)), e.tokens) : null;
|
|
587
587
|
}
|
|
588
|
-
const
|
|
588
|
+
const J = (e, n, s = null) => {
|
|
589
589
|
const t = e.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
590
|
-
return
|
|
591
|
-
const r = { timeLeft:
|
|
592
|
-
e.publishEvent(
|
|
590
|
+
return B.setTimeout(async () => {
|
|
591
|
+
const r = { timeLeft: V(t, n) };
|
|
592
|
+
e.publishEvent(N.eventNames.token_timer, r), await we(e, !1, s);
|
|
593
593
|
}, 1e3);
|
|
594
594
|
}, R = {
|
|
595
595
|
SESSION_LOST: "SESSION_LOST",
|
|
@@ -598,7 +598,7 @@ const V = (e, n, s = null) => {
|
|
|
598
598
|
TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID",
|
|
599
599
|
LOGOUT_FROM_ANOTHER_TAB: "LOGOUT_FROM_ANOTHER_TAB",
|
|
600
600
|
REQUIRE_SYNC_TOKENS: "REQUIRE_SYNC_TOKENS"
|
|
601
|
-
},
|
|
601
|
+
}, Qe = (e) => async (n, s, t, o = !1) => {
|
|
602
602
|
const r = { nonce: null };
|
|
603
603
|
if (!t)
|
|
604
604
|
return { tokens: null, status: "NOT_CONNECTED", nonce: r };
|
|
@@ -613,35 +613,35 @@ const V = (e, n, s = null) => {
|
|
|
613
613
|
if (!l || !u)
|
|
614
614
|
return { tokens: null, status: "REQUIRE_SYNC_TOKENS", nonce: r };
|
|
615
615
|
if (u.issuedAt !== t.issuedAt) {
|
|
616
|
-
const g =
|
|
616
|
+
const g = V(n.refresh_time_before_tokens_expiration_in_second, u.expiresAt) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", _ = await a.getNonceAsync();
|
|
617
617
|
return { tokens: u, status: g, nonce: _ };
|
|
618
618
|
}
|
|
619
619
|
i = await a.getNonceAsync();
|
|
620
620
|
} else {
|
|
621
621
|
const l = I(s, n.storage ?? sessionStorage);
|
|
622
622
|
let { tokens: u, status: y } = await l.initAsync();
|
|
623
|
-
if (u && (u =
|
|
623
|
+
if (u && (u = Q(u, e.tokens, n.token_renew_mode)), u) {
|
|
624
624
|
if (y === "SESSIONS_LOST")
|
|
625
625
|
return { tokens: null, status: "SESSIONS_LOST", nonce: r };
|
|
626
626
|
if (u.issuedAt !== t.issuedAt) {
|
|
627
|
-
const _ =
|
|
627
|
+
const _ = V(n.refresh_time_before_tokens_expiration_in_second, u.expiresAt) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", h = await l.getNonceAsync();
|
|
628
628
|
return { tokens: u, status: _, nonce: h };
|
|
629
629
|
}
|
|
630
630
|
} else
|
|
631
631
|
return { tokens: null, status: "LOGOUT_FROM_ANOTHER_TAB", nonce: r };
|
|
632
632
|
i = await l.getNonceAsync();
|
|
633
633
|
}
|
|
634
|
-
const f =
|
|
634
|
+
const f = V(n.refresh_time_before_tokens_expiration_in_second, t.expiresAt) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
|
|
635
635
|
return o ? { tokens: t, status: "FORCE_REFRESH", nonce: i } : { tokens: t, status: f, nonce: i };
|
|
636
|
-
},
|
|
636
|
+
}, H = (e) => async (n = 0, s = !1, t = null, o) => {
|
|
637
637
|
for (; !navigator.onLine && document.hidden; )
|
|
638
|
-
await
|
|
638
|
+
await F({ milliseconds: 1e3 }), e.publishEvent(m.refreshTokensAsync, { message: "wait because navigator is offline and hidden" });
|
|
639
639
|
let r = 6;
|
|
640
640
|
for (; !navigator.onLine && r > 0; )
|
|
641
|
-
await
|
|
641
|
+
await F({ milliseconds: 1e3 }), r--, e.publishEvent(m.refreshTokensAsync, { message: `wait because navigator is offline try ${r}` });
|
|
642
642
|
const i = document.hidden, c = n + 1;
|
|
643
643
|
t || (t = {});
|
|
644
|
-
const a = e.configuration, d = (l, u = null, y = null) =>
|
|
644
|
+
const a = e.configuration, d = (l, u = null, y = null) => ie(e.configurationName, e.configuration, e.publishEvent.bind(e))(l, u, y), f = async () => {
|
|
645
645
|
try {
|
|
646
646
|
let l;
|
|
647
647
|
const u = await C(a, e.configurationName);
|
|
@@ -652,15 +652,15 @@ const V = (e, n, s = null) => {
|
|
|
652
652
|
prompt: "none"
|
|
653
653
|
});
|
|
654
654
|
if (y)
|
|
655
|
-
return y.error ? (o(null), e.publishEvent(m.refreshTokensAsync_error, { message: "refresh token silent" }), { tokens: null, status: "SESSION_LOST" }) : (o(y.tokens), e.publishEvent(
|
|
655
|
+
return y.error ? (o(null), e.publishEvent(m.refreshTokensAsync_error, { message: "refresh token silent" }), { tokens: null, status: "SESSION_LOST" }) : (o(y.tokens), e.publishEvent(N.eventNames.token_renewed, {}), { tokens: y.tokens, status: "LOGGED" });
|
|
656
656
|
} catch (l) {
|
|
657
|
-
return console.error(l), e.publishEvent(m.refreshTokensAsync_silent_error, { message: "exceptionSilent", exception: l.message }), await
|
|
657
|
+
return console.error(l), e.publishEvent(m.refreshTokensAsync_silent_error, { message: "exceptionSilent", exception: l.message }), await H(e)(c, s, t, o);
|
|
658
658
|
}
|
|
659
659
|
};
|
|
660
660
|
if (n > 4)
|
|
661
661
|
return i ? { tokens: e.tokens, status: "GIVE_UP" } : (o(null), e.publishEvent(m.refreshTokensAsync_error, { message: "refresh token" }), { tokens: null, status: "SESSION_LOST" });
|
|
662
662
|
try {
|
|
663
|
-
const { status: l, tokens: u, nonce: y } = await
|
|
663
|
+
const { status: l, tokens: u, nonce: y } = await Qe(e)(a, e.configurationName, e.tokens, s);
|
|
664
664
|
switch (l) {
|
|
665
665
|
case R.SESSION_LOST:
|
|
666
666
|
return o(null), e.publishEvent(m.refreshTokensAsync_error, { message: "refresh token session lost" }), { tokens: null, status: "SESSION_LOST" };
|
|
@@ -669,7 +669,7 @@ const V = (e, n, s = null) => {
|
|
|
669
669
|
case R.TOKENS_VALID:
|
|
670
670
|
return o(u), { tokens: u, status: "LOGGED_IN" };
|
|
671
671
|
case R.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:
|
|
672
|
-
return o(u), e.publishEvent(
|
|
672
|
+
return o(u), e.publishEvent(N.eventNames.token_renewed, { reason: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" }), { tokens: u, status: "LOGGED_IN" };
|
|
673
673
|
case R.LOGOUT_FROM_ANOTHER_TAB:
|
|
674
674
|
return o(null), e.publishEvent(m.logout_from_another_tab, { status: "session syncTokensAsync" }), { tokens: null, status: "LOGGED_OUT" };
|
|
675
675
|
case R.REQUIRE_SYNC_TOKENS:
|
|
@@ -678,19 +678,19 @@ const V = (e, n, s = null) => {
|
|
|
678
678
|
if (e.publishEvent(m.refreshTokensAsync_begin, { refreshToken: u.refreshToken, status: l, tryNumber: n }), !u.refreshToken)
|
|
679
679
|
return await f();
|
|
680
680
|
const g = a.client_id, _ = a.redirect_uri, h = a.authority, S = { ...a.token_request_extras ? a.token_request_extras : {} };
|
|
681
|
-
for (const [
|
|
682
|
-
|
|
681
|
+
for (const [P, p] of Object.entries(t))
|
|
682
|
+
P.endsWith(":token_request") && (S[P.replace(":token_request", "")] = p);
|
|
683
683
|
return await (async () => {
|
|
684
|
-
const
|
|
684
|
+
const P = {
|
|
685
685
|
client_id: g,
|
|
686
686
|
redirect_uri: _,
|
|
687
687
|
grant_type: "refresh_token",
|
|
688
688
|
refresh_token: u.refreshToken
|
|
689
689
|
}, p = await e.initAsync(h, a.authority_configuration), k = document.hidden ? 1e4 : 3e4 * 10, w = p.tokenEndpoint, E = {};
|
|
690
690
|
a.demonstrating_proof_of_possession && (E.DPoP = await e.generateDemonstrationOfProofOfPossessionAsync(u.accessToken, w, "POST"));
|
|
691
|
-
const T = await
|
|
691
|
+
const T = await Ge(e.getFetch())(
|
|
692
692
|
w,
|
|
693
|
-
|
|
693
|
+
P,
|
|
694
694
|
S,
|
|
695
695
|
u,
|
|
696
696
|
E,
|
|
@@ -698,26 +698,26 @@ const V = (e, n, s = null) => {
|
|
|
698
698
|
k
|
|
699
699
|
);
|
|
700
700
|
if (T.success) {
|
|
701
|
-
const { isValid: D, reason: v } =
|
|
701
|
+
const { isValid: D, reason: v } = ge(T.data, y.nonce, p);
|
|
702
702
|
if (!D)
|
|
703
703
|
return o(null), e.publishEvent(m.refreshTokensAsync_error, { message: `refresh token return not valid tokens, reason: ${v}` }), { tokens: null, status: "SESSION_LOST" };
|
|
704
704
|
if (o(T.data), T.demonstratingProofOfPossessionNonce) {
|
|
705
705
|
const W = await C(a, e.configurationName);
|
|
706
706
|
W ? await W.setDemonstratingProofOfPossessionNonce(T.demonstratingProofOfPossessionNonce) : await I(e.configurationName, a.storage).setDemonstratingProofOfPossessionNonce(T.demonstratingProofOfPossessionNonce);
|
|
707
707
|
}
|
|
708
|
-
return e.publishEvent(m.refreshTokensAsync_end, { success: T.success }), e.publishEvent(
|
|
708
|
+
return e.publishEvent(m.refreshTokensAsync_end, { success: T.success }), e.publishEvent(N.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), { tokens: T.data, status: "LOGGED_IN" };
|
|
709
709
|
} else
|
|
710
710
|
return e.publishEvent(m.refreshTokensAsync_silent_error, {
|
|
711
711
|
message: "bad request",
|
|
712
712
|
tokenResponse: T
|
|
713
|
-
}), T.status >= 400 && T.status < 500 ? (o(null), e.publishEvent(m.refreshTokensAsync_error, { message: `session lost: ${T.status}` }), { tokens: null, status: "SESSION_LOST" }) : await
|
|
713
|
+
}), T.status >= 400 && T.status < 500 ? (o(null), e.publishEvent(m.refreshTokensAsync_error, { message: `session lost: ${T.status}` }), { tokens: null, status: "SESSION_LOST" }) : await H(e)(c, s, t, o);
|
|
714
714
|
})();
|
|
715
715
|
}
|
|
716
716
|
}
|
|
717
717
|
} catch (l) {
|
|
718
|
-
return console.error(l), e.publishEvent(m.refreshTokensAsync_silent_error, { message: "exception", exception: l.message }),
|
|
718
|
+
return console.error(l), e.publishEvent(m.refreshTokensAsync_silent_error, { message: "exception", exception: l.message }), H(e)(c, s, t, o);
|
|
719
719
|
}
|
|
720
|
-
},
|
|
720
|
+
}, ie = (e, n, s) => (t = null, o = null, r = null) => {
|
|
721
721
|
if (!n.silent_redirect_uri || !n.silent_login_uri)
|
|
722
722
|
return Promise.resolve(null);
|
|
723
723
|
try {
|
|
@@ -735,14 +735,14 @@ const V = (e, n, s = null) => {
|
|
|
735
735
|
const h = `${e}_oidc_tokens:`, A = `${e}_oidc_error:`, S = `${e}_oidc_exception:`, b = _.data;
|
|
736
736
|
if (b && typeof b == "string" && !y) {
|
|
737
737
|
if (b.startsWith(h)) {
|
|
738
|
-
const
|
|
739
|
-
s(m.silentLoginAsync_end, {}), f.remove(), y = !0, l(
|
|
738
|
+
const P = JSON.parse(_.data.replace(h, ""));
|
|
739
|
+
s(m.silentLoginAsync_end, {}), f.remove(), y = !0, l(P);
|
|
740
740
|
} else if (b.startsWith(A)) {
|
|
741
|
-
const
|
|
742
|
-
s(m.silentLoginAsync_error,
|
|
741
|
+
const P = JSON.parse(_.data.replace(A, ""));
|
|
742
|
+
s(m.silentLoginAsync_error, P), f.remove(), y = !0, l({ error: "oidc_" + P.error, tokens: null, sessionState: null });
|
|
743
743
|
} else if (b.startsWith(S)) {
|
|
744
|
-
const
|
|
745
|
-
s(m.silentLoginAsync_error,
|
|
744
|
+
const P = JSON.parse(_.data.replace(S, ""));
|
|
745
|
+
s(m.silentLoginAsync_error, P), f.remove(), y = !0, u(new Error(P.error));
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
}
|
|
@@ -758,11 +758,11 @@ const V = (e, n, s = null) => {
|
|
|
758
758
|
} catch (i) {
|
|
759
759
|
throw s(m.silentLoginAsync_error, i), i;
|
|
760
760
|
}
|
|
761
|
-
},
|
|
761
|
+
}, Ze = (e, n, s, t, o) => (r = null, i = void 0) => {
|
|
762
762
|
r = { ...r };
|
|
763
|
-
const c = (d, f, l) =>
|
|
763
|
+
const c = (d, f, l) => ie(n, s, t.bind(o))(d, f, l);
|
|
764
764
|
return (async () => {
|
|
765
|
-
o.timeoutId &&
|
|
765
|
+
o.timeoutId && B.clearTimeout(o.timeoutId);
|
|
766
766
|
let d;
|
|
767
767
|
r && "state" in r && (d = r.state, delete r.state);
|
|
768
768
|
try {
|
|
@@ -771,13 +771,13 @@ const V = (e, n, s = null) => {
|
|
|
771
771
|
prompt: "none"
|
|
772
772
|
}, d, i);
|
|
773
773
|
if (l)
|
|
774
|
-
return o.tokens = l.tokens, t(m.token_aquired, {}), o.timeoutId =
|
|
774
|
+
return o.tokens = l.tokens, t(m.token_aquired, {}), o.timeoutId = J(o, o.tokens.expiresAt, r), {};
|
|
775
775
|
} catch (f) {
|
|
776
776
|
return f;
|
|
777
777
|
}
|
|
778
778
|
})();
|
|
779
|
-
},
|
|
780
|
-
const c = (a, d = void 0, f = void 0) =>
|
|
779
|
+
}, en = (e, n, s) => (t, o, r, i = !1) => {
|
|
780
|
+
const c = (a, d = void 0, f = void 0) => ie(e.configurationName, s, e.publishEvent.bind(e))(a, d, f);
|
|
781
781
|
return new Promise((a, d) => {
|
|
782
782
|
if (s.silent_login_uri && s.silent_redirect_uri && s.monitor_session && t && r && !i) {
|
|
783
783
|
const f = () => {
|
|
@@ -813,7 +813,7 @@ const V = (e, n, s = null) => {
|
|
|
813
813
|
} else
|
|
814
814
|
a(null);
|
|
815
815
|
});
|
|
816
|
-
},
|
|
816
|
+
}, Ae = (e) => {
|
|
817
817
|
const n = e.match(
|
|
818
818
|
// eslint-disable-next-line no-useless-escape
|
|
819
819
|
/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/
|
|
@@ -835,16 +835,16 @@ const V = (e, n, s = null) => {
|
|
|
835
835
|
search: s,
|
|
836
836
|
hash: t
|
|
837
837
|
};
|
|
838
|
-
},
|
|
839
|
-
const n =
|
|
838
|
+
}, Cn = (e) => {
|
|
839
|
+
const n = Ae(e);
|
|
840
840
|
let { path: s } = n;
|
|
841
841
|
s.endsWith("/") && (s = s.slice(0, -1));
|
|
842
842
|
let { hash: t } = n;
|
|
843
843
|
return t === "#_=_" && (t = ""), t && (s += t), s;
|
|
844
|
-
},
|
|
845
|
-
const n =
|
|
846
|
-
return
|
|
847
|
-
},
|
|
844
|
+
}, X = (e) => {
|
|
845
|
+
const n = Ae(e), { search: s } = n;
|
|
846
|
+
return nn(s);
|
|
847
|
+
}, nn = (e) => {
|
|
848
848
|
const n = {};
|
|
849
849
|
let s, t, o;
|
|
850
850
|
const r = e.split("&");
|
|
@@ -852,27 +852,27 @@ const V = (e, n, s = null) => {
|
|
|
852
852
|
s = r[t].split("="), n[decodeURIComponent(s[0])] = decodeURIComponent(s[1]);
|
|
853
853
|
return n;
|
|
854
854
|
};
|
|
855
|
-
function
|
|
855
|
+
function Se(e) {
|
|
856
856
|
return new TextEncoder().encode(e);
|
|
857
857
|
}
|
|
858
|
-
function
|
|
858
|
+
function ve(e) {
|
|
859
859
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
|
|
860
860
|
}
|
|
861
|
-
function
|
|
861
|
+
function sn(e) {
|
|
862
862
|
return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function(t, o) {
|
|
863
863
|
return String.fromCharCode(parseInt(o, 16));
|
|
864
864
|
});
|
|
865
865
|
}
|
|
866
|
-
function
|
|
866
|
+
function Te(e) {
|
|
867
867
|
let n = "";
|
|
868
868
|
return e.forEach(function(s) {
|
|
869
869
|
n += String.fromCharCode(s);
|
|
870
|
-
}),
|
|
870
|
+
}), ve(n);
|
|
871
871
|
}
|
|
872
872
|
function _e(e) {
|
|
873
|
-
return
|
|
873
|
+
return ve(sn(e));
|
|
874
874
|
}
|
|
875
|
-
const
|
|
875
|
+
const tn = {
|
|
876
876
|
importKeyAlgorithm: {
|
|
877
877
|
name: "ECDSA",
|
|
878
878
|
namedCurve: "P-256",
|
|
@@ -885,7 +885,7 @@ const on = {
|
|
|
885
885
|
},
|
|
886
886
|
digestAlgorithm: { name: "SHA-256" },
|
|
887
887
|
jwtHeaderAlgorithm: "ES256"
|
|
888
|
-
},
|
|
888
|
+
}, on = async (e, n, s, t, o = "dpop+jwt") => {
|
|
889
889
|
switch (e = Object.assign({}, e), n.typ = o, n.alg = t.jwtHeaderAlgorithm, n.alg) {
|
|
890
890
|
case "ES256":
|
|
891
891
|
n.jwk = { kty: e.kty, crv: e.crv, x: e.x, y: e.y };
|
|
@@ -903,20 +903,20 @@ const on = {
|
|
|
903
903
|
// @ts-ignore
|
|
904
904
|
// JWT "claims" are really a JSON-defined JWS "payload"
|
|
905
905
|
payload: _e(JSON.stringify(s))
|
|
906
|
-
}, i = t.importKeyAlgorithm, c = !0, a = ["sign"], d = await window.crypto.subtle.importKey("jwk", e, i, c, a), f =
|
|
907
|
-
return r.signature =
|
|
906
|
+
}, i = t.importKeyAlgorithm, c = !0, a = ["sign"], d = await window.crypto.subtle.importKey("jwk", e, i, c, a), f = Se(`${r.protected}.${r.payload}`), l = t.signAlgorithm, u = await window.crypto.subtle.sign(l, d, f);
|
|
907
|
+
return r.signature = Te(new Uint8Array(u)), `${r.protected}.${r.payload}.${r.signature}`;
|
|
908
908
|
};
|
|
909
|
-
var
|
|
910
|
-
const
|
|
909
|
+
var rn = { sign: on };
|
|
910
|
+
const an = async (e) => {
|
|
911
911
|
const n = e, s = !0, t = ["sign", "verify"], o = await window.crypto.subtle.generateKey(n, s, t);
|
|
912
912
|
return await window.crypto.subtle.exportKey("jwk", o.privateKey);
|
|
913
|
-
},
|
|
913
|
+
}, cn = (e) => {
|
|
914
914
|
const n = Object.assign({}, e);
|
|
915
915
|
return delete n.d, n.key_ops = ["verify"], n;
|
|
916
|
-
},
|
|
917
|
-
generate:
|
|
918
|
-
neuter:
|
|
919
|
-
},
|
|
916
|
+
}, ln = {
|
|
917
|
+
generate: an,
|
|
918
|
+
neuter: cn
|
|
919
|
+
}, un = async (e, n) => {
|
|
920
920
|
let s;
|
|
921
921
|
switch (e.kty) {
|
|
922
922
|
case "EC":
|
|
@@ -928,38 +928,38 @@ const cn = async (e) => {
|
|
|
928
928
|
default:
|
|
929
929
|
throw new Error("Unknown or not implemented JWK type");
|
|
930
930
|
}
|
|
931
|
-
const t = await window.crypto.subtle.digest(n,
|
|
932
|
-
return
|
|
931
|
+
const t = await window.crypto.subtle.digest(n, Se(s));
|
|
932
|
+
return Te(new Uint8Array(t));
|
|
933
933
|
};
|
|
934
|
-
var
|
|
935
|
-
const
|
|
934
|
+
var fn = { thumbprint: un };
|
|
935
|
+
const dn = async (e) => await ln.generate(e), be = (e) => async (n, s = "POST", t, o = {}) => {
|
|
936
936
|
const r = {
|
|
937
937
|
// https://www.rfc-editor.org/rfc/rfc9449.html#name-concept
|
|
938
|
-
jti: btoa(
|
|
938
|
+
jti: btoa(_n()),
|
|
939
939
|
htm: s,
|
|
940
940
|
htu: t,
|
|
941
941
|
iat: Math.round(Date.now() / 1e3),
|
|
942
942
|
...o
|
|
943
|
-
}, i = await
|
|
944
|
-
return await
|
|
945
|
-
},
|
|
943
|
+
}, i = await fn.thumbprint(n, e.digestAlgorithm);
|
|
944
|
+
return await rn.sign(n, { kid: i }, r, e);
|
|
945
|
+
}, _n = () => {
|
|
946
946
|
const e = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", n = "0123456789abcdef";
|
|
947
947
|
let s = 0, t = "";
|
|
948
948
|
for (let o = 0; o < 36; o++)
|
|
949
949
|
e[o] !== "-" && e[o] !== "4" && (s = Math.random() * 16 | 0), e[o] === "x" ? t += n[s] : e[o] === "y" ? (s &= 3, s |= 8, t += n[s]) : t += e[o];
|
|
950
950
|
return t;
|
|
951
|
-
},
|
|
951
|
+
}, hn = (e, n, s, t, o) => (r = void 0, i = null, c = !1, a = void 0) => {
|
|
952
952
|
const d = i;
|
|
953
953
|
return i = { ...i }, (async () => {
|
|
954
954
|
const l = r || o.getPath();
|
|
955
|
-
if ("state" in i || (i.state =
|
|
955
|
+
if ("state" in i || (i.state = se(16)), s(m.loginAsync_begin, {}), i)
|
|
956
956
|
for (const u of Object.keys(i))
|
|
957
957
|
u.endsWith(":token_request") && delete i[u];
|
|
958
958
|
try {
|
|
959
959
|
const u = c ? n.silent_redirect_uri : n.redirect_uri;
|
|
960
960
|
a || (a = n.scope);
|
|
961
961
|
const y = n.extras ? { ...n.extras, ...i } : i;
|
|
962
|
-
y.nonce || (y.nonce =
|
|
962
|
+
y.nonce || (y.nonce = se(12));
|
|
963
963
|
const g = { nonce: y.nonce }, _ = await C(n, e), h = await t(n.authority, n.authority_configuration);
|
|
964
964
|
let A;
|
|
965
965
|
if (_)
|
|
@@ -975,15 +975,15 @@ const _n = async (e) => await un.generate(e), Te = (e) => async (n, s = "POST",
|
|
|
975
975
|
response_type: "code",
|
|
976
976
|
...y
|
|
977
977
|
};
|
|
978
|
-
await
|
|
978
|
+
await Ye(A, o)(h.authorizationEndpoint, S);
|
|
979
979
|
} catch (u) {
|
|
980
980
|
throw s(m.loginAsync_error, u), u;
|
|
981
981
|
}
|
|
982
982
|
})();
|
|
983
|
-
},
|
|
983
|
+
}, yn = (e) => async (n = !1) => {
|
|
984
984
|
try {
|
|
985
985
|
e.publishEvent(m.loginCallbackAsync_begin, {});
|
|
986
|
-
const s = e.configuration, t = s.client_id, o = n ? s.silent_redirect_uri : s.redirect_uri, r = s.authority, i = s.token_request_timeout, c = await e.initAsync(r, s.authority_configuration), a = e.location.getCurrentHref(), f =
|
|
986
|
+
const s = e.configuration, t = s.client_id, o = n ? s.silent_redirect_uri : s.redirect_uri, r = s.authority, i = s.token_request_timeout, c = await e.initAsync(r, s.authority_configuration), a = e.location.getCurrentHref(), f = X(a).session_state, l = await C(s, e.configurationName);
|
|
987
987
|
let u, y, g, _;
|
|
988
988
|
if (l)
|
|
989
989
|
await l.initAsync(c, "loginCallbackAsync", s), await l.setSessionStateAsync(f), y = await l.getNonceAsync(), g = l.getLoginParams(), _ = await l.getStateAsync(), l.startKeepAliveServiceWorker(), u = l;
|
|
@@ -991,7 +991,7 @@ const _n = async (e) => await un.generate(e), Te = (e) => async (n, s = "POST",
|
|
|
991
991
|
const v = I(e.configurationName, s.storage ?? sessionStorage);
|
|
992
992
|
await v.setSessionStateAsync(f), y = await v.getNonceAsync(), g = v.getLoginParams(), _ = await v.getStateAsync(), u = v;
|
|
993
993
|
}
|
|
994
|
-
const h =
|
|
994
|
+
const h = X(a);
|
|
995
995
|
if (h.error || h.error_description)
|
|
996
996
|
throw new Error(`Error from OIDC server: ${h.error} - ${h.error_description}`);
|
|
997
997
|
if (h.iss && h.iss !== c.issuer)
|
|
@@ -1010,15 +1010,15 @@ const _n = async (e) => await un.generate(e), Te = (e) => async (n, s = "POST",
|
|
|
1010
1010
|
if (g && g.extras)
|
|
1011
1011
|
for (const [v, W] of Object.entries(g.extras))
|
|
1012
1012
|
v.endsWith(":token_request") && (S[v.replace(":token_request", "")] = W);
|
|
1013
|
-
const b = c.tokenEndpoint,
|
|
1013
|
+
const b = c.tokenEndpoint, P = {};
|
|
1014
1014
|
if (s.demonstrating_proof_of_possession) {
|
|
1015
|
-
const v = await
|
|
1016
|
-
l ? await l.setDemonstratingProofOfPossessionJwkAsync(v) : await I(e.configurationName, s.storage).setDemonstratingProofOfPossessionJwkAsync(v),
|
|
1015
|
+
const v = await dn(s.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm);
|
|
1016
|
+
l ? await l.setDemonstratingProofOfPossessionJwkAsync(v) : await I(e.configurationName, s.storage).setDemonstratingProofOfPossessionJwkAsync(v), P.DPoP = await be(s.demonstrating_proof_of_possession_configuration)(v, "POST", b);
|
|
1017
1017
|
}
|
|
1018
|
-
const p = await
|
|
1018
|
+
const p = await Xe(u)(
|
|
1019
1019
|
b,
|
|
1020
1020
|
{ ...A, ...S },
|
|
1021
|
-
|
|
1021
|
+
P,
|
|
1022
1022
|
e.configuration.token_renew_mode,
|
|
1023
1023
|
i
|
|
1024
1024
|
);
|
|
@@ -1028,7 +1028,7 @@ const _n = async (e) => await un.generate(e), Te = (e) => async (n, s = "POST",
|
|
|
1028
1028
|
const w = p.data.tokens, E = p.data.demonstratingProofOfPossessionNonce;
|
|
1029
1029
|
if (p.data.state !== S.state)
|
|
1030
1030
|
throw new Error("state is not valid");
|
|
1031
|
-
const { isValid: T, reason: D } =
|
|
1031
|
+
const { isValid: T, reason: D } = ge(w, y.nonce, c);
|
|
1032
1032
|
if (!T)
|
|
1033
1033
|
throw new Error(`Tokens are not OpenID valid, reason: ${D}`);
|
|
1034
1034
|
if (l) {
|
|
@@ -1054,11 +1054,11 @@ const _n = async (e) => await un.generate(e), Te = (e) => async (n, s = "POST",
|
|
|
1054
1054
|
}, he = {
|
|
1055
1055
|
access_token: "access_token",
|
|
1056
1056
|
refresh_token: "refresh_token"
|
|
1057
|
-
},
|
|
1058
|
-
|
|
1057
|
+
}, gn = (e) => async (n) => {
|
|
1058
|
+
B.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
1059
1059
|
const s = await C(e.configuration, e.configurationName);
|
|
1060
1060
|
s ? await s.clearAsync(n) : await I(e.configurationName, e.configuration.storage).clearAsync(n), e.tokens = null, e.userInfo = null;
|
|
1061
|
-
},
|
|
1061
|
+
}, kn = (e, n, s, t, o) => async (r = void 0, i = null) => {
|
|
1062
1062
|
const c = e.configuration, a = await e.initAsync(c.authority, c.authority_configuration);
|
|
1063
1063
|
r && typeof r != "string" && (r = void 0, t.warn("callbackPathOrUrl path is not a string"));
|
|
1064
1064
|
const d = r ?? o.getPath();
|
|
@@ -1070,12 +1070,12 @@ const _n = async (e) => await un.generate(e), Te = (e) => async (n, s = "POST",
|
|
|
1070
1070
|
if (g) {
|
|
1071
1071
|
const _ = [], h = e.tokens ? e.tokens.accessToken : null;
|
|
1072
1072
|
if (h && c.logout_tokens_to_invalidate.includes(he.access_token)) {
|
|
1073
|
-
const S = fe(s)(g, h,
|
|
1073
|
+
const S = fe(s)(g, h, te.access_token, c.client_id);
|
|
1074
1074
|
_.push(S);
|
|
1075
1075
|
}
|
|
1076
1076
|
const A = e.tokens ? e.tokens.refreshToken : null;
|
|
1077
1077
|
if (A && c.logout_tokens_to_invalidate.includes(he.refresh_token)) {
|
|
1078
|
-
const S = fe(s)(g, A,
|
|
1078
|
+
const S = fe(s)(g, A, te.refresh_token, c.client_id);
|
|
1079
1079
|
_.push(S);
|
|
1080
1080
|
}
|
|
1081
1081
|
_.length > 0 && await Promise.all(_);
|
|
@@ -1097,11 +1097,11 @@ const _n = async (e) => await un.generate(e), Te = (e) => async (n, s = "POST",
|
|
|
1097
1097
|
o.open(`${a.endSessionEndpoint}${g}`);
|
|
1098
1098
|
} else
|
|
1099
1099
|
o.reload();
|
|
1100
|
-
},
|
|
1100
|
+
}, mn = (e) => async (n = !1) => {
|
|
1101
1101
|
if (e.userInfo != null && !n)
|
|
1102
1102
|
return e.userInfo;
|
|
1103
|
-
for (; e.tokens && !
|
|
1104
|
-
await
|
|
1103
|
+
for (; e.tokens && !ee(e.tokens); )
|
|
1104
|
+
await F({ milliseconds: 200 });
|
|
1105
1105
|
if (!e.tokens)
|
|
1106
1106
|
return null;
|
|
1107
1107
|
const s = e.tokens.accessToken;
|
|
@@ -1117,7 +1117,7 @@ const _n = async (e) => await un.generate(e), Te = (e) => async (n, s = "POST",
|
|
|
1117
1117
|
})(s);
|
|
1118
1118
|
return e.userInfo = c, c;
|
|
1119
1119
|
};
|
|
1120
|
-
class
|
|
1120
|
+
class z {
|
|
1121
1121
|
open(n) {
|
|
1122
1122
|
window.open(n, "_self");
|
|
1123
1123
|
}
|
|
@@ -1135,7 +1135,7 @@ class Y {
|
|
|
1135
1135
|
return window.origin;
|
|
1136
1136
|
}
|
|
1137
1137
|
}
|
|
1138
|
-
const
|
|
1138
|
+
const pn = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), wn = (e) => {
|
|
1139
1139
|
const n = e.appVersion, s = e.userAgent, t = "-";
|
|
1140
1140
|
let o = t;
|
|
1141
1141
|
const r = [
|
|
@@ -1192,7 +1192,7 @@ const wn = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os ===
|
|
|
1192
1192
|
osVersion: i
|
|
1193
1193
|
};
|
|
1194
1194
|
};
|
|
1195
|
-
function
|
|
1195
|
+
function An() {
|
|
1196
1196
|
const e = navigator.userAgent;
|
|
1197
1197
|
let n, s = e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
1198
1198
|
if (/trident/i.test(s[1]))
|
|
@@ -1210,13 +1210,13 @@ function Sn() {
|
|
|
1210
1210
|
version: s[1]
|
|
1211
1211
|
};
|
|
1212
1212
|
}
|
|
1213
|
-
const
|
|
1214
|
-
const { name: e, version: n } =
|
|
1213
|
+
const Sn = () => {
|
|
1214
|
+
const { name: e, version: n } = An();
|
|
1215
1215
|
if (e === "chrome" && parseInt(n) <= 70 || e === "opera" && (!n || parseInt(n.split(".")[0]) < 80) || e === "ie")
|
|
1216
1216
|
return !1;
|
|
1217
|
-
const s =
|
|
1218
|
-
return !
|
|
1219
|
-
},
|
|
1217
|
+
const s = wn(navigator);
|
|
1218
|
+
return !pn(s);
|
|
1219
|
+
}, vn = async (e) => {
|
|
1220
1220
|
let n;
|
|
1221
1221
|
if (e.tokens != null)
|
|
1222
1222
|
return !1;
|
|
@@ -1228,7 +1228,7 @@ const vn = () => {
|
|
|
1228
1228
|
if (o) {
|
|
1229
1229
|
n.startKeepAliveServiceWorker(), e.tokens = o;
|
|
1230
1230
|
const r = n.getLoginParams(e.configurationName);
|
|
1231
|
-
e.timeoutId =
|
|
1231
|
+
e.timeoutId = J(e, e.tokens.expiresAt, r.extras);
|
|
1232
1232
|
const i = await n.getSessionStateAsync();
|
|
1233
1233
|
return await e.startCheckSessionAsync(t.check_session_iframe, s.client_id, i), e.publishEvent(m.tryKeepExistingSessionAsync_end, {
|
|
1234
1234
|
success: !0,
|
|
@@ -1245,9 +1245,9 @@ const vn = () => {
|
|
|
1245
1245
|
});
|
|
1246
1246
|
const o = I(e.configurationName, s.storage ?? sessionStorage), { tokens: r } = await o.initAsync();
|
|
1247
1247
|
if (r) {
|
|
1248
|
-
e.tokens =
|
|
1248
|
+
e.tokens = Q(r, null, s.token_renew_mode);
|
|
1249
1249
|
const i = o.getLoginParams();
|
|
1250
|
-
e.timeoutId =
|
|
1250
|
+
e.timeoutId = J(e, e.tokens.expiresAt, i.extras);
|
|
1251
1251
|
const c = await o.getSessionStateAsync();
|
|
1252
1252
|
return await e.startCheckSessionAsync(t.check_session_iframe, s.client_id, c), e.publishEvent(m.tryKeepExistingSessionAsync_end, {
|
|
1253
1253
|
success: !0,
|
|
@@ -1262,40 +1262,40 @@ const vn = () => {
|
|
|
1262
1262
|
} catch (s) {
|
|
1263
1263
|
return console.error(s), n && await n.clearAsync(), e.publishEvent(m.tryKeepExistingSessionAsync_error, "tokens inside ServiceWorker are invalid"), !1;
|
|
1264
1264
|
}
|
|
1265
|
-
},
|
|
1266
|
-
class
|
|
1265
|
+
}, Tn = () => fetch;
|
|
1266
|
+
class oe {
|
|
1267
1267
|
constructor(n) {
|
|
1268
1268
|
this.authorizationEndpoint = n.authorization_endpoint, this.tokenEndpoint = n.token_endpoint, this.revocationEndpoint = n.revocation_endpoint, this.userInfoEndpoint = n.userinfo_endpoint, this.checkSessionIframe = n.check_session_iframe, this.issuer = n.issuer, this.endSessionEndpoint = n.end_session_endpoint;
|
|
1269
1269
|
}
|
|
1270
1270
|
}
|
|
1271
|
-
const L = {},
|
|
1271
|
+
const L = {}, bn = (e, n = new z()) => (s, t = "default") => (L[t] || (L[t] = new N(s, t, e, n)), L[t]), Pn = async (e) => {
|
|
1272
1272
|
const { parsedTokens: n, callbackPath: s } = await e.loginCallbackAsync();
|
|
1273
|
-
return e.timeoutId =
|
|
1274
|
-
},
|
|
1275
|
-
constructor(n, s = "default", t, o = new
|
|
1273
|
+
return e.timeoutId = J(e, n.expiresAt), { callbackPath: s };
|
|
1274
|
+
}, On = (e) => Math.floor(Math.random() * e), M = class M {
|
|
1275
|
+
constructor(n, s = "default", t, o = new z()) {
|
|
1276
1276
|
this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.logoutPromise = null;
|
|
1277
1277
|
let r = n.silent_login_uri;
|
|
1278
1278
|
n.silent_redirect_uri && !n.silent_login_uri && (r = `${n.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
|
|
1279
1279
|
let i = n.refresh_time_before_tokens_expiration_in_second ?? 120;
|
|
1280
|
-
i > 60 && (i = i - Math.floor(Math.random() * 40)), this.location = o ?? new
|
|
1281
|
-
const c = n.service_worker_update_require_callback ??
|
|
1280
|
+
i > 60 && (i = i - Math.floor(Math.random() * 40)), this.location = o ?? new z();
|
|
1281
|
+
const c = n.service_worker_update_require_callback ?? We(this.location);
|
|
1282
1282
|
this.configuration = {
|
|
1283
1283
|
...n,
|
|
1284
1284
|
silent_login_uri: r,
|
|
1285
1285
|
monitor_session: n.monitor_session ?? !1,
|
|
1286
1286
|
refresh_time_before_tokens_expiration_in_second: i,
|
|
1287
1287
|
silent_login_timeout: n.silent_login_timeout ?? 12e3,
|
|
1288
|
-
token_renew_mode: n.token_renew_mode ??
|
|
1288
|
+
token_renew_mode: n.token_renew_mode ?? Z.access_token_or_id_token_invalid,
|
|
1289
1289
|
demonstrating_proof_of_possession: n.demonstrating_proof_of_possession ?? !1,
|
|
1290
1290
|
authority_timeout_wellknowurl_in_millisecond: n.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
1291
1291
|
logout_tokens_to_invalidate: n.logout_tokens_to_invalidate ?? ["access_token", "refresh_token"],
|
|
1292
1292
|
service_worker_update_require_callback: c,
|
|
1293
|
-
service_worker_activate: n.service_worker_activate ??
|
|
1294
|
-
demonstrating_proof_of_possession_configuration: n.demonstrating_proof_of_possession_configuration ??
|
|
1295
|
-
}, this.getFetch = t ??
|
|
1293
|
+
service_worker_activate: n.service_worker_activate ?? Sn,
|
|
1294
|
+
demonstrating_proof_of_possession_configuration: n.demonstrating_proof_of_possession_configuration ?? tn
|
|
1295
|
+
}, this.getFetch = t ?? Tn, this.configurationName = s, this.tokens = null, this.userInfo = null, this.events = [], this.timeoutId = null, this.loginCallbackWithAutoTokensRenewAsync.bind(this), this.initAsync.bind(this), this.loginCallbackAsync.bind(this), this.subscribeEvents.bind(this), this.removeEventSubscription.bind(this), this.publishEvent.bind(this), this.destroyAsync.bind(this), this.logoutAsync.bind(this), this.renewTokensAsync.bind(this), this.initAsync(this.configuration.authority, this.configuration.authority_configuration);
|
|
1296
1296
|
}
|
|
1297
1297
|
subscribeEvents(n) {
|
|
1298
|
-
const s =
|
|
1298
|
+
const s = On(9999999999999).toString();
|
|
1299
1299
|
return this.events.push({ id: s, func: n }), s;
|
|
1300
1300
|
}
|
|
1301
1301
|
removeEventSubscription(n) {
|
|
@@ -1316,13 +1316,13 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1316
1316
|
}
|
|
1317
1317
|
_silentLoginCallbackFromIFrame() {
|
|
1318
1318
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1319
|
-
const n = this.location, s =
|
|
1319
|
+
const n = this.location, s = X(n.getCurrentHref());
|
|
1320
1320
|
window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState: s.session_state })}`, n.getOrigin());
|
|
1321
1321
|
}
|
|
1322
1322
|
}
|
|
1323
1323
|
_silentLoginErrorCallbackFromIFrame(n = null) {
|
|
1324
1324
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1325
|
-
const s = this.location, t =
|
|
1325
|
+
const s = this.location, t = X(s.getCurrentHref());
|
|
1326
1326
|
t.error ? window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({ error: t.error })}`, s.getOrigin()) : window.parent.postMessage(`${this.configurationName}_oidc_exception:${JSON.stringify({ error: n == null ? "" : n.toString() })}`, s.getOrigin());
|
|
1327
1327
|
}
|
|
1328
1328
|
}
|
|
@@ -1338,7 +1338,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1338
1338
|
return this.initPromise;
|
|
1339
1339
|
const t = async () => {
|
|
1340
1340
|
if (s != null)
|
|
1341
|
-
return new
|
|
1341
|
+
return new oe({
|
|
1342
1342
|
authorization_endpoint: s.authorization_endpoint,
|
|
1343
1343
|
end_session_endpoint: s.end_session_endpoint,
|
|
1344
1344
|
revocation_endpoint: s.revocation_endpoint,
|
|
@@ -1348,30 +1348,30 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1348
1348
|
issuer: s.issuer
|
|
1349
1349
|
});
|
|
1350
1350
|
const r = await C(this.configuration, this.configurationName) ? window.localStorage : null;
|
|
1351
|
-
return await
|
|
1351
|
+
return await He(this.getFetch())(n, this.configuration.authority_time_cache_wellknowurl_in_second ?? 60 * 60, r, this.configuration.authority_timeout_wellknowurl_in_millisecond);
|
|
1352
1352
|
};
|
|
1353
1353
|
return this.initPromise = t(), this.initPromise.then((o) => (this.initPromise = null, o));
|
|
1354
1354
|
}
|
|
1355
1355
|
async tryKeepExistingSessionAsync() {
|
|
1356
|
-
return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise =
|
|
1356
|
+
return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise = vn(this), this.tryKeepExistingSessionPromise.then((n) => (this.tryKeepExistingSessionPromise = null, n)));
|
|
1357
1357
|
}
|
|
1358
1358
|
async startCheckSessionAsync(n, s, t, o = !1) {
|
|
1359
|
-
await
|
|
1359
|
+
await en(this, L, this.configuration)(n, s, t, o);
|
|
1360
1360
|
}
|
|
1361
1361
|
async loginAsync(n = void 0, s = null, t = !1, o = void 0, r = !1) {
|
|
1362
|
-
return this.loginPromise !== null ? this.loginPromise : r ?
|
|
1362
|
+
return this.loginPromise !== null ? this.loginPromise : r ? Ze(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(s, o) : (this.loginPromise = hn(this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this), this.location)(n, s, t, o), this.loginPromise.then((i) => (this.loginPromise = null, i)));
|
|
1363
1363
|
}
|
|
1364
1364
|
async loginCallbackAsync(n = !1) {
|
|
1365
1365
|
if (this.loginCallbackPromise !== null)
|
|
1366
1366
|
return this.loginCallbackPromise;
|
|
1367
1367
|
const s = async () => {
|
|
1368
|
-
const t = await
|
|
1369
|
-
return this.tokens = o, await C(this.configuration, this.configurationName) || I(this.configurationName, this.configuration.storage).setTokens(o), this.publishEvent(
|
|
1368
|
+
const t = await yn(this)(n), o = t.tokens;
|
|
1369
|
+
return this.tokens = o, await C(this.configuration, this.configurationName) || I(this.configurationName, this.configuration.storage).setTokens(o), this.publishEvent(M.eventNames.token_aquired, o), { parsedTokens: o, state: t.state, callbackPath: t.callbackPath };
|
|
1370
1370
|
};
|
|
1371
1371
|
return this.loginCallbackPromise = s(), this.loginCallbackPromise.then((t) => (this.loginCallbackPromise = null, t));
|
|
1372
1372
|
}
|
|
1373
1373
|
async generateDemonstrationOfProofOfPossessionAsync(n, s, t) {
|
|
1374
|
-
const o = this.configuration, r = { ath: await
|
|
1374
|
+
const o = this.configuration, r = { ath: await pe(n) }, i = await C(o, this.configurationName);
|
|
1375
1375
|
let c, a;
|
|
1376
1376
|
if (i)
|
|
1377
1377
|
c = await i.getDemonstratingProofOfPossessionNonce(), a = await i.getDemonstratingProofOfPossessionJwkAsync();
|
|
@@ -1379,22 +1379,22 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1379
1379
|
const d = I(this.configurationName, o.storage);
|
|
1380
1380
|
a = await d.getDemonstratingProofOfPossessionJwkAsync(), c = await d.getDemonstratingProofOfPossessionNonce();
|
|
1381
1381
|
}
|
|
1382
|
-
return c && (r.nonce = c), await
|
|
1382
|
+
return c && (r.nonce = c), await be(o.demonstrating_proof_of_possession_configuration)(a, t, s, r);
|
|
1383
1383
|
}
|
|
1384
1384
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1385
1385
|
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise = Pn(this), this.loginCallbackWithAutoTokensRenewPromise.then((n) => (this.loginCallbackWithAutoTokensRenewPromise = null, n)));
|
|
1386
1386
|
}
|
|
1387
1387
|
userInfoAsync(n = !1) {
|
|
1388
|
-
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise =
|
|
1388
|
+
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise = mn(this)(n), this.userInfoPromise.then((s) => (this.userInfoPromise = null, s)));
|
|
1389
1389
|
}
|
|
1390
1390
|
async renewTokensAsync(n = null) {
|
|
1391
1391
|
if (this.renewTokensPromise !== null)
|
|
1392
1392
|
return this.renewTokensPromise;
|
|
1393
1393
|
if (this.timeoutId)
|
|
1394
|
-
return
|
|
1394
|
+
return B.clearTimeout(this.timeoutId), this.renewTokensPromise = we(this, !0, n), this.renewTokensPromise.then((s) => (this.renewTokensPromise = null, s));
|
|
1395
1395
|
}
|
|
1396
1396
|
async destroyAsync(n) {
|
|
1397
|
-
return await
|
|
1397
|
+
return await gn(this)(n);
|
|
1398
1398
|
}
|
|
1399
1399
|
async logoutSameTabAsync(n, s) {
|
|
1400
1400
|
this.configuration.monitor_session && this.configuration.client_id === n && s && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === s && (this.publishEvent(m.logout_from_same_tab, { mmessage: "SessionMonitor", sub: s }), await this.destroyAsync("LOGGED_OUT"));
|
|
@@ -1403,13 +1403,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1403
1403
|
this.configuration.monitor_session && this.configuration.client_id === n && s && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === s && (this.publishEvent(m.logout_from_another_tab, { message: "SessionMonitor", sub: s }), await this.destroyAsync("LOGGED_OUT"));
|
|
1404
1404
|
}
|
|
1405
1405
|
async logoutAsync(n = void 0, s = null) {
|
|
1406
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1406
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = kn(this, L, this.getFetch(), console, this.location)(n, s), this.logoutPromise.then((t) => (this.logoutPromise = null, t)));
|
|
1407
1407
|
}
|
|
1408
1408
|
};
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
const In = (e, n) => async (...s) => {
|
|
1409
|
+
M.getOrCreate = (n, s) => (t, o = "default") => bn(n, s)(t, o), M.eventNames = m;
|
|
1410
|
+
let N = M;
|
|
1411
|
+
const En = (e, n) => async (...s) => {
|
|
1413
1412
|
var u;
|
|
1414
1413
|
const [t, o, ...r] = s, i = o ? { ...o } : { method: "GET" };
|
|
1415
1414
|
let c = new Headers();
|
|
@@ -1425,7 +1424,7 @@ const In = (e, n) => async (...s) => {
|
|
|
1425
1424
|
}
|
|
1426
1425
|
const l = { ...i, headers: c };
|
|
1427
1426
|
return await e(t, l, ...r);
|
|
1428
|
-
},
|
|
1427
|
+
}, U = class U {
|
|
1429
1428
|
constructor(n) {
|
|
1430
1429
|
this._oidc = n;
|
|
1431
1430
|
}
|
|
@@ -1439,7 +1438,7 @@ const In = (e, n) => async (...s) => {
|
|
|
1439
1438
|
this._oidc.publishEvent(n, s);
|
|
1440
1439
|
}
|
|
1441
1440
|
static get(n = "default") {
|
|
1442
|
-
return new
|
|
1441
|
+
return new U(N.get(n));
|
|
1443
1442
|
}
|
|
1444
1443
|
tryKeepExistingSessionAsync() {
|
|
1445
1444
|
return this._oidc.tryKeepExistingSessionAsync();
|
|
@@ -1469,23 +1468,22 @@ const In = (e, n) => async (...s) => {
|
|
|
1469
1468
|
return this._oidc.generateDemonstrationOfProofOfPossessionAsync(n, s, t);
|
|
1470
1469
|
}
|
|
1471
1470
|
async getValidTokenAsync(n = 200, s = 50) {
|
|
1472
|
-
return
|
|
1471
|
+
return Ne(this._oidc, n, s);
|
|
1473
1472
|
}
|
|
1474
1473
|
fetchWithTokens(n) {
|
|
1475
|
-
return
|
|
1474
|
+
return En(n, this);
|
|
1476
1475
|
}
|
|
1477
1476
|
async userInfoAsync(n = !1) {
|
|
1478
1477
|
return this._oidc.userInfoAsync(n);
|
|
1479
1478
|
}
|
|
1480
1479
|
};
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
let xn = X;
|
|
1480
|
+
U.getOrCreate = (n, s = new z()) => (t, o = "default") => new U(N.getOrCreate(n, s)(t, o)), U.eventNames = N.eventNames;
|
|
1481
|
+
let ye = U;
|
|
1484
1482
|
export {
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1483
|
+
ye as OidcClient,
|
|
1484
|
+
z as OidcLocation,
|
|
1485
|
+
Z as TokenRenewMode,
|
|
1486
|
+
Tn as getFetchDefault,
|
|
1487
|
+
X as getParseQueryStringFromLocation,
|
|
1488
|
+
Cn as getPath
|
|
1491
1489
|
};
|