@fedify/fedify 1.6.1-dev.851 → 1.6.1-dev.856

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.
Files changed (74) hide show
  1. package/dist/_virtual/rolldown_runtime.js +26 -1
  2. package/dist/codegen/schema.js +5 -4
  3. package/dist/deno.js +15 -2
  4. package/dist/federation/middleware.test.js +62 -53
  5. package/dist/federation/send.test.js +8 -10
  6. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/constants.js +1 -7
  7. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/dirname.js +1 -1
  8. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/normalize.js +1 -1
  9. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/dirname.js +1 -32
  10. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/join.js +1 -32
  11. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/mod.js +0 -2
  12. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/_util.js +1 -1
  13. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/dirname.js +2 -2
  14. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/normalize.js +2 -2
  15. package/dist/node_modules/.pnpm/@jsr_std__url@1.0.0-rc.3/node_modules/@jsr/std__url/dirname.js +1 -1
  16. package/dist/node_modules/.pnpm/@jsr_std__url@1.0.0-rc.3/node_modules/@jsr/std__url/join.js +1 -1
  17. package/dist/node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.js +68 -0
  18. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/CallHistory.js +94 -0
  19. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/FetchMock.js +143 -0
  20. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/IsSubsetOf.js +103 -0
  21. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Matchers.js +195 -0
  22. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/RequestUtils.js +83 -0
  23. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Route.js +137 -0
  24. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Router.js +181 -0
  25. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/StatusTextMap.js +73 -0
  26. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/TypeDescriptor.js +97 -0
  27. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/index.js +11 -0
  28. package/dist/node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js +87 -0
  29. package/dist/node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.js +37 -0
  30. package/dist/runtime/authdocloader.test.js +5 -5
  31. package/dist/runtime/docloader.js +1 -1
  32. package/dist/runtime/docloader.test.js +8 -0
  33. package/dist/sig/key.js +7 -2
  34. package/dist/testing/docloader.js +34 -15
  35. package/dist/testing/fixtures/example.com/{hong-gildong → hong-gildong.json} +1 -1
  36. package/dist/testing/fixtures/example.com/{object → object.json} +1 -1
  37. package/dist/testing/fixtures/example.com/person.js +29 -0
  38. package/dist/testing/fixtures/example.com/person2.js +48 -0
  39. package/dist/testing/fixtures/example.com/{test → test.json} +1 -1
  40. package/dist/testing/fixtures/w3id.org/security/data-integrity/{v1 → v1.json} +1 -1
  41. package/dist/testing/fixtures/w3id.org/security/{v1 → v1.json} +9 -9
  42. package/dist/testing/mod.d.ts +11 -0
  43. package/dist/testing/mod.js +44 -38
  44. package/dist/vocab/lookup.test.js +30 -35
  45. package/dist/vocab/vocab.js +176 -176
  46. package/dist/vocab/vocab.test.js +2 -2
  47. package/package.json +8 -3
  48. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/_util.js +0 -19
  49. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/dirname.js +0 -75
  50. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/join.js +0 -54
  51. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/normalize.js +0 -87
  52. /package/dist/testing/fixtures/activitypub.academy/users/{brauca_darradiul → brauca_darradiul.json} +0 -0
  53. /package/dist/testing/fixtures/example.com/{announce → announce.json} +0 -0
  54. /package/dist/testing/fixtures/example.com/{collection → collection.json} +0 -0
  55. /package/dist/testing/fixtures/example.com/{create → create.json} +0 -0
  56. /package/dist/testing/fixtures/example.com/{cross-origin-actor → cross-origin-actor.json} +0 -0
  57. /package/dist/testing/fixtures/example.com/{invite → invite.json} +0 -0
  58. /package/dist/testing/fixtures/example.com/{key → key.json} +0 -0
  59. /package/dist/testing/fixtures/example.com/{key2 → key2.json} +0 -0
  60. /package/dist/testing/fixtures/example.com/{orderedcollectionpage → orderedcollectionpage.json} +0 -0
  61. /package/dist/testing/fixtures/example.com/paged/{a → a.json} +0 -0
  62. /package/dist/testing/fixtures/example.com/paged/{b → b.json} +0 -0
  63. /package/dist/testing/fixtures/example.com/{paged-collection → paged-collection.json} +0 -0
  64. /package/dist/testing/fixtures/example.com/{person → person.json} +0 -0
  65. /package/dist/testing/fixtures/example.com/{person2 → person2.json} +0 -0
  66. /package/dist/testing/fixtures/example.com/users/{handle → handle.json} +0 -0
  67. /package/dist/testing/fixtures/example.com/{wrong-type → wrong-type.json} +0 -0
  68. /package/dist/testing/fixtures/remote.domain/users/{bob → bob.json} +0 -0
  69. /package/dist/testing/fixtures/server.example/users/{alice → alice.json} +0 -0
  70. /package/dist/testing/fixtures/w3id.org/identity/{v1 → v1.json} +0 -0
  71. /package/dist/testing/fixtures/w3id.org/security/multikey/{v1 → v1.json} +0 -0
  72. /package/dist/testing/fixtures/wizard.casa/users/{hongminhee → hongminhee.json} +0 -0
  73. /package/dist/testing/fixtures/www.w3.org/ns/{activitystreams → activitystreams.json} +0 -0
  74. /package/dist/testing/fixtures/www.w3.org/ns/did/{v1 → v1.json} +0 -0
@@ -0,0 +1,137 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import { builtInMatchers } from "./Matchers.js";
6
+ import { StatusTextMap_default } from "./StatusTextMap.js";
7
+
8
+ //#region node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Route.js
9
+ var __classPrivateFieldSet = void 0 && (void 0).__classPrivateFieldSet || function(receiver, state, value, kind, f) {
10
+ if (kind === "m") throw new TypeError("Private method is not writable");
11
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
12
+ 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");
13
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
14
+ };
15
+ var __classPrivateFieldGet = void 0 && (void 0).__classPrivateFieldGet || function(receiver, state, kind, f) {
16
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
17
+ 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");
18
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
19
+ };
20
+ var _Route_instances, _a, _Route_responseSubscriptions, _Route_validate, _Route_sanitize, _Route_generateMatcher, _Route_limit, _Route_delayResponse;
21
+ function isBodyInit(body) {
22
+ return body instanceof Blob || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || body instanceof DataView || body instanceof FormData || body instanceof ReadableStream || body instanceof URLSearchParams || body instanceof String || typeof body === "string" || body === null;
23
+ }
24
+ function sanitizeStatus(status) {
25
+ if (status === 0) return 200;
26
+ if (!status) return 200;
27
+ if (typeof status === "number" && parseInt(String(status), 10) !== status && status >= 200 || status < 600) return status;
28
+ throw new TypeError(`fetch-mock: Invalid status ${status} passed on response object.
29
+ To respond with a JSON object that has status as a property assign the object to body
30
+ e.g. {"body": {"status: "registered"}}`);
31
+ }
32
+ var Route = class {
33
+ constructor(config) {
34
+ _Route_instances.add(this);
35
+ _Route_responseSubscriptions.set(this, void 0);
36
+ this.init(config);
37
+ }
38
+ init(config) {
39
+ this.config = config;
40
+ __classPrivateFieldSet(this, _Route_responseSubscriptions, [], "f");
41
+ __classPrivateFieldGet(this, _Route_instances, "m", _Route_sanitize).call(this);
42
+ __classPrivateFieldGet(this, _Route_instances, "m", _Route_validate).call(this);
43
+ __classPrivateFieldGet(this, _Route_instances, "m", _Route_generateMatcher).call(this);
44
+ __classPrivateFieldGet(this, _Route_instances, "m", _Route_limit).call(this);
45
+ __classPrivateFieldGet(this, _Route_instances, "m", _Route_delayResponse).call(this);
46
+ }
47
+ reset() {}
48
+ waitFor(awaitedRoutes) {
49
+ const { response } = this.config;
50
+ this.config.response = Promise.all(awaitedRoutes.map((awaitedRoute) => new Promise((res) => awaitedRoute.onRespond(() => {
51
+ res(void 0);
52
+ })))).then(() => response);
53
+ }
54
+ onRespond(func) {
55
+ __classPrivateFieldGet(this, _Route_responseSubscriptions, "f").push(func);
56
+ }
57
+ constructResponse(responseInput) {
58
+ const responseOptions = this.constructResponseOptions(responseInput);
59
+ const body = this.constructResponseBody(responseInput, responseOptions);
60
+ const responsePackage = {
61
+ response: new this.config.Response(body, responseOptions),
62
+ responseOptions,
63
+ responseInput
64
+ };
65
+ __classPrivateFieldGet(this, _Route_responseSubscriptions, "f").forEach((func) => func());
66
+ return responsePackage;
67
+ }
68
+ constructResponseOptions(responseInput) {
69
+ const options = responseInput.options || {};
70
+ options.status = sanitizeStatus(responseInput.status);
71
+ options.statusText = StatusTextMap_default[options.status];
72
+ options.headers = new this.config.Headers(responseInput.headers);
73
+ return options;
74
+ }
75
+ constructResponseBody(responseInput, responseOptions) {
76
+ let body = responseInput.body;
77
+ const bodyIsBodyInit = isBodyInit(body);
78
+ if (!bodyIsBodyInit) if (typeof body === "undefined") body = null;
79
+ else if (typeof body === "object") {
80
+ body = JSON.stringify(body);
81
+ if (!responseOptions.headers.has("Content-Type")) responseOptions.headers.set("Content-Type", "application/json");
82
+ } else throw new TypeError("Invalid body provided to construct response");
83
+ if (this.config.includeContentLength && !responseOptions.headers.has("Content-Length") && !(body instanceof ReadableStream) && !(body instanceof FormData)) {
84
+ let length = 0;
85
+ if (body instanceof Blob) length = body.size;
86
+ else if (body instanceof ArrayBuffer || ArrayBuffer.isView(body) || body instanceof DataView) length = body.byteLength;
87
+ else if (body instanceof URLSearchParams) length = body.toString().length;
88
+ else if (typeof body === "string" || body instanceof String) length = body.length;
89
+ responseOptions.headers.set("Content-Length", length.toString());
90
+ }
91
+ return body;
92
+ }
93
+ static defineMatcher(matcher) {
94
+ _a.registeredMatchers.push(matcher);
95
+ }
96
+ };
97
+ _a = Route, _Route_responseSubscriptions = new WeakMap(), _Route_instances = new WeakSet(), _Route_validate = function _Route_validate$1() {
98
+ if (["matched", "unmatched"].includes(this.config.name)) throw new Error(`fetch-mock: Routes cannot use the reserved name \`${this.config.name}\``);
99
+ if (!("response" in this.config)) throw new Error("fetch-mock: Each route must define a response");
100
+ 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 '*'");
101
+ }, _Route_sanitize = function _Route_sanitize$1() {
102
+ if (this.config.method) this.config.method = this.config.method.toLowerCase();
103
+ }, _Route_generateMatcher = function _Route_generateMatcher$1() {
104
+ const activeMatchers = _a.registeredMatchers.filter(({ name }) => name in this.config).map(({ matcher, usesBody }) => ({
105
+ matcher: matcher(this.config),
106
+ usesBody
107
+ }));
108
+ this.config.usesBody = activeMatchers.some(({ usesBody }) => usesBody);
109
+ this.matcher = (normalizedRequest) => activeMatchers.every(({ matcher }) => matcher(normalizedRequest));
110
+ }, _Route_limit = function _Route_limit$1() {
111
+ if (!this.config.repeat) return;
112
+ const originalMatcher = this.matcher;
113
+ let timesLeft = this.config.repeat;
114
+ this.matcher = (callLog) => {
115
+ const match = timesLeft && originalMatcher(callLog);
116
+ if (match) {
117
+ timesLeft--;
118
+ return true;
119
+ }
120
+ };
121
+ this.reset = () => {
122
+ timesLeft = this.config.repeat;
123
+ };
124
+ }, _Route_delayResponse = function _Route_delayResponse$1() {
125
+ if (this.config.delay) {
126
+ const { response } = this.config;
127
+ this.config.response = () => {
128
+ return new Promise((res) => setTimeout(() => res(response), this.config.delay));
129
+ };
130
+ }
131
+ };
132
+ Route.registeredMatchers = [];
133
+ builtInMatchers.forEach(Route.defineMatcher);
134
+ var Route_default = Route;
135
+
136
+ //#endregion
137
+ export { Route_default };
@@ -0,0 +1,181 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import { hasCredentialsInUrl } from "./RequestUtils.js";
6
+ import { isFunctionMatcher, isUrlMatcher } from "./Matchers.js";
7
+ import { Route_default } from "./Route.js";
8
+
9
+ //#region node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Router.js
10
+ const responseConfigProps = [
11
+ "body",
12
+ "headers",
13
+ "throws",
14
+ "status",
15
+ "redirectUrl"
16
+ ];
17
+ function nameToOptions(options) {
18
+ return typeof options === "string" ? { name: options } : options;
19
+ }
20
+ function isPromise(response) {
21
+ return typeof response.then === "function";
22
+ }
23
+ function normalizeResponseInput(responseInput) {
24
+ if (typeof responseInput === "number") return { status: responseInput };
25
+ else if (typeof responseInput === "string" || shouldSendAsObject(responseInput)) return { body: responseInput };
26
+ return responseInput;
27
+ }
28
+ function shouldSendAsObject(responseInput) {
29
+ if (responseConfigProps.some((prop) => prop in responseInput)) {
30
+ if (Object.keys(responseInput).every((key) => responseConfigProps.includes(key))) return false;
31
+ return true;
32
+ }
33
+ return true;
34
+ }
35
+ function throwSpecExceptions({ url, options: { headers, method, body } }) {
36
+ if (headers) Object.entries(headers).forEach(([key]) => {
37
+ if (/\s/.test(key)) throw new TypeError("Invalid name");
38
+ });
39
+ if (hasCredentialsInUrl(url)) throw new TypeError(`Request cannot be constructed from a URL that includes credentials: ${url}`);
40
+ if (["get", "head"].includes(method) && body) throw new TypeError("Request with GET/HEAD method cannot have body.");
41
+ }
42
+ const resolveUntilResponseConfig = async (callLog) => {
43
+ let response = callLog.route.config.response;
44
+ while (true) if (typeof response === "function") response = response(callLog);
45
+ else if (isPromise(response)) response = await response;
46
+ else return response;
47
+ };
48
+ var Router = class {
49
+ constructor(fetchMockConfig, { routes, fallbackRoute } = {}) {
50
+ this.config = fetchMockConfig;
51
+ this.routes = routes || [];
52
+ this.fallbackRoute = fallbackRoute;
53
+ }
54
+ needsToReadBody(request) {
55
+ return Boolean(request && this.routes.some((route) => route.config.usesBody));
56
+ }
57
+ execute(callLog) {
58
+ throwSpecExceptions(callLog);
59
+ return new Promise(async (resolve, reject) => {
60
+ const { url, options, request, pendingPromises } = callLog;
61
+ if (callLog.signal) {
62
+ const abort = () => {
63
+ const error = new DOMException("The operation was aborted.", "AbortError");
64
+ const requestBody = request?.body || options?.body;
65
+ if (requestBody instanceof ReadableStream) if (requestBody.locked) requestBody.getReader().cancel(error);
66
+ else requestBody.cancel(error);
67
+ if (callLog?.response?.body) if (callLog.response.body.locked) callLog.response.body.getReader().cancel(error);
68
+ else callLog.response.body.cancel(error);
69
+ reject(error);
70
+ };
71
+ if (callLog.signal.aborted) abort();
72
+ callLog.signal.addEventListener("abort", abort);
73
+ }
74
+ if (this.needsToReadBody(request)) options.body = await options.body;
75
+ const routesToTry = this.fallbackRoute ? [...this.routes, this.fallbackRoute] : this.routes;
76
+ const route = routesToTry.find((route$1) => route$1.matcher(callLog));
77
+ if (route) try {
78
+ callLog.route = route;
79
+ const { response, responseOptions, responseInput } = await this.generateResponse(callLog);
80
+ const observableResponse = this.createObservableResponse(response, responseOptions, responseInput, url, pendingPromises);
81
+ callLog.response = response;
82
+ resolve(observableResponse);
83
+ } catch (err) {
84
+ reject(err);
85
+ }
86
+ else reject(new Error(`fetch-mock: No response or fallback rule to cover ${options && options.method || "GET"} to ${url}`));
87
+ });
88
+ }
89
+ async generateResponse(callLog) {
90
+ const responseInput = await resolveUntilResponseConfig(callLog);
91
+ if (responseInput instanceof Response) return {
92
+ response: responseInput.clone(),
93
+ responseOptions: {},
94
+ responseInput: {}
95
+ };
96
+ const responseConfig = normalizeResponseInput(responseInput);
97
+ if (responseConfig.throws) throw responseConfig.throws;
98
+ return callLog.route.constructResponse(responseConfig);
99
+ }
100
+ createObservableResponse(response, responseConfig, responseInput, responseUrl, pendingPromises) {
101
+ return new Proxy(response, { get: (originalResponse, name) => {
102
+ if (responseInput.redirectUrl) {
103
+ if (name === "url") return responseInput.redirectUrl;
104
+ if (name === "redirected") return true;
105
+ } else {
106
+ if (name === "url") return responseUrl;
107
+ if (name === "redirected") return false;
108
+ }
109
+ if (responseInput.status === 0) {
110
+ if (name === "status") return 0;
111
+ if (name === "statusText") return "";
112
+ }
113
+ if (typeof response[name] === "function") return new Proxy(response[name], { apply: (func, thisArg, args) => {
114
+ const result = func.apply(response, args);
115
+ if (result.then) pendingPromises.push(result.catch(() => void 0));
116
+ return result;
117
+ } });
118
+ return originalResponse[name];
119
+ } });
120
+ }
121
+ addRoute(matcher, response, nameOrOptions) {
122
+ const config = {};
123
+ if (isUrlMatcher(matcher)) config.url = matcher;
124
+ else if (isFunctionMatcher(matcher)) config.matcherFunction = matcher;
125
+ else Object.assign(config, matcher);
126
+ if (typeof response !== "undefined") config.response = response;
127
+ if (nameOrOptions) Object.assign(config, typeof nameOrOptions === "string" ? nameToOptions(nameOrOptions) : nameOrOptions);
128
+ const route = new Route_default({
129
+ ...this.config,
130
+ ...config
131
+ });
132
+ if (route.config.name && this.routes.some(({ config: { name: existingName } }) => route.config.name === existingName)) throw new Error("fetch-mock: Adding route with same name as existing route.");
133
+ if (route.config.waitFor) {
134
+ const routeNamesToWaitFor = Array.isArray(route.config.waitFor) ? route.config.waitFor : [route.config.waitFor];
135
+ const routesToAwait = [];
136
+ routeNamesToWaitFor.forEach((routeName) => {
137
+ const routeToAwait = this.routes.find(({ config: { name: existingName } }) => routeName === existingName);
138
+ if (routeToAwait) routesToAwait.push(routeToAwait);
139
+ else throw new Error(`Cannot wait for route \`${routeName}\`: route of that name does not exist`);
140
+ });
141
+ route.waitFor(routesToAwait);
142
+ }
143
+ this.routes.push(route);
144
+ }
145
+ setFallback(response) {
146
+ if (this.fallbackRoute) console.warn("calling fetchMock.catch() twice - are you sure you want to overwrite the previous fallback response");
147
+ this.fallbackRoute = new Route_default({
148
+ matcherFunction: () => true,
149
+ response: response || "ok",
150
+ ...this.config
151
+ });
152
+ this.fallbackRoute.config.isFallback = true;
153
+ }
154
+ removeRoutes({ names, includeSticky, includeFallback } = {}) {
155
+ includeFallback = includeFallback ?? true;
156
+ this.routes = this.routes.filter(({ config: { sticky, name } }) => {
157
+ if (sticky && !includeSticky) return true;
158
+ if (!names) return false;
159
+ return !names.includes(name);
160
+ });
161
+ if (includeFallback) delete this.fallbackRoute;
162
+ }
163
+ modifyRoute(routeName, options) {
164
+ const route = this.routes.find(({ config: { name } }) => name === routeName);
165
+ if (!route) throw new Error(`Cannot call modifyRoute() on route \`${routeName}\`: route of that name not found`);
166
+ if (route.config.sticky) throw new Error(`Cannot call modifyRoute() on route \`${routeName}\`: route is sticky and cannot be modified`);
167
+ if ("name" in options) throw new Error(`Cannot rename the route \`${routeName}\` as \`${options.name}\`: renaming routes is not supported`);
168
+ if ("sticky" in options) throw new Error(`Altering the stickiness of route \`${routeName}\` is not supported`);
169
+ const newConfig = {
170
+ ...route.config,
171
+ ...options
172
+ };
173
+ Object.entries(options).forEach(([key, value]) => {
174
+ if (value === null) delete newConfig[key];
175
+ });
176
+ route.init(newConfig);
177
+ }
178
+ };
179
+
180
+ //#endregion
181
+ export { Router as Router$2 };
@@ -0,0 +1,73 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ //#region node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/StatusTextMap.js
6
+ const statusTextMap = {
7
+ 100: "Continue",
8
+ 101: "Switching Protocols",
9
+ 102: "Processing",
10
+ 200: "OK",
11
+ 201: "Created",
12
+ 202: "Accepted",
13
+ 203: "Non-Authoritative Information",
14
+ 204: "No Content",
15
+ 205: "Reset Content",
16
+ 206: "Partial Content",
17
+ 207: "Multi-Status",
18
+ 208: "Already Reported",
19
+ 226: "IM Used",
20
+ 300: "Multiple Choices",
21
+ 301: "Moved Permanently",
22
+ 302: "Found",
23
+ 303: "See Other",
24
+ 304: "Not Modified",
25
+ 305: "Use Proxy",
26
+ 307: "Temporary Redirect",
27
+ 308: "Permanent Redirect",
28
+ 400: "Bad Request",
29
+ 401: "Unauthorized",
30
+ 402: "Payment Required",
31
+ 403: "Forbidden",
32
+ 404: "Not Found",
33
+ 405: "Method Not Allowed",
34
+ 406: "Not Acceptable",
35
+ 407: "Proxy Authentication Required",
36
+ 408: "Request Timeout",
37
+ 409: "Conflict",
38
+ 410: "Gone",
39
+ 411: "Length Required",
40
+ 412: "Precondition Failed",
41
+ 413: "Payload Too Large",
42
+ 414: "URI Too Long",
43
+ 415: "Unsupported Media Type",
44
+ 416: "Range Not Satisfiable",
45
+ 417: "Expectation Failed",
46
+ 418: "I'm a teapot",
47
+ 421: "Misdirected Request",
48
+ 422: "Unprocessable Entity",
49
+ 423: "Locked",
50
+ 424: "Failed Dependency",
51
+ 425: "Unordered Collection",
52
+ 426: "Upgrade Required",
53
+ 428: "Precondition Required",
54
+ 429: "Too Many Requests",
55
+ 431: "Request Header Fields Too Large",
56
+ 451: "Unavailable For Legal Reasons",
57
+ 500: "Internal Server Error",
58
+ 501: "Not Implemented",
59
+ 502: "Bad Gateway",
60
+ 503: "Service Unavailable",
61
+ 504: "Gateway Timeout",
62
+ 505: "HTTP Version Not Supported",
63
+ 506: "Variant Also Negotiates",
64
+ 507: "Insufficient Storage",
65
+ 508: "Loop Detected",
66
+ 509: "Bandwidth Limit Exceeded",
67
+ 510: "Not Extended",
68
+ 511: "Network Authentication Required"
69
+ };
70
+ var StatusTextMap_default = statusTextMap;
71
+
72
+ //#endregion
73
+ export { StatusTextMap_default };
@@ -0,0 +1,97 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ //#region node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/TypeDescriptor.js
6
+ const valueTypes = new Set([
7
+ "boolean",
8
+ "number",
9
+ "null",
10
+ "string",
11
+ "undefined"
12
+ ]);
13
+ const referenceTypes = new Set([
14
+ "array",
15
+ "function",
16
+ "object",
17
+ "symbol"
18
+ ]);
19
+ const detectableTypes = new Set([
20
+ "boolean",
21
+ "function",
22
+ "number",
23
+ "string",
24
+ "symbol"
25
+ ]);
26
+ const typeConstructors = new Set([
27
+ Boolean,
28
+ Number,
29
+ String
30
+ ]);
31
+ var TypeDescriptor = class TypeDescriptor {
32
+ constructor(value) {
33
+ this.name = TypeDescriptor.of(value);
34
+ this.isValueType = TypeDescriptor.isValueType(value);
35
+ this.isReferenceType = TypeDescriptor.isReferenceType(value);
36
+ this.isArray = TypeDescriptor.isArray(value);
37
+ this.isBoolean = TypeDescriptor.isBoolean(value);
38
+ this.isFunction = TypeDescriptor.isFunction(value);
39
+ this.isNull = TypeDescriptor.isNull(value);
40
+ this.isNumber = TypeDescriptor.isNumber(value);
41
+ this.isObject = TypeDescriptor.isObject(value);
42
+ this.isString = TypeDescriptor.isString(value);
43
+ this.isSymbol = TypeDescriptor.isSymbol(value);
44
+ this.isUndefined = TypeDescriptor.isUndefined(value);
45
+ }
46
+ static of(value) {
47
+ if (value === null) return "null";
48
+ if (value === void 0) return "undefined";
49
+ const detectedType = typeof value;
50
+ if (detectableTypes.has(detectedType)) return detectedType;
51
+ if (detectedType === "object") {
52
+ if (Array.isArray(value)) return "array";
53
+ if (typeConstructors.has(value.constructor)) return value.constructor.name.toLowerCase();
54
+ return detectedType;
55
+ }
56
+ throw new Error("Failed due to an unknown type.");
57
+ }
58
+ static from(value) {
59
+ return new TypeDescriptor(value);
60
+ }
61
+ static isValueType(value) {
62
+ return valueTypes.has(TypeDescriptor.of(value));
63
+ }
64
+ static isReferenceType(value) {
65
+ return referenceTypes.has(TypeDescriptor.of(value));
66
+ }
67
+ static isArray(value) {
68
+ return TypeDescriptor.of(value) === "array";
69
+ }
70
+ static isBoolean(value) {
71
+ return TypeDescriptor.of(value) === "boolean";
72
+ }
73
+ static isFunction(value) {
74
+ return TypeDescriptor.of(value) === "function";
75
+ }
76
+ static isNull(value) {
77
+ return TypeDescriptor.of(value) === "null";
78
+ }
79
+ static isNumber(value) {
80
+ return TypeDescriptor.of(value) === "number";
81
+ }
82
+ static isObject(value) {
83
+ return TypeDescriptor.of(value) === "object";
84
+ }
85
+ static isString(value) {
86
+ return TypeDescriptor.of(value) === "string";
87
+ }
88
+ static isSymbol(value) {
89
+ return TypeDescriptor.of(value) === "symbol";
90
+ }
91
+ static isUndefined(value) {
92
+ return TypeDescriptor.of(value) === "undefined";
93
+ }
94
+ };
95
+
96
+ //#endregion
97
+ export { TypeDescriptor };
@@ -0,0 +1,11 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import { FetchMock, FetchMock_default, defaultFetchMockConfig } from "./FetchMock.js";
6
+
7
+ //#region node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/index.js
8
+ var esm_default = FetchMock_default;
9
+
10
+ //#endregion
11
+ export { esm_default };
@@ -0,0 +1,87 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import { __commonJS } from "../../../../../_virtual/rolldown_runtime.js";
6
+
7
+ //#region node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
8
+ var require_glob_to_regexp = __commonJS({ "node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js"(exports, module) {
9
+ module.exports = function(glob, opts) {
10
+ if (typeof glob !== "string") throw new TypeError("Expected a string");
11
+ var str = String(glob);
12
+ var reStr = "";
13
+ var extended = opts ? !!opts.extended : false;
14
+ var globstar = opts ? !!opts.globstar : false;
15
+ var inGroup = false;
16
+ var flags = opts && typeof opts.flags === "string" ? opts.flags : "";
17
+ var c;
18
+ for (var i = 0, len = str.length; i < len; i++) {
19
+ c = str[i];
20
+ switch (c) {
21
+ case "/":
22
+ case "$":
23
+ case "^":
24
+ case "+":
25
+ case ".":
26
+ case "(":
27
+ case ")":
28
+ case "=":
29
+ case "!":
30
+ case "|":
31
+ reStr += "\\" + c;
32
+ break;
33
+ case "?": if (extended) {
34
+ reStr += ".";
35
+ break;
36
+ }
37
+ case "[":
38
+ case "]": if (extended) {
39
+ reStr += c;
40
+ break;
41
+ }
42
+ case "{": if (extended) {
43
+ inGroup = true;
44
+ reStr += "(";
45
+ break;
46
+ }
47
+ case "}": if (extended) {
48
+ inGroup = false;
49
+ reStr += ")";
50
+ break;
51
+ }
52
+ case ",":
53
+ if (inGroup) {
54
+ reStr += "|";
55
+ break;
56
+ }
57
+ reStr += "\\" + c;
58
+ break;
59
+ case "*":
60
+ var prevChar = str[i - 1];
61
+ var starCount = 1;
62
+ while (str[i + 1] === "*") {
63
+ starCount++;
64
+ i++;
65
+ }
66
+ var nextChar = str[i + 1];
67
+ if (!globstar) reStr += ".*";
68
+ else {
69
+ var isGlobstar = starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0);
70
+ if (isGlobstar) {
71
+ reStr += "((?:[^/]*(?:/|$))*)";
72
+ i++;
73
+ } else reStr += "([^/]*)";
74
+ }
75
+ break;
76
+ default: reStr += c;
77
+ }
78
+ }
79
+ if (!flags || !~flags.indexOf("g")) reStr = "^" + reStr + "$";
80
+ return new RegExp(reStr, flags);
81
+ };
82
+ } });
83
+
84
+ //#endregion
85
+ export default require_glob_to_regexp();
86
+
87
+ export { require_glob_to_regexp };
@@ -0,0 +1,37 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ //#region node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.mjs
6
+ /**
7
+ * @param {string|RegExp} input The route pattern
8
+ * @param {boolean} [loose] Allow open-ended matching. Ignored with `RegExp` input.
9
+ */
10
+ function parse(input, loose) {
11
+ if (input instanceof RegExp) return {
12
+ keys: false,
13
+ pattern: input
14
+ };
15
+ var c, o, tmp, ext, keys = [], pattern = "", arr = input.split("/");
16
+ arr[0] || arr.shift();
17
+ while (tmp = arr.shift()) {
18
+ c = tmp[0];
19
+ if (c === "*") {
20
+ keys.push(c);
21
+ pattern += tmp[1] === "?" ? "(?:/(.*))?" : "/(.*)";
22
+ } else if (c === ":") {
23
+ o = tmp.indexOf("?", 1);
24
+ ext = tmp.indexOf(".", 1);
25
+ keys.push(tmp.substring(1, !!~o ? o : !!~ext ? ext : tmp.length));
26
+ pattern += !!~o && !~ext ? "(?:/([^/]+?))?" : "/([^/]+?)";
27
+ if (!!~ext) pattern += (!!~o ? "?" : "") + "\\" + tmp.substring(ext);
28
+ } else pattern += "/" + tmp;
29
+ }
30
+ return {
31
+ keys,
32
+ pattern: new RegExp("^" + pattern + (loose ? "(?=$|/)" : "/?$"), "i")
33
+ };
34
+ }
35
+
36
+ //#endregion
37
+ export { parse as parse$1 };
@@ -10,13 +10,13 @@ import { test } from "../testing/mod.js";
10
10
  import { assertRejects } from "../node_modules/.pnpm/@jsr_std__assert@0.226.0/node_modules/@jsr/std__assert/assert_rejects.js";
11
11
  import { mockDocumentLoader } from "../testing/docloader.js";
12
12
  import { rsaPrivateKey2 } from "../testing/keys.js";
13
- import { install, mock, uninstall } from "../node_modules/.pnpm/@jsr_hongminhee__deno-mock-fetch@0.3.2/node_modules/@jsr/hongminhee__deno-mock-fetch/mod.js";
13
+ import { esm_default } from "../node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/index.js";
14
14
 
15
15
  //#region runtime/authdocloader.test.ts
16
16
  test("getAuthenticatedDocumentLoader()", async (t) => {
17
- install();
18
- mock("GET@/object", async (req) => {
19
- const v = await verifyRequest(req, {
17
+ esm_default.spyGlobal();
18
+ esm_default.get("begin:https://example.com/object", async (cl) => {
19
+ const v = await verifyRequest(cl.request, {
20
20
  documentLoader: mockDocumentLoader,
21
21
  contextLoader: mockDocumentLoader,
22
22
  currentTime: Temporal.Now.instant()
@@ -34,7 +34,7 @@ test("getAuthenticatedDocumentLoader()", async (t) => {
34
34
  document: true
35
35
  });
36
36
  });
37
- uninstall();
37
+ esm_default.hardReset();
38
38
  await t.step("deny non-HTTP/HTTPS", async () => {
39
39
  const loader = await getAuthenticatedDocumentLoader({
40
40
  keyId: new URL("https://example.com/key2"),
@@ -279,7 +279,7 @@ function kvCache({ loader, kv, prefix, rules }) {
279
279
  */
280
280
  function getUserAgent({ software, url } = {}) {
281
281
  const fedify = `Fedify/${deno_default.version}`;
282
- const runtime = globalThis.Deno?.version?.deno != null ? `Deno/${Deno.version.deno}` : globalThis.process?.versions?.bun != null ? `Bun/${process.versions.bun}` : globalThis.process?.versions?.node != null ? `Node.js/${process.versions.node}` : null;
282
+ const runtime = globalThis.Deno?.version?.deno != null ? `Deno/${Deno.version.deno}` : globalThis.process?.versions?.bun != null ? `Bun/${process.versions.bun}` : "navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers" ? navigator.userAgent : globalThis.process?.versions?.node != null ? `Node.js/${process.versions.node}` : null;
283
283
  const userAgent = software == null ? [fedify] : [software, fedify];
284
284
  if (runtime != null) userAgent.push(runtime);
285
285
  if (url != null) userAgent.push(`+${url.toString()}`);
@@ -414,6 +414,14 @@ test("getUserAgent()", () => {
414
414
  software: "MyApp/1.0.0",
415
415
  url: new URL("https://example.com/")
416
416
  }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Bun/${Bun.version}; +https://example.com/)`);
417
+ } else if (navigator.userAgent === "Cloudflare-Workers") {
418
+ assertEquals(getUserAgent(), `Fedify/${deno_default.version} (Cloudflare-Workers)`);
419
+ assertEquals(getUserAgent({ software: "MyApp/1.0.0" }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Cloudflare-Workers)`);
420
+ assertEquals(getUserAgent({ url: "https://example.com/" }), `Fedify/${deno_default.version} (Cloudflare-Workers; +https://example.com/)`);
421
+ assertEquals(getUserAgent({
422
+ software: "MyApp/1.0.0",
423
+ url: new URL("https://example.com/")
424
+ }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Cloudflare-Workers; +https://example.com/)`);
417
425
  } else {
418
426
  assertEquals(getUserAgent(), `Fedify/${deno_default.version} (Node.js/${process.versions.node})`);
419
427
  assertEquals(getUserAgent({ software: "MyApp/1.0.0" }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Node.js/${process.versions.node})`);