@muze-nl/metro-oidc 0.2.0 → 0.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/browser.js +679 -748
- package/dist/browser.js.map +4 -4
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +4 -4
- package/package.json +3 -3
- package/src/browser.mjs +10 -3
- package/src/oidc.discovery.mjs +1 -1
- package/src/oidc.register.mjs +1 -1
- package/src/oidcmw.mjs +43 -26
package/dist/browser.js
CHANGED
|
@@ -107,12 +107,7 @@
|
|
|
107
107
|
}
|
|
108
108
|
const metrofetch = async function browserFetch(req2) {
|
|
109
109
|
if (req2[Symbol.metroProxy]) {
|
|
110
|
-
|
|
111
|
-
let body = req2.body[Symbol.metroSource];
|
|
112
|
-
req2 = new Request(req2[Symbol.metroSource], { body });
|
|
113
|
-
} else {
|
|
114
|
-
req2 = req2[Symbol.metroSource];
|
|
115
|
-
}
|
|
110
|
+
req2 = req2[Symbol.metroSource];
|
|
116
111
|
}
|
|
117
112
|
const res = await fetch(req2);
|
|
118
113
|
return response(res);
|
|
@@ -149,103 +144,6 @@
|
|
|
149
144
|
function client(...options) {
|
|
150
145
|
return new Client(...options);
|
|
151
146
|
}
|
|
152
|
-
function bodyProxy(body, r) {
|
|
153
|
-
let source = r.body;
|
|
154
|
-
if (!source) {
|
|
155
|
-
if (body === null) {
|
|
156
|
-
source = new ReadableStream();
|
|
157
|
-
} else if (body instanceof ReadableStream) {
|
|
158
|
-
source = body;
|
|
159
|
-
} else if (body instanceof Blob) {
|
|
160
|
-
source = body.stream();
|
|
161
|
-
} else {
|
|
162
|
-
source = new ReadableStream({
|
|
163
|
-
start(controller) {
|
|
164
|
-
let chunk;
|
|
165
|
-
switch (typeof body) {
|
|
166
|
-
case "object":
|
|
167
|
-
if (typeof body.toString == "function") {
|
|
168
|
-
chunk = body.toString();
|
|
169
|
-
} else if (body instanceof FormData) {
|
|
170
|
-
chunk = new URLSearchParams(body).toString();
|
|
171
|
-
} else if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) {
|
|
172
|
-
chunk = body;
|
|
173
|
-
} else {
|
|
174
|
-
throw metroError("Cannot convert body to ReadableStream", body);
|
|
175
|
-
}
|
|
176
|
-
break;
|
|
177
|
-
case "string":
|
|
178
|
-
case "number":
|
|
179
|
-
case "boolean":
|
|
180
|
-
chunk = body;
|
|
181
|
-
break;
|
|
182
|
-
default:
|
|
183
|
-
throw metroError("Cannot convert body to ReadableStream", body);
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
controller.enqueue(chunk);
|
|
187
|
-
controller.close();
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return new Proxy(source, {
|
|
193
|
-
get(target, prop, receiver) {
|
|
194
|
-
switch (prop) {
|
|
195
|
-
case Symbol.metroProxy:
|
|
196
|
-
return true;
|
|
197
|
-
break;
|
|
198
|
-
case Symbol.metroSource:
|
|
199
|
-
return body;
|
|
200
|
-
break;
|
|
201
|
-
case "toString":
|
|
202
|
-
return function() {
|
|
203
|
-
return "" + body;
|
|
204
|
-
};
|
|
205
|
-
break;
|
|
206
|
-
}
|
|
207
|
-
if (body && typeof body == "object") {
|
|
208
|
-
if (prop in body) {
|
|
209
|
-
if (typeof body[prop] == "function") {
|
|
210
|
-
return function(...args) {
|
|
211
|
-
return body[prop].apply(body, args);
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
return body[prop];
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (prop in target && prop != "toString") {
|
|
218
|
-
if (typeof target[prop] == "function") {
|
|
219
|
-
return function(...args) {
|
|
220
|
-
return target[prop].apply(target, args);
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
return target[prop];
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
has(target, prop) {
|
|
227
|
-
if (body && typeof body == "object") {
|
|
228
|
-
return prop in body;
|
|
229
|
-
} else {
|
|
230
|
-
return prop in target;
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
ownKeys(target) {
|
|
234
|
-
if (body && typeof body == "object") {
|
|
235
|
-
return Reflect.ownKeys(body);
|
|
236
|
-
} else {
|
|
237
|
-
return Reflect.ownKeys(target);
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
getOwnPropertyDescriptor(target, prop) {
|
|
241
|
-
if (body && typeof body == "object") {
|
|
242
|
-
return Object.getOwnPropertyDescriptor(body, prop);
|
|
243
|
-
} else {
|
|
244
|
-
return Object.getOwnPropertyDescriptor(target, prop);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
147
|
function getRequestParams(req, current) {
|
|
250
148
|
let params2 = current || {};
|
|
251
149
|
if (!params2.url && current.url) {
|
|
@@ -275,7 +173,7 @@
|
|
|
275
173
|
value = value[Symbol.metroSource];
|
|
276
174
|
}
|
|
277
175
|
if (typeof value == "function") {
|
|
278
|
-
value(params2[prop], params2);
|
|
176
|
+
params2[prop] = value(params2[prop], params2);
|
|
279
177
|
} else {
|
|
280
178
|
if (prop == "url") {
|
|
281
179
|
params2.url = url(params2.url, value);
|
|
@@ -292,6 +190,9 @@
|
|
|
292
190
|
}
|
|
293
191
|
}
|
|
294
192
|
}
|
|
193
|
+
if (req instanceof Request && req.data) {
|
|
194
|
+
params2.body = req.data;
|
|
195
|
+
}
|
|
295
196
|
return params2;
|
|
296
197
|
}
|
|
297
198
|
function request(...options) {
|
|
@@ -309,10 +210,10 @@
|
|
|
309
210
|
Object.assign(requestParams, getRequestParams(option, requestParams));
|
|
310
211
|
}
|
|
311
212
|
}
|
|
312
|
-
let
|
|
313
|
-
if (
|
|
314
|
-
if (typeof
|
|
315
|
-
requestParams.body = JSON.stringify(
|
|
213
|
+
let data = requestParams.body;
|
|
214
|
+
if (data) {
|
|
215
|
+
if (typeof data == "object" && !(data instanceof String) && !(data instanceof ReadableStream) && !(data instanceof Blob) && !(data instanceof ArrayBuffer) && !(data instanceof DataView) && !(data instanceof FormData) && !(data instanceof URLSearchParams) && (typeof TypedArray == "undefined" || !(data instanceof TypedArray))) {
|
|
216
|
+
requestParams.body = JSON.stringify(data);
|
|
316
217
|
}
|
|
317
218
|
}
|
|
318
219
|
let r = new Request(requestParams.url, requestParams);
|
|
@@ -328,25 +229,21 @@
|
|
|
328
229
|
break;
|
|
329
230
|
case "with":
|
|
330
231
|
return function(...options2) {
|
|
331
|
-
if (
|
|
332
|
-
options2.unshift({ body });
|
|
232
|
+
if (data) {
|
|
233
|
+
options2.unshift({ body: data });
|
|
333
234
|
}
|
|
334
235
|
return request(target, ...options2);
|
|
335
236
|
};
|
|
336
237
|
break;
|
|
337
238
|
case "body":
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
if (body) {
|
|
342
|
-
if (body[Symbol.metroProxy]) {
|
|
343
|
-
return body;
|
|
344
|
-
}
|
|
345
|
-
return bodyProxy(body, target);
|
|
346
|
-
}
|
|
239
|
+
break;
|
|
240
|
+
case "data":
|
|
241
|
+
return data;
|
|
347
242
|
break;
|
|
348
243
|
}
|
|
349
244
|
if (target[prop] instanceof Function) {
|
|
245
|
+
if (prop === "clone") {
|
|
246
|
+
}
|
|
350
247
|
return target[prop].bind(target);
|
|
351
248
|
}
|
|
352
249
|
return target[prop];
|
|
@@ -367,7 +264,7 @@
|
|
|
367
264
|
value = value[Symbol.metroSource];
|
|
368
265
|
}
|
|
369
266
|
if (typeof value == "function") {
|
|
370
|
-
value(params2[prop], params2);
|
|
267
|
+
params2[prop] = value(params2[prop], params2);
|
|
371
268
|
} else {
|
|
372
269
|
if (prop == "url") {
|
|
373
270
|
params2.url = new URL(value, params2.url || "https://localhost/");
|
|
@@ -376,6 +273,9 @@
|
|
|
376
273
|
}
|
|
377
274
|
}
|
|
378
275
|
}
|
|
276
|
+
if (res instanceof Response && res.data) {
|
|
277
|
+
params2.body = res.data;
|
|
278
|
+
}
|
|
379
279
|
return params2;
|
|
380
280
|
}
|
|
381
281
|
function response(...options) {
|
|
@@ -393,6 +293,10 @@
|
|
|
393
293
|
}
|
|
394
294
|
}
|
|
395
295
|
}
|
|
296
|
+
let data = void 0;
|
|
297
|
+
if (responseParams.body) {
|
|
298
|
+
data = responseParams.body;
|
|
299
|
+
}
|
|
396
300
|
let r = new Response(responseParams.body, responseParams);
|
|
397
301
|
Object.freeze(r);
|
|
398
302
|
return new Proxy(r, {
|
|
@@ -409,37 +313,17 @@
|
|
|
409
313
|
return response(target, ...options2);
|
|
410
314
|
};
|
|
411
315
|
break;
|
|
412
|
-
case "
|
|
413
|
-
|
|
414
|
-
if (responseParams.body[Symbol.metroProxy]) {
|
|
415
|
-
return responseParams.body;
|
|
416
|
-
}
|
|
417
|
-
return bodyProxy(responseParams.body, target);
|
|
418
|
-
} else {
|
|
419
|
-
return bodyProxy("", target);
|
|
420
|
-
}
|
|
316
|
+
case "data":
|
|
317
|
+
return data;
|
|
421
318
|
break;
|
|
422
319
|
case "ok":
|
|
423
320
|
return target.status >= 200 && target.status < 400;
|
|
424
321
|
break;
|
|
425
|
-
case "headers":
|
|
426
|
-
return target.headers;
|
|
427
|
-
break;
|
|
428
|
-
default:
|
|
429
|
-
if (prop in responseParams && prop != "toString") {
|
|
430
|
-
return responseParams[prop];
|
|
431
|
-
}
|
|
432
|
-
if (prop in target && prop != "toString") {
|
|
433
|
-
if (typeof target[prop] == "function") {
|
|
434
|
-
return function(...args) {
|
|
435
|
-
return target[prop].apply(target, args);
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
return target[prop];
|
|
439
|
-
}
|
|
440
|
-
break;
|
|
441
322
|
}
|
|
442
|
-
|
|
323
|
+
if (typeof target[prop] == "function") {
|
|
324
|
+
return target[prop].bind(target);
|
|
325
|
+
}
|
|
326
|
+
return target[prop];
|
|
443
327
|
}
|
|
444
328
|
});
|
|
445
329
|
}
|
|
@@ -636,38 +520,52 @@
|
|
|
636
520
|
// node_modules/@muze-nl/metro/src/mw/json.mjs
|
|
637
521
|
function jsonmw(options) {
|
|
638
522
|
options = Object.assign({
|
|
523
|
+
mimetype: "application/json",
|
|
639
524
|
reviver: null,
|
|
640
525
|
replacer: null,
|
|
641
526
|
space: ""
|
|
642
527
|
}, options);
|
|
643
528
|
return async (req, next) => {
|
|
644
|
-
if (
|
|
529
|
+
if (!isJSON(req.headers.get("Accept"))) {
|
|
645
530
|
req = req.with({
|
|
646
531
|
headers: {
|
|
647
|
-
"
|
|
648
|
-
"Accept": "application/json"
|
|
532
|
+
"Accept": options.mimetype
|
|
649
533
|
}
|
|
650
534
|
});
|
|
651
|
-
|
|
535
|
+
}
|
|
536
|
+
if (["POST", "PUT", "PATCH", "QUERY"].includes(req.method)) {
|
|
537
|
+
if (req.data && typeof req.data == "object" && !(req.data instanceof ReadableStream)) {
|
|
538
|
+
if (!isJSON(req.headers.get("content-type"))) {
|
|
539
|
+
req = req.with({
|
|
540
|
+
headers: {
|
|
541
|
+
"Content-Type": options.mimetype
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
}
|
|
652
545
|
req = req.with({
|
|
653
|
-
body: JSON.stringify(req.
|
|
546
|
+
body: JSON.stringify(req.data, options.replacer, options.space)
|
|
654
547
|
});
|
|
655
548
|
}
|
|
656
|
-
} else {
|
|
657
|
-
req = req.with({
|
|
658
|
-
headers: {
|
|
659
|
-
"Accept": "application/json"
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
549
|
}
|
|
663
550
|
let res = await next(req);
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
551
|
+
if (isJSON(res.headers.get("content-type"))) {
|
|
552
|
+
let tempRes = res.clone();
|
|
553
|
+
let body = await tempRes.text();
|
|
554
|
+
try {
|
|
555
|
+
let json = JSON.parse(body, options.reviver);
|
|
556
|
+
return res.with({
|
|
557
|
+
body: json
|
|
558
|
+
});
|
|
559
|
+
} catch (e) {
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return res;
|
|
669
563
|
};
|
|
670
564
|
}
|
|
565
|
+
var jsonRE = /^application\/([a-zA-Z0-9\-_]+\+)?json\b/;
|
|
566
|
+
function isJSON(contentType) {
|
|
567
|
+
return jsonRE.exec(contentType);
|
|
568
|
+
}
|
|
671
569
|
|
|
672
570
|
// node_modules/@muze-nl/metro/src/mw/thrower.mjs
|
|
673
571
|
function thrower(options) {
|
|
@@ -696,199 +594,134 @@
|
|
|
696
594
|
globalThis.metro = metro;
|
|
697
595
|
var everything_default = metro;
|
|
698
596
|
|
|
699
|
-
// node_modules/@muze-nl/
|
|
597
|
+
// node_modules/@muze-nl/metro-oauth2/src/oauth2.mjs
|
|
598
|
+
var oauth2_exports = {};
|
|
599
|
+
__export(oauth2_exports, {
|
|
600
|
+
authorizePopup: () => authorizePopup,
|
|
601
|
+
base64url_encode: () => base64url_encode,
|
|
602
|
+
createState: () => createState,
|
|
603
|
+
default: () => oauth2mw,
|
|
604
|
+
generateCodeChallenge: () => generateCodeChallenge,
|
|
605
|
+
generateCodeVerifier: () => generateCodeVerifier,
|
|
606
|
+
getExpires: () => getExpires,
|
|
607
|
+
isExpired: () => isExpired,
|
|
608
|
+
isRedirected: () => isRedirected
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
// node_modules/@muze-nl/metro-oauth2/node_modules/@muze-nl/assert/src/assert.mjs
|
|
700
612
|
globalThis.assertEnabled = false;
|
|
701
|
-
|
|
613
|
+
var assert = (source, test) => {
|
|
702
614
|
if (globalThis.assertEnabled) {
|
|
703
615
|
let problems = fails(source, test);
|
|
704
616
|
if (problems) {
|
|
705
|
-
|
|
706
|
-
throw new Error("Assertions failed", {
|
|
707
|
-
cause: { problems, source }
|
|
708
|
-
});
|
|
617
|
+
throw new assertError("Assertions failed", problems, source);
|
|
709
618
|
}
|
|
710
619
|
}
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
if (data == null || typeof data == "undefined") {
|
|
722
|
-
return error("data is required", data, pattern || "any value", path);
|
|
723
|
-
} else if (typeof pattern != "undefined") {
|
|
724
|
-
return fails(data, pattern, root, path);
|
|
725
|
-
} else {
|
|
726
|
-
return false;
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
}
|
|
730
|
-
function Recommended(pattern) {
|
|
731
|
-
return function _Recommended(data, root, path) {
|
|
732
|
-
if (data == null || typeof data == "undefined") {
|
|
733
|
-
console.warn("data does not contain recommended value", data, pattern, path);
|
|
620
|
+
};
|
|
621
|
+
var Optional = (pattern) => (data) => data == null || typeof data == "undefined" ? false : fails(data, pattern);
|
|
622
|
+
var Required = (pattern) => (data) => fails(data, pattern);
|
|
623
|
+
var Recommended = (pattern) => (data) => data == null || typeof data == "undefined" ? (() => {
|
|
624
|
+
console.warning("data does not contain recommended value", data, pattern);
|
|
625
|
+
return false;
|
|
626
|
+
})() : fails(data, pattern);
|
|
627
|
+
var oneOf = (...patterns) => (data) => {
|
|
628
|
+
for (let pattern of patterns) {
|
|
629
|
+
if (!fails(data, pattern)) {
|
|
734
630
|
return false;
|
|
735
|
-
} else {
|
|
736
|
-
return fails(data, pattern, root, path);
|
|
737
|
-
}
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
|
-
function oneOf(...patterns) {
|
|
741
|
-
return function _oneOf(data, root, path) {
|
|
742
|
-
for (let pattern of patterns) {
|
|
743
|
-
if (!fails(data, pattern, root, path)) {
|
|
744
|
-
return false;
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
return error("data does not match oneOf patterns", data, patterns, path);
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
function anyOf(...patterns) {
|
|
751
|
-
return function _anyOf(data, root, path) {
|
|
752
|
-
if (!Array.isArray(data)) {
|
|
753
|
-
return error("data is not an array", data, "anyOf", path);
|
|
754
|
-
}
|
|
755
|
-
for (let value of data) {
|
|
756
|
-
if (oneOf(...patterns)(value)) {
|
|
757
|
-
return error("data does not match anyOf patterns", value, patterns, path);
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
return false;
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
function allOf(...patterns) {
|
|
764
|
-
return function _allOf(data, root, path) {
|
|
765
|
-
let problems = [];
|
|
766
|
-
for (let pattern of patterns) {
|
|
767
|
-
problems = problems.concat(fails(data, pattern, root, path));
|
|
768
631
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
632
|
+
}
|
|
633
|
+
return error("data does not match oneOf patterns", data, patterns);
|
|
634
|
+
};
|
|
635
|
+
var anyOf = (...patterns) => (data) => {
|
|
636
|
+
if (!Array.isArray(data)) {
|
|
637
|
+
return error("data is not an array", data, "anyOf");
|
|
638
|
+
}
|
|
639
|
+
for (let value of data) {
|
|
640
|
+
if (oneOf(...patterns)(value)) {
|
|
641
|
+
return error("data does not match anyOf patterns", value, patterns);
|
|
772
642
|
}
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
|
|
643
|
+
}
|
|
644
|
+
return false;
|
|
645
|
+
};
|
|
646
|
+
function validURL(data) {
|
|
776
647
|
try {
|
|
777
648
|
if (data instanceof URL) {
|
|
778
649
|
data = data.href;
|
|
779
650
|
}
|
|
780
651
|
let url2 = new URL(data);
|
|
781
652
|
if (url2.href != data) {
|
|
782
|
-
|
|
783
|
-
return error("data is not a valid url", data, "validURL", path);
|
|
784
|
-
}
|
|
653
|
+
return error("data is not a valid url", data, "validURL");
|
|
785
654
|
}
|
|
786
655
|
} catch (e) {
|
|
787
|
-
return error("data is not a valid url", data, "validURL"
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
function validEmail(data, root, path) {
|
|
791
|
-
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data)) {
|
|
792
|
-
return error("data is not a valid email", data, "validEmail", path);
|
|
656
|
+
return error("data is not a valid url", data, "validURL");
|
|
793
657
|
}
|
|
658
|
+
return false;
|
|
794
659
|
}
|
|
795
|
-
function
|
|
796
|
-
return function _instanceOf(data, root, path) {
|
|
797
|
-
if (!(data instanceof constructor)) {
|
|
798
|
-
return error("data is not an instanceof pattern", data, constructor, path);
|
|
799
|
-
}
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
function not(pattern) {
|
|
803
|
-
return function _not(data, root, path) {
|
|
804
|
-
if (!fails(data, pattern, root, path)) {
|
|
805
|
-
return error("data matches pattern, when required not to", data, pattern, path);
|
|
806
|
-
}
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
function fails(data, pattern, root, path = "") {
|
|
660
|
+
function fails(data, pattern, root) {
|
|
810
661
|
if (!root) {
|
|
811
662
|
root = data;
|
|
812
663
|
}
|
|
813
664
|
let problems = [];
|
|
814
665
|
if (pattern === Boolean) {
|
|
815
|
-
if (typeof data != "boolean"
|
|
816
|
-
problems.push(error("data is not a boolean", data, pattern
|
|
666
|
+
if (typeof data != "boolean") {
|
|
667
|
+
problems.push(error("data is not a boolean", data, pattern));
|
|
817
668
|
}
|
|
818
669
|
} else if (pattern === Number) {
|
|
819
|
-
if (typeof data != "number"
|
|
820
|
-
problems.push(error("data is not a number", data, pattern
|
|
821
|
-
}
|
|
822
|
-
} else if (pattern === String) {
|
|
823
|
-
if (typeof data != "string" && !(data instanceof String)) {
|
|
824
|
-
problems.push(error("data is not a string", data, pattern, path));
|
|
825
|
-
}
|
|
826
|
-
if (data == "") {
|
|
827
|
-
problems.push(error("data is an empty string, which is not allowed", data, pattern, path));
|
|
670
|
+
if (typeof data != "number") {
|
|
671
|
+
problems.push(error("data is not a number", data, pattern));
|
|
828
672
|
}
|
|
829
673
|
} else if (pattern instanceof RegExp) {
|
|
830
674
|
if (Array.isArray(data)) {
|
|
831
|
-
let index = data.findIndex((element
|
|
675
|
+
let index = data.findIndex((element) => fails(element, pattern, root));
|
|
832
676
|
if (index > -1) {
|
|
833
|
-
problems.push(error("data[" + index + "] does not match pattern", data[index], pattern
|
|
677
|
+
problems.push(error("data[" + index + "] does not match pattern", data[index], pattern));
|
|
834
678
|
}
|
|
835
|
-
} else if (typeof data == "undefined") {
|
|
836
|
-
problems.push(error("data is undefined, should match pattern", data, pattern, path));
|
|
837
679
|
} else if (!pattern.test(data)) {
|
|
838
|
-
problems.push(error("data does not match pattern", data, pattern
|
|
680
|
+
problems.push(error("data does not match pattern", data, pattern));
|
|
839
681
|
}
|
|
840
682
|
} else if (pattern instanceof Function) {
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
if (Array.isArray(problem)) {
|
|
844
|
-
problems = problems.concat(problem);
|
|
845
|
-
} else {
|
|
846
|
-
problems.push(problem);
|
|
847
|
-
}
|
|
683
|
+
if (pattern(data, root)) {
|
|
684
|
+
problems.push(error("data does not match function", data, pattern));
|
|
848
685
|
}
|
|
849
686
|
} else if (Array.isArray(pattern)) {
|
|
850
687
|
if (!Array.isArray(data)) {
|
|
851
|
-
problems.push(error("data is not an array", data, []
|
|
688
|
+
problems.push(error("data is not an array", data, []));
|
|
852
689
|
}
|
|
853
|
-
for (
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
problems.push(problem);
|
|
860
|
-
}
|
|
690
|
+
for (p of pattern) {
|
|
691
|
+
let problem = fails(data, p, root);
|
|
692
|
+
if (Array.isArray(problem)) {
|
|
693
|
+
problems.concat(problem);
|
|
694
|
+
} else if (problem) {
|
|
695
|
+
problems.push(problem);
|
|
861
696
|
}
|
|
862
697
|
}
|
|
863
698
|
} else if (pattern && typeof pattern == "object") {
|
|
864
699
|
if (Array.isArray(data)) {
|
|
865
|
-
let index = data.findIndex((element
|
|
700
|
+
let index = data.findIndex((element) => fails(element, pattern, root));
|
|
866
701
|
if (index > -1) {
|
|
867
|
-
problems.push(error("data[" + index + "] does not match pattern", data[index], pattern
|
|
702
|
+
problems.push(error("data[" + index + "] does not match pattern", data[index], pattern));
|
|
868
703
|
}
|
|
869
704
|
} else if (!data || typeof data != "object") {
|
|
870
|
-
problems.push(error("data is not an object, pattern is", data, pattern
|
|
705
|
+
problems.push(error("data is not an object, pattern is", data, pattern));
|
|
871
706
|
} else {
|
|
872
707
|
if (data instanceof URLSearchParams) {
|
|
873
708
|
data = Object.fromEntries(data);
|
|
874
709
|
}
|
|
875
|
-
|
|
876
|
-
|
|
710
|
+
let p2 = problems[problems.length - 1];
|
|
711
|
+
for (const [wKey, wVal] of Object.entries(pattern)) {
|
|
712
|
+
let result = fails(data[wKey], wVal, root);
|
|
877
713
|
if (result) {
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
for (const [wKey, wVal] of Object.entries(pattern)) {
|
|
882
|
-
let result = fails(data[wKey], wVal, root, path + "." + wKey);
|
|
883
|
-
if (result) {
|
|
884
|
-
problems = problems.concat(result);
|
|
714
|
+
if (!p2 || typeof p2 == "string") {
|
|
715
|
+
p2 = {};
|
|
716
|
+
problems.push(error(p2, data[wKey], wVal));
|
|
885
717
|
}
|
|
718
|
+
p2[wKey] = result.problems;
|
|
886
719
|
}
|
|
887
720
|
}
|
|
888
721
|
}
|
|
889
722
|
} else {
|
|
890
723
|
if (pattern != data) {
|
|
891
|
-
problems.push(error("data and pattern are not equal", data, pattern
|
|
724
|
+
problems.push(error("data and pattern are not equal", data, pattern));
|
|
892
725
|
}
|
|
893
726
|
}
|
|
894
727
|
if (problems.length) {
|
|
@@ -896,334 +729,35 @@
|
|
|
896
729
|
}
|
|
897
730
|
return false;
|
|
898
731
|
}
|
|
899
|
-
|
|
900
|
-
|
|
732
|
+
var assertError = class extends Error {
|
|
733
|
+
constructor(message, problems, ...details) {
|
|
734
|
+
super(message);
|
|
735
|
+
this.problems = problems;
|
|
736
|
+
this.details = details;
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
function error(message, found, expected) {
|
|
740
|
+
return {
|
|
901
741
|
message,
|
|
902
742
|
found,
|
|
903
|
-
expected
|
|
904
|
-
path
|
|
743
|
+
expected
|
|
905
744
|
};
|
|
906
|
-
if (problems) {
|
|
907
|
-
result.problems = problems;
|
|
908
|
-
}
|
|
909
|
-
return result;
|
|
910
745
|
}
|
|
911
746
|
|
|
912
|
-
// src/
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
var validJWA = [
|
|
927
|
-
"HS256",
|
|
928
|
-
"HS384",
|
|
929
|
-
"HS512",
|
|
930
|
-
"RS256",
|
|
931
|
-
"RS384",
|
|
932
|
-
"RS512",
|
|
933
|
-
"ES256",
|
|
934
|
-
"ES384",
|
|
935
|
-
"ES512"
|
|
936
|
-
];
|
|
937
|
-
var validAuthMethods = [
|
|
938
|
-
"client_secret_post",
|
|
939
|
-
"client_secret_basic",
|
|
940
|
-
"client_secret_jwt",
|
|
941
|
-
"private_key_jwt"
|
|
942
|
-
];
|
|
943
|
-
|
|
944
|
-
// src/oidc.discovery.mjs
|
|
945
|
-
async function oidcDiscovery(options = {}) {
|
|
946
|
-
assert(options, {
|
|
947
|
-
client: Optional(instanceOf(everything_default.client().constructor)),
|
|
948
|
-
issuer: Required(validURL)
|
|
949
|
-
});
|
|
950
|
-
const defaultOptions = {
|
|
951
|
-
client: everything_default.client().with(thrower()).with(jsonmw()),
|
|
952
|
-
requireDynamicRegistration: false
|
|
953
|
-
};
|
|
954
|
-
options = Object.assign({}, defaultOptions, options);
|
|
955
|
-
const TestSucceeded = false;
|
|
956
|
-
function MustUseHTTPS(url2) {
|
|
957
|
-
return TestSucceeded;
|
|
958
|
-
}
|
|
959
|
-
const openid_provider_metadata = {
|
|
960
|
-
issuer: Required(allOf(options.issuer, MustUseHTTPS)),
|
|
961
|
-
authorization_endpoint: Required(validURL),
|
|
962
|
-
token_endpoint: Required(validURL),
|
|
963
|
-
userinfo_endpoint: Recommended(validURL),
|
|
964
|
-
// todo: test for https protocol
|
|
965
|
-
jwks_uri: Required(validURL),
|
|
966
|
-
registration_endpoint: options.requireDynamicRegistration ? Required(validURL) : Recommended(validURL),
|
|
967
|
-
scopes_supported: Recommended(MustInclude("openid")),
|
|
968
|
-
response_types_supported: options.requireDynamicRegistration ? Required(MustInclude("code", "id_token", "id_token token")) : Required([]),
|
|
969
|
-
response_modes_supported: Optional([]),
|
|
970
|
-
grant_types_supported: options.requireDynamicRegistration ? Optional(MustInclude("authorization_code")) : Optional([]),
|
|
971
|
-
acr_values_supported: Optional([]),
|
|
972
|
-
subject_types_supported: Required([]),
|
|
973
|
-
id_token_signing_alg_values_supported: Required(MustInclude("RS256")),
|
|
974
|
-
id_token_encryption_alg_values_supported: Optional([]),
|
|
975
|
-
id_token_encryption_enc_values_supported: Optional([]),
|
|
976
|
-
userinfo_signing_alg_values_supported: Optional([]),
|
|
977
|
-
userinfo_encryption_alg_values_supported: Optional([]),
|
|
978
|
-
userinfo_encryption_enc_values_supported: Optional([]),
|
|
979
|
-
request_object_signing_alg_values_supported: Optional(MustInclude("RS256")),
|
|
980
|
-
// not testing for 'none'
|
|
981
|
-
request_object_encryption_alg_values_supported: Optional([]),
|
|
982
|
-
request_object_encryption_enc_values_supported: Optional([]),
|
|
983
|
-
token_endpoint_auth_methods_supported: Optional(anyOf(...validAuthMethods)),
|
|
984
|
-
token_endpoint_auth_signing_alg_values_supported: Optional(MustInclude("RS256"), not(MustInclude("none"))),
|
|
985
|
-
display_values_supported: Optional(anyOf("page", "popup", "touch", "wap")),
|
|
986
|
-
claim_types_supported: Optional(anyOf("normal", "aggregated", "distributed")),
|
|
987
|
-
claims_supported: Recommended([]),
|
|
988
|
-
service_documentation: Optional(validURL),
|
|
989
|
-
claims_locales_supported: Optional([]),
|
|
990
|
-
ui_locales_supported: Optional([]),
|
|
991
|
-
claims_parameter_supported: Optional(Boolean),
|
|
992
|
-
request_parameter_supported: Optional(Boolean),
|
|
993
|
-
request_uri_parameter_supported: Optional(Boolean),
|
|
994
|
-
op_policy_uri: Optional(validURL),
|
|
995
|
-
op_tos_uri: Optional(validURL)
|
|
996
|
-
};
|
|
997
|
-
const configURL = everything_default.url(options.issuer, ".well-known/openid-configuration");
|
|
998
|
-
const response2 = await options.client.get(
|
|
999
|
-
// https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationRequest
|
|
1000
|
-
// note: this allows path components in the options.issuer url
|
|
1001
|
-
configURL
|
|
1002
|
-
);
|
|
1003
|
-
const openid_config = response2.body[Symbol.metroSource];
|
|
1004
|
-
assert(openid_config, openid_provider_metadata);
|
|
1005
|
-
assert(openid_config.issuer, options.issuer);
|
|
1006
|
-
return openid_config;
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
// src/oidc.register.mjs
|
|
1010
|
-
async function register(options) {
|
|
1011
|
-
const openid_client_metadata = {
|
|
1012
|
-
redirect_uris: Required([validURL]),
|
|
1013
|
-
response_types: Optional([]),
|
|
1014
|
-
grant_types: Optional(anyOf("authorization_code", "refresh_token")),
|
|
1015
|
-
//TODO: match response_types with grant_types
|
|
1016
|
-
application_type: Optional(oneOf("native", "web")),
|
|
1017
|
-
contacts: Optional([validEmail]),
|
|
1018
|
-
client_name: Optional(String),
|
|
1019
|
-
logo_uri: Optional(validURL),
|
|
1020
|
-
client_uri: Optional(validURL),
|
|
1021
|
-
policy_uri: Optional(validURL),
|
|
1022
|
-
tos_uri: Optional(validURL),
|
|
1023
|
-
jwks_uri: Optional(validURL, not(MustHave("jwks"))),
|
|
1024
|
-
jwks: Optional(validURL, not(MustHave("jwks_uri"))),
|
|
1025
|
-
sector_identifier_uri: Optional(validURL),
|
|
1026
|
-
subject_type: Optional(String),
|
|
1027
|
-
id_token_signed_response_alg: Optional(oneOf(...validJWA)),
|
|
1028
|
-
id_token_encrypted_response_alg: Optional(oneOf(...validJWA)),
|
|
1029
|
-
id_token_encrypted_response_enc: Optional(oneOf(...validJWA), MustHave("id_token_encrypted_response_alg")),
|
|
1030
|
-
userinfo_signed_response_alg: Optional(oneOf(...validJWA)),
|
|
1031
|
-
userinfo_encrypted_response_alg: Optional(oneOf(...validJWA)),
|
|
1032
|
-
userinfo_encrypted_response_enc: Optional(oneOf(...validJWA), MustHave("userinfo_encrypted_response_alg")),
|
|
1033
|
-
request_object_signing_alg: Optional(oneOf(...validJWA)),
|
|
1034
|
-
request_object_encryption_alg: Optional(oneOf(...validJWA)),
|
|
1035
|
-
request_object_encryption_enc: Optional(oneOf(...validJWA)),
|
|
1036
|
-
token_endpoint_auth_method: Optional(oneOf(...validAuthMethods)),
|
|
1037
|
-
token_endpoint_auth_signing_alg: Optional(oneOf(...validJWA)),
|
|
1038
|
-
default_max_age: Optional(Number),
|
|
1039
|
-
require_auth_time: Optional(Boolean),
|
|
1040
|
-
default_acr_values: Optional([String]),
|
|
1041
|
-
initiate_login_uri: Optional([validURL]),
|
|
1042
|
-
request_uris: Optional([validURL])
|
|
1043
|
-
};
|
|
1044
|
-
assert(options, {
|
|
1045
|
-
client: Optional(instanceOf(everything_default.client().constructor)),
|
|
1046
|
-
registration_endpoint: validURL,
|
|
1047
|
-
client_info: openid_client_metadata
|
|
1048
|
-
});
|
|
1049
|
-
const defaultOptions = {
|
|
1050
|
-
client: everything_default.client().with(thrower()).with(jsonmw())
|
|
1051
|
-
};
|
|
1052
|
-
options = Object.assign({}, defaultOptions, options);
|
|
1053
|
-
let response2 = await options.client.post(options.registration_endpoint, {
|
|
1054
|
-
body: options.client_info
|
|
1055
|
-
});
|
|
1056
|
-
let info = response2.body;
|
|
1057
|
-
if (!info.client_id || !info.client_secret) {
|
|
1058
|
-
throw everything_default.metroError("metro.oidc: Error: dynamic registration of client failed, no client_id or client_secret returned", response2);
|
|
1059
|
-
}
|
|
1060
|
-
options.client_info = Object.assign(options.client_info, info);
|
|
1061
|
-
return options.client_info;
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
// node_modules/@muze-nl/metro-oauth2/src/oauth2.mjs
|
|
1065
|
-
var oauth2_exports = {};
|
|
1066
|
-
__export(oauth2_exports, {
|
|
1067
|
-
base64url_encode: () => base64url_encode,
|
|
1068
|
-
createState: () => createState,
|
|
1069
|
-
default: () => oauth2mw,
|
|
1070
|
-
generateCodeChallenge: () => generateCodeChallenge,
|
|
1071
|
-
generateCodeVerifier: () => generateCodeVerifier,
|
|
1072
|
-
getExpires: () => getExpires,
|
|
1073
|
-
isExpired: () => isExpired,
|
|
1074
|
-
isRedirected: () => isRedirected
|
|
1075
|
-
});
|
|
1076
|
-
|
|
1077
|
-
// node_modules/@muze-nl/metro-oauth2/node_modules/@muze-nl/assert/src/assert.mjs
|
|
1078
|
-
globalThis.assertEnabled = false;
|
|
1079
|
-
var assert2 = (source, test) => {
|
|
1080
|
-
if (globalThis.assertEnabled) {
|
|
1081
|
-
let problems = fails2(source, test);
|
|
1082
|
-
if (problems) {
|
|
1083
|
-
throw new assertError("Assertions failed", problems, source);
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
};
|
|
1087
|
-
var Optional2 = (pattern) => (data) => data == null || typeof data == "undefined" ? false : fails2(data, pattern);
|
|
1088
|
-
var Required2 = (pattern) => (data) => fails2(data, pattern);
|
|
1089
|
-
var Recommended2 = (pattern) => (data) => data == null || typeof data == "undefined" ? (() => {
|
|
1090
|
-
console.warning("data does not contain recommended value", data, pattern);
|
|
1091
|
-
return false;
|
|
1092
|
-
})() : fails2(data, pattern);
|
|
1093
|
-
var oneOf2 = (...patterns) => (data) => {
|
|
1094
|
-
for (let pattern of patterns) {
|
|
1095
|
-
if (!fails2(data, pattern)) {
|
|
1096
|
-
return false;
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
return error2("data does not match oneOf patterns", data, patterns);
|
|
1100
|
-
};
|
|
1101
|
-
var anyOf2 = (...patterns) => (data) => {
|
|
1102
|
-
if (!Array.isArray(data)) {
|
|
1103
|
-
return error2("data is not an array", data, "anyOf");
|
|
1104
|
-
}
|
|
1105
|
-
for (let value of data) {
|
|
1106
|
-
if (oneOf2(...patterns)(value)) {
|
|
1107
|
-
return error2("data does not match anyOf patterns", value, patterns);
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
return false;
|
|
1111
|
-
};
|
|
1112
|
-
function validURL2(data) {
|
|
1113
|
-
try {
|
|
1114
|
-
if (data instanceof URL) {
|
|
1115
|
-
data = data.href;
|
|
1116
|
-
}
|
|
1117
|
-
let url2 = new URL(data);
|
|
1118
|
-
if (url2.href != data) {
|
|
1119
|
-
return error2("data is not a valid url", data, "validURL");
|
|
1120
|
-
}
|
|
1121
|
-
} catch (e) {
|
|
1122
|
-
return error2("data is not a valid url", data, "validURL");
|
|
1123
|
-
}
|
|
1124
|
-
return false;
|
|
1125
|
-
}
|
|
1126
|
-
function fails2(data, pattern, root) {
|
|
1127
|
-
if (!root) {
|
|
1128
|
-
root = data;
|
|
1129
|
-
}
|
|
1130
|
-
let problems = [];
|
|
1131
|
-
if (pattern === Boolean) {
|
|
1132
|
-
if (typeof data != "boolean") {
|
|
1133
|
-
problems.push(error2("data is not a boolean", data, pattern));
|
|
1134
|
-
}
|
|
1135
|
-
} else if (pattern === Number) {
|
|
1136
|
-
if (typeof data != "number") {
|
|
1137
|
-
problems.push(error2("data is not a number", data, pattern));
|
|
1138
|
-
}
|
|
1139
|
-
} else if (pattern instanceof RegExp) {
|
|
1140
|
-
if (Array.isArray(data)) {
|
|
1141
|
-
let index = data.findIndex((element) => fails2(element, pattern, root));
|
|
1142
|
-
if (index > -1) {
|
|
1143
|
-
problems.push(error2("data[" + index + "] does not match pattern", data[index], pattern));
|
|
1144
|
-
}
|
|
1145
|
-
} else if (!pattern.test(data)) {
|
|
1146
|
-
problems.push(error2("data does not match pattern", data, pattern));
|
|
1147
|
-
}
|
|
1148
|
-
} else if (pattern instanceof Function) {
|
|
1149
|
-
if (pattern(data, root)) {
|
|
1150
|
-
problems.push(error2("data does not match function", data, pattern));
|
|
1151
|
-
}
|
|
1152
|
-
} else if (Array.isArray(pattern)) {
|
|
1153
|
-
if (!Array.isArray(data)) {
|
|
1154
|
-
problems.push(error2("data is not an array", data, []));
|
|
1155
|
-
}
|
|
1156
|
-
for (p of pattern) {
|
|
1157
|
-
let problem = fails2(data, p, root);
|
|
1158
|
-
if (Array.isArray(problem)) {
|
|
1159
|
-
problems.concat(problem);
|
|
1160
|
-
} else if (problem) {
|
|
1161
|
-
problems.push(problem);
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
} else if (pattern && typeof pattern == "object") {
|
|
1165
|
-
if (Array.isArray(data)) {
|
|
1166
|
-
let index = data.findIndex((element) => fails2(element, pattern, root));
|
|
1167
|
-
if (index > -1) {
|
|
1168
|
-
problems.push(error2("data[" + index + "] does not match pattern", data[index], pattern));
|
|
1169
|
-
}
|
|
1170
|
-
} else if (!data || typeof data != "object") {
|
|
1171
|
-
problems.push(error2("data is not an object, pattern is", data, pattern));
|
|
1172
|
-
} else {
|
|
1173
|
-
if (data instanceof URLSearchParams) {
|
|
1174
|
-
data = Object.fromEntries(data);
|
|
1175
|
-
}
|
|
1176
|
-
let p2 = problems[problems.length - 1];
|
|
1177
|
-
for (const [wKey, wVal] of Object.entries(pattern)) {
|
|
1178
|
-
let result = fails2(data[wKey], wVal, root);
|
|
1179
|
-
if (result) {
|
|
1180
|
-
if (!p2 || typeof p2 == "string") {
|
|
1181
|
-
p2 = {};
|
|
1182
|
-
problems.push(error2(p2, data[wKey], wVal));
|
|
1183
|
-
}
|
|
1184
|
-
p2[wKey] = result.problems;
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
} else {
|
|
1189
|
-
if (pattern != data) {
|
|
1190
|
-
problems.push(error2("data and pattern are not equal", data, pattern));
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
if (problems.length) {
|
|
1194
|
-
return problems;
|
|
1195
|
-
}
|
|
1196
|
-
return false;
|
|
1197
|
-
}
|
|
1198
|
-
var assertError = class extends Error {
|
|
1199
|
-
constructor(message, problems, ...details) {
|
|
1200
|
-
super(message);
|
|
1201
|
-
this.problems = problems;
|
|
1202
|
-
this.details = details;
|
|
1203
|
-
}
|
|
1204
|
-
};
|
|
1205
|
-
function error2(message, found, expected) {
|
|
1206
|
-
return {
|
|
1207
|
-
message,
|
|
1208
|
-
found,
|
|
1209
|
-
expected
|
|
1210
|
-
};
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
// node_modules/@muze-nl/metro-oauth2/src/tokenstore.mjs
|
|
1214
|
-
function tokenStore(site) {
|
|
1215
|
-
let localState, localTokens;
|
|
1216
|
-
if (typeof localStorage !== "undefined") {
|
|
1217
|
-
localState = {
|
|
1218
|
-
get: () => localStorage.getItem("metro/state:" + site),
|
|
1219
|
-
set: (value) => localStorage.setItem("metro/state:" + site, value),
|
|
1220
|
-
has: () => localStorage.getItem("metro/state:" + site) !== null
|
|
1221
|
-
};
|
|
1222
|
-
localTokens = {
|
|
1223
|
-
get: (name) => JSON.parse(localStorage.getItem(site + ":" + name)),
|
|
1224
|
-
set: (name, value) => localStorage.setItem(site + ":" + name, JSON.stringify(value)),
|
|
1225
|
-
has: (name) => localStorage.getItem(site + ":" + name) !== null
|
|
1226
|
-
};
|
|
747
|
+
// node_modules/@muze-nl/metro-oauth2/src/tokenstore.mjs
|
|
748
|
+
function tokenStore(site) {
|
|
749
|
+
let localState, localTokens;
|
|
750
|
+
if (typeof localStorage !== "undefined") {
|
|
751
|
+
localState = {
|
|
752
|
+
get: () => localStorage.getItem("metro/state:" + site),
|
|
753
|
+
set: (value) => localStorage.setItem("metro/state:" + site, value),
|
|
754
|
+
has: () => localStorage.getItem("metro/state:" + site) !== null
|
|
755
|
+
};
|
|
756
|
+
localTokens = {
|
|
757
|
+
get: (name) => JSON.parse(localStorage.getItem(site + ":" + name)),
|
|
758
|
+
set: (name, value) => localStorage.setItem(site + ":" + name, JSON.stringify(value)),
|
|
759
|
+
has: (name) => localStorage.getItem(site + ":" + name) !== null
|
|
760
|
+
};
|
|
1227
761
|
} else {
|
|
1228
762
|
let stateMap = /* @__PURE__ */ new Map();
|
|
1229
763
|
localState = {
|
|
@@ -1242,7 +776,7 @@
|
|
|
1242
776
|
// node_modules/@muze-nl/metro-oauth2/src/oauth2.mjs
|
|
1243
777
|
function oauth2mw(options) {
|
|
1244
778
|
const defaultOptions = {
|
|
1245
|
-
client:
|
|
779
|
+
client: client(),
|
|
1246
780
|
force_authorization: false,
|
|
1247
781
|
site: "default",
|
|
1248
782
|
oauth2_configuration: {
|
|
@@ -1252,16 +786,14 @@
|
|
|
1252
786
|
grant_type: "authorization_code",
|
|
1253
787
|
code_verifier: generateCodeVerifier(64)
|
|
1254
788
|
},
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
window.location.replace(url2.href);
|
|
1259
|
-
}
|
|
1260
|
-
return false;
|
|
789
|
+
authorize_callback: async (url2) => {
|
|
790
|
+
if (window.location.href != url2.href) {
|
|
791
|
+
window.location.replace(url2.href);
|
|
1261
792
|
}
|
|
793
|
+
return false;
|
|
1262
794
|
}
|
|
1263
795
|
};
|
|
1264
|
-
|
|
796
|
+
assert(options, {});
|
|
1265
797
|
const oauth22 = Object.assign({}, defaultOptions.oauth2_configuration, options?.oauth2_configuration);
|
|
1266
798
|
options = Object.assign({}, defaultOptions, options);
|
|
1267
799
|
options.oauth2_configuration = oauth22;
|
|
@@ -1272,13 +804,13 @@
|
|
|
1272
804
|
if (!options.state) {
|
|
1273
805
|
options.state = store.state;
|
|
1274
806
|
}
|
|
1275
|
-
|
|
807
|
+
assert(options, {
|
|
1276
808
|
oauth2_configuration: {
|
|
1277
|
-
client_id:
|
|
809
|
+
client_id: Required(/.+/),
|
|
1278
810
|
grant_type: "authorization_code",
|
|
1279
|
-
authorization_endpoint:
|
|
1280
|
-
token_endpoint:
|
|
1281
|
-
redirect_uri:
|
|
811
|
+
authorization_endpoint: Required(validURL),
|
|
812
|
+
token_endpoint: Required(validURL),
|
|
813
|
+
redirect_uri: Required(validURL)
|
|
1282
814
|
}
|
|
1283
815
|
});
|
|
1284
816
|
for (let option in oauth22) {
|
|
@@ -1328,7 +860,7 @@
|
|
|
1328
860
|
try {
|
|
1329
861
|
let token = await fetchAccessToken();
|
|
1330
862
|
if (!token) {
|
|
1331
|
-
return
|
|
863
|
+
return response("false");
|
|
1332
864
|
}
|
|
1333
865
|
} catch (e) {
|
|
1334
866
|
throw e;
|
|
@@ -1338,14 +870,14 @@
|
|
|
1338
870
|
try {
|
|
1339
871
|
let token = await fetchRefreshToken();
|
|
1340
872
|
if (!token) {
|
|
1341
|
-
return
|
|
873
|
+
return response("false");
|
|
1342
874
|
}
|
|
1343
875
|
} catch (e) {
|
|
1344
876
|
throw e;
|
|
1345
877
|
}
|
|
1346
878
|
return oauth2authorized(req, next);
|
|
1347
879
|
} else {
|
|
1348
|
-
req =
|
|
880
|
+
req = request(req, {
|
|
1349
881
|
headers: {
|
|
1350
882
|
Authorization: accessToken.type + " " + accessToken.value
|
|
1351
883
|
}
|
|
@@ -1355,7 +887,7 @@
|
|
|
1355
887
|
}
|
|
1356
888
|
function getTokensFromLocation() {
|
|
1357
889
|
if (typeof window !== "undefined" && window?.location) {
|
|
1358
|
-
let url2 =
|
|
890
|
+
let url2 = url(window.location);
|
|
1359
891
|
let code, state, params2;
|
|
1360
892
|
if (url2.searchParams.has("code")) {
|
|
1361
893
|
params2 = url2.searchParams;
|
|
@@ -1383,10 +915,10 @@
|
|
|
1383
915
|
async function fetchAccessToken() {
|
|
1384
916
|
if (oauth22.grant_type === "authorization_code" && !options.tokens.has("authorization_code")) {
|
|
1385
917
|
let authReqURL = await getAuthorizationCodeURL();
|
|
1386
|
-
if (!options.
|
|
1387
|
-
throw
|
|
918
|
+
if (!options.authorize_callback || typeof options.authorize_callback !== "function") {
|
|
919
|
+
throw metroError("oauth2mw: oauth2 with grant_type:authorization_code requires a callback function in client options.authorize_callback");
|
|
1388
920
|
}
|
|
1389
|
-
let token = await options.
|
|
921
|
+
let token = await options.authorize_callback(authReqURL);
|
|
1390
922
|
if (token) {
|
|
1391
923
|
options.tokens.set("authorization_code", token);
|
|
1392
924
|
} else {
|
|
@@ -1397,7 +929,7 @@
|
|
|
1397
929
|
let response2 = await options.client.post(tokenReq);
|
|
1398
930
|
if (!response2.ok) {
|
|
1399
931
|
let msg = await response2.text();
|
|
1400
|
-
throw
|
|
932
|
+
throw metroError("OAuth2mw: fetch access_token: " + response2.status + ": " + response2.statusText, { cause: tokenReq });
|
|
1401
933
|
}
|
|
1402
934
|
let data = await response2.json();
|
|
1403
935
|
options.tokens.set("access_token", {
|
|
@@ -1418,7 +950,7 @@
|
|
|
1418
950
|
let refreshTokenReq = getAccessTokenRequest("refresh_token");
|
|
1419
951
|
let response2 = await options.client.post(refreshTokenReq);
|
|
1420
952
|
if (!response2.ok) {
|
|
1421
|
-
throw
|
|
953
|
+
throw metroError("OAuth2mw: refresh access_token: " + response2.status + ": " + response2.statusText, { cause: refreshTokenReq });
|
|
1422
954
|
}
|
|
1423
955
|
let data = await response2.json();
|
|
1424
956
|
options.tokens.set("access_token", {
|
|
@@ -1439,10 +971,10 @@
|
|
|
1439
971
|
}
|
|
1440
972
|
async function getAuthorizationCodeURL() {
|
|
1441
973
|
if (!oauth22.authorization_endpoint) {
|
|
1442
|
-
throw
|
|
974
|
+
throw metroError("oauth2mw: Missing options.oauth2_configuration.authorization_endpoint");
|
|
1443
975
|
}
|
|
1444
|
-
let url2 =
|
|
1445
|
-
|
|
976
|
+
let url2 = url(oauth22.authorization_endpoint, { hash: "" });
|
|
977
|
+
assert(oauth22, {
|
|
1446
978
|
client_id: /.+/,
|
|
1447
979
|
redirect_uri: /.+/,
|
|
1448
980
|
scope: /.*/
|
|
@@ -1466,7 +998,7 @@
|
|
|
1466
998
|
search.client_secret = oauth22.client_secret;
|
|
1467
999
|
}
|
|
1468
1000
|
if (oauth22.code_verifier) {
|
|
1469
|
-
search.code_challenge =
|
|
1001
|
+
search.code_challenge = await generateCodeChallenge(oauth22.code_verifier);
|
|
1470
1002
|
search.code_challenge_method = "S256";
|
|
1471
1003
|
}
|
|
1472
1004
|
if (oauth22.scope) {
|
|
@@ -1475,23 +1007,23 @@
|
|
|
1475
1007
|
if (oauth22.prompt) {
|
|
1476
1008
|
search.prompt = oauth22.prompt;
|
|
1477
1009
|
}
|
|
1478
|
-
return
|
|
1010
|
+
return url(url2, { search });
|
|
1479
1011
|
}
|
|
1480
1012
|
function getAccessTokenRequest(grant_type = null) {
|
|
1481
|
-
|
|
1013
|
+
assert(oauth22, {
|
|
1482
1014
|
client_id: /.+/,
|
|
1483
1015
|
redirect_uri: /.+/
|
|
1484
1016
|
});
|
|
1485
1017
|
if (!oauth22.token_endpoint) {
|
|
1486
|
-
throw
|
|
1018
|
+
throw metroError("oauth2mw: Missing options.endpoints.token url");
|
|
1487
1019
|
}
|
|
1488
|
-
let url2 =
|
|
1020
|
+
let url2 = url(oauth22.token_endpoint, { hash: "" });
|
|
1489
1021
|
let params2 = {
|
|
1490
1022
|
grant_type: grant_type || oauth22.grant_type,
|
|
1491
1023
|
client_id: oauth22.client_id
|
|
1492
1024
|
};
|
|
1493
1025
|
if (oauth22.code_verifier) {
|
|
1494
|
-
params2.code_verifier =
|
|
1026
|
+
params2.code_verifier = oauth22.code_verifier;
|
|
1495
1027
|
}
|
|
1496
1028
|
if (oauth22.client_secret) {
|
|
1497
1029
|
params2.client_secret = oauth22.client_secret;
|
|
@@ -1503,10 +1035,6 @@
|
|
|
1503
1035
|
case "authorization_code":
|
|
1504
1036
|
params2.redirect_uri = oauth22.redirect_uri;
|
|
1505
1037
|
params2.code = options.tokens.get("authorization_code");
|
|
1506
|
-
if (options.dpop) {
|
|
1507
|
-
const keyPair = options.tokens.get("keyPair");
|
|
1508
|
-
params2.dpop_jkt = keyPair.publicKey;
|
|
1509
|
-
}
|
|
1510
1038
|
break;
|
|
1511
1039
|
case "client_credentials":
|
|
1512
1040
|
break;
|
|
@@ -1517,7 +1045,7 @@
|
|
|
1517
1045
|
throw new Error("Unknown grant_type: ".oauth2.grant_type);
|
|
1518
1046
|
break;
|
|
1519
1047
|
}
|
|
1520
|
-
return
|
|
1048
|
+
return request(url2, { method: "POST", body: new URLSearchParams(params2) });
|
|
1521
1049
|
}
|
|
1522
1050
|
}
|
|
1523
1051
|
function isExpired(token) {
|
|
@@ -1542,13 +1070,13 @@
|
|
|
1542
1070
|
function generateCodeVerifier(size = 64) {
|
|
1543
1071
|
const code_verifier = new Uint8Array(size);
|
|
1544
1072
|
globalThis.crypto.getRandomValues(code_verifier);
|
|
1545
|
-
return code_verifier;
|
|
1073
|
+
return base64url_encode(code_verifier);
|
|
1546
1074
|
}
|
|
1547
1075
|
async function generateCodeChallenge(code_verifier) {
|
|
1548
|
-
const b64encoded = base64url_encode(code_verifier);
|
|
1549
1076
|
const encoder2 = new TextEncoder();
|
|
1550
|
-
const data = encoder2.encode(
|
|
1551
|
-
|
|
1077
|
+
const data = encoder2.encode(code_verifier);
|
|
1078
|
+
const challenge = await globalThis.crypto.subtle.digest("SHA-256", data);
|
|
1079
|
+
return base64url_encode(challenge);
|
|
1552
1080
|
}
|
|
1553
1081
|
function base64url_encode(buffer) {
|
|
1554
1082
|
const byteString = Array.from(new Uint8Array(buffer), (b) => String.fromCharCode(b)).join("");
|
|
@@ -1578,6 +1106,14 @@
|
|
|
1578
1106
|
}
|
|
1579
1107
|
return true;
|
|
1580
1108
|
}
|
|
1109
|
+
async function authorizePopup(authorizationCodeURL) {
|
|
1110
|
+
return new Promise((resolve, reject) => {
|
|
1111
|
+
addEventListener("oauth2authorized", (evt) => {
|
|
1112
|
+
resolve(event.authorization_code);
|
|
1113
|
+
}, { once: true });
|
|
1114
|
+
window.open(authorizationCodeURL);
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1581
1117
|
|
|
1582
1118
|
// node_modules/@muze-nl/metro-oauth2/src/oauth2.mockserver.mjs
|
|
1583
1119
|
var oauth2_mockserver_exports = {};
|
|
@@ -1604,7 +1140,7 @@
|
|
|
1604
1140
|
})
|
|
1605
1141
|
};
|
|
1606
1142
|
};
|
|
1607
|
-
var
|
|
1143
|
+
var error2;
|
|
1608
1144
|
var pkce = {};
|
|
1609
1145
|
function oauth2mockserver(options = {}) {
|
|
1610
1146
|
const defaultOptions = {
|
|
@@ -1616,12 +1152,12 @@
|
|
|
1616
1152
|
let url2 = everything_default.url(req.url);
|
|
1617
1153
|
switch (url2.pathname) {
|
|
1618
1154
|
case "/authorize/":
|
|
1619
|
-
if (
|
|
1155
|
+
if (error2 = fails(url2.searchParams, {
|
|
1620
1156
|
response_type: "code",
|
|
1621
1157
|
client_id: "mockClientId",
|
|
1622
|
-
state:
|
|
1158
|
+
state: Optional(/.*/)
|
|
1623
1159
|
})) {
|
|
1624
|
-
return everything_default.response(badRequest(
|
|
1160
|
+
return everything_default.response(badRequest(error2));
|
|
1625
1161
|
}
|
|
1626
1162
|
if (url2.searchParams.has("code_challenge")) {
|
|
1627
1163
|
if (!url2.searchParams.has("code_challenge_method")) {
|
|
@@ -1638,22 +1174,22 @@
|
|
|
1638
1174
|
});
|
|
1639
1175
|
break;
|
|
1640
1176
|
case "/token/":
|
|
1641
|
-
if (req.
|
|
1177
|
+
if (req.data instanceof URLSearchParams) {
|
|
1642
1178
|
let body = {};
|
|
1643
|
-
req.
|
|
1179
|
+
req.data.forEach((value, key) => body[key] = value);
|
|
1644
1180
|
req = req.with({ body });
|
|
1645
1181
|
}
|
|
1646
|
-
if (
|
|
1182
|
+
if (error2 = fails(req, {
|
|
1647
1183
|
method: "POST",
|
|
1648
|
-
|
|
1649
|
-
grant_type:
|
|
1184
|
+
data: {
|
|
1185
|
+
grant_type: oneOf("refresh_token", "authorization_code")
|
|
1650
1186
|
}
|
|
1651
1187
|
})) {
|
|
1652
|
-
return everything_default.response(badRequest(
|
|
1188
|
+
return everything_default.response(badRequest(error2));
|
|
1653
1189
|
}
|
|
1654
|
-
switch (req.
|
|
1190
|
+
switch (req.data.grant_type) {
|
|
1655
1191
|
case "refresh_token":
|
|
1656
|
-
if (
|
|
1192
|
+
if (error2 = fails(req.data, oneOf({
|
|
1657
1193
|
refresh_token: "mockRefreshToken",
|
|
1658
1194
|
client_id: "mockClientId",
|
|
1659
1195
|
client_secret: "mockClientSecret"
|
|
@@ -1662,11 +1198,11 @@
|
|
|
1662
1198
|
client_id: "mockClientId",
|
|
1663
1199
|
code_verifier: /.+/
|
|
1664
1200
|
}))) {
|
|
1665
|
-
return everything_default.response(badRequest(
|
|
1201
|
+
return everything_default.response(badRequest(error2));
|
|
1666
1202
|
}
|
|
1667
1203
|
break;
|
|
1668
1204
|
case "access_token":
|
|
1669
|
-
if (
|
|
1205
|
+
if (error2 = fails(req.data, oneOf({
|
|
1670
1206
|
client_id: "mockClientId",
|
|
1671
1207
|
client_secret: "mockClientSecret"
|
|
1672
1208
|
}, {
|
|
@@ -1675,7 +1211,7 @@
|
|
|
1675
1211
|
//FIXME: check that this matches code_verifier
|
|
1676
1212
|
code_challenge_method: "S256"
|
|
1677
1213
|
}))) {
|
|
1678
|
-
return everything_default.response(badRequest(
|
|
1214
|
+
return everything_default.response(badRequest(error2));
|
|
1679
1215
|
}
|
|
1680
1216
|
break;
|
|
1681
1217
|
}
|
|
@@ -1739,43 +1275,43 @@
|
|
|
1739
1275
|
"ES384",
|
|
1740
1276
|
"ES512"
|
|
1741
1277
|
];
|
|
1742
|
-
var
|
|
1278
|
+
var validAuthMethods = [
|
|
1743
1279
|
"client_secret_post",
|
|
1744
1280
|
"client_secret_base",
|
|
1745
1281
|
"client_secret_jwt",
|
|
1746
1282
|
"private_key_jwt"
|
|
1747
1283
|
];
|
|
1748
1284
|
var oauth_authorization_server_metadata = {
|
|
1749
|
-
issuer:
|
|
1750
|
-
authorization_endpoint:
|
|
1751
|
-
token_endpoint:
|
|
1752
|
-
jwks_uri:
|
|
1753
|
-
registration_endpoint:
|
|
1754
|
-
scopes_supported:
|
|
1755
|
-
response_types_supported:
|
|
1756
|
-
response_modes_supported:
|
|
1757
|
-
grant_types_supported:
|
|
1758
|
-
token_endpoint_auth_methods_supported:
|
|
1759
|
-
token_endpoint_auth_signing_alg_values_supported:
|
|
1760
|
-
service_documentation:
|
|
1761
|
-
ui_locales_supported:
|
|
1762
|
-
op_policy_uri:
|
|
1763
|
-
op_tos_uri:
|
|
1764
|
-
revocation_endpoint:
|
|
1765
|
-
revocation_endpoint_auth_methods_supported:
|
|
1766
|
-
revocation_endpoint_auth_signing_alg_values_supported:
|
|
1767
|
-
introspection_endpoint:
|
|
1768
|
-
introspection_endpoint_auth_methods_supported:
|
|
1769
|
-
introspection_endpoint_auth_signing_alg_values_supported:
|
|
1770
|
-
code_challendge_methods_supported:
|
|
1285
|
+
issuer: Required(validURL),
|
|
1286
|
+
authorization_endpoint: Required(validURL),
|
|
1287
|
+
token_endpoint: Required(validURL),
|
|
1288
|
+
jwks_uri: Optional(validURL),
|
|
1289
|
+
registration_endpoint: Optional(validURL),
|
|
1290
|
+
scopes_supported: Recommended([]),
|
|
1291
|
+
response_types_supported: Required(anyOf("code", "token")),
|
|
1292
|
+
response_modes_supported: Optional([]),
|
|
1293
|
+
grant_types_supported: Optional([]),
|
|
1294
|
+
token_endpoint_auth_methods_supported: Optional([]),
|
|
1295
|
+
token_endpoint_auth_signing_alg_values_supported: Optional([]),
|
|
1296
|
+
service_documentation: Optional(validURL),
|
|
1297
|
+
ui_locales_supported: Optional([]),
|
|
1298
|
+
op_policy_uri: Optional(validURL),
|
|
1299
|
+
op_tos_uri: Optional(validURL),
|
|
1300
|
+
revocation_endpoint: Optional(validURL),
|
|
1301
|
+
revocation_endpoint_auth_methods_supported: Optional(validAuthMethods),
|
|
1302
|
+
revocation_endpoint_auth_signing_alg_values_supported: Optional(validAlgorithms),
|
|
1303
|
+
introspection_endpoint: Optional(validURL),
|
|
1304
|
+
introspection_endpoint_auth_methods_supported: Optional(validAuthMethods),
|
|
1305
|
+
introspection_endpoint_auth_signing_alg_values_supported: Optional(validAlgorithms),
|
|
1306
|
+
code_challendge_methods_supported: Optional([])
|
|
1771
1307
|
};
|
|
1772
1308
|
function makeClient(options = {}) {
|
|
1773
1309
|
const defaultOptions = {
|
|
1774
1310
|
client: everything_default.client()
|
|
1775
1311
|
};
|
|
1776
1312
|
options = Object.assign({}, defaultOptions, options);
|
|
1777
|
-
|
|
1778
|
-
issuer:
|
|
1313
|
+
assert(options, {
|
|
1314
|
+
issuer: Required(validURL)
|
|
1779
1315
|
});
|
|
1780
1316
|
const oauth_authorization_server_configuration = fetchWellknownOauthAuthorizationServer(options.issuer);
|
|
1781
1317
|
let client2 = options.client.with(options.issuer);
|
|
@@ -1783,9 +1319,9 @@
|
|
|
1783
1319
|
async function fetchWellknownOauthAuthorizationServer(issuer, client2) {
|
|
1784
1320
|
let res = client2.get(everything_default.url(issuer, ".wellknown/oauth_authorization_server"));
|
|
1785
1321
|
if (res.ok) {
|
|
1786
|
-
|
|
1322
|
+
assert(res.headers.get("Content-Type"), /application\/json.*/);
|
|
1787
1323
|
let configuration = await res.json();
|
|
1788
|
-
|
|
1324
|
+
assert(configuration, oauth_authorization_server_metadata);
|
|
1789
1325
|
return configuration;
|
|
1790
1326
|
}
|
|
1791
1327
|
throw everything_default.metroError("metro.oidcmw: Error while fetching " + issuer + ".wellknown/oauth_authorization_server", res);
|
|
@@ -1796,11 +1332,11 @@
|
|
|
1796
1332
|
return new Promise((resolve, reject) => {
|
|
1797
1333
|
const request2 = globalThis.indexedDB.open("metro", 1);
|
|
1798
1334
|
request2.onupgradeneeded = () => request2.result.createObjectStore("keyPairs", { keyPath: "domain" });
|
|
1799
|
-
request2.onerror = (
|
|
1800
|
-
reject(
|
|
1335
|
+
request2.onerror = (event2) => {
|
|
1336
|
+
reject(event2);
|
|
1801
1337
|
};
|
|
1802
|
-
request2.onsuccess = (
|
|
1803
|
-
const db =
|
|
1338
|
+
request2.onsuccess = (event2) => {
|
|
1339
|
+
const db = event2.target.result;
|
|
1804
1340
|
resolve({
|
|
1805
1341
|
set: function(value, key) {
|
|
1806
1342
|
return new Promise((resolve2, reject2) => {
|
|
@@ -2044,11 +1580,12 @@
|
|
|
2044
1580
|
|
|
2045
1581
|
// node_modules/@muze-nl/metro-oauth2/src/oauth2.dpop.mjs
|
|
2046
1582
|
function dpopmw(options) {
|
|
2047
|
-
|
|
2048
|
-
site:
|
|
2049
|
-
authorization_endpoint:
|
|
2050
|
-
token_endpoint:
|
|
2051
|
-
|
|
1583
|
+
assert(options, {
|
|
1584
|
+
site: Required(validURL),
|
|
1585
|
+
authorization_endpoint: Required(validURL),
|
|
1586
|
+
token_endpoint: Required(validURL),
|
|
1587
|
+
dpop_signing_alg_values_supported: Optional([])
|
|
1588
|
+
// this property is unfortunately rarely supported
|
|
2052
1589
|
});
|
|
2053
1590
|
return async (req, next) => {
|
|
2054
1591
|
const keys = await keysStore();
|
|
@@ -2059,7 +1596,14 @@
|
|
|
2059
1596
|
await keys.set(keyInfo);
|
|
2060
1597
|
}
|
|
2061
1598
|
const url2 = everything_default.url(req.url);
|
|
2062
|
-
if (req.url.startsWith(options.authorization_endpoint)
|
|
1599
|
+
if (req.url.startsWith(options.authorization_endpoint)) {
|
|
1600
|
+
let params2 = req.body;
|
|
1601
|
+
if (params2 instanceof URLSearchParams || params2 instanceof FormData) {
|
|
1602
|
+
params2.set("dpop_jkt", keyInfo.keyPair.publicKey);
|
|
1603
|
+
} else {
|
|
1604
|
+
params2.dpop_jkt = keyInfo.keyPair.publicKey;
|
|
1605
|
+
}
|
|
1606
|
+
} else if (req.url.startsWith(options.token_endpoint)) {
|
|
2063
1607
|
const dpopHeader = await DPoP(keyInfo.keyPair, req.url, req.method);
|
|
2064
1608
|
req = req.with({
|
|
2065
1609
|
headers: {
|
|
@@ -2073,7 +1617,6 @@
|
|
|
2073
1617
|
req = req.with({
|
|
2074
1618
|
headers: {
|
|
2075
1619
|
"Authorization": "DPoP " + accessToken,
|
|
2076
|
-
//solidcommunity server sends accesstoken with type Bearer
|
|
2077
1620
|
"DPoP": dpopHeader
|
|
2078
1621
|
}
|
|
2079
1622
|
});
|
|
@@ -2087,15 +1630,382 @@
|
|
|
2087
1630
|
}
|
|
2088
1631
|
|
|
2089
1632
|
// node_modules/@muze-nl/metro-oauth2/src/browser.mjs
|
|
2090
|
-
var oauth2 = Object.assign(
|
|
1633
|
+
var oauth2 = Object.assign(oauth2_exports, {
|
|
1634
|
+
oauth2mw,
|
|
2091
1635
|
mockserver: oauth2_mockserver_exports,
|
|
2092
|
-
|
|
1636
|
+
discover: oauth2_discovery_exports,
|
|
2093
1637
|
tokenstore: tokenStore,
|
|
2094
1638
|
dpopmw,
|
|
2095
1639
|
keysstore: keysStore
|
|
2096
1640
|
});
|
|
2097
|
-
globalThis.oauth2
|
|
2098
|
-
|
|
1641
|
+
if (!globalThis.metro.oauth2) {
|
|
1642
|
+
globalThis.metro.oauth2 = oauth2;
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
// node_modules/@muze-nl/assert/src/assert.mjs
|
|
1646
|
+
globalThis.assertEnabled = false;
|
|
1647
|
+
function assert2(source, test) {
|
|
1648
|
+
if (globalThis.assertEnabled) {
|
|
1649
|
+
let problems = fails2(source, test);
|
|
1650
|
+
if (problems) {
|
|
1651
|
+
console.error("\u{1F170}\uFE0F Assertions failed because of:", problems, "in this source:", source);
|
|
1652
|
+
throw new Error("Assertions failed", {
|
|
1653
|
+
cause: { problems, source }
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
function Optional2(pattern) {
|
|
1659
|
+
return function _Optional(data, root, path) {
|
|
1660
|
+
if (typeof data != "undefined" && data != null && typeof pattern != "undefined") {
|
|
1661
|
+
return fails2(data, pattern, root, path);
|
|
1662
|
+
}
|
|
1663
|
+
};
|
|
1664
|
+
}
|
|
1665
|
+
function Required2(pattern) {
|
|
1666
|
+
return function _Required(data, root, path) {
|
|
1667
|
+
if (data == null || typeof data == "undefined") {
|
|
1668
|
+
return error3("data is required", data, pattern || "any value", path);
|
|
1669
|
+
} else if (typeof pattern != "undefined") {
|
|
1670
|
+
return fails2(data, pattern, root, path);
|
|
1671
|
+
} else {
|
|
1672
|
+
return false;
|
|
1673
|
+
}
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
function Recommended2(pattern) {
|
|
1677
|
+
return function _Recommended(data, root, path) {
|
|
1678
|
+
if (data == null || typeof data == "undefined") {
|
|
1679
|
+
console.warn("data does not contain recommended value", data, pattern, path);
|
|
1680
|
+
return false;
|
|
1681
|
+
} else {
|
|
1682
|
+
return fails2(data, pattern, root, path);
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
function oneOf2(...patterns) {
|
|
1687
|
+
return function _oneOf(data, root, path) {
|
|
1688
|
+
for (let pattern of patterns) {
|
|
1689
|
+
if (!fails2(data, pattern, root, path)) {
|
|
1690
|
+
return false;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
return error3("data does not match oneOf patterns", data, patterns, path);
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1696
|
+
function anyOf2(...patterns) {
|
|
1697
|
+
return function _anyOf(data, root, path) {
|
|
1698
|
+
if (!Array.isArray(data)) {
|
|
1699
|
+
return error3("data is not an array", data, "anyOf", path);
|
|
1700
|
+
}
|
|
1701
|
+
for (let value of data) {
|
|
1702
|
+
if (oneOf2(...patterns)(value)) {
|
|
1703
|
+
return error3("data does not match anyOf patterns", value, patterns, path);
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
return false;
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
function allOf(...patterns) {
|
|
1710
|
+
return function _allOf(data, root, path) {
|
|
1711
|
+
let problems = [];
|
|
1712
|
+
for (let pattern of patterns) {
|
|
1713
|
+
problems = problems.concat(fails2(data, pattern, root, path));
|
|
1714
|
+
}
|
|
1715
|
+
problems = problems.filter(Boolean);
|
|
1716
|
+
if (problems.length) {
|
|
1717
|
+
return error3("data does not match all given patterns", data, patterns, path, problems);
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
function validURL2(data, root, path) {
|
|
1722
|
+
try {
|
|
1723
|
+
if (data instanceof URL) {
|
|
1724
|
+
data = data.href;
|
|
1725
|
+
}
|
|
1726
|
+
let url2 = new URL(data);
|
|
1727
|
+
if (url2.href != data) {
|
|
1728
|
+
if (!(url2.href + "/" == data || url2.href == data + "/")) {
|
|
1729
|
+
return error3("data is not a valid url", data, "validURL", path);
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
} catch (e) {
|
|
1733
|
+
return error3("data is not a valid url", data, "validURL", path);
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
function validEmail(data, root, path) {
|
|
1737
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data)) {
|
|
1738
|
+
return error3("data is not a valid email", data, "validEmail", path);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
function instanceOf(constructor) {
|
|
1742
|
+
return function _instanceOf(data, root, path) {
|
|
1743
|
+
if (!(data instanceof constructor)) {
|
|
1744
|
+
return error3("data is not an instanceof pattern", data, constructor, path);
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
function not(pattern) {
|
|
1749
|
+
return function _not(data, root, path) {
|
|
1750
|
+
if (!fails2(data, pattern, root, path)) {
|
|
1751
|
+
return error3("data matches pattern, when required not to", data, pattern, path);
|
|
1752
|
+
}
|
|
1753
|
+
};
|
|
1754
|
+
}
|
|
1755
|
+
function fails2(data, pattern, root, path = "") {
|
|
1756
|
+
if (!root) {
|
|
1757
|
+
root = data;
|
|
1758
|
+
}
|
|
1759
|
+
let problems = [];
|
|
1760
|
+
if (pattern === Boolean) {
|
|
1761
|
+
if (typeof data != "boolean" && !(data instanceof Boolean)) {
|
|
1762
|
+
problems.push(error3("data is not a boolean", data, pattern, path));
|
|
1763
|
+
}
|
|
1764
|
+
} else if (pattern === Number) {
|
|
1765
|
+
if (typeof data != "number" && !(data instanceof Number)) {
|
|
1766
|
+
problems.push(error3("data is not a number", data, pattern, path));
|
|
1767
|
+
}
|
|
1768
|
+
} else if (pattern === String) {
|
|
1769
|
+
if (typeof data != "string" && !(data instanceof String)) {
|
|
1770
|
+
problems.push(error3("data is not a string", data, pattern, path));
|
|
1771
|
+
}
|
|
1772
|
+
if (data == "") {
|
|
1773
|
+
problems.push(error3("data is an empty string, which is not allowed", data, pattern, path));
|
|
1774
|
+
}
|
|
1775
|
+
} else if (pattern instanceof RegExp) {
|
|
1776
|
+
if (Array.isArray(data)) {
|
|
1777
|
+
let index = data.findIndex((element, index2) => fails2(element, pattern, root, path + "[" + index2 + "]"));
|
|
1778
|
+
if (index > -1) {
|
|
1779
|
+
problems.push(error3("data[" + index + "] does not match pattern", data[index], pattern, path + "[" + index + "]"));
|
|
1780
|
+
}
|
|
1781
|
+
} else if (typeof data == "undefined") {
|
|
1782
|
+
problems.push(error3("data is undefined, should match pattern", data, pattern, path));
|
|
1783
|
+
} else if (!pattern.test(data)) {
|
|
1784
|
+
problems.push(error3("data does not match pattern", data, pattern, path));
|
|
1785
|
+
}
|
|
1786
|
+
} else if (pattern instanceof Function) {
|
|
1787
|
+
let problem = pattern(data, root, path);
|
|
1788
|
+
if (problem) {
|
|
1789
|
+
if (Array.isArray(problem)) {
|
|
1790
|
+
problems = problems.concat(problem);
|
|
1791
|
+
} else {
|
|
1792
|
+
problems.push(problem);
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
} else if (Array.isArray(pattern)) {
|
|
1796
|
+
if (!Array.isArray(data)) {
|
|
1797
|
+
problems.push(error3("data is not an array", data, [], path));
|
|
1798
|
+
}
|
|
1799
|
+
for (let p2 of pattern) {
|
|
1800
|
+
for (let index of data.keys()) {
|
|
1801
|
+
let problem = fails2(data[index], p2, root, path + "[" + index + "]");
|
|
1802
|
+
if (Array.isArray(problem)) {
|
|
1803
|
+
problems = problems.concat(problem);
|
|
1804
|
+
} else if (problem) {
|
|
1805
|
+
problems.push(problem);
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
} else if (pattern && typeof pattern == "object") {
|
|
1810
|
+
if (Array.isArray(data)) {
|
|
1811
|
+
let index = data.findIndex((element, index2) => fails2(element, pattern, root, path + "[" + index2 + "]"));
|
|
1812
|
+
if (index > -1) {
|
|
1813
|
+
problems.push(error3("data[" + index + "] does not match pattern", data[index], pattern, path + "[" + index + "]"));
|
|
1814
|
+
}
|
|
1815
|
+
} else if (!data || typeof data != "object") {
|
|
1816
|
+
problems.push(error3("data is not an object, pattern is", data, pattern, path));
|
|
1817
|
+
} else {
|
|
1818
|
+
if (data instanceof URLSearchParams) {
|
|
1819
|
+
data = Object.fromEntries(data);
|
|
1820
|
+
}
|
|
1821
|
+
if (pattern instanceof Function) {
|
|
1822
|
+
let result = fails2(data, pattern, root, path);
|
|
1823
|
+
if (result) {
|
|
1824
|
+
problems = problems.concat(result);
|
|
1825
|
+
}
|
|
1826
|
+
} else {
|
|
1827
|
+
for (const [wKey, wVal] of Object.entries(pattern)) {
|
|
1828
|
+
let result = fails2(data[wKey], wVal, root, path + "." + wKey);
|
|
1829
|
+
if (result) {
|
|
1830
|
+
problems = problems.concat(result);
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
} else {
|
|
1836
|
+
if (pattern != data) {
|
|
1837
|
+
problems.push(error3("data and pattern are not equal", data, pattern, path));
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
if (problems.length) {
|
|
1841
|
+
return problems;
|
|
1842
|
+
}
|
|
1843
|
+
return false;
|
|
1844
|
+
}
|
|
1845
|
+
function error3(message, found, expected, path, problems) {
|
|
1846
|
+
let result = {
|
|
1847
|
+
message,
|
|
1848
|
+
found,
|
|
1849
|
+
expected,
|
|
1850
|
+
path
|
|
1851
|
+
};
|
|
1852
|
+
if (problems) {
|
|
1853
|
+
result.problems = problems;
|
|
1854
|
+
}
|
|
1855
|
+
return result;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
// src/oidc.util.mjs
|
|
1859
|
+
var MustHave = (...options) => (value, root) => {
|
|
1860
|
+
if (options.filter((o) => root.hasOwnKey(o)).length > 0) {
|
|
1861
|
+
return false;
|
|
1862
|
+
}
|
|
1863
|
+
return error3("root data must have all of", root, options);
|
|
1864
|
+
};
|
|
1865
|
+
var MustInclude = (...options) => (value) => {
|
|
1866
|
+
if (Array.isArray(value) && options.filter((o) => !value.includes(o)).length == 0) {
|
|
1867
|
+
return false;
|
|
1868
|
+
} else {
|
|
1869
|
+
return error3("data must be an array which includes", value, options);
|
|
1870
|
+
}
|
|
1871
|
+
};
|
|
1872
|
+
var validJWA = [
|
|
1873
|
+
"HS256",
|
|
1874
|
+
"HS384",
|
|
1875
|
+
"HS512",
|
|
1876
|
+
"RS256",
|
|
1877
|
+
"RS384",
|
|
1878
|
+
"RS512",
|
|
1879
|
+
"ES256",
|
|
1880
|
+
"ES384",
|
|
1881
|
+
"ES512"
|
|
1882
|
+
];
|
|
1883
|
+
var validAuthMethods2 = [
|
|
1884
|
+
"client_secret_post",
|
|
1885
|
+
"client_secret_basic",
|
|
1886
|
+
"client_secret_jwt",
|
|
1887
|
+
"private_key_jwt"
|
|
1888
|
+
];
|
|
1889
|
+
|
|
1890
|
+
// src/oidc.discovery.mjs
|
|
1891
|
+
async function oidcDiscovery(options = {}) {
|
|
1892
|
+
assert2(options, {
|
|
1893
|
+
client: Optional2(instanceOf(everything_default.client().constructor)),
|
|
1894
|
+
issuer: Required2(validURL2)
|
|
1895
|
+
});
|
|
1896
|
+
const defaultOptions = {
|
|
1897
|
+
client: everything_default.client().with(thrower()).with(jsonmw()),
|
|
1898
|
+
requireDynamicRegistration: false
|
|
1899
|
+
};
|
|
1900
|
+
options = Object.assign({}, defaultOptions, options);
|
|
1901
|
+
const TestSucceeded = false;
|
|
1902
|
+
function MustUseHTTPS(url2) {
|
|
1903
|
+
return TestSucceeded;
|
|
1904
|
+
}
|
|
1905
|
+
const openid_provider_metadata = {
|
|
1906
|
+
issuer: Required2(allOf(options.issuer, MustUseHTTPS)),
|
|
1907
|
+
authorization_endpoint: Required2(validURL2),
|
|
1908
|
+
token_endpoint: Required2(validURL2),
|
|
1909
|
+
userinfo_endpoint: Recommended2(validURL2),
|
|
1910
|
+
// todo: test for https protocol
|
|
1911
|
+
jwks_uri: Required2(validURL2),
|
|
1912
|
+
registration_endpoint: options.requireDynamicRegistration ? Required2(validURL2) : Recommended2(validURL2),
|
|
1913
|
+
scopes_supported: Recommended2(MustInclude("openid")),
|
|
1914
|
+
response_types_supported: options.requireDynamicRegistration ? Required2(MustInclude("code", "id_token", "id_token token")) : Required2([]),
|
|
1915
|
+
response_modes_supported: Optional2([]),
|
|
1916
|
+
grant_types_supported: options.requireDynamicRegistration ? Optional2(MustInclude("authorization_code")) : Optional2([]),
|
|
1917
|
+
acr_values_supported: Optional2([]),
|
|
1918
|
+
subject_types_supported: Required2([]),
|
|
1919
|
+
id_token_signing_alg_values_supported: Required2(MustInclude("RS256")),
|
|
1920
|
+
id_token_encryption_alg_values_supported: Optional2([]),
|
|
1921
|
+
id_token_encryption_enc_values_supported: Optional2([]),
|
|
1922
|
+
userinfo_signing_alg_values_supported: Optional2([]),
|
|
1923
|
+
userinfo_encryption_alg_values_supported: Optional2([]),
|
|
1924
|
+
userinfo_encryption_enc_values_supported: Optional2([]),
|
|
1925
|
+
request_object_signing_alg_values_supported: Optional2(MustInclude("RS256")),
|
|
1926
|
+
// not testing for 'none'
|
|
1927
|
+
request_object_encryption_alg_values_supported: Optional2([]),
|
|
1928
|
+
request_object_encryption_enc_values_supported: Optional2([]),
|
|
1929
|
+
token_endpoint_auth_methods_supported: Optional2(anyOf2(...validAuthMethods2)),
|
|
1930
|
+
token_endpoint_auth_signing_alg_values_supported: Optional2(MustInclude("RS256"), not(MustInclude("none"))),
|
|
1931
|
+
display_values_supported: Optional2(anyOf2("page", "popup", "touch", "wap")),
|
|
1932
|
+
claim_types_supported: Optional2(anyOf2("normal", "aggregated", "distributed")),
|
|
1933
|
+
claims_supported: Recommended2([]),
|
|
1934
|
+
service_documentation: Optional2(validURL2),
|
|
1935
|
+
claims_locales_supported: Optional2([]),
|
|
1936
|
+
ui_locales_supported: Optional2([]),
|
|
1937
|
+
claims_parameter_supported: Optional2(Boolean),
|
|
1938
|
+
request_parameter_supported: Optional2(Boolean),
|
|
1939
|
+
request_uri_parameter_supported: Optional2(Boolean),
|
|
1940
|
+
op_policy_uri: Optional2(validURL2),
|
|
1941
|
+
op_tos_uri: Optional2(validURL2)
|
|
1942
|
+
};
|
|
1943
|
+
const configURL = everything_default.url(options.issuer, ".well-known/openid-configuration");
|
|
1944
|
+
const response2 = await options.client.get(
|
|
1945
|
+
// https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationRequest
|
|
1946
|
+
// note: this allows path components in the options.issuer url
|
|
1947
|
+
configURL
|
|
1948
|
+
);
|
|
1949
|
+
const openid_config = response2.data;
|
|
1950
|
+
assert2(openid_config, openid_provider_metadata);
|
|
1951
|
+
assert2(openid_config.issuer, options.issuer);
|
|
1952
|
+
return openid_config;
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
// src/oidc.register.mjs
|
|
1956
|
+
async function register(options) {
|
|
1957
|
+
const openid_client_metadata = {
|
|
1958
|
+
redirect_uris: Required2([validURL2]),
|
|
1959
|
+
response_types: Optional2([]),
|
|
1960
|
+
grant_types: Optional2(anyOf2("authorization_code", "refresh_token")),
|
|
1961
|
+
//TODO: match response_types with grant_types
|
|
1962
|
+
application_type: Optional2(oneOf2("native", "web")),
|
|
1963
|
+
contacts: Optional2([validEmail]),
|
|
1964
|
+
client_name: Optional2(String),
|
|
1965
|
+
logo_uri: Optional2(validURL2),
|
|
1966
|
+
client_uri: Optional2(validURL2),
|
|
1967
|
+
policy_uri: Optional2(validURL2),
|
|
1968
|
+
tos_uri: Optional2(validURL2),
|
|
1969
|
+
jwks_uri: Optional2(validURL2, not(MustHave("jwks"))),
|
|
1970
|
+
jwks: Optional2(validURL2, not(MustHave("jwks_uri"))),
|
|
1971
|
+
sector_identifier_uri: Optional2(validURL2),
|
|
1972
|
+
subject_type: Optional2(String),
|
|
1973
|
+
id_token_signed_response_alg: Optional2(oneOf2(...validJWA)),
|
|
1974
|
+
id_token_encrypted_response_alg: Optional2(oneOf2(...validJWA)),
|
|
1975
|
+
id_token_encrypted_response_enc: Optional2(oneOf2(...validJWA), MustHave("id_token_encrypted_response_alg")),
|
|
1976
|
+
userinfo_signed_response_alg: Optional2(oneOf2(...validJWA)),
|
|
1977
|
+
userinfo_encrypted_response_alg: Optional2(oneOf2(...validJWA)),
|
|
1978
|
+
userinfo_encrypted_response_enc: Optional2(oneOf2(...validJWA), MustHave("userinfo_encrypted_response_alg")),
|
|
1979
|
+
request_object_signing_alg: Optional2(oneOf2(...validJWA)),
|
|
1980
|
+
request_object_encryption_alg: Optional2(oneOf2(...validJWA)),
|
|
1981
|
+
request_object_encryption_enc: Optional2(oneOf2(...validJWA)),
|
|
1982
|
+
token_endpoint_auth_method: Optional2(oneOf2(...validAuthMethods2)),
|
|
1983
|
+
token_endpoint_auth_signing_alg: Optional2(oneOf2(...validJWA)),
|
|
1984
|
+
default_max_age: Optional2(Number),
|
|
1985
|
+
require_auth_time: Optional2(Boolean),
|
|
1986
|
+
default_acr_values: Optional2([String]),
|
|
1987
|
+
initiate_login_uri: Optional2([validURL2]),
|
|
1988
|
+
request_uris: Optional2([validURL2])
|
|
1989
|
+
};
|
|
1990
|
+
assert2(options, {
|
|
1991
|
+
client: Optional2(instanceOf(everything_default.client().constructor)),
|
|
1992
|
+
registration_endpoint: validURL2,
|
|
1993
|
+
client_info: openid_client_metadata
|
|
1994
|
+
});
|
|
1995
|
+
const defaultOptions = {
|
|
1996
|
+
client: everything_default.client().with(thrower()).with(jsonmw())
|
|
1997
|
+
};
|
|
1998
|
+
options = Object.assign({}, defaultOptions, options);
|
|
1999
|
+
let response2 = await options.client.post(options.registration_endpoint, {
|
|
2000
|
+
body: options.client_info
|
|
2001
|
+
});
|
|
2002
|
+
let info = response2.data;
|
|
2003
|
+
if (!info.client_id || !info.client_secret) {
|
|
2004
|
+
throw everything_default.metroError("metro.oidc: Error: dynamic registration of client failed, no client_id or client_secret returned", response2);
|
|
2005
|
+
}
|
|
2006
|
+
options.client_info = Object.assign(options.client_info, info);
|
|
2007
|
+
return options.client_info;
|
|
2008
|
+
}
|
|
2099
2009
|
|
|
2100
2010
|
// src/oidc.store.mjs
|
|
2101
2011
|
function oidcStore(site) {
|
|
@@ -2120,17 +2030,24 @@
|
|
|
2120
2030
|
// src/oidcmw.mjs
|
|
2121
2031
|
function oidcmw(options = {}) {
|
|
2122
2032
|
const defaultOptions = {
|
|
2123
|
-
client:
|
|
2124
|
-
force_authorization: false
|
|
2033
|
+
client: client(),
|
|
2034
|
+
force_authorization: false,
|
|
2035
|
+
use_dpop: true,
|
|
2036
|
+
authorize_callback: async (url2) => {
|
|
2037
|
+
if (window.location.href != url2.href) {
|
|
2038
|
+
window.location.replace(url2.href);
|
|
2039
|
+
}
|
|
2040
|
+
return false;
|
|
2041
|
+
}
|
|
2125
2042
|
};
|
|
2126
2043
|
options = Object.assign({}, defaultOptions, options);
|
|
2127
|
-
|
|
2128
|
-
client:
|
|
2044
|
+
assert2(options, {
|
|
2045
|
+
client: Required2(instanceOf(client().constructor)),
|
|
2129
2046
|
// required because it is set in defaultOptions
|
|
2130
|
-
client_info:
|
|
2131
|
-
issuer:
|
|
2132
|
-
oauth2:
|
|
2133
|
-
openid_configuration:
|
|
2047
|
+
client_info: Required2(),
|
|
2048
|
+
issuer: Required2(validURL2),
|
|
2049
|
+
oauth2: Optional2({}),
|
|
2050
|
+
openid_configuration: Optional2()
|
|
2134
2051
|
});
|
|
2135
2052
|
if (!options.store) {
|
|
2136
2053
|
options.store = oidcStore(options.issuer);
|
|
@@ -2162,9 +2079,9 @@
|
|
|
2162
2079
|
options.store.set("openid_configuration", options.openid_configuration);
|
|
2163
2080
|
}
|
|
2164
2081
|
if (!options.client_info?.client_id) {
|
|
2165
|
-
|
|
2082
|
+
assert2(options.client_info?.client_name, Required2());
|
|
2166
2083
|
if (!options.openid_configuration.registration_endpoint) {
|
|
2167
|
-
throw
|
|
2084
|
+
throw metroError("metro.oidcmw: Error: issuer " + options.issuer + " does not support dynamic client registration, but you haven't specified a client_id");
|
|
2168
2085
|
}
|
|
2169
2086
|
options.client_info = await register({
|
|
2170
2087
|
registration_endpoint: options.openid_configuration.registration_endpoint,
|
|
@@ -2178,6 +2095,7 @@
|
|
|
2178
2095
|
site: options.issuer,
|
|
2179
2096
|
client: options.client,
|
|
2180
2097
|
force_authorization: true,
|
|
2098
|
+
authorize_callback: options.authorize_callback,
|
|
2181
2099
|
oauth2_configuration: {
|
|
2182
2100
|
client_id: options.client_info.client_id,
|
|
2183
2101
|
client_secret: options.client_info.client_secret,
|
|
@@ -2194,48 +2112,61 @@
|
|
|
2194
2112
|
}
|
|
2195
2113
|
//...
|
|
2196
2114
|
);
|
|
2197
|
-
const dpopOptions = {
|
|
2198
|
-
site: options.issuer,
|
|
2199
|
-
authorization_endpoint: options.openid_configuration.authorization_endpoint,
|
|
2200
|
-
token_endpoint: options.openid_configuration.token_endpoint,
|
|
2201
|
-
dpop_signing_alg_values_supported: options.openid_configuration.dpop_signing_alg_values_supported
|
|
2202
|
-
};
|
|
2203
2115
|
const storeIdToken = async (req2, next2) => {
|
|
2204
2116
|
const res2 = await next2(req2);
|
|
2205
2117
|
const contentType = res2.headers.get("content-type");
|
|
2206
2118
|
if (contentType?.startsWith("application/json")) {
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2119
|
+
let id_token = res2.data?.id_token;
|
|
2120
|
+
if (!id_token) {
|
|
2121
|
+
const res22 = res2.clone();
|
|
2122
|
+
try {
|
|
2123
|
+
let data = await res22.json();
|
|
2124
|
+
if (data && data.id_token) {
|
|
2125
|
+
id_token = data.id_token;
|
|
2126
|
+
}
|
|
2127
|
+
} catch (e) {
|
|
2212
2128
|
}
|
|
2213
|
-
}
|
|
2129
|
+
}
|
|
2130
|
+
if (id_token) {
|
|
2131
|
+
options.store.set("id_token", id_token);
|
|
2214
2132
|
}
|
|
2215
2133
|
}
|
|
2216
2134
|
return res2;
|
|
2217
2135
|
};
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2136
|
+
let oauth2client = options.client.with(options.issuer).with(storeIdToken);
|
|
2137
|
+
if (options.use_dpop) {
|
|
2138
|
+
const dpopOptions = {
|
|
2139
|
+
site: options.issuer,
|
|
2140
|
+
authorization_endpoint: options.openid_configuration.authorization_endpoint,
|
|
2141
|
+
token_endpoint: options.openid_configuration.token_endpoint,
|
|
2142
|
+
dpop_signing_alg_values_supported: options.openid_configuration.dpop_signing_alg_values_supported
|
|
2143
|
+
};
|
|
2144
|
+
oauth2client = oauth2client.with(dpopmw(dpopOptions));
|
|
2145
|
+
oauth2Options.client = oauth2client;
|
|
2146
|
+
}
|
|
2147
|
+
oauth2client = oauth2client.with(oauth2mw(oauth2Options));
|
|
2221
2148
|
res = await oauth2client.fetch(req);
|
|
2222
2149
|
return res;
|
|
2223
2150
|
};
|
|
2224
2151
|
}
|
|
2225
2152
|
function isRedirected2() {
|
|
2226
|
-
return
|
|
2153
|
+
return isRedirected();
|
|
2227
2154
|
}
|
|
2228
2155
|
function idToken(options) {
|
|
2229
2156
|
return options.store.get("id_token");
|
|
2230
2157
|
}
|
|
2231
2158
|
|
|
2232
2159
|
// src/browser.mjs
|
|
2233
|
-
var oidc =
|
|
2160
|
+
var oidc = {
|
|
2161
|
+
oidcmw,
|
|
2234
2162
|
discover: oidcDiscovery,
|
|
2235
2163
|
register,
|
|
2236
2164
|
isRedirected: isRedirected2,
|
|
2237
2165
|
idToken
|
|
2238
|
-
}
|
|
2239
|
-
globalThis.oidc
|
|
2166
|
+
};
|
|
2167
|
+
if (!globalThis.metro.oidc) {
|
|
2168
|
+
globalThis.metro.oidc = oidc;
|
|
2169
|
+
}
|
|
2170
|
+
var browser_default2 = oidc;
|
|
2240
2171
|
})();
|
|
2241
2172
|
//# sourceMappingURL=browser.js.map
|