@axa-fr/oidc-client 7.25.10-beta.1717 → 7.25.11
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 +0 -1
- package/dist/index.js +269 -283
- package/dist/index.umd.cjs +2 -2
- package/dist/initWorker.d.ts +0 -1
- package/dist/initWorker.d.ts.map +1 -1
- package/dist/oidc.d.ts.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/initWorker.ts +27 -42
- package/src/oidc.ts +1 -9
- package/src/types.ts +0 -1
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class H {
|
|
2
2
|
open(n) {
|
|
3
3
|
window.location.href = n;
|
|
4
4
|
}
|
|
@@ -17,7 +17,7 @@ class j {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
const le = 2e3, D = console;
|
|
20
|
-
class
|
|
20
|
+
class Ne {
|
|
21
21
|
constructor(n, s, t, o = le, i = !0) {
|
|
22
22
|
this._callback = n, this._client_id = s, this._url = t, this._interval = o || le, this._stopOnError = i;
|
|
23
23
|
const r = t.indexOf("/", t.indexOf("//") + 2);
|
|
@@ -92,7 +92,7 @@ const k = {
|
|
|
92
92
|
n[`oidc.jwk.${e}`] = JSON.stringify(g);
|
|
93
93
|
}, l = () => JSON.parse(n[`oidc.jwk.${e}`]), d = async () => ({ nonce: n[`oidc.nonce.${e}`] }), u = async (g) => {
|
|
94
94
|
n[`oidc.dpop_nonce.${e}`] = g;
|
|
95
|
-
}, _ = () => n[`oidc.dpop_nonce.${e}`], f = () => n[`oidc.${e}`] ? JSON.stringify({ tokens: JSON.parse(n[`oidc.${e}`]).tokens }) : null,
|
|
95
|
+
}, _ = () => n[`oidc.dpop_nonce.${e}`], f = () => n[`oidc.${e}`] ? JSON.stringify({ tokens: JSON.parse(n[`oidc.${e}`]).tokens }) : null, y = {};
|
|
96
96
|
return {
|
|
97
97
|
clearAsync: s,
|
|
98
98
|
initAsync: t,
|
|
@@ -103,11 +103,11 @@ const k = {
|
|
|
103
103
|
setNonceAsync: a,
|
|
104
104
|
getNonceAsync: d,
|
|
105
105
|
setLoginParams: (g) => {
|
|
106
|
-
|
|
106
|
+
y[e] = g, n[`oidc.login.${e}`] = JSON.stringify(g);
|
|
107
107
|
},
|
|
108
108
|
getLoginParams: () => {
|
|
109
109
|
const g = n[`oidc.login.${e}`];
|
|
110
|
-
return g ? (
|
|
110
|
+
return g ? (y[e] || (y[e] = JSON.parse(g)), y[e]) : (console.warn(
|
|
111
111
|
`storage[oidc.login.${e}] is empty, you should have an bad OIDC or code configuration somewhere.`
|
|
112
112
|
), null);
|
|
113
113
|
},
|
|
@@ -125,29 +125,29 @@ const k = {
|
|
|
125
125
|
getDemonstratingProofOfPossessionJwkAsync: l
|
|
126
126
|
};
|
|
127
127
|
};
|
|
128
|
-
var
|
|
129
|
-
const
|
|
128
|
+
var V = /* @__PURE__ */ ((e) => (e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e))(V || {});
|
|
129
|
+
const xe = (e) => decodeURIComponent(
|
|
130
130
|
Array.prototype.map.call(atob(e), (n) => "%" + ("00" + n.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
131
|
-
),
|
|
131
|
+
), We = (e) => JSON.parse(xe(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), ue = (e) => {
|
|
132
132
|
try {
|
|
133
|
-
return e &&
|
|
133
|
+
return e && Le(e, ".") === 2 ? We(e.split(".")[1]) : null;
|
|
134
134
|
} catch (n) {
|
|
135
135
|
console.warn(n);
|
|
136
136
|
}
|
|
137
137
|
return null;
|
|
138
|
-
},
|
|
138
|
+
}, Le = (e, n) => e.split(n).length - 1, z = {
|
|
139
139
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
140
140
|
access_token_invalid: "access_token_invalid",
|
|
141
141
|
id_token_invalid: "id_token_invalid"
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function De(e, n, s) {
|
|
144
144
|
if (e.issuedAt) {
|
|
145
145
|
if (typeof e.issuedAt == "string")
|
|
146
146
|
return parseInt(e.issuedAt, 10);
|
|
147
147
|
} else return n && n.iat ? n.iat : s && s.iat ? s.iat : (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
148
148
|
return e.issuedAt;
|
|
149
149
|
}
|
|
150
|
-
const
|
|
150
|
+
const te = (e, n = null, s) => {
|
|
151
151
|
if (!e)
|
|
152
152
|
return null;
|
|
153
153
|
let t;
|
|
@@ -156,9 +156,9 @@ const oe = (e, n = null, s) => {
|
|
|
156
156
|
let i;
|
|
157
157
|
n != null && "idToken" in n && !("idToken" in e) ? i = n.idToken : i = e.idToken;
|
|
158
158
|
const r = e.idTokenPayload ? e.idTokenPayload : ue(i), a = r && r.exp ? r.exp : Number.MAX_VALUE, c = t && t.exp ? t.exp : e.issuedAt + o;
|
|
159
|
-
e.issuedAt =
|
|
159
|
+
e.issuedAt = De(e, t, r);
|
|
160
160
|
let l;
|
|
161
|
-
e.expiresAt ? l = e.expiresAt : s ===
|
|
161
|
+
e.expiresAt ? l = e.expiresAt : s === z.access_token_invalid ? l = c : s === z.id_token_invalid ? l = a : l = a < c ? a : c;
|
|
162
162
|
const d = {
|
|
163
163
|
...e,
|
|
164
164
|
idTokenPayload: r,
|
|
@@ -171,7 +171,7 @@ const oe = (e, n = null, s) => {
|
|
|
171
171
|
return { ...d, refreshToken: u };
|
|
172
172
|
}
|
|
173
173
|
return d;
|
|
174
|
-
},
|
|
174
|
+
}, oe = (e, n, s) => {
|
|
175
175
|
if (!e)
|
|
176
176
|
return null;
|
|
177
177
|
if (!e.issued_at) {
|
|
@@ -186,7 +186,7 @@ const oe = (e, n = null, s) => {
|
|
|
186
186
|
tokenType: e.token_type,
|
|
187
187
|
issuedAt: e.issued_at
|
|
188
188
|
};
|
|
189
|
-
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),
|
|
189
|
+
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), te(t, n, s);
|
|
190
190
|
}, K = (e, n) => {
|
|
191
191
|
const s = (/* @__PURE__ */ new Date()).getTime() / 1e3, t = n - s;
|
|
192
192
|
return Math.round(t - e);
|
|
@@ -198,11 +198,11 @@ const oe = (e, n = null, s) => {
|
|
|
198
198
|
e.getTokens(),
|
|
199
199
|
e.configuration.refresh_time_before_tokens_expiration_in_second
|
|
200
200
|
) && t > 0; ) {
|
|
201
|
-
if (e.configuration.token_automatic_renew_mode ==
|
|
201
|
+
if (e.configuration.token_automatic_renew_mode == V.AutomaticOnlyWhenFetchExecuted) {
|
|
202
202
|
await e.renewTokensAsync({});
|
|
203
203
|
break;
|
|
204
204
|
} else
|
|
205
|
-
await
|
|
205
|
+
await ie({ milliseconds: n });
|
|
206
206
|
t = t - 1;
|
|
207
207
|
}
|
|
208
208
|
return {
|
|
@@ -245,31 +245,21 @@ const oe = (e, n = null, s) => {
|
|
|
245
245
|
setInterval: setInterval.bind(e),
|
|
246
246
|
clearInterval: clearInterval.bind(e)
|
|
247
247
|
};
|
|
248
|
-
}(),
|
|
249
|
-
let fe = null,
|
|
250
|
-
const
|
|
248
|
+
}(), q = "7.25.11";
|
|
249
|
+
let fe = null, j;
|
|
250
|
+
const ie = ({ milliseconds: e }) => new Promise((n) => U.setTimeout(n, e)), we = (e = "/") => {
|
|
251
251
|
try {
|
|
252
|
-
|
|
252
|
+
j = new AbortController(), fetch(
|
|
253
253
|
`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`,
|
|
254
|
-
{ signal:
|
|
254
|
+
{ signal: j.signal }
|
|
255
255
|
).catch((t) => {
|
|
256
256
|
console.log(t);
|
|
257
|
-
}),
|
|
257
|
+
}), ie({ milliseconds: 150 * 1e3 }).then(we);
|
|
258
258
|
} catch (n) {
|
|
259
259
|
console.log(n);
|
|
260
260
|
}
|
|
261
|
-
},
|
|
262
|
-
|
|
263
|
-
}, Re = (e = "/") => fetch(`${e}OidcKeepAliveServiceWorker.json`, {
|
|
264
|
-
headers: {
|
|
265
|
-
"oidc-vanilla": "true"
|
|
266
|
-
}
|
|
267
|
-
}).then((n) => n.statusText === "oidc-service-worker").catch((n) => {
|
|
268
|
-
console.log(n);
|
|
269
|
-
}), $e = (e) => async (n, s) => {
|
|
270
|
-
s(), await n.update();
|
|
271
|
-
const t = await n.unregister();
|
|
272
|
-
console.log(`Service worker unregistration ${t ? "successful" : "failed"}`), await Y({ milliseconds: 2e3 }), e.reload();
|
|
261
|
+
}, Y = () => {
|
|
262
|
+
j && j.abort();
|
|
273
263
|
}, Ae = (e) => {
|
|
274
264
|
const n = sessionStorage.getItem(`oidc.tabId.${e}`);
|
|
275
265
|
if (n)
|
|
@@ -287,24 +277,29 @@ const Y = ({ milliseconds: e }) => new Promise((n) => U.setTimeout(n, e)), we =
|
|
|
287
277
|
const s = e.service_worker_relative_url;
|
|
288
278
|
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !s || e.service_worker_activate() === !1)
|
|
289
279
|
return null;
|
|
290
|
-
const t = `${s}?v=${
|
|
280
|
+
const t = `${s}?v=${q}`;
|
|
281
|
+
let o = null;
|
|
282
|
+
e.service_worker_register ? o = await e.service_worker_register(s) : o = await navigator.serviceWorker.register(t, {
|
|
291
283
|
updateViaCache: "none"
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
y.state === "installed" && navigator.serviceWorker.controller && (console.log("New SW waiting – skipWaiting()"), y.postMessage({ type: "SKIP_WAITING" }));
|
|
284
|
+
}), o.addEventListener("updatefound", () => {
|
|
285
|
+
const h = o.installing;
|
|
286
|
+
Y(), h == null || h.addEventListener("statechange", () => {
|
|
287
|
+
h.state === "installed" && navigator.serviceWorker.controller && (Y(), console.log("New SW waiting – skipWaiting()"), h.postMessage({ type: "SKIP_WAITING" }));
|
|
297
288
|
});
|
|
298
289
|
}), navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
299
|
-
|
|
300
|
-
})
|
|
301
|
-
|
|
302
|
-
|
|
290
|
+
console.log("SW controller changed – reloading page"), Y(), window.location.reload();
|
|
291
|
+
});
|
|
292
|
+
try {
|
|
293
|
+
await navigator.serviceWorker.ready, navigator.serviceWorker.controller || await O(o)({ type: "claim" });
|
|
294
|
+
} catch (h) {
|
|
295
|
+
return console.warn(`Failed init ServiceWorker ${h.toString()}`), null;
|
|
296
|
+
}
|
|
297
|
+
const i = async (h) => O(o)({ type: "clear", data: { status: h }, configurationName: n }), r = async (h, b, S) => {
|
|
303
298
|
const m = await O(o)({
|
|
304
299
|
type: "init",
|
|
305
300
|
data: {
|
|
306
|
-
oidcServerConfiguration:
|
|
307
|
-
where:
|
|
301
|
+
oidcServerConfiguration: h,
|
|
302
|
+
where: b,
|
|
308
303
|
oidcConfiguration: {
|
|
309
304
|
token_renew_mode: S.token_renew_mode,
|
|
310
305
|
service_worker_convert_all_requests_to_cors: S.service_worker_convert_all_requests_to_cors
|
|
@@ -312,118 +307,112 @@ const Y = ({ milliseconds: e }) => new Promise((n) => U.setTimeout(n, e)), we =
|
|
|
312
307
|
},
|
|
313
308
|
configurationName: n
|
|
314
309
|
}), x = m.version;
|
|
315
|
-
return x !==
|
|
316
|
-
`Service worker ${x} version mismatch with js client version ${
|
|
317
|
-
),
|
|
318
|
-
tokens:
|
|
310
|
+
return x !== q && console.warn(
|
|
311
|
+
`Service worker ${x} version mismatch with js client version ${q}, unregistering and reloading`
|
|
312
|
+
), {
|
|
313
|
+
tokens: oe(m.tokens, null, S.token_renew_mode),
|
|
319
314
|
status: m.status
|
|
320
315
|
};
|
|
321
|
-
}, a = (
|
|
322
|
-
fe == null && (fe = "not_null", we(
|
|
323
|
-
}, c = (
|
|
316
|
+
}, a = (h = "/") => {
|
|
317
|
+
fe == null && (fe = "not_null", we(h));
|
|
318
|
+
}, c = (h) => O(o)({
|
|
324
319
|
type: "setSessionState",
|
|
325
|
-
data: { sessionState:
|
|
320
|
+
data: { sessionState: h },
|
|
326
321
|
configurationName: n
|
|
327
322
|
}), l = async () => (await O(o)({
|
|
328
323
|
type: "getSessionState",
|
|
329
324
|
data: null,
|
|
330
325
|
configurationName: n
|
|
331
|
-
})).sessionState, d = (
|
|
326
|
+
})).sessionState, d = (h) => (sessionStorage[`oidc.nonce.${n}`] = h.nonce, O(o)({
|
|
332
327
|
type: "setNonce",
|
|
333
|
-
data: { nonce:
|
|
328
|
+
data: { nonce: h },
|
|
334
329
|
configurationName: n
|
|
335
|
-
})), u = async (
|
|
330
|
+
})), u = async (h = !0) => {
|
|
336
331
|
let S = (await O(o)({
|
|
337
332
|
type: "getNonce",
|
|
338
333
|
data: null,
|
|
339
334
|
configurationName: n
|
|
340
335
|
})).nonce;
|
|
341
|
-
return S || (S = sessionStorage[`oidc.nonce.${n}`], console.warn("nonce not found in service worker, using sessionStorage"),
|
|
342
|
-
}, _ = {}, f = (
|
|
343
|
-
_[n] =
|
|
344
|
-
},
|
|
345
|
-
const
|
|
346
|
-
return _[n] || (_[n] = JSON.parse(
|
|
347
|
-
}, p = async (
|
|
336
|
+
return S || (S = sessionStorage[`oidc.nonce.${n}`], console.warn("nonce not found in service worker, using sessionStorage"), h && (await d(S), S = (await u(!1)).nonce)), { nonce: S };
|
|
337
|
+
}, _ = {}, f = (h) => {
|
|
338
|
+
_[n] = h, localStorage[`oidc.login.${n}`] = JSON.stringify(h);
|
|
339
|
+
}, y = () => {
|
|
340
|
+
const h = localStorage[`oidc.login.${n}`];
|
|
341
|
+
return _[n] || (_[n] = JSON.parse(h)), _[n];
|
|
342
|
+
}, p = async (h) => {
|
|
348
343
|
await O(o)({
|
|
349
344
|
type: "setDemonstratingProofOfPossessionNonce",
|
|
350
|
-
data: { demonstratingProofOfPossessionNonce:
|
|
345
|
+
data: { demonstratingProofOfPossessionNonce: h },
|
|
351
346
|
configurationName: n
|
|
352
347
|
});
|
|
353
348
|
}, w = async () => (await O(o)({
|
|
354
349
|
type: "getDemonstratingProofOfPossessionNonce",
|
|
355
350
|
data: null,
|
|
356
351
|
configurationName: n
|
|
357
|
-
})).demonstratingProofOfPossessionNonce, v = async (
|
|
358
|
-
const
|
|
352
|
+
})).demonstratingProofOfPossessionNonce, v = async (h) => {
|
|
353
|
+
const b = JSON.stringify(h);
|
|
359
354
|
await O(o)({
|
|
360
355
|
type: "setDemonstratingProofOfPossessionJwk",
|
|
361
|
-
data: { demonstratingProofOfPossessionJwkJson:
|
|
356
|
+
data: { demonstratingProofOfPossessionJwkJson: b },
|
|
362
357
|
configurationName: n
|
|
363
358
|
});
|
|
364
359
|
}, P = async () => {
|
|
365
|
-
const
|
|
360
|
+
const h = await O(o)({
|
|
366
361
|
type: "getDemonstratingProofOfPossessionJwk",
|
|
367
362
|
data: null,
|
|
368
363
|
configurationName: n
|
|
369
364
|
});
|
|
370
|
-
return
|
|
371
|
-
}, A = async (
|
|
365
|
+
return h.demonstratingProofOfPossessionJwkJson ? JSON.parse(h.demonstratingProofOfPossessionJwkJson) : null;
|
|
366
|
+
}, A = async (h = !0) => {
|
|
372
367
|
let S = (await O(o)({
|
|
373
368
|
type: "getState",
|
|
374
369
|
data: null,
|
|
375
370
|
configurationName: n
|
|
376
371
|
})).state;
|
|
377
|
-
return S || (S = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"),
|
|
378
|
-
}, T = async (
|
|
372
|
+
return S || (S = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"), h && (await T(S), S = await A(!1))), S;
|
|
373
|
+
}, T = async (h) => (sessionStorage[`oidc.state.${n}`] = h, O(o)({
|
|
379
374
|
type: "setState",
|
|
380
|
-
data: { state:
|
|
375
|
+
data: { state: h },
|
|
381
376
|
configurationName: n
|
|
382
|
-
})), g = async (
|
|
377
|
+
})), g = async (h = !0) => {
|
|
383
378
|
let S = (await O(o)({
|
|
384
379
|
type: "getCodeVerifier",
|
|
385
380
|
data: null,
|
|
386
381
|
configurationName: n
|
|
387
382
|
})).codeVerifier;
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
const m = await g(!1);
|
|
391
|
-
console.log("getCodeVerifierAsync", m), S = m.codeVerifier;
|
|
392
|
-
}
|
|
393
|
-
return S;
|
|
394
|
-
}, b = async (y) => (sessionStorage[`oidc.code_verifier.${n}`] = y, O(o)({
|
|
383
|
+
return S || (S = sessionStorage[`oidc.code_verifier.${n}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), h && (await E(S), S = await g(!1))), S;
|
|
384
|
+
}, E = async (h) => (sessionStorage[`oidc.code_verifier.${n}`] = h, O(o)({
|
|
395
385
|
type: "setCodeVerifier",
|
|
396
|
-
data: { codeVerifier:
|
|
386
|
+
data: { codeVerifier: h },
|
|
397
387
|
configurationName: n
|
|
398
388
|
}));
|
|
399
389
|
return {
|
|
400
390
|
clearAsync: i,
|
|
401
391
|
initAsync: r,
|
|
402
392
|
startKeepAliveServiceWorker: () => a(e.service_worker_keep_alive_path),
|
|
403
|
-
isServiceWorkerProxyActiveAsync: () => Re(e.service_worker_keep_alive_path),
|
|
404
393
|
setSessionStateAsync: c,
|
|
405
394
|
getSessionStateAsync: l,
|
|
406
395
|
setNonceAsync: d,
|
|
407
396
|
getNonceAsync: u,
|
|
408
397
|
setLoginParams: f,
|
|
409
|
-
getLoginParams:
|
|
398
|
+
getLoginParams: y,
|
|
410
399
|
getStateAsync: A,
|
|
411
400
|
setStateAsync: T,
|
|
412
401
|
getCodeVerifierAsync: g,
|
|
413
|
-
setCodeVerifierAsync:
|
|
402
|
+
setCodeVerifierAsync: E,
|
|
414
403
|
setDemonstratingProofOfPossessionNonce: p,
|
|
415
404
|
getDemonstratingProofOfPossessionNonce: w,
|
|
416
405
|
setDemonstratingProofOfPossessionJwkAsync: v,
|
|
417
406
|
getDemonstratingProofOfPossessionJwkAsync: P
|
|
418
407
|
};
|
|
419
|
-
}, R = {},
|
|
408
|
+
}, R = {}, Re = (e, n = window.sessionStorage, s) => {
|
|
420
409
|
if (!R[e] && n) {
|
|
421
410
|
const o = n.getItem(e);
|
|
422
411
|
o && (R[e] = JSON.parse(o));
|
|
423
412
|
}
|
|
424
413
|
const t = 1e3 * s;
|
|
425
414
|
return R[e] && R[e].timestamp + t > Date.now() ? R[e].result : null;
|
|
426
|
-
},
|
|
415
|
+
}, $e = (e, n, s = window.sessionStorage) => {
|
|
427
416
|
const t = Date.now();
|
|
428
417
|
R[e] = { result: n, timestamp: t }, s && s.setItem(e, JSON.stringify({ result: n, timestamp: t }));
|
|
429
418
|
};
|
|
@@ -433,7 +422,7 @@ function Se(e) {
|
|
|
433
422
|
function Te(e) {
|
|
434
423
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
|
|
435
424
|
}
|
|
436
|
-
function
|
|
425
|
+
function Ue(e) {
|
|
437
426
|
return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function(s, t) {
|
|
438
427
|
return String.fromCharCode(parseInt(t, 16));
|
|
439
428
|
});
|
|
@@ -445,9 +434,9 @@ const re = (e) => {
|
|
|
445
434
|
}), Te(n);
|
|
446
435
|
};
|
|
447
436
|
function de(e) {
|
|
448
|
-
return Te(
|
|
437
|
+
return Te(Ue(e));
|
|
449
438
|
}
|
|
450
|
-
const
|
|
439
|
+
const Ke = {
|
|
451
440
|
importKeyAlgorithm: {
|
|
452
441
|
name: "ECDSA",
|
|
453
442
|
namedCurve: "P-256",
|
|
@@ -460,7 +449,7 @@ const Fe = {
|
|
|
460
449
|
},
|
|
461
450
|
digestAlgorithm: { name: "SHA-256" },
|
|
462
451
|
jwtHeaderAlgorithm: "ES256"
|
|
463
|
-
},
|
|
452
|
+
}, Fe = (e) => async (n, s, t, o, i = "dpop+jwt") => {
|
|
464
453
|
switch (n = Object.assign({}, n), s.typ = i, s.alg = o.jwtHeaderAlgorithm, s.alg) {
|
|
465
454
|
case "ES256":
|
|
466
455
|
s.jwk = { kty: n.kty, crv: n.crv, x: n.x, y: n.y };
|
|
@@ -480,16 +469,16 @@ const Fe = {
|
|
|
480
469
|
payload: de(JSON.stringify(t))
|
|
481
470
|
}, a = o.importKeyAlgorithm, c = !0, l = ["sign"], d = await e.crypto.subtle.importKey("jwk", n, a, c, l), u = Se(`${r.protected}.${r.payload}`), _ = o.signAlgorithm, f = await e.crypto.subtle.sign(_, d, u);
|
|
482
471
|
return r.signature = re(new Uint8Array(f)), `${r.protected}.${r.payload}.${r.signature}`;
|
|
483
|
-
},
|
|
472
|
+
}, Ve = { sign: Fe }, Me = (e) => async (n) => {
|
|
484
473
|
const s = n, t = !0, o = ["sign", "verify"], i = await e.crypto.subtle.generateKey(s, t, o);
|
|
485
474
|
return await e.crypto.subtle.exportKey("jwk", i.privateKey);
|
|
486
|
-
},
|
|
475
|
+
}, Je = (e) => {
|
|
487
476
|
const n = Object.assign({}, e);
|
|
488
477
|
return delete n.d, n.key_ops = ["verify"], n;
|
|
489
|
-
},
|
|
490
|
-
generate:
|
|
491
|
-
neuter:
|
|
492
|
-
},
|
|
478
|
+
}, Be = {
|
|
479
|
+
generate: Me,
|
|
480
|
+
neuter: Je
|
|
481
|
+
}, He = (e) => async (n, s) => {
|
|
493
482
|
let t;
|
|
494
483
|
switch (n.kty) {
|
|
495
484
|
case "EC":
|
|
@@ -503,77 +492,77 @@ const Fe = {
|
|
|
503
492
|
}
|
|
504
493
|
const o = await e.crypto.subtle.digest(s, Se(t));
|
|
505
494
|
return re(new Uint8Array(o));
|
|
506
|
-
},
|
|
495
|
+
}, je = { thumbprint: He }, Ge = (e) => async (n) => await Be.generate(e)(n), ve = (e) => (n) => async (s, t = "POST", o, i = {}) => {
|
|
507
496
|
const r = {
|
|
508
497
|
// https://www.rfc-editor.org/rfc/rfc9449.html#name-concept
|
|
509
|
-
jti: btoa(
|
|
498
|
+
jti: btoa(qe()),
|
|
510
499
|
htm: t,
|
|
511
500
|
htu: o,
|
|
512
501
|
iat: Math.round(Date.now() / 1e3),
|
|
513
502
|
...i
|
|
514
|
-
}, a = await
|
|
503
|
+
}, a = await je.thumbprint(e)(
|
|
515
504
|
s,
|
|
516
505
|
n.digestAlgorithm
|
|
517
506
|
);
|
|
518
|
-
return await
|
|
507
|
+
return await Ve.sign(e)(
|
|
519
508
|
s,
|
|
520
509
|
{ kid: a },
|
|
521
510
|
r,
|
|
522
511
|
n
|
|
523
512
|
);
|
|
524
|
-
},
|
|
513
|
+
}, qe = () => {
|
|
525
514
|
const e = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", n = "0123456789abcdef";
|
|
526
515
|
let s = 0, t = "";
|
|
527
516
|
for (let o = 0; o < 36; o++)
|
|
528
517
|
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];
|
|
529
518
|
return t;
|
|
530
|
-
},
|
|
519
|
+
}, Ee = () => {
|
|
531
520
|
const e = typeof window < "u" && !!window.crypto, n = e && !!window.crypto.subtle;
|
|
532
521
|
return { hasCrypto: e, hasSubtleCrypto: n };
|
|
533
|
-
},
|
|
522
|
+
}, Q = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", Ye = (e) => {
|
|
534
523
|
const n = [];
|
|
535
524
|
for (let s = 0; s < e.byteLength; s += 1) {
|
|
536
|
-
const t = e[s] %
|
|
537
|
-
n.push(
|
|
525
|
+
const t = e[s] % Q.length;
|
|
526
|
+
n.push(Q[t]);
|
|
538
527
|
}
|
|
539
528
|
return n.join("");
|
|
540
|
-
},
|
|
541
|
-
const n = new Uint8Array(e), { hasCrypto: s } =
|
|
529
|
+
}, Z = (e) => {
|
|
530
|
+
const n = new Uint8Array(e), { hasCrypto: s } = Ee();
|
|
542
531
|
if (s)
|
|
543
532
|
window.crypto.getRandomValues(n);
|
|
544
533
|
else
|
|
545
534
|
for (let t = 0; t < e; t += 1)
|
|
546
|
-
n[t] = Math.random() *
|
|
547
|
-
return
|
|
535
|
+
n[t] = Math.random() * Q.length | 0;
|
|
536
|
+
return Ye(n);
|
|
548
537
|
};
|
|
549
|
-
function
|
|
538
|
+
function Xe(e) {
|
|
550
539
|
const n = new ArrayBuffer(e.length), s = new Uint8Array(n);
|
|
551
540
|
for (let t = 0; t < e.length; t++)
|
|
552
541
|
s[t] = e.charCodeAt(t);
|
|
553
542
|
return s;
|
|
554
543
|
}
|
|
555
|
-
function
|
|
544
|
+
function be(e) {
|
|
556
545
|
return new Promise((n, s) => {
|
|
557
|
-
crypto.subtle.digest("SHA-256",
|
|
546
|
+
crypto.subtle.digest("SHA-256", Xe(e)).then(
|
|
558
547
|
(t) => n(re(new Uint8Array(t))),
|
|
559
548
|
(t) => s(t)
|
|
560
549
|
);
|
|
561
550
|
});
|
|
562
551
|
}
|
|
563
|
-
const
|
|
552
|
+
const ze = (e) => {
|
|
564
553
|
if (e.length < 43 || e.length > 128)
|
|
565
554
|
return Promise.reject(new Error("Invalid code length."));
|
|
566
|
-
const { hasSubtleCrypto: n } =
|
|
567
|
-
return n ?
|
|
568
|
-
},
|
|
569
|
-
const i = `${n}/.well-known/openid-configuration`, r = `oidc.server:${n}`, a =
|
|
555
|
+
const { hasSubtleCrypto: n } = Ee();
|
|
556
|
+
return n ? be(e) : Promise.reject(new Error("window.crypto.subtle is unavailable."));
|
|
557
|
+
}, Qe = 60 * 60, Ze = (e) => async (n, s = Qe, t = window.sessionStorage, o = 1e4) => {
|
|
558
|
+
const i = `${n}/.well-known/openid-configuration`, r = `oidc.server:${n}`, a = Re(r, t, s);
|
|
570
559
|
if (a)
|
|
571
|
-
return new
|
|
560
|
+
return new se(a);
|
|
572
561
|
const c = await J(e)(i, {}, o);
|
|
573
562
|
if (c.status !== 200)
|
|
574
563
|
return null;
|
|
575
564
|
const l = await c.json();
|
|
576
|
-
return
|
|
565
|
+
return $e(r, l, t), new se(l);
|
|
577
566
|
}, J = (e) => async (n, s = {}, t = 1e4, o = 0) => {
|
|
578
567
|
let i;
|
|
579
568
|
try {
|
|
@@ -588,10 +577,10 @@ const Ze = (e) => {
|
|
|
588
577
|
throw console.error(r.message), r;
|
|
589
578
|
}
|
|
590
579
|
return i;
|
|
591
|
-
},
|
|
580
|
+
}, ee = {
|
|
592
581
|
refresh_token: "refresh_token",
|
|
593
582
|
access_token: "access_token"
|
|
594
|
-
}, he = (e) => async (n, s, t =
|
|
583
|
+
}, he = (e) => async (n, s, t = ee.refresh_token, o, i = {}, r = 1e4) => {
|
|
595
584
|
const a = {
|
|
596
585
|
token: s,
|
|
597
586
|
token_type_hint: t,
|
|
@@ -618,13 +607,13 @@ const Ze = (e) => {
|
|
|
618
607
|
)).status !== 200 ? { success: !1 } : {
|
|
619
608
|
success: !0
|
|
620
609
|
};
|
|
621
|
-
},
|
|
622
|
-
for (const [f,
|
|
623
|
-
s[f] === void 0 && (s[f] =
|
|
610
|
+
}, en = (e) => async (n, s, t, o, i = {}, r, a = 1e4) => {
|
|
611
|
+
for (const [f, y] of Object.entries(t))
|
|
612
|
+
s[f] === void 0 && (s[f] = y);
|
|
624
613
|
const c = [];
|
|
625
614
|
for (const f in s) {
|
|
626
|
-
const
|
|
627
|
-
c.push(`${
|
|
615
|
+
const y = encodeURIComponent(f), p = encodeURIComponent(s[f]);
|
|
616
|
+
c.push(`${y}=${p}`);
|
|
628
617
|
}
|
|
629
618
|
const l = c.join("&"), d = await J(e)(
|
|
630
619
|
n,
|
|
@@ -651,19 +640,19 @@ const Ze = (e) => {
|
|
|
651
640
|
)), {
|
|
652
641
|
success: !0,
|
|
653
642
|
status: d.status,
|
|
654
|
-
data:
|
|
643
|
+
data: oe(u, o, r),
|
|
655
644
|
demonstratingProofOfPossessionNonce: _
|
|
656
645
|
};
|
|
657
|
-
},
|
|
646
|
+
}, nn = (e, n) => async (s, t) => {
|
|
658
647
|
t = t ? { ...t } : {};
|
|
659
|
-
const o =
|
|
648
|
+
const o = Z(128), i = await ze(o);
|
|
660
649
|
await e.setCodeVerifierAsync(o), await e.setStateAsync(t.state), t.code_challenge = i, t.code_challenge_method = "S256";
|
|
661
650
|
let r = "";
|
|
662
651
|
if (t)
|
|
663
652
|
for (const [a, c] of Object.entries(t))
|
|
664
653
|
r === "" ? r += "?" : r += "&", r += `${a}=${encodeURIComponent(c)}`;
|
|
665
654
|
n.open(`${s}${r}`);
|
|
666
|
-
}, G = "DPoP-Nonce",
|
|
655
|
+
}, G = "DPoP-Nonce", sn = (e) => async (n, s, t, o, i = 1e4) => {
|
|
667
656
|
s = s ? { ...s } : {}, s.code_verifier = await e.getCodeVerifierAsync();
|
|
668
657
|
const r = [];
|
|
669
658
|
for (const u in s) {
|
|
@@ -693,7 +682,7 @@ const Ze = (e) => {
|
|
|
693
682
|
success: !0,
|
|
694
683
|
data: {
|
|
695
684
|
state: s.state,
|
|
696
|
-
tokens:
|
|
685
|
+
tokens: oe(d, null, o),
|
|
697
686
|
demonstratingProofOfPossessionNonce: l
|
|
698
687
|
}
|
|
699
688
|
};
|
|
@@ -701,7 +690,7 @@ const Ze = (e) => {
|
|
|
701
690
|
async function ye(e, n, s, t = null) {
|
|
702
691
|
const o = (c) => {
|
|
703
692
|
e.tokens = c;
|
|
704
|
-
}, { tokens: i, status: r } = await
|
|
693
|
+
}, { tokens: i, status: r } = await B(e)(
|
|
705
694
|
o,
|
|
706
695
|
0,
|
|
707
696
|
n,
|
|
@@ -744,7 +733,7 @@ const M = (e, n, s = null, t = null) => {
|
|
|
744
733
|
TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID",
|
|
745
734
|
LOGOUT_FROM_ANOTHER_TAB: "LOGOUT_FROM_ANOTHER_TAB",
|
|
746
735
|
REQUIRE_SYNC_TOKENS: "REQUIRE_SYNC_TOKENS"
|
|
747
|
-
},
|
|
736
|
+
}, tn = (e) => async (n, s, t, o = !1) => {
|
|
748
737
|
const i = { nonce: null };
|
|
749
738
|
if (!t)
|
|
750
739
|
return { tokens: null, status: "NOT_CONNECTED", nonce: i };
|
|
@@ -766,19 +755,19 @@ const M = (e, n, s = null, t = null) => {
|
|
|
766
755
|
if (!u || !_)
|
|
767
756
|
return { tokens: null, status: "REQUIRE_SYNC_TOKENS", nonce: i };
|
|
768
757
|
if (_.issuedAt !== t.issuedAt) {
|
|
769
|
-
const
|
|
758
|
+
const y = K(
|
|
770
759
|
n.refresh_time_before_tokens_expiration_in_second,
|
|
771
760
|
_.expiresAt
|
|
772
761
|
) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", p = await c.getNonceAsync();
|
|
773
|
-
return { tokens: _, status:
|
|
762
|
+
return { tokens: _, status: y, nonce: p };
|
|
774
763
|
}
|
|
775
764
|
r = await c.getNonceAsync();
|
|
776
765
|
} else {
|
|
777
766
|
const u = I(s, n.storage ?? sessionStorage), _ = await u.initAsync();
|
|
778
767
|
let { tokens: f } = _;
|
|
779
|
-
const { status:
|
|
780
|
-
if (f && (f =
|
|
781
|
-
if (
|
|
768
|
+
const { status: y } = _;
|
|
769
|
+
if (f && (f = te(f, e.tokens, n.token_renew_mode)), f) {
|
|
770
|
+
if (y === "SESSIONS_LOST")
|
|
782
771
|
return { tokens: null, status: "SESSIONS_LOST", nonce: i };
|
|
783
772
|
if (f.issuedAt !== t.issuedAt) {
|
|
784
773
|
const w = K(
|
|
@@ -795,43 +784,43 @@ const M = (e, n, s = null, t = null) => {
|
|
|
795
784
|
t.expiresAt
|
|
796
785
|
) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
|
|
797
786
|
return o ? { tokens: t, status: "FORCE_REFRESH", nonce: r } : { tokens: t, status: d, nonce: r };
|
|
798
|
-
},
|
|
787
|
+
}, B = (e) => async (n, s = 0, t = !1, o = null, i = null) => {
|
|
799
788
|
if (!navigator.onLine && document.hidden)
|
|
800
789
|
return { tokens: e.tokens, status: "GIVE_UP" };
|
|
801
790
|
let r = 6;
|
|
802
791
|
for (; !navigator.onLine && r > 0; )
|
|
803
|
-
await
|
|
792
|
+
await ie({ milliseconds: 1e3 }), r--, e.publishEvent(k.refreshTokensAsync, {
|
|
804
793
|
message: `wait because navigator is offline try ${r}`
|
|
805
794
|
});
|
|
806
795
|
const a = document.hidden, c = a ? s : s + 1;
|
|
807
796
|
if (s > 4)
|
|
808
797
|
return a ? { tokens: e.tokens, status: "GIVE_UP" } : (n(null), e.publishEvent(k.refreshTokensAsync_error, { message: "refresh token" }), { tokens: null, status: "SESSION_LOST" });
|
|
809
798
|
o || (o = {});
|
|
810
|
-
const l = e.configuration, d = (_, f = null,
|
|
799
|
+
const l = e.configuration, d = (_, f = null, y = null) => ae(
|
|
811
800
|
e.configurationName,
|
|
812
801
|
e.configuration,
|
|
813
802
|
e.publishEvent.bind(e)
|
|
814
|
-
)(_, f,
|
|
803
|
+
)(_, f, y), u = async () => {
|
|
815
804
|
try {
|
|
816
805
|
let _;
|
|
817
806
|
const f = await C(l, e.configurationName);
|
|
818
807
|
f ? _ = f.getLoginParams() : _ = I(e.configurationName, l.storage).getLoginParams();
|
|
819
|
-
const
|
|
808
|
+
const y = await d({
|
|
820
809
|
..._.extras,
|
|
821
810
|
...o,
|
|
822
811
|
prompt: "none",
|
|
823
812
|
scope: i
|
|
824
813
|
});
|
|
825
|
-
return
|
|
814
|
+
return y ? y.error ? (n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
826
815
|
message: "refresh token silent"
|
|
827
|
-
}), { tokens: null, status: "SESSION_LOST" }) : (n(
|
|
816
|
+
}), { tokens: null, status: "SESSION_LOST" }) : (n(y.tokens), e.publishEvent(N.eventNames.token_renewed, {}), { tokens: y.tokens, status: "LOGGED" }) : (n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
828
817
|
message: "refresh token silent not active"
|
|
829
818
|
}), { tokens: null, status: "SESSION_LOST" });
|
|
830
819
|
} catch (_) {
|
|
831
820
|
return console.error(_), e.publishEvent(k.refreshTokensAsync_silent_error, {
|
|
832
821
|
message: "exceptionSilent",
|
|
833
822
|
exception: _.message
|
|
834
|
-
}), await
|
|
823
|
+
}), await B(e)(
|
|
835
824
|
n,
|
|
836
825
|
c,
|
|
837
826
|
t,
|
|
@@ -841,7 +830,7 @@ const M = (e, n, s = null, t = null) => {
|
|
|
841
830
|
}
|
|
842
831
|
};
|
|
843
832
|
try {
|
|
844
|
-
const { status: _, tokens: f, nonce:
|
|
833
|
+
const { status: _, tokens: f, nonce: y } = await tn(e)(
|
|
845
834
|
l,
|
|
846
835
|
e.configurationName,
|
|
847
836
|
e.tokens,
|
|
@@ -865,9 +854,9 @@ const M = (e, n, s = null, t = null) => {
|
|
|
865
854
|
status: "session syncTokensAsync"
|
|
866
855
|
}), { tokens: null, status: "LOGGED_OUT" };
|
|
867
856
|
case W.REQUIRE_SYNC_TOKENS:
|
|
868
|
-
return l.token_automatic_renew_mode ==
|
|
857
|
+
return l.token_automatic_renew_mode == V.AutomaticOnlyWhenFetchExecuted && W.FORCE_REFRESH !== _ ? (e.publishEvent(k.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" }) : (e.publishEvent(k.refreshTokensAsync_begin, { tryNumber: s }), await u());
|
|
869
858
|
default: {
|
|
870
|
-
if (l.token_automatic_renew_mode ==
|
|
859
|
+
if (l.token_automatic_renew_mode == V.AutomaticOnlyWhenFetchExecuted && W.FORCE_REFRESH !== _)
|
|
871
860
|
return e.publishEvent(k.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" };
|
|
872
861
|
if (e.publishEvent(k.refreshTokensAsync_begin, {
|
|
873
862
|
refreshToken: f.refreshToken,
|
|
@@ -876,41 +865,41 @@ const M = (e, n, s = null, t = null) => {
|
|
|
876
865
|
}), !f.refreshToken)
|
|
877
866
|
return await u();
|
|
878
867
|
const p = l.client_id, w = l.redirect_uri, v = l.authority, A = { ...l.token_request_extras ? l.token_request_extras : {} };
|
|
879
|
-
for (const [g,
|
|
880
|
-
g.endsWith(":token_request") && (A[g.replace(":token_request", "")] =
|
|
868
|
+
for (const [g, E] of Object.entries(o))
|
|
869
|
+
g.endsWith(":token_request") && (A[g.replace(":token_request", "")] = E);
|
|
881
870
|
return await (async () => {
|
|
882
871
|
const g = {
|
|
883
872
|
client_id: p,
|
|
884
873
|
redirect_uri: w,
|
|
885
874
|
grant_type: "refresh_token",
|
|
886
875
|
refresh_token: f.refreshToken
|
|
887
|
-
},
|
|
876
|
+
}, E = await e.initAsync(
|
|
888
877
|
v,
|
|
889
878
|
l.authority_configuration
|
|
890
|
-
),
|
|
879
|
+
), h = document.hidden ? 1e4 : 3e4 * 10, b = E.tokenEndpoint, S = {};
|
|
891
880
|
l.demonstrating_proof_of_possession && (S.DPoP = await e.generateDemonstrationOfProofOfPossessionAsync(
|
|
892
881
|
f.accessToken,
|
|
893
|
-
|
|
882
|
+
b,
|
|
894
883
|
"POST"
|
|
895
884
|
));
|
|
896
|
-
const m = await
|
|
897
|
-
|
|
885
|
+
const m = await en(e.getFetch())(
|
|
886
|
+
b,
|
|
898
887
|
g,
|
|
899
888
|
A,
|
|
900
889
|
f,
|
|
901
890
|
S,
|
|
902
891
|
l.token_renew_mode,
|
|
903
|
-
|
|
892
|
+
h
|
|
904
893
|
);
|
|
905
894
|
if (m.success) {
|
|
906
|
-
const { isValid: x, reason:
|
|
895
|
+
const { isValid: x, reason: Ce } = pe(
|
|
907
896
|
m.data,
|
|
908
|
-
|
|
909
|
-
|
|
897
|
+
y.nonce,
|
|
898
|
+
E
|
|
910
899
|
);
|
|
911
900
|
if (!x)
|
|
912
901
|
return n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
913
|
-
message: `refresh token return not valid tokens, reason: ${
|
|
902
|
+
message: `refresh token return not valid tokens, reason: ${Ce}`
|
|
914
903
|
}), { tokens: null, status: "SESSION_LOST" };
|
|
915
904
|
if (n(m.data), m.demonstratingProofOfPossessionNonce) {
|
|
916
905
|
const ce = await C(l, e.configurationName);
|
|
@@ -929,7 +918,7 @@ const M = (e, n, s = null, t = null) => {
|
|
|
929
918
|
tokenResponse: m
|
|
930
919
|
}), m.status >= 400 && m.status < 500 ? (n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
931
920
|
message: `session lost: ${m.status}`
|
|
932
|
-
}), { tokens: null, status: "SESSION_LOST" }) : await
|
|
921
|
+
}), { tokens: null, status: "SESSION_LOST" }) : await B(e)(
|
|
933
922
|
n,
|
|
934
923
|
c,
|
|
935
924
|
t,
|
|
@@ -943,9 +932,9 @@ const M = (e, n, s = null, t = null) => {
|
|
|
943
932
|
return console.error(_), e.publishEvent(k.refreshTokensAsync_silent_error, {
|
|
944
933
|
message: "exception",
|
|
945
934
|
exception: _.message
|
|
946
|
-
}), new Promise((f,
|
|
935
|
+
}), new Promise((f, y) => {
|
|
947
936
|
setTimeout(() => {
|
|
948
|
-
|
|
937
|
+
B(e)(n, c, t, o, i).then(f).catch(y);
|
|
949
938
|
}, 1e3);
|
|
950
939
|
});
|
|
951
940
|
}
|
|
@@ -961,7 +950,7 @@ const M = (e, n, s = null, t = null) => {
|
|
|
961
950
|
const a = n.silent_login_uri + r, c = a.indexOf("/", a.indexOf("//") + 2), l = a.substring(0, c), d = document.createElement("iframe");
|
|
962
951
|
return d.width = "0px", d.height = "0px", d.id = `${e}_oidc_iframe`, d.setAttribute("src", a), document.body.appendChild(d), new Promise((u, _) => {
|
|
963
952
|
let f = !1;
|
|
964
|
-
const
|
|
953
|
+
const y = () => {
|
|
965
954
|
window.removeEventListener("message", p), d.remove(), f = !0;
|
|
966
955
|
}, p = (w) => {
|
|
967
956
|
if (w.origin === l && w.source === d.contentWindow) {
|
|
@@ -969,13 +958,13 @@ const M = (e, n, s = null, t = null) => {
|
|
|
969
958
|
if (T && typeof T == "string" && !f) {
|
|
970
959
|
if (T.startsWith(v)) {
|
|
971
960
|
const g = JSON.parse(w.data.replace(v, ""));
|
|
972
|
-
s(k.silentLoginAsync_end, {}), u(g),
|
|
961
|
+
s(k.silentLoginAsync_end, {}), u(g), y();
|
|
973
962
|
} else if (T.startsWith(P)) {
|
|
974
963
|
const g = JSON.parse(w.data.replace(P, ""));
|
|
975
|
-
s(k.silentLoginAsync_error, g), u({ error: "oidc_" + g.error, tokens: null, sessionState: null }),
|
|
964
|
+
s(k.silentLoginAsync_error, g), u({ error: "oidc_" + g.error, tokens: null, sessionState: null }), y();
|
|
976
965
|
} else if (T.startsWith(A)) {
|
|
977
966
|
const g = JSON.parse(w.data.replace(A, ""));
|
|
978
|
-
s(k.silentLoginAsync_error, g), _(new Error(g.error)),
|
|
967
|
+
s(k.silentLoginAsync_error, g), _(new Error(g.error)), y();
|
|
979
968
|
}
|
|
980
969
|
}
|
|
981
970
|
}
|
|
@@ -984,16 +973,16 @@ const M = (e, n, s = null, t = null) => {
|
|
|
984
973
|
window.addEventListener("message", p);
|
|
985
974
|
const w = n.silent_login_timeout;
|
|
986
975
|
setTimeout(() => {
|
|
987
|
-
f || (
|
|
976
|
+
f || (y(), s(k.silentLoginAsync_error, { reason: "timeout" }), _(new Error("timeout")));
|
|
988
977
|
}, w);
|
|
989
978
|
} catch (w) {
|
|
990
|
-
|
|
979
|
+
y(), s(k.silentLoginAsync_error, w), _(w);
|
|
991
980
|
}
|
|
992
981
|
});
|
|
993
982
|
} catch (r) {
|
|
994
983
|
throw s(k.silentLoginAsync_error, r), r;
|
|
995
984
|
}
|
|
996
|
-
},
|
|
985
|
+
}, on = (e, n, s, t, o) => (i = null, r = void 0) => {
|
|
997
986
|
i = { ...i };
|
|
998
987
|
const a = (l, d, u) => ae(n, s, t.bind(o))(
|
|
999
988
|
l,
|
|
@@ -1019,7 +1008,7 @@ const M = (e, n, s = null, t = null) => {
|
|
|
1019
1008
|
return d;
|
|
1020
1009
|
}
|
|
1021
1010
|
})();
|
|
1022
|
-
},
|
|
1011
|
+
}, rn = (e, n, s) => (t, o, i, r = !1) => {
|
|
1023
1012
|
const a = (c, l = void 0, d = void 0) => ae(e.configurationName, s, e.publishEvent.bind(e))(
|
|
1024
1013
|
c,
|
|
1025
1014
|
l,
|
|
@@ -1037,13 +1026,13 @@ const M = (e, n, s = null, t = null) => {
|
|
|
1037
1026
|
prompt: "none",
|
|
1038
1027
|
id_token_hint: _,
|
|
1039
1028
|
scope: s.scope || "openid"
|
|
1040
|
-
}).then((
|
|
1041
|
-
if (
|
|
1042
|
-
throw new Error(
|
|
1043
|
-
const p =
|
|
1029
|
+
}).then((y) => {
|
|
1030
|
+
if (y.error)
|
|
1031
|
+
throw new Error(y.error);
|
|
1032
|
+
const p = y.tokens.idTokenPayload;
|
|
1044
1033
|
if (f.sub === p.sub) {
|
|
1045
|
-
const w =
|
|
1046
|
-
e.checkSessionIFrame.start(
|
|
1034
|
+
const w = y.sessionState;
|
|
1035
|
+
e.checkSessionIFrame.start(y.sessionState), f.sid === p.sid ? console.debug(
|
|
1047
1036
|
"SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",
|
|
1048
1037
|
w
|
|
1049
1038
|
) : console.debug(
|
|
@@ -1055,16 +1044,16 @@ const M = (e, n, s = null, t = null) => {
|
|
|
1055
1044
|
"SessionMonitor._callback: Different subject signed into OP:",
|
|
1056
1045
|
p.sub
|
|
1057
1046
|
);
|
|
1058
|
-
}).catch(async (
|
|
1047
|
+
}).catch(async (y) => {
|
|
1059
1048
|
console.warn(
|
|
1060
1049
|
"SessionMonitor._callback: Silent login failed, logging out other tabs:",
|
|
1061
|
-
|
|
1050
|
+
y
|
|
1062
1051
|
);
|
|
1063
1052
|
for (const [, p] of Object.entries(n))
|
|
1064
1053
|
await p.logoutOtherTabAsync(s.client_id, f.sub);
|
|
1065
1054
|
});
|
|
1066
1055
|
};
|
|
1067
|
-
e.checkSessionIFrame = new
|
|
1056
|
+
e.checkSessionIFrame = new Ne(
|
|
1068
1057
|
d,
|
|
1069
1058
|
o,
|
|
1070
1059
|
t
|
|
@@ -1076,7 +1065,7 @@ const M = (e, n, s = null, t = null) => {
|
|
|
1076
1065
|
} else
|
|
1077
1066
|
c(null);
|
|
1078
1067
|
});
|
|
1079
|
-
},
|
|
1068
|
+
}, an = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), cn = (e) => {
|
|
1080
1069
|
const n = e.appVersion, s = e.userAgent, t = "-";
|
|
1081
1070
|
let o = t;
|
|
1082
1071
|
const i = [
|
|
@@ -1136,7 +1125,7 @@ const M = (e, n, s = null, t = null) => {
|
|
|
1136
1125
|
osVersion: r
|
|
1137
1126
|
};
|
|
1138
1127
|
};
|
|
1139
|
-
function
|
|
1128
|
+
function ln() {
|
|
1140
1129
|
const e = navigator.userAgent;
|
|
1141
1130
|
let n, s = e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
1142
1131
|
if (/trident/i.test(s[1]))
|
|
@@ -1154,13 +1143,13 @@ function _n() {
|
|
|
1154
1143
|
version: s[1]
|
|
1155
1144
|
};
|
|
1156
1145
|
}
|
|
1157
|
-
const
|
|
1158
|
-
const { name: e, version: n } =
|
|
1146
|
+
const un = () => {
|
|
1147
|
+
const { name: e, version: n } = ln();
|
|
1159
1148
|
if (e === "chrome" && parseInt(n) <= 70 || e === "opera" && (!n || parseInt(n.split(".")[0]) < 80) || e === "ie")
|
|
1160
1149
|
return !1;
|
|
1161
|
-
const s =
|
|
1162
|
-
return !
|
|
1163
|
-
},
|
|
1150
|
+
const s = cn(navigator);
|
|
1151
|
+
return !an(s);
|
|
1152
|
+
}, _n = async (e) => {
|
|
1164
1153
|
let n;
|
|
1165
1154
|
if (e.tokens != null)
|
|
1166
1155
|
return !1;
|
|
@@ -1205,7 +1194,7 @@ const fn = () => {
|
|
|
1205
1194
|
});
|
|
1206
1195
|
const o = I(e.configurationName, s.storage ?? sessionStorage), { tokens: i } = await o.initAsync();
|
|
1207
1196
|
if (i) {
|
|
1208
|
-
e.tokens =
|
|
1197
|
+
e.tokens = te(i, null, s.token_renew_mode);
|
|
1209
1198
|
const r = o.getLoginParams();
|
|
1210
1199
|
e.timeoutId = M(
|
|
1211
1200
|
e,
|
|
@@ -1256,44 +1245,44 @@ const fn = () => {
|
|
|
1256
1245
|
search: s,
|
|
1257
1246
|
hash: t
|
|
1258
1247
|
};
|
|
1259
|
-
},
|
|
1248
|
+
}, vn = (e) => {
|
|
1260
1249
|
const n = Pe(e);
|
|
1261
1250
|
let { path: s } = n;
|
|
1262
1251
|
s.endsWith("/") && (s = s.slice(0, -1));
|
|
1263
1252
|
let { hash: t } = n;
|
|
1264
1253
|
return t === "#_=_" && (t = ""), t && (s += t), s;
|
|
1265
|
-
},
|
|
1254
|
+
}, ne = (e) => {
|
|
1266
1255
|
const n = Pe(e), { search: s } = n;
|
|
1267
|
-
return
|
|
1268
|
-
},
|
|
1256
|
+
return fn(s);
|
|
1257
|
+
}, fn = (e) => {
|
|
1269
1258
|
const n = {};
|
|
1270
1259
|
let s, t, o;
|
|
1271
1260
|
const i = e.split("&");
|
|
1272
1261
|
for (t = 0, o = i.length; t < o; t++)
|
|
1273
1262
|
s = i[t].split("="), n[decodeURIComponent(s[0])] = decodeURIComponent(s[1]);
|
|
1274
1263
|
return n;
|
|
1275
|
-
},
|
|
1264
|
+
}, dn = (e, n, s, t, o) => (i = void 0, r = null, a = !1, c = void 0) => {
|
|
1276
1265
|
const l = r;
|
|
1277
1266
|
return r = { ...r }, (async () => {
|
|
1278
1267
|
const u = i || o.getPath();
|
|
1279
|
-
if ("state" in r || (r.state =
|
|
1268
|
+
if ("state" in r || (r.state = Z(16)), s(k.loginAsync_begin, {}), r)
|
|
1280
1269
|
for (const _ of Object.keys(r))
|
|
1281
1270
|
_.endsWith(":token_request") && delete r[_];
|
|
1282
1271
|
try {
|
|
1283
1272
|
const _ = a ? n.silent_redirect_uri : n.redirect_uri;
|
|
1284
1273
|
c || (c = n.scope);
|
|
1285
1274
|
const f = n.extras ? { ...n.extras, ...r } : r;
|
|
1286
|
-
f.nonce || (f.nonce =
|
|
1287
|
-
const
|
|
1275
|
+
f.nonce || (f.nonce = Z(12));
|
|
1276
|
+
const y = { nonce: f.nonce }, p = await C(n, e), w = await t(
|
|
1288
1277
|
n.authority,
|
|
1289
1278
|
n.authority_configuration
|
|
1290
1279
|
);
|
|
1291
1280
|
let v;
|
|
1292
1281
|
if (p)
|
|
1293
|
-
p.setLoginParams({ callbackPath: u, extras: l, scope: c }), await p.initAsync(w, "loginAsync", n), await p.setNonceAsync(
|
|
1282
|
+
p.setLoginParams({ callbackPath: u, extras: l, scope: c }), await p.initAsync(w, "loginAsync", n), await p.setNonceAsync(y), p.startKeepAliveServiceWorker(), v = p;
|
|
1294
1283
|
else {
|
|
1295
1284
|
const A = I(e, n.storage ?? sessionStorage);
|
|
1296
|
-
A.setLoginParams({ callbackPath: u, extras: l, scope: c }), await A.setNonceAsync(
|
|
1285
|
+
A.setLoginParams({ callbackPath: u, extras: l, scope: c }), await A.setNonceAsync(y), v = A;
|
|
1297
1286
|
}
|
|
1298
1287
|
const P = {
|
|
1299
1288
|
client_id: n.client_id,
|
|
@@ -1302,7 +1291,7 @@ const fn = () => {
|
|
|
1302
1291
|
response_type: "code",
|
|
1303
1292
|
...f
|
|
1304
1293
|
};
|
|
1305
|
-
await
|
|
1294
|
+
await nn(v, o)(
|
|
1306
1295
|
w.authorizationEndpoint,
|
|
1307
1296
|
P
|
|
1308
1297
|
);
|
|
@@ -1310,22 +1299,22 @@ const fn = () => {
|
|
|
1310
1299
|
throw s(k.loginAsync_error, _), _;
|
|
1311
1300
|
}
|
|
1312
1301
|
})();
|
|
1313
|
-
},
|
|
1302
|
+
}, hn = (e) => async (n = !1) => {
|
|
1314
1303
|
try {
|
|
1315
1304
|
e.publishEvent(k.loginCallbackAsync_begin, {});
|
|
1316
1305
|
const s = e.configuration, t = s.client_id, o = n ? s.silent_redirect_uri : s.redirect_uri, i = s.authority, r = s.token_request_timeout, a = await e.initAsync(
|
|
1317
1306
|
i,
|
|
1318
1307
|
s.authority_configuration
|
|
1319
|
-
), c = e.location.getCurrentHref(), l =
|
|
1320
|
-
let _, f,
|
|
1308
|
+
), c = e.location.getCurrentHref(), l = ne(c), d = l.session_state, u = await C(s, e.configurationName);
|
|
1309
|
+
let _, f, y, p;
|
|
1321
1310
|
if (u)
|
|
1322
|
-
await u.initAsync(a, "loginCallbackAsync", s), await u.setSessionStateAsync(d), f = await u.getNonceAsync(),
|
|
1311
|
+
await u.initAsync(a, "loginCallbackAsync", s), await u.setSessionStateAsync(d), f = await u.getNonceAsync(), y = u.getLoginParams(), p = await u.getStateAsync(), u.startKeepAliveServiceWorker(), _ = u;
|
|
1323
1312
|
else {
|
|
1324
1313
|
const m = I(
|
|
1325
1314
|
e.configurationName,
|
|
1326
1315
|
s.storage ?? sessionStorage
|
|
1327
1316
|
);
|
|
1328
|
-
await m.setSessionStateAsync(d), f = await m.getNonceAsync(),
|
|
1317
|
+
await m.setSessionStateAsync(d), f = await m.getNonceAsync(), y = m.getLoginParams(), p = await m.getStateAsync(), _ = m;
|
|
1329
1318
|
}
|
|
1330
1319
|
if (l.error || l.error_description)
|
|
1331
1320
|
throw new Error(
|
|
@@ -1346,22 +1335,22 @@ const fn = () => {
|
|
|
1346
1335
|
if (s.token_request_extras)
|
|
1347
1336
|
for (const [m, x] of Object.entries(s.token_request_extras))
|
|
1348
1337
|
v[m] = x;
|
|
1349
|
-
if (
|
|
1350
|
-
for (const [m, x] of Object.entries(
|
|
1338
|
+
if (y != null && y.extras)
|
|
1339
|
+
for (const [m, x] of Object.entries(y.extras))
|
|
1351
1340
|
m.endsWith(":token_request") && (v[m.replace(":token_request", "")] = x);
|
|
1352
1341
|
const P = a.tokenEndpoint, A = {};
|
|
1353
1342
|
if (s.demonstrating_proof_of_possession)
|
|
1354
1343
|
if (u)
|
|
1355
1344
|
A.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${e.configurationName}`;
|
|
1356
1345
|
else {
|
|
1357
|
-
const m = await
|
|
1346
|
+
const m = await Ge(window)(
|
|
1358
1347
|
s.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm
|
|
1359
1348
|
);
|
|
1360
1349
|
await I(e.configurationName, s.storage).setDemonstratingProofOfPossessionJwkAsync(m), A.DPoP = await ve(window)(
|
|
1361
1350
|
s.demonstrating_proof_of_possession_configuration
|
|
1362
1351
|
)(m, "POST", P);
|
|
1363
1352
|
}
|
|
1364
|
-
const T = await
|
|
1353
|
+
const T = await sn(_)(
|
|
1365
1354
|
P,
|
|
1366
1355
|
{ ...w, ...v },
|
|
1367
1356
|
A,
|
|
@@ -1371,31 +1360,31 @@ const fn = () => {
|
|
|
1371
1360
|
if (!T.success)
|
|
1372
1361
|
throw new Error("Token request failed");
|
|
1373
1362
|
let g;
|
|
1374
|
-
const
|
|
1363
|
+
const E = T.data.tokens, h = T.data.demonstratingProofOfPossessionNonce;
|
|
1375
1364
|
if (T.data.state !== v.state)
|
|
1376
1365
|
throw new Error("state is not valid");
|
|
1377
|
-
const { isValid:
|
|
1378
|
-
|
|
1366
|
+
const { isValid: b, reason: S } = pe(
|
|
1367
|
+
E,
|
|
1379
1368
|
f.nonce,
|
|
1380
1369
|
a
|
|
1381
1370
|
);
|
|
1382
|
-
if (!
|
|
1371
|
+
if (!b)
|
|
1383
1372
|
throw new Error(`Tokens are not OpenID valid, reason: ${S}`);
|
|
1384
1373
|
if (u) {
|
|
1385
|
-
if (
|
|
1374
|
+
if (E.refreshToken && !E.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))
|
|
1386
1375
|
throw new Error("Refresh token should be hidden by service worker");
|
|
1387
|
-
if (
|
|
1376
|
+
if (h && (E != null && E.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER")))
|
|
1388
1377
|
throw new Error(
|
|
1389
1378
|
"Demonstration of proof of possession require Access token not hidden by service worker"
|
|
1390
1379
|
);
|
|
1391
1380
|
}
|
|
1392
1381
|
if (u)
|
|
1393
|
-
await u.initAsync(a, "syncTokensAsync", s), g = u.getLoginParams(),
|
|
1394
|
-
|
|
1382
|
+
await u.initAsync(a, "syncTokensAsync", s), g = u.getLoginParams(), h && await u.setDemonstratingProofOfPossessionNonce(
|
|
1383
|
+
h
|
|
1395
1384
|
);
|
|
1396
1385
|
else {
|
|
1397
1386
|
const m = I(e.configurationName, s.storage);
|
|
1398
|
-
g = m.getLoginParams(),
|
|
1387
|
+
g = m.getLoginParams(), h && await m.setDemonstratingProofOfPossessionNonce(h);
|
|
1399
1388
|
}
|
|
1400
1389
|
return await e.startCheckSessionAsync(
|
|
1401
1390
|
a.checkSessionIframe,
|
|
@@ -1403,7 +1392,7 @@ const fn = () => {
|
|
|
1403
1392
|
d,
|
|
1404
1393
|
n
|
|
1405
1394
|
), e.publishEvent(k.loginCallbackAsync_end, {}), {
|
|
1406
|
-
tokens:
|
|
1395
|
+
tokens: E,
|
|
1407
1396
|
state: "request.state",
|
|
1408
1397
|
callbackPath: g.callbackPath,
|
|
1409
1398
|
scope: l.scope,
|
|
@@ -1415,7 +1404,7 @@ const fn = () => {
|
|
|
1415
1404
|
}, ge = {
|
|
1416
1405
|
access_token: "access_token",
|
|
1417
1406
|
refresh_token: "refresh_token"
|
|
1418
|
-
},
|
|
1407
|
+
}, X = (e, n) => {
|
|
1419
1408
|
const s = {};
|
|
1420
1409
|
if (e) {
|
|
1421
1410
|
for (const [t, o] of Object.entries(e))
|
|
@@ -1426,7 +1415,7 @@ const fn = () => {
|
|
|
1426
1415
|
return s;
|
|
1427
1416
|
}
|
|
1428
1417
|
return s;
|
|
1429
|
-
},
|
|
1418
|
+
}, yn = (e) => {
|
|
1430
1419
|
const n = {};
|
|
1431
1420
|
if (e) {
|
|
1432
1421
|
for (const [s, t] of Object.entries(e))
|
|
@@ -1434,11 +1423,11 @@ const fn = () => {
|
|
|
1434
1423
|
return n;
|
|
1435
1424
|
}
|
|
1436
1425
|
return n;
|
|
1437
|
-
},
|
|
1426
|
+
}, gn = (e) => async (n) => {
|
|
1438
1427
|
U.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
1439
1428
|
const s = await C(e.configuration, e.configurationName);
|
|
1440
1429
|
s ? await s.clearAsync(n) : await I(e.configurationName, e.configuration.storage).clearAsync(n), e.tokens = null, e.userInfo = null;
|
|
1441
|
-
},
|
|
1430
|
+
}, kn = (e, n, s, t, o) => async (i = void 0, r = null) => {
|
|
1442
1431
|
var v, P;
|
|
1443
1432
|
const a = e.configuration, c = await e.initAsync(
|
|
1444
1433
|
a.authority,
|
|
@@ -1454,25 +1443,25 @@ const fn = () => {
|
|
|
1454
1443
|
if (A) {
|
|
1455
1444
|
const T = [], g = e.tokens ? e.tokens.accessToken : null;
|
|
1456
1445
|
if (g && a.logout_tokens_to_invalidate.includes(ge.access_token)) {
|
|
1457
|
-
const
|
|
1446
|
+
const h = X(r, ":revoke_access_token"), b = he(s)(
|
|
1458
1447
|
A,
|
|
1459
1448
|
g,
|
|
1460
|
-
|
|
1449
|
+
ee.access_token,
|
|
1461
1450
|
a.client_id,
|
|
1462
|
-
|
|
1451
|
+
h
|
|
1463
1452
|
);
|
|
1464
|
-
T.push(
|
|
1453
|
+
T.push(b);
|
|
1465
1454
|
}
|
|
1466
|
-
const
|
|
1467
|
-
if (
|
|
1468
|
-
const
|
|
1455
|
+
const E = e.tokens ? e.tokens.refreshToken : null;
|
|
1456
|
+
if (E && a.logout_tokens_to_invalidate.includes(ge.refresh_token)) {
|
|
1457
|
+
const h = X(r, ":revoke_refresh_token"), b = he(s)(
|
|
1469
1458
|
A,
|
|
1470
|
-
|
|
1471
|
-
|
|
1459
|
+
E,
|
|
1460
|
+
ee.refresh_token,
|
|
1472
1461
|
a.client_id,
|
|
1473
|
-
|
|
1462
|
+
h
|
|
1474
1463
|
);
|
|
1475
|
-
T.push(
|
|
1464
|
+
T.push(b);
|
|
1476
1465
|
}
|
|
1477
1466
|
T.length > 0 && await Promise.all(T);
|
|
1478
1467
|
}
|
|
@@ -1485,10 +1474,10 @@ const fn = () => {
|
|
|
1485
1474
|
await e.destroyAsync("LOGGED_OUT");
|
|
1486
1475
|
for (const [, A] of Object.entries(n))
|
|
1487
1476
|
A !== e ? await e.logoutSameTabAsync(e.configuration.client_id, f) : e.publishEvent(k.logout_from_same_tab, {});
|
|
1488
|
-
const
|
|
1489
|
-
if (
|
|
1477
|
+
const y = X(r, ":oidc");
|
|
1478
|
+
if (y && y.no_reload === "true")
|
|
1490
1479
|
return;
|
|
1491
|
-
const w =
|
|
1480
|
+
const w = yn(r);
|
|
1492
1481
|
if (c.endSessionEndpoint) {
|
|
1493
1482
|
"id_token_hint" in w || (w.id_token_hint = _), !("post_logout_redirect_uri" in w) && i !== null && (w.post_logout_redirect_uri = u);
|
|
1494
1483
|
let A = "";
|
|
@@ -1512,19 +1501,19 @@ const fn = () => {
|
|
|
1512
1501
|
}, d = await me(l), u = (f = d == null ? void 0 : d.tokens) == null ? void 0 : f.accessToken;
|
|
1513
1502
|
if (c.has("Accept") || c.set("Accept", "application/json"), u) {
|
|
1514
1503
|
if (n.configuration.demonstrating_proof_of_possession && s) {
|
|
1515
|
-
const
|
|
1504
|
+
const y = await n.generateDemonstrationOfProofOfPossessionAsync(
|
|
1516
1505
|
u,
|
|
1517
1506
|
o.toString(),
|
|
1518
1507
|
a.method
|
|
1519
1508
|
);
|
|
1520
|
-
c.set("Authorization", `DPoP ${u}`), c.set("DPoP",
|
|
1509
|
+
c.set("Authorization", `DPoP ${u}`), c.set("DPoP", y);
|
|
1521
1510
|
} else
|
|
1522
1511
|
c.set("Authorization", `Bearer ${u}`);
|
|
1523
1512
|
a.credentials || (a.credentials = "same-origin");
|
|
1524
1513
|
}
|
|
1525
1514
|
const _ = { ...a, headers: c };
|
|
1526
1515
|
return await e(o, _, ...r);
|
|
1527
|
-
},
|
|
1516
|
+
}, mn = (e) => async (n = !1, s = !1) => {
|
|
1528
1517
|
if (e.userInfo != null && !n)
|
|
1529
1518
|
return e.userInfo;
|
|
1530
1519
|
const t = e.configuration, i = (await e.initAsync(
|
|
@@ -1535,45 +1524,42 @@ const fn = () => {
|
|
|
1535
1524
|
return l.status !== 200 ? null : l.json();
|
|
1536
1525
|
})();
|
|
1537
1526
|
return e.userInfo = a, a;
|
|
1538
|
-
},
|
|
1539
|
-
class
|
|
1527
|
+
}, pn = () => fetch;
|
|
1528
|
+
class se {
|
|
1540
1529
|
constructor(n) {
|
|
1541
1530
|
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;
|
|
1542
1531
|
}
|
|
1543
1532
|
}
|
|
1544
|
-
const L = {},
|
|
1533
|
+
const L = {}, wn = (e, n = new H()) => (s, t = "default") => (L[t] || (L[t] = new N(s, t, e, n)), L[t]), An = async (e) => {
|
|
1545
1534
|
const { parsedTokens: n, callbackPath: s, extras: t, scope: o } = await e.loginCallbackAsync();
|
|
1546
1535
|
return e.timeoutId = M(e, n.expiresAt, t, o), { callbackPath: s };
|
|
1547
|
-
},
|
|
1548
|
-
constructor(n, s = "default", t, o = new
|
|
1536
|
+
}, Sn = (e) => Math.floor(Math.random() * e), F = class F {
|
|
1537
|
+
constructor(n, s = "default", t, o = new H()) {
|
|
1549
1538
|
this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.logoutPromise = null;
|
|
1550
1539
|
let i = n.silent_login_uri;
|
|
1551
1540
|
n.silent_redirect_uri && !n.silent_login_uri && (i = `${n.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
|
|
1552
1541
|
let r = n.refresh_time_before_tokens_expiration_in_second ?? 120;
|
|
1553
|
-
r > 60 && (r = r - Math.floor(Math.random() * 40)), this.location = o ?? new
|
|
1554
|
-
const a = n.service_worker_update_require_callback ?? $e(this.location);
|
|
1555
|
-
this.configuration = {
|
|
1542
|
+
r > 60 && (r = r - Math.floor(Math.random() * 40)), this.location = o ?? new H(), this.configuration = {
|
|
1556
1543
|
...n,
|
|
1557
1544
|
silent_login_uri: i,
|
|
1558
|
-
token_automatic_renew_mode: n.token_automatic_renew_mode ??
|
|
1545
|
+
token_automatic_renew_mode: n.token_automatic_renew_mode ?? V.AutomaticBeforeTokenExpiration,
|
|
1559
1546
|
monitor_session: n.monitor_session ?? !1,
|
|
1560
1547
|
refresh_time_before_tokens_expiration_in_second: r,
|
|
1561
1548
|
silent_login_timeout: n.silent_login_timeout ?? 12e3,
|
|
1562
|
-
token_renew_mode: n.token_renew_mode ??
|
|
1549
|
+
token_renew_mode: n.token_renew_mode ?? z.access_token_or_id_token_invalid,
|
|
1563
1550
|
demonstrating_proof_of_possession: n.demonstrating_proof_of_possession ?? !1,
|
|
1564
1551
|
authority_timeout_wellknowurl_in_millisecond: n.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
1565
1552
|
logout_tokens_to_invalidate: n.logout_tokens_to_invalidate ?? [
|
|
1566
1553
|
"access_token",
|
|
1567
1554
|
"refresh_token"
|
|
1568
1555
|
],
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
demonstrating_proof_of_possession_configuration: n.demonstrating_proof_of_possession_configuration ?? Fe,
|
|
1556
|
+
service_worker_activate: n.service_worker_activate ?? un,
|
|
1557
|
+
demonstrating_proof_of_possession_configuration: n.demonstrating_proof_of_possession_configuration ?? Ke,
|
|
1572
1558
|
preload_user_info: n.preload_user_info ?? !1
|
|
1573
|
-
}, this.getFetch = t ??
|
|
1559
|
+
}, this.getFetch = t ?? pn, 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);
|
|
1574
1560
|
}
|
|
1575
1561
|
subscribeEvents(n) {
|
|
1576
|
-
const s =
|
|
1562
|
+
const s = Sn(9999999999999).toString();
|
|
1577
1563
|
return this.events.push({ id: s, func: n }), s;
|
|
1578
1564
|
}
|
|
1579
1565
|
removeEventSubscription(n) {
|
|
@@ -1594,7 +1580,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1594
1580
|
}
|
|
1595
1581
|
_silentLoginCallbackFromIFrame() {
|
|
1596
1582
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1597
|
-
const n = this.location, s =
|
|
1583
|
+
const n = this.location, s = ne(n.getCurrentHref());
|
|
1598
1584
|
window.parent.postMessage(
|
|
1599
1585
|
`${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState: s.session_state })}`,
|
|
1600
1586
|
n.getOrigin()
|
|
@@ -1603,7 +1589,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1603
1589
|
}
|
|
1604
1590
|
_silentLoginErrorCallbackFromIFrame(n = null) {
|
|
1605
1591
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1606
|
-
const s = this.location, t =
|
|
1592
|
+
const s = this.location, t = ne(s.getCurrentHref());
|
|
1607
1593
|
t.error ? window.parent.postMessage(
|
|
1608
1594
|
`${this.configurationName}_oidc_error:${JSON.stringify({ error: t.error })}`,
|
|
1609
1595
|
s.getOrigin()
|
|
@@ -1625,7 +1611,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1625
1611
|
return this.initPromise;
|
|
1626
1612
|
const t = async () => {
|
|
1627
1613
|
if (s != null)
|
|
1628
|
-
return new
|
|
1614
|
+
return new se({
|
|
1629
1615
|
authorization_endpoint: s.authorization_endpoint,
|
|
1630
1616
|
end_session_endpoint: s.end_session_endpoint,
|
|
1631
1617
|
revocation_endpoint: s.revocation_endpoint,
|
|
@@ -1635,7 +1621,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1635
1621
|
issuer: s.issuer
|
|
1636
1622
|
});
|
|
1637
1623
|
const i = await C(this.configuration, this.configurationName) ? window.sessionStorage : null;
|
|
1638
|
-
return await
|
|
1624
|
+
return await Ze(this.getFetch())(
|
|
1639
1625
|
n,
|
|
1640
1626
|
this.configuration.authority_time_cache_wellknowurl_in_second ?? 60 * 60,
|
|
1641
1627
|
i,
|
|
@@ -1647,12 +1633,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1647
1633
|
});
|
|
1648
1634
|
}
|
|
1649
1635
|
async tryKeepExistingSessionAsync() {
|
|
1650
|
-
return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise =
|
|
1636
|
+
return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise = _n(this), this.tryKeepExistingSessionPromise.finally(() => {
|
|
1651
1637
|
this.tryKeepExistingSessionPromise = null;
|
|
1652
1638
|
}));
|
|
1653
1639
|
}
|
|
1654
1640
|
async startCheckSessionAsync(n, s, t, o = !1) {
|
|
1655
|
-
await
|
|
1641
|
+
await rn(this, L, this.configuration)(
|
|
1656
1642
|
n,
|
|
1657
1643
|
s,
|
|
1658
1644
|
t,
|
|
@@ -1660,13 +1646,13 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1660
1646
|
);
|
|
1661
1647
|
}
|
|
1662
1648
|
async loginAsync(n = void 0, s = null, t = !1, o = void 0, i = !1) {
|
|
1663
|
-
return this.logoutPromise && await this.logoutPromise, this.loginPromise !== null ? this.loginPromise : (i ? this.loginPromise =
|
|
1649
|
+
return this.logoutPromise && await this.logoutPromise, this.loginPromise !== null ? this.loginPromise : (i ? this.loginPromise = on(
|
|
1664
1650
|
window,
|
|
1665
1651
|
this.configurationName,
|
|
1666
1652
|
this.configuration,
|
|
1667
1653
|
this.publishEvent.bind(this),
|
|
1668
1654
|
this
|
|
1669
|
-
)(s, o) : this.loginPromise =
|
|
1655
|
+
)(s, o) : this.loginPromise = dn(
|
|
1670
1656
|
this.configurationName,
|
|
1671
1657
|
this.configuration,
|
|
1672
1658
|
this.publishEvent.bind(this),
|
|
@@ -1680,8 +1666,8 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1680
1666
|
if (this.loginCallbackPromise !== null)
|
|
1681
1667
|
return this.loginCallbackPromise;
|
|
1682
1668
|
const s = async () => {
|
|
1683
|
-
const t = await
|
|
1684
|
-
return this.tokens = o, await C(this.configuration, this.configurationName) || I(this.configurationName, this.configuration.storage).setTokens(o), this.publishEvent(
|
|
1669
|
+
const t = await hn(this)(n), o = t.tokens;
|
|
1670
|
+
return this.tokens = o, await C(this.configuration, this.configurationName) || I(this.configurationName, this.configuration.storage).setTokens(o), this.publishEvent(F.eventNames.token_acquired, o), this.configuration.preload_user_info && await this.userInfoAsync(), {
|
|
1685
1671
|
parsedTokens: o,
|
|
1686
1672
|
state: t.state,
|
|
1687
1673
|
callbackPath: t.callbackPath,
|
|
@@ -1695,7 +1681,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1695
1681
|
}
|
|
1696
1682
|
async generateDemonstrationOfProofOfPossessionAsync(n, s, t, o = {}) {
|
|
1697
1683
|
const i = this.configuration, r = {
|
|
1698
|
-
ath: await
|
|
1684
|
+
ath: await be(n),
|
|
1699
1685
|
...o
|
|
1700
1686
|
};
|
|
1701
1687
|
if (await C(i, this.configurationName))
|
|
@@ -1706,12 +1692,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1706
1692
|
)(l, t, s, r);
|
|
1707
1693
|
}
|
|
1708
1694
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1709
|
-
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1695
|
+
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise = An(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
|
|
1710
1696
|
this.loginCallbackWithAutoTokensRenewPromise = null;
|
|
1711
1697
|
}));
|
|
1712
1698
|
}
|
|
1713
1699
|
userInfoAsync(n = !1, s = !1) {
|
|
1714
|
-
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise =
|
|
1700
|
+
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise = mn(this)(n, s), this.userInfoPromise.finally(() => {
|
|
1715
1701
|
this.userInfoPromise = null;
|
|
1716
1702
|
}));
|
|
1717
1703
|
}
|
|
@@ -1724,7 +1710,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1724
1710
|
});
|
|
1725
1711
|
}
|
|
1726
1712
|
async destroyAsync(n) {
|
|
1727
|
-
return await
|
|
1713
|
+
return await gn(this)(n);
|
|
1728
1714
|
}
|
|
1729
1715
|
async logoutSameTabAsync(n, s) {
|
|
1730
1716
|
this.configuration.monitor_session && this.configuration.client_id === n && s && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === s && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(k.logout_from_same_tab, { mmessage: "SessionMonitor", sub: s }));
|
|
@@ -1733,7 +1719,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1733
1719
|
this.configuration.monitor_session && this.configuration.client_id === n && s && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === s && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(k.logout_from_another_tab, { message: "SessionMonitor", sub: s }));
|
|
1734
1720
|
}
|
|
1735
1721
|
async logoutAsync(n = void 0, s = null) {
|
|
1736
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1722
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = kn(
|
|
1737
1723
|
this,
|
|
1738
1724
|
L,
|
|
1739
1725
|
this.getFetch(),
|
|
@@ -1744,8 +1730,8 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1744
1730
|
}));
|
|
1745
1731
|
}
|
|
1746
1732
|
};
|
|
1747
|
-
|
|
1748
|
-
let N =
|
|
1733
|
+
F.getOrCreate = (n, s) => (t, o = "default") => wn(n, s)(t, o), F.eventNames = k;
|
|
1734
|
+
let N = F;
|
|
1749
1735
|
const $ = class $ {
|
|
1750
1736
|
constructor(n) {
|
|
1751
1737
|
this._oidc = n;
|
|
@@ -1815,14 +1801,14 @@ const $ = class $ {
|
|
|
1815
1801
|
return this._oidc.userInfo;
|
|
1816
1802
|
}
|
|
1817
1803
|
};
|
|
1818
|
-
$.getOrCreate = (n, s = new
|
|
1804
|
+
$.getOrCreate = (n, s = new H()) => (t, o = "default") => new $(N.getOrCreate(n, s)(t, o)), $.eventNames = N.eventNames;
|
|
1819
1805
|
let ke = $;
|
|
1820
1806
|
export {
|
|
1821
1807
|
ke as OidcClient,
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1808
|
+
H as OidcLocation,
|
|
1809
|
+
V as TokenAutomaticRenewMode,
|
|
1810
|
+
z as TokenRenewMode,
|
|
1811
|
+
pn as getFetchDefault,
|
|
1812
|
+
ne as getParseQueryStringFromLocation,
|
|
1813
|
+
vn as getPath
|
|
1828
1814
|
};
|