@gen-epix/ui-client-common 4.3.0 → 4.3.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/_chunks/Breadcrumbs.js +22 -22
- package/dist/_chunks/Table.js +559 -3173
- package/dist/_chunks/Table.js.map +1 -1
- package/dist/_chunks/{oidc-client-ts.js → UserManagerUtil.js} +222 -198
- package/dist/_chunks/UserManagerUtil.js.map +1 -0
- package/dist/_chunks/middleware.js +1 -1
- package/dist/_chunks/middleware.js.map +1 -1
- package/dist/_chunks/omit.js +1 -1
- package/dist/_chunks/omit.js.map +1 -1
- package/dist/_chunks/react.js +1 -1
- package/dist/_chunks/react.js.map +1 -1
- package/dist/_chunks/useColumnsMenu.js +2 -2
- package/dist/_chunks/useColumnsMenu.js.map +1 -1
- package/dist/_chunks/useQueryMemo.js +1 -1
- package/dist/_chunks/useQueryMemo.js.map +1 -1
- package/dist/_chunks/vanilla.js +1 -1
- package/dist/_chunks/vanilla.js.map +1 -1
- package/dist/_chunks/yup.js +2 -2
- package/dist/_chunks/yup.js.map +1 -1
- package/dist/classes/services/LogService/index.js +1 -1
- package/dist/classes/services/LogService/index.js.map +1 -1
- package/dist/classes/services/RouterService/index.js +4 -4
- package/dist/components/app/App/index.js +35 -100
- package/dist/components/app/App/index.js.map +1 -1
- package/dist/components/app/AuthenticationWrapper/index.js +38 -38
- package/dist/components/app/AuthorizationWrapper/index.js +20 -20
- package/dist/components/app/RouterRoot/index.js +58 -59
- package/dist/components/app/RouterRoot/index.js.map +1 -1
- package/dist/components/ui/ApplicationBar/index.js +146 -146
- package/dist/components/ui/ApplicationBar/index.js.map +1 -1
- package/dist/components/ui/GenericErrorMessage/index.js +34 -34
- package/dist/components/ui/GenericErrorMessage/index.js.map +1 -1
- package/dist/components/ui/NavLink/index.js +8 -8
- package/dist/components/ui/PageContainer/index.js +1 -1
- package/dist/components/ui/PageContainer/index.js.map +1 -1
- package/dist/pages/AcceptInvitationPage/index.js +28 -28
- package/dist/pages/AdminPage/index.js +23 -23
- package/dist/pages/OrganizationContactsAdminPage/index.js +29 -29
- package/dist/pages/OrganizationSitesAdminPage/index.js +25 -25
- package/dist/pages/PostLoginPage/index.js +11 -11
- package/dist/pages/RouterErrorPage/index.js +10 -10
- package/dist/utils/UserManagerUtil/index.js +2 -31
- package/package.json +13 -8
- package/dist/_chunks/chunk-OB3PAWPO.js +0 -3742
- package/dist/_chunks/chunk-OB3PAWPO.js.map +0 -1
- package/dist/_chunks/oidc-client-ts.js.map +0 -1
- package/dist/_chunks/react-oidc-context.js +0 -201
- package/dist/_chunks/react-oidc-context.js.map +0 -1
- package/dist/utils/UserManagerUtil/index.js.map +0 -1
|
@@ -1,85 +1,86 @@
|
|
|
1
|
+
import { WindowService as e } from "@gen-epix/ui-core/classes/services/WindowService";
|
|
1
2
|
//#region ../../node_modules/.pnpm/jwt-decode@4.0.0/node_modules/jwt-decode/build/esm/index.js
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
function
|
|
3
|
+
var t = class extends Error {};
|
|
4
|
+
t.prototype.name = "InvalidTokenError";
|
|
5
|
+
function n(e) {
|
|
5
6
|
return decodeURIComponent(atob(e).replace(/(.)/g, (e, t) => {
|
|
6
7
|
let n = t.charCodeAt(0).toString(16).toUpperCase();
|
|
7
8
|
return n.length < 2 && (n = "0" + n), "%" + n;
|
|
8
9
|
}));
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
let
|
|
12
|
-
switch (
|
|
11
|
+
function r(e) {
|
|
12
|
+
let t = e.replace(/-/g, "+").replace(/_/g, "/");
|
|
13
|
+
switch (t.length % 4) {
|
|
13
14
|
case 0: break;
|
|
14
15
|
case 2:
|
|
15
|
-
|
|
16
|
+
t += "==";
|
|
16
17
|
break;
|
|
17
18
|
case 3:
|
|
18
|
-
|
|
19
|
+
t += "=";
|
|
19
20
|
break;
|
|
20
21
|
default: throw Error("base64 string is not of the correct length");
|
|
21
22
|
}
|
|
22
23
|
try {
|
|
23
|
-
return t
|
|
24
|
+
return n(t);
|
|
24
25
|
} catch {
|
|
25
|
-
return atob(
|
|
26
|
+
return atob(t);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
-
if (typeof
|
|
30
|
-
|
|
31
|
-
let i =
|
|
32
|
-
if (typeof a != "string") throw new
|
|
29
|
+
function i(e, n) {
|
|
30
|
+
if (typeof e != "string") throw new t("Invalid token specified: must be a string");
|
|
31
|
+
n ||= {};
|
|
32
|
+
let i = n.header === !0 ? 0 : 1, a = e.split(".")[i];
|
|
33
|
+
if (typeof a != "string") throw new t(`Invalid token specified: missing part #${i + 1}`);
|
|
33
34
|
let o;
|
|
34
35
|
try {
|
|
35
|
-
o =
|
|
36
|
-
} catch (
|
|
37
|
-
throw new
|
|
36
|
+
o = r(a);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw new t(`Invalid token specified: invalid base64 for part #${i + 1} (${e.message})`);
|
|
38
39
|
}
|
|
39
40
|
try {
|
|
40
41
|
return JSON.parse(o);
|
|
41
|
-
} catch (
|
|
42
|
-
throw new
|
|
42
|
+
} catch (e) {
|
|
43
|
+
throw new t(`Invalid token specified: invalid json for part #${i + 1} (${e.message})`);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
//#endregion
|
|
46
47
|
//#region ../../node_modules/.pnpm/oidc-client-ts@3.5.0/node_modules/oidc-client-ts/dist/esm/oidc-client-ts.js
|
|
47
|
-
var
|
|
48
|
+
var a = {
|
|
48
49
|
debug: () => void 0,
|
|
49
50
|
info: () => void 0,
|
|
50
51
|
warn: () => void 0,
|
|
51
52
|
error: () => void 0
|
|
52
|
-
},
|
|
53
|
+
}, o, s, c = /* @__PURE__ */ ((e) => (e[e.NONE = 0] = "NONE", e[e.ERROR = 1] = "ERROR", e[e.WARN = 2] = "WARN", e[e.INFO = 3] = "INFO", e[e.DEBUG = 4] = "DEBUG", e))(c || {});
|
|
53
54
|
((e) => {
|
|
54
55
|
function t() {
|
|
55
|
-
|
|
56
|
+
o = 3, s = a;
|
|
56
57
|
}
|
|
57
58
|
e.reset = t;
|
|
58
59
|
function n(e) {
|
|
59
60
|
if (!(0 <= e && e <= 4)) throw Error("Invalid log level");
|
|
60
|
-
|
|
61
|
+
o = e;
|
|
61
62
|
}
|
|
62
63
|
e.setLevel = n;
|
|
63
64
|
function r(e) {
|
|
64
|
-
|
|
65
|
+
s = e;
|
|
65
66
|
}
|
|
66
67
|
e.setLogger = r;
|
|
67
|
-
})(
|
|
68
|
-
var
|
|
68
|
+
})(c ||= {});
|
|
69
|
+
var l = class e {
|
|
69
70
|
constructor(e) {
|
|
70
71
|
this._name = e;
|
|
71
72
|
}
|
|
72
73
|
debug(...t) {
|
|
73
|
-
|
|
74
|
+
o >= 4 && s.debug(e._format(this._name, this._method), ...t);
|
|
74
75
|
}
|
|
75
76
|
info(...t) {
|
|
76
|
-
|
|
77
|
+
o >= 3 && s.info(e._format(this._name, this._method), ...t);
|
|
77
78
|
}
|
|
78
79
|
warn(...t) {
|
|
79
|
-
|
|
80
|
+
o >= 2 && s.warn(e._format(this._name, this._method), ...t);
|
|
80
81
|
}
|
|
81
82
|
error(...t) {
|
|
82
|
-
|
|
83
|
+
o >= 1 && s.error(e._format(this._name, this._method), ...t);
|
|
83
84
|
}
|
|
84
85
|
throw(e) {
|
|
85
86
|
throw this.error(e), e;
|
|
@@ -97,45 +98,45 @@ var c = class e {
|
|
|
97
98
|
return t ? `${n} ${t}:` : n;
|
|
98
99
|
}
|
|
99
100
|
static debug(t, ...n) {
|
|
100
|
-
|
|
101
|
+
o >= 4 && s.debug(e._format(t), ...n);
|
|
101
102
|
}
|
|
102
103
|
static info(t, ...n) {
|
|
103
|
-
|
|
104
|
+
o >= 3 && s.info(e._format(t), ...n);
|
|
104
105
|
}
|
|
105
106
|
static warn(t, ...n) {
|
|
106
|
-
|
|
107
|
+
o >= 2 && s.warn(e._format(t), ...n);
|
|
107
108
|
}
|
|
108
109
|
static error(t, ...n) {
|
|
109
|
-
|
|
110
|
+
o >= 1 && s.error(e._format(t), ...n);
|
|
110
111
|
}
|
|
111
112
|
};
|
|
112
|
-
|
|
113
|
-
var
|
|
113
|
+
c.reset();
|
|
114
|
+
var u = class {
|
|
114
115
|
static decode(e) {
|
|
115
116
|
try {
|
|
116
|
-
return
|
|
117
|
+
return i(e);
|
|
117
118
|
} catch (e) {
|
|
118
|
-
throw
|
|
119
|
+
throw l.error("JwtUtils.decode", e), e;
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
static async generateSignedJwt(e, t, n) {
|
|
122
|
-
let r = `${
|
|
123
|
+
let r = `${m.encodeBase64Url(new TextEncoder().encode(JSON.stringify(e)))}.${m.encodeBase64Url(new TextEncoder().encode(JSON.stringify(t)))}`, i = await window.crypto.subtle.sign({
|
|
123
124
|
name: "ECDSA",
|
|
124
125
|
hash: { name: "SHA-256" }
|
|
125
126
|
}, n, new TextEncoder().encode(r));
|
|
126
|
-
return `${r}.${
|
|
127
|
+
return `${r}.${m.encodeBase64Url(new Uint8Array(i))}`;
|
|
127
128
|
}
|
|
128
129
|
static async generateSignedJwtWithHmac(e, t, n) {
|
|
129
|
-
let r = `${
|
|
130
|
-
return `${r}.${
|
|
130
|
+
let r = `${m.encodeBase64Url(new TextEncoder().encode(JSON.stringify(e)))}.${m.encodeBase64Url(new TextEncoder().encode(JSON.stringify(t)))}`, i = await window.crypto.subtle.sign("HMAC", n, new TextEncoder().encode(r));
|
|
131
|
+
return `${r}.${m.encodeBase64Url(new Uint8Array(i))}`;
|
|
131
132
|
}
|
|
132
|
-
},
|
|
133
|
+
}, d = "10000000-1000-4000-8000-100000000000", f = (e) => btoa([...new Uint8Array(e)].map((e) => String.fromCharCode(e)).join("")), p = class e {
|
|
133
134
|
static _randomWord() {
|
|
134
135
|
let e = /* @__PURE__ */ new Uint32Array(1);
|
|
135
136
|
return crypto.getRandomValues(e), e[0];
|
|
136
137
|
}
|
|
137
138
|
static generateUUIDv4() {
|
|
138
|
-
return
|
|
139
|
+
return d.replace(/[018]/g, (t) => (+t ^ e._randomWord() & 15 >> t / 4).toString(16)).replace(/-/g, "");
|
|
139
140
|
}
|
|
140
141
|
static generateCodeVerifier() {
|
|
141
142
|
return e.generateUUIDv4() + e.generateUUIDv4() + e.generateUUIDv4();
|
|
@@ -144,13 +145,13 @@ var l = class {
|
|
|
144
145
|
if (!crypto.subtle) throw Error("Crypto.subtle is available only in secure contexts (HTTPS).");
|
|
145
146
|
try {
|
|
146
147
|
let t = new TextEncoder().encode(e);
|
|
147
|
-
return
|
|
148
|
+
return f(await crypto.subtle.digest("SHA-256", t)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
148
149
|
} catch (e) {
|
|
149
|
-
throw
|
|
150
|
+
throw l.error("CryptoUtils.generateCodeChallenge", e), e;
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
static generateBasicAuth(e, t) {
|
|
153
|
-
return
|
|
154
|
+
return f(new TextEncoder().encode([e, t].join(":")));
|
|
154
155
|
}
|
|
155
156
|
static async hash(e, t) {
|
|
156
157
|
let n = new TextEncoder().encode(t), r = await crypto.subtle.digest(e, n);
|
|
@@ -211,7 +212,7 @@ var l = class {
|
|
|
211
212
|
y: e.y
|
|
212
213
|
}
|
|
213
214
|
};
|
|
214
|
-
return await
|
|
215
|
+
return await u.generateSignedJwt(t, c, i.privateKey);
|
|
215
216
|
} catch (e) {
|
|
216
217
|
throw e instanceof TypeError ? Error(`Error exporting dpop public key: ${e.message}`) : e;
|
|
217
218
|
}
|
|
@@ -247,17 +248,17 @@ var l = class {
|
|
|
247
248
|
HS512: "SHA-512"
|
|
248
249
|
}[i];
|
|
249
250
|
if (!c) throw Error(`Unsupported algorithm: ${i}. Supported algorithms are: HS256, HS384, HS512`);
|
|
250
|
-
let
|
|
251
|
+
let l = new TextEncoder(), d = await crypto.subtle.importKey("raw", l.encode(n), {
|
|
251
252
|
name: "HMAC",
|
|
252
253
|
hash: c
|
|
253
254
|
}, !1, ["sign"]);
|
|
254
|
-
return await
|
|
255
|
+
return await u.generateSignedJwtWithHmac(o, s, d);
|
|
255
256
|
}
|
|
256
257
|
};
|
|
257
|
-
|
|
258
|
-
var
|
|
258
|
+
p.encodeBase64Url = (e) => f(e).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
259
|
+
var m = p, h = class {
|
|
259
260
|
constructor(e) {
|
|
260
|
-
this._name = e, this._callbacks = [], this._logger = new
|
|
261
|
+
this._name = e, this._callbacks = [], this._logger = new l(`Event('${this._name}')`);
|
|
261
262
|
}
|
|
262
263
|
addHandler(e) {
|
|
263
264
|
return this._callbacks.push(e), () => this.removeHandler(e);
|
|
@@ -270,7 +271,7 @@ var p = f, m = class {
|
|
|
270
271
|
this._logger.debug("raise:", ...e);
|
|
271
272
|
for (let t of this._callbacks) await t(...e);
|
|
272
273
|
}
|
|
273
|
-
},
|
|
274
|
+
}, g = class {
|
|
274
275
|
static center({ ...e }) {
|
|
275
276
|
return e.width ??= [
|
|
276
277
|
800,
|
|
@@ -282,9 +283,9 @@ var p = f, m = class {
|
|
|
282
283
|
static serialize(e) {
|
|
283
284
|
return Object.entries(e).filter(([, e]) => e != null).map(([e, t]) => `${e}=${typeof t == "boolean" ? t ? "yes" : "no" : t}`).join(",");
|
|
284
285
|
}
|
|
285
|
-
},
|
|
286
|
+
}, _ = class e extends h {
|
|
286
287
|
constructor() {
|
|
287
|
-
super(...arguments), this._logger = new
|
|
288
|
+
super(...arguments), this._logger = new l(`Timer('${this._name}')`), this._timerHandle = null, this._expiration = 0, this._callback = () => {
|
|
288
289
|
let t = this._expiration - e.getEpochTime();
|
|
289
290
|
this._logger.debug("timer completes in", t), this._expiration <= e.getEpochTime() && (this.cancel(), super.raise());
|
|
290
291
|
};
|
|
@@ -310,24 +311,24 @@ var p = f, m = class {
|
|
|
310
311
|
cancel() {
|
|
311
312
|
this._logger.create("cancel"), this._timerHandle &&= (clearInterval(this._timerHandle), null);
|
|
312
313
|
}
|
|
313
|
-
},
|
|
314
|
+
}, v = class {
|
|
314
315
|
static readParams(e, t = "query") {
|
|
315
316
|
if (!e) throw TypeError("Invalid URL");
|
|
316
317
|
let n = new URL(e, "http://127.0.0.1")[t === "fragment" ? "hash" : "search"];
|
|
317
318
|
return new URLSearchParams(n.slice(1));
|
|
318
319
|
}
|
|
319
|
-
},
|
|
320
|
+
}, y = ";", b = class extends Error {
|
|
320
321
|
constructor(e, t) {
|
|
321
|
-
if (super(e.error_description || e.error || ""), this.form = t, this.name = "ErrorResponse", !e.error) throw
|
|
322
|
+
if (super(e.error_description || e.error || ""), this.form = t, this.name = "ErrorResponse", !e.error) throw l.error("ErrorResponse", "No error passed"), Error("No error passed");
|
|
322
323
|
this.error = e.error, this.error_description = e.error_description ?? null, this.error_uri = e.error_uri ?? null, this.state = e.userState, this.session_state = e.session_state ?? null, this.url_state = e.url_state;
|
|
323
324
|
}
|
|
324
|
-
},
|
|
325
|
+
}, x = class extends Error {
|
|
325
326
|
constructor(e) {
|
|
326
327
|
super(e), this.name = "ErrorTimeout";
|
|
327
328
|
}
|
|
328
|
-
},
|
|
329
|
+
}, S = class {
|
|
329
330
|
constructor(e) {
|
|
330
|
-
this._logger = new
|
|
331
|
+
this._logger = new l("AccessTokenEvents"), this._expiringTimer = new _("Access token expiring"), this._expiredTimer = new _("Access token expired"), this._expiringNotificationTimeInSeconds = e.expiringNotificationTimeInSeconds;
|
|
331
332
|
}
|
|
332
333
|
async load(e) {
|
|
333
334
|
let t = this._logger.create("load");
|
|
@@ -356,9 +357,9 @@ var p = f, m = class {
|
|
|
356
357
|
removeAccessTokenExpired(e) {
|
|
357
358
|
this._expiredTimer.removeHandler(e);
|
|
358
359
|
}
|
|
359
|
-
},
|
|
360
|
+
}, C = class {
|
|
360
361
|
constructor(e, t, n, r, i) {
|
|
361
|
-
this._callback = e, this._client_id = t, this._intervalInSeconds = r, this._stopOnError = i, this._logger = new
|
|
362
|
+
this._callback = e, this._client_id = t, this._intervalInSeconds = r, this._stopOnError = i, this._logger = new l("CheckSessionIFrame"), this._timer = null, this._session_state = null, this._message = (e) => {
|
|
362
363
|
e.origin === this._frame_origin && e.source === this._frame.contentWindow && (e.data === "error" ? (this._logger.error("error message from check session op iframe"), this._stopOnError && this.stop()) : e.data === "changed" ? (this._logger.debug("changed message from check session op iframe"), this.stop(), this._callback()) : this._logger.debug(e.data + " message from check session op iframe"));
|
|
363
364
|
};
|
|
364
365
|
let a = new URL(n);
|
|
@@ -375,16 +376,16 @@ var p = f, m = class {
|
|
|
375
376
|
if (this._session_state === e) return;
|
|
376
377
|
this._logger.create("start"), this.stop(), this._session_state = e;
|
|
377
378
|
let t = () => {
|
|
378
|
-
|
|
379
|
+
this._frame.contentWindow && this._session_state && this._frame.contentWindow.postMessage(this._client_id + " " + this._session_state, this._frame_origin);
|
|
379
380
|
};
|
|
380
381
|
t(), this._timer = setInterval(t, this._intervalInSeconds * 1e3);
|
|
381
382
|
}
|
|
382
383
|
stop() {
|
|
383
384
|
this._logger.create("stop"), this._session_state = null, this._timer &&= (clearInterval(this._timer), null);
|
|
384
385
|
}
|
|
385
|
-
},
|
|
386
|
+
}, w = class {
|
|
386
387
|
constructor() {
|
|
387
|
-
this._logger = new
|
|
388
|
+
this._logger = new l("InMemoryWebStorage"), this._data = {};
|
|
388
389
|
}
|
|
389
390
|
clear() {
|
|
390
391
|
this._logger.create("clear"), this._data = {};
|
|
@@ -404,13 +405,13 @@ var p = f, m = class {
|
|
|
404
405
|
key(e) {
|
|
405
406
|
return Object.getOwnPropertyNames(this._data)[e];
|
|
406
407
|
}
|
|
407
|
-
},
|
|
408
|
+
}, T = class extends Error {
|
|
408
409
|
constructor(e, t) {
|
|
409
410
|
super(t), this.name = "ErrorDPoPNonce", this.nonce = e;
|
|
410
411
|
}
|
|
411
|
-
},
|
|
412
|
+
}, E = class {
|
|
412
413
|
constructor(e = [], t = null, n = {}) {
|
|
413
|
-
this._jwtHandler = t, this._extraHeaders = n, this._logger = new
|
|
414
|
+
this._jwtHandler = t, this._extraHeaders = n, this._logger = new l("JsonService"), this._contentTypes = [], this._contentTypes.push(...e, "application/json"), t && this._contentTypes.push("application/jwt");
|
|
414
415
|
}
|
|
415
416
|
async fetchWithTimeout(e, t = {}) {
|
|
416
417
|
let { timeoutInSeconds: n, ...r } = t;
|
|
@@ -422,7 +423,7 @@ var p = f, m = class {
|
|
|
422
423
|
signal: i.signal
|
|
423
424
|
});
|
|
424
425
|
} catch (e) {
|
|
425
|
-
throw e instanceof DOMException && e.name === "AbortError" ? new
|
|
426
|
+
throw e instanceof DOMException && e.name === "AbortError" ? new x("Network timed out") : e;
|
|
426
427
|
} finally {
|
|
427
428
|
clearTimeout(a);
|
|
428
429
|
}
|
|
@@ -450,7 +451,7 @@ var p = f, m = class {
|
|
|
450
451
|
} catch (e) {
|
|
451
452
|
throw i.error("Error parsing JSON response", e), o.ok ? e : Error(`${o.statusText} (${o.status})`);
|
|
452
453
|
}
|
|
453
|
-
if (!o.ok) throw i.error("Error from server:", c), c.error ? new
|
|
454
|
+
if (!o.ok) throw i.error("Error from server:", c), c.error ? new b(c) : Error(`${o.statusText} (${o.status}): ${JSON.stringify(c)}`);
|
|
454
455
|
return c;
|
|
455
456
|
}
|
|
456
457
|
async postForm(e, { body: t, basicAuth: n, timeoutInSeconds: r, initCredentials: i, extraHeaders: a }) {
|
|
@@ -481,7 +482,7 @@ var p = f, m = class {
|
|
|
481
482
|
} catch (e) {
|
|
482
483
|
throw o.error("Error parsing JSON response", e), c.ok ? e : Error(`${c.statusText} (${c.status})`);
|
|
483
484
|
}
|
|
484
|
-
if (!c.ok) throw o.error("Error from server:", d), c.headers.has("dpop-nonce") ? new
|
|
485
|
+
if (!c.ok) throw o.error("Error from server:", d), c.headers.has("dpop-nonce") ? new T(c.headers.get("dpop-nonce"), `${JSON.stringify(d)}`) : d.error ? new b(d, t) : Error(`${c.statusText} (${c.status}): ${JSON.stringify(d)}`);
|
|
485
486
|
return d;
|
|
486
487
|
}
|
|
487
488
|
_appendExtraHeaders(e) {
|
|
@@ -499,9 +500,9 @@ var p = f, m = class {
|
|
|
499
500
|
a && a !== "" && (e[n] = a);
|
|
500
501
|
});
|
|
501
502
|
}
|
|
502
|
-
},
|
|
503
|
+
}, D = class {
|
|
503
504
|
constructor(e) {
|
|
504
|
-
this._settings = e, this._logger = new
|
|
505
|
+
this._settings = e, this._logger = new l("MetadataService"), this._signingKeys = null, this._metadata = null, this._metadataUrl = this._settings.metadataUrl, this._jsonService = new E(["application/jwk-set+json"], null, this._settings.extraHeaders), this._settings.signingKeys && (this._logger.debug("using signingKeys from settings"), this._signingKeys = this._settings.signingKeys), this._settings.metadata && (this._logger.debug("using metadata from settings"), this._metadata = this._settings.metadata), this._settings.fetchRequestCredentials && (this._logger.debug("using fetchRequestCredentials from settings"), this._fetchRequestCredentials = this._settings.fetchRequestCredentials);
|
|
505
506
|
}
|
|
506
507
|
resetSigningKeys() {
|
|
507
508
|
this._signingKeys = null;
|
|
@@ -561,9 +562,9 @@ var p = f, m = class {
|
|
|
561
562
|
if (e.debug("got key set", n), !Array.isArray(n.keys)) throw e.throw(/* @__PURE__ */ Error("Missing keys on keyset")), null;
|
|
562
563
|
return this._signingKeys = n.keys, this._signingKeys;
|
|
563
564
|
}
|
|
564
|
-
},
|
|
565
|
+
}, O = class {
|
|
565
566
|
constructor({ prefix: e = "oidc.", store: t = localStorage } = {}) {
|
|
566
|
-
this._logger = new
|
|
567
|
+
this._logger = new l("WebStorageStateStore"), this._store = t, this._prefix = e;
|
|
567
568
|
}
|
|
568
569
|
async set(e, t) {
|
|
569
570
|
this._logger.create(`set('${e}')`), e = this._prefix + e, await this._store.setItem(e, t);
|
|
@@ -585,26 +586,26 @@ var p = f, m = class {
|
|
|
585
586
|
}
|
|
586
587
|
return t;
|
|
587
588
|
}
|
|
588
|
-
},
|
|
589
|
-
constructor({ authority: e, metadataUrl: t, metadata: n, signingKeys: r, metadataSeed: i, client_id: a, client_secret: o, response_type: s =
|
|
590
|
-
if (this.authority = e, t ? this.metadataUrl = t : (this.metadataUrl = e, e && (this.metadataUrl.endsWith("/") || (this.metadataUrl += "/"), this.metadataUrl += ".well-known/openid-configuration")), this.metadata = n, this.metadataSeed = i, this.signingKeys = r, this.client_id = a, this.client_secret = o, this.response_type = s, this.scope = c, this.redirect_uri = l, this.post_logout_redirect_uri = u, this.client_authentication = d, this.token_endpoint_auth_signing_alg = f, this.prompt = p, this.display = m, this.max_age = h, this.ui_locales = g, this.acr_values = _, this.resource = v, this.response_mode = y, this.filterProtocolClaims = b ?? !0, this.loadUserInfo = !!x, this.staleStateAgeInSeconds =
|
|
589
|
+
}, k = "code", A = "openid", j = "client_secret_post", ee = 900, M = class {
|
|
590
|
+
constructor({ authority: e, metadataUrl: t, metadata: n, signingKeys: r, metadataSeed: i, client_id: a, client_secret: o, response_type: s = k, scope: c = A, redirect_uri: l, post_logout_redirect_uri: u, client_authentication: d = j, token_endpoint_auth_signing_alg: f = "HS256", prompt: p, display: m, max_age: h, ui_locales: g, acr_values: _, resource: v, response_mode: y, filterProtocolClaims: b = !0, loadUserInfo: x = !1, requestTimeoutInSeconds: S, staleStateAgeInSeconds: C = ee, mergeClaimsStrategy: T = { array: "replace" }, disablePKCE: E = !1, stateStore: D, revokeTokenAdditionalContentTypes: M, fetchRequestCredentials: N, refreshTokenAllowedScope: P, extraQueryParams: F = {}, extraTokenParams: I = {}, extraHeaders: L = {}, dpop: R, omitScopeWhenRequesting: z = !1 }) {
|
|
591
|
+
if (this.authority = e, t ? this.metadataUrl = t : (this.metadataUrl = e, e && (this.metadataUrl.endsWith("/") || (this.metadataUrl += "/"), this.metadataUrl += ".well-known/openid-configuration")), this.metadata = n, this.metadataSeed = i, this.signingKeys = r, this.client_id = a, this.client_secret = o, this.response_type = s, this.scope = c, this.redirect_uri = l, this.post_logout_redirect_uri = u, this.client_authentication = d, this.token_endpoint_auth_signing_alg = f, this.prompt = p, this.display = m, this.max_age = h, this.ui_locales = g, this.acr_values = _, this.resource = v, this.response_mode = y, this.filterProtocolClaims = b ?? !0, this.loadUserInfo = !!x, this.staleStateAgeInSeconds = C, this.mergeClaimsStrategy = T, this.omitScopeWhenRequesting = z, this.disablePKCE = !!E, this.revokeTokenAdditionalContentTypes = M, this.fetchRequestCredentials = N || "same-origin", this.requestTimeoutInSeconds = S, D) this.stateStore = D;
|
|
591
592
|
else {
|
|
592
|
-
let e = typeof window < "u" ? window.localStorage : new
|
|
593
|
-
this.stateStore = new
|
|
593
|
+
let e = typeof window < "u" ? window.localStorage : new w();
|
|
594
|
+
this.stateStore = new O({ store: e });
|
|
594
595
|
}
|
|
595
|
-
if (this.refreshTokenAllowedScope =
|
|
596
|
+
if (this.refreshTokenAllowedScope = P, this.extraQueryParams = F, this.extraTokenParams = I, this.extraHeaders = L, this.dpop = R, this.dpop && !this.dpop?.store) throw Error("A DPoPStore is required when dpop is enabled");
|
|
596
597
|
}
|
|
597
|
-
},
|
|
598
|
+
}, N = class {
|
|
598
599
|
constructor(e, t) {
|
|
599
|
-
this._settings = e, this._metadataService = t, this._logger = new
|
|
600
|
+
this._settings = e, this._metadataService = t, this._logger = new l("UserInfoService"), this._getClaimsFromJwt = async (e) => {
|
|
600
601
|
let t = this._logger.create("_getClaimsFromJwt");
|
|
601
602
|
try {
|
|
602
|
-
let n =
|
|
603
|
+
let n = u.decode(e);
|
|
603
604
|
return t.debug("JWT decoding successful"), n;
|
|
604
605
|
} catch (e) {
|
|
605
606
|
throw t.error("Error parsing JWT response"), e;
|
|
606
607
|
}
|
|
607
|
-
}, this._jsonService = new
|
|
608
|
+
}, this._jsonService = new E(void 0, this._getClaimsFromJwt, this._settings.extraHeaders);
|
|
608
609
|
}
|
|
609
610
|
async getClaims(e) {
|
|
610
611
|
let t = this._logger.create("getClaims");
|
|
@@ -618,9 +619,9 @@ var p = f, m = class {
|
|
|
618
619
|
});
|
|
619
620
|
return t.debug("got claims", r), r;
|
|
620
621
|
}
|
|
621
|
-
},
|
|
622
|
+
}, P = class {
|
|
622
623
|
constructor(e, t) {
|
|
623
|
-
this._settings = e, this._metadataService = t, this._logger = new
|
|
624
|
+
this._settings = e, this._metadataService = t, this._logger = new l("TokenClient"), this._jsonService = new E(this._settings.revokeTokenAdditionalContentTypes, null, this._settings.extraHeaders);
|
|
624
625
|
}
|
|
625
626
|
async exchangeCode({ grant_type: e = "authorization_code", redirect_uri: t = this._settings.redirect_uri, client_id: n = this._settings.client_id, client_secret: r = this._settings.client_secret, extraHeaders: i, ...a }) {
|
|
626
627
|
let o = this._logger.create("exchangeCode");
|
|
@@ -634,13 +635,13 @@ var p = f, m = class {
|
|
|
634
635
|
let c, l = await this._metadataService.getTokenEndpoint(!1);
|
|
635
636
|
switch (this._settings.client_authentication) {
|
|
636
637
|
case "client_secret_basic":
|
|
637
|
-
c =
|
|
638
|
+
c = m.generateBasicAuth(n, r);
|
|
638
639
|
break;
|
|
639
640
|
case "client_secret_post":
|
|
640
641
|
s.append("client_id", n), r && s.append("client_secret", r);
|
|
641
642
|
break;
|
|
642
643
|
case "client_secret_jwt": {
|
|
643
|
-
let e = await
|
|
644
|
+
let e = await m.generateClientAssertionJwt(n, r, l, this._settings.token_endpoint_auth_signing_alg);
|
|
644
645
|
s.append("client_id", n), s.append("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), s.append("client_assertion", e);
|
|
645
646
|
break;
|
|
646
647
|
}
|
|
@@ -665,13 +666,13 @@ var p = f, m = class {
|
|
|
665
666
|
let s, c = await this._metadataService.getTokenEndpoint(!1);
|
|
666
667
|
switch (this._settings.client_authentication) {
|
|
667
668
|
case "client_secret_basic":
|
|
668
|
-
s =
|
|
669
|
+
s = m.generateBasicAuth(t, n);
|
|
669
670
|
break;
|
|
670
671
|
case "client_secret_post":
|
|
671
672
|
o.append("client_id", t), n && o.append("client_secret", n);
|
|
672
673
|
break;
|
|
673
674
|
case "client_secret_jwt": {
|
|
674
|
-
let e = await
|
|
675
|
+
let e = await m.generateClientAssertionJwt(t, n, c, this._settings.token_endpoint_auth_signing_alg);
|
|
675
676
|
o.append("client_id", t), o.append("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), o.append("client_assertion", e);
|
|
676
677
|
break;
|
|
677
678
|
}
|
|
@@ -694,13 +695,13 @@ var p = f, m = class {
|
|
|
694
695
|
let c, l = await this._metadataService.getTokenEndpoint(!1);
|
|
695
696
|
switch (this._settings.client_authentication) {
|
|
696
697
|
case "client_secret_basic":
|
|
697
|
-
c =
|
|
698
|
+
c = m.generateBasicAuth(t, n);
|
|
698
699
|
break;
|
|
699
700
|
case "client_secret_post":
|
|
700
701
|
s.append("client_id", t), n && s.append("client_secret", n);
|
|
701
702
|
break;
|
|
702
703
|
case "client_secret_jwt": {
|
|
703
|
-
let e = await
|
|
704
|
+
let e = await m.generateClientAssertionJwt(t, n, l, this._settings.token_endpoint_auth_signing_alg);
|
|
704
705
|
s.append("client_id", t), s.append("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), s.append("client_assertion", e);
|
|
705
706
|
break;
|
|
706
707
|
}
|
|
@@ -727,9 +728,9 @@ var p = f, m = class {
|
|
|
727
728
|
timeoutInSeconds: this._settings.requestTimeoutInSeconds
|
|
728
729
|
}), t.debug("got response");
|
|
729
730
|
}
|
|
730
|
-
},
|
|
731
|
+
}, F = class {
|
|
731
732
|
constructor(e, t, n) {
|
|
732
|
-
this._settings = e, this._metadataService = t, this._claimsService = n, this._logger = new
|
|
733
|
+
this._settings = e, this._metadataService = t, this._claimsService = n, this._logger = new l("ResponseValidator"), this._userInfoService = new N(this._settings, this._metadataService), this._tokenClient = new P(this._settings, this._metadataService);
|
|
733
734
|
}
|
|
734
735
|
async validateSigninResponse(e, t, n) {
|
|
735
736
|
let r = this._logger.create("validateSigninResponse");
|
|
@@ -747,11 +748,11 @@ var p = f, m = class {
|
|
|
747
748
|
}
|
|
748
749
|
validateSignoutResponse(e, t) {
|
|
749
750
|
let n = this._logger.create("validateSignoutResponse");
|
|
750
|
-
if (t.id !== e.state && n.throw(/* @__PURE__ */ Error("State does not match")), n.debug("state validated"), e.userState = t.data, e.error) throw n.warn("Response was error", e.error), new
|
|
751
|
+
if (t.id !== e.state && n.throw(/* @__PURE__ */ Error("State does not match")), n.debug("state validated"), e.userState = t.data, e.error) throw n.warn("Response was error", e.error), new b(e);
|
|
751
752
|
}
|
|
752
753
|
_processSigninState(e, t) {
|
|
753
754
|
let n = this._logger.create("_processSigninState");
|
|
754
|
-
if (t.id !== e.state && n.throw(/* @__PURE__ */ Error("State does not match")), t.client_id || n.throw(/* @__PURE__ */ Error("No client_id on state")), t.authority || n.throw(/* @__PURE__ */ Error("No authority on state")), this._settings.authority !== t.authority && n.throw(/* @__PURE__ */ Error("authority mismatch on settings vs. signin state")), this._settings.client_id && this._settings.client_id !== t.client_id && n.throw(/* @__PURE__ */ Error("client_id mismatch on settings vs. signin state")), n.debug("state validated"), e.userState = t.data, e.url_state = t.url_state, e.scope ??= t.scope, e.error) throw n.warn("Response was error", e.error), new
|
|
755
|
+
if (t.id !== e.state && n.throw(/* @__PURE__ */ Error("State does not match")), t.client_id || n.throw(/* @__PURE__ */ Error("No client_id on state")), t.authority || n.throw(/* @__PURE__ */ Error("No authority on state")), this._settings.authority !== t.authority && n.throw(/* @__PURE__ */ Error("authority mismatch on settings vs. signin state")), this._settings.client_id && this._settings.client_id !== t.client_id && n.throw(/* @__PURE__ */ Error("client_id mismatch on settings vs. signin state")), n.debug("state validated"), e.userState = t.data, e.url_state = t.url_state, e.scope ??= t.scope, e.error) throw n.warn("Response was error", e.error), new b(e);
|
|
755
756
|
t.code_verifier && !e.code && n.throw(/* @__PURE__ */ Error("Expected code in response"));
|
|
756
757
|
}
|
|
757
758
|
async _processClaims(e, t = !1, n = !0) {
|
|
@@ -783,19 +784,19 @@ var p = f, m = class {
|
|
|
783
784
|
_validateIdTokenAttributes(e, t, n) {
|
|
784
785
|
let r = this._logger.create("_validateIdTokenAttributes");
|
|
785
786
|
r.debug("decoding ID Token JWT");
|
|
786
|
-
let i =
|
|
787
|
+
let i = u.decode(e.id_token ?? "");
|
|
787
788
|
if (i.sub || r.throw(/* @__PURE__ */ Error("ID Token is missing a subject claim")), n && i.nonce !== n && r.throw(/* @__PURE__ */ Error("nonce in id_token does not match nonce in client storage")), t) {
|
|
788
|
-
let e =
|
|
789
|
+
let e = u.decode(t);
|
|
789
790
|
i.sub !== e.sub && r.throw(/* @__PURE__ */ Error("sub in id_token does not match current sub")), i.auth_time && i.auth_time !== e.auth_time && r.throw(/* @__PURE__ */ Error("auth_time in id_token does not match original auth_time")), i.azp && i.azp !== e.azp && r.throw(/* @__PURE__ */ Error("azp in id_token does not match original azp")), !i.azp && e.azp && r.throw(/* @__PURE__ */ Error("azp not in id_token, but present in original id_token"));
|
|
790
791
|
}
|
|
791
792
|
e.profile = i;
|
|
792
793
|
}
|
|
793
|
-
},
|
|
794
|
+
}, I = class e {
|
|
794
795
|
constructor(e) {
|
|
795
|
-
this.id = e.id ||
|
|
796
|
+
this.id = e.id || m.generateUUIDv4(), this.data = e.data, this.created = e.created && e.created > 0 ? e.created : _.getEpochTime(), this.request_type = e.request_type, this.url_state = e.url_state;
|
|
796
797
|
}
|
|
797
798
|
toStorageString() {
|
|
798
|
-
return new
|
|
799
|
+
return new l("State").create("toStorageString"), JSON.stringify({
|
|
799
800
|
id: this.id,
|
|
800
801
|
data: this.data,
|
|
801
802
|
created: this.created,
|
|
@@ -804,10 +805,10 @@ var p = f, m = class {
|
|
|
804
805
|
});
|
|
805
806
|
}
|
|
806
807
|
static fromStorageString(t) {
|
|
807
|
-
return
|
|
808
|
+
return l.createStatic("State", "fromStorageString"), Promise.resolve(new e(JSON.parse(t)));
|
|
808
809
|
}
|
|
809
810
|
static async clearStaleState(t, n) {
|
|
810
|
-
let r =
|
|
811
|
+
let r = l.createStatic("State", "clearStaleState"), i = _.getEpochTime() - n, a = await t.getAllKeys();
|
|
811
812
|
r.debug("got keys", a);
|
|
812
813
|
for (let n = 0; n < a.length; n++) {
|
|
813
814
|
let o = a[n], s = await t.get(o), c = !1;
|
|
@@ -821,12 +822,12 @@ var p = f, m = class {
|
|
|
821
822
|
c && (r.debug("removed item for key:", o), t.remove(o));
|
|
822
823
|
}
|
|
823
824
|
}
|
|
824
|
-
},
|
|
825
|
+
}, L = class e extends I {
|
|
825
826
|
constructor(e) {
|
|
826
827
|
super(e), this.code_verifier = e.code_verifier, this.code_challenge = e.code_challenge, this.authority = e.authority, this.client_id = e.client_id, this.redirect_uri = e.redirect_uri, this.scope = e.scope, this.client_secret = e.client_secret, this.extraTokenParams = e.extraTokenParams, this.response_mode = e.response_mode, this.skipUserInfo = e.skipUserInfo, this.nonce = e.nonce;
|
|
827
828
|
}
|
|
828
829
|
static async create(t) {
|
|
829
|
-
let n = t.code_verifier === !0 ?
|
|
830
|
+
let n = t.code_verifier === !0 ? m.generateCodeVerifier() : t.code_verifier || void 0, r = n ? await m.generateCodeChallenge(n) : void 0;
|
|
830
831
|
return new e({
|
|
831
832
|
...t,
|
|
832
833
|
code_verifier: n,
|
|
@@ -834,7 +835,7 @@ var p = f, m = class {
|
|
|
834
835
|
});
|
|
835
836
|
}
|
|
836
837
|
toStorageString() {
|
|
837
|
-
return new
|
|
838
|
+
return new l("SigninState").create("toStorageString"), JSON.stringify({
|
|
838
839
|
id: this.id,
|
|
839
840
|
data: this.data,
|
|
840
841
|
created: this.created,
|
|
@@ -853,22 +854,22 @@ var p = f, m = class {
|
|
|
853
854
|
});
|
|
854
855
|
}
|
|
855
856
|
static fromStorageString(t) {
|
|
856
|
-
|
|
857
|
+
l.createStatic("SigninState", "fromStorageString");
|
|
857
858
|
let n = JSON.parse(t);
|
|
858
859
|
return e.create(n);
|
|
859
860
|
}
|
|
860
|
-
},
|
|
861
|
+
}, R = class e {
|
|
861
862
|
constructor(e) {
|
|
862
863
|
this.url = e.url, this.state = e.state;
|
|
863
864
|
}
|
|
864
|
-
static async create({ url: t, authority: n, client_id: r, redirect_uri: i, response_type: a, scope: o, state_data: s, response_mode: c, request_type: l, client_secret: u, nonce: d, url_state: f, resource: p, skipUserInfo: m, extraQueryParams: h, extraTokenParams: g, disablePKCE: _, dpopJkt:
|
|
865
|
+
static async create({ url: t, authority: n, client_id: r, redirect_uri: i, response_type: a, scope: o, state_data: s, response_mode: c, request_type: l, client_secret: u, nonce: d, url_state: f, resource: p, skipUserInfo: m, extraQueryParams: h, extraTokenParams: g, disablePKCE: _, dpopJkt: v, omitScopeWhenRequesting: b, ...x }) {
|
|
865
866
|
if (!t) throw this._logger.error("create: No url passed"), Error("url");
|
|
866
867
|
if (!r) throw this._logger.error("create: No client_id passed"), Error("client_id");
|
|
867
868
|
if (!i) throw this._logger.error("create: No redirect_uri passed"), Error("redirect_uri");
|
|
868
869
|
if (!a) throw this._logger.error("create: No response_type passed"), Error("response_type");
|
|
869
870
|
if (!o) throw this._logger.error("create: No scope passed"), Error("scope");
|
|
870
871
|
if (!n) throw this._logger.error("create: No authority passed"), Error("authority");
|
|
871
|
-
let S = await
|
|
872
|
+
let S = await L.create({
|
|
872
873
|
data: s,
|
|
873
874
|
request_type: l,
|
|
874
875
|
url_state: f,
|
|
@@ -883,9 +884,9 @@ var p = f, m = class {
|
|
|
883
884
|
skipUserInfo: m,
|
|
884
885
|
nonce: d
|
|
885
886
|
}), C = new URL(t);
|
|
886
|
-
C.searchParams.append("client_id", r), C.searchParams.append("redirect_uri", i), C.searchParams.append("response_type", a), b || C.searchParams.append("scope", o), d && C.searchParams.append("nonce", d),
|
|
887
|
+
C.searchParams.append("client_id", r), C.searchParams.append("redirect_uri", i), C.searchParams.append("response_type", a), b || C.searchParams.append("scope", o), d && C.searchParams.append("nonce", d), v && C.searchParams.append("dpop_jkt", v);
|
|
887
888
|
let w = S.id;
|
|
888
|
-
f && (w = `${w}${
|
|
889
|
+
f && (w = `${w}${y}${f}`), C.searchParams.append("state", w), S.code_challenge && (C.searchParams.append("code_challenge", S.code_challenge), C.searchParams.append("code_challenge_method", "S256")), p && (Array.isArray(p) ? p : [p]).forEach((e) => C.searchParams.append("resource", e));
|
|
889
890
|
for (let [e, t] of Object.entries({
|
|
890
891
|
response_mode: c,
|
|
891
892
|
...x,
|
|
@@ -897,49 +898,49 @@ var p = f, m = class {
|
|
|
897
898
|
});
|
|
898
899
|
}
|
|
899
900
|
};
|
|
900
|
-
|
|
901
|
-
var
|
|
901
|
+
R._logger = new l("SigninRequest");
|
|
902
|
+
var z = R, te = "openid", B = class {
|
|
902
903
|
constructor(e) {
|
|
903
904
|
if (this.access_token = "", this.token_type = "", this.profile = {}, this.state = e.get("state"), this.session_state = e.get("session_state"), this.state) {
|
|
904
|
-
let e = decodeURIComponent(this.state).split(
|
|
905
|
-
this.state = e[0], e.length > 1 && (this.url_state = e.slice(1).join(
|
|
905
|
+
let e = decodeURIComponent(this.state).split(y);
|
|
906
|
+
this.state = e[0], e.length > 1 && (this.url_state = e.slice(1).join(y));
|
|
906
907
|
}
|
|
907
908
|
this.error = e.get("error"), this.error_description = e.get("error_description"), this.error_uri = e.get("error_uri"), this.code = e.get("code");
|
|
908
909
|
}
|
|
909
910
|
get expires_in() {
|
|
910
|
-
if (this.expires_at !== void 0) return this.expires_at -
|
|
911
|
+
if (this.expires_at !== void 0) return this.expires_at - _.getEpochTime();
|
|
911
912
|
}
|
|
912
913
|
set expires_in(e) {
|
|
913
|
-
typeof e == "string" && (e = Number(e)), e !== void 0 && e >= 0 && (this.expires_at = Math.floor(e) +
|
|
914
|
+
typeof e == "string" && (e = Number(e)), e !== void 0 && e >= 0 && (this.expires_at = Math.floor(e) + _.getEpochTime());
|
|
914
915
|
}
|
|
915
916
|
get isOpenId() {
|
|
916
|
-
return this.scope?.split(" ").includes(
|
|
917
|
+
return this.scope?.split(" ").includes(te) || !!this.id_token;
|
|
917
918
|
}
|
|
918
|
-
},
|
|
919
|
+
}, V = class {
|
|
919
920
|
constructor({ url: e, state_data: t, id_token_hint: n, post_logout_redirect_uri: r, extraQueryParams: i, request_type: a, client_id: o, url_state: s }) {
|
|
920
|
-
if (this._logger = new
|
|
921
|
-
let
|
|
922
|
-
if (n &&
|
|
923
|
-
this.state = new
|
|
921
|
+
if (this._logger = new l("SignoutRequest"), !e) throw this._logger.error("ctor: No url passed"), Error("url");
|
|
922
|
+
let c = new URL(e);
|
|
923
|
+
if (n && c.searchParams.append("id_token_hint", n), o && c.searchParams.append("client_id", o), r && (c.searchParams.append("post_logout_redirect_uri", r), t || s)) {
|
|
924
|
+
this.state = new I({
|
|
924
925
|
data: t,
|
|
925
926
|
request_type: a,
|
|
926
927
|
url_state: s
|
|
927
928
|
});
|
|
928
929
|
let e = this.state.id;
|
|
929
|
-
s && (e = `${e}${
|
|
930
|
+
s && (e = `${e}${y}${s}`), c.searchParams.append("state", e);
|
|
930
931
|
}
|
|
931
|
-
for (let [e, t] of Object.entries({ ...i })) t != null &&
|
|
932
|
-
this.url =
|
|
932
|
+
for (let [e, t] of Object.entries({ ...i })) t != null && c.searchParams.append(e, t.toString());
|
|
933
|
+
this.url = c.href;
|
|
933
934
|
}
|
|
934
|
-
},
|
|
935
|
+
}, ne = class {
|
|
935
936
|
constructor(e) {
|
|
936
937
|
if (this.state = e.get("state"), this.state) {
|
|
937
|
-
let e = decodeURIComponent(this.state).split(
|
|
938
|
-
this.state = e[0], e.length > 1 && (this.url_state = e.slice(1).join(
|
|
938
|
+
let e = decodeURIComponent(this.state).split(y);
|
|
939
|
+
this.state = e[0], e.length > 1 && (this.url_state = e.slice(1).join(y));
|
|
939
940
|
}
|
|
940
941
|
this.error = e.get("error"), this.error_description = e.get("error_description"), this.error_uri = e.get("error_uri");
|
|
941
942
|
}
|
|
942
|
-
},
|
|
943
|
+
}, re = [
|
|
943
944
|
"nbf",
|
|
944
945
|
"jti",
|
|
945
946
|
"auth_time",
|
|
@@ -948,22 +949,22 @@ var L = I, R = "openid", z = class {
|
|
|
948
949
|
"amr",
|
|
949
950
|
"azp",
|
|
950
951
|
"at_hash"
|
|
951
|
-
],
|
|
952
|
+
], ie = [
|
|
952
953
|
"sub",
|
|
953
954
|
"iss",
|
|
954
955
|
"aud",
|
|
955
956
|
"exp",
|
|
956
957
|
"iat"
|
|
957
|
-
],
|
|
958
|
+
], ae = class {
|
|
958
959
|
constructor(e) {
|
|
959
|
-
this._settings = e, this._logger = new
|
|
960
|
+
this._settings = e, this._logger = new l("ClaimsService");
|
|
960
961
|
}
|
|
961
962
|
filterProtocolClaims(e) {
|
|
962
963
|
let t = { ...e };
|
|
963
964
|
if (this._settings.filterProtocolClaims) {
|
|
964
965
|
let e;
|
|
965
|
-
e = Array.isArray(this._settings.filterProtocolClaims) ? this._settings.filterProtocolClaims :
|
|
966
|
-
for (let n of e)
|
|
966
|
+
e = Array.isArray(this._settings.filterProtocolClaims) ? this._settings.filterProtocolClaims : re;
|
|
967
|
+
for (let n of e) ie.includes(n) || delete t[n];
|
|
967
968
|
}
|
|
968
969
|
return t;
|
|
969
970
|
}
|
|
@@ -981,20 +982,20 @@ var L = I, R = "openid", z = class {
|
|
|
981
982
|
}
|
|
982
983
|
return n;
|
|
983
984
|
}
|
|
984
|
-
},
|
|
985
|
+
}, H = class {
|
|
985
986
|
constructor(e, t) {
|
|
986
987
|
this.keys = e, this.nonce = t;
|
|
987
988
|
}
|
|
988
|
-
},
|
|
989
|
+
}, U = class {
|
|
989
990
|
constructor(e, t) {
|
|
990
|
-
this._logger = new
|
|
991
|
+
this._logger = new l("OidcClient"), this.settings = e instanceof M ? e : new M(e), this.metadataService = t ?? new D(this.settings), this._claimsService = new ae(this.settings), this._validator = new F(this.settings, this.metadataService, this._claimsService), this._tokenClient = new P(this.settings, this.metadataService);
|
|
991
992
|
}
|
|
992
993
|
async createSigninRequest({ state: e, request: t, request_uri: n, request_type: r, id_token_hint: i, login_hint: a, skipUserInfo: o, nonce: s, url_state: c, response_type: l = this.settings.response_type, scope: u = this.settings.scope, redirect_uri: d = this.settings.redirect_uri, prompt: f = this.settings.prompt, display: p = this.settings.display, max_age: m = this.settings.max_age, ui_locales: h = this.settings.ui_locales, acr_values: g = this.settings.acr_values, resource: _ = this.settings.resource, response_mode: v = this.settings.response_mode, extraQueryParams: y = this.settings.extraQueryParams, extraTokenParams: b = this.settings.extraTokenParams, dpopJkt: x, omitScopeWhenRequesting: S = this.settings.omitScopeWhenRequesting }) {
|
|
993
994
|
let C = this._logger.create("createSigninRequest");
|
|
994
995
|
if (l !== "code") throw Error("Only the Authorization Code flow (with PKCE) is supported");
|
|
995
996
|
let w = await this.metadataService.getAuthorizationEndpoint();
|
|
996
997
|
C.debug("Received authorization endpoint", w);
|
|
997
|
-
let T = await
|
|
998
|
+
let T = await z.create({
|
|
998
999
|
url: w,
|
|
999
1000
|
authority: this.settings.authority,
|
|
1000
1001
|
client_id: this.settings.client_id,
|
|
@@ -1029,12 +1030,12 @@ var L = I, R = "openid", z = class {
|
|
|
1029
1030
|
return await this.settings.stateStore.set(E.id, E.toStorageString()), T;
|
|
1030
1031
|
}
|
|
1031
1032
|
async readSigninResponseState(e, t = !1) {
|
|
1032
|
-
let n = this._logger.create("readSigninResponseState"), r = new
|
|
1033
|
+
let n = this._logger.create("readSigninResponseState"), r = new B(v.readParams(e, this.settings.response_mode));
|
|
1033
1034
|
if (!r.state) throw n.throw(/* @__PURE__ */ Error("No state in response")), null;
|
|
1034
1035
|
let i = await this.settings.stateStore[t ? "remove" : "get"](r.state);
|
|
1035
1036
|
if (!i) throw n.throw(/* @__PURE__ */ Error("No matching state found in storage")), null;
|
|
1036
1037
|
return {
|
|
1037
|
-
state: await
|
|
1038
|
+
state: await L.fromStorageString(i),
|
|
1038
1039
|
response: r
|
|
1039
1040
|
};
|
|
1040
1041
|
}
|
|
@@ -1050,7 +1051,7 @@ var L = I, R = "openid", z = class {
|
|
|
1050
1051
|
try {
|
|
1051
1052
|
await this._validator.validateSigninResponse(a, i, t);
|
|
1052
1053
|
} catch (e) {
|
|
1053
|
-
if (e instanceof
|
|
1054
|
+
if (e instanceof T && this.settings.dpop) {
|
|
1054
1055
|
let n = await this.getDpopProof(this.settings.dpop.store, e.nonce);
|
|
1055
1056
|
t.DPoP = n, await this._validator.validateSigninResponse(a, i, t);
|
|
1056
1057
|
} else throw e;
|
|
@@ -1059,7 +1060,7 @@ var L = I, R = "openid", z = class {
|
|
|
1059
1060
|
}
|
|
1060
1061
|
async getDpopProof(e, t) {
|
|
1061
1062
|
let n, r;
|
|
1062
|
-
return (await e.getAllKeys()).includes(this.settings.client_id) ? (r = await e.get(this.settings.client_id), r.nonce !== t && t && (r.nonce = t, await e.set(this.settings.client_id, r))) : (n = await
|
|
1063
|
+
return (await e.getAllKeys()).includes(this.settings.client_id) ? (r = await e.get(this.settings.client_id), r.nonce !== t && t && (r.nonce = t, await e.set(this.settings.client_id, r))) : (n = await m.generateDPoPKeys(), r = new H(n, t), await e.set(this.settings.client_id, r)), await m.generateDPoPProof({
|
|
1063
1064
|
url: await this.metadataService.getTokenEndpoint(!1),
|
|
1064
1065
|
httpMethod: "POST",
|
|
1065
1066
|
keyPair: r.keys,
|
|
@@ -1071,7 +1072,7 @@ var L = I, R = "openid", z = class {
|
|
|
1071
1072
|
username: e,
|
|
1072
1073
|
password: t,
|
|
1073
1074
|
...r
|
|
1074
|
-
}), a = new
|
|
1075
|
+
}), a = new B(new URLSearchParams());
|
|
1075
1076
|
return Object.assign(a, i), await this._validator.validateCredentialsResponse(a, n), a;
|
|
1076
1077
|
}
|
|
1077
1078
|
async useRefreshToken({ state: e, redirect_uri: t, resource: n, timeoutInSeconds: r, extraHeaders: i, extraTokenParams: a }) {
|
|
@@ -1100,7 +1101,7 @@ var L = I, R = "openid", z = class {
|
|
|
1100
1101
|
...a
|
|
1101
1102
|
});
|
|
1102
1103
|
} catch (o) {
|
|
1103
|
-
if (o instanceof
|
|
1104
|
+
if (o instanceof T && this.settings.dpop) i.DPoP = await this.getDpopProof(this.settings.dpop.store, o.nonce), c = await this._tokenClient.exchangeRefreshToken({
|
|
1104
1105
|
refresh_token: e.refresh_token,
|
|
1105
1106
|
scope: s,
|
|
1106
1107
|
redirect_uri: t,
|
|
@@ -1111,7 +1112,7 @@ var L = I, R = "openid", z = class {
|
|
|
1111
1112
|
});
|
|
1112
1113
|
else throw o;
|
|
1113
1114
|
}
|
|
1114
|
-
let l = new
|
|
1115
|
+
let l = new B(new URLSearchParams());
|
|
1115
1116
|
return Object.assign(l, c), o.debug("validating response", l), await this._validator.validateRefreshResponse(l, {
|
|
1116
1117
|
...e,
|
|
1117
1118
|
scope: s
|
|
@@ -1121,7 +1122,7 @@ var L = I, R = "openid", z = class {
|
|
|
1121
1122
|
let s = this._logger.create("createSignoutRequest"), c = await this.metadataService.getEndSessionEndpoint();
|
|
1122
1123
|
if (!c) throw s.throw(/* @__PURE__ */ Error("No end session endpoint")), null;
|
|
1123
1124
|
s.debug("Received end session endpoint", c), !n && a && !t && (n = this.settings.client_id);
|
|
1124
|
-
let l = new
|
|
1125
|
+
let l = new V({
|
|
1125
1126
|
url: c,
|
|
1126
1127
|
id_token_hint: t,
|
|
1127
1128
|
client_id: n,
|
|
@@ -1136,9 +1137,9 @@ var L = I, R = "openid", z = class {
|
|
|
1136
1137
|
return u && (s.debug("Signout request has state to persist"), await this.settings.stateStore.set(u.id, u.toStorageString())), l;
|
|
1137
1138
|
}
|
|
1138
1139
|
async readSignoutResponseState(e, t = !1) {
|
|
1139
|
-
let n = this._logger.create("readSignoutResponseState"), r = new
|
|
1140
|
+
let n = this._logger.create("readSignoutResponseState"), r = new ne(v.readParams(e, this.settings.response_mode));
|
|
1140
1141
|
if (!r.state) {
|
|
1141
|
-
if (n.debug("No state in response"), r.error) throw n.warn("Response was error:", r.error), new
|
|
1142
|
+
if (n.debug("No state in response"), r.error) throw n.warn("Response was error:", r.error), new b(r);
|
|
1142
1143
|
return {
|
|
1143
1144
|
state: void 0,
|
|
1144
1145
|
response: r
|
|
@@ -1147,7 +1148,7 @@ var L = I, R = "openid", z = class {
|
|
|
1147
1148
|
let i = await this.settings.stateStore[t ? "remove" : "get"](r.state);
|
|
1148
1149
|
if (!i) throw n.throw(/* @__PURE__ */ Error("No matching state found in storage")), null;
|
|
1149
1150
|
return {
|
|
1150
|
-
state: await
|
|
1151
|
+
state: await I.fromStorageString(i),
|
|
1151
1152
|
response: r
|
|
1152
1153
|
};
|
|
1153
1154
|
}
|
|
@@ -1156,7 +1157,7 @@ var L = I, R = "openid", z = class {
|
|
|
1156
1157
|
return n ? (t.debug("Received state from storage; validating response"), this._validator.validateSignoutResponse(r, n)) : t.debug("No state from storage; skipping response validation"), r;
|
|
1157
1158
|
}
|
|
1158
1159
|
clearStaleState() {
|
|
1159
|
-
return this._logger.create("clearStaleState"),
|
|
1160
|
+
return this._logger.create("clearStaleState"), I.clearStaleState(this.settings.stateStore, this.settings.staleStateAgeInSeconds);
|
|
1160
1161
|
}
|
|
1161
1162
|
async revokeToken(e, t) {
|
|
1162
1163
|
return this._logger.create("revokeToken"), await this._tokenClient.revoke({
|
|
@@ -1166,7 +1167,7 @@ var L = I, R = "openid", z = class {
|
|
|
1166
1167
|
}
|
|
1167
1168
|
}, W = class {
|
|
1168
1169
|
constructor(e) {
|
|
1169
|
-
this._userManager = e, this._logger = new
|
|
1170
|
+
this._userManager = e, this._logger = new l("SessionMonitor"), this._start = async (e) => {
|
|
1170
1171
|
let t = e.session_state;
|
|
1171
1172
|
if (!t) return;
|
|
1172
1173
|
let n = this._logger.create("_start");
|
|
@@ -1178,7 +1179,7 @@ var L = I, R = "openid", z = class {
|
|
|
1178
1179
|
let e = await this._userManager.metadataService.getCheckSessionIframe();
|
|
1179
1180
|
if (e) {
|
|
1180
1181
|
n.debug("initializing check session iframe");
|
|
1181
|
-
let r = this._userManager.settings.client_id, i = this._userManager.settings.checkSessionIntervalInSeconds, a = this._userManager.settings.stopCheckSessionOnError, o = new
|
|
1182
|
+
let r = this._userManager.settings.client_id, i = this._userManager.settings.checkSessionIntervalInSeconds, a = this._userManager.settings.stopCheckSessionOnError, o = new C(this._callback, r, e, i, a);
|
|
1182
1183
|
await o.load(), this._checkSessionIFrame = o, o.start(t);
|
|
1183
1184
|
} else n.warn("no check session iframe found in the metadata");
|
|
1184
1185
|
} catch (e) {
|
|
@@ -1235,10 +1236,10 @@ var L = I, R = "openid", z = class {
|
|
|
1235
1236
|
this.id_token = e.id_token, this.session_state = e.session_state ?? null, this.access_token = e.access_token, this.refresh_token = e.refresh_token, this.token_type = e.token_type, this.scope = e.scope, this.profile = e.profile, this.expires_at = e.expires_at, this.state = e.userState, this.url_state = e.url_state;
|
|
1236
1237
|
}
|
|
1237
1238
|
get expires_in() {
|
|
1238
|
-
if (this.expires_at !== void 0) return this.expires_at -
|
|
1239
|
+
if (this.expires_at !== void 0) return this.expires_at - _.getEpochTime();
|
|
1239
1240
|
}
|
|
1240
1241
|
set expires_in(e) {
|
|
1241
|
-
e !== void 0 && (this.expires_at = Math.floor(e) +
|
|
1242
|
+
e !== void 0 && (this.expires_at = Math.floor(e) + _.getEpochTime());
|
|
1242
1243
|
}
|
|
1243
1244
|
get expired() {
|
|
1244
1245
|
let e = this.expires_in;
|
|
@@ -1248,7 +1249,7 @@ var L = I, R = "openid", z = class {
|
|
|
1248
1249
|
return this.scope?.split(" ") ?? [];
|
|
1249
1250
|
}
|
|
1250
1251
|
toStorageString() {
|
|
1251
|
-
return new
|
|
1252
|
+
return new l("User").create("toStorageString"), JSON.stringify({
|
|
1252
1253
|
id_token: this.id_token,
|
|
1253
1254
|
session_state: this.session_state,
|
|
1254
1255
|
access_token: this.access_token,
|
|
@@ -1260,11 +1261,11 @@ var L = I, R = "openid", z = class {
|
|
|
1260
1261
|
});
|
|
1261
1262
|
}
|
|
1262
1263
|
static fromStorageString(t) {
|
|
1263
|
-
return
|
|
1264
|
+
return l.createStatic("User", "fromStorageString"), new e(JSON.parse(t));
|
|
1264
1265
|
}
|
|
1265
1266
|
}, K = "oidc-client", q = class {
|
|
1266
1267
|
constructor() {
|
|
1267
|
-
this._abort = new
|
|
1268
|
+
this._abort = new h("Window navigation aborted"), this._disposeHandlers = /* @__PURE__ */ new Set(), this._window = null;
|
|
1268
1269
|
}
|
|
1269
1270
|
async navigate(e) {
|
|
1270
1271
|
let t = this._logger.create("navigate");
|
|
@@ -1275,7 +1276,7 @@ var L = I, R = "openid", z = class {
|
|
|
1275
1276
|
let a = i.data, o = e.scriptOrigin ?? window.location.origin;
|
|
1276
1277
|
if (i.origin === o && a?.source === K) {
|
|
1277
1278
|
try {
|
|
1278
|
-
let n =
|
|
1279
|
+
let n = v.readParams(a.url, e.response_mode).get("state");
|
|
1279
1280
|
if (n || t.warn("no state found in response url"), i.source !== this._window && n !== e.state) return;
|
|
1280
1281
|
} catch {
|
|
1281
1282
|
this._dispose(), r(/* @__PURE__ */ Error("Invalid response from window"));
|
|
@@ -1301,7 +1302,7 @@ var L = I, R = "openid", z = class {
|
|
|
1301
1302
|
source: K,
|
|
1302
1303
|
url: t,
|
|
1303
1304
|
keepOpen: n
|
|
1304
|
-
}, a = new
|
|
1305
|
+
}, a = new l("_notifyParent");
|
|
1305
1306
|
if (e) a.debug("With parent. Using parent.postMessage."), e.postMessage(i, r);
|
|
1306
1307
|
else {
|
|
1307
1308
|
a.debug("No parent. Using BroadcastChannel.");
|
|
@@ -1316,18 +1317,18 @@ var L = I, R = "openid", z = class {
|
|
|
1316
1317
|
toolbar: !1,
|
|
1317
1318
|
height: 640,
|
|
1318
1319
|
closePopupWindowAfterInSeconds: -1
|
|
1319
|
-
}, Y = "_blank",
|
|
1320
|
+
}, Y = "_blank", oe = 60, se = 2, X = 10, ce = class extends M {
|
|
1320
1321
|
constructor(e) {
|
|
1321
|
-
let { popup_redirect_uri: t = e.redirect_uri, popup_post_logout_redirect_uri: n = e.post_logout_redirect_uri, popupWindowFeatures: r = J, popupWindowTarget: i = Y, redirectMethod: a = "assign", redirectTarget: o = "self", iframeNotifyParentOrigin: s = e.iframeNotifyParentOrigin, iframeScriptOrigin: c = e.iframeScriptOrigin, requestTimeoutInSeconds: l, silent_redirect_uri: u = e.redirect_uri, silentRequestTimeoutInSeconds: d, automaticSilentRenew: f = !0, validateSubOnSilentRenew: p = !0, includeIdTokenInSilentRenew: m = !1, monitorSession: h = !1, monitorAnonymousSession: g = !1, checkSessionIntervalInSeconds: _ =
|
|
1322
|
-
if (super(e), this.popup_redirect_uri = t, this.popup_post_logout_redirect_uri = n, this.popupWindowFeatures = r, this.popupWindowTarget = i, this.redirectMethod = a, this.redirectTarget = o, this.iframeNotifyParentOrigin = s, this.iframeScriptOrigin = c, this.silent_redirect_uri = u, this.silentRequestTimeoutInSeconds = d || l || X, this.automaticSilentRenew = f, this.validateSubOnSilentRenew = p, this.includeIdTokenInSilentRenew = m, this.monitorSession = h, this.monitorAnonymousSession = g, this.checkSessionIntervalInSeconds = _, this.stopCheckSessionOnError = y, this.query_status_response_type = v, this.revokeTokenTypes = b, this.revokeTokensOnSignout = x, this.includeIdTokenInSilentSignout = S, this.accessTokenExpiringNotificationTimeInSeconds =
|
|
1322
|
+
let { popup_redirect_uri: t = e.redirect_uri, popup_post_logout_redirect_uri: n = e.post_logout_redirect_uri, popupWindowFeatures: r = J, popupWindowTarget: i = Y, redirectMethod: a = "assign", redirectTarget: o = "self", iframeNotifyParentOrigin: s = e.iframeNotifyParentOrigin, iframeScriptOrigin: c = e.iframeScriptOrigin, requestTimeoutInSeconds: l, silent_redirect_uri: u = e.redirect_uri, silentRequestTimeoutInSeconds: d, automaticSilentRenew: f = !0, validateSubOnSilentRenew: p = !0, includeIdTokenInSilentRenew: m = !1, monitorSession: h = !1, monitorAnonymousSession: g = !1, checkSessionIntervalInSeconds: _ = se, query_status_response_type: v = "code", stopCheckSessionOnError: y = !0, revokeTokenTypes: b = ["access_token", "refresh_token"], revokeTokensOnSignout: x = !1, includeIdTokenInSilentSignout: S = !1, accessTokenExpiringNotificationTimeInSeconds: C = oe, maxSilentRenewTimeoutRetries: T, userStore: E } = e;
|
|
1323
|
+
if (super(e), this.popup_redirect_uri = t, this.popup_post_logout_redirect_uri = n, this.popupWindowFeatures = r, this.popupWindowTarget = i, this.redirectMethod = a, this.redirectTarget = o, this.iframeNotifyParentOrigin = s, this.iframeScriptOrigin = c, this.silent_redirect_uri = u, this.silentRequestTimeoutInSeconds = d || l || X, this.automaticSilentRenew = f, this.validateSubOnSilentRenew = p, this.includeIdTokenInSilentRenew = m, this.monitorSession = h, this.monitorAnonymousSession = g, this.checkSessionIntervalInSeconds = _, this.stopCheckSessionOnError = y, this.query_status_response_type = v, this.revokeTokenTypes = b, this.revokeTokensOnSignout = x, this.includeIdTokenInSilentSignout = S, this.accessTokenExpiringNotificationTimeInSeconds = C, this.maxSilentRenewTimeoutRetries = T, E) this.userStore = E;
|
|
1323
1324
|
else {
|
|
1324
|
-
let e = typeof window < "u" ? window.sessionStorage : new
|
|
1325
|
-
this.userStore = new
|
|
1325
|
+
let e = typeof window < "u" ? window.sessionStorage : new w();
|
|
1326
|
+
this.userStore = new O({ store: e });
|
|
1326
1327
|
}
|
|
1327
1328
|
}
|
|
1328
1329
|
}, Z = class e extends q {
|
|
1329
1330
|
constructor({ silentRequestTimeoutInSeconds: t = X }) {
|
|
1330
|
-
super(), this._logger = new
|
|
1331
|
+
super(), this._logger = new l("IFrameWindow"), this._timeoutInSeconds = t, this._frame = e.createHiddenIframe(), this._window = this._frame.contentWindow;
|
|
1331
1332
|
}
|
|
1332
1333
|
static createHiddenIframe() {
|
|
1333
1334
|
let e = window.document.createElement("iframe");
|
|
@@ -1335,7 +1336,7 @@ var L = I, R = "openid", z = class {
|
|
|
1335
1336
|
}
|
|
1336
1337
|
async navigate(e) {
|
|
1337
1338
|
this._logger.debug("navigate: Using timeout of:", this._timeoutInSeconds);
|
|
1338
|
-
let t = setTimeout(() => void this._abort.raise(new
|
|
1339
|
+
let t = setTimeout(() => void this._abort.raise(new x("IFrame timed out without a response")), this._timeoutInSeconds * 1e3);
|
|
1339
1340
|
return this._disposeHandlers.add(() => clearTimeout(t)), await super.navigate(e);
|
|
1340
1341
|
}
|
|
1341
1342
|
close() {
|
|
@@ -1349,9 +1350,9 @@ var L = I, R = "openid", z = class {
|
|
|
1349
1350
|
static notifyParent(e, t) {
|
|
1350
1351
|
return super._notifyParent(window.parent, e, !1, t);
|
|
1351
1352
|
}
|
|
1352
|
-
},
|
|
1353
|
+
}, le = class {
|
|
1353
1354
|
constructor(e) {
|
|
1354
|
-
this._settings = e, this._logger = new
|
|
1355
|
+
this._settings = e, this._logger = new l("IFrameNavigator");
|
|
1355
1356
|
}
|
|
1356
1357
|
async prepare({ silentRequestTimeoutInSeconds: e = this._settings.silentRequestTimeoutInSeconds }) {
|
|
1357
1358
|
return new Z({ silentRequestTimeoutInSeconds: e });
|
|
@@ -1359,14 +1360,14 @@ var L = I, R = "openid", z = class {
|
|
|
1359
1360
|
async callback(e) {
|
|
1360
1361
|
this._logger.create("callback"), Z.notifyParent(e, this._settings.iframeNotifyParentOrigin);
|
|
1361
1362
|
}
|
|
1362
|
-
},
|
|
1363
|
+
}, ue = 500, de = 1e3, Q = class extends q {
|
|
1363
1364
|
constructor({ popupWindowTarget: e = Y, popupWindowFeatures: t = {}, popupSignal: n, popupAbortOnClose: r }) {
|
|
1364
|
-
super(), this._logger = new
|
|
1365
|
-
let i =
|
|
1365
|
+
super(), this._logger = new l("PopupWindow");
|
|
1366
|
+
let i = g.center({
|
|
1366
1367
|
...J,
|
|
1367
1368
|
...t
|
|
1368
1369
|
});
|
|
1369
|
-
this._window = window.open(void 0, e,
|
|
1370
|
+
this._window = window.open(void 0, e, g.serialize(i)), this.abortOnClose = !!r, n && n.addEventListener("abort", () => {
|
|
1370
1371
|
this._abort.raise(Error(n.reason ?? "Popup aborted"));
|
|
1371
1372
|
}), t.closePopupWindowAfterInSeconds && t.closePopupWindowAfterInSeconds > 0 && setTimeout(() => {
|
|
1372
1373
|
if (!this._window || typeof this._window.closed != "boolean" || this._window.closed) {
|
|
@@ -1374,14 +1375,14 @@ var L = I, R = "openid", z = class {
|
|
|
1374
1375
|
return;
|
|
1375
1376
|
}
|
|
1376
1377
|
this.close();
|
|
1377
|
-
}, t.closePopupWindowAfterInSeconds *
|
|
1378
|
+
}, t.closePopupWindowAfterInSeconds * de);
|
|
1378
1379
|
}
|
|
1379
1380
|
async navigate(e) {
|
|
1380
1381
|
var t;
|
|
1381
1382
|
(t = this._window) == null || t.focus();
|
|
1382
1383
|
let n = setInterval(() => {
|
|
1383
1384
|
(!this._window || this._window.closed) && (this._logger.debug("Popup closed by user or isolated by redirect"), r(), this._disposeHandlers.delete(r), this.abortOnClose && this._abort.raise(/* @__PURE__ */ Error("Popup closed by user")));
|
|
1384
|
-
},
|
|
1385
|
+
}, ue), r = () => clearInterval(n);
|
|
1385
1386
|
return this._disposeHandlers.add(r), await super.navigate(e);
|
|
1386
1387
|
}
|
|
1387
1388
|
close() {
|
|
@@ -1392,7 +1393,7 @@ var L = I, R = "openid", z = class {
|
|
|
1392
1393
|
}
|
|
1393
1394
|
}, $ = class {
|
|
1394
1395
|
constructor(e) {
|
|
1395
|
-
this._settings = e, this._logger = new
|
|
1396
|
+
this._settings = e, this._logger = new l("PopupNavigator");
|
|
1396
1397
|
}
|
|
1397
1398
|
async prepare({ popupWindowFeatures: e = this._settings.popupWindowFeatures, popupWindowTarget: t = this._settings.popupWindowTarget, popupSignal: n, popupAbortOnClose: r }) {
|
|
1398
1399
|
return new Q({
|
|
@@ -1405,9 +1406,9 @@ var L = I, R = "openid", z = class {
|
|
|
1405
1406
|
async callback(e, { keepOpen: t = !1 }) {
|
|
1406
1407
|
this._logger.create("callback"), Q.notifyOpener(e, t);
|
|
1407
1408
|
}
|
|
1408
|
-
},
|
|
1409
|
+
}, fe = class {
|
|
1409
1410
|
constructor(e) {
|
|
1410
|
-
this._settings = e, this._logger = new
|
|
1411
|
+
this._settings = e, this._logger = new l("RedirectNavigator");
|
|
1411
1412
|
}
|
|
1412
1413
|
async prepare({ redirectMethod: e = this._settings.redirectMethod, redirectTarget: t = this._settings.redirectTarget }) {
|
|
1413
1414
|
this._logger.create("prepare");
|
|
@@ -1424,9 +1425,9 @@ var L = I, R = "openid", z = class {
|
|
|
1424
1425
|
};
|
|
1425
1426
|
}
|
|
1426
1427
|
async callback() {}
|
|
1427
|
-
},
|
|
1428
|
+
}, pe = class extends S {
|
|
1428
1429
|
constructor(e) {
|
|
1429
|
-
super({ expiringNotificationTimeInSeconds: e.accessTokenExpiringNotificationTimeInSeconds }), this._logger = new
|
|
1430
|
+
super({ expiringNotificationTimeInSeconds: e.accessTokenExpiringNotificationTimeInSeconds }), this._logger = new l("UserManagerEvents"), this._userLoaded = new h("User loaded"), this._userUnloaded = new h("User unloaded"), this._silentRenewError = new h("Silent renew error"), this._userSignedIn = new h("User signed in"), this._userSignedOut = new h("User signed out"), this._userSessionChanged = new h("User session changed");
|
|
1430
1431
|
}
|
|
1431
1432
|
async load(e, t = !0) {
|
|
1432
1433
|
await super.load(e), t && await this._userLoaded.raise(e);
|
|
@@ -1482,14 +1483,14 @@ var L = I, R = "openid", z = class {
|
|
|
1482
1483
|
async _raiseUserSessionChanged() {
|
|
1483
1484
|
await this._userSessionChanged.raise();
|
|
1484
1485
|
}
|
|
1485
|
-
},
|
|
1486
|
+
}, me = class {
|
|
1486
1487
|
constructor(e) {
|
|
1487
|
-
this._userManager = e, this._logger = new
|
|
1488
|
+
this._userManager = e, this._logger = new l("SilentRenewService"), this._isStarted = !1, this._retryTimer = new _("Retry Silent Renew"), this._timeoutRetryCount = 0, this._tokenExpiring = async () => {
|
|
1488
1489
|
let e = this._logger.create("_tokenExpiring");
|
|
1489
1490
|
try {
|
|
1490
1491
|
await this._userManager.signinSilent(), this._timeoutRetryCount = 0, e.debug("silent token renewal successful");
|
|
1491
1492
|
} catch (t) {
|
|
1492
|
-
if (t instanceof
|
|
1493
|
+
if (t instanceof x) {
|
|
1493
1494
|
this._timeoutRetryCount++;
|
|
1494
1495
|
let n = this._userManager.settings.maxSilentRenewTimeoutRetries;
|
|
1495
1496
|
if (n !== void 0 && this._timeoutRetryCount > n) {
|
|
@@ -1517,13 +1518,13 @@ var L = I, R = "openid", z = class {
|
|
|
1517
1518
|
stop() {
|
|
1518
1519
|
this._isStarted &&= (this._retryTimer.cancel(), this._retryTimer.removeHandler(this._tokenExpiring), this._userManager.events.removeAccessTokenExpiring(this._tokenExpiring), !1);
|
|
1519
1520
|
}
|
|
1520
|
-
},
|
|
1521
|
+
}, he = class {
|
|
1521
1522
|
constructor(e) {
|
|
1522
1523
|
this.refresh_token = e.refresh_token, this.id_token = e.id_token, this.session_state = e.session_state, this.scope = e.scope, this.profile = e.profile, this.data = e.state;
|
|
1523
1524
|
}
|
|
1524
|
-
},
|
|
1525
|
+
}, ge = class {
|
|
1525
1526
|
constructor(e, t, n, r) {
|
|
1526
|
-
this._logger = new
|
|
1527
|
+
this._logger = new l("UserManager"), this.settings = new ce(e), this._client = new U(e), this._redirectNavigator = t ?? new fe(this.settings), this._popupNavigator = n ?? new $(this.settings), this._iframeNavigator = r ?? new le(this.settings), this._events = new pe(this.settings), this._silentRenewService = new me(this), this.settings.automaticSilentRenew && this.startSilentRenew(), this._sessionMonitor = null, this.settings.monitorSession && (this._sessionMonitor = new W(this));
|
|
1527
1528
|
}
|
|
1528
1529
|
get events() {
|
|
1529
1530
|
return this._events;
|
|
@@ -1592,7 +1593,7 @@ var L = I, R = "openid", z = class {
|
|
|
1592
1593
|
let t = this._logger.create("signinSilent"), { silentRequestTimeoutInSeconds: n, ...r } = e, i = await this._loadUser();
|
|
1593
1594
|
if (!e.forceIframeAuth && i?.refresh_token) {
|
|
1594
1595
|
t.debug("using refresh token");
|
|
1595
|
-
let e = new
|
|
1596
|
+
let e = new he(i);
|
|
1596
1597
|
return await this._useRefreshToken({
|
|
1597
1598
|
state: e,
|
|
1598
1599
|
redirect_uri: r.redirect_uri,
|
|
@@ -1677,7 +1678,7 @@ var L = I, R = "openid", z = class {
|
|
|
1677
1678
|
sub: e.profile.sub
|
|
1678
1679
|
}) : (t.info("success, user not authenticated"), null);
|
|
1679
1680
|
} catch (e) {
|
|
1680
|
-
if (this.settings.monitorAnonymousSession && e instanceof
|
|
1681
|
+
if (this.settings.monitorAnonymousSession && e instanceof b) switch (e.error) {
|
|
1681
1682
|
case "login_required":
|
|
1682
1683
|
case "consent_required":
|
|
1683
1684
|
case "interaction_required":
|
|
@@ -1711,7 +1712,7 @@ var L = I, R = "openid", z = class {
|
|
|
1711
1712
|
async _buildUser(e, t) {
|
|
1712
1713
|
let n = this._logger.create("_buildUser"), r = new G(e);
|
|
1713
1714
|
if (t) {
|
|
1714
|
-
if (t !== r.profile.sub) throw n.debug("current user does not match user returned from signin. sub from signin:", r.profile.sub), new
|
|
1715
|
+
if (t !== r.profile.sub) throw n.debug("current user does not match user returned from signin. sub from signin:", r.profile.sub), new b({
|
|
1715
1716
|
...e,
|
|
1716
1717
|
error: "login_required"
|
|
1717
1718
|
});
|
|
@@ -1827,7 +1828,7 @@ var L = I, R = "openid", z = class {
|
|
|
1827
1828
|
}
|
|
1828
1829
|
async dpopProof(e, t, n, r) {
|
|
1829
1830
|
let i = await (this.settings.dpop?.store)?.get(this.settings.client_id);
|
|
1830
|
-
if (i) return await
|
|
1831
|
+
if (i) return await m.generateDPoPProof({
|
|
1831
1832
|
url: e,
|
|
1832
1833
|
accessToken: t?.access_token,
|
|
1833
1834
|
httpMethod: n,
|
|
@@ -1837,10 +1838,33 @@ var L = I, R = "openid", z = class {
|
|
|
1837
1838
|
}
|
|
1838
1839
|
async generateDPoPJkt(e) {
|
|
1839
1840
|
let t = await e.store.get(this.settings.client_id);
|
|
1840
|
-
return t || (t = new
|
|
1841
|
+
return t || (t = new H(await m.generateDPoPKeys()), await e.store.set(this.settings.client_id, t)), await m.generateDPoPJkt(t.keys);
|
|
1842
|
+
}
|
|
1843
|
+
}, _e = class {
|
|
1844
|
+
static userManager;
|
|
1845
|
+
static getSettings(t) {
|
|
1846
|
+
let n = new URL(e.getInstance().window.location.href);
|
|
1847
|
+
n.search = "", n.pathname = "/post-login";
|
|
1848
|
+
let r = n.toString();
|
|
1849
|
+
n.pathname = "/post-logout";
|
|
1850
|
+
let i = n.toString();
|
|
1851
|
+
return {
|
|
1852
|
+
authority: t.issuer,
|
|
1853
|
+
automaticSilentRenew: !0,
|
|
1854
|
+
client_id: t.client_id,
|
|
1855
|
+
client_secret: t.client_secret,
|
|
1856
|
+
metadataUrl: t.discovery_url,
|
|
1857
|
+
post_logout_redirect_uri: i,
|
|
1858
|
+
redirect_uri: r,
|
|
1859
|
+
refreshTokenAllowedScope: "",
|
|
1860
|
+
response_type: "code",
|
|
1861
|
+
scope: t.scope,
|
|
1862
|
+
userStore: new O({ store: sessionStorage }),
|
|
1863
|
+
validateSubOnSilentRenew: !0
|
|
1864
|
+
};
|
|
1841
1865
|
}
|
|
1842
1866
|
};
|
|
1843
1867
|
//#endregion
|
|
1844
|
-
export {
|
|
1868
|
+
export { ge as n, _e as t };
|
|
1845
1869
|
|
|
1846
|
-
//# sourceMappingURL=
|
|
1870
|
+
//# sourceMappingURL=UserManagerUtil.js.map
|