@fedify/fedify 2.2.13 → 2.2.14

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 (67) hide show
  1. package/dist/{builder-uTlVksLw.mjs → builder-ky-Enw7B.mjs} +2 -2
  2. package/dist/{client-CQ7zd8tW.mjs → client-CJ4Y0keQ.mjs} +7 -3
  3. package/dist/compat/transformers.test.mjs +1 -1
  4. package/dist/{deno-Cg_cZHcI.mjs → deno-BnfWZfzD.mjs} +1 -1
  5. package/dist/docloader-Ctm-HtB1.mjs +79 -0
  6. package/dist/federation/builder.test.mjs +2 -2
  7. package/dist/federation/collection.test.mjs +1 -1
  8. package/dist/federation/handler.test.mjs +6 -6
  9. package/dist/federation/idempotency.test.mjs +3 -3
  10. package/dist/federation/kv.test.mjs +1 -1
  11. package/dist/federation/middleware.test.mjs +134 -7
  12. package/dist/federation/mod.cjs +1 -1
  13. package/dist/federation/mod.js +1 -1
  14. package/dist/federation/mq.test.mjs +98 -43
  15. package/dist/federation/negotiation.test.mjs +1 -1
  16. package/dist/federation/router.test.mjs +1 -1
  17. package/dist/federation/send.test.mjs +68 -5
  18. package/dist/federation/temporal.test.mjs +2 -2
  19. package/dist/federation/webfinger.test.mjs +2 -2
  20. package/dist/{http-DaLdtguq.js → http-BBGyG2ez.js} +6 -2
  21. package/dist/{http-BdbKIiay.cjs → http-DXyLMSXp.cjs} +6 -2
  22. package/dist/{http-B3V9unT4.mjs → http-xscrPdwI.mjs} +7 -3
  23. package/dist/{key-CLRfRmA_.mjs → key-DwyWxSP6.mjs} +1 -1
  24. package/dist/{kv-cache-K6eHO_YH.cjs → kv-cache-BATy5Vhq.cjs} +34 -8
  25. package/dist/{kv-cache-TPuR5wYg.js → kv-cache-D_17I8jy.js} +35 -9
  26. package/dist/{ld-C0s4f-GU.mjs → ld-CQLGYzwy.mjs} +3 -3
  27. package/dist/{middleware-BDc7xyOx.cjs → middleware-BbomR2ro.cjs} +14 -5
  28. package/dist/{middleware-BDRZkGPG.js → middleware-CdgK6YM3.js} +13 -4
  29. package/dist/{middleware-D6bGiZn6.cjs → middleware-DRzTRfmd.cjs} +1 -1
  30. package/dist/{middleware-BsDiZP9H.mjs → middleware-Dv-j_sRD.mjs} +11 -11
  31. package/dist/{middleware-uaOjlLEG.mjs → middleware-kjzamfZM.mjs} +1 -1
  32. package/dist/{mod-DzPMtIV3.d.cts → mod-BYg1qMPB.d.cts} +2 -0
  33. package/dist/{mod-0MWo2Nu5.d.ts → mod-C9jqpInC.d.ts} +2 -0
  34. package/dist/mod.cjs +5 -5
  35. package/dist/mod.d.cts +1 -1
  36. package/dist/mod.d.ts +1 -1
  37. package/dist/mod.js +5 -5
  38. package/dist/nodeinfo/client.test.mjs +50 -2
  39. package/dist/nodeinfo/handler.test.mjs +2 -2
  40. package/dist/nodeinfo/mod.cjs +1 -1
  41. package/dist/nodeinfo/mod.js +1 -1
  42. package/dist/nodeinfo/types.test.mjs +1 -1
  43. package/dist/otel/exporter.test.mjs +1 -1
  44. package/dist/{owner-DLbN_4jZ.mjs → owner-pFTUYlVh.mjs} +2 -2
  45. package/dist/{proof-CqyprEYB.js → proof-BCHw9az4.js} +2 -2
  46. package/dist/{proof-CTIG9UEI.cjs → proof-BLZMJa2g.cjs} +2 -2
  47. package/dist/{proof-CW3Zrxmd.mjs → proof-CJxlMyX3.mjs} +2 -2
  48. package/dist/{send-B5QvdrZ1.mjs → send-C_Pfo7Lr.mjs} +12 -3
  49. package/dist/sig/http.test.mjs +43 -3
  50. package/dist/sig/key.test.mjs +2 -2
  51. package/dist/sig/ld.test.mjs +5 -2
  52. package/dist/sig/mod.cjs +2 -2
  53. package/dist/sig/mod.js +2 -2
  54. package/dist/sig/owner.test.mjs +2 -2
  55. package/dist/sig/proof.test.mjs +2 -2
  56. package/dist/{std__assert-CRDpx_HF.mjs → std__assert-BVFj8-_V.mjs} +1 -26
  57. package/dist/{temporal-CFLRXAcm.mjs → temporal-DA4sccOr.mjs} +1 -1
  58. package/dist/{types-DWs-qZaY.cjs → types-DRPjmHVV.cjs} +7 -3
  59. package/dist/{types-sXITXcWa.js → types-miAYfiGO.js} +7 -3
  60. package/dist/utils/docloader.test.mjs +299 -3
  61. package/dist/utils/mod.cjs +1 -1
  62. package/dist/utils/mod.d.cts +1 -1
  63. package/dist/utils/mod.d.ts +1 -1
  64. package/dist/utils/mod.js +1 -1
  65. package/dist/vocab/cjs.test.mjs +1 -1
  66. package/package.json +6 -6
  67. package/dist/docloader-BwXP5fDH.mjs +0 -53
@@ -3,13 +3,16 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as esm_default } from "../esm-DVILvP5e.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
- import "../std__assert-CRDpx_HF.mjs";
6
+ import "../std__assert-BVFj8-_V.mjs";
7
7
  import { t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
8
- import { l as verifyRequest } from "../http-B3V9unT4.mjs";
8
+ import { l as verifyRequest } from "../http-xscrPdwI.mjs";
9
9
  import { i as rsaPrivateKey2 } from "../keys-BAK-tUlf.mjs";
10
- import { t as getAuthenticatedDocumentLoader } from "../docloader-BwXP5fDH.mjs";
10
+ import { t as getAuthenticatedDocumentLoader } from "../docloader-Ctm-HtB1.mjs";
11
11
  import { mockDocumentLoader, test } from "@fedify/fixture";
12
12
  import { FetchError, UrlError } from "@fedify/vocab-runtime";
13
+ import { configure, reset } from "@logtape/logtape";
14
+ import dns from "node:dns/promises";
15
+ import { deepStrictEqual, ok, rejects } from "node:assert/strict";
13
16
  //#region src/utils/docloader.test.ts
14
17
  test("getAuthenticatedDocumentLoader()", async (t) => {
15
18
  esm_default.spyGlobal();
@@ -160,5 +163,298 @@ test("getAuthenticatedDocumentLoader() bounds JSON after redirects", async () =>
160
163
  esm_default.hardReset();
161
164
  }
162
165
  });
166
+ test("getAuthenticatedDocumentLoader() logs DNS failures as such", { ignore: "Deno" in globalThis && (await Deno.permissions.query({ name: "net" })).state !== "granted" }, async (t) => {
167
+ const loader = getAuthenticatedDocumentLoader({
168
+ keyId: new URL("https://example.com/key2"),
169
+ privateKey: rsaPrivateKey2
170
+ });
171
+ for (const result of [
172
+ "throws",
173
+ "empty",
174
+ "private"
175
+ ]) await t.step(result, async () => {
176
+ const originalLookup = dns.lookup;
177
+ dns.lookup = (() => result === "throws" ? Promise.reject(/* @__PURE__ */ new Error("Resolver unavailable")) : Promise.resolve(result === "empty" ? [] : [{
178
+ address: "127.0.0.1",
179
+ family: 4
180
+ }]));
181
+ const records = [];
182
+ await configure({
183
+ sinks: { buffer: (record) => records.push(record) },
184
+ loggers: [{
185
+ category: "fedify",
186
+ sinks: ["buffer"],
187
+ lowestLevel: "debug"
188
+ }, {
189
+ category: ["logtape", "meta"],
190
+ sinks: []
191
+ }],
192
+ reset: true
193
+ });
194
+ try {
195
+ const url = "https://dns-failure.invalid/object";
196
+ const error = await assertRejects(() => loader(url), UrlError);
197
+ assertEquals(error.reason, result === "private" ? "disallowed" : "dns");
198
+ assertEquals(records.map((r) => [
199
+ r.level,
200
+ r.rawMessage,
201
+ r.properties.url
202
+ ]), [result === "private" ? [
203
+ "error",
204
+ "Disallowed private URL: {url}",
205
+ url
206
+ ] : [
207
+ "debug",
208
+ "DNS lookup failed for {url}",
209
+ url
210
+ ]]);
211
+ assertEquals(records[0].properties.error, error);
212
+ } finally {
213
+ await reset();
214
+ dns.lookup = originalLookup;
215
+ }
216
+ });
217
+ });
218
+ test("getAuthenticatedDocumentLoader() bounds alternate document chains", async (t) => {
219
+ const base = "https://example.com/alternate-chain/";
220
+ const loader = getAuthenticatedDocumentLoader({
221
+ keyId: new URL("https://example.com/key2"),
222
+ privateKey: rsaPrivateKey2
223
+ }, { allowPrivateAddress: true });
224
+ for (const mode of [
225
+ "header",
226
+ "html",
227
+ "mixed"
228
+ ]) for (const hops of [20, 21]) await t.step(`${mode}: ${hops} hops`, async () => {
229
+ esm_default.mockGlobal();
230
+ let requests = 0;
231
+ esm_default.get(`begin:${base}`, ({ url }) => {
232
+ requests++;
233
+ const index = Number(new URL(url).pathname.split("/").at(-1));
234
+ if (index === hops || requests > 30) return Response.json({ done: true });
235
+ const next = `${base}${index + 1}`;
236
+ if (mode === "mixed" && index % 2 === 1) return Response.redirect(next, 302);
237
+ return alternate(next, mode === "html");
238
+ });
239
+ try {
240
+ if (hops === 20) deepStrictEqual((await loader(`${base}0`)).document, { done: true });
241
+ else await rejects(loader(`${base}0`), (error) => {
242
+ ok(error instanceof FetchError);
243
+ ok(error.message.includes("Too many redirections (21)"));
244
+ return true;
245
+ });
246
+ deepStrictEqual(requests, 21);
247
+ } finally {
248
+ esm_default.hardReset();
249
+ }
250
+ });
251
+ for (const mode of [
252
+ "header",
253
+ "html",
254
+ "alternate-redirect",
255
+ "redirect-alternate",
256
+ "redirect-intermediate"
257
+ ]) await t.step(`${mode}: cycle`, async () => {
258
+ esm_default.mockGlobal();
259
+ let requests = 0;
260
+ esm_default.get(`begin:${base}`, ({ url }) => {
261
+ requests++;
262
+ if (requests > 30) return Response.json({ stopped: true });
263
+ const index = Number(new URL(url).pathname.split("/").at(-1));
264
+ const next = `${base}${mode === "redirect-intermediate" ? index === 0 ? 1 : index === 1 ? 2 : 1 : 1 - index}`;
265
+ if (mode === "alternate-redirect" && index === 1 || (mode === "redirect-alternate" || mode === "redirect-intermediate") && index === 0) return Response.redirect(next, 302);
266
+ return alternate(next, mode === "html");
267
+ });
268
+ try {
269
+ await rejects(loader(`${base}0`), (error) => {
270
+ ok(error instanceof FetchError);
271
+ ok(error.message.includes("Redirect loop detected:"));
272
+ return true;
273
+ });
274
+ deepStrictEqual(requests, mode === "redirect-intermediate" ? 3 : 2);
275
+ } finally {
276
+ esm_default.hardReset();
277
+ }
278
+ });
279
+ await t.step("alternate followed by 20 redirects shares the limit", async () => {
280
+ esm_default.mockGlobal();
281
+ let requests = 0;
282
+ esm_default.get(`begin:${base}`, ({ url }) => {
283
+ requests++;
284
+ const index = Number(new URL(url).pathname.split("/").at(-1));
285
+ if (index === 21) return Response.json({ done: true });
286
+ return index === 0 ? alternate(`${base}1`, false) : Response.redirect(`${base}${index + 1}`, 302);
287
+ });
288
+ try {
289
+ await rejects(loader(`${base}0`), (error) => {
290
+ ok(error instanceof FetchError);
291
+ ok(error.message.includes("Too many redirections (21)"));
292
+ return true;
293
+ });
294
+ deepStrictEqual(requests, 21);
295
+ } finally {
296
+ esm_default.hardReset();
297
+ }
298
+ });
299
+ await t.step("relative alternate after redirect and isolated calls", async () => {
300
+ esm_default.mockGlobal();
301
+ esm_default.get(`${base}start`, Response.redirect(`${base}html`, 302));
302
+ esm_default.get(`${base}html`, alternate("./document", true));
303
+ esm_default.get(`${base}document`, Response.json({ done: true }));
304
+ try {
305
+ for (let i = 0; i < 2; i++) {
306
+ const results = await Promise.all([loader(`${base}start`), loader(`${base}start`)]);
307
+ for (const result of results) {
308
+ deepStrictEqual(result.document, { done: true });
309
+ deepStrictEqual(result.documentUrl, `${base}document`);
310
+ }
311
+ }
312
+ } finally {
313
+ esm_default.hardReset();
314
+ }
315
+ });
316
+ function alternate(next, html) {
317
+ return html ? new Response(`<link rel="alternate" type="application/activity+json" href="${next}">`, { headers: { "Content-Type": "text/html" } }) : new Response("not JSON", { headers: {
318
+ "Content-Type": "text/plain",
319
+ Link: `<${next}>; rel="alternate"; type="application/activity+json"`
320
+ } });
321
+ }
322
+ });
323
+ test("getAuthenticatedDocumentLoader() preserves cancellation across alternates", async (t) => {
324
+ const base = "https://example.com/alternate-abort/";
325
+ const loader = getAuthenticatedDocumentLoader({
326
+ keyId: new URL("https://example.com/key2"),
327
+ privateKey: rsaPrivateKey2
328
+ }, { allowPrivateAddress: true });
329
+ for (const html of [false, true]) await t.step(html ? "HTML" : "Link header", async () => {
330
+ esm_default.mockGlobal();
331
+ const controller = new AbortController();
332
+ const reason = /* @__PURE__ */ new Error("Alternate document loading cancelled");
333
+ let requests = 0;
334
+ esm_default.get(`begin:${base}`, ({ url }) => {
335
+ requests++;
336
+ const index = Number(new URL(url).pathname.split("/").at(-1));
337
+ if (index === 2) return Response.json({ done: true });
338
+ if (index === 1) controller.abort(reason);
339
+ const next = `${base}${index + 1}`;
340
+ return new Response(html ? `<link rel="alternate" type="application/activity+json" href="${next}">` : "not JSON", { headers: html ? { "Content-Type": "text/html" } : {
341
+ "Content-Type": "text/plain",
342
+ Link: `<${next}>; rel="alternate"; type="application/activity+json"`
343
+ } });
344
+ });
345
+ try {
346
+ await rejects(loader(`${base}0`, { signal: controller.signal }), (error) => {
347
+ ok(error === reason);
348
+ return true;
349
+ });
350
+ deepStrictEqual(requests, 2);
351
+ } finally {
352
+ esm_default.hardReset();
353
+ }
354
+ });
355
+ });
356
+ test("getAuthenticatedDocumentLoader() tracks fallback redirects after alternates", async () => {
357
+ esm_default.mockGlobal();
358
+ let requests = 0;
359
+ let knocks = 0;
360
+ const first = "https://example.com/fallback-alternate/a";
361
+ const second = "https://example.com/fallback-alternate/b";
362
+ esm_default.get(first, () => {
363
+ requests++;
364
+ if (requests > 30) return Response.json({ stopped: true });
365
+ return new Response("", { headers: {
366
+ "Content-Type": "text/plain",
367
+ Link: `<${second}>; rel="alternate"; type="application/activity+json"`
368
+ } });
369
+ });
370
+ esm_default.get(second, () => {
371
+ requests++;
372
+ return ++knocks % 2 === 1 ? new Response("", { status: 401 }) : Response.redirect(first, 302);
373
+ });
374
+ try {
375
+ const loader = getAuthenticatedDocumentLoader({
376
+ keyId: new URL("https://example.com/key2"),
377
+ privateKey: rsaPrivateKey2
378
+ }, { allowPrivateAddress: true });
379
+ await assertRejects(() => loader(first), FetchError, "Redirect loop detected:");
380
+ assertEquals(requests, 3);
381
+ } finally {
382
+ esm_default.hardReset();
383
+ }
384
+ });
385
+ test("getAuthenticatedDocumentLoader() resolves relative alternates without response URLs", async () => {
386
+ const originalFetch = globalThis.fetch;
387
+ const base = "https://example.com/empty-response-url/";
388
+ const urls = [];
389
+ globalThis.fetch = (input) => {
390
+ const url = input instanceof Request ? input.url : String(input);
391
+ urls.push(url);
392
+ if (url === `${base}start`) return Promise.resolve(Response.redirect(`${base}nested/page`, 302));
393
+ if (url === `${base}nested/page`) return Promise.resolve(new Response("<link rel=\"alternate\" type=\"application/activity+json\" href=\"document\">", { headers: { "Content-Type": "text/html" } }));
394
+ assertEquals(url, `${base}nested/document`);
395
+ return Promise.resolve(Response.json({ done: true }));
396
+ };
397
+ try {
398
+ assertEquals(await getAuthenticatedDocumentLoader({
399
+ keyId: new URL("https://example.com/key2"),
400
+ privateKey: rsaPrivateKey2
401
+ }, { allowPrivateAddress: true })(`${base}start`), {
402
+ contextUrl: null,
403
+ document: { done: true },
404
+ documentUrl: `${base}nested/document`
405
+ });
406
+ assertEquals(urls, [
407
+ `${base}start`,
408
+ `${base}nested/page`,
409
+ `${base}nested/document`
410
+ ]);
411
+ } finally {
412
+ globalThis.fetch = originalFetch;
413
+ }
414
+ });
415
+ test("getAuthenticatedDocumentLoader() validates alternate addresses", async () => {
416
+ esm_default.mockGlobal();
417
+ let privateRequests = 0;
418
+ const url = "https://8.8.8.8/alternate";
419
+ esm_default.get(url, new Response("", { headers: {
420
+ "Content-Type": "text/plain",
421
+ Link: "<http://127.0.0.1/private>; rel=\"alternate\"; type=\"application/activity+json\""
422
+ } }));
423
+ esm_default.get("http://127.0.0.1/private", () => {
424
+ privateRequests++;
425
+ return Response.json({ private: true });
426
+ });
427
+ try {
428
+ const loader = getAuthenticatedDocumentLoader({
429
+ keyId: new URL("https://example.com/key2"),
430
+ privateKey: rsaPrivateKey2
431
+ });
432
+ await assertRejects(() => loader(url), UrlError);
433
+ assertEquals(privateRequests, 0);
434
+ } finally {
435
+ esm_default.hardReset();
436
+ }
437
+ });
438
+ test("getAuthenticatedDocumentLoader() rejects cancellation before fetching", async () => {
439
+ esm_default.mockGlobal();
440
+ let requests = 0;
441
+ const url = "https://example.com/pre-aborted-alternate";
442
+ esm_default.get(url, () => {
443
+ requests++;
444
+ return Response.json({ done: true });
445
+ });
446
+ try {
447
+ const loader = getAuthenticatedDocumentLoader({
448
+ keyId: new URL("https://example.com/key2"),
449
+ privateKey: rsaPrivateKey2
450
+ }, { allowPrivateAddress: true });
451
+ const controller = new AbortController();
452
+ controller.abort();
453
+ await rejects(loader(url, { signal: controller.signal }), { name: "AbortError" });
454
+ deepStrictEqual(requests, 0);
455
+ } finally {
456
+ esm_default.hardReset();
457
+ }
458
+ });
163
459
  //#endregion
164
460
  export {};
@@ -1,6 +1,6 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const require_kv_cache = require("../kv-cache-K6eHO_YH.cjs");
4
+ const require_kv_cache = require("../kv-cache-BATy5Vhq.cjs");
5
5
  exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
6
6
  exports.kvCache = require_kv_cache.kvCache;
@@ -1,3 +1,3 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../mod-DzPMtIV3.cjs";
2
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../mod-BYg1qMPB.cjs";
3
3
  export { getAuthenticatedDocumentLoader, kvCache };
@@ -1,3 +1,3 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../mod-0MWo2Nu5.js";
2
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../mod-C9jqpInC.js";
3
3
  export { getAuthenticatedDocumentLoader, kvCache };
package/dist/utils/mod.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-TPuR5wYg.js";
3
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-D_17I8jy.js";
4
4
  export { getAuthenticatedDocumentLoader, kvCache };
@@ -5,7 +5,7 @@ import { createRequire } from "node:module";
5
5
  import { test } from "@fedify/fixture";
6
6
  import { strictEqual } from "node:assert";
7
7
  //#region src/vocab/cjs.test.ts
8
- test("CommonJS vocab entry exports Object", { ignore: "Deno" in globalThis }, () => {
8
+ test("CommonJS vocab entry exports Object", { ignore: "Deno" in globalThis || "navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers" }, () => {
9
9
  const vocab = createRequire(import.meta.url)("./mod.cjs");
10
10
  strictEqual(typeof vocab.Object, "function");
11
11
  strictEqual(typeof vocab.Update, "function");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "2.2.13",
3
+ "version": "2.2.14",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -153,9 +153,9 @@
153
153
  "uri-template-router": "^1.0.0",
154
154
  "url-template": "^3.1.1",
155
155
  "urlpattern-polyfill": "^10.1.0",
156
- "@fedify/vocab": "2.2.13",
157
- "@fedify/webfinger": "2.2.13",
158
- "@fedify/vocab-runtime": "2.2.13"
156
+ "@fedify/vocab": "2.2.14",
157
+ "@fedify/vocab-runtime": "2.2.14",
158
+ "@fedify/webfinger": "2.2.14"
159
159
  },
160
160
  "devDependencies": {
161
161
  "@std/assert": "npm:@jsr/std__assert@^0.226.0",
@@ -168,7 +168,7 @@
168
168
  "typescript": "^6.0.0",
169
169
  "wrangler": "^4.17.0",
170
170
  "@fedify/fixture": "2.0.0",
171
- "@fedify/vocab-tools": "^2.2.13"
171
+ "@fedify/vocab-tools": "^2.2.14"
172
172
  },
173
173
  "scripts": {
174
174
  "build:self": "tsdown",
@@ -178,6 +178,6 @@
178
178
  "test": "cd dist/ && node --test",
179
179
  "pretest:bun": "pnpm build",
180
180
  "test:bun": "cd dist/ && bun test --timeout 60000",
181
- "test:cfworkers": "deno task codegen && wrangler deploy --dry-run --outdir src/cfworkers && node --import=tsx src/cfworkers/client.ts"
181
+ "test:cfworkers": "deno task codegen && wrangler deploy --dry-run --outdir src/cfworkers && node --import=tsx scripts/check_cfworkers.ts && node --import=tsx src/cfworkers/client.ts"
182
182
  }
183
183
  }
@@ -1,53 +0,0 @@
1
- import "@js-temporal/polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { s as validateCryptoKey } from "./key-CLRfRmA_.mjs";
5
- import { n as doubleKnock } from "./http-B3V9unT4.mjs";
6
- import { curry } from "es-toolkit";
7
- import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
8
- import { getLogger } from "@logtape/logtape";
9
- //#region src/utils/docloader.ts
10
- const logger = getLogger([
11
- "fedify",
12
- "utils",
13
- "docloader"
14
- ]);
15
- /**
16
- * Gets an authenticated {@link DocumentLoader} for the given identity.
17
- * Note that an authenticated document loader intentionally does not cache
18
- * the fetched documents.
19
- * @param identity The identity to get the document loader for.
20
- * The actor's key pair.
21
- * @param options The options for the document loader.
22
- * @returns The authenticated document loader.
23
- * @throws {TypeError} If the key is invalid or unsupported.
24
- * @since 0.4.0
25
- */
26
- function getAuthenticatedDocumentLoader(identity, { allowPrivateAddress, maxRedirection, userAgent, specDeterminer, tracerProvider } = {}) {
27
- validateCryptoKey(identity.privateKey);
28
- async function load(url, options) {
29
- await validateUrl(url);
30
- return getRemoteDocument(url, await doubleKnock(createActivityPubRequest(url, { userAgent }), identity, {
31
- maxRedirection,
32
- specDeterminer,
33
- log: curry(logRequest)(logger),
34
- tracerProvider,
35
- signal: options?.signal,
36
- validateRedirect: validateUrl
37
- }), load);
38
- }
39
- async function validateUrl(url) {
40
- if (!allowPrivateAddress) try {
41
- await validatePublicUrl(url);
42
- } catch (error) {
43
- if (error instanceof UrlError) logger.error("Disallowed private URL: {url}", {
44
- url,
45
- error
46
- });
47
- throw error;
48
- }
49
- }
50
- return load;
51
- }
52
- //#endregion
53
- export { getAuthenticatedDocumentLoader as t };