@axa-fr/oidc-client 7.27.0 → 7.27.1
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 +490 -431
- 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 +168 -33
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class ee {
|
|
2
2
|
open(n) {
|
|
3
3
|
window.location.href = n;
|
|
4
4
|
}
|
|
@@ -16,10 +16,10 @@ class Q {
|
|
|
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 Ae = 2e3, F = console;
|
|
20
|
+
class Fe {
|
|
21
|
+
constructor(n, t, s, o = Ae, i = !0) {
|
|
22
|
+
this._callback = n, this._client_id = t, this._url = s, this._interval = o || Ae, 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
|
}
|
|
@@ -31,10 +31,10 @@ class $e {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
_message(n) {
|
|
34
|
-
n.origin === this._frame_origin && n.source === this._frame.contentWindow && (n.data === "error" ? (
|
|
34
|
+
n.origin === this._frame_origin && n.source === this._frame.contentWindow && (n.data === "error" ? (F.error("CheckSessionIFrame: error message from check session op iframe"), this._stopOnError && this.stop()) : n.data === "changed" ? (F.debug(n), F.debug("CheckSessionIFrame: changed message from check session op iframe"), this.stop(), this._callback()) : F.debug("CheckSessionIFrame: " + n.data + " message from check session op iframe"));
|
|
35
35
|
}
|
|
36
36
|
start(n) {
|
|
37
|
-
|
|
37
|
+
F.debug("CheckSessionIFrame.start :" + n), this.stop();
|
|
38
38
|
const t = () => {
|
|
39
39
|
this._frame.contentWindow.postMessage(
|
|
40
40
|
this._client_id + " " + n,
|
|
@@ -44,7 +44,7 @@ class $e {
|
|
|
44
44
|
t(), this._timer = window.setInterval(t, this._interval);
|
|
45
45
|
}
|
|
46
46
|
stop() {
|
|
47
|
-
this._timer && (
|
|
47
|
+
this._timer && (F.debug("CheckSessionIFrame.stop"), window.clearInterval(this._timer), this._timer = null);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
const k = {
|
|
@@ -76,7 +76,7 @@ const k = {
|
|
|
76
76
|
syncTokensAsync_end: "syncTokensAsync_end",
|
|
77
77
|
syncTokensAsync_error: "syncTokensAsync_error",
|
|
78
78
|
tokensInvalidAndWaitingActionsToRefresh: "tokensInvalidAndWaitingActionsToRefresh"
|
|
79
|
-
},
|
|
79
|
+
}, x = (e, n = sessionStorage, t) => {
|
|
80
80
|
const s = t ?? n, o = (w) => (n[`oidc.${e}`] = JSON.stringify({ tokens: null, status: w }), delete n[`oidc.${e}.userInfo`], t && t !== n && (delete s[`oidc.login.${e}`], delete s[`oidc.state.${e}`], delete s[`oidc.code_verifier.${e}`], delete s[`oidc.nonce.${e}`]), Promise.resolve()), i = async () => {
|
|
81
81
|
if (!n[`oidc.${e}`])
|
|
82
82
|
return n[`oidc.${e}`] = JSON.stringify({ tokens: null, status: null }), { tokens: null, status: null };
|
|
@@ -125,40 +125,40 @@ const k = {
|
|
|
125
125
|
getDemonstratingProofOfPossessionJwkAsync: l
|
|
126
126
|
};
|
|
127
127
|
};
|
|
128
|
-
var
|
|
129
|
-
const
|
|
128
|
+
var q = /* @__PURE__ */ ((e) => (e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e))(q || {});
|
|
129
|
+
const Me = (e) => decodeURIComponent(
|
|
130
130
|
Array.prototype.map.call(atob(e), (n) => "%" + ("00" + n.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
131
|
-
),
|
|
131
|
+
), Be = (e) => JSON.parse(Me(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), Se = (e) => {
|
|
132
132
|
try {
|
|
133
|
-
return e &&
|
|
133
|
+
return e && Je(e, ".") === 2 ? Be(e.split(".")[1]) : null;
|
|
134
134
|
} catch (n) {
|
|
135
135
|
console.warn(n);
|
|
136
136
|
}
|
|
137
137
|
return null;
|
|
138
|
-
},
|
|
138
|
+
}, Je = (e, n) => e.split(n).length - 1, re = {
|
|
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 He(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 de = (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 = Se(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 : Se(i), a = r && r.exp ? r.exp : Number.MAX_VALUE, c = s && s.exp ? s.exp : e.issuedAt + o;
|
|
159
|
+
e.issuedAt = He(e, s, r);
|
|
160
160
|
let f;
|
|
161
|
-
e.expiresAt ? f = e.expiresAt : t ===
|
|
161
|
+
e.expiresAt ? f = e.expiresAt : t === re.access_token_invalid ? f = c : t === re.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 ue = (e, n = null, t) => {
|
|
|
171
171
|
return { ...u, refreshToken: l };
|
|
172
172
|
}
|
|
173
173
|
return u;
|
|
174
|
-
},
|
|
174
|
+
}, ge = (e, n, t) => {
|
|
175
175
|
if (!e)
|
|
176
176
|
return null;
|
|
177
177
|
if (!e.issued_at) {
|
|
@@ -186,30 +186,30 @@ const ue = (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), de(s, n, t);
|
|
190
|
+
}, G = (e, n) => {
|
|
191
191
|
const t = (/* @__PURE__ */ new Date()).getTime() / 1e3, s = n - t;
|
|
192
192
|
return Math.round(s - e);
|
|
193
|
-
},
|
|
193
|
+
}, Ge = (e, n = 0) => e ? G(n, e.expiresAt) > 0 : !1, Ce = async (e, n = 200, t = 50) => {
|
|
194
194
|
let s = t, o = await e.syncTokensInfoAsync();
|
|
195
195
|
for (; [
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
P.REQUIRE_SYNC_TOKENS,
|
|
197
|
+
P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
|
|
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 == q.AutomaticOnlyWhenFetchExecuted) {
|
|
201
201
|
await e.renewTokensAsync({});
|
|
202
202
|
break;
|
|
203
203
|
} else
|
|
204
|
-
await
|
|
204
|
+
await Y({ milliseconds: n });
|
|
205
205
|
s = s - 1, o = await e.syncTokensInfoAsync();
|
|
206
206
|
}
|
|
207
207
|
return {
|
|
208
|
-
isTokensValid:
|
|
208
|
+
isTokensValid: Ge(e.getTokens()),
|
|
209
209
|
tokens: e.getTokens(),
|
|
210
210
|
numberWaited: s - t
|
|
211
211
|
};
|
|
212
|
-
},
|
|
212
|
+
}, Ne = (e, n, t) => {
|
|
213
213
|
if (e.idTokenPayload) {
|
|
214
214
|
const s = e.idTokenPayload;
|
|
215
215
|
if (t.issuer !== s.iss)
|
|
@@ -236,7 +236,7 @@ const ue = (e, n = null, t) => {
|
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
238
|
return { isValid: !0, reason: "" };
|
|
239
|
-
},
|
|
239
|
+
}, R = (function() {
|
|
240
240
|
const e = typeof window > "u" ? global : window;
|
|
241
241
|
return {
|
|
242
242
|
setTimeout: setTimeout.bind(e),
|
|
@@ -244,32 +244,32 @@ const ue = (e, n = null, t) => {
|
|
|
244
244
|
setInterval: setInterval.bind(e),
|
|
245
245
|
clearInterval: clearInterval.bind(e)
|
|
246
246
|
};
|
|
247
|
-
})(),
|
|
248
|
-
let
|
|
249
|
-
const
|
|
247
|
+
})(), se = "7.27.1";
|
|
248
|
+
let Te = null, ne;
|
|
249
|
+
const Y = ({ milliseconds: e }) => new Promise((n) => R.setTimeout(n, e)), xe = (e = "/") => {
|
|
250
250
|
try {
|
|
251
|
-
|
|
251
|
+
ne = new AbortController(), fetch(
|
|
252
252
|
`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`,
|
|
253
|
-
{ signal:
|
|
253
|
+
{ signal: ne.signal }
|
|
254
254
|
).catch((s) => {
|
|
255
255
|
console.log(s);
|
|
256
|
-
}),
|
|
257
|
-
() =>
|
|
256
|
+
}), Y({ milliseconds: 150 * 1e3 }).then(
|
|
257
|
+
() => xe(e)
|
|
258
258
|
);
|
|
259
259
|
} catch (n) {
|
|
260
260
|
console.log(n);
|
|
261
261
|
}
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
},
|
|
262
|
+
}, Q = () => {
|
|
263
|
+
ne && ne.abort();
|
|
264
|
+
}, he = (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
|
+
}, je = 5e3, qe = (e) => navigator.serviceWorker.controller ?? e.active ?? e.waiting ?? e.installing ?? null, I = (e, n) => (t) => {
|
|
270
|
+
const s = n?.timeoutMs ?? je;
|
|
271
271
|
return new Promise((o, i) => {
|
|
272
|
-
const r =
|
|
272
|
+
const r = qe(e);
|
|
273
273
|
if (!r) {
|
|
274
274
|
i(
|
|
275
275
|
new Error(
|
|
@@ -282,12 +282,12 @@ const ne = ({ milliseconds: e }) => new Promise((n) => $.setTimeout(n, e)), Oe =
|
|
|
282
282
|
let c = null;
|
|
283
283
|
const f = () => {
|
|
284
284
|
try {
|
|
285
|
-
c != null && (
|
|
285
|
+
c != null && (R.clearTimeout(c), c = null), a.port1.onmessage = null, a.port1.close(), a.port2.close();
|
|
286
286
|
} catch (u) {
|
|
287
287
|
console.error(u);
|
|
288
288
|
}
|
|
289
289
|
};
|
|
290
|
-
c =
|
|
290
|
+
c = R.setTimeout(() => {
|
|
291
291
|
f(), i(
|
|
292
292
|
new Error(`Service worker did not respond within ${s}ms (type=${t?.type})`)
|
|
293
293
|
);
|
|
@@ -296,116 +296,175 @@ const ne = ({ milliseconds: e }) => new Promise((n) => $.setTimeout(n, e)), Oe =
|
|
|
296
296
|
};
|
|
297
297
|
try {
|
|
298
298
|
const u = t?.configurationName;
|
|
299
|
-
r.postMessage({ ...t, tabId:
|
|
299
|
+
r.postMessage({ ...t, tabId: he(u ?? "default") }, [
|
|
300
300
|
a.port2
|
|
301
301
|
]);
|
|
302
302
|
} catch (u) {
|
|
303
303
|
f(), i(u);
|
|
304
304
|
}
|
|
305
305
|
});
|
|
306
|
-
},
|
|
306
|
+
}, Ye = 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));
|
|
310
310
|
};
|
|
311
|
-
navigator.serviceWorker.addEventListener("controllerchange", s),
|
|
311
|
+
navigator.serviceWorker.addEventListener("controllerchange", s), R.setTimeout(() => {
|
|
312
312
|
t || (t = !0, navigator.serviceWorker.removeEventListener("controllerchange", s), n(navigator.serviceWorker.controller ?? null));
|
|
313
313
|
}, e);
|
|
314
|
-
})
|
|
314
|
+
});
|
|
315
|
+
let ve = !1, M = !1;
|
|
316
|
+
const ye = "oidc.sw.controllerchange_reload_count", oe = 3, ae = () => {
|
|
317
|
+
try {
|
|
318
|
+
return parseInt(sessionStorage.getItem(ye) ?? "0", 10);
|
|
319
|
+
} catch {
|
|
320
|
+
return 0;
|
|
321
|
+
}
|
|
322
|
+
}, Xe = () => {
|
|
323
|
+
const e = ae() + 1;
|
|
324
|
+
try {
|
|
325
|
+
sessionStorage.setItem(ye, String(e));
|
|
326
|
+
} catch {
|
|
327
|
+
}
|
|
328
|
+
return e;
|
|
329
|
+
}, ze = () => {
|
|
330
|
+
try {
|
|
331
|
+
sessionStorage.removeItem(ye);
|
|
332
|
+
} catch {
|
|
333
|
+
}
|
|
334
|
+
}, W = async (e, n) => {
|
|
315
335
|
const t = e.service_worker_relative_url;
|
|
316
336
|
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !t || e.service_worker_activate() === !1)
|
|
317
337
|
return null;
|
|
318
|
-
const s = `${t}?v=${
|
|
338
|
+
const s = `${t}?v=${se}`;
|
|
319
339
|
let o = null;
|
|
320
340
|
e.service_worker_register ? o = await e.service_worker_register(t) : o = await navigator.serviceWorker.register(s, {
|
|
321
341
|
updateViaCache: "none"
|
|
322
342
|
});
|
|
323
|
-
const i = `oidc.sw.version_mismatch_reload.${n}`, r = async () => {
|
|
324
|
-
|
|
343
|
+
const i = `oidc.sw.version_mismatch_reload.${n}`, r = async (d) => {
|
|
344
|
+
Q(), console.log("New SW waiting – SKIP_WAITING");
|
|
325
345
|
try {
|
|
326
|
-
await
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
346
|
+
await new Promise((N, S) => {
|
|
347
|
+
const b = new MessageChannel();
|
|
348
|
+
let K = null;
|
|
349
|
+
const U = () => {
|
|
350
|
+
try {
|
|
351
|
+
K != null && (R.clearTimeout(K), K = null), b.port1.onmessage = null, b.port1.close(), b.port2.close();
|
|
352
|
+
} catch (L) {
|
|
353
|
+
console.error(L);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
K = R.setTimeout(() => {
|
|
357
|
+
U(), S(new Error("SKIP_WAITING did not respond within 8000ms"));
|
|
358
|
+
}, 8e3), b.port1.onmessage = (L) => {
|
|
359
|
+
U(), L?.data?.error ? S(L.data.error) : N();
|
|
360
|
+
};
|
|
361
|
+
try {
|
|
362
|
+
d.postMessage(
|
|
363
|
+
{
|
|
364
|
+
type: "SKIP_WAITING",
|
|
365
|
+
configurationName: n,
|
|
366
|
+
data: null,
|
|
367
|
+
tabId: he(n ?? "default")
|
|
368
|
+
},
|
|
369
|
+
[b.port2]
|
|
370
|
+
);
|
|
371
|
+
} catch (L) {
|
|
372
|
+
U(), S(L);
|
|
373
|
+
}
|
|
330
374
|
});
|
|
331
|
-
} catch (
|
|
332
|
-
console.warn("SKIP_WAITING failed",
|
|
375
|
+
} catch (N) {
|
|
376
|
+
console.warn("SKIP_WAITING failed", N);
|
|
333
377
|
}
|
|
334
|
-
}, a = (
|
|
335
|
-
|
|
336
|
-
|
|
378
|
+
}, a = async () => {
|
|
379
|
+
const d = o.waiting;
|
|
380
|
+
d ? await r(d) : console.warn("sendSkipWaiting called but no waiting service worker found");
|
|
381
|
+
}, c = (d) => {
|
|
382
|
+
Q(), d.addEventListener("statechange", async () => {
|
|
383
|
+
if (d.state === "installed" && navigator.serviceWorker.controller) {
|
|
384
|
+
if (ae() >= oe) {
|
|
385
|
+
console.warn(
|
|
386
|
+
"SW trackInstallingWorker: skipping SKIP_WAITING because the reload budget is exhausted"
|
|
387
|
+
);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
await r(d);
|
|
391
|
+
}
|
|
337
392
|
});
|
|
338
393
|
};
|
|
339
394
|
o.addEventListener("updatefound", () => {
|
|
340
395
|
const d = o.installing;
|
|
341
|
-
d &&
|
|
342
|
-
}), o.installing ?
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
} catch (d) {
|
|
396
|
+
d && c(d);
|
|
397
|
+
}), o.installing ? c(o.installing) : o.waiting && navigator.serviceWorker.controller && (ae() < oe ? a() : console.warn(
|
|
398
|
+
"SW: a waiting worker exists but reload budget is exhausted – skipping activation"
|
|
399
|
+
)), o.update().catch((d) => {
|
|
346
400
|
console.error(d);
|
|
347
|
-
}
|
|
348
|
-
const c = `oidc.sw.controllerchange.reloaded.${n}`;
|
|
349
|
-
navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
350
|
-
try {
|
|
351
|
-
if (sessionStorage.getItem(c) === "1") return;
|
|
352
|
-
sessionStorage.setItem(c, "1");
|
|
353
|
-
} catch {
|
|
354
|
-
}
|
|
355
|
-
console.log("SW controller changed – reloading page"), X(), window.location.reload();
|
|
356
401
|
});
|
|
357
402
|
try {
|
|
358
403
|
await navigator.serviceWorker.ready, navigator.serviceWorker.controller || (await I(o, { timeoutMs: 8e3 })({
|
|
359
404
|
type: "claim",
|
|
360
405
|
configurationName: n,
|
|
361
406
|
data: null
|
|
362
|
-
}), await
|
|
407
|
+
}), await Ye(2e3));
|
|
363
408
|
} catch (d) {
|
|
364
409
|
return console.warn(`Failed init ServiceWorker ${d?.toString?.() ?? String(d)}`), null;
|
|
365
410
|
}
|
|
366
|
-
|
|
367
|
-
|
|
411
|
+
ve || (ve = !0, navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
412
|
+
if (M)
|
|
413
|
+
return;
|
|
414
|
+
const d = Xe();
|
|
415
|
+
if (d > oe) {
|
|
416
|
+
console.warn(
|
|
417
|
+
`SW controllerchange: reload budget exhausted (${d - 1} reloads). Skipping reload to avoid infinite loop.`
|
|
418
|
+
);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
M = !0, console.log("SW controller changed – reloading page"), Q(), window.location.reload();
|
|
422
|
+
}));
|
|
423
|
+
const f = async (d) => I(o)({ type: "clear", data: { status: d }, configurationName: n }), u = async (d, N, S) => {
|
|
424
|
+
const b = await I(o)({
|
|
368
425
|
type: "init",
|
|
369
426
|
data: {
|
|
370
427
|
oidcServerConfiguration: d,
|
|
371
|
-
where:
|
|
428
|
+
where: N,
|
|
372
429
|
oidcConfiguration: {
|
|
373
|
-
token_renew_mode:
|
|
374
|
-
service_worker_convert_all_requests_to_cors:
|
|
430
|
+
token_renew_mode: S.token_renew_mode,
|
|
431
|
+
service_worker_convert_all_requests_to_cors: S.service_worker_convert_all_requests_to_cors
|
|
375
432
|
}
|
|
376
433
|
},
|
|
377
434
|
configurationName: n
|
|
378
|
-
}),
|
|
379
|
-
if (
|
|
435
|
+
}), K = b.version;
|
|
436
|
+
if (K !== se) {
|
|
380
437
|
console.warn(
|
|
381
|
-
`Service worker ${
|
|
438
|
+
`Service worker ${K} version mismatch with js client version ${se}, unregistering and reloading`
|
|
382
439
|
);
|
|
383
|
-
const
|
|
384
|
-
if (
|
|
385
|
-
if (sessionStorage.setItem(i, String(
|
|
386
|
-
await
|
|
387
|
-
|
|
388
|
-
|
|
440
|
+
const U = parseInt(sessionStorage.getItem(i) ?? "0", 10);
|
|
441
|
+
if (U < 3) {
|
|
442
|
+
if (sessionStorage.setItem(i, String(U + 1)), o.waiting)
|
|
443
|
+
return await a(), await Y({ milliseconds: 500 }), M || (M = !0, window.location.reload()), new Promise(() => {
|
|
444
|
+
});
|
|
445
|
+
{
|
|
446
|
+
Q();
|
|
389
447
|
try {
|
|
390
448
|
await o.update();
|
|
391
|
-
} catch (
|
|
392
|
-
console.error(
|
|
449
|
+
} catch (pe) {
|
|
450
|
+
console.error(pe);
|
|
393
451
|
}
|
|
394
|
-
const
|
|
395
|
-
console.log(`Service worker unregistering ${
|
|
452
|
+
const L = await o.unregister();
|
|
453
|
+
return console.log(`Service worker unregistering ${L}`), await Y({ milliseconds: 500 }), M || (M = !0, window.location.reload()), new Promise(() => {
|
|
454
|
+
});
|
|
396
455
|
}
|
|
397
|
-
else
|
|
456
|
+
} else
|
|
398
457
|
console.error(
|
|
399
|
-
`Service worker version mismatch persists after ${
|
|
400
|
-
)
|
|
458
|
+
`Service worker version mismatch persists after ${U} attempt(s). Continuing with mismatched version.`
|
|
459
|
+
);
|
|
401
460
|
} else
|
|
402
|
-
sessionStorage.removeItem(i);
|
|
461
|
+
sessionStorage.removeItem(i), ze();
|
|
403
462
|
return {
|
|
404
|
-
tokens:
|
|
405
|
-
status:
|
|
463
|
+
tokens: ge(b.tokens, null, S.token_renew_mode),
|
|
464
|
+
status: b.status
|
|
406
465
|
};
|
|
407
466
|
}, l = (d = "/") => {
|
|
408
|
-
|
|
467
|
+
Te == null && (Te = "not_null", xe(d));
|
|
409
468
|
}, h = (d) => I(o)({
|
|
410
469
|
type: "setSessionState",
|
|
411
470
|
data: { sessionState: d },
|
|
@@ -419,18 +478,18 @@ const ne = ({ milliseconds: e }) => new Promise((n) => $.setTimeout(n, e)), Oe =
|
|
|
419
478
|
data: { nonce: d },
|
|
420
479
|
configurationName: n
|
|
421
480
|
})), p = async (d = !0) => {
|
|
422
|
-
let
|
|
481
|
+
let S = (await I(o)({
|
|
423
482
|
type: "getNonce",
|
|
424
483
|
data: null,
|
|
425
484
|
configurationName: n
|
|
426
485
|
})).nonce;
|
|
427
|
-
return
|
|
486
|
+
return S || (S = sessionStorage[`oidc.nonce.${n}`], console.warn("nonce not found in service worker, using sessionStorage"), d && (await m(S), S = (await p(!1)).nonce)), { nonce: S };
|
|
428
487
|
}, g = {}, y = (d) => {
|
|
429
488
|
g[n] = d, localStorage[`oidc.login.${n}`] = JSON.stringify(d);
|
|
430
489
|
}, A = () => {
|
|
431
490
|
const d = localStorage[`oidc.login.${n}`];
|
|
432
491
|
return g[n] || (g[n] = JSON.parse(d)), g[n];
|
|
433
|
-
},
|
|
492
|
+
}, T = async (d) => {
|
|
434
493
|
await I(o)({
|
|
435
494
|
type: "setDemonstratingProofOfPossessionNonce",
|
|
436
495
|
data: { demonstratingProofOfPossessionNonce: d },
|
|
@@ -440,14 +499,14 @@ const ne = ({ milliseconds: e }) => new Promise((n) => $.setTimeout(n, e)), Oe =
|
|
|
440
499
|
type: "getDemonstratingProofOfPossessionNonce",
|
|
441
500
|
data: null,
|
|
442
501
|
configurationName: n
|
|
443
|
-
})).demonstratingProofOfPossessionNonce,
|
|
444
|
-
const
|
|
502
|
+
})).demonstratingProofOfPossessionNonce, v = async (d) => {
|
|
503
|
+
const N = JSON.stringify(d);
|
|
445
504
|
await I(o)({
|
|
446
505
|
type: "setDemonstratingProofOfPossessionJwk",
|
|
447
|
-
data: { demonstratingProofOfPossessionJwkJson:
|
|
506
|
+
data: { demonstratingProofOfPossessionJwkJson: N },
|
|
448
507
|
configurationName: n
|
|
449
508
|
});
|
|
450
|
-
},
|
|
509
|
+
}, C = async () => {
|
|
451
510
|
const d = await I(o)({
|
|
452
511
|
type: "getDemonstratingProofOfPossessionJwk",
|
|
453
512
|
data: null,
|
|
@@ -455,24 +514,24 @@ const ne = ({ milliseconds: e }) => new Promise((n) => $.setTimeout(n, e)), Oe =
|
|
|
455
514
|
});
|
|
456
515
|
return d.demonstratingProofOfPossessionJwkJson ? JSON.parse(d.demonstratingProofOfPossessionJwkJson) : null;
|
|
457
516
|
}, w = async (d = !0) => {
|
|
458
|
-
let
|
|
517
|
+
let S = (await I(o)({
|
|
459
518
|
type: "getState",
|
|
460
519
|
data: null,
|
|
461
520
|
configurationName: n
|
|
462
521
|
})).state;
|
|
463
|
-
return
|
|
464
|
-
},
|
|
522
|
+
return S || (S = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"), d && (await H(S), S = await w(!1))), S;
|
|
523
|
+
}, H = async (d) => (sessionStorage[`oidc.state.${n}`] = d, I(o)({
|
|
465
524
|
type: "setState",
|
|
466
525
|
data: { state: d },
|
|
467
526
|
configurationName: n
|
|
468
|
-
})),
|
|
469
|
-
let
|
|
527
|
+
})), $ = async (d = !0) => {
|
|
528
|
+
let S = (await I(o)({
|
|
470
529
|
type: "getCodeVerifier",
|
|
471
530
|
data: null,
|
|
472
531
|
configurationName: n
|
|
473
532
|
})).codeVerifier;
|
|
474
|
-
return
|
|
475
|
-
},
|
|
533
|
+
return S || (S = sessionStorage[`oidc.code_verifier.${n}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), d && (await E(S), S = await $(!1))), S;
|
|
534
|
+
}, E = async (d) => (sessionStorage[`oidc.code_verifier.${n}`] = d, I(o)({
|
|
476
535
|
type: "setCodeVerifier",
|
|
477
536
|
data: { codeVerifier: d },
|
|
478
537
|
configurationName: n
|
|
@@ -488,46 +547,46 @@ const ne = ({ milliseconds: e }) => new Promise((n) => $.setTimeout(n, e)), Oe =
|
|
|
488
547
|
setLoginParams: y,
|
|
489
548
|
getLoginParams: A,
|
|
490
549
|
getStateAsync: w,
|
|
491
|
-
setStateAsync:
|
|
492
|
-
getCodeVerifierAsync:
|
|
493
|
-
setCodeVerifierAsync:
|
|
494
|
-
setDemonstratingProofOfPossessionNonce:
|
|
550
|
+
setStateAsync: H,
|
|
551
|
+
getCodeVerifierAsync: $,
|
|
552
|
+
setCodeVerifierAsync: E,
|
|
553
|
+
setDemonstratingProofOfPossessionNonce: T,
|
|
495
554
|
getDemonstratingProofOfPossessionNonce: O,
|
|
496
|
-
setDemonstratingProofOfPossessionJwkAsync:
|
|
497
|
-
getDemonstratingProofOfPossessionJwkAsync:
|
|
555
|
+
setDemonstratingProofOfPossessionJwkAsync: v,
|
|
556
|
+
getDemonstratingProofOfPossessionJwkAsync: C
|
|
498
557
|
};
|
|
499
|
-
},
|
|
500
|
-
if (!
|
|
558
|
+
}, B = {}, Qe = (e, n = window.sessionStorage, t) => {
|
|
559
|
+
if (!B[e] && n) {
|
|
501
560
|
const o = n.getItem(e);
|
|
502
|
-
o && (
|
|
561
|
+
o && (B[e] = JSON.parse(o));
|
|
503
562
|
}
|
|
504
563
|
const s = 1e3 * t;
|
|
505
|
-
return
|
|
506
|
-
},
|
|
564
|
+
return B[e] && B[e].timestamp + s > Date.now() ? B[e].result : null;
|
|
565
|
+
}, Ze = (e, n, t = window.sessionStorage) => {
|
|
507
566
|
const s = Date.now();
|
|
508
|
-
|
|
567
|
+
B[e] = { result: n, timestamp: s }, t && t.setItem(e, JSON.stringify({ result: n, timestamp: s }));
|
|
509
568
|
};
|
|
510
|
-
function
|
|
569
|
+
function We(e) {
|
|
511
570
|
return new TextEncoder().encode(e);
|
|
512
571
|
}
|
|
513
|
-
function
|
|
572
|
+
function Le(e) {
|
|
514
573
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
|
|
515
574
|
}
|
|
516
|
-
function
|
|
575
|
+
function en(e) {
|
|
517
576
|
return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function(t, s) {
|
|
518
577
|
return String.fromCharCode(parseInt(s, 16));
|
|
519
578
|
});
|
|
520
579
|
}
|
|
521
|
-
const
|
|
580
|
+
const ke = (e) => {
|
|
522
581
|
let n = "";
|
|
523
582
|
return e.forEach(function(t) {
|
|
524
583
|
n += String.fromCharCode(t);
|
|
525
|
-
}),
|
|
584
|
+
}), Le(n);
|
|
526
585
|
};
|
|
527
|
-
function
|
|
528
|
-
return
|
|
586
|
+
function Ee(e) {
|
|
587
|
+
return Le(en(e));
|
|
529
588
|
}
|
|
530
|
-
const
|
|
589
|
+
const nn = {
|
|
531
590
|
importKeyAlgorithm: {
|
|
532
591
|
name: "ECDSA",
|
|
533
592
|
namedCurve: "P-256",
|
|
@@ -540,7 +599,7 @@ const qe = {
|
|
|
540
599
|
},
|
|
541
600
|
digestAlgorithm: { name: "SHA-256" },
|
|
542
601
|
jwtHeaderAlgorithm: "ES256"
|
|
543
|
-
},
|
|
602
|
+
}, tn = (e) => async (n, t, s, o, i = "dpop+jwt") => {
|
|
544
603
|
switch (n = Object.assign({}, n), t.typ = i, t.alg = o.jwtHeaderAlgorithm, t.alg) {
|
|
545
604
|
case "ES256":
|
|
546
605
|
t.jwk = { kty: n.kty, crv: n.crv, x: n.x, y: n.y };
|
|
@@ -554,22 +613,22 @@ const qe = {
|
|
|
554
613
|
const r = {
|
|
555
614
|
// @ts-ignore
|
|
556
615
|
// JWT "headers" really means JWS "protected headers"
|
|
557
|
-
protected:
|
|
616
|
+
protected: Ee(JSON.stringify(t)),
|
|
558
617
|
// @ts-ignore
|
|
559
618
|
// JWT "claims" are really a JSON-defined JWS "payload"
|
|
560
|
-
payload:
|
|
561
|
-
}, a = o.importKeyAlgorithm, c = !0, f = ["sign"], u = await e.crypto.subtle.importKey("jwk", n, a, c, f), l =
|
|
562
|
-
return r.signature =
|
|
563
|
-
},
|
|
619
|
+
payload: Ee(JSON.stringify(s))
|
|
620
|
+
}, a = o.importKeyAlgorithm, c = !0, f = ["sign"], u = await e.crypto.subtle.importKey("jwk", n, a, c, f), l = We(`${r.protected}.${r.payload}`), h = o.signAlgorithm, _ = await e.crypto.subtle.sign(h, u, l);
|
|
621
|
+
return r.signature = ke(new Uint8Array(_)), `${r.protected}.${r.payload}.${r.signature}`;
|
|
622
|
+
}, sn = { sign: tn }, on = (e) => async (n) => {
|
|
564
623
|
const t = n, s = !0, o = ["sign", "verify"], i = await e.crypto.subtle.generateKey(t, s, o);
|
|
565
624
|
return await e.crypto.subtle.exportKey("jwk", i.privateKey);
|
|
566
|
-
},
|
|
625
|
+
}, rn = (e) => {
|
|
567
626
|
const n = Object.assign({}, e);
|
|
568
627
|
return delete n.d, n.key_ops = ["verify"], n;
|
|
569
|
-
},
|
|
570
|
-
generate:
|
|
571
|
-
neuter:
|
|
572
|
-
},
|
|
628
|
+
}, an = {
|
|
629
|
+
generate: on,
|
|
630
|
+
neuter: rn
|
|
631
|
+
}, cn = (e) => async (n, t) => {
|
|
573
632
|
let s;
|
|
574
633
|
switch (n.kty) {
|
|
575
634
|
case "EC":
|
|
@@ -581,80 +640,80 @@ const qe = {
|
|
|
581
640
|
default:
|
|
582
641
|
throw new Error("Unknown or not implemented JWK type");
|
|
583
642
|
}
|
|
584
|
-
const o = await e.crypto.subtle.digest(t,
|
|
585
|
-
return
|
|
586
|
-
},
|
|
643
|
+
const o = await e.crypto.subtle.digest(t, We(s));
|
|
644
|
+
return ke(new Uint8Array(o));
|
|
645
|
+
}, ln = { thumbprint: cn }, un = (e) => async (n) => await an.generate(e)(n), De = (e) => (n) => async (t, s = "POST", o, i = {}) => {
|
|
587
646
|
const r = {
|
|
588
647
|
// https://www.rfc-editor.org/rfc/rfc9449.html#name-concept
|
|
589
|
-
jti: btoa(
|
|
648
|
+
jti: btoa(_n()),
|
|
590
649
|
htm: s,
|
|
591
650
|
htu: o,
|
|
592
651
|
iat: Math.round(Date.now() / 1e3),
|
|
593
652
|
...i
|
|
594
|
-
}, a = await
|
|
653
|
+
}, a = await ln.thumbprint(e)(
|
|
595
654
|
t,
|
|
596
655
|
n.digestAlgorithm
|
|
597
656
|
);
|
|
598
|
-
return await
|
|
657
|
+
return await sn.sign(e)(
|
|
599
658
|
t,
|
|
600
659
|
{ kid: a },
|
|
601
660
|
r,
|
|
602
661
|
n
|
|
603
662
|
);
|
|
604
|
-
},
|
|
663
|
+
}, _n = () => {
|
|
605
664
|
const e = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", n = "0123456789abcdef";
|
|
606
665
|
let t = 0, s = "";
|
|
607
666
|
for (let o = 0; o < 36; o++)
|
|
608
667
|
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];
|
|
609
668
|
return s;
|
|
610
|
-
},
|
|
669
|
+
}, Re = () => {
|
|
611
670
|
const e = typeof window < "u" && !!window.crypto, n = e && !!window.crypto.subtle;
|
|
612
671
|
return { hasCrypto: e, hasSubtleCrypto: n };
|
|
613
|
-
},
|
|
672
|
+
}, ce = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", fn = (e) => {
|
|
614
673
|
const n = [];
|
|
615
674
|
for (let t = 0; t < e.byteLength; t += 1) {
|
|
616
|
-
const s = e[t] %
|
|
617
|
-
n.push(
|
|
675
|
+
const s = e[t] % ce.length;
|
|
676
|
+
n.push(ce[s]);
|
|
618
677
|
}
|
|
619
678
|
return n.join("");
|
|
620
|
-
},
|
|
621
|
-
const n = new Uint8Array(e), { hasCrypto: t } =
|
|
679
|
+
}, le = (e) => {
|
|
680
|
+
const n = new Uint8Array(e), { hasCrypto: t } = Re();
|
|
622
681
|
if (t)
|
|
623
682
|
window.crypto.getRandomValues(n);
|
|
624
683
|
else
|
|
625
684
|
for (let s = 0; s < e; s += 1)
|
|
626
|
-
n[s] = Math.random() *
|
|
627
|
-
return
|
|
685
|
+
n[s] = Math.random() * ce.length | 0;
|
|
686
|
+
return fn(n);
|
|
628
687
|
};
|
|
629
|
-
function
|
|
688
|
+
function dn(e) {
|
|
630
689
|
const n = new ArrayBuffer(e.length), t = new Uint8Array(n);
|
|
631
690
|
for (let s = 0; s < e.length; s++)
|
|
632
691
|
t[s] = e.charCodeAt(s);
|
|
633
692
|
return t;
|
|
634
693
|
}
|
|
635
|
-
function
|
|
694
|
+
function $e(e) {
|
|
636
695
|
return new Promise((n, t) => {
|
|
637
|
-
crypto.subtle.digest("SHA-256",
|
|
638
|
-
(s) => n(
|
|
696
|
+
crypto.subtle.digest("SHA-256", dn(e)).then(
|
|
697
|
+
(s) => n(ke(new Uint8Array(s))),
|
|
639
698
|
(s) => t(s)
|
|
640
699
|
);
|
|
641
700
|
});
|
|
642
701
|
}
|
|
643
|
-
const
|
|
702
|
+
const gn = (e) => {
|
|
644
703
|
if (e.length < 43 || e.length > 128)
|
|
645
704
|
return Promise.reject(new Error("Invalid code length."));
|
|
646
|
-
const { hasSubtleCrypto: n } =
|
|
647
|
-
return n ?
|
|
648
|
-
},
|
|
649
|
-
const i = `${n}/.well-known/openid-configuration`, r = `oidc.server:${n}`, a =
|
|
705
|
+
const { hasSubtleCrypto: n } = Re();
|
|
706
|
+
return n ? $e(e) : Promise.reject(new Error("window.crypto.subtle is unavailable."));
|
|
707
|
+
}, hn = 3600, yn = (e) => async (n, t = hn, s = window.sessionStorage, o = 1e4) => {
|
|
708
|
+
const i = `${n}/.well-known/openid-configuration`, r = `oidc.server:${n}`, a = Qe(r, s, t);
|
|
650
709
|
if (a)
|
|
651
|
-
return new
|
|
652
|
-
const c = await
|
|
710
|
+
return new fe(a);
|
|
711
|
+
const c = await z(e)(i, {}, o);
|
|
653
712
|
if (c.status !== 200)
|
|
654
713
|
return null;
|
|
655
714
|
const f = await c.json();
|
|
656
|
-
return
|
|
657
|
-
},
|
|
715
|
+
return Ze(r, f, s), new fe(f);
|
|
716
|
+
}, z = (e) => async (n, t = {}, s = 1e4, o = 0) => {
|
|
658
717
|
let i;
|
|
659
718
|
try {
|
|
660
719
|
const r = new AbortController();
|
|
@@ -662,16 +721,16 @@ const an = (e) => {
|
|
|
662
721
|
} catch (r) {
|
|
663
722
|
if (r.name === "AbortError" || r.message === "Network request failed") {
|
|
664
723
|
if (o <= 1)
|
|
665
|
-
return await
|
|
724
|
+
return await z(e)(n, t, s, o + 1);
|
|
666
725
|
throw r;
|
|
667
726
|
} else
|
|
668
727
|
throw console.error(r.message), r;
|
|
669
728
|
}
|
|
670
729
|
return i;
|
|
671
|
-
},
|
|
730
|
+
}, ue = {
|
|
672
731
|
refresh_token: "refresh_token",
|
|
673
732
|
access_token: "access_token"
|
|
674
|
-
},
|
|
733
|
+
}, Oe = (e) => async (n, t, s = ue.refresh_token, o, i = {}, r = 1e4) => {
|
|
675
734
|
const a = {
|
|
676
735
|
token: t,
|
|
677
736
|
token_type_hint: s,
|
|
@@ -685,7 +744,7 @@ const an = (e) => {
|
|
|
685
744
|
c.push(`${h}=${_}`);
|
|
686
745
|
}
|
|
687
746
|
const f = c.join("&");
|
|
688
|
-
return (await
|
|
747
|
+
return (await z(e)(
|
|
689
748
|
n,
|
|
690
749
|
{
|
|
691
750
|
method: "POST",
|
|
@@ -698,7 +757,7 @@ const an = (e) => {
|
|
|
698
757
|
)).status !== 200 ? { success: !1 } : {
|
|
699
758
|
success: !0
|
|
700
759
|
};
|
|
701
|
-
},
|
|
760
|
+
}, kn = (e) => async (n, t, s, o, i = {}, r, a = 1e4) => {
|
|
702
761
|
for (const [_, m] of Object.entries(s))
|
|
703
762
|
t[_] === void 0 && (t[_] = m);
|
|
704
763
|
const c = [];
|
|
@@ -706,7 +765,7 @@ const an = (e) => {
|
|
|
706
765
|
const m = encodeURIComponent(_), p = encodeURIComponent(t[_]);
|
|
707
766
|
c.push(`${m}=${p}`);
|
|
708
767
|
}
|
|
709
|
-
const f = c.join("&"), u = await
|
|
768
|
+
const f = c.join("&"), u = await z(e)(
|
|
710
769
|
n,
|
|
711
770
|
{
|
|
712
771
|
method: "POST",
|
|
@@ -726,31 +785,31 @@ const an = (e) => {
|
|
|
726
785
|
};
|
|
727
786
|
const l = await u.json();
|
|
728
787
|
let h = null;
|
|
729
|
-
return u.headers.has(
|
|
730
|
-
|
|
788
|
+
return u.headers.has(te) && (h = u.headers.get(
|
|
789
|
+
te
|
|
731
790
|
)), {
|
|
732
791
|
success: !0,
|
|
733
792
|
status: u.status,
|
|
734
|
-
data:
|
|
793
|
+
data: ge(l, o, r),
|
|
735
794
|
demonstratingProofOfPossessionNonce: h
|
|
736
795
|
};
|
|
737
|
-
},
|
|
796
|
+
}, mn = (e, n) => async (t, s) => {
|
|
738
797
|
s = s ? { ...s } : {};
|
|
739
|
-
const o =
|
|
798
|
+
const o = le(128), i = await gn(o);
|
|
740
799
|
await e.setCodeVerifierAsync(o), await e.setStateAsync(s.state), s.code_challenge = i, s.code_challenge_method = "S256";
|
|
741
800
|
let r = "";
|
|
742
801
|
if (s)
|
|
743
802
|
for (const [a, c] of Object.entries(s))
|
|
744
803
|
r === "" ? r += "?" : r += "&", r += `${a}=${encodeURIComponent(c)}`;
|
|
745
804
|
n.open(`${t}${r}`);
|
|
746
|
-
},
|
|
805
|
+
}, te = "DPoP-Nonce", wn = (e) => async (n, t, s, o, i = 1e4) => {
|
|
747
806
|
t = t ? { ...t } : {}, t.code_verifier = await e.getCodeVerifierAsync();
|
|
748
807
|
const r = [];
|
|
749
808
|
for (const l in t) {
|
|
750
809
|
const h = encodeURIComponent(l), _ = encodeURIComponent(t[l]);
|
|
751
810
|
r.push(`${h}=${_}`);
|
|
752
811
|
}
|
|
753
|
-
const a = r.join("&"), c = await
|
|
812
|
+
const a = r.join("&"), c = await z(fetch)(
|
|
754
813
|
n,
|
|
755
814
|
{
|
|
756
815
|
method: "POST",
|
|
@@ -765,23 +824,23 @@ const an = (e) => {
|
|
|
765
824
|
if (await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]), c.status !== 200)
|
|
766
825
|
return { success: !1, status: c.status };
|
|
767
826
|
let f = null;
|
|
768
|
-
c.headers.has(
|
|
769
|
-
|
|
827
|
+
c.headers.has(te) && (f = c.headers.get(
|
|
828
|
+
te
|
|
770
829
|
));
|
|
771
830
|
const u = await c.json();
|
|
772
831
|
return {
|
|
773
832
|
success: !0,
|
|
774
833
|
data: {
|
|
775
834
|
state: t.state,
|
|
776
|
-
tokens:
|
|
835
|
+
tokens: ge(u, null, o),
|
|
777
836
|
demonstratingProofOfPossessionNonce: f
|
|
778
837
|
}
|
|
779
838
|
};
|
|
780
839
|
};
|
|
781
|
-
async function
|
|
840
|
+
async function be(e, n, t, s = null) {
|
|
782
841
|
const o = (c) => {
|
|
783
842
|
e.tokens = c;
|
|
784
|
-
}, { tokens: i, status: r } = await
|
|
843
|
+
}, { tokens: i, status: r } = await Z(e)(
|
|
785
844
|
o,
|
|
786
845
|
0,
|
|
787
846
|
0,
|
|
@@ -789,39 +848,39 @@ async function Ae(e, n, t, s = null) {
|
|
|
789
848
|
t,
|
|
790
849
|
s
|
|
791
850
|
);
|
|
792
|
-
return await
|
|
851
|
+
return await W(e.configuration, e.configurationName) || x(
|
|
793
852
|
e.configurationName,
|
|
794
853
|
e.configuration.storage,
|
|
795
854
|
e.configuration.login_state_storage ?? e.configuration.storage
|
|
796
855
|
).setTokens(e.tokens), e.tokens ? i : (await e.destroyAsync(r), null);
|
|
797
856
|
}
|
|
798
|
-
async function
|
|
857
|
+
async function Ke(e, n = !1, t = null, s = null) {
|
|
799
858
|
const o = e.configuration, i = `${o.client_id}_${e.configurationName}_${o.authority}`;
|
|
800
859
|
let r;
|
|
801
|
-
const a = await
|
|
860
|
+
const a = await W(e.configuration, e.configurationName);
|
|
802
861
|
if (o?.storage === window?.sessionStorage && !a || !navigator.locks)
|
|
803
|
-
r = await
|
|
862
|
+
r = await be(e, n, t, s);
|
|
804
863
|
else {
|
|
805
864
|
let c = "retry";
|
|
806
865
|
for (; c === "retry"; )
|
|
807
866
|
c = await navigator.locks.request(
|
|
808
867
|
i,
|
|
809
868
|
{ ifAvailable: !0 },
|
|
810
|
-
async (f) => f ? await
|
|
869
|
+
async (f) => f ? await be(e, n, t, s) : (e.publishEvent(D.eventNames.syncTokensAsync_lock_not_available, {
|
|
811
870
|
lock: "lock not available"
|
|
812
871
|
}), "retry")
|
|
813
872
|
);
|
|
814
873
|
r = c;
|
|
815
874
|
}
|
|
816
|
-
return r ? (e.timeoutId && (e.timeoutId =
|
|
875
|
+
return r ? (e.timeoutId && (e.timeoutId = X(e, e.tokens.expiresAt, t, s)), e.tokens) : null;
|
|
817
876
|
}
|
|
818
|
-
const
|
|
877
|
+
const X = (e, n, t = null, s = null) => {
|
|
819
878
|
const o = e.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
820
|
-
return e.timeoutId &&
|
|
821
|
-
const r = { timeLeft:
|
|
822
|
-
e.publishEvent(
|
|
879
|
+
return e.timeoutId && R.clearTimeout(e.timeoutId), R.setTimeout(async () => {
|
|
880
|
+
const r = { timeLeft: G(o, n) };
|
|
881
|
+
e.publishEvent(D.eventNames.token_timer, r), await Ke(e, !1, t, s);
|
|
823
882
|
}, 1e3);
|
|
824
|
-
},
|
|
883
|
+
}, P = {
|
|
825
884
|
FORCE_REFRESH: "FORCE_REFRESH",
|
|
826
885
|
SESSION_LOST: "SESSION_LOST",
|
|
827
886
|
NOT_CONNECTED: "NOT_CONNECTED",
|
|
@@ -831,15 +890,15 @@ const G = (e, n, t = null, s = null) => {
|
|
|
831
890
|
LOGOUT_FROM_ANOTHER_TAB: "LOGOUT_FROM_ANOTHER_TAB",
|
|
832
891
|
REQUIRE_SYNC_TOKENS: "REQUIRE_SYNC_TOKENS",
|
|
833
892
|
TOKENS_INVALID: "TOKENS_INVALID"
|
|
834
|
-
},
|
|
893
|
+
}, me = (e) => async (n, t, s, o = !1) => {
|
|
835
894
|
const i = { nonce: null };
|
|
836
895
|
if (!s)
|
|
837
|
-
return { tokens: null, status:
|
|
896
|
+
return { tokens: null, status: P.NOT_CONNECTED, nonce: i };
|
|
838
897
|
let r = i;
|
|
839
898
|
const a = await e.initAsync(
|
|
840
899
|
n.authority,
|
|
841
900
|
n.authority_configuration
|
|
842
|
-
), c = await
|
|
901
|
+
), c = await W(n, t);
|
|
843
902
|
if (c) {
|
|
844
903
|
const { status: l, tokens: h } = await c.initAsync(
|
|
845
904
|
a,
|
|
@@ -849,100 +908,100 @@ const G = (e, n, t = null, s = null) => {
|
|
|
849
908
|
if (l === "LOGGED_OUT")
|
|
850
909
|
return {
|
|
851
910
|
tokens: null,
|
|
852
|
-
status:
|
|
911
|
+
status: P.LOGOUT_FROM_ANOTHER_TAB,
|
|
853
912
|
nonce: i
|
|
854
913
|
};
|
|
855
914
|
if (l === "SESSIONS_LOST")
|
|
856
|
-
return { tokens: null, status:
|
|
915
|
+
return { tokens: null, status: P.SESSION_LOST, nonce: i };
|
|
857
916
|
if (!l || !h)
|
|
858
917
|
return {
|
|
859
918
|
tokens: null,
|
|
860
|
-
status:
|
|
919
|
+
status: P.REQUIRE_SYNC_TOKENS,
|
|
861
920
|
nonce: i
|
|
862
921
|
};
|
|
863
922
|
if (h.issuedAt !== s.issuedAt) {
|
|
864
|
-
const m =
|
|
923
|
+
const m = G(
|
|
865
924
|
n.refresh_time_before_tokens_expiration_in_second,
|
|
866
925
|
h.expiresAt
|
|
867
|
-
) > 0 ?
|
|
926
|
+
) > 0 ? P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, p = await c.getNonceAsync();
|
|
868
927
|
return { tokens: h, status: m, nonce: p };
|
|
869
928
|
}
|
|
870
929
|
r = await c.getNonceAsync();
|
|
871
930
|
} else {
|
|
872
|
-
const l =
|
|
931
|
+
const l = x(
|
|
873
932
|
t,
|
|
874
933
|
n.storage ?? sessionStorage,
|
|
875
934
|
n.login_state_storage ?? n.storage ?? sessionStorage
|
|
876
935
|
), h = await l.initAsync();
|
|
877
936
|
let { tokens: _ } = h;
|
|
878
937
|
const { status: m } = h;
|
|
879
|
-
if (_ && (_ =
|
|
938
|
+
if (_ && (_ = de(_, e.tokens, n.token_renew_mode)), _) {
|
|
880
939
|
if (m === "SESSIONS_LOST")
|
|
881
|
-
return { tokens: null, status:
|
|
940
|
+
return { tokens: null, status: P.SESSION_LOST, nonce: i };
|
|
882
941
|
if (_.issuedAt !== s.issuedAt) {
|
|
883
|
-
const g =
|
|
942
|
+
const g = G(
|
|
884
943
|
n.refresh_time_before_tokens_expiration_in_second,
|
|
885
944
|
_.expiresAt
|
|
886
|
-
) > 0 ?
|
|
945
|
+
) > 0 ? P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, y = await l.getNonceAsync();
|
|
887
946
|
return { tokens: _, status: g, nonce: y };
|
|
888
947
|
}
|
|
889
948
|
} else return {
|
|
890
949
|
tokens: null,
|
|
891
|
-
status:
|
|
950
|
+
status: P.LOGOUT_FROM_ANOTHER_TAB,
|
|
892
951
|
nonce: i
|
|
893
952
|
};
|
|
894
953
|
r = await l.getNonceAsync();
|
|
895
954
|
}
|
|
896
|
-
const u =
|
|
955
|
+
const u = G(
|
|
897
956
|
n.refresh_time_before_tokens_expiration_in_second,
|
|
898
957
|
s.expiresAt
|
|
899
958
|
) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
|
|
900
959
|
return o ? { tokens: s, status: "FORCE_REFRESH", nonce: r } : { tokens: s, status: u, nonce: r };
|
|
901
|
-
},
|
|
960
|
+
}, Z = (e) => async (n, t = 0, s = 0, o = !1, i = null, r = null) => {
|
|
902
961
|
if (!navigator.onLine && document.hidden)
|
|
903
962
|
return { tokens: e.tokens, status: "GIVE_UP" };
|
|
904
963
|
let a = 6;
|
|
905
964
|
const c = o ? 2 : 5, f = 5;
|
|
906
965
|
for (; !navigator.onLine && a > 0; )
|
|
907
|
-
await
|
|
966
|
+
await Y({ milliseconds: 1e3 }), a--, e.publishEvent(k.refreshTokensAsync, {
|
|
908
967
|
message: `wait because navigator is offline try ${a}`
|
|
909
968
|
});
|
|
910
969
|
const u = document.hidden, l = u ? t : t + 1, h = u ? s + 1 : s;
|
|
911
970
|
if (t >= c || s >= f)
|
|
912
971
|
return n(null), e.publishEvent(k.refreshTokensAsync_error, { message: "refresh token" }), { tokens: null, status: "SESSION_LOST" };
|
|
913
972
|
i || (i = {});
|
|
914
|
-
const _ = e.configuration, m = (g, y = null, A = null) =>
|
|
973
|
+
const _ = e.configuration, m = (g, y = null, A = null) => we(
|
|
915
974
|
e.configurationName,
|
|
916
975
|
e.configuration,
|
|
917
976
|
e.publishEvent.bind(e)
|
|
918
977
|
)(g, y, A), p = async () => {
|
|
919
978
|
try {
|
|
920
979
|
let g;
|
|
921
|
-
const y = await
|
|
922
|
-
y ? g = y.getLoginParams() : g =
|
|
980
|
+
const y = await W(_, e.configurationName);
|
|
981
|
+
y ? g = y.getLoginParams() : g = x(
|
|
923
982
|
e.configurationName,
|
|
924
983
|
_.storage,
|
|
925
984
|
_.login_state_storage ?? _.storage
|
|
926
985
|
).getLoginParams();
|
|
927
986
|
const A = {};
|
|
928
987
|
if (g && g.extras)
|
|
929
|
-
for (const [O,
|
|
930
|
-
|
|
988
|
+
for (const [O, v] of Object.entries(g.extras))
|
|
989
|
+
v != null && (A[O] = v);
|
|
931
990
|
if (i)
|
|
932
|
-
for (const [O,
|
|
933
|
-
|
|
991
|
+
for (const [O, v] of Object.entries(i))
|
|
992
|
+
v != null && (A[O] = v);
|
|
934
993
|
A.prompt = "none", r && (A.scope = r);
|
|
935
|
-
const
|
|
936
|
-
return
|
|
994
|
+
const T = await m(A);
|
|
995
|
+
return T ? T.error ? (n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
937
996
|
message: "refresh token silent"
|
|
938
|
-
}), { tokens: null, status: "SESSION_LOST" }) : (n(
|
|
997
|
+
}), { tokens: null, status: "SESSION_LOST" }) : (n(T.tokens), e.publishEvent(D.eventNames.token_renewed, {}), { tokens: T.tokens, status: "LOGGED" }) : (n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
939
998
|
message: "refresh token silent not active"
|
|
940
999
|
}), { tokens: null, status: "SESSION_LOST" });
|
|
941
1000
|
} catch (g) {
|
|
942
1001
|
return console.error(g), e.publishEvent(k.refreshTokensAsync_silent_error, {
|
|
943
1002
|
message: "exceptionSilent",
|
|
944
1003
|
exception: g.message
|
|
945
|
-
}), await
|
|
1004
|
+
}), await Z(e)(
|
|
946
1005
|
n,
|
|
947
1006
|
l,
|
|
948
1007
|
h,
|
|
@@ -953,33 +1012,33 @@ const G = (e, n, t = null, s = null) => {
|
|
|
953
1012
|
}
|
|
954
1013
|
};
|
|
955
1014
|
try {
|
|
956
|
-
const { status: g, tokens: y, nonce: A } = await
|
|
1015
|
+
const { status: g, tokens: y, nonce: A } = await me(e)(
|
|
957
1016
|
_,
|
|
958
1017
|
e.configurationName,
|
|
959
1018
|
e.tokens,
|
|
960
1019
|
o
|
|
961
1020
|
);
|
|
962
1021
|
switch (g) {
|
|
963
|
-
case
|
|
1022
|
+
case P.SESSION_LOST:
|
|
964
1023
|
return n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
965
1024
|
message: "refresh token session lost"
|
|
966
1025
|
}), { tokens: null, status: "SESSION_LOST" };
|
|
967
|
-
case
|
|
1026
|
+
case P.NOT_CONNECTED:
|
|
968
1027
|
return n(null), { tokens: null, status: null };
|
|
969
|
-
case
|
|
1028
|
+
case P.TOKENS_VALID:
|
|
970
1029
|
return n(y), { tokens: y, status: "LOGGED_IN" };
|
|
971
|
-
case
|
|
972
|
-
return n(y), e.publishEvent(
|
|
1030
|
+
case P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:
|
|
1031
|
+
return n(y), e.publishEvent(D.eventNames.token_renewed, {
|
|
973
1032
|
reason: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID"
|
|
974
1033
|
}), { tokens: y, status: "LOGGED_IN" };
|
|
975
|
-
case
|
|
1034
|
+
case P.LOGOUT_FROM_ANOTHER_TAB:
|
|
976
1035
|
return n(null), e.publishEvent(k.logout_from_another_tab, {
|
|
977
1036
|
status: "session syncTokensAsync"
|
|
978
1037
|
}), { tokens: null, status: "LOGGED_OUT" };
|
|
979
|
-
case
|
|
980
|
-
return _.token_automatic_renew_mode ==
|
|
1038
|
+
case P.REQUIRE_SYNC_TOKENS:
|
|
1039
|
+
return _.token_automatic_renew_mode == q.AutomaticOnlyWhenFetchExecuted && !o ? (e.publishEvent(k.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" }) : (e.publishEvent(k.refreshTokensAsync_begin, { tryNumber: t }), await p());
|
|
981
1040
|
default: {
|
|
982
|
-
if (_.token_automatic_renew_mode ==
|
|
1041
|
+
if (_.token_automatic_renew_mode == q.AutomaticOnlyWhenFetchExecuted && P.FORCE_REFRESH !== g)
|
|
983
1042
|
return e.publishEvent(k.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" };
|
|
984
1043
|
if (e.publishEvent(k.refreshTokensAsync_begin, {
|
|
985
1044
|
refreshToken: y.refreshToken,
|
|
@@ -988,65 +1047,65 @@ const G = (e, n, t = null, s = null) => {
|
|
|
988
1047
|
backgroundTry: s
|
|
989
1048
|
}), !y.refreshToken)
|
|
990
1049
|
return await p();
|
|
991
|
-
const
|
|
992
|
-
for (const [
|
|
993
|
-
|
|
1050
|
+
const T = _.client_id, O = _.redirect_uri, v = _.authority, w = { ..._.token_request_extras ? _.token_request_extras : {} };
|
|
1051
|
+
for (const [$, E] of Object.entries(i))
|
|
1052
|
+
$.endsWith(":token_request") && (w[$.replace(":token_request", "")] = E);
|
|
994
1053
|
return await (async () => {
|
|
995
|
-
const
|
|
996
|
-
client_id:
|
|
1054
|
+
const $ = {
|
|
1055
|
+
client_id: T,
|
|
997
1056
|
redirect_uri: O,
|
|
998
1057
|
grant_type: "refresh_token",
|
|
999
1058
|
refresh_token: y.refreshToken
|
|
1000
|
-
},
|
|
1001
|
-
|
|
1059
|
+
}, E = await e.initAsync(
|
|
1060
|
+
v,
|
|
1002
1061
|
_.authority_configuration
|
|
1003
|
-
), d = document.hidden ? 1e4 : 3e4 * 10,
|
|
1004
|
-
_.demonstrating_proof_of_possession && (
|
|
1062
|
+
), d = document.hidden ? 1e4 : 3e4 * 10, N = E.tokenEndpoint, S = {};
|
|
1063
|
+
_.demonstrating_proof_of_possession && (S.DPoP = await e.generateDemonstrationOfProofOfPossessionAsync(
|
|
1005
1064
|
y.accessToken,
|
|
1006
|
-
|
|
1065
|
+
N,
|
|
1007
1066
|
"POST"
|
|
1008
1067
|
));
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1011
|
-
|
|
1068
|
+
const b = await kn(e.getFetch())(
|
|
1069
|
+
N,
|
|
1070
|
+
$,
|
|
1012
1071
|
w,
|
|
1013
1072
|
y,
|
|
1014
|
-
|
|
1073
|
+
S,
|
|
1015
1074
|
_.token_renew_mode,
|
|
1016
1075
|
d
|
|
1017
1076
|
);
|
|
1018
|
-
if (
|
|
1019
|
-
const { isValid:
|
|
1020
|
-
|
|
1077
|
+
if (b.success) {
|
|
1078
|
+
const { isValid: K, reason: U } = Ne(
|
|
1079
|
+
b.data,
|
|
1021
1080
|
A.nonce,
|
|
1022
|
-
|
|
1081
|
+
E
|
|
1023
1082
|
);
|
|
1024
|
-
if (!
|
|
1083
|
+
if (!K)
|
|
1025
1084
|
return n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
1026
|
-
message: `refresh token return not valid tokens, reason: ${
|
|
1085
|
+
message: `refresh token return not valid tokens, reason: ${U}`
|
|
1027
1086
|
}), { tokens: null, status: "SESSION_LOST" };
|
|
1028
|
-
if (n(
|
|
1029
|
-
const
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
) : await
|
|
1087
|
+
if (n(b.data), b.demonstratingProofOfPossessionNonce) {
|
|
1088
|
+
const L = await W(_, e.configurationName);
|
|
1089
|
+
L ? await L.setDemonstratingProofOfPossessionNonce(
|
|
1090
|
+
b.demonstratingProofOfPossessionNonce
|
|
1091
|
+
) : await x(
|
|
1033
1092
|
e.configurationName,
|
|
1034
1093
|
_.storage,
|
|
1035
1094
|
_.login_state_storage ?? _.storage
|
|
1036
1095
|
).setDemonstratingProofOfPossessionNonce(
|
|
1037
|
-
|
|
1096
|
+
b.demonstratingProofOfPossessionNonce
|
|
1038
1097
|
);
|
|
1039
1098
|
}
|
|
1040
1099
|
return e.publishEvent(k.refreshTokensAsync_end, {
|
|
1041
|
-
success:
|
|
1042
|
-
}), e.publishEvent(
|
|
1100
|
+
success: b.success
|
|
1101
|
+
}), e.publishEvent(D.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), { tokens: b.data, status: "LOGGED_IN" };
|
|
1043
1102
|
} else
|
|
1044
1103
|
return e.publishEvent(k.refreshTokensAsync_silent_error, {
|
|
1045
1104
|
message: "bad request",
|
|
1046
|
-
tokenResponse:
|
|
1047
|
-
}),
|
|
1048
|
-
message: `session lost: ${
|
|
1049
|
-
}), { tokens: null, status: "SESSION_LOST" }) : await
|
|
1105
|
+
tokenResponse: b
|
|
1106
|
+
}), b.status >= 400 && b.status < 500 ? (n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
1107
|
+
message: `session lost: ${b.status}`
|
|
1108
|
+
}), { tokens: null, status: "SESSION_LOST" }) : await Z(e)(
|
|
1050
1109
|
n,
|
|
1051
1110
|
l,
|
|
1052
1111
|
h,
|
|
@@ -1063,7 +1122,7 @@ const G = (e, n, t = null, s = null) => {
|
|
|
1063
1122
|
exception: g.message
|
|
1064
1123
|
}), new Promise((y, A) => {
|
|
1065
1124
|
setTimeout(() => {
|
|
1066
|
-
|
|
1125
|
+
Z(e)(
|
|
1067
1126
|
n,
|
|
1068
1127
|
l,
|
|
1069
1128
|
h,
|
|
@@ -1074,7 +1133,7 @@ const G = (e, n, t = null, s = null) => {
|
|
|
1074
1133
|
}, 1e3);
|
|
1075
1134
|
});
|
|
1076
1135
|
}
|
|
1077
|
-
},
|
|
1136
|
+
}, we = (e, n, t) => (s = null, o = null, i = null) => {
|
|
1078
1137
|
if (!n.silent_redirect_uri || !n.silent_login_uri)
|
|
1079
1138
|
return Promise.resolve(null);
|
|
1080
1139
|
try {
|
|
@@ -1090,17 +1149,17 @@ const G = (e, n, t = null, s = null) => {
|
|
|
1090
1149
|
window.removeEventListener("message", p), u.remove(), _ = !0;
|
|
1091
1150
|
}, p = (g) => {
|
|
1092
1151
|
if (g.origin === f && g.source === u.contentWindow) {
|
|
1093
|
-
const y = `${e}_oidc_tokens:`, A = `${e}_oidc_error:`,
|
|
1152
|
+
const y = `${e}_oidc_tokens:`, A = `${e}_oidc_error:`, T = `${e}_oidc_exception:`, O = g.data;
|
|
1094
1153
|
if (O && typeof O == "string" && !_) {
|
|
1095
1154
|
if (O.startsWith(y)) {
|
|
1096
|
-
const
|
|
1097
|
-
t(k.silentLoginAsync_end, {}), l(
|
|
1155
|
+
const v = JSON.parse(g.data.replace(y, ""));
|
|
1156
|
+
t(k.silentLoginAsync_end, {}), l(v), m();
|
|
1098
1157
|
} else if (O.startsWith(A)) {
|
|
1099
|
-
const
|
|
1100
|
-
t(k.silentLoginAsync_error,
|
|
1101
|
-
} else if (O.startsWith(
|
|
1102
|
-
const
|
|
1103
|
-
t(k.silentLoginAsync_error,
|
|
1158
|
+
const v = JSON.parse(g.data.replace(A, ""));
|
|
1159
|
+
t(k.silentLoginAsync_error, v), l({ error: "oidc_" + v.error, tokens: null, sessionState: null }), m();
|
|
1160
|
+
} else if (O.startsWith(T)) {
|
|
1161
|
+
const v = JSON.parse(g.data.replace(T, ""));
|
|
1162
|
+
t(k.silentLoginAsync_error, v), h(new Error(v.error)), m();
|
|
1104
1163
|
}
|
|
1105
1164
|
}
|
|
1106
1165
|
}
|
|
@@ -1118,15 +1177,15 @@ const G = (e, n, t = null, s = null) => {
|
|
|
1118
1177
|
} catch (r) {
|
|
1119
1178
|
throw t(k.silentLoginAsync_error, r), r;
|
|
1120
1179
|
}
|
|
1121
|
-
},
|
|
1180
|
+
}, pn = (e, n, t, s, o) => (i = null, r = void 0) => {
|
|
1122
1181
|
i = { ...i };
|
|
1123
|
-
const a = (f, u, l) =>
|
|
1182
|
+
const a = (f, u, l) => we(n, t, s.bind(o))(
|
|
1124
1183
|
f,
|
|
1125
1184
|
u,
|
|
1126
1185
|
l
|
|
1127
1186
|
);
|
|
1128
1187
|
return (async () => {
|
|
1129
|
-
o.timeoutId &&
|
|
1188
|
+
o.timeoutId && R.clearTimeout(o.timeoutId);
|
|
1130
1189
|
let f;
|
|
1131
1190
|
i && "state" in i && (f = i.state, delete i.state);
|
|
1132
1191
|
try {
|
|
@@ -1139,13 +1198,13 @@ const G = (e, n, t = null, s = null) => {
|
|
|
1139
1198
|
r
|
|
1140
1199
|
);
|
|
1141
1200
|
if (l)
|
|
1142
|
-
return o.tokens = l.tokens, s(k.token_acquired, {}), o.timeoutId =
|
|
1201
|
+
return o.tokens = l.tokens, s(k.token_acquired, {}), o.timeoutId = X(o, o.tokens.expiresAt, i, r), {};
|
|
1143
1202
|
} catch (u) {
|
|
1144
1203
|
return u;
|
|
1145
1204
|
}
|
|
1146
1205
|
})();
|
|
1147
|
-
},
|
|
1148
|
-
const a = (c, f = void 0, u = void 0) =>
|
|
1206
|
+
}, An = (e, n, t) => (s, o, i, r = !1) => {
|
|
1207
|
+
const a = (c, f = void 0, u = void 0) => we(e.configurationName, t, e.publishEvent.bind(e))(
|
|
1149
1208
|
c,
|
|
1150
1209
|
f,
|
|
1151
1210
|
u
|
|
@@ -1189,7 +1248,7 @@ const G = (e, n, t = null, s = null) => {
|
|
|
1189
1248
|
await p.logoutOtherTabAsync(t.client_id, _.sub);
|
|
1190
1249
|
});
|
|
1191
1250
|
};
|
|
1192
|
-
e.checkSessionIFrame = new
|
|
1251
|
+
e.checkSessionIFrame = new Fe(
|
|
1193
1252
|
u,
|
|
1194
1253
|
o,
|
|
1195
1254
|
s
|
|
@@ -1201,7 +1260,7 @@ const G = (e, n, t = null, s = null) => {
|
|
|
1201
1260
|
} else
|
|
1202
1261
|
c(null);
|
|
1203
1262
|
});
|
|
1204
|
-
},
|
|
1263
|
+
}, Sn = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), Tn = (e) => {
|
|
1205
1264
|
const n = e.appVersion, t = e.userAgent, s = "-";
|
|
1206
1265
|
let o = s;
|
|
1207
1266
|
const i = [
|
|
@@ -1261,7 +1320,7 @@ const G = (e, n, t = null, s = null) => {
|
|
|
1261
1320
|
osVersion: r
|
|
1262
1321
|
};
|
|
1263
1322
|
};
|
|
1264
|
-
function
|
|
1323
|
+
function vn() {
|
|
1265
1324
|
const e = navigator.userAgent;
|
|
1266
1325
|
let n, t = e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
1267
1326
|
if (/trident/i.test(t[1]))
|
|
@@ -1279,13 +1338,13 @@ function kn() {
|
|
|
1279
1338
|
version: t[1]
|
|
1280
1339
|
};
|
|
1281
1340
|
}
|
|
1282
|
-
const
|
|
1283
|
-
const { name: e, version: n } =
|
|
1341
|
+
const En = () => {
|
|
1342
|
+
const { name: e, version: n } = vn();
|
|
1284
1343
|
if (e === "chrome" && parseInt(n) <= 70 || e === "opera" && (!n || parseInt(n.split(".")[0]) < 80) || e === "ie")
|
|
1285
1344
|
return !1;
|
|
1286
|
-
const t =
|
|
1287
|
-
return !
|
|
1288
|
-
},
|
|
1345
|
+
const t = Tn(navigator);
|
|
1346
|
+
return !Sn(t);
|
|
1347
|
+
}, On = async (e) => {
|
|
1289
1348
|
let n;
|
|
1290
1349
|
if (e.tokens != null)
|
|
1291
1350
|
return !1;
|
|
@@ -1295,7 +1354,7 @@ const mn = () => {
|
|
|
1295
1354
|
t.authority,
|
|
1296
1355
|
t.authority_configuration
|
|
1297
1356
|
);
|
|
1298
|
-
if (n = await
|
|
1357
|
+
if (n = await W(t, e.configurationName), n) {
|
|
1299
1358
|
const { tokens: o } = await n.initAsync(
|
|
1300
1359
|
s,
|
|
1301
1360
|
"tryKeepExistingSessionAsync",
|
|
@@ -1304,7 +1363,7 @@ const mn = () => {
|
|
|
1304
1363
|
if (o) {
|
|
1305
1364
|
n.startKeepAliveServiceWorker(), e.tokens = o;
|
|
1306
1365
|
const i = n.getLoginParams(e.configurationName);
|
|
1307
|
-
e.timeoutId =
|
|
1366
|
+
e.timeoutId = X(
|
|
1308
1367
|
e,
|
|
1309
1368
|
e.tokens.expiresAt,
|
|
1310
1369
|
i.extras,
|
|
@@ -1328,15 +1387,15 @@ const mn = () => {
|
|
|
1328
1387
|
t.service_worker_relative_url && e.publishEvent(k.service_worker_not_supported_by_browser, {
|
|
1329
1388
|
message: "service worker is not supported by this browser"
|
|
1330
1389
|
});
|
|
1331
|
-
const o =
|
|
1390
|
+
const o = x(
|
|
1332
1391
|
e.configurationName,
|
|
1333
1392
|
t.storage ?? sessionStorage,
|
|
1334
1393
|
t.login_state_storage ?? t.storage ?? sessionStorage
|
|
1335
1394
|
), { tokens: i } = await o.initAsync();
|
|
1336
1395
|
if (i) {
|
|
1337
|
-
e.tokens =
|
|
1396
|
+
e.tokens = de(i, null, t.token_renew_mode);
|
|
1338
1397
|
const r = o.getLoginParams();
|
|
1339
|
-
e.timeoutId =
|
|
1398
|
+
e.timeoutId = X(
|
|
1340
1399
|
e,
|
|
1341
1400
|
e.tokens.expiresAt,
|
|
1342
1401
|
r.extras,
|
|
@@ -1363,7 +1422,7 @@ const mn = () => {
|
|
|
1363
1422
|
"tokens inside ServiceWorker are invalid"
|
|
1364
1423
|
), !1;
|
|
1365
1424
|
}
|
|
1366
|
-
},
|
|
1425
|
+
}, Ue = (e) => {
|
|
1367
1426
|
const n = e.match(
|
|
1368
1427
|
// eslint-disable-next-line no-useless-escape
|
|
1369
1428
|
/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/
|
|
@@ -1385,35 +1444,35 @@ const mn = () => {
|
|
|
1385
1444
|
search: t,
|
|
1386
1445
|
hash: s
|
|
1387
1446
|
};
|
|
1388
|
-
},
|
|
1389
|
-
const n =
|
|
1447
|
+
}, Kn = (e) => {
|
|
1448
|
+
const n = Ue(e);
|
|
1390
1449
|
let { path: t } = n;
|
|
1391
1450
|
t.endsWith("/") && (t = t.slice(0, -1));
|
|
1392
1451
|
let { hash: s } = n;
|
|
1393
1452
|
return s === "#_=_" && (s = ""), s && (t += s), t;
|
|
1394
|
-
},
|
|
1395
|
-
const n =
|
|
1396
|
-
return
|
|
1397
|
-
},
|
|
1453
|
+
}, _e = (e) => {
|
|
1454
|
+
const n = Ue(e), { search: t } = n;
|
|
1455
|
+
return bn(t);
|
|
1456
|
+
}, bn = (e) => {
|
|
1398
1457
|
const n = {};
|
|
1399
1458
|
let t, s, o;
|
|
1400
1459
|
const i = e.split("&");
|
|
1401
1460
|
for (s = 0, o = i.length; s < o; s++)
|
|
1402
1461
|
t = i[s].split("="), n[decodeURIComponent(t[0])] = decodeURIComponent(t[1]);
|
|
1403
1462
|
return n;
|
|
1404
|
-
},
|
|
1463
|
+
}, Pn = (e, n, t, s, o) => (i = void 0, r = null, a = !1, c = void 0) => {
|
|
1405
1464
|
const f = r;
|
|
1406
1465
|
return r = { ...r }, (async () => {
|
|
1407
1466
|
const l = i || o.getPath();
|
|
1408
|
-
if ("state" in r || (r.state =
|
|
1467
|
+
if ("state" in r || (r.state = le(16)), t(k.loginAsync_begin, {}), r)
|
|
1409
1468
|
for (const h of Object.keys(r))
|
|
1410
1469
|
h.endsWith(":token_request") && delete r[h];
|
|
1411
1470
|
try {
|
|
1412
1471
|
const h = a ? n.silent_redirect_uri : n.redirect_uri;
|
|
1413
1472
|
c || (c = n.scope);
|
|
1414
1473
|
const _ = n.extras ? { ...n.extras, ...r } : r;
|
|
1415
|
-
_.nonce || (_.nonce =
|
|
1416
|
-
const m = { nonce: _.nonce }, p = await
|
|
1474
|
+
_.nonce || (_.nonce = le(12));
|
|
1475
|
+
const m = { nonce: _.nonce }, p = await W(n, e), g = await s(
|
|
1417
1476
|
n.authority,
|
|
1418
1477
|
n.authority_configuration
|
|
1419
1478
|
);
|
|
@@ -1421,12 +1480,12 @@ const mn = () => {
|
|
|
1421
1480
|
if (p)
|
|
1422
1481
|
p.setLoginParams({ callbackPath: l, extras: f, scope: c }), await p.initAsync(g, "loginAsync", n), await p.setNonceAsync(m), p.startKeepAliveServiceWorker(), y = p;
|
|
1423
1482
|
else {
|
|
1424
|
-
const
|
|
1483
|
+
const T = x(
|
|
1425
1484
|
e,
|
|
1426
1485
|
n.storage ?? sessionStorage,
|
|
1427
1486
|
n.login_state_storage ?? n.storage ?? sessionStorage
|
|
1428
1487
|
);
|
|
1429
|
-
|
|
1488
|
+
T.setLoginParams({ callbackPath: l, extras: f, scope: c }), await T.setNonceAsync(m), y = T;
|
|
1430
1489
|
}
|
|
1431
1490
|
const A = {
|
|
1432
1491
|
client_id: n.client_id,
|
|
@@ -1435,7 +1494,7 @@ const mn = () => {
|
|
|
1435
1494
|
response_type: "code",
|
|
1436
1495
|
..._
|
|
1437
1496
|
};
|
|
1438
|
-
await
|
|
1497
|
+
await mn(y, o)(
|
|
1439
1498
|
g.authorizationEndpoint,
|
|
1440
1499
|
A
|
|
1441
1500
|
);
|
|
@@ -1443,23 +1502,23 @@ const mn = () => {
|
|
|
1443
1502
|
throw t(k.loginAsync_error, h), h;
|
|
1444
1503
|
}
|
|
1445
1504
|
})();
|
|
1446
|
-
},
|
|
1505
|
+
}, In = (e) => async (n = !1) => {
|
|
1447
1506
|
try {
|
|
1448
1507
|
e.publishEvent(k.loginCallbackAsync_begin, {});
|
|
1449
1508
|
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(
|
|
1450
1509
|
i,
|
|
1451
1510
|
t.authority_configuration
|
|
1452
|
-
), c = e.location.getCurrentHref(), f =
|
|
1511
|
+
), c = e.location.getCurrentHref(), f = _e(c), u = f.session_state, l = await W(t, e.configurationName);
|
|
1453
1512
|
let h, _, m, p;
|
|
1454
1513
|
if (l)
|
|
1455
1514
|
await l.initAsync(a, "loginCallbackAsync", t), await l.setSessionStateAsync(u), _ = await l.getNonceAsync(), m = l.getLoginParams(), p = await l.getStateAsync(), l.startKeepAliveServiceWorker(), h = l;
|
|
1456
1515
|
else {
|
|
1457
|
-
const
|
|
1516
|
+
const E = x(
|
|
1458
1517
|
e.configurationName,
|
|
1459
1518
|
t.storage ?? sessionStorage,
|
|
1460
1519
|
t.login_state_storage ?? t.storage ?? sessionStorage
|
|
1461
1520
|
);
|
|
1462
|
-
await
|
|
1521
|
+
await E.setSessionStateAsync(u), _ = await E.getNonceAsync(), m = E.getLoginParams(), p = await E.getStateAsync(), h = E;
|
|
1463
1522
|
}
|
|
1464
1523
|
if (f.error || f.error_description)
|
|
1465
1524
|
throw new Error(
|
|
@@ -1478,66 +1537,66 @@ const mn = () => {
|
|
|
1478
1537
|
redirect_uri: o
|
|
1479
1538
|
}, y = {};
|
|
1480
1539
|
if (t.token_request_extras)
|
|
1481
|
-
for (const [
|
|
1482
|
-
y[
|
|
1540
|
+
for (const [E, d] of Object.entries(t.token_request_extras))
|
|
1541
|
+
y[E] = d;
|
|
1483
1542
|
if (m?.extras)
|
|
1484
|
-
for (const [
|
|
1485
|
-
|
|
1486
|
-
const A = a.tokenEndpoint,
|
|
1543
|
+
for (const [E, d] of Object.entries(m.extras))
|
|
1544
|
+
E.endsWith(":token_request") && (y[E.replace(":token_request", "")] = d);
|
|
1545
|
+
const A = a.tokenEndpoint, T = {};
|
|
1487
1546
|
if (t.demonstrating_proof_of_possession)
|
|
1488
1547
|
if (l)
|
|
1489
|
-
|
|
1548
|
+
T.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${e.configurationName}`;
|
|
1490
1549
|
else {
|
|
1491
|
-
const
|
|
1550
|
+
const E = await un(window)(
|
|
1492
1551
|
t.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm
|
|
1493
1552
|
);
|
|
1494
|
-
await
|
|
1553
|
+
await x(
|
|
1495
1554
|
e.configurationName,
|
|
1496
1555
|
t.storage,
|
|
1497
1556
|
t.login_state_storage ?? t.storage
|
|
1498
|
-
).setDemonstratingProofOfPossessionJwkAsync(
|
|
1557
|
+
).setDemonstratingProofOfPossessionJwkAsync(E), T.DPoP = await De(window)(
|
|
1499
1558
|
t.demonstrating_proof_of_possession_configuration
|
|
1500
|
-
)(
|
|
1559
|
+
)(E, "POST", A);
|
|
1501
1560
|
}
|
|
1502
|
-
const O = await
|
|
1561
|
+
const O = await wn(h)(
|
|
1503
1562
|
A,
|
|
1504
1563
|
{ ...g, ...y },
|
|
1505
|
-
|
|
1564
|
+
T,
|
|
1506
1565
|
e.configuration.token_renew_mode,
|
|
1507
1566
|
r
|
|
1508
1567
|
);
|
|
1509
1568
|
if (!O.success)
|
|
1510
1569
|
throw new Error("Token request failed");
|
|
1511
|
-
let
|
|
1512
|
-
const
|
|
1570
|
+
let v;
|
|
1571
|
+
const C = O.data.tokens, w = O.data.demonstratingProofOfPossessionNonce;
|
|
1513
1572
|
if (O.data.state !== y.state)
|
|
1514
1573
|
throw new Error("state is not valid");
|
|
1515
|
-
const { isValid:
|
|
1516
|
-
|
|
1574
|
+
const { isValid: H, reason: $ } = Ne(
|
|
1575
|
+
C,
|
|
1517
1576
|
_.nonce,
|
|
1518
1577
|
a
|
|
1519
1578
|
);
|
|
1520
|
-
if (!
|
|
1521
|
-
throw new Error(`Tokens are not OpenID valid, reason: ${
|
|
1579
|
+
if (!H)
|
|
1580
|
+
throw new Error(`Tokens are not OpenID valid, reason: ${$}`);
|
|
1522
1581
|
if (l) {
|
|
1523
|
-
if (
|
|
1582
|
+
if (C.refreshToken && !C.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))
|
|
1524
1583
|
throw new Error("Refresh token should be hidden by service worker");
|
|
1525
|
-
if (w &&
|
|
1584
|
+
if (w && C?.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))
|
|
1526
1585
|
throw new Error(
|
|
1527
1586
|
"Demonstration of proof of possession require Access token not hidden by service worker"
|
|
1528
1587
|
);
|
|
1529
1588
|
}
|
|
1530
1589
|
if (l)
|
|
1531
|
-
await l.initAsync(a, "syncTokensAsync", t),
|
|
1590
|
+
await l.initAsync(a, "syncTokensAsync", t), v = l.getLoginParams(), w && await l.setDemonstratingProofOfPossessionNonce(
|
|
1532
1591
|
w
|
|
1533
1592
|
);
|
|
1534
1593
|
else {
|
|
1535
|
-
const
|
|
1594
|
+
const E = x(
|
|
1536
1595
|
e.configurationName,
|
|
1537
1596
|
t.storage,
|
|
1538
1597
|
t.login_state_storage ?? t.storage
|
|
1539
1598
|
);
|
|
1540
|
-
|
|
1599
|
+
v = E.getLoginParams(), w && await E.setDemonstratingProofOfPossessionNonce(w);
|
|
1541
1600
|
}
|
|
1542
1601
|
return await e.startCheckSessionAsync(
|
|
1543
1602
|
a.checkSessionIframe,
|
|
@@ -1545,19 +1604,19 @@ const mn = () => {
|
|
|
1545
1604
|
u,
|
|
1546
1605
|
n
|
|
1547
1606
|
), e.publishEvent(k.loginCallbackAsync_end, {}), {
|
|
1548
|
-
tokens:
|
|
1607
|
+
tokens: C,
|
|
1549
1608
|
state: "request.state",
|
|
1550
|
-
callbackPath:
|
|
1609
|
+
callbackPath: v.callbackPath,
|
|
1551
1610
|
scope: f.scope,
|
|
1552
|
-
extras:
|
|
1611
|
+
extras: v.extras
|
|
1553
1612
|
};
|
|
1554
1613
|
} catch (t) {
|
|
1555
1614
|
throw console.error(t), e.publishEvent(k.loginCallbackAsync_error, t), t;
|
|
1556
1615
|
}
|
|
1557
|
-
},
|
|
1616
|
+
}, Pe = {
|
|
1558
1617
|
access_token: "access_token",
|
|
1559
1618
|
refresh_token: "refresh_token"
|
|
1560
|
-
},
|
|
1619
|
+
}, ie = (e, n) => {
|
|
1561
1620
|
const t = {};
|
|
1562
1621
|
if (e) {
|
|
1563
1622
|
for (const [s, o] of Object.entries(e))
|
|
@@ -1568,7 +1627,7 @@ const mn = () => {
|
|
|
1568
1627
|
return t;
|
|
1569
1628
|
}
|
|
1570
1629
|
return t;
|
|
1571
|
-
},
|
|
1630
|
+
}, Cn = (e) => {
|
|
1572
1631
|
const n = {};
|
|
1573
1632
|
if (e) {
|
|
1574
1633
|
for (const [t, s] of Object.entries(e))
|
|
@@ -1576,15 +1635,15 @@ const mn = () => {
|
|
|
1576
1635
|
return n;
|
|
1577
1636
|
}
|
|
1578
1637
|
return n;
|
|
1579
|
-
},
|
|
1580
|
-
|
|
1581
|
-
const t = await
|
|
1582
|
-
t ? await t.clearAsync(n) : await
|
|
1638
|
+
}, Nn = (e) => async (n) => {
|
|
1639
|
+
R.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
1640
|
+
const t = await W(e.configuration, e.configurationName);
|
|
1641
|
+
t ? await t.clearAsync(n) : await x(
|
|
1583
1642
|
e.configurationName,
|
|
1584
1643
|
e.configuration.storage,
|
|
1585
1644
|
e.configuration.login_state_storage ?? e.configuration.storage
|
|
1586
1645
|
).clearAsync(n), e.tokens = null, e.userInfo = null;
|
|
1587
|
-
},
|
|
1646
|
+
}, xn = (e, n, t, s, o) => async (i = void 0, r = null) => {
|
|
1588
1647
|
const a = e.configuration, c = await e.initAsync(
|
|
1589
1648
|
a.authority,
|
|
1590
1649
|
a.authority_configuration
|
|
@@ -1597,27 +1656,27 @@ const mn = () => {
|
|
|
1597
1656
|
try {
|
|
1598
1657
|
const y = c.revocationEndpoint;
|
|
1599
1658
|
if (y) {
|
|
1600
|
-
const A = [],
|
|
1601
|
-
if (
|
|
1602
|
-
const
|
|
1659
|
+
const A = [], T = e.tokens ? e.tokens.accessToken : null;
|
|
1660
|
+
if (T && a.logout_tokens_to_invalidate.includes(Pe.access_token)) {
|
|
1661
|
+
const v = ie(r, ":revoke_access_token"), C = Oe(t)(
|
|
1603
1662
|
y,
|
|
1604
|
-
|
|
1605
|
-
|
|
1663
|
+
T,
|
|
1664
|
+
ue.access_token,
|
|
1606
1665
|
a.client_id,
|
|
1607
|
-
|
|
1666
|
+
v
|
|
1608
1667
|
);
|
|
1609
|
-
A.push(
|
|
1668
|
+
A.push(C);
|
|
1610
1669
|
}
|
|
1611
1670
|
const O = e.tokens ? e.tokens.refreshToken : null;
|
|
1612
|
-
if (O && a.logout_tokens_to_invalidate.includes(
|
|
1613
|
-
const
|
|
1671
|
+
if (O && a.logout_tokens_to_invalidate.includes(Pe.refresh_token)) {
|
|
1672
|
+
const v = ie(r, ":revoke_refresh_token"), C = Oe(t)(
|
|
1614
1673
|
y,
|
|
1615
1674
|
O,
|
|
1616
|
-
|
|
1675
|
+
ue.refresh_token,
|
|
1617
1676
|
a.client_id,
|
|
1618
|
-
|
|
1677
|
+
v
|
|
1619
1678
|
);
|
|
1620
|
-
A.push(
|
|
1679
|
+
A.push(C);
|
|
1621
1680
|
}
|
|
1622
1681
|
A.length > 0 && await Promise.all(A);
|
|
1623
1682
|
}
|
|
@@ -1630,19 +1689,19 @@ const mn = () => {
|
|
|
1630
1689
|
await e.destroyAsync("LOGGED_OUT");
|
|
1631
1690
|
for (const [, y] of Object.entries(n))
|
|
1632
1691
|
y !== e ? await e.logoutSameTabAsync(e.configuration.client_id, _) : e.publishEvent(k.logout_from_same_tab, {});
|
|
1633
|
-
const m =
|
|
1692
|
+
const m = ie(r, ":oidc");
|
|
1634
1693
|
if (m && m.no_reload === "true")
|
|
1635
1694
|
return;
|
|
1636
|
-
const g =
|
|
1695
|
+
const g = Cn(r);
|
|
1637
1696
|
if (c.endSessionEndpoint) {
|
|
1638
1697
|
"id_token_hint" in g || (g.id_token_hint = h), !("post_logout_redirect_uri" in g) && i !== null && (g.post_logout_redirect_uri = l);
|
|
1639
1698
|
let y = "";
|
|
1640
|
-
for (const [A,
|
|
1641
|
-
|
|
1699
|
+
for (const [A, T] of Object.entries(g))
|
|
1700
|
+
T != null && (y === "" ? y += "?" : y += "&", y += `${A}=${encodeURIComponent(T)}`);
|
|
1642
1701
|
o.open(`${c.endSessionEndpoint}${y}`);
|
|
1643
1702
|
} else
|
|
1644
1703
|
o.reload();
|
|
1645
|
-
},
|
|
1704
|
+
}, Ve = (e, n, t = !1) => async (...s) => {
|
|
1646
1705
|
const [o, i, ...r] = s, a = i ? { ...i } : { method: "GET" };
|
|
1647
1706
|
let c = new Headers();
|
|
1648
1707
|
a.headers && (c = a.headers instanceof Headers ? a.headers : new Headers(a.headers));
|
|
@@ -1653,7 +1712,7 @@ const mn = () => {
|
|
|
1653
1712
|
refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
|
|
1654
1713
|
},
|
|
1655
1714
|
syncTokensInfoAsync: async () => {
|
|
1656
|
-
const { status: _ } = await
|
|
1715
|
+
const { status: _ } = await me(n)(
|
|
1657
1716
|
n.configuration,
|
|
1658
1717
|
n.configurationName,
|
|
1659
1718
|
n.tokens,
|
|
@@ -1662,7 +1721,7 @@ const mn = () => {
|
|
|
1662
1721
|
return _;
|
|
1663
1722
|
},
|
|
1664
1723
|
renewTokensAsync: n.renewTokensAsync.bind(n)
|
|
1665
|
-
}, l = (await
|
|
1724
|
+
}, l = (await Ce(f))?.tokens?.accessToken;
|
|
1666
1725
|
if (c.has("Accept") || c.set("Accept", "application/json"), l) {
|
|
1667
1726
|
if (n.configuration.demonstrating_proof_of_possession && t) {
|
|
1668
1727
|
const _ = await n.generateDemonstrationOfProofOfPossessionAsync(
|
|
@@ -1677,7 +1736,7 @@ const mn = () => {
|
|
|
1677
1736
|
}
|
|
1678
1737
|
const h = { ...a, headers: c };
|
|
1679
1738
|
return await e(o, h, ...r);
|
|
1680
|
-
},
|
|
1739
|
+
}, Wn = (e) => async (n = !1, t = !1) => {
|
|
1681
1740
|
if (e.userInfo != null && !n)
|
|
1682
1741
|
return e.userInfo;
|
|
1683
1742
|
const s = !n && e.configuration.storage?.getItem(`oidc.${e.configurationName}.userInfo`);
|
|
@@ -1687,49 +1746,49 @@ const mn = () => {
|
|
|
1687
1746
|
o.authority,
|
|
1688
1747
|
o.authority_configuration
|
|
1689
1748
|
)).userInfoEndpoint, c = await (async () => {
|
|
1690
|
-
const u = await
|
|
1749
|
+
const u = await Ve(fetch, e, t)(r);
|
|
1691
1750
|
return u.status !== 200 ? null : u.json();
|
|
1692
1751
|
})();
|
|
1693
1752
|
return e.userInfo = c, c && e.configuration.storage?.setItem(
|
|
1694
1753
|
`oidc.${e.configurationName}.userInfo`,
|
|
1695
1754
|
JSON.stringify(c)
|
|
1696
1755
|
), c;
|
|
1697
|
-
},
|
|
1698
|
-
class
|
|
1756
|
+
}, Ln = () => fetch;
|
|
1757
|
+
class fe {
|
|
1699
1758
|
constructor(n) {
|
|
1700
1759
|
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;
|
|
1701
1760
|
}
|
|
1702
1761
|
}
|
|
1703
|
-
const
|
|
1762
|
+
const V = {}, Dn = (e, n = new ee()) => (t, s = "default") => (V[s] || (V[s] = new D(t, s, e, n)), V[s]), Rn = async (e) => {
|
|
1704
1763
|
const { parsedTokens: n, callbackPath: t, extras: s, scope: o } = await e.loginCallbackAsync();
|
|
1705
|
-
return e.timeoutId =
|
|
1706
|
-
},
|
|
1707
|
-
constructor(n, t = "default", s, o = new
|
|
1764
|
+
return e.timeoutId = X(e, n.expiresAt, s, o), { callbackPath: t };
|
|
1765
|
+
}, $n = (e) => Math.floor(Math.random() * e), j = class j {
|
|
1766
|
+
constructor(n, t = "default", s, o = new ee()) {
|
|
1708
1767
|
this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.logoutPromise = null;
|
|
1709
1768
|
let i = n.silent_login_uri;
|
|
1710
1769
|
n.silent_redirect_uri && !n.silent_login_uri && (i = `${n.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
|
|
1711
1770
|
let r = n.refresh_time_before_tokens_expiration_in_second ?? 120;
|
|
1712
|
-
r > 60 && (r = r - Math.floor(Math.random() * 40)), this.location = o ?? new
|
|
1771
|
+
r > 60 && (r = r - Math.floor(Math.random() * 40)), this.location = o ?? new ee(), this.configuration = {
|
|
1713
1772
|
...n,
|
|
1714
1773
|
silent_login_uri: i,
|
|
1715
|
-
token_automatic_renew_mode: n.token_automatic_renew_mode ??
|
|
1774
|
+
token_automatic_renew_mode: n.token_automatic_renew_mode ?? q.AutomaticBeforeTokenExpiration,
|
|
1716
1775
|
monitor_session: n.monitor_session ?? !1,
|
|
1717
1776
|
refresh_time_before_tokens_expiration_in_second: r,
|
|
1718
1777
|
silent_login_timeout: n.silent_login_timeout ?? 12e3,
|
|
1719
|
-
token_renew_mode: n.token_renew_mode ??
|
|
1778
|
+
token_renew_mode: n.token_renew_mode ?? re.access_token_or_id_token_invalid,
|
|
1720
1779
|
demonstrating_proof_of_possession: n.demonstrating_proof_of_possession ?? !1,
|
|
1721
1780
|
authority_timeout_wellknowurl_in_millisecond: n.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
1722
1781
|
logout_tokens_to_invalidate: n.logout_tokens_to_invalidate ?? [
|
|
1723
1782
|
"access_token",
|
|
1724
1783
|
"refresh_token"
|
|
1725
1784
|
],
|
|
1726
|
-
service_worker_activate: n.service_worker_activate ??
|
|
1727
|
-
demonstrating_proof_of_possession_configuration: n.demonstrating_proof_of_possession_configuration ??
|
|
1785
|
+
service_worker_activate: n.service_worker_activate ?? En,
|
|
1786
|
+
demonstrating_proof_of_possession_configuration: n.demonstrating_proof_of_possession_configuration ?? nn,
|
|
1728
1787
|
preload_user_info: n.preload_user_info ?? !1
|
|
1729
|
-
}, this.getFetch = s ??
|
|
1788
|
+
}, this.getFetch = s ?? Ln, 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);
|
|
1730
1789
|
}
|
|
1731
1790
|
subscribeEvents(n) {
|
|
1732
|
-
const t =
|
|
1791
|
+
const t = $n(9999999999999).toString();
|
|
1733
1792
|
return this.events.push({ id: t, func: n }), t;
|
|
1734
1793
|
}
|
|
1735
1794
|
removeEventSubscription(n) {
|
|
@@ -1743,14 +1802,14 @@ const R = {}, Pn = (e, n = new Q()) => (t, s = "default") => (R[s] || (R[s] = ne
|
|
|
1743
1802
|
}
|
|
1744
1803
|
static get(n = "default") {
|
|
1745
1804
|
const t = typeof process > "u";
|
|
1746
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
1805
|
+
if (!Object.prototype.hasOwnProperty.call(V, n) && t)
|
|
1747
1806
|
throw Error(`OIDC library does seem initialized.
|
|
1748
1807
|
Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${n}"></OidcProvider> component.`);
|
|
1749
|
-
return
|
|
1808
|
+
return V[n];
|
|
1750
1809
|
}
|
|
1751
1810
|
_silentLoginCallbackFromIFrame() {
|
|
1752
1811
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1753
|
-
const n = this.location, t =
|
|
1812
|
+
const n = this.location, t = _e(n.getCurrentHref());
|
|
1754
1813
|
window.parent.postMessage(
|
|
1755
1814
|
`${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState: t.session_state })}`,
|
|
1756
1815
|
n.getOrigin()
|
|
@@ -1759,7 +1818,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1759
1818
|
}
|
|
1760
1819
|
_silentLoginErrorCallbackFromIFrame(n = null) {
|
|
1761
1820
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1762
|
-
const t = this.location, s =
|
|
1821
|
+
const t = this.location, s = _e(t.getCurrentHref());
|
|
1763
1822
|
s.error ? window.parent.postMessage(
|
|
1764
1823
|
`${this.configurationName}_oidc_error:${JSON.stringify({ error: s.error })}`,
|
|
1765
1824
|
t.getOrigin()
|
|
@@ -1781,7 +1840,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1781
1840
|
return this.initPromise;
|
|
1782
1841
|
const s = async () => {
|
|
1783
1842
|
if (t != null)
|
|
1784
|
-
return new
|
|
1843
|
+
return new fe({
|
|
1785
1844
|
authorization_endpoint: t.authorization_endpoint,
|
|
1786
1845
|
end_session_endpoint: t.end_session_endpoint,
|
|
1787
1846
|
revocation_endpoint: t.revocation_endpoint,
|
|
@@ -1790,8 +1849,8 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1790
1849
|
check_session_iframe: t.check_session_iframe,
|
|
1791
1850
|
issuer: t.issuer
|
|
1792
1851
|
});
|
|
1793
|
-
const i = await
|
|
1794
|
-
return await
|
|
1852
|
+
const i = await W(this.configuration, this.configurationName) ? this.configuration.storage || window.sessionStorage : this.configuration.storage;
|
|
1853
|
+
return await yn(this.getFetch())(
|
|
1795
1854
|
n,
|
|
1796
1855
|
this.configuration.authority_time_cache_wellknowurl_in_second ?? 3600,
|
|
1797
1856
|
i,
|
|
@@ -1803,12 +1862,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1803
1862
|
});
|
|
1804
1863
|
}
|
|
1805
1864
|
async tryKeepExistingSessionAsync() {
|
|
1806
|
-
return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise =
|
|
1865
|
+
return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise = On(this), this.tryKeepExistingSessionPromise.finally(() => {
|
|
1807
1866
|
this.tryKeepExistingSessionPromise = null;
|
|
1808
1867
|
}));
|
|
1809
1868
|
}
|
|
1810
1869
|
async startCheckSessionAsync(n, t, s, o = !1) {
|
|
1811
|
-
await
|
|
1870
|
+
await An(this, V, this.configuration)(
|
|
1812
1871
|
n,
|
|
1813
1872
|
t,
|
|
1814
1873
|
s,
|
|
@@ -1816,13 +1875,13 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1816
1875
|
);
|
|
1817
1876
|
}
|
|
1818
1877
|
async loginAsync(n = void 0, t = null, s = !1, o = void 0, i = !1) {
|
|
1819
|
-
return this.logoutPromise && await this.logoutPromise, this.loginPromise !== null ? this.loginPromise : (i ? this.loginPromise =
|
|
1878
|
+
return this.logoutPromise && await this.logoutPromise, this.loginPromise !== null ? this.loginPromise : (i ? this.loginPromise = pn(
|
|
1820
1879
|
window,
|
|
1821
1880
|
this.configurationName,
|
|
1822
1881
|
this.configuration,
|
|
1823
1882
|
this.publishEvent.bind(this),
|
|
1824
1883
|
this
|
|
1825
|
-
)(t, o) : this.loginPromise =
|
|
1884
|
+
)(t, o) : this.loginPromise = Pn(
|
|
1826
1885
|
this.configurationName,
|
|
1827
1886
|
this.configuration,
|
|
1828
1887
|
this.publishEvent.bind(this),
|
|
@@ -1836,12 +1895,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1836
1895
|
if (this.loginCallbackPromise !== null)
|
|
1837
1896
|
return this.loginCallbackPromise;
|
|
1838
1897
|
const t = async () => {
|
|
1839
|
-
const s = await
|
|
1840
|
-
return this.tokens = o, await
|
|
1898
|
+
const s = await In(this)(n), o = s.tokens;
|
|
1899
|
+
return this.tokens = o, await W(this.configuration, this.configurationName) || x(
|
|
1841
1900
|
this.configurationName,
|
|
1842
1901
|
this.configuration.storage,
|
|
1843
1902
|
this.configuration.login_state_storage ?? this.configuration.storage
|
|
1844
|
-
).setTokens(o), this.publishEvent(
|
|
1903
|
+
).setTokens(o), this.publishEvent(j.eventNames.token_acquired, o), this.configuration.preload_user_info && await this.userInfoAsync(), {
|
|
1845
1904
|
parsedTokens: o,
|
|
1846
1905
|
state: s.state,
|
|
1847
1906
|
callbackPath: s.callbackPath,
|
|
@@ -1855,27 +1914,27 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1855
1914
|
}
|
|
1856
1915
|
async generateDemonstrationOfProofOfPossessionAsync(n, t, s, o = {}) {
|
|
1857
1916
|
const i = this.configuration, r = {
|
|
1858
|
-
ath: await
|
|
1917
|
+
ath: await $e(n),
|
|
1859
1918
|
...o
|
|
1860
1919
|
};
|
|
1861
|
-
if (await
|
|
1862
|
-
return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${
|
|
1863
|
-
const c =
|
|
1920
|
+
if (await W(i, this.configurationName))
|
|
1921
|
+
return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${he(this.configurationName)}`;
|
|
1922
|
+
const c = x(
|
|
1864
1923
|
this.configurationName,
|
|
1865
1924
|
i.storage,
|
|
1866
1925
|
i.login_state_storage ?? i.storage
|
|
1867
1926
|
), f = await c.getDemonstratingProofOfPossessionJwkAsync(), u = c.getDemonstratingProofOfPossessionNonce();
|
|
1868
|
-
return u && (r.nonce = u), await
|
|
1927
|
+
return u && (r.nonce = u), await De(window)(
|
|
1869
1928
|
i.demonstrating_proof_of_possession_configuration
|
|
1870
1929
|
)(f, s, t, r);
|
|
1871
1930
|
}
|
|
1872
1931
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1873
|
-
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1932
|
+
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise = Rn(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
|
|
1874
1933
|
this.loginCallbackWithAutoTokensRenewPromise = null;
|
|
1875
1934
|
}));
|
|
1876
1935
|
}
|
|
1877
1936
|
userInfoAsync(n = !1, t = !1) {
|
|
1878
|
-
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise =
|
|
1937
|
+
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise = Wn(this)(n, t), this.userInfoPromise.finally(() => {
|
|
1879
1938
|
this.userInfoPromise = null;
|
|
1880
1939
|
}));
|
|
1881
1940
|
}
|
|
@@ -1883,12 +1942,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1883
1942
|
if (this.renewTokensPromise !== null)
|
|
1884
1943
|
return this.renewTokensPromise;
|
|
1885
1944
|
if (this.timeoutId)
|
|
1886
|
-
return
|
|
1945
|
+
return R.clearTimeout(this.timeoutId), this.renewTokensPromise = Ke(this, !0, n, t), this.renewTokensPromise.finally(() => {
|
|
1887
1946
|
this.renewTokensPromise = null;
|
|
1888
1947
|
});
|
|
1889
1948
|
}
|
|
1890
1949
|
async destroyAsync(n) {
|
|
1891
|
-
return await
|
|
1950
|
+
return await Nn(this)(n);
|
|
1892
1951
|
}
|
|
1893
1952
|
async logoutSameTabAsync(n, t) {
|
|
1894
1953
|
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 }));
|
|
@@ -1897,9 +1956,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1897
1956
|
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 }));
|
|
1898
1957
|
}
|
|
1899
1958
|
async logoutAsync(n = void 0, t = null) {
|
|
1900
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1959
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = xn(
|
|
1901
1960
|
this,
|
|
1902
|
-
|
|
1961
|
+
V,
|
|
1903
1962
|
this.getFetch(),
|
|
1904
1963
|
console,
|
|
1905
1964
|
this.location
|
|
@@ -1908,9 +1967,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1908
1967
|
}));
|
|
1909
1968
|
}
|
|
1910
1969
|
};
|
|
1911
|
-
|
|
1912
|
-
let
|
|
1913
|
-
const
|
|
1970
|
+
j.getOrCreate = (n, t) => (s, o = "default") => Dn(n, t)(s, o), j.eventNames = k;
|
|
1971
|
+
let D = j;
|
|
1972
|
+
const J = class J {
|
|
1914
1973
|
constructor(n) {
|
|
1915
1974
|
this._oidc = n;
|
|
1916
1975
|
}
|
|
@@ -1924,7 +1983,7 @@ const V = class V {
|
|
|
1924
1983
|
this._oidc.publishEvent(n, t);
|
|
1925
1984
|
}
|
|
1926
1985
|
static get(n = "default") {
|
|
1927
|
-
return new
|
|
1986
|
+
return new J(D.get(n));
|
|
1928
1987
|
}
|
|
1929
1988
|
tryKeepExistingSessionAsync() {
|
|
1930
1989
|
return this._oidc.tryKeepExistingSessionAsync();
|
|
@@ -1966,7 +2025,7 @@ const V = class V {
|
|
|
1966
2025
|
refresh_time_before_tokens_expiration_in_second: s.configuration.refresh_time_before_tokens_expiration_in_second
|
|
1967
2026
|
},
|
|
1968
2027
|
syncTokensInfoAsync: async () => {
|
|
1969
|
-
const { status: i } = await
|
|
2028
|
+
const { status: i } = await me(s)(
|
|
1970
2029
|
s.configuration,
|
|
1971
2030
|
s.configurationName,
|
|
1972
2031
|
s.tokens,
|
|
@@ -1976,10 +2035,10 @@ const V = class V {
|
|
|
1976
2035
|
},
|
|
1977
2036
|
renewTokensAsync: s.renewTokensAsync.bind(s)
|
|
1978
2037
|
};
|
|
1979
|
-
return
|
|
2038
|
+
return Ce(o, n, t);
|
|
1980
2039
|
}
|
|
1981
2040
|
fetchWithTokens(n, t = !1) {
|
|
1982
|
-
return
|
|
2041
|
+
return Ve(n, this._oidc, t);
|
|
1983
2042
|
}
|
|
1984
2043
|
async userInfoAsync(n = !1, t = !1) {
|
|
1985
2044
|
return this._oidc.userInfoAsync(n, t);
|
|
@@ -1988,14 +2047,14 @@ const V = class V {
|
|
|
1988
2047
|
return this._oidc.userInfo;
|
|
1989
2048
|
}
|
|
1990
2049
|
};
|
|
1991
|
-
|
|
1992
|
-
let
|
|
2050
|
+
J.getOrCreate = (n, t = new ee()) => (s, o = "default") => new J(D.getOrCreate(n, t)(s, o)), J.eventNames = D.eventNames;
|
|
2051
|
+
let Ie = J;
|
|
1993
2052
|
export {
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2053
|
+
Ie as OidcClient,
|
|
2054
|
+
ee as OidcLocation,
|
|
2055
|
+
q as TokenAutomaticRenewMode,
|
|
2056
|
+
re as TokenRenewMode,
|
|
2057
|
+
Ln as getFetchDefault,
|
|
2058
|
+
_e as getParseQueryStringFromLocation,
|
|
2059
|
+
Kn as getPath
|
|
2001
2060
|
};
|