@fedify/webfinger 2.2.0-dev.613 → 2.2.0-dev.622
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/lookup.test.cjs +84 -162
- package/dist/lookup.test.js +70 -149
- package/dist/mod.cjs +14 -71
- package/dist/mod.js +3 -38
- package/package.json +4 -4
- package/tsdown.config.ts +14 -2
package/deno.json
CHANGED
package/dist/lookup.test.cjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
11
9
|
var __copyProps = (to, from, except, desc) => {
|
|
12
10
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
11
|
key = keys[i];
|
|
@@ -22,20 +20,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
20
|
value: mod,
|
|
23
21
|
enumerable: true
|
|
24
22
|
}) : target, mod));
|
|
25
|
-
|
|
26
23
|
//#endregion
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//#region ../../node_modules/.pnpm/
|
|
35
|
-
var
|
|
36
|
-
module.exports = function(glob
|
|
37
|
-
if (typeof glob
|
|
38
|
-
var str = String(glob
|
|
24
|
+
let _fedify_fixture = require("@fedify/fixture");
|
|
25
|
+
let es_toolkit = require("es-toolkit");
|
|
26
|
+
let node_assert_strict = require("node:assert/strict");
|
|
27
|
+
let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
28
|
+
let _logtape_logtape = require("@logtape/logtape");
|
|
29
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region ../../node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.mjs
|
|
32
|
+
var import_glob_to_regexp = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
33
|
+
module.exports = function(glob, opts) {
|
|
34
|
+
if (typeof glob !== "string") throw new TypeError("Expected a string");
|
|
35
|
+
var str = String(glob);
|
|
39
36
|
var reStr = "";
|
|
40
37
|
var extended = opts ? !!opts.extended : false;
|
|
41
38
|
var globstar = opts ? !!opts.globstar : false;
|
|
@@ -92,13 +89,10 @@ var require_glob_to_regexp = __commonJS({ "../../node_modules/.pnpm/glob-to-rege
|
|
|
92
89
|
}
|
|
93
90
|
var nextChar = str[i + 1];
|
|
94
91
|
if (!globstar) reStr += ".*";
|
|
95
|
-
else {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
i++;
|
|
100
|
-
} else reStr += "([^/]*)";
|
|
101
|
-
}
|
|
92
|
+
else if (starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0)) {
|
|
93
|
+
reStr += "((?:[^/]*(?:/|$))*)";
|
|
94
|
+
i++;
|
|
95
|
+
} else reStr += "([^/]*)";
|
|
102
96
|
break;
|
|
103
97
|
default: reStr += c;
|
|
104
98
|
}
|
|
@@ -106,10 +100,7 @@ var require_glob_to_regexp = __commonJS({ "../../node_modules/.pnpm/glob-to-rege
|
|
|
106
100
|
if (!flags || !~flags.indexOf("g")) reStr = "^" + reStr + "$";
|
|
107
101
|
return new RegExp(reStr, flags);
|
|
108
102
|
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region ../../node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.mjs
|
|
103
|
+
})))(), 1);
|
|
113
104
|
/**
|
|
114
105
|
* @param {string|RegExp} input The route pattern
|
|
115
106
|
* @param {boolean} [loose] Allow open-ended matching. Ignored with `RegExp` input.
|
|
@@ -139,7 +130,6 @@ function parse(input, loose) {
|
|
|
139
130
|
pattern: new RegExp("^" + pattern + (loose ? "(?=$|/)" : "/?$"), "i")
|
|
140
131
|
};
|
|
141
132
|
}
|
|
142
|
-
|
|
143
133
|
//#endregion
|
|
144
134
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/TypeDescriptor.js
|
|
145
135
|
const valueTypes = new Set([
|
|
@@ -231,7 +221,6 @@ var TypeDescriptor = class TypeDescriptor {
|
|
|
231
221
|
return TypeDescriptor.of(value) === "undefined";
|
|
232
222
|
}
|
|
233
223
|
};
|
|
234
|
-
|
|
235
224
|
//#endregion
|
|
236
225
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/IsSubsetOf.js
|
|
237
226
|
const allowedTypes = new Set([
|
|
@@ -258,7 +247,7 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
258
247
|
switch (subsetItemType) {
|
|
259
248
|
case "array":
|
|
260
249
|
case "object":
|
|
261
|
-
case "function":
|
|
250
|
+
case "function":
|
|
262
251
|
if (visited.includes(subsetItem)) continue;
|
|
263
252
|
visited.push(subsetItem);
|
|
264
253
|
isItemInSuperset = superset.some((supersetItem) => {
|
|
@@ -269,7 +258,6 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
269
258
|
}
|
|
270
259
|
});
|
|
271
260
|
break;
|
|
272
|
-
}
|
|
273
261
|
default: isItemInSuperset = superset.includes(subsetItem);
|
|
274
262
|
}
|
|
275
263
|
if (!isItemInSuperset) return false;
|
|
@@ -281,21 +269,18 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
281
269
|
if (Object.keys(subset).length > Object.keys(superset).length) return false;
|
|
282
270
|
for (const [subsetKey, subsetValue] of Object.entries(subset)) {
|
|
283
271
|
const supersetValue = superset[subsetKey];
|
|
284
|
-
|
|
285
|
-
switch (subsetValueType) {
|
|
272
|
+
switch (TypeDescriptor.of(subsetValue)) {
|
|
286
273
|
case "array":
|
|
287
274
|
case "object":
|
|
288
|
-
case "function":
|
|
275
|
+
case "function":
|
|
289
276
|
if (visited.includes(subsetValue)) continue;
|
|
290
277
|
visited.push(subsetValue);
|
|
291
278
|
try {
|
|
292
|
-
|
|
293
|
-
if (!isInSuperset) return false;
|
|
279
|
+
if (!isSubsetOf(subsetValue, supersetValue, visited)) return false;
|
|
294
280
|
} catch {
|
|
295
281
|
return false;
|
|
296
282
|
}
|
|
297
283
|
break;
|
|
298
|
-
}
|
|
299
284
|
default: if (subsetValue !== supersetValue) return false;
|
|
300
285
|
}
|
|
301
286
|
}
|
|
@@ -318,8 +303,7 @@ isSubsetOf.structural = function(subset, superset, visited = []) {
|
|
|
318
303
|
if (visited.includes(subsetValue)) continue;
|
|
319
304
|
visited.push(subsetValue);
|
|
320
305
|
try {
|
|
321
|
-
|
|
322
|
-
if (!isInSuperset) return false;
|
|
306
|
+
if (!isSubsetOf.structural(subsetValue, supersetValue, visited)) return false;
|
|
323
307
|
} catch {
|
|
324
308
|
return false;
|
|
325
309
|
}
|
|
@@ -327,7 +311,6 @@ isSubsetOf.structural = function(subset, superset, visited = []) {
|
|
|
327
311
|
}
|
|
328
312
|
return true;
|
|
329
313
|
};
|
|
330
|
-
|
|
331
314
|
//#endregion
|
|
332
315
|
//#region ../../node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.mjs
|
|
333
316
|
var has = Object.prototype.hasOwnProperty;
|
|
@@ -390,11 +373,10 @@ function dequal(foo, bar) {
|
|
|
390
373
|
}
|
|
391
374
|
return foo !== foo && bar !== bar;
|
|
392
375
|
}
|
|
393
|
-
|
|
394
376
|
//#endregion
|
|
395
377
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/RequestUtils.js
|
|
396
|
-
const absoluteUrlRX = new RegExp("^[a-z]+://|^data:", "i");
|
|
397
|
-
const protocolRelativeUrlRX = new RegExp("^//", "i");
|
|
378
|
+
const absoluteUrlRX = /* @__PURE__ */ new RegExp("^[a-z]+://|^data:", "i");
|
|
379
|
+
const protocolRelativeUrlRX = /* @__PURE__ */ new RegExp("^//", "i");
|
|
398
380
|
function hasCredentialsInUrl(url) {
|
|
399
381
|
const urlObject = new URL(url, !absoluteUrlRX.test(url) ? "http://dummy" : void 0);
|
|
400
382
|
return Boolean(urlObject.username || urlObject.password);
|
|
@@ -442,7 +424,7 @@ async function createCallLogFromRequest(request, options) {
|
|
|
442
424
|
} catch {}
|
|
443
425
|
if (request.headers) derivedOptions.headers = normalizeHeaders(request.headers);
|
|
444
426
|
const url = normalizeUrl(request.url, true);
|
|
445
|
-
|
|
427
|
+
return {
|
|
446
428
|
args: [request, options],
|
|
447
429
|
url,
|
|
448
430
|
queryParams: new URLSearchParams(getQuery(url)),
|
|
@@ -451,11 +433,9 @@ async function createCallLogFromRequest(request, options) {
|
|
|
451
433
|
signal: options && options.signal || request.signal,
|
|
452
434
|
pendingPromises
|
|
453
435
|
};
|
|
454
|
-
return callLog;
|
|
455
436
|
}
|
|
456
437
|
function getPath(url) {
|
|
457
|
-
|
|
458
|
-
return u.pathname;
|
|
438
|
+
return (absoluteUrlRX.test(url) ? new URL(url) : new URL(url, "http://dummy")).pathname;
|
|
459
439
|
}
|
|
460
440
|
function getHost(url) {
|
|
461
441
|
if (absoluteUrlRX.test(url)) return new URL(url).host;
|
|
@@ -473,10 +453,8 @@ function normalizeHeaders(headers) {
|
|
|
473
453
|
else entries = Object.entries(headers);
|
|
474
454
|
return Object.fromEntries(entries.map(([key, val]) => [key.toLowerCase(), String(val).valueOf()]));
|
|
475
455
|
}
|
|
476
|
-
|
|
477
456
|
//#endregion
|
|
478
457
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Matchers.js
|
|
479
|
-
var import_glob_to_regexp = __toESM(require_glob_to_regexp(), 1);
|
|
480
458
|
const isUrlMatcher = (matcher) => matcher instanceof RegExp || typeof matcher === "string" || typeof matcher === "object" && "href" in matcher;
|
|
481
459
|
const isFunctionMatcher = (matcher) => typeof matcher === "function";
|
|
482
460
|
const stringMatchers = {
|
|
@@ -530,8 +508,7 @@ const getMissingHeaderMatcher = ({ missingHeaders: expectedMissingHeaders }) =>
|
|
|
530
508
|
const getMethodMatcher = ({ method: expectedMethod }) => {
|
|
531
509
|
if (!expectedMethod) return;
|
|
532
510
|
return ({ options: { method } = {} }) => {
|
|
533
|
-
|
|
534
|
-
return expectedMethod === actualMethod;
|
|
511
|
+
return expectedMethod === (method ? method.toLowerCase() : "get");
|
|
535
512
|
};
|
|
536
513
|
};
|
|
537
514
|
const getQueryParamsMatcher = ({ query: passedQuery }) => {
|
|
@@ -610,7 +587,7 @@ const getUrlMatcher = (route) => {
|
|
|
610
587
|
}
|
|
611
588
|
if (typeof matcherUrl === "string") {
|
|
612
589
|
for (const shorthand in stringMatchers) if (matcherUrl.indexOf(`${shorthand}:`) === 0) {
|
|
613
|
-
const urlFragment = matcherUrl.replace(
|
|
590
|
+
const urlFragment = matcherUrl.replace(new RegExp(`^${shorthand}:`), "");
|
|
614
591
|
return stringMatchers[shorthand](urlFragment);
|
|
615
592
|
}
|
|
616
593
|
return getFullUrlMatcher(route, matcherUrl, query);
|
|
@@ -621,7 +598,7 @@ const getUrlMatcher = (route) => {
|
|
|
621
598
|
else if (key in stringMatchers) return stringMatchers[key](pattern);
|
|
622
599
|
else throw new Error(`unrecognised url matching pattern: ${key}`);
|
|
623
600
|
});
|
|
624
|
-
return (route
|
|
601
|
+
return (route) => matchers.every((matcher) => matcher(route));
|
|
625
602
|
}
|
|
626
603
|
};
|
|
627
604
|
const builtInMatchers = [
|
|
@@ -659,7 +636,6 @@ const builtInMatchers = [
|
|
|
659
636
|
matcher: getFunctionMatcher
|
|
660
637
|
}
|
|
661
638
|
];
|
|
662
|
-
|
|
663
639
|
//#endregion
|
|
664
640
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/StatusTextMap.js
|
|
665
641
|
const statusTextMap = {
|
|
@@ -726,17 +702,15 @@ const statusTextMap = {
|
|
|
726
702
|
510: "Not Extended",
|
|
727
703
|
511: "Network Authentication Required"
|
|
728
704
|
};
|
|
729
|
-
var StatusTextMap_default = statusTextMap;
|
|
730
|
-
|
|
731
705
|
//#endregion
|
|
732
706
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Route.js
|
|
733
|
-
var __classPrivateFieldSet =
|
|
707
|
+
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
734
708
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
735
709
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
736
710
|
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");
|
|
737
711
|
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
738
712
|
};
|
|
739
|
-
var __classPrivateFieldGet =
|
|
713
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
740
714
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
741
715
|
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");
|
|
742
716
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -797,14 +771,13 @@ var Route = class {
|
|
|
797
771
|
constructResponseOptions(responseInput) {
|
|
798
772
|
const options = responseInput.options || {};
|
|
799
773
|
options.status = sanitizeStatus(responseInput.status);
|
|
800
|
-
options.statusText =
|
|
774
|
+
options.statusText = statusTextMap[options.status];
|
|
801
775
|
options.headers = new this.config.Headers(responseInput.headers);
|
|
802
776
|
return options;
|
|
803
777
|
}
|
|
804
778
|
constructResponseBody(responseInput, responseOptions) {
|
|
805
779
|
let body = responseInput.body;
|
|
806
|
-
|
|
807
|
-
if (!bodyIsBodyInit) if (typeof body === "undefined") body = null;
|
|
780
|
+
if (!isBodyInit(body)) if (typeof body === "undefined") body = null;
|
|
808
781
|
else if (typeof body === "object") {
|
|
809
782
|
body = JSON.stringify(body);
|
|
810
783
|
if (!responseOptions.headers.has("Content-Type")) responseOptions.headers.set("Content-Type", "application/json");
|
|
@@ -823,26 +796,25 @@ var Route = class {
|
|
|
823
796
|
_a.registeredMatchers.push(matcher);
|
|
824
797
|
}
|
|
825
798
|
};
|
|
826
|
-
_a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route_instances = /* @__PURE__ */ new WeakSet(), _Route_validate = function _Route_validate
|
|
799
|
+
_a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route_instances = /* @__PURE__ */ new WeakSet(), _Route_validate = function _Route_validate() {
|
|
827
800
|
if (["matched", "unmatched"].includes(this.config.name)) throw new Error(`fetch-mock: Routes cannot use the reserved name \`${this.config.name}\``);
|
|
828
801
|
if (!("response" in this.config)) throw new Error("fetch-mock: Each route must define a response");
|
|
829
|
-
if (!_a.registeredMatchers.some(({ name
|
|
830
|
-
}, _Route_sanitize = function _Route_sanitize
|
|
802
|
+
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 '*'");
|
|
803
|
+
}, _Route_sanitize = function _Route_sanitize() {
|
|
831
804
|
if (this.config.method) this.config.method = this.config.method.toLowerCase();
|
|
832
|
-
}, _Route_generateMatcher = function _Route_generateMatcher
|
|
833
|
-
const activeMatchers = _a.registeredMatchers.filter(({ name
|
|
805
|
+
}, _Route_generateMatcher = function _Route_generateMatcher() {
|
|
806
|
+
const activeMatchers = _a.registeredMatchers.filter(({ name }) => name in this.config).map(({ matcher, usesBody }) => ({
|
|
834
807
|
matcher: matcher(this.config),
|
|
835
808
|
usesBody
|
|
836
809
|
}));
|
|
837
810
|
this.config.usesBody = activeMatchers.some(({ usesBody }) => usesBody);
|
|
838
811
|
this.matcher = (normalizedRequest) => activeMatchers.every(({ matcher }) => matcher(normalizedRequest));
|
|
839
|
-
}, _Route_limit = function _Route_limit
|
|
812
|
+
}, _Route_limit = function _Route_limit() {
|
|
840
813
|
if (!this.config.repeat) return;
|
|
841
814
|
const originalMatcher = this.matcher;
|
|
842
815
|
let timesLeft = this.config.repeat;
|
|
843
816
|
this.matcher = (callLog) => {
|
|
844
|
-
|
|
845
|
-
if (match) {
|
|
817
|
+
if (timesLeft && originalMatcher(callLog)) {
|
|
846
818
|
timesLeft--;
|
|
847
819
|
return true;
|
|
848
820
|
}
|
|
@@ -850,7 +822,7 @@ _a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route
|
|
|
850
822
|
this.reset = () => {
|
|
851
823
|
timesLeft = this.config.repeat;
|
|
852
824
|
};
|
|
853
|
-
}, _Route_delayResponse = function _Route_delayResponse
|
|
825
|
+
}, _Route_delayResponse = function _Route_delayResponse() {
|
|
854
826
|
if (this.config.delay) {
|
|
855
827
|
const { response } = this.config;
|
|
856
828
|
this.config.response = () => {
|
|
@@ -860,8 +832,6 @@ _a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route
|
|
|
860
832
|
};
|
|
861
833
|
Route.registeredMatchers = [];
|
|
862
834
|
builtInMatchers.forEach(Route.defineMatcher);
|
|
863
|
-
var Route_default = Route;
|
|
864
|
-
|
|
865
835
|
//#endregion
|
|
866
836
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Router.js
|
|
867
837
|
const responseConfigProps = [
|
|
@@ -934,8 +904,7 @@ var Router = class {
|
|
|
934
904
|
});
|
|
935
905
|
}
|
|
936
906
|
if (this.needsToReadBody(request)) options.body = await options.body;
|
|
937
|
-
const
|
|
938
|
-
const route = routesToTry.find((route$1) => route$1.matcher(callLog));
|
|
907
|
+
const route = (this.fallbackRoute ? [...this.routes, this.fallbackRoute] : this.routes).find((route) => route.matcher(callLog));
|
|
939
908
|
if (route) try {
|
|
940
909
|
callLog.route = route;
|
|
941
910
|
const { response, responseOptions, responseInput } = await this.generateResponse(callLog);
|
|
@@ -962,24 +931,24 @@ var Router = class {
|
|
|
962
931
|
return callLog.route.constructResponse(responseConfig);
|
|
963
932
|
}
|
|
964
933
|
createObservableResponse(response, responseConfig, responseInput, responseUrl, pendingPromises) {
|
|
965
|
-
return new Proxy(response, { get: (originalResponse, name
|
|
934
|
+
return new Proxy(response, { get: (originalResponse, name) => {
|
|
966
935
|
if (responseInput.redirectUrl) {
|
|
967
|
-
if (name
|
|
968
|
-
if (name
|
|
936
|
+
if (name === "url") return responseInput.redirectUrl;
|
|
937
|
+
if (name === "redirected") return true;
|
|
969
938
|
} else {
|
|
970
|
-
if (name
|
|
971
|
-
if (name
|
|
939
|
+
if (name === "url") return responseUrl;
|
|
940
|
+
if (name === "redirected") return false;
|
|
972
941
|
}
|
|
973
942
|
if (responseInput.status === 0) {
|
|
974
|
-
if (name
|
|
975
|
-
if (name
|
|
943
|
+
if (name === "status") return 0;
|
|
944
|
+
if (name === "statusText") return "";
|
|
976
945
|
}
|
|
977
|
-
if (typeof response[name
|
|
946
|
+
if (typeof response[name] === "function") return new Proxy(response[name], { apply: (func, thisArg, args) => {
|
|
978
947
|
const result = func.apply(response, args);
|
|
979
948
|
if (result.then) pendingPromises.push(result.catch(() => void 0));
|
|
980
949
|
return result;
|
|
981
950
|
} });
|
|
982
|
-
return originalResponse[name
|
|
951
|
+
return originalResponse[name];
|
|
983
952
|
} });
|
|
984
953
|
}
|
|
985
954
|
addRoute(matcher, response, nameOrOptions) {
|
|
@@ -990,7 +959,7 @@ var Router = class {
|
|
|
990
959
|
else Object.assign(config, matcher);
|
|
991
960
|
if (typeof response !== "undefined") config.response = response;
|
|
992
961
|
if (nameOrOptions) Object.assign(config, typeof nameOrOptions === "string" ? nameToOptions(nameOrOptions) : nameOrOptions);
|
|
993
|
-
const route = new
|
|
962
|
+
const route = new Route({
|
|
994
963
|
...this.config,
|
|
995
964
|
...config
|
|
996
965
|
});
|
|
@@ -1009,7 +978,7 @@ var Router = class {
|
|
|
1009
978
|
}
|
|
1010
979
|
setFallback(response) {
|
|
1011
980
|
if (this.fallbackRoute) console.warn("calling fetchMock.catch() twice - are you sure you want to overwrite the previous fallback response");
|
|
1012
|
-
this.fallbackRoute = new
|
|
981
|
+
this.fallbackRoute = new Route({
|
|
1013
982
|
matcherFunction: () => true,
|
|
1014
983
|
response: response || "ok",
|
|
1015
984
|
...this.config
|
|
@@ -1018,15 +987,15 @@ var Router = class {
|
|
|
1018
987
|
}
|
|
1019
988
|
removeRoutes({ names, includeSticky, includeFallback } = {}) {
|
|
1020
989
|
includeFallback = includeFallback ?? true;
|
|
1021
|
-
this.routes = this.routes.filter(({ config: { sticky, name
|
|
990
|
+
this.routes = this.routes.filter(({ config: { sticky, name } }) => {
|
|
1022
991
|
if (sticky && !includeSticky) return true;
|
|
1023
992
|
if (!names) return false;
|
|
1024
|
-
return !names.includes(name
|
|
993
|
+
return !names.includes(name);
|
|
1025
994
|
});
|
|
1026
995
|
if (includeFallback) delete this.fallbackRoute;
|
|
1027
996
|
}
|
|
1028
997
|
modifyRoute(routeName, options) {
|
|
1029
|
-
const route = this.routes.find(({ config: { name
|
|
998
|
+
const route = this.routes.find(({ config: { name } }) => name === routeName);
|
|
1030
999
|
if (!route) throw new Error(`Cannot call modifyRoute() on route \`${routeName}\`: route of that name not found`);
|
|
1031
1000
|
if (route.config.sticky) throw new Error(`Cannot call modifyRoute() on route \`${routeName}\`: route is sticky and cannot be modified`);
|
|
1032
1001
|
if ("name" in options) throw new Error(`Cannot rename the route \`${routeName}\` as \`${options.name}\`: renaming routes is not supported`);
|
|
@@ -1041,7 +1010,6 @@ var Router = class {
|
|
|
1041
1010
|
route.init(newConfig);
|
|
1042
1011
|
}
|
|
1043
1012
|
};
|
|
1044
|
-
|
|
1045
1013
|
//#endregion
|
|
1046
1014
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/CallHistory.js
|
|
1047
1015
|
const isName = (filter) => typeof filter === "string" && /^[\da-zA-Z-]+$/.test(filter) && !["matched", "unmatched"].includes(filter);
|
|
@@ -1087,12 +1055,12 @@ var CallHistory = class {
|
|
|
1087
1055
|
...filter,
|
|
1088
1056
|
...options || {}
|
|
1089
1057
|
};
|
|
1090
|
-
const { matcher } = new
|
|
1058
|
+
const { matcher } = new Route({
|
|
1091
1059
|
response: "ok",
|
|
1092
1060
|
...options
|
|
1093
1061
|
});
|
|
1094
|
-
calls = calls.filter(({ url, options
|
|
1095
|
-
return matcher(createCallLogFromUrlAndOptions(url, options
|
|
1062
|
+
calls = calls.filter(({ url, options }) => {
|
|
1063
|
+
return matcher(createCallLogFromUrlAndOptions(url, options));
|
|
1096
1064
|
});
|
|
1097
1065
|
return calls;
|
|
1098
1066
|
}
|
|
@@ -1106,7 +1074,7 @@ var CallHistory = class {
|
|
|
1106
1074
|
let routesToCheck = this.router.routes;
|
|
1107
1075
|
if (routeNames) {
|
|
1108
1076
|
routeNames = Array.isArray(routeNames) ? routeNames : [routeNames];
|
|
1109
|
-
routesToCheck = this.router.routes.filter(({ config: { name
|
|
1077
|
+
routesToCheck = this.router.routes.filter(({ config: { name } }) => routeNames.includes(name));
|
|
1110
1078
|
}
|
|
1111
1079
|
return routesToCheck.map((route) => {
|
|
1112
1080
|
const calls = this.callLogs.filter(({ route: routeApplied }) => routeApplied === route);
|
|
@@ -1125,8 +1093,6 @@ var CallHistory = class {
|
|
|
1125
1093
|
}).every((isDone) => isDone);
|
|
1126
1094
|
}
|
|
1127
1095
|
};
|
|
1128
|
-
var CallHistory_default = CallHistory;
|
|
1129
|
-
|
|
1130
1096
|
//#endregion
|
|
1131
1097
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/FetchMock.js
|
|
1132
1098
|
const defaultFetchMockConfig = {
|
|
@@ -1148,7 +1114,9 @@ const defineGreedyShorthand = (shorthandOptions) => {
|
|
|
1148
1114
|
return this.route("*", response, Object.assign(options || {}, shorthandOptions));
|
|
1149
1115
|
};
|
|
1150
1116
|
};
|
|
1151
|
-
|
|
1117
|
+
//#endregion
|
|
1118
|
+
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/index.js
|
|
1119
|
+
var esm_default = new class FetchMock {
|
|
1152
1120
|
constructor(config, router) {
|
|
1153
1121
|
this.sticky = defineShorthand({ sticky: true });
|
|
1154
1122
|
this.once = defineShorthand({ repeat: 1 });
|
|
@@ -1189,7 +1157,7 @@ var FetchMock = class FetchMock {
|
|
|
1189
1157
|
routes: router ? [...router.routes] : [],
|
|
1190
1158
|
fallbackRoute: router ? router.fallbackRoute : null
|
|
1191
1159
|
});
|
|
1192
|
-
this.callHistory = new
|
|
1160
|
+
this.callHistory = new CallHistory(this.config, this.router);
|
|
1193
1161
|
this.fetchHandler = this.fetchHandler.bind(this);
|
|
1194
1162
|
Object.assign(this.fetchHandler, { fetchMock: this });
|
|
1195
1163
|
}
|
|
@@ -1214,7 +1182,7 @@ var FetchMock = class FetchMock {
|
|
|
1214
1182
|
return this;
|
|
1215
1183
|
}
|
|
1216
1184
|
defineMatcher(matcher) {
|
|
1217
|
-
|
|
1185
|
+
Route.defineMatcher(matcher);
|
|
1218
1186
|
}
|
|
1219
1187
|
removeRoutes(options) {
|
|
1220
1188
|
this.router.removeRoutes(options);
|
|
@@ -1246,9 +1214,9 @@ var FetchMock = class FetchMock {
|
|
|
1246
1214
|
this.unmockGlobal();
|
|
1247
1215
|
return this;
|
|
1248
1216
|
}
|
|
1249
|
-
spy(matcher, name
|
|
1217
|
+
spy(matcher, name) {
|
|
1250
1218
|
const boundFetch = this.config.fetch.bind(globalThis);
|
|
1251
|
-
if (matcher) this.route(matcher, ({ args }) => boundFetch(...args), name
|
|
1219
|
+
if (matcher) this.route(matcher, ({ args }) => boundFetch(...args), name);
|
|
1252
1220
|
else this.catch(({ args }) => boundFetch(...args));
|
|
1253
1221
|
return this;
|
|
1254
1222
|
}
|
|
@@ -1256,52 +1224,14 @@ var FetchMock = class FetchMock {
|
|
|
1256
1224
|
this.mockGlobal();
|
|
1257
1225
|
return this.spy();
|
|
1258
1226
|
}
|
|
1259
|
-
};
|
|
1260
|
-
const fetchMock = new FetchMock({ ...defaultFetchMockConfig });
|
|
1261
|
-
var FetchMock_default = fetchMock;
|
|
1262
|
-
|
|
1263
|
-
//#endregion
|
|
1264
|
-
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/index.js
|
|
1265
|
-
var esm_default = FetchMock_default;
|
|
1266
|
-
|
|
1227
|
+
}({ ...defaultFetchMockConfig });
|
|
1267
1228
|
//#endregion
|
|
1268
1229
|
//#region deno.json
|
|
1269
1230
|
var name = "@fedify/webfinger";
|
|
1270
|
-
var version = "2.2.0-dev.
|
|
1271
|
-
var license = "MIT";
|
|
1272
|
-
var exports$1 = { ".": "./src/mod.ts" };
|
|
1273
|
-
var description = "WebFinger client library for Fedify";
|
|
1274
|
-
var author = {
|
|
1275
|
-
"name": "Hong Minhee",
|
|
1276
|
-
"email": "hong@minhee.org",
|
|
1277
|
-
"url": "https://hongminhee.org/"
|
|
1278
|
-
};
|
|
1279
|
-
var imports = {
|
|
1280
|
-
"es-toolkit": "npm:es-toolkit@^1.42.0",
|
|
1281
|
-
"fetch-mock": "npm:fetch-mock@^12.5.4"
|
|
1282
|
-
};
|
|
1283
|
-
var exclude = ["dist", "node_modules"];
|
|
1284
|
-
var publish = { "exclude": ["**/*.test.ts", "tsdown.config.ts"] };
|
|
1285
|
-
var tasks = {
|
|
1286
|
-
"check": "deno fmt --check && deno lint && deno check src/*.ts",
|
|
1287
|
-
"test": "deno test"
|
|
1288
|
-
};
|
|
1289
|
-
var deno_default = {
|
|
1290
|
-
name,
|
|
1291
|
-
version,
|
|
1292
|
-
license,
|
|
1293
|
-
exports: exports$1,
|
|
1294
|
-
description,
|
|
1295
|
-
author,
|
|
1296
|
-
imports,
|
|
1297
|
-
exclude,
|
|
1298
|
-
publish,
|
|
1299
|
-
tasks
|
|
1300
|
-
};
|
|
1301
|
-
|
|
1231
|
+
var version = "2.2.0-dev.622+e54cb037";
|
|
1302
1232
|
//#endregion
|
|
1303
1233
|
//#region src/lookup.ts
|
|
1304
|
-
const logger = (0,
|
|
1234
|
+
const logger = (0, _logtape_logtape.getLogger)([
|
|
1305
1235
|
"fedify",
|
|
1306
1236
|
"webfinger",
|
|
1307
1237
|
"lookup"
|
|
@@ -1315,10 +1245,8 @@ const DEFAULT_MAX_REDIRECTION = 5;
|
|
|
1315
1245
|
* @since 0.2.0
|
|
1316
1246
|
*/
|
|
1317
1247
|
async function lookupWebFinger(resource, options = {}) {
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
return await tracer.startActiveSpan("webfinger.lookup", {
|
|
1321
|
-
kind: __opentelemetry_api.SpanKind.CLIENT,
|
|
1248
|
+
return await (options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()).getTracer(name, version).startActiveSpan("webfinger.lookup", {
|
|
1249
|
+
kind: _opentelemetry_api.SpanKind.CLIENT,
|
|
1322
1250
|
attributes: {
|
|
1323
1251
|
"webfinger.resource": resource.toString(),
|
|
1324
1252
|
"webfinger.resource.scheme": typeof resource === "string" ? resource.replace(/:.*$/, "") : resource.protocol.replace(/:$/, "")
|
|
@@ -1326,11 +1254,11 @@ async function lookupWebFinger(resource, options = {}) {
|
|
|
1326
1254
|
}, async (span) => {
|
|
1327
1255
|
try {
|
|
1328
1256
|
const result = await lookupWebFingerInternal(resource, options);
|
|
1329
|
-
span.setStatus({ code: result === null ?
|
|
1257
|
+
span.setStatus({ code: result === null ? _opentelemetry_api.SpanStatusCode.ERROR : _opentelemetry_api.SpanStatusCode.OK });
|
|
1330
1258
|
return result;
|
|
1331
1259
|
} catch (error) {
|
|
1332
1260
|
span.setStatus({
|
|
1333
|
-
code:
|
|
1261
|
+
code: _opentelemetry_api.SpanStatusCode.ERROR,
|
|
1334
1262
|
message: String(error)
|
|
1335
1263
|
});
|
|
1336
1264
|
throw error;
|
|
@@ -1359,9 +1287,9 @@ async function lookupWebFingerInternal(resource, options = {}) {
|
|
|
1359
1287
|
logger.debug("Fetching WebFinger resource descriptor from {url}...", { url: url.href });
|
|
1360
1288
|
let response;
|
|
1361
1289
|
if (options.allowPrivateAddress !== true) try {
|
|
1362
|
-
await (0,
|
|
1290
|
+
await (0, _fedify_vocab_runtime.validatePublicUrl)(url.href);
|
|
1363
1291
|
} catch (e) {
|
|
1364
|
-
if (e instanceof
|
|
1292
|
+
if (e instanceof _fedify_vocab_runtime.UrlError) {
|
|
1365
1293
|
logger.error("Invalid URL for WebFinger resource descriptor: {error}", { error: e });
|
|
1366
1294
|
return null;
|
|
1367
1295
|
}
|
|
@@ -1371,7 +1299,7 @@ async function lookupWebFingerInternal(resource, options = {}) {
|
|
|
1371
1299
|
response = await fetch(url, {
|
|
1372
1300
|
headers: {
|
|
1373
1301
|
Accept: "application/jrd+json",
|
|
1374
|
-
"User-Agent": typeof options.userAgent === "string" ? options.userAgent : (0,
|
|
1302
|
+
"User-Agent": typeof options.userAgent === "string" ? options.userAgent : (0, _fedify_vocab_runtime.getUserAgent)(options.userAgent)
|
|
1375
1303
|
},
|
|
1376
1304
|
redirect: "manual",
|
|
1377
1305
|
signal: options.signal
|
|
@@ -1420,10 +1348,9 @@ async function lookupWebFingerInternal(resource, options = {}) {
|
|
|
1420
1348
|
}
|
|
1421
1349
|
}
|
|
1422
1350
|
}
|
|
1423
|
-
|
|
1424
1351
|
//#endregion
|
|
1425
1352
|
//#region src/lookup.test.ts
|
|
1426
|
-
(0,
|
|
1353
|
+
(0, _fedify_fixture.test)({
|
|
1427
1354
|
name: "lookupWebFinger()",
|
|
1428
1355
|
sanitizeOps: false,
|
|
1429
1356
|
sanitizeResources: false,
|
|
@@ -1502,8 +1429,7 @@ async function lookupWebFingerInternal(resource, options = {}) {
|
|
|
1502
1429
|
headers: { Location: "/.well-known/webfinger" }
|
|
1503
1430
|
});
|
|
1504
1431
|
await t.step("infinite redirection", async () => {
|
|
1505
|
-
|
|
1506
|
-
(0, node_assert_strict.deepStrictEqual)(result, null);
|
|
1432
|
+
(0, node_assert_strict.deepStrictEqual)(await (0, es_toolkit.withTimeout)(() => lookupWebFinger("acct:johndoe@example.com"), 2e3), null);
|
|
1507
1433
|
});
|
|
1508
1434
|
esm_default.removeRoutes();
|
|
1509
1435
|
esm_default.get("begin:https://example.com/.well-known/webfinger?", {
|
|
@@ -1583,18 +1509,14 @@ async function lookupWebFingerInternal(resource, options = {}) {
|
|
|
1583
1509
|
await t.step("cancellation with immediate abort", async () => {
|
|
1584
1510
|
const controller = new AbortController();
|
|
1585
1511
|
controller.abort();
|
|
1586
|
-
|
|
1587
|
-
(0, node_assert_strict.deepStrictEqual)(result, null);
|
|
1512
|
+
(0, node_assert_strict.deepStrictEqual)(await lookupWebFinger("acct:johndoe@example.com", { signal: controller.signal }), null);
|
|
1588
1513
|
});
|
|
1589
1514
|
esm_default.removeRoutes();
|
|
1590
1515
|
esm_default.get("begin:https://example.com/.well-known/webfinger?", { body: expected });
|
|
1591
1516
|
await t.step("successful request with signal", async () => {
|
|
1592
|
-
|
|
1593
|
-
const result = await lookupWebFinger("acct:johndoe@example.com", { signal: controller.signal });
|
|
1594
|
-
(0, node_assert_strict.deepStrictEqual)(result, expected);
|
|
1517
|
+
(0, node_assert_strict.deepStrictEqual)(await lookupWebFinger("acct:johndoe@example.com", { signal: new AbortController().signal }), expected);
|
|
1595
1518
|
});
|
|
1596
1519
|
esm_default.hardReset();
|
|
1597
1520
|
}
|
|
1598
1521
|
});
|
|
1599
|
-
|
|
1600
|
-
//#endregion
|
|
1522
|
+
//#endregion
|