@axa-fr/oidc-client 7.27.1 → 7.27.3
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 +274 -268
- package/dist/index.umd.cjs +2 -2
- package/dist/initWorker.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/initWorker.ts +21 -4
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class ne {
|
|
2
2
|
open(n) {
|
|
3
3
|
window.location.href = n;
|
|
4
4
|
}
|
|
@@ -16,10 +16,10 @@ class ee {
|
|
|
16
16
|
return window.origin;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
class
|
|
21
|
-
constructor(n, t, s, o =
|
|
22
|
-
this._callback = n, this._client_id = t, this._url = s, this._interval = o ||
|
|
19
|
+
const Se = 2e3, F = console;
|
|
20
|
+
class Me {
|
|
21
|
+
constructor(n, t, s, o = Se, i = !0) {
|
|
22
|
+
this._callback = n, this._client_id = t, this._url = s, this._interval = o || Se, this._stopOnError = i;
|
|
23
23
|
const r = s.indexOf("/", s.indexOf("//") + 2);
|
|
24
24
|
this._frame_origin = s.substring(0, r), this._frame = window.document.createElement("iframe"), this._frame.style.visibility = "hidden", this._frame.style.position = "absolute", this._frame.style.display = "none", this._frame.width = 0, this._frame.height = 0, this._frame.src = s;
|
|
25
25
|
}
|
|
@@ -125,40 +125,40 @@ const k = {
|
|
|
125
125
|
getDemonstratingProofOfPossessionJwkAsync: l
|
|
126
126
|
};
|
|
127
127
|
};
|
|
128
|
-
var
|
|
129
|
-
const
|
|
128
|
+
var Y = /* @__PURE__ */ ((e) => (e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e))(Y || {});
|
|
129
|
+
const Be = (e) => decodeURIComponent(
|
|
130
130
|
Array.prototype.map.call(atob(e), (n) => "%" + ("00" + n.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
131
|
-
),
|
|
131
|
+
), Je = (e) => JSON.parse(Be(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), Te = (e) => {
|
|
132
132
|
try {
|
|
133
|
-
return e &&
|
|
133
|
+
return e && He(e, ".") === 2 ? Je(e.split(".")[1]) : null;
|
|
134
134
|
} catch (n) {
|
|
135
135
|
console.warn(n);
|
|
136
136
|
}
|
|
137
137
|
return null;
|
|
138
|
-
},
|
|
138
|
+
}, He = (e, n) => e.split(n).length - 1, ae = {
|
|
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 Ge(e, n, t) {
|
|
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 : t && t.iat ? t.iat : (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
148
148
|
return e.issuedAt;
|
|
149
149
|
}
|
|
150
|
-
const
|
|
150
|
+
const ge = (e, n = null, t) => {
|
|
151
151
|
if (!e)
|
|
152
152
|
return null;
|
|
153
153
|
let s;
|
|
154
154
|
const o = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
|
|
155
|
-
e.accessTokenPayload !== void 0 ? s = e.accessTokenPayload : s =
|
|
155
|
+
e.accessTokenPayload !== void 0 ? s = e.accessTokenPayload : s = Te(e.accessToken);
|
|
156
156
|
let i;
|
|
157
157
|
n != null && "idToken" in n && !("idToken" in e) ? i = n.idToken : i = e.idToken;
|
|
158
|
-
const r = e.idTokenPayload ? e.idTokenPayload :
|
|
159
|
-
e.issuedAt =
|
|
158
|
+
const r = e.idTokenPayload ? e.idTokenPayload : Te(i), a = r && r.exp ? r.exp : Number.MAX_VALUE, c = s && s.exp ? s.exp : e.issuedAt + o;
|
|
159
|
+
e.issuedAt = Ge(e, s, r);
|
|
160
160
|
let f;
|
|
161
|
-
e.expiresAt ? f = e.expiresAt : t ===
|
|
161
|
+
e.expiresAt ? f = e.expiresAt : t === ae.access_token_invalid ? f = c : t === ae.id_token_invalid ? f = a : f = a < c ? a : c;
|
|
162
162
|
const u = {
|
|
163
163
|
...e,
|
|
164
164
|
idTokenPayload: r,
|
|
@@ -171,7 +171,7 @@ const de = (e, n = null, t) => {
|
|
|
171
171
|
return { ...u, refreshToken: l };
|
|
172
172
|
}
|
|
173
173
|
return u;
|
|
174
|
-
},
|
|
174
|
+
}, he = (e, n, t) => {
|
|
175
175
|
if (!e)
|
|
176
176
|
return null;
|
|
177
177
|
if (!e.issued_at) {
|
|
@@ -186,30 +186,30 @@ const de = (e, n = null, t) => {
|
|
|
186
186
|
tokenType: e.token_type,
|
|
187
187
|
issuedAt: e.issued_at
|
|
188
188
|
};
|
|
189
|
-
return "refresh_token" in e && (s.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (s.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (s.idTokenPayload = e.idTokenPayload),
|
|
190
|
-
},
|
|
189
|
+
return "refresh_token" in e && (s.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (s.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (s.idTokenPayload = e.idTokenPayload), ge(s, n, t);
|
|
190
|
+
}, j = (e, n) => {
|
|
191
191
|
const t = (/* @__PURE__ */ new Date()).getTime() / 1e3, s = n - t;
|
|
192
192
|
return Math.round(s - e);
|
|
193
|
-
},
|
|
193
|
+
}, je = (e, n = 0) => e ? j(n, e.expiresAt) > 0 : !1, Ne = async (e, n = 200, t = 50) => {
|
|
194
194
|
let s = t, o = await e.syncTokensInfoAsync();
|
|
195
195
|
for (; [
|
|
196
196
|
P.REQUIRE_SYNC_TOKENS,
|
|
197
197
|
P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
|
|
198
198
|
P.TOKENS_INVALID
|
|
199
199
|
].includes(o) && s > 0; ) {
|
|
200
|
-
if (e.configuration.token_automatic_renew_mode ==
|
|
200
|
+
if (e.configuration.token_automatic_renew_mode == Y.AutomaticOnlyWhenFetchExecuted) {
|
|
201
201
|
await e.renewTokensAsync({});
|
|
202
202
|
break;
|
|
203
203
|
} else
|
|
204
|
-
await
|
|
204
|
+
await X({ milliseconds: n });
|
|
205
205
|
s = s - 1, o = await e.syncTokensInfoAsync();
|
|
206
206
|
}
|
|
207
207
|
return {
|
|
208
|
-
isTokensValid:
|
|
208
|
+
isTokensValid: je(e.getTokens()),
|
|
209
209
|
tokens: e.getTokens(),
|
|
210
210
|
numberWaited: s - t
|
|
211
211
|
};
|
|
212
|
-
},
|
|
212
|
+
}, xe = (e, n, t) => {
|
|
213
213
|
if (e.idTokenPayload) {
|
|
214
214
|
const s = e.idTokenPayload;
|
|
215
215
|
if (t.issuer !== s.iss)
|
|
@@ -244,32 +244,32 @@ const de = (e, n = null, t) => {
|
|
|
244
244
|
setInterval: setInterval.bind(e),
|
|
245
245
|
clearInterval: clearInterval.bind(e)
|
|
246
246
|
};
|
|
247
|
-
})(),
|
|
248
|
-
let
|
|
249
|
-
const
|
|
247
|
+
})(), oe = "7.27.3";
|
|
248
|
+
let ve = null, te;
|
|
249
|
+
const X = ({ milliseconds: e }) => new Promise((n) => R.setTimeout(n, e)), We = (e = "/") => {
|
|
250
250
|
try {
|
|
251
|
-
|
|
251
|
+
te = new AbortController(), fetch(
|
|
252
252
|
`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`,
|
|
253
|
-
{ signal:
|
|
253
|
+
{ signal: te.signal }
|
|
254
254
|
).catch((s) => {
|
|
255
255
|
console.log(s);
|
|
256
|
-
}),
|
|
257
|
-
() =>
|
|
256
|
+
}), X({ milliseconds: 150 * 1e3 }).then(
|
|
257
|
+
() => We(e)
|
|
258
258
|
);
|
|
259
259
|
} catch (n) {
|
|
260
260
|
console.log(n);
|
|
261
261
|
}
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
},
|
|
262
|
+
}, Z = () => {
|
|
263
|
+
te && te.abort();
|
|
264
|
+
}, ye = (e) => {
|
|
265
265
|
const n = `oidc.tabId.${e}`, t = sessionStorage.getItem(n);
|
|
266
266
|
if (t) return t;
|
|
267
267
|
const s = globalThis.crypto.randomUUID();
|
|
268
268
|
return sessionStorage.setItem(n, s), s;
|
|
269
|
-
},
|
|
270
|
-
const s = n?.timeoutMs ??
|
|
269
|
+
}, qe = 5e3, Ye = (e) => navigator.serviceWorker.controller ?? e.active ?? e.waiting ?? e.installing ?? null, I = (e, n) => (t) => {
|
|
270
|
+
const s = n?.timeoutMs ?? qe;
|
|
271
271
|
return new Promise((o, i) => {
|
|
272
|
-
const r =
|
|
272
|
+
const r = Ye(e);
|
|
273
273
|
if (!r) {
|
|
274
274
|
i(
|
|
275
275
|
new Error(
|
|
@@ -296,14 +296,14 @@ const Y = ({ milliseconds: e }) => new Promise((n) => R.setTimeout(n, e)), xe =
|
|
|
296
296
|
};
|
|
297
297
|
try {
|
|
298
298
|
const u = t?.configurationName;
|
|
299
|
-
r.postMessage({ ...t, tabId:
|
|
299
|
+
r.postMessage({ ...t, tabId: ye(u ?? "default") }, [
|
|
300
300
|
a.port2
|
|
301
301
|
]);
|
|
302
302
|
} catch (u) {
|
|
303
303
|
f(), i(u);
|
|
304
304
|
}
|
|
305
305
|
});
|
|
306
|
-
},
|
|
306
|
+
}, Xe = async (e) => navigator.serviceWorker.controller ? navigator.serviceWorker.controller : new Promise((n) => {
|
|
307
307
|
let t = !1;
|
|
308
308
|
const s = () => {
|
|
309
309
|
t || (t = !0, navigator.serviceWorker.removeEventListener("controllerchange", s), n(navigator.serviceWorker.controller ?? null));
|
|
@@ -312,36 +312,42 @@ const Y = ({ milliseconds: e }) => new Promise((n) => R.setTimeout(n, e)), xe =
|
|
|
312
312
|
t || (t = !0, navigator.serviceWorker.removeEventListener("controllerchange", s), n(navigator.serviceWorker.controller ?? null));
|
|
313
313
|
}, e);
|
|
314
314
|
});
|
|
315
|
-
let
|
|
316
|
-
const
|
|
315
|
+
let Ee = !1, M = !1;
|
|
316
|
+
const B = /* @__PURE__ */ new Map(), ke = "oidc.sw.controllerchange_reload_count", ie = 3, ce = () => {
|
|
317
317
|
try {
|
|
318
|
-
return parseInt(sessionStorage.getItem(
|
|
318
|
+
return parseInt(sessionStorage.getItem(ke) ?? "0", 10);
|
|
319
319
|
} catch {
|
|
320
320
|
return 0;
|
|
321
321
|
}
|
|
322
|
-
},
|
|
323
|
-
const e =
|
|
322
|
+
}, ze = () => {
|
|
323
|
+
const e = ce() + 1;
|
|
324
324
|
try {
|
|
325
|
-
sessionStorage.setItem(
|
|
325
|
+
sessionStorage.setItem(ke, String(e));
|
|
326
326
|
} catch {
|
|
327
327
|
}
|
|
328
328
|
return e;
|
|
329
|
-
},
|
|
329
|
+
}, Qe = () => {
|
|
330
330
|
try {
|
|
331
|
-
sessionStorage.removeItem(
|
|
331
|
+
sessionStorage.removeItem(ke);
|
|
332
332
|
} catch {
|
|
333
333
|
}
|
|
334
334
|
}, W = async (e, n) => {
|
|
335
335
|
const t = e.service_worker_relative_url;
|
|
336
336
|
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !t || e.service_worker_activate() === !1)
|
|
337
337
|
return null;
|
|
338
|
-
const s = `${t}?v=${
|
|
338
|
+
const s = `${t}?v=${oe}`;
|
|
339
339
|
let o = null;
|
|
340
|
-
e.service_worker_register ?
|
|
341
|
-
|
|
342
|
-
|
|
340
|
+
e.service_worker_register ? (B.has(t) || B.set(
|
|
341
|
+
t,
|
|
342
|
+
e.service_worker_register(t)
|
|
343
|
+
), o = await B.get(t)) : (B.has(s) || B.set(
|
|
344
|
+
s,
|
|
345
|
+
navigator.serviceWorker.register(s, {
|
|
346
|
+
updateViaCache: "none"
|
|
347
|
+
})
|
|
348
|
+
), o = await B.get(s));
|
|
343
349
|
const i = `oidc.sw.version_mismatch_reload.${n}`, r = async (d) => {
|
|
344
|
-
|
|
350
|
+
Z(), console.log("New SW waiting – SKIP_WAITING");
|
|
345
351
|
try {
|
|
346
352
|
await new Promise((N, S) => {
|
|
347
353
|
const b = new MessageChannel();
|
|
@@ -364,7 +370,7 @@ const ye = "oidc.sw.controllerchange_reload_count", oe = 3, ae = () => {
|
|
|
364
370
|
type: "SKIP_WAITING",
|
|
365
371
|
configurationName: n,
|
|
366
372
|
data: null,
|
|
367
|
-
tabId:
|
|
373
|
+
tabId: ye(n ?? "default")
|
|
368
374
|
},
|
|
369
375
|
[b.port2]
|
|
370
376
|
);
|
|
@@ -379,9 +385,9 @@ const ye = "oidc.sw.controllerchange_reload_count", oe = 3, ae = () => {
|
|
|
379
385
|
const d = o.waiting;
|
|
380
386
|
d ? await r(d) : console.warn("sendSkipWaiting called but no waiting service worker found");
|
|
381
387
|
}, c = (d) => {
|
|
382
|
-
|
|
388
|
+
Z(), d.addEventListener("statechange", async () => {
|
|
383
389
|
if (d.state === "installed" && navigator.serviceWorker.controller) {
|
|
384
|
-
if (
|
|
390
|
+
if (ce() >= ie) {
|
|
385
391
|
console.warn(
|
|
386
392
|
"SW trackInstallingWorker: skipping SKIP_WAITING because the reload budget is exhausted"
|
|
387
393
|
);
|
|
@@ -394,7 +400,7 @@ const ye = "oidc.sw.controllerchange_reload_count", oe = 3, ae = () => {
|
|
|
394
400
|
o.addEventListener("updatefound", () => {
|
|
395
401
|
const d = o.installing;
|
|
396
402
|
d && c(d);
|
|
397
|
-
}), o.installing ? c(o.installing) : o.waiting && navigator.serviceWorker.controller && (
|
|
403
|
+
}), o.installing ? c(o.installing) : o.waiting && navigator.serviceWorker.controller && (ce() < ie ? a() : console.warn(
|
|
398
404
|
"SW: a waiting worker exists but reload budget is exhausted – skipping activation"
|
|
399
405
|
)), o.update().catch((d) => {
|
|
400
406
|
console.error(d);
|
|
@@ -404,21 +410,21 @@ const ye = "oidc.sw.controllerchange_reload_count", oe = 3, ae = () => {
|
|
|
404
410
|
type: "claim",
|
|
405
411
|
configurationName: n,
|
|
406
412
|
data: null
|
|
407
|
-
}), await
|
|
413
|
+
}), await Xe(2e3));
|
|
408
414
|
} catch (d) {
|
|
409
415
|
return console.warn(`Failed init ServiceWorker ${d?.toString?.() ?? String(d)}`), null;
|
|
410
416
|
}
|
|
411
|
-
|
|
417
|
+
Ee || (Ee = !0, navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
412
418
|
if (M)
|
|
413
419
|
return;
|
|
414
|
-
const d =
|
|
415
|
-
if (d >
|
|
420
|
+
const d = ze();
|
|
421
|
+
if (d > ie) {
|
|
416
422
|
console.warn(
|
|
417
423
|
`SW controllerchange: reload budget exhausted (${d - 1} reloads). Skipping reload to avoid infinite loop.`
|
|
418
424
|
);
|
|
419
425
|
return;
|
|
420
426
|
}
|
|
421
|
-
M = !0, console.log("SW controller changed – reloading page"),
|
|
427
|
+
M = !0, console.log("SW controller changed – reloading page"), Z(), window.location.reload();
|
|
422
428
|
}));
|
|
423
429
|
const f = async (d) => I(o)({ type: "clear", data: { status: d }, configurationName: n }), u = async (d, N, S) => {
|
|
424
430
|
const b = await I(o)({
|
|
@@ -433,24 +439,24 @@ const ye = "oidc.sw.controllerchange_reload_count", oe = 3, ae = () => {
|
|
|
433
439
|
},
|
|
434
440
|
configurationName: n
|
|
435
441
|
}), K = b.version;
|
|
436
|
-
if (K !==
|
|
442
|
+
if (K !== oe) {
|
|
437
443
|
console.warn(
|
|
438
|
-
`Service worker ${K} version mismatch with js client version ${
|
|
444
|
+
`Service worker ${K} version mismatch with js client version ${oe}, unregistering and reloading`
|
|
439
445
|
);
|
|
440
446
|
const U = parseInt(sessionStorage.getItem(i) ?? "0", 10);
|
|
441
447
|
if (U < 3) {
|
|
442
448
|
if (sessionStorage.setItem(i, String(U + 1)), o.waiting)
|
|
443
|
-
return await a(), await
|
|
449
|
+
return await a(), await X({ milliseconds: 500 }), M || (M = !0, window.location.reload()), new Promise(() => {
|
|
444
450
|
});
|
|
445
451
|
{
|
|
446
|
-
|
|
452
|
+
Z();
|
|
447
453
|
try {
|
|
448
454
|
await o.update();
|
|
449
|
-
} catch (
|
|
450
|
-
console.error(
|
|
455
|
+
} catch (Ae) {
|
|
456
|
+
console.error(Ae);
|
|
451
457
|
}
|
|
452
458
|
const L = await o.unregister();
|
|
453
|
-
return console.log(`Service worker unregistering ${L}`), await
|
|
459
|
+
return console.log(`Service worker unregistering ${L}`), await X({ milliseconds: 500 }), M || (M = !0, window.location.reload()), new Promise(() => {
|
|
454
460
|
});
|
|
455
461
|
}
|
|
456
462
|
} else
|
|
@@ -458,13 +464,13 @@ const ye = "oidc.sw.controllerchange_reload_count", oe = 3, ae = () => {
|
|
|
458
464
|
`Service worker version mismatch persists after ${U} attempt(s). Continuing with mismatched version.`
|
|
459
465
|
);
|
|
460
466
|
} else
|
|
461
|
-
sessionStorage.removeItem(i),
|
|
467
|
+
sessionStorage.removeItem(i), Qe();
|
|
462
468
|
return {
|
|
463
|
-
tokens:
|
|
469
|
+
tokens: he(b.tokens, null, S.token_renew_mode),
|
|
464
470
|
status: b.status
|
|
465
471
|
};
|
|
466
472
|
}, l = (d = "/") => {
|
|
467
|
-
|
|
473
|
+
ve == null && (ve = "not_null", We(d));
|
|
468
474
|
}, h = (d) => I(o)({
|
|
469
475
|
type: "setSessionState",
|
|
470
476
|
data: { sessionState: d },
|
|
@@ -519,8 +525,8 @@ const ye = "oidc.sw.controllerchange_reload_count", oe = 3, ae = () => {
|
|
|
519
525
|
data: null,
|
|
520
526
|
configurationName: n
|
|
521
527
|
})).state;
|
|
522
|
-
return S || (S = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"), d && (await
|
|
523
|
-
},
|
|
528
|
+
return S || (S = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"), d && (await G(S), S = await w(!1))), S;
|
|
529
|
+
}, G = async (d) => (sessionStorage[`oidc.state.${n}`] = d, I(o)({
|
|
524
530
|
type: "setState",
|
|
525
531
|
data: { state: d },
|
|
526
532
|
configurationName: n
|
|
@@ -547,7 +553,7 @@ const ye = "oidc.sw.controllerchange_reload_count", oe = 3, ae = () => {
|
|
|
547
553
|
setLoginParams: y,
|
|
548
554
|
getLoginParams: A,
|
|
549
555
|
getStateAsync: w,
|
|
550
|
-
setStateAsync:
|
|
556
|
+
setStateAsync: G,
|
|
551
557
|
getCodeVerifierAsync: $,
|
|
552
558
|
setCodeVerifierAsync: E,
|
|
553
559
|
setDemonstratingProofOfPossessionNonce: T,
|
|
@@ -555,38 +561,38 @@ const ye = "oidc.sw.controllerchange_reload_count", oe = 3, ae = () => {
|
|
|
555
561
|
setDemonstratingProofOfPossessionJwkAsync: v,
|
|
556
562
|
getDemonstratingProofOfPossessionJwkAsync: C
|
|
557
563
|
};
|
|
558
|
-
},
|
|
559
|
-
if (!
|
|
564
|
+
}, J = {}, Ze = (e, n = window.sessionStorage, t) => {
|
|
565
|
+
if (!J[e] && n) {
|
|
560
566
|
const o = n.getItem(e);
|
|
561
|
-
o && (
|
|
567
|
+
o && (J[e] = JSON.parse(o));
|
|
562
568
|
}
|
|
563
569
|
const s = 1e3 * t;
|
|
564
|
-
return
|
|
565
|
-
},
|
|
570
|
+
return J[e] && J[e].timestamp + s > Date.now() ? J[e].result : null;
|
|
571
|
+
}, en = (e, n, t = window.sessionStorage) => {
|
|
566
572
|
const s = Date.now();
|
|
567
|
-
|
|
573
|
+
J[e] = { result: n, timestamp: s }, t && t.setItem(e, JSON.stringify({ result: n, timestamp: s }));
|
|
568
574
|
};
|
|
569
|
-
function
|
|
575
|
+
function Le(e) {
|
|
570
576
|
return new TextEncoder().encode(e);
|
|
571
577
|
}
|
|
572
|
-
function
|
|
578
|
+
function De(e) {
|
|
573
579
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
|
|
574
580
|
}
|
|
575
|
-
function
|
|
581
|
+
function nn(e) {
|
|
576
582
|
return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function(t, s) {
|
|
577
583
|
return String.fromCharCode(parseInt(s, 16));
|
|
578
584
|
});
|
|
579
585
|
}
|
|
580
|
-
const
|
|
586
|
+
const me = (e) => {
|
|
581
587
|
let n = "";
|
|
582
588
|
return e.forEach(function(t) {
|
|
583
589
|
n += String.fromCharCode(t);
|
|
584
|
-
}),
|
|
590
|
+
}), De(n);
|
|
585
591
|
};
|
|
586
|
-
function
|
|
587
|
-
return
|
|
592
|
+
function Oe(e) {
|
|
593
|
+
return De(nn(e));
|
|
588
594
|
}
|
|
589
|
-
const
|
|
595
|
+
const tn = {
|
|
590
596
|
importKeyAlgorithm: {
|
|
591
597
|
name: "ECDSA",
|
|
592
598
|
namedCurve: "P-256",
|
|
@@ -599,7 +605,7 @@ const nn = {
|
|
|
599
605
|
},
|
|
600
606
|
digestAlgorithm: { name: "SHA-256" },
|
|
601
607
|
jwtHeaderAlgorithm: "ES256"
|
|
602
|
-
},
|
|
608
|
+
}, sn = (e) => async (n, t, s, o, i = "dpop+jwt") => {
|
|
603
609
|
switch (n = Object.assign({}, n), t.typ = i, t.alg = o.jwtHeaderAlgorithm, t.alg) {
|
|
604
610
|
case "ES256":
|
|
605
611
|
t.jwk = { kty: n.kty, crv: n.crv, x: n.x, y: n.y };
|
|
@@ -613,22 +619,22 @@ const nn = {
|
|
|
613
619
|
const r = {
|
|
614
620
|
// @ts-ignore
|
|
615
621
|
// JWT "headers" really means JWS "protected headers"
|
|
616
|
-
protected:
|
|
622
|
+
protected: Oe(JSON.stringify(t)),
|
|
617
623
|
// @ts-ignore
|
|
618
624
|
// JWT "claims" are really a JSON-defined JWS "payload"
|
|
619
|
-
payload:
|
|
620
|
-
}, a = o.importKeyAlgorithm, c = !0, f = ["sign"], u = await e.crypto.subtle.importKey("jwk", n, a, c, f), l =
|
|
621
|
-
return r.signature =
|
|
622
|
-
},
|
|
625
|
+
payload: Oe(JSON.stringify(s))
|
|
626
|
+
}, a = o.importKeyAlgorithm, c = !0, f = ["sign"], u = await e.crypto.subtle.importKey("jwk", n, a, c, f), l = Le(`${r.protected}.${r.payload}`), h = o.signAlgorithm, _ = await e.crypto.subtle.sign(h, u, l);
|
|
627
|
+
return r.signature = me(new Uint8Array(_)), `${r.protected}.${r.payload}.${r.signature}`;
|
|
628
|
+
}, on = { sign: sn }, rn = (e) => async (n) => {
|
|
623
629
|
const t = n, s = !0, o = ["sign", "verify"], i = await e.crypto.subtle.generateKey(t, s, o);
|
|
624
630
|
return await e.crypto.subtle.exportKey("jwk", i.privateKey);
|
|
625
|
-
},
|
|
631
|
+
}, an = (e) => {
|
|
626
632
|
const n = Object.assign({}, e);
|
|
627
633
|
return delete n.d, n.key_ops = ["verify"], n;
|
|
628
|
-
},
|
|
629
|
-
generate:
|
|
630
|
-
neuter:
|
|
631
|
-
},
|
|
634
|
+
}, cn = {
|
|
635
|
+
generate: rn,
|
|
636
|
+
neuter: an
|
|
637
|
+
}, ln = (e) => async (n, t) => {
|
|
632
638
|
let s;
|
|
633
639
|
switch (n.kty) {
|
|
634
640
|
case "EC":
|
|
@@ -640,80 +646,80 @@ const nn = {
|
|
|
640
646
|
default:
|
|
641
647
|
throw new Error("Unknown or not implemented JWK type");
|
|
642
648
|
}
|
|
643
|
-
const o = await e.crypto.subtle.digest(t,
|
|
644
|
-
return
|
|
645
|
-
},
|
|
649
|
+
const o = await e.crypto.subtle.digest(t, Le(s));
|
|
650
|
+
return me(new Uint8Array(o));
|
|
651
|
+
}, un = { thumbprint: ln }, _n = (e) => async (n) => await cn.generate(e)(n), Re = (e) => (n) => async (t, s = "POST", o, i = {}) => {
|
|
646
652
|
const r = {
|
|
647
653
|
// https://www.rfc-editor.org/rfc/rfc9449.html#name-concept
|
|
648
|
-
jti: btoa(
|
|
654
|
+
jti: btoa(fn()),
|
|
649
655
|
htm: s,
|
|
650
656
|
htu: o,
|
|
651
657
|
iat: Math.round(Date.now() / 1e3),
|
|
652
658
|
...i
|
|
653
|
-
}, a = await
|
|
659
|
+
}, a = await un.thumbprint(e)(
|
|
654
660
|
t,
|
|
655
661
|
n.digestAlgorithm
|
|
656
662
|
);
|
|
657
|
-
return await
|
|
663
|
+
return await on.sign(e)(
|
|
658
664
|
t,
|
|
659
665
|
{ kid: a },
|
|
660
666
|
r,
|
|
661
667
|
n
|
|
662
668
|
);
|
|
663
|
-
},
|
|
669
|
+
}, fn = () => {
|
|
664
670
|
const e = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", n = "0123456789abcdef";
|
|
665
671
|
let t = 0, s = "";
|
|
666
672
|
for (let o = 0; o < 36; o++)
|
|
667
673
|
e[o] !== "-" && e[o] !== "4" && (t = Math.random() * 16 | 0), e[o] === "x" ? s += n[t] : e[o] === "y" ? (t &= 3, t |= 8, s += n[t]) : s += e[o];
|
|
668
674
|
return s;
|
|
669
|
-
},
|
|
675
|
+
}, $e = () => {
|
|
670
676
|
const e = typeof window < "u" && !!window.crypto, n = e && !!window.crypto.subtle;
|
|
671
677
|
return { hasCrypto: e, hasSubtleCrypto: n };
|
|
672
|
-
},
|
|
678
|
+
}, le = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", dn = (e) => {
|
|
673
679
|
const n = [];
|
|
674
680
|
for (let t = 0; t < e.byteLength; t += 1) {
|
|
675
|
-
const s = e[t] %
|
|
676
|
-
n.push(
|
|
681
|
+
const s = e[t] % le.length;
|
|
682
|
+
n.push(le[s]);
|
|
677
683
|
}
|
|
678
684
|
return n.join("");
|
|
679
|
-
},
|
|
680
|
-
const n = new Uint8Array(e), { hasCrypto: t } =
|
|
685
|
+
}, ue = (e) => {
|
|
686
|
+
const n = new Uint8Array(e), { hasCrypto: t } = $e();
|
|
681
687
|
if (t)
|
|
682
688
|
window.crypto.getRandomValues(n);
|
|
683
689
|
else
|
|
684
690
|
for (let s = 0; s < e; s += 1)
|
|
685
|
-
n[s] = Math.random() *
|
|
686
|
-
return
|
|
691
|
+
n[s] = Math.random() * le.length | 0;
|
|
692
|
+
return dn(n);
|
|
687
693
|
};
|
|
688
|
-
function
|
|
694
|
+
function gn(e) {
|
|
689
695
|
const n = new ArrayBuffer(e.length), t = new Uint8Array(n);
|
|
690
696
|
for (let s = 0; s < e.length; s++)
|
|
691
697
|
t[s] = e.charCodeAt(s);
|
|
692
698
|
return t;
|
|
693
699
|
}
|
|
694
|
-
function
|
|
700
|
+
function Ke(e) {
|
|
695
701
|
return new Promise((n, t) => {
|
|
696
|
-
crypto.subtle.digest("SHA-256",
|
|
697
|
-
(s) => n(
|
|
702
|
+
crypto.subtle.digest("SHA-256", gn(e)).then(
|
|
703
|
+
(s) => n(me(new Uint8Array(s))),
|
|
698
704
|
(s) => t(s)
|
|
699
705
|
);
|
|
700
706
|
});
|
|
701
707
|
}
|
|
702
|
-
const
|
|
708
|
+
const hn = (e) => {
|
|
703
709
|
if (e.length < 43 || e.length > 128)
|
|
704
710
|
return Promise.reject(new Error("Invalid code length."));
|
|
705
|
-
const { hasSubtleCrypto: n } =
|
|
706
|
-
return n ?
|
|
707
|
-
},
|
|
708
|
-
const i = `${n}/.well-known/openid-configuration`, r = `oidc.server:${n}`, a =
|
|
711
|
+
const { hasSubtleCrypto: n } = $e();
|
|
712
|
+
return n ? Ke(e) : Promise.reject(new Error("window.crypto.subtle is unavailable."));
|
|
713
|
+
}, yn = 3600, kn = (e) => async (n, t = yn, s = window.sessionStorage, o = 1e4) => {
|
|
714
|
+
const i = `${n}/.well-known/openid-configuration`, r = `oidc.server:${n}`, a = Ze(r, s, t);
|
|
709
715
|
if (a)
|
|
710
|
-
return new
|
|
711
|
-
const c = await
|
|
716
|
+
return new de(a);
|
|
717
|
+
const c = await Q(e)(i, {}, o);
|
|
712
718
|
if (c.status !== 200)
|
|
713
719
|
return null;
|
|
714
720
|
const f = await c.json();
|
|
715
|
-
return
|
|
716
|
-
},
|
|
721
|
+
return en(r, f, s), new de(f);
|
|
722
|
+
}, Q = (e) => async (n, t = {}, s = 1e4, o = 0) => {
|
|
717
723
|
let i;
|
|
718
724
|
try {
|
|
719
725
|
const r = new AbortController();
|
|
@@ -721,16 +727,16 @@ const gn = (e) => {
|
|
|
721
727
|
} catch (r) {
|
|
722
728
|
if (r.name === "AbortError" || r.message === "Network request failed") {
|
|
723
729
|
if (o <= 1)
|
|
724
|
-
return await
|
|
730
|
+
return await Q(e)(n, t, s, o + 1);
|
|
725
731
|
throw r;
|
|
726
732
|
} else
|
|
727
733
|
throw console.error(r.message), r;
|
|
728
734
|
}
|
|
729
735
|
return i;
|
|
730
|
-
},
|
|
736
|
+
}, _e = {
|
|
731
737
|
refresh_token: "refresh_token",
|
|
732
738
|
access_token: "access_token"
|
|
733
|
-
},
|
|
739
|
+
}, be = (e) => async (n, t, s = _e.refresh_token, o, i = {}, r = 1e4) => {
|
|
734
740
|
const a = {
|
|
735
741
|
token: t,
|
|
736
742
|
token_type_hint: s,
|
|
@@ -744,7 +750,7 @@ const gn = (e) => {
|
|
|
744
750
|
c.push(`${h}=${_}`);
|
|
745
751
|
}
|
|
746
752
|
const f = c.join("&");
|
|
747
|
-
return (await
|
|
753
|
+
return (await Q(e)(
|
|
748
754
|
n,
|
|
749
755
|
{
|
|
750
756
|
method: "POST",
|
|
@@ -757,7 +763,7 @@ const gn = (e) => {
|
|
|
757
763
|
)).status !== 200 ? { success: !1 } : {
|
|
758
764
|
success: !0
|
|
759
765
|
};
|
|
760
|
-
},
|
|
766
|
+
}, mn = (e) => async (n, t, s, o, i = {}, r, a = 1e4) => {
|
|
761
767
|
for (const [_, m] of Object.entries(s))
|
|
762
768
|
t[_] === void 0 && (t[_] = m);
|
|
763
769
|
const c = [];
|
|
@@ -765,7 +771,7 @@ const gn = (e) => {
|
|
|
765
771
|
const m = encodeURIComponent(_), p = encodeURIComponent(t[_]);
|
|
766
772
|
c.push(`${m}=${p}`);
|
|
767
773
|
}
|
|
768
|
-
const f = c.join("&"), u = await
|
|
774
|
+
const f = c.join("&"), u = await Q(e)(
|
|
769
775
|
n,
|
|
770
776
|
{
|
|
771
777
|
method: "POST",
|
|
@@ -785,31 +791,31 @@ const gn = (e) => {
|
|
|
785
791
|
};
|
|
786
792
|
const l = await u.json();
|
|
787
793
|
let h = null;
|
|
788
|
-
return u.headers.has(
|
|
789
|
-
|
|
794
|
+
return u.headers.has(se) && (h = u.headers.get(
|
|
795
|
+
se
|
|
790
796
|
)), {
|
|
791
797
|
success: !0,
|
|
792
798
|
status: u.status,
|
|
793
|
-
data:
|
|
799
|
+
data: he(l, o, r),
|
|
794
800
|
demonstratingProofOfPossessionNonce: h
|
|
795
801
|
};
|
|
796
|
-
},
|
|
802
|
+
}, wn = (e, n) => async (t, s) => {
|
|
797
803
|
s = s ? { ...s } : {};
|
|
798
|
-
const o =
|
|
804
|
+
const o = ue(128), i = await hn(o);
|
|
799
805
|
await e.setCodeVerifierAsync(o), await e.setStateAsync(s.state), s.code_challenge = i, s.code_challenge_method = "S256";
|
|
800
806
|
let r = "";
|
|
801
807
|
if (s)
|
|
802
808
|
for (const [a, c] of Object.entries(s))
|
|
803
809
|
r === "" ? r += "?" : r += "&", r += `${a}=${encodeURIComponent(c)}`;
|
|
804
810
|
n.open(`${t}${r}`);
|
|
805
|
-
},
|
|
811
|
+
}, se = "DPoP-Nonce", pn = (e) => async (n, t, s, o, i = 1e4) => {
|
|
806
812
|
t = t ? { ...t } : {}, t.code_verifier = await e.getCodeVerifierAsync();
|
|
807
813
|
const r = [];
|
|
808
814
|
for (const l in t) {
|
|
809
815
|
const h = encodeURIComponent(l), _ = encodeURIComponent(t[l]);
|
|
810
816
|
r.push(`${h}=${_}`);
|
|
811
817
|
}
|
|
812
|
-
const a = r.join("&"), c = await
|
|
818
|
+
const a = r.join("&"), c = await Q(fetch)(
|
|
813
819
|
n,
|
|
814
820
|
{
|
|
815
821
|
method: "POST",
|
|
@@ -824,23 +830,23 @@ const gn = (e) => {
|
|
|
824
830
|
if (await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]), c.status !== 200)
|
|
825
831
|
return { success: !1, status: c.status };
|
|
826
832
|
let f = null;
|
|
827
|
-
c.headers.has(
|
|
828
|
-
|
|
833
|
+
c.headers.has(se) && (f = c.headers.get(
|
|
834
|
+
se
|
|
829
835
|
));
|
|
830
836
|
const u = await c.json();
|
|
831
837
|
return {
|
|
832
838
|
success: !0,
|
|
833
839
|
data: {
|
|
834
840
|
state: t.state,
|
|
835
|
-
tokens:
|
|
841
|
+
tokens: he(u, null, o),
|
|
836
842
|
demonstratingProofOfPossessionNonce: f
|
|
837
843
|
}
|
|
838
844
|
};
|
|
839
845
|
};
|
|
840
|
-
async function
|
|
846
|
+
async function Pe(e, n, t, s = null) {
|
|
841
847
|
const o = (c) => {
|
|
842
848
|
e.tokens = c;
|
|
843
|
-
}, { tokens: i, status: r } = await
|
|
849
|
+
}, { tokens: i, status: r } = await ee(e)(
|
|
844
850
|
o,
|
|
845
851
|
0,
|
|
846
852
|
0,
|
|
@@ -854,31 +860,31 @@ async function be(e, n, t, s = null) {
|
|
|
854
860
|
e.configuration.login_state_storage ?? e.configuration.storage
|
|
855
861
|
).setTokens(e.tokens), e.tokens ? i : (await e.destroyAsync(r), null);
|
|
856
862
|
}
|
|
857
|
-
async function
|
|
863
|
+
async function Ue(e, n = !1, t = null, s = null) {
|
|
858
864
|
const o = e.configuration, i = `${o.client_id}_${e.configurationName}_${o.authority}`;
|
|
859
865
|
let r;
|
|
860
866
|
const a = await W(e.configuration, e.configurationName);
|
|
861
867
|
if (o?.storage === window?.sessionStorage && !a || !navigator.locks)
|
|
862
|
-
r = await
|
|
868
|
+
r = await Pe(e, n, t, s);
|
|
863
869
|
else {
|
|
864
870
|
let c = "retry";
|
|
865
871
|
for (; c === "retry"; )
|
|
866
872
|
c = await navigator.locks.request(
|
|
867
873
|
i,
|
|
868
874
|
{ ifAvailable: !0 },
|
|
869
|
-
async (f) => f ? await
|
|
875
|
+
async (f) => f ? await Pe(e, n, t, s) : (e.publishEvent(D.eventNames.syncTokensAsync_lock_not_available, {
|
|
870
876
|
lock: "lock not available"
|
|
871
877
|
}), "retry")
|
|
872
878
|
);
|
|
873
879
|
r = c;
|
|
874
880
|
}
|
|
875
|
-
return r ? (e.timeoutId && (e.timeoutId =
|
|
881
|
+
return r ? (e.timeoutId && (e.timeoutId = z(e, e.tokens.expiresAt, t, s)), e.tokens) : null;
|
|
876
882
|
}
|
|
877
|
-
const
|
|
883
|
+
const z = (e, n, t = null, s = null) => {
|
|
878
884
|
const o = e.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
879
885
|
return e.timeoutId && R.clearTimeout(e.timeoutId), R.setTimeout(async () => {
|
|
880
|
-
const r = { timeLeft:
|
|
881
|
-
e.publishEvent(D.eventNames.token_timer, r), await
|
|
886
|
+
const r = { timeLeft: j(o, n) };
|
|
887
|
+
e.publishEvent(D.eventNames.token_timer, r), await Ue(e, !1, t, s);
|
|
882
888
|
}, 1e3);
|
|
883
889
|
}, P = {
|
|
884
890
|
FORCE_REFRESH: "FORCE_REFRESH",
|
|
@@ -890,7 +896,7 @@ const X = (e, n, t = null, s = null) => {
|
|
|
890
896
|
LOGOUT_FROM_ANOTHER_TAB: "LOGOUT_FROM_ANOTHER_TAB",
|
|
891
897
|
REQUIRE_SYNC_TOKENS: "REQUIRE_SYNC_TOKENS",
|
|
892
898
|
TOKENS_INVALID: "TOKENS_INVALID"
|
|
893
|
-
},
|
|
899
|
+
}, we = (e) => async (n, t, s, o = !1) => {
|
|
894
900
|
const i = { nonce: null };
|
|
895
901
|
if (!s)
|
|
896
902
|
return { tokens: null, status: P.NOT_CONNECTED, nonce: i };
|
|
@@ -920,7 +926,7 @@ const X = (e, n, t = null, s = null) => {
|
|
|
920
926
|
nonce: i
|
|
921
927
|
};
|
|
922
928
|
if (h.issuedAt !== s.issuedAt) {
|
|
923
|
-
const m =
|
|
929
|
+
const m = j(
|
|
924
930
|
n.refresh_time_before_tokens_expiration_in_second,
|
|
925
931
|
h.expiresAt
|
|
926
932
|
) > 0 ? P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, p = await c.getNonceAsync();
|
|
@@ -935,11 +941,11 @@ const X = (e, n, t = null, s = null) => {
|
|
|
935
941
|
), h = await l.initAsync();
|
|
936
942
|
let { tokens: _ } = h;
|
|
937
943
|
const { status: m } = h;
|
|
938
|
-
if (_ && (_ =
|
|
944
|
+
if (_ && (_ = ge(_, e.tokens, n.token_renew_mode)), _) {
|
|
939
945
|
if (m === "SESSIONS_LOST")
|
|
940
946
|
return { tokens: null, status: P.SESSION_LOST, nonce: i };
|
|
941
947
|
if (_.issuedAt !== s.issuedAt) {
|
|
942
|
-
const g =
|
|
948
|
+
const g = j(
|
|
943
949
|
n.refresh_time_before_tokens_expiration_in_second,
|
|
944
950
|
_.expiresAt
|
|
945
951
|
) > 0 ? P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, y = await l.getNonceAsync();
|
|
@@ -952,25 +958,25 @@ const X = (e, n, t = null, s = null) => {
|
|
|
952
958
|
};
|
|
953
959
|
r = await l.getNonceAsync();
|
|
954
960
|
}
|
|
955
|
-
const u =
|
|
961
|
+
const u = j(
|
|
956
962
|
n.refresh_time_before_tokens_expiration_in_second,
|
|
957
963
|
s.expiresAt
|
|
958
964
|
) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
|
|
959
965
|
return o ? { tokens: s, status: "FORCE_REFRESH", nonce: r } : { tokens: s, status: u, nonce: r };
|
|
960
|
-
},
|
|
966
|
+
}, ee = (e) => async (n, t = 0, s = 0, o = !1, i = null, r = null) => {
|
|
961
967
|
if (!navigator.onLine && document.hidden)
|
|
962
968
|
return { tokens: e.tokens, status: "GIVE_UP" };
|
|
963
969
|
let a = 6;
|
|
964
970
|
const c = o ? 2 : 5, f = 5;
|
|
965
971
|
for (; !navigator.onLine && a > 0; )
|
|
966
|
-
await
|
|
972
|
+
await X({ milliseconds: 1e3 }), a--, e.publishEvent(k.refreshTokensAsync, {
|
|
967
973
|
message: `wait because navigator is offline try ${a}`
|
|
968
974
|
});
|
|
969
975
|
const u = document.hidden, l = u ? t : t + 1, h = u ? s + 1 : s;
|
|
970
976
|
if (t >= c || s >= f)
|
|
971
977
|
return n(null), e.publishEvent(k.refreshTokensAsync_error, { message: "refresh token" }), { tokens: null, status: "SESSION_LOST" };
|
|
972
978
|
i || (i = {});
|
|
973
|
-
const _ = e.configuration, m = (g, y = null, A = null) =>
|
|
979
|
+
const _ = e.configuration, m = (g, y = null, A = null) => pe(
|
|
974
980
|
e.configurationName,
|
|
975
981
|
e.configuration,
|
|
976
982
|
e.publishEvent.bind(e)
|
|
@@ -1001,7 +1007,7 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1001
1007
|
return console.error(g), e.publishEvent(k.refreshTokensAsync_silent_error, {
|
|
1002
1008
|
message: "exceptionSilent",
|
|
1003
1009
|
exception: g.message
|
|
1004
|
-
}), await
|
|
1010
|
+
}), await ee(e)(
|
|
1005
1011
|
n,
|
|
1006
1012
|
l,
|
|
1007
1013
|
h,
|
|
@@ -1012,7 +1018,7 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1012
1018
|
}
|
|
1013
1019
|
};
|
|
1014
1020
|
try {
|
|
1015
|
-
const { status: g, tokens: y, nonce: A } = await
|
|
1021
|
+
const { status: g, tokens: y, nonce: A } = await we(e)(
|
|
1016
1022
|
_,
|
|
1017
1023
|
e.configurationName,
|
|
1018
1024
|
e.tokens,
|
|
@@ -1036,9 +1042,9 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1036
1042
|
status: "session syncTokensAsync"
|
|
1037
1043
|
}), { tokens: null, status: "LOGGED_OUT" };
|
|
1038
1044
|
case P.REQUIRE_SYNC_TOKENS:
|
|
1039
|
-
return _.token_automatic_renew_mode ==
|
|
1045
|
+
return _.token_automatic_renew_mode == Y.AutomaticOnlyWhenFetchExecuted && !o ? (e.publishEvent(k.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" }) : (e.publishEvent(k.refreshTokensAsync_begin, { tryNumber: t }), await p());
|
|
1040
1046
|
default: {
|
|
1041
|
-
if (_.token_automatic_renew_mode ==
|
|
1047
|
+
if (_.token_automatic_renew_mode == Y.AutomaticOnlyWhenFetchExecuted && P.FORCE_REFRESH !== g)
|
|
1042
1048
|
return e.publishEvent(k.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" };
|
|
1043
1049
|
if (e.publishEvent(k.refreshTokensAsync_begin, {
|
|
1044
1050
|
refreshToken: y.refreshToken,
|
|
@@ -1065,7 +1071,7 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1065
1071
|
N,
|
|
1066
1072
|
"POST"
|
|
1067
1073
|
));
|
|
1068
|
-
const b = await
|
|
1074
|
+
const b = await mn(e.getFetch())(
|
|
1069
1075
|
N,
|
|
1070
1076
|
$,
|
|
1071
1077
|
w,
|
|
@@ -1075,7 +1081,7 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1075
1081
|
d
|
|
1076
1082
|
);
|
|
1077
1083
|
if (b.success) {
|
|
1078
|
-
const { isValid: K, reason: U } =
|
|
1084
|
+
const { isValid: K, reason: U } = xe(
|
|
1079
1085
|
b.data,
|
|
1080
1086
|
A.nonce,
|
|
1081
1087
|
E
|
|
@@ -1105,7 +1111,7 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1105
1111
|
tokenResponse: b
|
|
1106
1112
|
}), b.status >= 400 && b.status < 500 ? (n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
1107
1113
|
message: `session lost: ${b.status}`
|
|
1108
|
-
}), { tokens: null, status: "SESSION_LOST" }) : await
|
|
1114
|
+
}), { tokens: null, status: "SESSION_LOST" }) : await ee(e)(
|
|
1109
1115
|
n,
|
|
1110
1116
|
l,
|
|
1111
1117
|
h,
|
|
@@ -1122,7 +1128,7 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1122
1128
|
exception: g.message
|
|
1123
1129
|
}), new Promise((y, A) => {
|
|
1124
1130
|
setTimeout(() => {
|
|
1125
|
-
|
|
1131
|
+
ee(e)(
|
|
1126
1132
|
n,
|
|
1127
1133
|
l,
|
|
1128
1134
|
h,
|
|
@@ -1133,7 +1139,7 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1133
1139
|
}, 1e3);
|
|
1134
1140
|
});
|
|
1135
1141
|
}
|
|
1136
|
-
},
|
|
1142
|
+
}, pe = (e, n, t) => (s = null, o = null, i = null) => {
|
|
1137
1143
|
if (!n.silent_redirect_uri || !n.silent_login_uri)
|
|
1138
1144
|
return Promise.resolve(null);
|
|
1139
1145
|
try {
|
|
@@ -1177,9 +1183,9 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1177
1183
|
} catch (r) {
|
|
1178
1184
|
throw t(k.silentLoginAsync_error, r), r;
|
|
1179
1185
|
}
|
|
1180
|
-
},
|
|
1186
|
+
}, An = (e, n, t, s, o) => (i = null, r = void 0) => {
|
|
1181
1187
|
i = { ...i };
|
|
1182
|
-
const a = (f, u, l) =>
|
|
1188
|
+
const a = (f, u, l) => pe(n, t, s.bind(o))(
|
|
1183
1189
|
f,
|
|
1184
1190
|
u,
|
|
1185
1191
|
l
|
|
@@ -1198,13 +1204,13 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1198
1204
|
r
|
|
1199
1205
|
);
|
|
1200
1206
|
if (l)
|
|
1201
|
-
return o.tokens = l.tokens, s(k.token_acquired, {}), o.timeoutId =
|
|
1207
|
+
return o.tokens = l.tokens, s(k.token_acquired, {}), o.timeoutId = z(o, o.tokens.expiresAt, i, r), {};
|
|
1202
1208
|
} catch (u) {
|
|
1203
1209
|
return u;
|
|
1204
1210
|
}
|
|
1205
1211
|
})();
|
|
1206
|
-
},
|
|
1207
|
-
const a = (c, f = void 0, u = void 0) =>
|
|
1212
|
+
}, Sn = (e, n, t) => (s, o, i, r = !1) => {
|
|
1213
|
+
const a = (c, f = void 0, u = void 0) => pe(e.configurationName, t, e.publishEvent.bind(e))(
|
|
1208
1214
|
c,
|
|
1209
1215
|
f,
|
|
1210
1216
|
u
|
|
@@ -1248,7 +1254,7 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1248
1254
|
await p.logoutOtherTabAsync(t.client_id, _.sub);
|
|
1249
1255
|
});
|
|
1250
1256
|
};
|
|
1251
|
-
e.checkSessionIFrame = new
|
|
1257
|
+
e.checkSessionIFrame = new Me(
|
|
1252
1258
|
u,
|
|
1253
1259
|
o,
|
|
1254
1260
|
s
|
|
@@ -1260,7 +1266,7 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1260
1266
|
} else
|
|
1261
1267
|
c(null);
|
|
1262
1268
|
});
|
|
1263
|
-
},
|
|
1269
|
+
}, Tn = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), vn = (e) => {
|
|
1264
1270
|
const n = e.appVersion, t = e.userAgent, s = "-";
|
|
1265
1271
|
let o = s;
|
|
1266
1272
|
const i = [
|
|
@@ -1320,7 +1326,7 @@ const X = (e, n, t = null, s = null) => {
|
|
|
1320
1326
|
osVersion: r
|
|
1321
1327
|
};
|
|
1322
1328
|
};
|
|
1323
|
-
function
|
|
1329
|
+
function En() {
|
|
1324
1330
|
const e = navigator.userAgent;
|
|
1325
1331
|
let n, t = e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
1326
1332
|
if (/trident/i.test(t[1]))
|
|
@@ -1338,13 +1344,13 @@ function vn() {
|
|
|
1338
1344
|
version: t[1]
|
|
1339
1345
|
};
|
|
1340
1346
|
}
|
|
1341
|
-
const
|
|
1342
|
-
const { name: e, version: n } =
|
|
1347
|
+
const On = () => {
|
|
1348
|
+
const { name: e, version: n } = En();
|
|
1343
1349
|
if (e === "chrome" && parseInt(n) <= 70 || e === "opera" && (!n || parseInt(n.split(".")[0]) < 80) || e === "ie")
|
|
1344
1350
|
return !1;
|
|
1345
|
-
const t =
|
|
1346
|
-
return !
|
|
1347
|
-
},
|
|
1351
|
+
const t = vn(navigator);
|
|
1352
|
+
return !Tn(t);
|
|
1353
|
+
}, bn = async (e) => {
|
|
1348
1354
|
let n;
|
|
1349
1355
|
if (e.tokens != null)
|
|
1350
1356
|
return !1;
|
|
@@ -1363,7 +1369,7 @@ const En = () => {
|
|
|
1363
1369
|
if (o) {
|
|
1364
1370
|
n.startKeepAliveServiceWorker(), e.tokens = o;
|
|
1365
1371
|
const i = n.getLoginParams(e.configurationName);
|
|
1366
|
-
e.timeoutId =
|
|
1372
|
+
e.timeoutId = z(
|
|
1367
1373
|
e,
|
|
1368
1374
|
e.tokens.expiresAt,
|
|
1369
1375
|
i.extras,
|
|
@@ -1393,9 +1399,9 @@ const En = () => {
|
|
|
1393
1399
|
t.login_state_storage ?? t.storage ?? sessionStorage
|
|
1394
1400
|
), { tokens: i } = await o.initAsync();
|
|
1395
1401
|
if (i) {
|
|
1396
|
-
e.tokens =
|
|
1402
|
+
e.tokens = ge(i, null, t.token_renew_mode);
|
|
1397
1403
|
const r = o.getLoginParams();
|
|
1398
|
-
e.timeoutId =
|
|
1404
|
+
e.timeoutId = z(
|
|
1399
1405
|
e,
|
|
1400
1406
|
e.tokens.expiresAt,
|
|
1401
1407
|
r.extras,
|
|
@@ -1422,7 +1428,7 @@ const En = () => {
|
|
|
1422
1428
|
"tokens inside ServiceWorker are invalid"
|
|
1423
1429
|
), !1;
|
|
1424
1430
|
}
|
|
1425
|
-
},
|
|
1431
|
+
}, Ve = (e) => {
|
|
1426
1432
|
const n = e.match(
|
|
1427
1433
|
// eslint-disable-next-line no-useless-escape
|
|
1428
1434
|
/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/
|
|
@@ -1444,34 +1450,34 @@ const En = () => {
|
|
|
1444
1450
|
search: t,
|
|
1445
1451
|
hash: s
|
|
1446
1452
|
};
|
|
1447
|
-
},
|
|
1448
|
-
const n =
|
|
1453
|
+
}, Un = (e) => {
|
|
1454
|
+
const n = Ve(e);
|
|
1449
1455
|
let { path: t } = n;
|
|
1450
1456
|
t.endsWith("/") && (t = t.slice(0, -1));
|
|
1451
1457
|
let { hash: s } = n;
|
|
1452
1458
|
return s === "#_=_" && (s = ""), s && (t += s), t;
|
|
1453
|
-
},
|
|
1454
|
-
const n =
|
|
1455
|
-
return
|
|
1456
|
-
},
|
|
1459
|
+
}, fe = (e) => {
|
|
1460
|
+
const n = Ve(e), { search: t } = n;
|
|
1461
|
+
return Pn(t);
|
|
1462
|
+
}, Pn = (e) => {
|
|
1457
1463
|
const n = {};
|
|
1458
1464
|
let t, s, o;
|
|
1459
1465
|
const i = e.split("&");
|
|
1460
1466
|
for (s = 0, o = i.length; s < o; s++)
|
|
1461
1467
|
t = i[s].split("="), n[decodeURIComponent(t[0])] = decodeURIComponent(t[1]);
|
|
1462
1468
|
return n;
|
|
1463
|
-
},
|
|
1469
|
+
}, In = (e, n, t, s, o) => (i = void 0, r = null, a = !1, c = void 0) => {
|
|
1464
1470
|
const f = r;
|
|
1465
1471
|
return r = { ...r }, (async () => {
|
|
1466
1472
|
const l = i || o.getPath();
|
|
1467
|
-
if ("state" in r || (r.state =
|
|
1473
|
+
if ("state" in r || (r.state = ue(16)), t(k.loginAsync_begin, {}), r)
|
|
1468
1474
|
for (const h of Object.keys(r))
|
|
1469
1475
|
h.endsWith(":token_request") && delete r[h];
|
|
1470
1476
|
try {
|
|
1471
1477
|
const h = a ? n.silent_redirect_uri : n.redirect_uri;
|
|
1472
1478
|
c || (c = n.scope);
|
|
1473
1479
|
const _ = n.extras ? { ...n.extras, ...r } : r;
|
|
1474
|
-
_.nonce || (_.nonce =
|
|
1480
|
+
_.nonce || (_.nonce = ue(12));
|
|
1475
1481
|
const m = { nonce: _.nonce }, p = await W(n, e), g = await s(
|
|
1476
1482
|
n.authority,
|
|
1477
1483
|
n.authority_configuration
|
|
@@ -1494,7 +1500,7 @@ const En = () => {
|
|
|
1494
1500
|
response_type: "code",
|
|
1495
1501
|
..._
|
|
1496
1502
|
};
|
|
1497
|
-
await
|
|
1503
|
+
await wn(y, o)(
|
|
1498
1504
|
g.authorizationEndpoint,
|
|
1499
1505
|
A
|
|
1500
1506
|
);
|
|
@@ -1502,13 +1508,13 @@ const En = () => {
|
|
|
1502
1508
|
throw t(k.loginAsync_error, h), h;
|
|
1503
1509
|
}
|
|
1504
1510
|
})();
|
|
1505
|
-
},
|
|
1511
|
+
}, Cn = (e) => async (n = !1) => {
|
|
1506
1512
|
try {
|
|
1507
1513
|
e.publishEvent(k.loginCallbackAsync_begin, {});
|
|
1508
1514
|
const t = e.configuration, s = t.client_id, o = n ? t.silent_redirect_uri : t.redirect_uri, i = t.authority, r = t.token_request_timeout, a = await e.initAsync(
|
|
1509
1515
|
i,
|
|
1510
1516
|
t.authority_configuration
|
|
1511
|
-
), c = e.location.getCurrentHref(), f =
|
|
1517
|
+
), c = e.location.getCurrentHref(), f = fe(c), u = f.session_state, l = await W(t, e.configurationName);
|
|
1512
1518
|
let h, _, m, p;
|
|
1513
1519
|
if (l)
|
|
1514
1520
|
await l.initAsync(a, "loginCallbackAsync", t), await l.setSessionStateAsync(u), _ = await l.getNonceAsync(), m = l.getLoginParams(), p = await l.getStateAsync(), l.startKeepAliveServiceWorker(), h = l;
|
|
@@ -1547,18 +1553,18 @@ const En = () => {
|
|
|
1547
1553
|
if (l)
|
|
1548
1554
|
T.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${e.configurationName}`;
|
|
1549
1555
|
else {
|
|
1550
|
-
const E = await
|
|
1556
|
+
const E = await _n(window)(
|
|
1551
1557
|
t.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm
|
|
1552
1558
|
);
|
|
1553
1559
|
await x(
|
|
1554
1560
|
e.configurationName,
|
|
1555
1561
|
t.storage,
|
|
1556
1562
|
t.login_state_storage ?? t.storage
|
|
1557
|
-
).setDemonstratingProofOfPossessionJwkAsync(E), T.DPoP = await
|
|
1563
|
+
).setDemonstratingProofOfPossessionJwkAsync(E), T.DPoP = await Re(window)(
|
|
1558
1564
|
t.demonstrating_proof_of_possession_configuration
|
|
1559
1565
|
)(E, "POST", A);
|
|
1560
1566
|
}
|
|
1561
|
-
const O = await
|
|
1567
|
+
const O = await pn(h)(
|
|
1562
1568
|
A,
|
|
1563
1569
|
{ ...g, ...y },
|
|
1564
1570
|
T,
|
|
@@ -1571,12 +1577,12 @@ const En = () => {
|
|
|
1571
1577
|
const C = O.data.tokens, w = O.data.demonstratingProofOfPossessionNonce;
|
|
1572
1578
|
if (O.data.state !== y.state)
|
|
1573
1579
|
throw new Error("state is not valid");
|
|
1574
|
-
const { isValid:
|
|
1580
|
+
const { isValid: G, reason: $ } = xe(
|
|
1575
1581
|
C,
|
|
1576
1582
|
_.nonce,
|
|
1577
1583
|
a
|
|
1578
1584
|
);
|
|
1579
|
-
if (!
|
|
1585
|
+
if (!G)
|
|
1580
1586
|
throw new Error(`Tokens are not OpenID valid, reason: ${$}`);
|
|
1581
1587
|
if (l) {
|
|
1582
1588
|
if (C.refreshToken && !C.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))
|
|
@@ -1613,10 +1619,10 @@ const En = () => {
|
|
|
1613
1619
|
} catch (t) {
|
|
1614
1620
|
throw console.error(t), e.publishEvent(k.loginCallbackAsync_error, t), t;
|
|
1615
1621
|
}
|
|
1616
|
-
},
|
|
1622
|
+
}, Ie = {
|
|
1617
1623
|
access_token: "access_token",
|
|
1618
1624
|
refresh_token: "refresh_token"
|
|
1619
|
-
},
|
|
1625
|
+
}, re = (e, n) => {
|
|
1620
1626
|
const t = {};
|
|
1621
1627
|
if (e) {
|
|
1622
1628
|
for (const [s, o] of Object.entries(e))
|
|
@@ -1627,7 +1633,7 @@ const En = () => {
|
|
|
1627
1633
|
return t;
|
|
1628
1634
|
}
|
|
1629
1635
|
return t;
|
|
1630
|
-
},
|
|
1636
|
+
}, Nn = (e) => {
|
|
1631
1637
|
const n = {};
|
|
1632
1638
|
if (e) {
|
|
1633
1639
|
for (const [t, s] of Object.entries(e))
|
|
@@ -1635,7 +1641,7 @@ const En = () => {
|
|
|
1635
1641
|
return n;
|
|
1636
1642
|
}
|
|
1637
1643
|
return n;
|
|
1638
|
-
},
|
|
1644
|
+
}, xn = (e) => async (n) => {
|
|
1639
1645
|
R.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
1640
1646
|
const t = await W(e.configuration, e.configurationName);
|
|
1641
1647
|
t ? await t.clearAsync(n) : await x(
|
|
@@ -1643,7 +1649,7 @@ const En = () => {
|
|
|
1643
1649
|
e.configuration.storage,
|
|
1644
1650
|
e.configuration.login_state_storage ?? e.configuration.storage
|
|
1645
1651
|
).clearAsync(n), e.tokens = null, e.userInfo = null;
|
|
1646
|
-
},
|
|
1652
|
+
}, Wn = (e, n, t, s, o) => async (i = void 0, r = null) => {
|
|
1647
1653
|
const a = e.configuration, c = await e.initAsync(
|
|
1648
1654
|
a.authority,
|
|
1649
1655
|
a.authority_configuration
|
|
@@ -1657,22 +1663,22 @@ const En = () => {
|
|
|
1657
1663
|
const y = c.revocationEndpoint;
|
|
1658
1664
|
if (y) {
|
|
1659
1665
|
const A = [], T = e.tokens ? e.tokens.accessToken : null;
|
|
1660
|
-
if (T && a.logout_tokens_to_invalidate.includes(
|
|
1661
|
-
const v =
|
|
1666
|
+
if (T && a.logout_tokens_to_invalidate.includes(Ie.access_token)) {
|
|
1667
|
+
const v = re(r, ":revoke_access_token"), C = be(t)(
|
|
1662
1668
|
y,
|
|
1663
1669
|
T,
|
|
1664
|
-
|
|
1670
|
+
_e.access_token,
|
|
1665
1671
|
a.client_id,
|
|
1666
1672
|
v
|
|
1667
1673
|
);
|
|
1668
1674
|
A.push(C);
|
|
1669
1675
|
}
|
|
1670
1676
|
const O = e.tokens ? e.tokens.refreshToken : null;
|
|
1671
|
-
if (O && a.logout_tokens_to_invalidate.includes(
|
|
1672
|
-
const v =
|
|
1677
|
+
if (O && a.logout_tokens_to_invalidate.includes(Ie.refresh_token)) {
|
|
1678
|
+
const v = re(r, ":revoke_refresh_token"), C = be(t)(
|
|
1673
1679
|
y,
|
|
1674
1680
|
O,
|
|
1675
|
-
|
|
1681
|
+
_e.refresh_token,
|
|
1676
1682
|
a.client_id,
|
|
1677
1683
|
v
|
|
1678
1684
|
);
|
|
@@ -1689,10 +1695,10 @@ const En = () => {
|
|
|
1689
1695
|
await e.destroyAsync("LOGGED_OUT");
|
|
1690
1696
|
for (const [, y] of Object.entries(n))
|
|
1691
1697
|
y !== e ? await e.logoutSameTabAsync(e.configuration.client_id, _) : e.publishEvent(k.logout_from_same_tab, {});
|
|
1692
|
-
const m =
|
|
1698
|
+
const m = re(r, ":oidc");
|
|
1693
1699
|
if (m && m.no_reload === "true")
|
|
1694
1700
|
return;
|
|
1695
|
-
const g =
|
|
1701
|
+
const g = Nn(r);
|
|
1696
1702
|
if (c.endSessionEndpoint) {
|
|
1697
1703
|
"id_token_hint" in g || (g.id_token_hint = h), !("post_logout_redirect_uri" in g) && i !== null && (g.post_logout_redirect_uri = l);
|
|
1698
1704
|
let y = "";
|
|
@@ -1701,7 +1707,7 @@ const En = () => {
|
|
|
1701
1707
|
o.open(`${c.endSessionEndpoint}${y}`);
|
|
1702
1708
|
} else
|
|
1703
1709
|
o.reload();
|
|
1704
|
-
},
|
|
1710
|
+
}, Fe = (e, n, t = !1) => async (...s) => {
|
|
1705
1711
|
const [o, i, ...r] = s, a = i ? { ...i } : { method: "GET" };
|
|
1706
1712
|
let c = new Headers();
|
|
1707
1713
|
a.headers && (c = a.headers instanceof Headers ? a.headers : new Headers(a.headers));
|
|
@@ -1712,7 +1718,7 @@ const En = () => {
|
|
|
1712
1718
|
refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
|
|
1713
1719
|
},
|
|
1714
1720
|
syncTokensInfoAsync: async () => {
|
|
1715
|
-
const { status: _ } = await
|
|
1721
|
+
const { status: _ } = await we(n)(
|
|
1716
1722
|
n.configuration,
|
|
1717
1723
|
n.configurationName,
|
|
1718
1724
|
n.tokens,
|
|
@@ -1721,7 +1727,7 @@ const En = () => {
|
|
|
1721
1727
|
return _;
|
|
1722
1728
|
},
|
|
1723
1729
|
renewTokensAsync: n.renewTokensAsync.bind(n)
|
|
1724
|
-
}, l = (await
|
|
1730
|
+
}, l = (await Ne(f))?.tokens?.accessToken;
|
|
1725
1731
|
if (c.has("Accept") || c.set("Accept", "application/json"), l) {
|
|
1726
1732
|
if (n.configuration.demonstrating_proof_of_possession && t) {
|
|
1727
1733
|
const _ = await n.generateDemonstrationOfProofOfPossessionAsync(
|
|
@@ -1736,7 +1742,7 @@ const En = () => {
|
|
|
1736
1742
|
}
|
|
1737
1743
|
const h = { ...a, headers: c };
|
|
1738
1744
|
return await e(o, h, ...r);
|
|
1739
|
-
},
|
|
1745
|
+
}, Ln = (e) => async (n = !1, t = !1) => {
|
|
1740
1746
|
if (e.userInfo != null && !n)
|
|
1741
1747
|
return e.userInfo;
|
|
1742
1748
|
const s = !n && e.configuration.storage?.getItem(`oidc.${e.configurationName}.userInfo`);
|
|
@@ -1746,49 +1752,49 @@ const En = () => {
|
|
|
1746
1752
|
o.authority,
|
|
1747
1753
|
o.authority_configuration
|
|
1748
1754
|
)).userInfoEndpoint, c = await (async () => {
|
|
1749
|
-
const u = await
|
|
1755
|
+
const u = await Fe(fetch, e, t)(r);
|
|
1750
1756
|
return u.status !== 200 ? null : u.json();
|
|
1751
1757
|
})();
|
|
1752
1758
|
return e.userInfo = c, c && e.configuration.storage?.setItem(
|
|
1753
1759
|
`oidc.${e.configurationName}.userInfo`,
|
|
1754
1760
|
JSON.stringify(c)
|
|
1755
1761
|
), c;
|
|
1756
|
-
},
|
|
1757
|
-
class
|
|
1762
|
+
}, Dn = () => fetch;
|
|
1763
|
+
class de {
|
|
1758
1764
|
constructor(n) {
|
|
1759
1765
|
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;
|
|
1760
1766
|
}
|
|
1761
1767
|
}
|
|
1762
|
-
const V = {},
|
|
1768
|
+
const V = {}, Rn = (e, n = new ne()) => (t, s = "default") => (V[s] || (V[s] = new D(t, s, e, n)), V[s]), $n = async (e) => {
|
|
1763
1769
|
const { parsedTokens: n, callbackPath: t, extras: s, scope: o } = await e.loginCallbackAsync();
|
|
1764
|
-
return e.timeoutId =
|
|
1765
|
-
},
|
|
1766
|
-
constructor(n, t = "default", s, o = new
|
|
1770
|
+
return e.timeoutId = z(e, n.expiresAt, s, o), { callbackPath: t };
|
|
1771
|
+
}, Kn = (e) => Math.floor(Math.random() * e), q = class q {
|
|
1772
|
+
constructor(n, t = "default", s, o = new ne()) {
|
|
1767
1773
|
this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.logoutPromise = null;
|
|
1768
1774
|
let i = n.silent_login_uri;
|
|
1769
1775
|
n.silent_redirect_uri && !n.silent_login_uri && (i = `${n.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
|
|
1770
1776
|
let r = n.refresh_time_before_tokens_expiration_in_second ?? 120;
|
|
1771
|
-
r > 60 && (r = r - Math.floor(Math.random() * 40)), this.location = o ?? new
|
|
1777
|
+
r > 60 && (r = r - Math.floor(Math.random() * 40)), this.location = o ?? new ne(), this.configuration = {
|
|
1772
1778
|
...n,
|
|
1773
1779
|
silent_login_uri: i,
|
|
1774
|
-
token_automatic_renew_mode: n.token_automatic_renew_mode ??
|
|
1780
|
+
token_automatic_renew_mode: n.token_automatic_renew_mode ?? Y.AutomaticBeforeTokenExpiration,
|
|
1775
1781
|
monitor_session: n.monitor_session ?? !1,
|
|
1776
1782
|
refresh_time_before_tokens_expiration_in_second: r,
|
|
1777
1783
|
silent_login_timeout: n.silent_login_timeout ?? 12e3,
|
|
1778
|
-
token_renew_mode: n.token_renew_mode ??
|
|
1784
|
+
token_renew_mode: n.token_renew_mode ?? ae.access_token_or_id_token_invalid,
|
|
1779
1785
|
demonstrating_proof_of_possession: n.demonstrating_proof_of_possession ?? !1,
|
|
1780
1786
|
authority_timeout_wellknowurl_in_millisecond: n.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
1781
1787
|
logout_tokens_to_invalidate: n.logout_tokens_to_invalidate ?? [
|
|
1782
1788
|
"access_token",
|
|
1783
1789
|
"refresh_token"
|
|
1784
1790
|
],
|
|
1785
|
-
service_worker_activate: n.service_worker_activate ??
|
|
1786
|
-
demonstrating_proof_of_possession_configuration: n.demonstrating_proof_of_possession_configuration ??
|
|
1791
|
+
service_worker_activate: n.service_worker_activate ?? On,
|
|
1792
|
+
demonstrating_proof_of_possession_configuration: n.demonstrating_proof_of_possession_configuration ?? tn,
|
|
1787
1793
|
preload_user_info: n.preload_user_info ?? !1
|
|
1788
|
-
}, this.getFetch = s ??
|
|
1794
|
+
}, this.getFetch = s ?? Dn, this.configurationName = t, this.tokens = null, this.userInfo = null, this.events = [], this.timeoutId = null, this.loginCallbackWithAutoTokensRenewAsync.bind(this), this.initAsync.bind(this), this.loginCallbackAsync.bind(this), this.subscribeEvents.bind(this), this.removeEventSubscription.bind(this), this.publishEvent.bind(this), this.destroyAsync.bind(this), this.logoutAsync.bind(this), this.renewTokensAsync.bind(this), this.initAsync(this.configuration.authority, this.configuration.authority_configuration);
|
|
1789
1795
|
}
|
|
1790
1796
|
subscribeEvents(n) {
|
|
1791
|
-
const t =
|
|
1797
|
+
const t = Kn(9999999999999).toString();
|
|
1792
1798
|
return this.events.push({ id: t, func: n }), t;
|
|
1793
1799
|
}
|
|
1794
1800
|
removeEventSubscription(n) {
|
|
@@ -1809,7 +1815,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1809
1815
|
}
|
|
1810
1816
|
_silentLoginCallbackFromIFrame() {
|
|
1811
1817
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1812
|
-
const n = this.location, t =
|
|
1818
|
+
const n = this.location, t = fe(n.getCurrentHref());
|
|
1813
1819
|
window.parent.postMessage(
|
|
1814
1820
|
`${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState: t.session_state })}`,
|
|
1815
1821
|
n.getOrigin()
|
|
@@ -1818,7 +1824,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1818
1824
|
}
|
|
1819
1825
|
_silentLoginErrorCallbackFromIFrame(n = null) {
|
|
1820
1826
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1821
|
-
const t = this.location, s =
|
|
1827
|
+
const t = this.location, s = fe(t.getCurrentHref());
|
|
1822
1828
|
s.error ? window.parent.postMessage(
|
|
1823
1829
|
`${this.configurationName}_oidc_error:${JSON.stringify({ error: s.error })}`,
|
|
1824
1830
|
t.getOrigin()
|
|
@@ -1840,7 +1846,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1840
1846
|
return this.initPromise;
|
|
1841
1847
|
const s = async () => {
|
|
1842
1848
|
if (t != null)
|
|
1843
|
-
return new
|
|
1849
|
+
return new de({
|
|
1844
1850
|
authorization_endpoint: t.authorization_endpoint,
|
|
1845
1851
|
end_session_endpoint: t.end_session_endpoint,
|
|
1846
1852
|
revocation_endpoint: t.revocation_endpoint,
|
|
@@ -1850,7 +1856,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1850
1856
|
issuer: t.issuer
|
|
1851
1857
|
});
|
|
1852
1858
|
const i = await W(this.configuration, this.configurationName) ? this.configuration.storage || window.sessionStorage : this.configuration.storage;
|
|
1853
|
-
return await
|
|
1859
|
+
return await kn(this.getFetch())(
|
|
1854
1860
|
n,
|
|
1855
1861
|
this.configuration.authority_time_cache_wellknowurl_in_second ?? 3600,
|
|
1856
1862
|
i,
|
|
@@ -1862,12 +1868,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1862
1868
|
});
|
|
1863
1869
|
}
|
|
1864
1870
|
async tryKeepExistingSessionAsync() {
|
|
1865
|
-
return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise =
|
|
1871
|
+
return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise = bn(this), this.tryKeepExistingSessionPromise.finally(() => {
|
|
1866
1872
|
this.tryKeepExistingSessionPromise = null;
|
|
1867
1873
|
}));
|
|
1868
1874
|
}
|
|
1869
1875
|
async startCheckSessionAsync(n, t, s, o = !1) {
|
|
1870
|
-
await
|
|
1876
|
+
await Sn(this, V, this.configuration)(
|
|
1871
1877
|
n,
|
|
1872
1878
|
t,
|
|
1873
1879
|
s,
|
|
@@ -1875,13 +1881,13 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1875
1881
|
);
|
|
1876
1882
|
}
|
|
1877
1883
|
async loginAsync(n = void 0, t = null, s = !1, o = void 0, i = !1) {
|
|
1878
|
-
return this.logoutPromise && await this.logoutPromise, this.loginPromise !== null ? this.loginPromise : (i ? this.loginPromise =
|
|
1884
|
+
return this.logoutPromise && await this.logoutPromise, this.loginPromise !== null ? this.loginPromise : (i ? this.loginPromise = An(
|
|
1879
1885
|
window,
|
|
1880
1886
|
this.configurationName,
|
|
1881
1887
|
this.configuration,
|
|
1882
1888
|
this.publishEvent.bind(this),
|
|
1883
1889
|
this
|
|
1884
|
-
)(t, o) : this.loginPromise =
|
|
1890
|
+
)(t, o) : this.loginPromise = In(
|
|
1885
1891
|
this.configurationName,
|
|
1886
1892
|
this.configuration,
|
|
1887
1893
|
this.publishEvent.bind(this),
|
|
@@ -1895,12 +1901,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1895
1901
|
if (this.loginCallbackPromise !== null)
|
|
1896
1902
|
return this.loginCallbackPromise;
|
|
1897
1903
|
const t = async () => {
|
|
1898
|
-
const s = await
|
|
1904
|
+
const s = await Cn(this)(n), o = s.tokens;
|
|
1899
1905
|
return this.tokens = o, await W(this.configuration, this.configurationName) || x(
|
|
1900
1906
|
this.configurationName,
|
|
1901
1907
|
this.configuration.storage,
|
|
1902
1908
|
this.configuration.login_state_storage ?? this.configuration.storage
|
|
1903
|
-
).setTokens(o), this.publishEvent(
|
|
1909
|
+
).setTokens(o), this.publishEvent(q.eventNames.token_acquired, o), this.configuration.preload_user_info && await this.userInfoAsync(), {
|
|
1904
1910
|
parsedTokens: o,
|
|
1905
1911
|
state: s.state,
|
|
1906
1912
|
callbackPath: s.callbackPath,
|
|
@@ -1914,27 +1920,27 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1914
1920
|
}
|
|
1915
1921
|
async generateDemonstrationOfProofOfPossessionAsync(n, t, s, o = {}) {
|
|
1916
1922
|
const i = this.configuration, r = {
|
|
1917
|
-
ath: await
|
|
1923
|
+
ath: await Ke(n),
|
|
1918
1924
|
...o
|
|
1919
1925
|
};
|
|
1920
1926
|
if (await W(i, this.configurationName))
|
|
1921
|
-
return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${
|
|
1927
|
+
return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${ye(this.configurationName)}`;
|
|
1922
1928
|
const c = x(
|
|
1923
1929
|
this.configurationName,
|
|
1924
1930
|
i.storage,
|
|
1925
1931
|
i.login_state_storage ?? i.storage
|
|
1926
1932
|
), f = await c.getDemonstratingProofOfPossessionJwkAsync(), u = c.getDemonstratingProofOfPossessionNonce();
|
|
1927
|
-
return u && (r.nonce = u), await
|
|
1933
|
+
return u && (r.nonce = u), await Re(window)(
|
|
1928
1934
|
i.demonstrating_proof_of_possession_configuration
|
|
1929
1935
|
)(f, s, t, r);
|
|
1930
1936
|
}
|
|
1931
1937
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1932
|
-
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1938
|
+
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise = $n(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
|
|
1933
1939
|
this.loginCallbackWithAutoTokensRenewPromise = null;
|
|
1934
1940
|
}));
|
|
1935
1941
|
}
|
|
1936
1942
|
userInfoAsync(n = !1, t = !1) {
|
|
1937
|
-
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise =
|
|
1943
|
+
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise = Ln(this)(n, t), this.userInfoPromise.finally(() => {
|
|
1938
1944
|
this.userInfoPromise = null;
|
|
1939
1945
|
}));
|
|
1940
1946
|
}
|
|
@@ -1942,12 +1948,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1942
1948
|
if (this.renewTokensPromise !== null)
|
|
1943
1949
|
return this.renewTokensPromise;
|
|
1944
1950
|
if (this.timeoutId)
|
|
1945
|
-
return R.clearTimeout(this.timeoutId), this.renewTokensPromise =
|
|
1951
|
+
return R.clearTimeout(this.timeoutId), this.renewTokensPromise = Ue(this, !0, n, t), this.renewTokensPromise.finally(() => {
|
|
1946
1952
|
this.renewTokensPromise = null;
|
|
1947
1953
|
});
|
|
1948
1954
|
}
|
|
1949
1955
|
async destroyAsync(n) {
|
|
1950
|
-
return await
|
|
1956
|
+
return await xn(this)(n);
|
|
1951
1957
|
}
|
|
1952
1958
|
async logoutSameTabAsync(n, t) {
|
|
1953
1959
|
this.configuration.monitor_session && this.configuration.client_id === n && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(k.logout_from_same_tab, { mmessage: "SessionMonitor", sub: t }));
|
|
@@ -1956,7 +1962,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1956
1962
|
this.configuration.monitor_session && this.configuration.client_id === n && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(k.logout_from_another_tab, { message: "SessionMonitor", sub: t }));
|
|
1957
1963
|
}
|
|
1958
1964
|
async logoutAsync(n = void 0, t = null) {
|
|
1959
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1965
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = Wn(
|
|
1960
1966
|
this,
|
|
1961
1967
|
V,
|
|
1962
1968
|
this.getFetch(),
|
|
@@ -1967,9 +1973,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1967
1973
|
}));
|
|
1968
1974
|
}
|
|
1969
1975
|
};
|
|
1970
|
-
|
|
1971
|
-
let D =
|
|
1972
|
-
const
|
|
1976
|
+
q.getOrCreate = (n, t) => (s, o = "default") => Rn(n, t)(s, o), q.eventNames = k;
|
|
1977
|
+
let D = q;
|
|
1978
|
+
const H = class H {
|
|
1973
1979
|
constructor(n) {
|
|
1974
1980
|
this._oidc = n;
|
|
1975
1981
|
}
|
|
@@ -1983,7 +1989,7 @@ const J = class J {
|
|
|
1983
1989
|
this._oidc.publishEvent(n, t);
|
|
1984
1990
|
}
|
|
1985
1991
|
static get(n = "default") {
|
|
1986
|
-
return new
|
|
1992
|
+
return new H(D.get(n));
|
|
1987
1993
|
}
|
|
1988
1994
|
tryKeepExistingSessionAsync() {
|
|
1989
1995
|
return this._oidc.tryKeepExistingSessionAsync();
|
|
@@ -2025,7 +2031,7 @@ const J = class J {
|
|
|
2025
2031
|
refresh_time_before_tokens_expiration_in_second: s.configuration.refresh_time_before_tokens_expiration_in_second
|
|
2026
2032
|
},
|
|
2027
2033
|
syncTokensInfoAsync: async () => {
|
|
2028
|
-
const { status: i } = await
|
|
2034
|
+
const { status: i } = await we(s)(
|
|
2029
2035
|
s.configuration,
|
|
2030
2036
|
s.configurationName,
|
|
2031
2037
|
s.tokens,
|
|
@@ -2035,10 +2041,10 @@ const J = class J {
|
|
|
2035
2041
|
},
|
|
2036
2042
|
renewTokensAsync: s.renewTokensAsync.bind(s)
|
|
2037
2043
|
};
|
|
2038
|
-
return
|
|
2044
|
+
return Ne(o, n, t);
|
|
2039
2045
|
}
|
|
2040
2046
|
fetchWithTokens(n, t = !1) {
|
|
2041
|
-
return
|
|
2047
|
+
return Fe(n, this._oidc, t);
|
|
2042
2048
|
}
|
|
2043
2049
|
async userInfoAsync(n = !1, t = !1) {
|
|
2044
2050
|
return this._oidc.userInfoAsync(n, t);
|
|
@@ -2047,14 +2053,14 @@ const J = class J {
|
|
|
2047
2053
|
return this._oidc.userInfo;
|
|
2048
2054
|
}
|
|
2049
2055
|
};
|
|
2050
|
-
|
|
2051
|
-
let
|
|
2056
|
+
H.getOrCreate = (n, t = new ne()) => (s, o = "default") => new H(D.getOrCreate(n, t)(s, o)), H.eventNames = D.eventNames;
|
|
2057
|
+
let Ce = H;
|
|
2052
2058
|
export {
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2059
|
+
Ce as OidcClient,
|
|
2060
|
+
ne as OidcLocation,
|
|
2061
|
+
Y as TokenAutomaticRenewMode,
|
|
2062
|
+
ae as TokenRenewMode,
|
|
2063
|
+
Dn as getFetchDefault,
|
|
2064
|
+
fe as getParseQueryStringFromLocation,
|
|
2065
|
+
Un as getPath
|
|
2060
2066
|
};
|