@fedify/vocab-runtime 2.0.8 → 2.0.9
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/deno.json +1 -1
- package/dist/{chunk-CUT6urMc.cjs → chunk-CKQMccvm.cjs} +7 -9
- package/dist/jsonld.cjs +4 -5
- package/dist/jsonld.d.cts +3 -4
- package/dist/jsonld.d.ts +2 -2
- package/dist/jsonld.js +1 -3
- package/dist/mod.cjs +56 -121
- package/dist/mod.d.cts +1 -5
- package/dist/mod.d.ts +1 -5
- package/dist/mod.js +32 -100
- package/dist/tests/{chunk-DWy1uDak.cjs → chunk-Do9eywBl.cjs} +13 -17
- package/dist/tests/docloader.test.cjs +65 -106
- package/dist/tests/{docloader.test.js → docloader.test.mjs} +60 -107
- package/dist/tests/internal/multicodec.test.cjs +5 -7
- package/dist/tests/internal/{multicodec.test.js → multicodec.test.mjs} +3 -4
- package/dist/tests/key.test.cjs +39 -70
- package/dist/tests/{key.test.js → key.test.mjs} +32 -62
- package/dist/tests/langstr.test.cjs +6 -8
- package/dist/tests/{langstr.test.js → langstr.test.mjs} +2 -4
- package/dist/tests/{link-CdFPEo9O.cjs → link-B6ZWBZhf.cjs} +6 -8
- package/dist/tests/{link-Ck2yj4dH.js → link-B8JGXSS2.mjs} +1 -2
- package/dist/tests/link.test.cjs +5 -7
- package/dist/tests/{link.test.js → link.test.mjs} +3 -4
- package/dist/tests/multibase/multibase.test.cjs +10 -17
- package/dist/tests/multibase/{multibase.test.js → multibase.test.mjs} +10 -18
- package/dist/tests/{multibase-B2D6B0V4.cjs → multibase-CgYqpk4Z.cjs} +43 -49
- package/dist/tests/{multibase-BdHCGO4H.js → multibase-jcKrOpuU.mjs} +5 -12
- package/dist/tests/{multicodec-mHcRzSGY.cjs → multicodec-DeYop8xg.cjs} +16 -18
- package/dist/tests/{multicodec-DvC5xnX2.js → multicodec-aqbZnrNi.mjs} +1 -2
- package/dist/tests/{request-Cqx2eUpt.js → request-AitXfW_2.mjs} +4 -45
- package/dist/tests/{request-D2-F2dMS.cjs → request-C6iSYeYi.cjs} +38 -72
- package/dist/tests/request.test.cjs +23 -24
- package/dist/tests/request.test.mjs +42 -0
- package/dist/tests/{url-C5Vs9nYh.cjs → url-Cr2K-wzd.cjs} +31 -35
- package/dist/tests/{url-fW_DHbih.js → url-Djghaq0m.mjs} +3 -7
- package/dist/tests/url.test.cjs +5 -7
- package/dist/tests/{url.test.js → url.test.mjs} +3 -4
- package/package.json +3 -3
- package/dist/tests/request.test.js +0 -43
- /package/dist/tests/{docloader.test.d.ts → docloader.test.d.mts} +0 -0
- /package/dist/tests/internal/{multicodec.test.d.ts → multicodec.test.d.mts} +0 -0
- /package/dist/tests/{key.test.d.ts → key.test.d.mts} +0 -0
- /package/dist/tests/{langstr.test.d.ts → langstr.test.d.mts} +0 -0
- /package/dist/tests/{link.test.d.ts → link.test.d.mts} +0 -0
- /package/dist/tests/multibase/{multibase.test.d.ts → multibase.test.d.mts} +0 -0
- /package/dist/tests/{request.test.d.ts → request.test.d.mts} +0 -0
- /package/dist/tests/{url.test.d.ts → url.test.d.mts} +0 -0
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
const require_chunk = require(
|
|
2
|
-
const require_request = require(
|
|
3
|
-
const require_link = require(
|
|
4
|
-
const require_url = require(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
const require_chunk = require("./chunk-Do9eywBl.cjs");
|
|
2
|
+
const require_request = require("./request-C6iSYeYi.cjs");
|
|
3
|
+
const require_link = require("./link-B6ZWBZhf.cjs");
|
|
4
|
+
const require_url = require("./url-Cr2K-wzd.cjs");
|
|
5
|
+
let node_assert = require("node:assert");
|
|
6
|
+
let node_test = require("node:test");
|
|
7
|
+
let _logtape_logtape = require("@logtape/logtape");
|
|
8
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
10
9
|
//#region ../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
|
|
11
|
-
var require_glob_to_regexp =
|
|
12
|
-
module.exports = function(glob
|
|
13
|
-
if (typeof glob
|
|
14
|
-
var str = String(glob
|
|
10
|
+
var require_glob_to_regexp = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
|
|
11
|
+
module.exports = function(glob, opts) {
|
|
12
|
+
if (typeof glob !== "string") throw new TypeError("Expected a string");
|
|
13
|
+
var str = String(glob);
|
|
15
14
|
var reStr = "";
|
|
16
15
|
var extended = opts ? !!opts.extended : false;
|
|
17
16
|
var globstar = opts ? !!opts.globstar : false;
|
|
@@ -68,13 +67,10 @@ var require_glob_to_regexp = require_chunk.__commonJS({ "../../node_modules/.pnp
|
|
|
68
67
|
}
|
|
69
68
|
var nextChar = str[i + 1];
|
|
70
69
|
if (!globstar) reStr += ".*";
|
|
71
|
-
else {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
i++;
|
|
76
|
-
} else reStr += "([^/]*)";
|
|
77
|
-
}
|
|
70
|
+
else if (starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0)) {
|
|
71
|
+
reStr += "((?:[^/]*(?:/|$))*)";
|
|
72
|
+
i++;
|
|
73
|
+
} else reStr += "([^/]*)";
|
|
78
74
|
break;
|
|
79
75
|
default: reStr += c;
|
|
80
76
|
}
|
|
@@ -82,10 +78,10 @@ var require_glob_to_regexp = require_chunk.__commonJS({ "../../node_modules/.pnp
|
|
|
82
78
|
if (!flags || !~flags.indexOf("g")) reStr = "^" + reStr + "$";
|
|
83
79
|
return new RegExp(reStr, flags);
|
|
84
80
|
};
|
|
85
|
-
}
|
|
86
|
-
|
|
81
|
+
}));
|
|
87
82
|
//#endregion
|
|
88
83
|
//#region ../../node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.mjs
|
|
84
|
+
var import_glob_to_regexp = /* @__PURE__ */ require_chunk.__toESM(require_glob_to_regexp(), 1);
|
|
89
85
|
/**
|
|
90
86
|
* @param {string|RegExp} input The route pattern
|
|
91
87
|
* @param {boolean} [loose] Allow open-ended matching. Ignored with `RegExp` input.
|
|
@@ -115,7 +111,6 @@ function parse(input, loose) {
|
|
|
115
111
|
pattern: new RegExp("^" + pattern + (loose ? "(?=$|/)" : "/?$"), "i")
|
|
116
112
|
};
|
|
117
113
|
}
|
|
118
|
-
|
|
119
114
|
//#endregion
|
|
120
115
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/TypeDescriptor.js
|
|
121
116
|
const valueTypes = new Set([
|
|
@@ -207,7 +202,6 @@ var TypeDescriptor = class TypeDescriptor {
|
|
|
207
202
|
return TypeDescriptor.of(value) === "undefined";
|
|
208
203
|
}
|
|
209
204
|
};
|
|
210
|
-
|
|
211
205
|
//#endregion
|
|
212
206
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/IsSubsetOf.js
|
|
213
207
|
const allowedTypes = new Set([
|
|
@@ -234,7 +228,7 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
234
228
|
switch (subsetItemType) {
|
|
235
229
|
case "array":
|
|
236
230
|
case "object":
|
|
237
|
-
case "function":
|
|
231
|
+
case "function":
|
|
238
232
|
if (visited.includes(subsetItem)) continue;
|
|
239
233
|
visited.push(subsetItem);
|
|
240
234
|
isItemInSuperset = superset.some((supersetItem) => {
|
|
@@ -245,7 +239,6 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
245
239
|
}
|
|
246
240
|
});
|
|
247
241
|
break;
|
|
248
|
-
}
|
|
249
242
|
default: isItemInSuperset = superset.includes(subsetItem);
|
|
250
243
|
}
|
|
251
244
|
if (!isItemInSuperset) return false;
|
|
@@ -257,21 +250,18 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
257
250
|
if (Object.keys(subset).length > Object.keys(superset).length) return false;
|
|
258
251
|
for (const [subsetKey, subsetValue] of Object.entries(subset)) {
|
|
259
252
|
const supersetValue = superset[subsetKey];
|
|
260
|
-
|
|
261
|
-
switch (subsetValueType) {
|
|
253
|
+
switch (TypeDescriptor.of(subsetValue)) {
|
|
262
254
|
case "array":
|
|
263
255
|
case "object":
|
|
264
|
-
case "function":
|
|
256
|
+
case "function":
|
|
265
257
|
if (visited.includes(subsetValue)) continue;
|
|
266
258
|
visited.push(subsetValue);
|
|
267
259
|
try {
|
|
268
|
-
|
|
269
|
-
if (!isInSuperset) return false;
|
|
260
|
+
if (!isSubsetOf(subsetValue, supersetValue, visited)) return false;
|
|
270
261
|
} catch {
|
|
271
262
|
return false;
|
|
272
263
|
}
|
|
273
264
|
break;
|
|
274
|
-
}
|
|
275
265
|
default: if (subsetValue !== supersetValue) return false;
|
|
276
266
|
}
|
|
277
267
|
}
|
|
@@ -294,8 +284,7 @@ isSubsetOf.structural = function(subset, superset, visited = []) {
|
|
|
294
284
|
if (visited.includes(subsetValue)) continue;
|
|
295
285
|
visited.push(subsetValue);
|
|
296
286
|
try {
|
|
297
|
-
|
|
298
|
-
if (!isInSuperset) return false;
|
|
287
|
+
if (!isSubsetOf.structural(subsetValue, supersetValue, visited)) return false;
|
|
299
288
|
} catch {
|
|
300
289
|
return false;
|
|
301
290
|
}
|
|
@@ -303,7 +292,6 @@ isSubsetOf.structural = function(subset, superset, visited = []) {
|
|
|
303
292
|
}
|
|
304
293
|
return true;
|
|
305
294
|
};
|
|
306
|
-
|
|
307
295
|
//#endregion
|
|
308
296
|
//#region ../../node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.mjs
|
|
309
297
|
var has = Object.prototype.hasOwnProperty;
|
|
@@ -366,11 +354,10 @@ function dequal(foo, bar) {
|
|
|
366
354
|
}
|
|
367
355
|
return foo !== foo && bar !== bar;
|
|
368
356
|
}
|
|
369
|
-
|
|
370
357
|
//#endregion
|
|
371
358
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/RequestUtils.js
|
|
372
|
-
const absoluteUrlRX = new RegExp("^[a-z]+://|^data:", "i");
|
|
373
|
-
const protocolRelativeUrlRX = new RegExp("^//", "i");
|
|
359
|
+
const absoluteUrlRX = /* @__PURE__ */ new RegExp("^[a-z]+://|^data:", "i");
|
|
360
|
+
const protocolRelativeUrlRX = /* @__PURE__ */ new RegExp("^//", "i");
|
|
374
361
|
function hasCredentialsInUrl(url) {
|
|
375
362
|
const urlObject = new URL(url, !absoluteUrlRX.test(url) ? "http://dummy" : void 0);
|
|
376
363
|
return Boolean(urlObject.username || urlObject.password);
|
|
@@ -418,7 +405,7 @@ async function createCallLogFromRequest(request, options) {
|
|
|
418
405
|
} catch {}
|
|
419
406
|
if (request.headers) derivedOptions.headers = normalizeHeaders(request.headers);
|
|
420
407
|
const url = normalizeUrl(request.url, true);
|
|
421
|
-
|
|
408
|
+
return {
|
|
422
409
|
args: [request, options],
|
|
423
410
|
url,
|
|
424
411
|
queryParams: new URLSearchParams(getQuery(url)),
|
|
@@ -427,11 +414,9 @@ async function createCallLogFromRequest(request, options) {
|
|
|
427
414
|
signal: options && options.signal || request.signal,
|
|
428
415
|
pendingPromises
|
|
429
416
|
};
|
|
430
|
-
return callLog;
|
|
431
417
|
}
|
|
432
418
|
function getPath(url) {
|
|
433
|
-
|
|
434
|
-
return u.pathname;
|
|
419
|
+
return (absoluteUrlRX.test(url) ? new URL(url) : new URL(url, "http://dummy")).pathname;
|
|
435
420
|
}
|
|
436
421
|
function getHost(url) {
|
|
437
422
|
if (absoluteUrlRX.test(url)) return new URL(url).host;
|
|
@@ -449,10 +434,8 @@ function normalizeHeaders(headers) {
|
|
|
449
434
|
else entries = Object.entries(headers);
|
|
450
435
|
return Object.fromEntries(entries.map(([key, val]) => [key.toLowerCase(), String(val).valueOf()]));
|
|
451
436
|
}
|
|
452
|
-
|
|
453
437
|
//#endregion
|
|
454
438
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Matchers.js
|
|
455
|
-
var import_glob_to_regexp = require_chunk.__toESM(require_glob_to_regexp(), 1);
|
|
456
439
|
const isUrlMatcher = (matcher) => matcher instanceof RegExp || typeof matcher === "string" || typeof matcher === "object" && "href" in matcher;
|
|
457
440
|
const isFunctionMatcher = (matcher) => typeof matcher === "function";
|
|
458
441
|
const stringMatchers = {
|
|
@@ -506,8 +489,7 @@ const getMissingHeaderMatcher = ({ missingHeaders: expectedMissingHeaders }) =>
|
|
|
506
489
|
const getMethodMatcher = ({ method: expectedMethod }) => {
|
|
507
490
|
if (!expectedMethod) return;
|
|
508
491
|
return ({ options: { method } = {} }) => {
|
|
509
|
-
|
|
510
|
-
return expectedMethod === actualMethod;
|
|
492
|
+
return expectedMethod === (method ? method.toLowerCase() : "get");
|
|
511
493
|
};
|
|
512
494
|
};
|
|
513
495
|
const getQueryParamsMatcher = ({ query: passedQuery }) => {
|
|
@@ -586,7 +568,7 @@ const getUrlMatcher = (route) => {
|
|
|
586
568
|
}
|
|
587
569
|
if (typeof matcherUrl === "string") {
|
|
588
570
|
for (const shorthand in stringMatchers) if (matcherUrl.indexOf(`${shorthand}:`) === 0) {
|
|
589
|
-
const urlFragment = matcherUrl.replace(
|
|
571
|
+
const urlFragment = matcherUrl.replace(new RegExp(`^${shorthand}:`), "");
|
|
590
572
|
return stringMatchers[shorthand](urlFragment);
|
|
591
573
|
}
|
|
592
574
|
return getFullUrlMatcher(route, matcherUrl, query);
|
|
@@ -597,7 +579,7 @@ const getUrlMatcher = (route) => {
|
|
|
597
579
|
else if (key in stringMatchers) return stringMatchers[key](pattern);
|
|
598
580
|
else throw new Error(`unrecognised url matching pattern: ${key}`);
|
|
599
581
|
});
|
|
600
|
-
return (route
|
|
582
|
+
return (route) => matchers.every((matcher) => matcher(route));
|
|
601
583
|
}
|
|
602
584
|
};
|
|
603
585
|
const builtInMatchers = [
|
|
@@ -635,7 +617,6 @@ const builtInMatchers = [
|
|
|
635
617
|
matcher: getFunctionMatcher
|
|
636
618
|
}
|
|
637
619
|
];
|
|
638
|
-
|
|
639
620
|
//#endregion
|
|
640
621
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/StatusTextMap.js
|
|
641
622
|
const statusTextMap = {
|
|
@@ -702,17 +683,15 @@ const statusTextMap = {
|
|
|
702
683
|
510: "Not Extended",
|
|
703
684
|
511: "Network Authentication Required"
|
|
704
685
|
};
|
|
705
|
-
var StatusTextMap_default = statusTextMap;
|
|
706
|
-
|
|
707
686
|
//#endregion
|
|
708
687
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Route.js
|
|
709
|
-
var __classPrivateFieldSet =
|
|
688
|
+
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
710
689
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
711
690
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
712
691
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
713
692
|
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
714
693
|
};
|
|
715
|
-
var __classPrivateFieldGet =
|
|
694
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
716
695
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
717
696
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
718
697
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -773,14 +752,13 @@ var Route = class {
|
|
|
773
752
|
constructResponseOptions(responseInput) {
|
|
774
753
|
const options = responseInput.options || {};
|
|
775
754
|
options.status = sanitizeStatus(responseInput.status);
|
|
776
|
-
options.statusText =
|
|
755
|
+
options.statusText = statusTextMap[options.status];
|
|
777
756
|
options.headers = new this.config.Headers(responseInput.headers);
|
|
778
757
|
return options;
|
|
779
758
|
}
|
|
780
759
|
constructResponseBody(responseInput, responseOptions) {
|
|
781
760
|
let body = responseInput.body;
|
|
782
|
-
|
|
783
|
-
if (!bodyIsBodyInit) if (typeof body === "undefined") body = null;
|
|
761
|
+
if (!isBodyInit(body)) if (typeof body === "undefined") body = null;
|
|
784
762
|
else if (typeof body === "object") {
|
|
785
763
|
body = JSON.stringify(body);
|
|
786
764
|
if (!responseOptions.headers.has("Content-Type")) responseOptions.headers.set("Content-Type", "application/json");
|
|
@@ -799,26 +777,25 @@ var Route = class {
|
|
|
799
777
|
_a.registeredMatchers.push(matcher);
|
|
800
778
|
}
|
|
801
779
|
};
|
|
802
|
-
_a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route_instances = /* @__PURE__ */ new WeakSet(), _Route_validate = function _Route_validate
|
|
780
|
+
_a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route_instances = /* @__PURE__ */ new WeakSet(), _Route_validate = function _Route_validate() {
|
|
803
781
|
if (["matched", "unmatched"].includes(this.config.name)) throw new Error(`fetch-mock: Routes cannot use the reserved name \`${this.config.name}\``);
|
|
804
782
|
if (!("response" in this.config)) throw new Error("fetch-mock: Each route must define a response");
|
|
805
783
|
if (!_a.registeredMatchers.some(({ name }) => name in this.config)) throw new Error("fetch-mock: Each route must specify some criteria for matching calls to fetch. To match all calls use '*'");
|
|
806
|
-
}, _Route_sanitize = function _Route_sanitize
|
|
784
|
+
}, _Route_sanitize = function _Route_sanitize() {
|
|
807
785
|
if (this.config.method) this.config.method = this.config.method.toLowerCase();
|
|
808
|
-
}, _Route_generateMatcher = function _Route_generateMatcher
|
|
786
|
+
}, _Route_generateMatcher = function _Route_generateMatcher() {
|
|
809
787
|
const activeMatchers = _a.registeredMatchers.filter(({ name }) => name in this.config).map(({ matcher, usesBody }) => ({
|
|
810
788
|
matcher: matcher(this.config),
|
|
811
789
|
usesBody
|
|
812
790
|
}));
|
|
813
791
|
this.config.usesBody = activeMatchers.some(({ usesBody }) => usesBody);
|
|
814
792
|
this.matcher = (normalizedRequest) => activeMatchers.every(({ matcher }) => matcher(normalizedRequest));
|
|
815
|
-
}, _Route_limit = function _Route_limit
|
|
793
|
+
}, _Route_limit = function _Route_limit() {
|
|
816
794
|
if (!this.config.repeat) return;
|
|
817
795
|
const originalMatcher = this.matcher;
|
|
818
796
|
let timesLeft = this.config.repeat;
|
|
819
797
|
this.matcher = (callLog) => {
|
|
820
|
-
|
|
821
|
-
if (match) {
|
|
798
|
+
if (timesLeft && originalMatcher(callLog)) {
|
|
822
799
|
timesLeft--;
|
|
823
800
|
return true;
|
|
824
801
|
}
|
|
@@ -826,7 +803,7 @@ _a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route
|
|
|
826
803
|
this.reset = () => {
|
|
827
804
|
timesLeft = this.config.repeat;
|
|
828
805
|
};
|
|
829
|
-
}, _Route_delayResponse = function _Route_delayResponse
|
|
806
|
+
}, _Route_delayResponse = function _Route_delayResponse() {
|
|
830
807
|
if (this.config.delay) {
|
|
831
808
|
const { response } = this.config;
|
|
832
809
|
this.config.response = () => {
|
|
@@ -836,8 +813,6 @@ _a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route
|
|
|
836
813
|
};
|
|
837
814
|
Route.registeredMatchers = [];
|
|
838
815
|
builtInMatchers.forEach(Route.defineMatcher);
|
|
839
|
-
var Route_default = Route;
|
|
840
|
-
|
|
841
816
|
//#endregion
|
|
842
817
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Router.js
|
|
843
818
|
const responseConfigProps = [
|
|
@@ -910,8 +885,7 @@ var Router = class {
|
|
|
910
885
|
});
|
|
911
886
|
}
|
|
912
887
|
if (this.needsToReadBody(request)) options.body = await options.body;
|
|
913
|
-
const
|
|
914
|
-
const route = routesToTry.find((route$1) => route$1.matcher(callLog));
|
|
888
|
+
const route = (this.fallbackRoute ? [...this.routes, this.fallbackRoute] : this.routes).find((route) => route.matcher(callLog));
|
|
915
889
|
if (route) try {
|
|
916
890
|
callLog.route = route;
|
|
917
891
|
const { response, responseOptions, responseInput } = await this.generateResponse(callLog);
|
|
@@ -966,7 +940,7 @@ var Router = class {
|
|
|
966
940
|
else Object.assign(config, matcher);
|
|
967
941
|
if (typeof response !== "undefined") config.response = response;
|
|
968
942
|
if (nameOrOptions) Object.assign(config, typeof nameOrOptions === "string" ? nameToOptions(nameOrOptions) : nameOrOptions);
|
|
969
|
-
const route = new
|
|
943
|
+
const route = new Route({
|
|
970
944
|
...this.config,
|
|
971
945
|
...config
|
|
972
946
|
});
|
|
@@ -985,7 +959,7 @@ var Router = class {
|
|
|
985
959
|
}
|
|
986
960
|
setFallback(response) {
|
|
987
961
|
if (this.fallbackRoute) console.warn("calling fetchMock.catch() twice - are you sure you want to overwrite the previous fallback response");
|
|
988
|
-
this.fallbackRoute = new
|
|
962
|
+
this.fallbackRoute = new Route({
|
|
989
963
|
matcherFunction: () => true,
|
|
990
964
|
response: response || "ok",
|
|
991
965
|
...this.config
|
|
@@ -1017,7 +991,6 @@ var Router = class {
|
|
|
1017
991
|
route.init(newConfig);
|
|
1018
992
|
}
|
|
1019
993
|
};
|
|
1020
|
-
|
|
1021
994
|
//#endregion
|
|
1022
995
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/CallHistory.js
|
|
1023
996
|
const isName = (filter) => typeof filter === "string" && /^[\da-zA-Z-]+$/.test(filter) && !["matched", "unmatched"].includes(filter);
|
|
@@ -1063,12 +1036,12 @@ var CallHistory = class {
|
|
|
1063
1036
|
...filter,
|
|
1064
1037
|
...options || {}
|
|
1065
1038
|
};
|
|
1066
|
-
const { matcher } = new
|
|
1039
|
+
const { matcher } = new Route({
|
|
1067
1040
|
response: "ok",
|
|
1068
1041
|
...options
|
|
1069
1042
|
});
|
|
1070
|
-
calls = calls.filter(({ url, options
|
|
1071
|
-
return matcher(createCallLogFromUrlAndOptions(url, options
|
|
1043
|
+
calls = calls.filter(({ url, options }) => {
|
|
1044
|
+
return matcher(createCallLogFromUrlAndOptions(url, options));
|
|
1072
1045
|
});
|
|
1073
1046
|
return calls;
|
|
1074
1047
|
}
|
|
@@ -1101,8 +1074,6 @@ var CallHistory = class {
|
|
|
1101
1074
|
}).every((isDone) => isDone);
|
|
1102
1075
|
}
|
|
1103
1076
|
};
|
|
1104
|
-
var CallHistory_default = CallHistory;
|
|
1105
|
-
|
|
1106
1077
|
//#endregion
|
|
1107
1078
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/FetchMock.js
|
|
1108
1079
|
const defaultFetchMockConfig = {
|
|
@@ -1124,7 +1095,9 @@ const defineGreedyShorthand = (shorthandOptions) => {
|
|
|
1124
1095
|
return this.route("*", response, Object.assign(options || {}, shorthandOptions));
|
|
1125
1096
|
};
|
|
1126
1097
|
};
|
|
1127
|
-
|
|
1098
|
+
//#endregion
|
|
1099
|
+
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/index.js
|
|
1100
|
+
var esm_default = new class FetchMock {
|
|
1128
1101
|
constructor(config, router) {
|
|
1129
1102
|
this.sticky = defineShorthand({ sticky: true });
|
|
1130
1103
|
this.once = defineShorthand({ repeat: 1 });
|
|
@@ -1165,7 +1138,7 @@ var FetchMock = class FetchMock {
|
|
|
1165
1138
|
routes: router ? [...router.routes] : [],
|
|
1166
1139
|
fallbackRoute: router ? router.fallbackRoute : null
|
|
1167
1140
|
});
|
|
1168
|
-
this.callHistory = new
|
|
1141
|
+
this.callHistory = new CallHistory(this.config, this.router);
|
|
1169
1142
|
this.fetchHandler = this.fetchHandler.bind(this);
|
|
1170
1143
|
Object.assign(this.fetchHandler, { fetchMock: this });
|
|
1171
1144
|
}
|
|
@@ -1190,7 +1163,7 @@ var FetchMock = class FetchMock {
|
|
|
1190
1163
|
return this;
|
|
1191
1164
|
}
|
|
1192
1165
|
defineMatcher(matcher) {
|
|
1193
|
-
|
|
1166
|
+
Route.defineMatcher(matcher);
|
|
1194
1167
|
}
|
|
1195
1168
|
removeRoutes(options) {
|
|
1196
1169
|
this.router.removeRoutes(options);
|
|
@@ -1232,14 +1205,7 @@ var FetchMock = class FetchMock {
|
|
|
1232
1205
|
this.mockGlobal();
|
|
1233
1206
|
return this.spy();
|
|
1234
1207
|
}
|
|
1235
|
-
};
|
|
1236
|
-
const fetchMock = new FetchMock({ ...defaultFetchMockConfig });
|
|
1237
|
-
var FetchMock_default = fetchMock;
|
|
1238
|
-
|
|
1239
|
-
//#endregion
|
|
1240
|
-
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/index.js
|
|
1241
|
-
var esm_default = FetchMock_default;
|
|
1242
|
-
|
|
1208
|
+
}({ ...defaultFetchMockConfig });
|
|
1243
1209
|
//#endregion
|
|
1244
1210
|
//#region src/contexts.ts
|
|
1245
1211
|
const preloadedContexts = {
|
|
@@ -5488,11 +5454,9 @@ const preloadedContexts = {
|
|
|
5488
5454
|
}
|
|
5489
5455
|
} }
|
|
5490
5456
|
};
|
|
5491
|
-
var contexts_default = preloadedContexts;
|
|
5492
|
-
|
|
5493
5457
|
//#endregion
|
|
5494
5458
|
//#region src/docloader.ts
|
|
5495
|
-
const logger = (0,
|
|
5459
|
+
const logger = (0, _logtape_logtape.getLogger)([
|
|
5496
5460
|
"fedify",
|
|
5497
5461
|
"runtime",
|
|
5498
5462
|
"docloader"
|
|
@@ -5507,7 +5471,7 @@ const DEFAULT_MAX_REDIRECTION = 20;
|
|
|
5507
5471
|
* @throws {FetchError} If the response is not OK.
|
|
5508
5472
|
* @internal
|
|
5509
5473
|
*/
|
|
5510
|
-
async function getRemoteDocument(url, response, fetch
|
|
5474
|
+
async function getRemoteDocument(url, response, fetch) {
|
|
5511
5475
|
const documentUrl = response.url === "" ? url : response.url;
|
|
5512
5476
|
const docUrl = new URL(documentUrl);
|
|
5513
5477
|
if (!response.ok) {
|
|
@@ -5545,7 +5509,7 @@ async function getRemoteDocument(url, response, fetch$1) {
|
|
|
5545
5509
|
alternateUrl: altUri.href,
|
|
5546
5510
|
url: documentUrl
|
|
5547
5511
|
});
|
|
5548
|
-
return await fetch
|
|
5512
|
+
return await fetch(altUri.href);
|
|
5549
5513
|
}
|
|
5550
5514
|
}
|
|
5551
5515
|
}
|
|
@@ -5571,15 +5535,14 @@ async function getRemoteDocument(url, response, fetch$1) {
|
|
|
5571
5535
|
attrPattern.lastIndex = 0;
|
|
5572
5536
|
while ((attrMatch = attrPattern.exec(tagContent)) !== null) {
|
|
5573
5537
|
const key = attrMatch[1].toLowerCase();
|
|
5574
|
-
|
|
5575
|
-
attribs[key] = value;
|
|
5538
|
+
attribs[key] = attrMatch[2] ?? attrMatch[3] ?? attrMatch[4] ?? "";
|
|
5576
5539
|
}
|
|
5577
5540
|
if (attribs.rel === "alternate" && "type" in attribs && (attribs.type === "application/activity+json" || attribs.type === "application/ld+json" || attribs.type.startsWith("application/ld+json;")) && "href" in attribs && new URL(attribs.href, docUrl).href !== docUrl.href) {
|
|
5578
5541
|
logger.debug("Found alternate document: {alternateUrl} from {url}", {
|
|
5579
5542
|
alternateUrl: attribs.href,
|
|
5580
5543
|
url: documentUrl
|
|
5581
5544
|
});
|
|
5582
|
-
return await fetch
|
|
5545
|
+
return await fetch(new URL(attribs.href, docUrl).href);
|
|
5583
5546
|
}
|
|
5584
5547
|
}
|
|
5585
5548
|
document = JSON.parse(html);
|
|
@@ -5614,16 +5577,15 @@ async function getRemoteDocument(url, response, fetch$1) {
|
|
|
5614
5577
|
* @since 1.3.0
|
|
5615
5578
|
*/
|
|
5616
5579
|
function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAgent } = {}) {
|
|
5617
|
-
const
|
|
5618
|
-
const tracer = tracerProvider.getTracer(require_request.deno_default.name, require_request.deno_default.version);
|
|
5580
|
+
const tracer = _opentelemetry_api.trace.getTracerProvider().getTracer(require_request.name, require_request.version);
|
|
5619
5581
|
async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
|
|
5620
5582
|
options?.signal?.throwIfAborted();
|
|
5621
5583
|
const currentUrl = new URL(url).href;
|
|
5622
|
-
if (!skipPreloadedContexts && currentUrl in
|
|
5584
|
+
if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
|
|
5623
5585
|
logger.debug("Using preloaded context: {url}.", { url: currentUrl });
|
|
5624
5586
|
return {
|
|
5625
5587
|
contextUrl: null,
|
|
5626
|
-
document:
|
|
5588
|
+
document: preloadedContexts[currentUrl],
|
|
5627
5589
|
documentUrl: currentUrl
|
|
5628
5590
|
};
|
|
5629
5591
|
}
|
|
@@ -5638,7 +5600,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5638
5600
|
}
|
|
5639
5601
|
visited.add(currentUrl);
|
|
5640
5602
|
return await tracer.startActiveSpan("activitypub.fetch_document", {
|
|
5641
|
-
kind:
|
|
5603
|
+
kind: _opentelemetry_api.SpanKind.CLIENT,
|
|
5642
5604
|
attributes: { "url.full": currentUrl }
|
|
5643
5605
|
}, async (span) => {
|
|
5644
5606
|
try {
|
|
@@ -5675,7 +5637,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5675
5637
|
} catch (error) {
|
|
5676
5638
|
span.recordException(error);
|
|
5677
5639
|
span.setStatus({
|
|
5678
|
-
code:
|
|
5640
|
+
code: _opentelemetry_api.SpanStatusCode.ERROR,
|
|
5679
5641
|
message: String(error)
|
|
5680
5642
|
});
|
|
5681
5643
|
throw error;
|
|
@@ -5686,7 +5648,6 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5686
5648
|
}
|
|
5687
5649
|
return load;
|
|
5688
5650
|
}
|
|
5689
|
-
|
|
5690
5651
|
//#endregion
|
|
5691
5652
|
//#region src/docloader.test.ts
|
|
5692
5653
|
(0, node_test.test)("new FetchError()", () => {
|
|
@@ -5904,7 +5865,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5904
5865
|
await (0, node_assert.rejects)(() => fetchDocumentLoader("https://example.com/404"), require_request.FetchError, "HTTP 404: https://example.com/404");
|
|
5905
5866
|
});
|
|
5906
5867
|
await t.test("preloaded contexts", async () => {
|
|
5907
|
-
for (const [url, document] of Object.entries(
|
|
5868
|
+
for (const [url, document] of Object.entries(preloadedContexts)) (0, node_assert.deepStrictEqual)(await fetchDocumentLoader(url), {
|
|
5908
5869
|
contextUrl: null,
|
|
5909
5870
|
documentUrl: url,
|
|
5910
5871
|
document
|
|
@@ -5959,10 +5920,9 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5959
5920
|
let redirectAttempts = 0;
|
|
5960
5921
|
esm_default.get("begin:https://example.com/too-many-redirects/", (cl) => {
|
|
5961
5922
|
redirectAttempts++;
|
|
5962
|
-
const index = Number(cl.url.split("/").at(-1));
|
|
5963
5923
|
return {
|
|
5964
5924
|
status: 302,
|
|
5965
|
-
headers: { Location: `https://example.com/too-many-redirects/${
|
|
5925
|
+
headers: { Location: `https://example.com/too-many-redirects/${Number(cl.url.split("/").at(-1)) + 1}` }
|
|
5966
5926
|
};
|
|
5967
5927
|
});
|
|
5968
5928
|
await t.test("too many redirects", async () => {
|
|
@@ -6016,5 +5976,4 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
6016
5976
|
});
|
|
6017
5977
|
esm_default.hardReset();
|
|
6018
5978
|
});
|
|
6019
|
-
|
|
6020
|
-
//#endregion
|
|
5979
|
+
//#endregion
|