@fedify/fedify 1.8.1-pr.328.1159 → 1.8.1-pr.331.1169
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/README.md +4 -1
- package/dist/{actor-LkF6aqGd.js → actor-CM9DhmYG.js} +179 -179
- package/dist/{actor-BI_2abz3.js → actor-CXiBUxzX.js} +1 -4
- package/dist/{assert_rejects-DceVjUlD.js → assert_rejects-AjlKk-Vo.js} +1 -1
- package/dist/{assert_throws-DTDC_gwN.js → assert_throws-CqMKbTh_.js} +1 -1
- package/dist/{authdocloader-Bn1wpyy1.js → authdocloader-CoK1cNSv.js} +3 -4
- package/dist/{authdocloader-DeF41lCp.js → authdocloader-CxTR6Cx7.js} +3 -3
- package/dist/{builder-ypgCZZ9b.js → builder-D5PVNw-f.js} +4 -5
- package/dist/{client-D_GpybaE.js → client-Deo5HWuU.js} +2 -2
- package/dist/compat/transformers.test.js +20 -27
- package/dist/{docloader-ZcdrjMf8.js → docloader-CoCVFIdd.js} +2 -1
- package/dist/{esm-d-9EVGaP.js → esm-EXQbXMPG.js} +1 -1
- package/dist/federation/builder.test.js +11 -16
- package/dist/federation/collection.test.js +9 -7
- package/dist/federation/handler.test.js +26 -35
- package/dist/federation/inbox.test.js +6 -10
- package/dist/federation/keycache.test.js +4 -7
- package/dist/federation/kv.test.js +8 -6
- package/dist/federation/middleware.test.js +27 -35
- package/dist/federation/mod.js +10 -10
- package/dist/federation/mq.test.js +10 -8
- package/dist/federation/retry.test.js +5 -3
- package/dist/federation/router.test.js +8 -7
- package/dist/federation/send.test.js +15 -21
- package/dist/{http-CzYP-q4a.js → http-BMGJhytW.js} +2 -3
- package/dist/{http-BzbQEWKu.js → http-C2JU_TBj.js} +3 -3
- package/dist/{inbox-C3u7wpp-.js → inbox-BPbz_ao6.js} +1 -3
- package/dist/{key-ctbEcqup.js → key-Cw4UVtxp.js} +2 -3
- package/dist/{key-DpPVsVBo.js → key-DN4BIKz_.js} +4 -4
- package/dist/key-IO1BOpia.js +10 -0
- package/dist/{key-DuMiqGNl.js → key-OtdoFkXm.js} +2 -2
- package/dist/{keycache-B4MVJOqX.js → keycache-VoOwxP0J.js} +1 -1
- package/dist/{keys-8BtWAvD6.js → keys-BLkL01oe.js} +1 -1
- package/dist/{ld-DpsRY9hw.js → ld-DzSYkEZt.js} +2 -4
- package/dist/{lookup-Cl-flyHw.js → lookup-C_W_03GR.js} +1 -1
- package/dist/{lookup-DrKu09YQ.js → lookup-DmCcT32H.js} +113 -6
- package/dist/middleware-BOpaJuMq.js +26 -0
- package/dist/{middleware-Bel3idhw.js → middleware-CpvSNOWP.js} +11 -11
- package/dist/{middleware-_FILA5XM.js → middleware-D5a8IwLT.js} +17 -21
- package/dist/middleware-DsTB1RZr.js +17 -0
- package/dist/mod.js +10 -10
- package/dist/nodeinfo/client.test.js +11 -11
- package/dist/nodeinfo/handler.test.js +25 -34
- package/dist/nodeinfo/mod.js +2 -2
- package/dist/nodeinfo/semver.test.js +9 -7
- package/dist/nodeinfo/types.test.js +10 -8
- package/dist/{owner-MQpfmrEp.js → owner-B7WC4XMm.js} +2 -3
- package/dist/{proof-BmJlaEuD.js → proof-DGvKD7fj.js} +3 -3
- package/dist/{proof-C3Gb_y9R.js → proof-DZgS1afh.js} +2 -4
- package/dist/runtime/authdocloader.test.js +14 -20
- package/dist/runtime/docloader.test.js +9 -10
- package/dist/runtime/key.test.js +10 -15
- package/dist/runtime/langstr.test.js +8 -7
- package/dist/runtime/mod.js +6 -6
- package/dist/runtime/multibase/multibase.test.js +8 -7
- package/dist/runtime/url.test.js +5 -4
- package/dist/{send-B95nXWtF.js → send-KqOpWmPm.js} +2 -2
- package/dist/sig/http.test.js +13 -19
- package/dist/sig/key.test.js +11 -17
- package/dist/sig/ld.test.js +10 -16
- package/dist/sig/mod.js +6 -6
- package/dist/sig/owner.test.js +12 -19
- package/dist/sig/proof.test.js +12 -18
- package/dist/testing/docloader.test.js +8 -7
- package/dist/testing/mod.d.ts +8387 -1
- package/dist/testing/mod.js +4 -2
- package/dist/testing-Ckz8sJMd.js +301 -0
- package/dist/{vocab-BczrO3jQ.js → type-C5cdRbDh.js} +5255 -183
- package/dist/{types-C7C_l-jz.js → types-n7HI7VFr.js} +1 -1
- package/dist/{types-BACpZoAu.js → types-zNofm6uK.js} +1 -1
- package/dist/vocab/actor.test.js +10 -16
- package/dist/vocab/lookup.test.js +9 -16
- package/dist/vocab/mod.js +4 -4
- package/dist/vocab/type.test.js +3 -7
- package/dist/vocab/vocab.test.js +9 -13
- package/dist/{vocab-BFQwOXsO.js → vocab-B-ZpQXwI.js} +3 -3
- package/dist/webfinger/handler.test.js +25 -34
- package/dist/webfinger/lookup.test.js +9 -10
- package/dist/webfinger/mod.js +2 -2
- package/dist/x/cfworkers.test.js +8 -6
- package/package.json +1 -1
- package/dist/chunk-HsBuZ-b2.js +0 -41
- package/dist/context-wTS6NVpw.js +0 -108
- package/dist/docloader-09nVWLAZ.js +0 -68
- package/dist/docloader-4n0wKCuD.js +0 -4526
- package/dist/key-BDYWJlpE.js +0 -16
- package/dist/langstr-DbWheeIS.js +0 -33
- package/dist/lookup-CIZBWILo.js +0 -132
- package/dist/middleware-BoSxCdkz.js +0 -17
- package/dist/middleware-Db3gnzbt.js +0 -33
- package/dist/multibase-DeCHcK8L.js +0 -316
- package/dist/router-D3UybECj.js +0 -118
- package/dist/testing-BZ0dJ4qn.js +0 -143
- package/dist/type-D2s5lmbZ.js +0 -14
- package/dist/url-kTAI6_KP.js +0 -68
- /package/dist/{assert_is_error-DQdKoRgb.js → assert_is_error-CeVBLPsZ.js} +0 -0
- /package/dist/{assert_not_equals-7pyUM3Ib.js → assert_not_equals-D2R2nl5h.js} +0 -0
- /package/dist/{collection-Dfb0TPno.js → collection-D5V3UzU3.js} +0 -0
- /package/dist/{denokv-QWKsIqML.js → denokv-DK9P5Jq7.js} +0 -0
- /package/dist/{retry-BiIhZWgD.js → retry-BnpVRGFC.js} +0 -0
- /package/dist/{semver-DWClQt_5.js → semver-DCqorrj5.js} +0 -0
- /package/dist/{std__assert-B3iAixc-.js → std__assert-BQdmxyzF.js} +0 -0
package/dist/testing/mod.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import "../type-C5cdRbDh.js";
|
|
7
|
+
import "../lookup-DmCcT32H.js";
|
|
8
|
+
import { createInboxContext, createRequestContext, test, testDefinitions } from "../testing-Ckz8sJMd.js";
|
|
7
9
|
|
|
8
|
-
export { test, testDefinitions };
|
|
10
|
+
export { createInboxContext, createRequestContext, test, testDefinitions };
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
globalThis.addEventListener = () => {};
|
|
5
|
+
|
|
6
|
+
import { __require, lookupWebFinger } from "./type-C5cdRbDh.js";
|
|
7
|
+
import { RouterError, lookupObject, traverseCollection } from "./lookup-DmCcT32H.js";
|
|
8
|
+
import { configure, getConsoleSink, getLogger, reset } from "@logtape/logtape";
|
|
9
|
+
import { trace } from "@opentelemetry/api";
|
|
10
|
+
|
|
11
|
+
//#region testing/docloader.ts
|
|
12
|
+
const logger = getLogger([
|
|
13
|
+
"fedify",
|
|
14
|
+
"testing",
|
|
15
|
+
"docloader"
|
|
16
|
+
]);
|
|
17
|
+
/**
|
|
18
|
+
* A mock of the document loader. This does not make any actual HTTP requests
|
|
19
|
+
* towards the remote server, but looks up the local fixture files instead.
|
|
20
|
+
*
|
|
21
|
+
* For instance, `mockDocumentLoader("http://example.com/foo/bar")` will look up
|
|
22
|
+
* the file `testing/fixtures/http/example.com/foo/bar` (no suffix) and return
|
|
23
|
+
* its content as the response.
|
|
24
|
+
*/
|
|
25
|
+
async function mockDocumentLoader(resource) {
|
|
26
|
+
const url = new URL(resource);
|
|
27
|
+
if ("navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers") {
|
|
28
|
+
const testUrl = new URL(url);
|
|
29
|
+
testUrl.hostname += ".test";
|
|
30
|
+
const resp = await fetch(testUrl);
|
|
31
|
+
if (resp.ok) {
|
|
32
|
+
const document$1 = await resp.json();
|
|
33
|
+
logger.debug("Successfully fetched fixture {resource}: {status} {statusText}\n{body}", {
|
|
34
|
+
resource,
|
|
35
|
+
status: resp.status,
|
|
36
|
+
statusText: resp.statusText,
|
|
37
|
+
body: document$1
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
contextUrl: null,
|
|
41
|
+
document: document$1,
|
|
42
|
+
documentUrl: resource
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const error = await resp.text();
|
|
46
|
+
logger.error("Failed to fetch fixture {resource}: {error}", {
|
|
47
|
+
resource,
|
|
48
|
+
error
|
|
49
|
+
});
|
|
50
|
+
throw new Error(error);
|
|
51
|
+
}
|
|
52
|
+
const path = `./fixtures/${url.host}${url.pathname}.json`;
|
|
53
|
+
let document;
|
|
54
|
+
try {
|
|
55
|
+
document = (await import(path, { with: { type: "json" } })).default;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
logger.error("Failed to read fixture file {path}: {error}", {
|
|
58
|
+
path,
|
|
59
|
+
error
|
|
60
|
+
});
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
contextUrl: null,
|
|
65
|
+
document,
|
|
66
|
+
documentUrl: resource
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region testing/context.ts
|
|
72
|
+
function createContext(values) {
|
|
73
|
+
const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, tracerProvider, clone, getNodeInfoUri, getActorUri, getObjectUri, getOutboxUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject: lookupObject$1, traverseCollection: traverseCollection$1, lookupNodeInfo, lookupWebFinger: lookupWebFinger$1, sendActivity, routeActivity } = values;
|
|
74
|
+
function throwRouteError() {
|
|
75
|
+
throw new RouterError("Not implemented");
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
federation,
|
|
79
|
+
data,
|
|
80
|
+
origin: url.origin,
|
|
81
|
+
canonicalOrigin: canonicalOrigin ?? url.origin,
|
|
82
|
+
host: url.host,
|
|
83
|
+
hostname: url.hostname,
|
|
84
|
+
documentLoader: documentLoader ?? mockDocumentLoader,
|
|
85
|
+
contextLoader: contextLoader ?? mockDocumentLoader,
|
|
86
|
+
tracerProvider: tracerProvider ?? trace.getTracerProvider(),
|
|
87
|
+
clone: clone ?? ((data$1) => createContext({
|
|
88
|
+
...values,
|
|
89
|
+
data: data$1
|
|
90
|
+
})),
|
|
91
|
+
getNodeInfoUri: getNodeInfoUri ?? throwRouteError,
|
|
92
|
+
getActorUri: getActorUri ?? throwRouteError,
|
|
93
|
+
getObjectUri: getObjectUri ?? throwRouteError,
|
|
94
|
+
getOutboxUri: getOutboxUri ?? throwRouteError,
|
|
95
|
+
getInboxUri: getInboxUri ?? throwRouteError,
|
|
96
|
+
getFollowingUri: getFollowingUri ?? throwRouteError,
|
|
97
|
+
getFollowersUri: getFollowersUri ?? throwRouteError,
|
|
98
|
+
getLikedUri: getLikedUri ?? throwRouteError,
|
|
99
|
+
getFeaturedUri: getFeaturedUri ?? throwRouteError,
|
|
100
|
+
getFeaturedTagsUri: getFeaturedTagsUri ?? throwRouteError,
|
|
101
|
+
parseUri: parseUri ?? ((_uri) => {
|
|
102
|
+
throw new Error("Not implemented");
|
|
103
|
+
}),
|
|
104
|
+
getDocumentLoader: getDocumentLoader ?? ((_params) => {
|
|
105
|
+
throw new Error("Not implemented");
|
|
106
|
+
}),
|
|
107
|
+
getActorKeyPairs: getActorKeyPairs ?? ((_handle) => Promise.resolve([])),
|
|
108
|
+
lookupObject: lookupObject$1 ?? ((uri, options = {}) => {
|
|
109
|
+
return lookupObject(uri, {
|
|
110
|
+
documentLoader: options.documentLoader ?? documentLoader ?? mockDocumentLoader,
|
|
111
|
+
contextLoader: options.contextLoader ?? contextLoader ?? mockDocumentLoader
|
|
112
|
+
});
|
|
113
|
+
}),
|
|
114
|
+
traverseCollection: traverseCollection$1 ?? ((collection, options = {}) => {
|
|
115
|
+
return traverseCollection(collection, {
|
|
116
|
+
documentLoader: options.documentLoader ?? documentLoader ?? mockDocumentLoader,
|
|
117
|
+
contextLoader: options.contextLoader ?? contextLoader ?? mockDocumentLoader
|
|
118
|
+
});
|
|
119
|
+
}),
|
|
120
|
+
lookupNodeInfo: lookupNodeInfo ?? ((_params) => {
|
|
121
|
+
throw new Error("Not implemented");
|
|
122
|
+
}),
|
|
123
|
+
lookupWebFinger: lookupWebFinger$1 ?? ((resource, options = {}) => {
|
|
124
|
+
return lookupWebFinger(resource, options);
|
|
125
|
+
}),
|
|
126
|
+
sendActivity: sendActivity ?? ((_params) => {
|
|
127
|
+
throw new Error("Not implemented");
|
|
128
|
+
}),
|
|
129
|
+
routeActivity: routeActivity ?? ((_params) => {
|
|
130
|
+
throw new Error("Not implemented");
|
|
131
|
+
})
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function createRequestContext(args) {
|
|
135
|
+
return {
|
|
136
|
+
...createContext(args),
|
|
137
|
+
clone: args.clone ?? ((data) => createRequestContext({
|
|
138
|
+
...args,
|
|
139
|
+
data
|
|
140
|
+
})),
|
|
141
|
+
request: args.request ?? new Request(args.url),
|
|
142
|
+
url: args.url,
|
|
143
|
+
getActor: args.getActor ?? (() => Promise.resolve(null)),
|
|
144
|
+
getObject: args.getObject ?? (() => Promise.resolve(null)),
|
|
145
|
+
getSignedKey: args.getSignedKey ?? (() => Promise.resolve(null)),
|
|
146
|
+
getSignedKeyOwner: args.getSignedKeyOwner ?? (() => Promise.resolve(null)),
|
|
147
|
+
sendActivity: args.sendActivity ?? ((_params) => {
|
|
148
|
+
throw new Error("Not implemented");
|
|
149
|
+
})
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function createInboxContext(args) {
|
|
153
|
+
return {
|
|
154
|
+
...createContext(args),
|
|
155
|
+
clone: args.clone ?? ((data) => createInboxContext({
|
|
156
|
+
...args,
|
|
157
|
+
data
|
|
158
|
+
})),
|
|
159
|
+
recipient: args.recipient ?? null,
|
|
160
|
+
forwardActivity: args.forwardActivity ?? ((_params) => {
|
|
161
|
+
throw new Error("Not implemented");
|
|
162
|
+
})
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region testing/mod.ts
|
|
168
|
+
const testDefinitions = [];
|
|
169
|
+
function test(name, options, fn) {
|
|
170
|
+
const def = typeof name === "string" ? typeof options === "function" ? {
|
|
171
|
+
name,
|
|
172
|
+
fn: options
|
|
173
|
+
} : {
|
|
174
|
+
name,
|
|
175
|
+
...options,
|
|
176
|
+
fn
|
|
177
|
+
} : name;
|
|
178
|
+
testDefinitions.push(def);
|
|
179
|
+
if ("Deno" in globalThis) {
|
|
180
|
+
const func = def.fn;
|
|
181
|
+
Deno.test({
|
|
182
|
+
...def,
|
|
183
|
+
async fn(t) {
|
|
184
|
+
const records = [];
|
|
185
|
+
await configure({
|
|
186
|
+
sinks: {
|
|
187
|
+
buffer(record) {
|
|
188
|
+
if (record.category.length > 1 && record.category[0] === "logtape" && record.category[1] === "meta") return;
|
|
189
|
+
records.push(record);
|
|
190
|
+
},
|
|
191
|
+
console: getConsoleSink()
|
|
192
|
+
},
|
|
193
|
+
filters: {},
|
|
194
|
+
loggers: [{
|
|
195
|
+
category: [],
|
|
196
|
+
sinks: [Deno.env.get("LOG") === "always" ? "console" : "buffer"]
|
|
197
|
+
}]
|
|
198
|
+
});
|
|
199
|
+
try {
|
|
200
|
+
await func(t);
|
|
201
|
+
} catch (e) {
|
|
202
|
+
const consoleSink = getConsoleSink();
|
|
203
|
+
for (const record of records) consoleSink(record);
|
|
204
|
+
throw e;
|
|
205
|
+
} finally {
|
|
206
|
+
await reset();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
} else if ("Bun" in globalThis) {
|
|
211
|
+
let failed = void 0;
|
|
212
|
+
async function step(defOrNameOrFn, fn$2) {
|
|
213
|
+
let def$1;
|
|
214
|
+
if (typeof defOrNameOrFn === "string") def$1 = {
|
|
215
|
+
name: defOrNameOrFn,
|
|
216
|
+
fn: fn$2
|
|
217
|
+
};
|
|
218
|
+
else if (typeof defOrNameOrFn === "function") def$1 = {
|
|
219
|
+
name: defOrNameOrFn.name,
|
|
220
|
+
fn: defOrNameOrFn
|
|
221
|
+
};
|
|
222
|
+
else def$1 = defOrNameOrFn;
|
|
223
|
+
if (def$1.ignore) return true;
|
|
224
|
+
try {
|
|
225
|
+
await def$1.fn({
|
|
226
|
+
name: def$1.name,
|
|
227
|
+
origin: "",
|
|
228
|
+
step
|
|
229
|
+
});
|
|
230
|
+
} catch (e) {
|
|
231
|
+
failed ??= e;
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
const ctx = {
|
|
237
|
+
name: def.name,
|
|
238
|
+
origin: "",
|
|
239
|
+
step
|
|
240
|
+
};
|
|
241
|
+
async function fn$1() {
|
|
242
|
+
await def.fn(ctx);
|
|
243
|
+
if (failed) throw failed;
|
|
244
|
+
}
|
|
245
|
+
const bunTest = Bun.jest(caller()).test;
|
|
246
|
+
if (def.ignore) bunTest.skip(def.name, fn$1);
|
|
247
|
+
else if (def.only) bunTest.only(def.name, fn$1);
|
|
248
|
+
else bunTest(def.name, fn$1);
|
|
249
|
+
} else try {
|
|
250
|
+
const { test: nodeTest } = __require("node:test");
|
|
251
|
+
nodeTest(def.name, {
|
|
252
|
+
only: def.only,
|
|
253
|
+
skip: def.ignore
|
|
254
|
+
}, async (t) => {
|
|
255
|
+
await def.fn(intoDenoTestContext(def.name, t));
|
|
256
|
+
});
|
|
257
|
+
} catch {}
|
|
258
|
+
}
|
|
259
|
+
function intoDenoTestContext(name, ctx) {
|
|
260
|
+
async function step(defOrNameOrFn, fn) {
|
|
261
|
+
let def;
|
|
262
|
+
if (typeof defOrNameOrFn === "string") def = {
|
|
263
|
+
name: defOrNameOrFn,
|
|
264
|
+
fn
|
|
265
|
+
};
|
|
266
|
+
else if (typeof defOrNameOrFn === "function") def = {
|
|
267
|
+
name: defOrNameOrFn.name,
|
|
268
|
+
fn: defOrNameOrFn
|
|
269
|
+
};
|
|
270
|
+
else def = defOrNameOrFn;
|
|
271
|
+
let failed = false;
|
|
272
|
+
await ctx.test(def.name, async (ctx2) => {
|
|
273
|
+
try {
|
|
274
|
+
await def.fn(intoDenoTestContext(def.name, ctx2));
|
|
275
|
+
} catch (e) {
|
|
276
|
+
failed = true;
|
|
277
|
+
throw e;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
return failed;
|
|
281
|
+
}
|
|
282
|
+
const denoCtx = {
|
|
283
|
+
name,
|
|
284
|
+
origin: ctx.filePath ?? "",
|
|
285
|
+
step
|
|
286
|
+
};
|
|
287
|
+
return denoCtx;
|
|
288
|
+
}
|
|
289
|
+
/** Retrieve caller test file. */
|
|
290
|
+
function caller() {
|
|
291
|
+
const Trace = Error;
|
|
292
|
+
const _ = Trace.prepareStackTrace;
|
|
293
|
+
Trace.prepareStackTrace = (_$1, stack$1) => stack$1;
|
|
294
|
+
const { stack } = /* @__PURE__ */ new Error();
|
|
295
|
+
Trace.prepareStackTrace = _;
|
|
296
|
+
const caller$1 = stack[2];
|
|
297
|
+
return caller$1.getFileName().replaceAll("\\", "/");
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
//#endregion
|
|
301
|
+
export { createInboxContext, createRequestContext, mockDocumentLoader, test, testDefinitions };
|