@fedify/fedify 2.0.36-dev.2842 → 2.0.36

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 (72) hide show
  1. package/dist/{builder-CuQLFOSj.mjs → builder-BgN3eUcV.mjs} +3 -3
  2. package/dist/{callback-ySj5p3Ml.d.mts → callback-Bmi_V7Ai.d.mts} +16 -0
  3. package/dist/{client-jE7oGvRh.d.ts → client-9DPcy_Yx.d.ts} +16 -0
  4. package/dist/{client-BIBzqEIp.d.cts → client-B3ruDgWg.d.cts} +16 -0
  5. package/dist/{client-DLAWT9ep.mjs → client-DMnQeMkz.mjs} +86 -11
  6. package/dist/compat/mod.d.cts +1 -1
  7. package/dist/compat/mod.d.ts +1 -1
  8. package/dist/compat/transformers.test.mjs +1 -1
  9. package/dist/{context-DGC1C_UU.d.cts → context-CO7Qh6cG.d.cts} +1 -1
  10. package/dist/{context-CgpkmUFq.d.ts → context-D-oakGjH.d.ts} +1 -1
  11. package/dist/{deno-USvfGHbR.mjs → deno-CqGxhJxg.mjs} +1 -1
  12. package/dist/{docloader-CDITXM6j.mjs → docloader-B4avweRS.mjs} +2 -2
  13. package/dist/federation/attachment-responses.test.mjs +2 -2
  14. package/dist/federation/builder.test.mjs +1 -1
  15. package/dist/federation/delivery-attachments.test.mjs +3 -3
  16. package/dist/federation/handler.test.mjs +6 -6
  17. package/dist/federation/idempotency.test.mjs +2 -2
  18. package/dist/federation/inbox.test.mjs +1 -1
  19. package/dist/federation/middleware.test.mjs +23 -7
  20. package/dist/federation/mod.cjs +1 -1
  21. package/dist/federation/mod.d.cts +2 -2
  22. package/dist/federation/mod.d.ts +2 -2
  23. package/dist/federation/mod.js +1 -1
  24. package/dist/federation/send.test.mjs +3 -3
  25. package/dist/federation/temporal.test.mjs +1 -1
  26. package/dist/federation/webfinger.test.mjs +1 -1
  27. package/dist/{http-BGjEnY4L.mjs → http-BcKYM_M1.mjs} +2 -2
  28. package/dist/{http-ixT5PjBz.js → http-DUO4mfwi.js} +1 -1
  29. package/dist/{http-BAhackOL.cjs → http-Dd2WgYHq.cjs} +1 -1
  30. package/dist/{inbox-BtfUJZS3.mjs → inbox-DzACsAnP.mjs} +1 -1
  31. package/dist/{key-BDisDFGv.mjs → key-CH4J7bu-.mjs} +1 -1
  32. package/dist/{kv-cache-YdAhdrrh.js → kv-cache-BjZVBg__.js} +1 -1
  33. package/dist/{kv-cache-BKEuedCv.cjs → kv-cache-lmBOUjBb.cjs} +1 -1
  34. package/dist/{ld-CjHkfxXf.mjs → ld-nCaXr4W2.mjs} +2 -2
  35. package/dist/{middleware-X7A94J2d.js → middleware-CAGB8LcZ.js} +8 -4
  36. package/dist/{middleware-gr2ldCQw.mjs → middleware-CrVytvP8.mjs} +1 -1
  37. package/dist/{middleware-DkrLbSc2.mjs → middleware-CwLd8bQH.mjs} +16 -12
  38. package/dist/{middleware-HI6aNn_6.cjs → middleware-DcgLe2c1.cjs} +1 -1
  39. package/dist/{middleware-DjXy4YoB.cjs → middleware-EIpnqxbe.cjs} +9 -5
  40. package/dist/{mod-BzKteaAe.d.cts → mod-DUC2Rnne.d.cts} +1 -1
  41. package/dist/{mod-BqnolIm8.d.ts → mod-Dl09kqul.d.ts} +1 -1
  42. package/dist/mod.cjs +5 -5
  43. package/dist/mod.d.cts +3 -3
  44. package/dist/mod.d.ts +3 -3
  45. package/dist/mod.js +5 -5
  46. package/dist/nodeinfo/client.test.mjs +432 -5
  47. package/dist/nodeinfo/handler.test.mjs +1 -1
  48. package/dist/nodeinfo/mod.cjs +1 -1
  49. package/dist/nodeinfo/mod.d.cts +1 -1
  50. package/dist/nodeinfo/mod.d.ts +1 -1
  51. package/dist/nodeinfo/mod.js +1 -1
  52. package/dist/{owner-CyoKKXIR.mjs → owner-RdxrumqL.mjs} +2 -2
  53. package/dist/{proof-BiTmCpLq.js → proof-BQTBsTGc.js} +1 -1
  54. package/dist/{proof-D8S0HFxt.mjs → proof-BbHdti21.mjs} +2 -2
  55. package/dist/{proof-BOemJGRl.cjs → proof-MoO82jAG.cjs} +1 -1
  56. package/dist/{send-speW4h59.mjs → send-CIyuJAVP.mjs} +2 -2
  57. package/dist/sig/http.test.mjs +2 -2
  58. package/dist/sig/key-types.test.d.mts +1 -1
  59. package/dist/sig/key.test.mjs +2 -2
  60. package/dist/sig/ld.test.mjs +2 -2
  61. package/dist/sig/mod.cjs +2 -2
  62. package/dist/sig/mod.js +2 -2
  63. package/dist/sig/owner.test.mjs +1 -1
  64. package/dist/sig/proof.test.mjs +2 -2
  65. package/dist/{temporal-Dlbq-g7z.mjs → temporal-D_RguQEu.mjs} +1 -1
  66. package/dist/testing/mod.d.mts +1 -1
  67. package/dist/{types-DOvyymM4.cjs → types-B5wRhemi.cjs} +85 -10
  68. package/dist/{types-B1_pRFE_.js → types-CXy2lRVU.js} +86 -11
  69. package/dist/utils/docloader.test.mjs +2 -2
  70. package/dist/utils/mod.cjs +1 -1
  71. package/dist/utils/mod.js +1 -1
  72. package/package.json +5 -5
@@ -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-DflMZha5.mjs";
6
+ import { n as assertStrictEquals } from "../std__assert-DflMZha5.mjs";
7
7
  import { n as assertInstanceOf } from "../assert-BhQd8QHP.mjs";
8
- import { a as parseOutboundService, c as parseSoftware, i as parseNodeInfo, l as parseUsage, n as getNodeInfoInternal, o as parseProtocol, r as parseInboundService, s as parseServices, t as getNodeInfo } from "../client-DLAWT9ep.mjs";
8
+ import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
9
+ import { a as parseOutboundService, c as parseSoftware, i as parseNodeInfo, l as parseUsage, n as getNodeInfoInternal, o as parseProtocol, r as parseInboundService, s as parseServices, t as getNodeInfo } from "../client-DMnQeMkz.mjs";
9
10
  import { test } from "@fedify/fixture";
10
11
  import { UrlError } from "@fedify/vocab-runtime";
11
- import { openDirectFetch, openPublicFetch } from "@fedify/vocab-runtime/internal";
12
+ import { detectRuntime, openDirectFetch, openPublicFetch } from "@fedify/vocab-runtime/internal";
12
13
  import { configure, reset } from "@logtape/logtape";
14
+ import dns from "node:dns/promises";
15
+ import { createServer } from "node:http";
13
16
  //#region src/nodeinfo/client.test.ts
14
17
  function getNodeInfoDirect(url, options) {
15
18
  return getNodeInfoInternal(url, options, { openHop: openDirectFetch });
@@ -1049,6 +1052,64 @@ test("getNodeInfo() logs DNS failures as such", async (t) => {
1049
1052
  }
1050
1053
  });
1051
1054
  });
1055
+ test("getNodeInfo() bounds and cancels default Node.js DNS lookups", { ignore: detectRuntime() !== "node" }, async () => {
1056
+ const originalLookup = dns.lookup;
1057
+ const pending = [];
1058
+ const hostnames = [];
1059
+ const twoStarted = deferred();
1060
+ const records = [];
1061
+ dns.lookup = ((hostname) => {
1062
+ hostnames.push(hostname);
1063
+ const lookup = deferred();
1064
+ pending.push(lookup);
1065
+ if (hostnames.length === 2) twoStarted.resolve();
1066
+ return lookup.promise;
1067
+ });
1068
+ try {
1069
+ await configure({
1070
+ sinks: { buffer: (record) => records.push(record) },
1071
+ loggers: [{
1072
+ category: "fedify",
1073
+ sinks: ["buffer"],
1074
+ lowestLevel: "debug"
1075
+ }, {
1076
+ category: ["logtape", "meta"],
1077
+ sinks: []
1078
+ }],
1079
+ reset: true
1080
+ });
1081
+ const first = getNodeInfo("https://first.example/nodeinfo", {
1082
+ direct: true,
1083
+ timeout: 50
1084
+ });
1085
+ const second = getNodeInfo("https://second.example/nodeinfo", {
1086
+ direct: true,
1087
+ timeout: 50
1088
+ });
1089
+ await settleWithin(twoStarted.promise, 1e3);
1090
+ assertEquals(await settleWithin(getNodeInfo("https://third.example/nodeinfo", {
1091
+ direct: true,
1092
+ timeout: 20
1093
+ }), 1e3), void 0);
1094
+ assertEquals(await settleWithin(first, 1e3), void 0);
1095
+ assertEquals(await settleWithin(second, 1e3), void 0);
1096
+ assertEquals(hostnames, ["first.example", "second.example"]);
1097
+ for (const lookup of pending) lookup.resolve([{
1098
+ address: "93.184.215.14",
1099
+ family: 4
1100
+ }]);
1101
+ await new Promise((resolve) => setTimeout(resolve, 0));
1102
+ assertEquals(hostnames, ["first.example", "second.example"]);
1103
+ assertEquals(records.some((record) => String(record.rawMessage).includes("DNS lookup failed")), false);
1104
+ } finally {
1105
+ dns.lookup = originalLookup;
1106
+ for (const lookup of pending) lookup.resolve([{
1107
+ address: "93.184.215.14",
1108
+ family: 4
1109
+ }]);
1110
+ await reset();
1111
+ }
1112
+ });
1052
1113
  function recordHops(respond) {
1053
1114
  const events = [];
1054
1115
  const unsettled = [];
@@ -1116,6 +1177,347 @@ function recordHops(respond) {
1116
1177
  }
1117
1178
  };
1118
1179
  }
1180
+ function deferred() {
1181
+ let resolve;
1182
+ return {
1183
+ promise: new Promise((done) => resolve = done),
1184
+ resolve
1185
+ };
1186
+ }
1187
+ function waitForAbort(signal) {
1188
+ return new Promise((_, reject) => {
1189
+ if (signal?.aborted) {
1190
+ reject(signal.reason);
1191
+ return;
1192
+ }
1193
+ signal?.addEventListener("abort", () => reject(signal.reason), { once: true });
1194
+ });
1195
+ }
1196
+ test("getNodeInfo() times out while waiting for response headers", async () => {
1197
+ const closed = deferred();
1198
+ let fetches = 0;
1199
+ let closes = 0;
1200
+ let signal;
1201
+ const records = [];
1202
+ await configure({
1203
+ sinks: { buffer: (record) => records.push(record) },
1204
+ loggers: [{
1205
+ category: "fedify",
1206
+ sinks: ["buffer"],
1207
+ lowestLevel: "debug"
1208
+ }, {
1209
+ category: ["logtape", "meta"],
1210
+ sinks: []
1211
+ }],
1212
+ reset: true
1213
+ });
1214
+ try {
1215
+ assertEquals(await settleWithin(getNodeInfoInternal("https://example.com/nodeinfo", {
1216
+ direct: true,
1217
+ timeout: 30
1218
+ }, { openHop: async (url, hopSignal) => {
1219
+ signal = hopSignal;
1220
+ return {
1221
+ url: new URL(url),
1222
+ fetch(_input, init) {
1223
+ fetches++;
1224
+ assertEquals(init?.signal, hopSignal);
1225
+ return waitForAbort(init?.signal);
1226
+ },
1227
+ async close() {
1228
+ closes++;
1229
+ closed.resolve();
1230
+ }
1231
+ };
1232
+ } }), 1e3), void 0);
1233
+ await settleWithin(closed.promise, 1e3);
1234
+ assertEquals(fetches, 1);
1235
+ assertEquals(closes, 1);
1236
+ assertEquals(signal?.aborted, true);
1237
+ assertEquals(records.filter((record) => record.level === "error").length, 1);
1238
+ await new Promise((resolve) => setTimeout(resolve, 0));
1239
+ assertEquals(records.filter((record) => record.level === "error").length, 1);
1240
+ } finally {
1241
+ await reset();
1242
+ }
1243
+ });
1244
+ test("getNodeInfo() times out while a small response body stalls", async () => {
1245
+ const closed = deferred();
1246
+ let bodyCancelled = false;
1247
+ let signal;
1248
+ assertEquals(await settleWithin(getNodeInfoInternal("https://example.com/nodeinfo", {
1249
+ direct: true,
1250
+ timeout: 30
1251
+ }, { async openHop(url, hopSignal) {
1252
+ signal = hopSignal;
1253
+ return {
1254
+ url: new URL(url),
1255
+ async fetch(_input, init) {
1256
+ assertEquals(init?.signal, hopSignal);
1257
+ return new Response(new ReadableStream({
1258
+ start(controller) {
1259
+ controller.enqueue(new TextEncoder().encode("{\"software\":"));
1260
+ },
1261
+ cancel() {
1262
+ bodyCancelled = true;
1263
+ }
1264
+ }));
1265
+ },
1266
+ async close() {
1267
+ closed.resolve();
1268
+ }
1269
+ };
1270
+ } }), 1e3), void 0);
1271
+ await settleWithin(closed.promise, 1e3);
1272
+ assertEquals(signal?.aborted, true);
1273
+ assertEquals(bodyCancelled, true);
1274
+ });
1275
+ test({
1276
+ name: "getNodeInfo() aborts stalled HTTP responses",
1277
+ ignore: "navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers" || "Deno" in globalThis && (await Deno.permissions.query({ name: "net" })).state !== "granted",
1278
+ async fn(t) {
1279
+ for (const stage of ["headers", "body"]) await t.step(stage, async () => {
1280
+ const disconnected = deferred();
1281
+ const server = createServer((request, response) => {
1282
+ response.on("close", () => disconnected.resolve());
1283
+ request.socket.on("close", () => disconnected.resolve());
1284
+ if (stage === "body") {
1285
+ response.writeHead(200, { "Content-Type": "application/json" });
1286
+ response.write("{\"software\":");
1287
+ }
1288
+ });
1289
+ try {
1290
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
1291
+ const address = server.address();
1292
+ if (address == null || typeof address === "string") throw new Error("Expected a TCP server address.");
1293
+ assertEquals(await settleWithin(getNodeInfoInternal(`http://127.0.0.1:${address.port}/nodeinfo`, {
1294
+ direct: true,
1295
+ timeout: 200
1296
+ }, { openHop: openDirectFetch }), 2e3).catch((error) => {
1297
+ throw new Error(`${stage} lookup did not finish`, { cause: error });
1298
+ }), void 0);
1299
+ await settleWithin(disconnected.promise, 2e3).catch((error) => {
1300
+ throw new Error(`${stage} connection did not close`, { cause: error });
1301
+ });
1302
+ } finally {
1303
+ server.closeAllConnections();
1304
+ await new Promise((resolve) => server.close(() => resolve()));
1305
+ }
1306
+ });
1307
+ }
1308
+ });
1309
+ test("getNodeInfo() shares one timeout across discovery and document", async () => {
1310
+ const documentRequested = deferred();
1311
+ const documentClosed = deferred();
1312
+ let discoverySignal;
1313
+ let documentSignal;
1314
+ const descriptor = JSON.stringify({ links: [{
1315
+ rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
1316
+ href: "https://example.com/nodeinfo/2.1"
1317
+ }] });
1318
+ const result = getNodeInfoInternal("https://example.com/", { timeout: 200 }, { async openHop(url) {
1319
+ const isDocument = url.endsWith("/nodeinfo/2.1");
1320
+ return {
1321
+ url: new URL(url),
1322
+ async fetch(_input, init) {
1323
+ if (isDocument) {
1324
+ documentSignal = init?.signal ?? void 0;
1325
+ documentRequested.resolve();
1326
+ return await waitForAbort(init?.signal);
1327
+ }
1328
+ discoverySignal = init?.signal ?? void 0;
1329
+ return new Response(descriptor);
1330
+ },
1331
+ async close() {
1332
+ if (isDocument) documentClosed.resolve();
1333
+ }
1334
+ };
1335
+ } });
1336
+ await settleWithin(documentRequested.promise, 1e3);
1337
+ assertStrictEquals(documentSignal, discoverySignal);
1338
+ assertEquals(await settleWithin(result, 1e3), void 0);
1339
+ await settleWithin(documentClosed.promise, 1e3);
1340
+ assertEquals(discoverySignal?.aborted, true);
1341
+ });
1342
+ test("getNodeInfo() honors caller cancellation without a timeout", async () => {
1343
+ const caller = new AbortController();
1344
+ const closed = deferred();
1345
+ let requestSignal;
1346
+ assertEquals(await settleWithin(getNodeInfoInternal("https://example.com/nodeinfo", {
1347
+ direct: true,
1348
+ timeout: null,
1349
+ signal: caller.signal
1350
+ }, { async openHop(url, signal) {
1351
+ requestSignal = signal;
1352
+ return {
1353
+ url: new URL(url),
1354
+ fetch(_input, init) {
1355
+ assertStrictEquals(init?.signal, signal);
1356
+ caller.abort(/* @__PURE__ */ new Error("Caller stopped waiting"));
1357
+ return waitForAbort(init?.signal);
1358
+ },
1359
+ async close() {
1360
+ closed.resolve();
1361
+ }
1362
+ };
1363
+ } }), 1e3), void 0);
1364
+ await settleWithin(closed.promise, 1e3);
1365
+ assertEquals(requestSignal?.aborted, true);
1366
+ });
1367
+ test("getNodeInfo() stops before fetching when caller already aborted", async () => {
1368
+ const caller = new AbortController();
1369
+ caller.abort();
1370
+ let opened = false;
1371
+ assertEquals(await getNodeInfoInternal("https://example.com/nodeinfo", {
1372
+ direct: true,
1373
+ signal: caller.signal
1374
+ }, { async openHop() {
1375
+ opened = true;
1376
+ throw new Error("Unexpected fetch");
1377
+ } }), void 0);
1378
+ assertEquals(opened, false);
1379
+ });
1380
+ test("getNodeInfo() closes a session opened just after its timeout", async () => {
1381
+ const closed = deferred();
1382
+ let fetches = 0;
1383
+ let closes = 0;
1384
+ assertEquals(await settleWithin(getNodeInfoInternal("https://example.com/nodeinfo", {
1385
+ direct: true,
1386
+ timeout: 25
1387
+ }, { async openHop(url) {
1388
+ await new Promise((resolve) => setTimeout(resolve, 55));
1389
+ return {
1390
+ url: new URL(url),
1391
+ async fetch() {
1392
+ fetches++;
1393
+ return Response.json({ software: {
1394
+ name: "x",
1395
+ version: "1"
1396
+ } });
1397
+ },
1398
+ async close() {
1399
+ closes++;
1400
+ closed.resolve();
1401
+ }
1402
+ };
1403
+ } }), 1e3), void 0);
1404
+ await settleWithin(closed.promise, 1e3);
1405
+ assertEquals(fetches, 0);
1406
+ assertEquals(closes, 1);
1407
+ });
1408
+ test("getNodeInfo() does not log a late DNS failure as another error", async () => {
1409
+ const records = [];
1410
+ const finished = deferred();
1411
+ await configure({
1412
+ sinks: { buffer: (record) => records.push(record) },
1413
+ loggers: [{
1414
+ category: "fedify",
1415
+ sinks: ["buffer"],
1416
+ lowestLevel: "debug"
1417
+ }, {
1418
+ category: ["logtape", "meta"],
1419
+ sinks: []
1420
+ }],
1421
+ reset: true
1422
+ });
1423
+ try {
1424
+ assertEquals(await settleWithin(getNodeInfoInternal("https://example.com/nodeinfo", {
1425
+ direct: true,
1426
+ timeout: 25
1427
+ }, { async openHop() {
1428
+ try {
1429
+ await new Promise((resolve) => setTimeout(resolve, 55));
1430
+ throw new UrlError("DNS lookup failed", { reason: "dns" });
1431
+ } finally {
1432
+ finished.resolve();
1433
+ }
1434
+ } }), 1e3), void 0);
1435
+ await settleWithin(finished.promise, 1e3);
1436
+ await new Promise((resolve) => setTimeout(resolve, 0));
1437
+ assertEquals(records.filter((record) => record.level === "error").length, 1);
1438
+ } finally {
1439
+ await reset();
1440
+ }
1441
+ });
1442
+ test("getNodeInfo() cancels a response returned after timeout", async () => {
1443
+ const closed = deferred();
1444
+ let bodyCancelled = false;
1445
+ let closes = 0;
1446
+ assertEquals(await settleWithin(getNodeInfoInternal("https://example.com/nodeinfo", {
1447
+ direct: true,
1448
+ timeout: 25
1449
+ }, { async openHop(url) {
1450
+ return {
1451
+ url: new URL(url),
1452
+ async fetch() {
1453
+ await new Promise((resolve) => setTimeout(resolve, 55));
1454
+ return new Response(new ReadableStream({ cancel() {
1455
+ bodyCancelled = true;
1456
+ } }));
1457
+ },
1458
+ async close() {
1459
+ closes++;
1460
+ closed.resolve();
1461
+ }
1462
+ };
1463
+ } }), 1e3), void 0);
1464
+ await settleWithin(closed.promise, 1e3);
1465
+ assertEquals(closes, 1);
1466
+ assertEquals(bodyCancelled, true);
1467
+ });
1468
+ test("getNodeInfo() validates its timeout", async () => {
1469
+ for (const timeout of [
1470
+ 0,
1471
+ -1,
1472
+ NaN,
1473
+ Infinity,
1474
+ 2147483648
1475
+ ]) await assertRejects(() => getNodeInfoInternal("https://example.com/", { timeout }), RangeError);
1476
+ });
1477
+ test("getNodeInfo() can disable its timeout", async () => {
1478
+ const value = { software: {
1479
+ name: "x",
1480
+ version: "1"
1481
+ } };
1482
+ assertEquals(await getNodeInfoInternal("https://example.com/nodeinfo", {
1483
+ direct: true,
1484
+ parse: "none",
1485
+ timeout: null
1486
+ }, { async openHop(url, signal) {
1487
+ assertEquals(signal, void 0);
1488
+ return {
1489
+ url: new URL(url),
1490
+ async fetch(_input, init) {
1491
+ assertEquals(init?.signal, void 0);
1492
+ return Response.json(value);
1493
+ },
1494
+ async close() {}
1495
+ };
1496
+ } }), value);
1497
+ });
1498
+ test("getNodeInfo() clears its timer after a successful fetch", async () => {
1499
+ let signal;
1500
+ const value = { software: {
1501
+ name: "x",
1502
+ version: "1"
1503
+ } };
1504
+ assertEquals(await getNodeInfoInternal("https://example.com/nodeinfo", {
1505
+ direct: true,
1506
+ parse: "none",
1507
+ timeout: 100
1508
+ }, { async openHop(url, hopSignal) {
1509
+ signal = hopSignal;
1510
+ return {
1511
+ url: new URL(url),
1512
+ async fetch() {
1513
+ return Response.json(value);
1514
+ },
1515
+ async close() {}
1516
+ };
1517
+ } }), value);
1518
+ await new Promise((resolve) => setTimeout(resolve, 120));
1519
+ assertEquals(signal?.aborted, false);
1520
+ });
1119
1521
  test("getNodeInfo() closes each hop after cleaning up its body", async (t) => {
1120
1522
  const wellKnown = "https://example.com/.well-known/nodeinfo";
1121
1523
  const wellKnown2 = "https://example.com/.well-known/nodeinfo2";
@@ -1186,9 +1588,9 @@ test("getNodeInfo() closes each hop after cleaning up its body", async (t) => {
1186
1588
  recorder.assertInvariants();
1187
1589
  });
1188
1590
  await t.step("too many redirections", async () => {
1189
- const recorder = recordHops(() => ({
1591
+ const recorder = recordHops((url) => ({
1190
1592
  status: 302,
1191
- headers: { Location: "/.well-known/nodeinfo" },
1593
+ headers: { Location: `?hop=${Number(url.searchParams.get("hop") ?? 0) + 1}` },
1192
1594
  body: "redirecting"
1193
1595
  }));
1194
1596
  assertEquals(await getNodeInfoInternal("https://example.com/", {}, { openHop: recorder.openHop }), void 0);
@@ -1196,6 +1598,31 @@ test("getNodeInfo() closes each hop after cleaning up its body", async (t) => {
1196
1598
  assertEquals(recorder.events.filter((e) => e.startsWith("cancel ")).length, 5);
1197
1599
  recorder.assertInvariants();
1198
1600
  });
1601
+ await t.step("self-redirect cycle", async () => {
1602
+ const recorder = recordHops(() => ({
1603
+ status: 302,
1604
+ headers: { Location: "/.well-known/nodeinfo#another-fragment" },
1605
+ body: "redirecting"
1606
+ }));
1607
+ assertEquals(await getNodeInfoInternal("https://example.com/", {}, { openHop: recorder.openHop }), void 0);
1608
+ assertEquals(recorder.events, [
1609
+ `open ${wellKnown}`,
1610
+ `fetch ${wellKnown} #1`,
1611
+ "cancel #1",
1612
+ `close ${wellKnown}`
1613
+ ]);
1614
+ recorder.assertInvariants();
1615
+ });
1616
+ await t.step("two-URL redirect cycle", async () => {
1617
+ const recorder = recordHops((url) => ({
1618
+ status: 302,
1619
+ headers: { Location: url.href === wellKnown ? "/.well-known/nodeinfo2" : "/.well-known/nodeinfo" },
1620
+ body: "redirecting"
1621
+ }));
1622
+ assertEquals(await getNodeInfoInternal("https://example.com/", {}, { openHop: recorder.openHop }), void 0);
1623
+ assertEquals(recorder.events.filter((e) => e.startsWith("open ")), [`open ${wellKnown}`, `open ${wellKnown2}`]);
1624
+ recorder.assertInvariants();
1625
+ });
1199
1626
  await t.step("failed redirect body cancellation", async () => {
1200
1627
  const recorder = recordHops((url) => {
1201
1628
  switch (url.href) {
@@ -5,7 +5,7 @@ import { n as createRequestContext } from "../context-Juj6bdHC.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-DflMZha5.mjs";
7
7
  import { t as MemoryKvStore } from "../kv-BrZHNugx.mjs";
8
- import { a as createFederation, h as handleNodeInfoJrd, m as handleNodeInfo } from "../middleware-DkrLbSc2.mjs";
8
+ import { a as createFederation, h as handleNodeInfoJrd, m as handleNodeInfo } from "../middleware-CwLd8bQH.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  //#region src/nodeinfo/handler.test.ts
11
11
  test("handleNodeInfo()", async () => {
@@ -1,7 +1,7 @@
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_types = require("../types-DOvyymM4.cjs");
4
+ const require_types = require("../types-B5wRhemi.cjs");
5
5
  exports.getNodeInfo = require_types.getNodeInfo;
6
6
  exports.nodeInfoToJson = require_types.nodeInfoToJson;
7
7
  exports.parseNodeInfo = require_types.parseNodeInfo;
@@ -1,3 +1,3 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { a as InboundService, c as OutboundService, d as Software, f as Usage, i as parseNodeInfo, l as Protocol, n as ParseNodeInfoOptions, o as JsonValue, p as nodeInfoToJson, r as getNodeInfo, s as NodeInfo, t as GetNodeInfoOptions, u as Services } from "../client-BIBzqEIp.cjs";
2
+ import { a as InboundService, c as OutboundService, d as Software, f as Usage, i as parseNodeInfo, l as Protocol, n as ParseNodeInfoOptions, o as JsonValue, p as nodeInfoToJson, r as getNodeInfo, s as NodeInfo, t as GetNodeInfoOptions, u as Services } from "../client-B3ruDgWg.cjs";
3
3
  export { type GetNodeInfoOptions, InboundService, JsonValue, NodeInfo, OutboundService, type ParseNodeInfoOptions, Protocol, Services, Software, Usage, getNodeInfo, nodeInfoToJson, parseNodeInfo };
@@ -1,3 +1,3 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { a as InboundService, c as OutboundService, d as Software, f as Usage, i as parseNodeInfo, l as Protocol, n as ParseNodeInfoOptions, o as JsonValue, p as nodeInfoToJson, r as getNodeInfo, s as NodeInfo, t as GetNodeInfoOptions, u as Services } from "../client-jE7oGvRh.js";
2
+ import { a as InboundService, c as OutboundService, d as Software, f as Usage, i as parseNodeInfo, l as Protocol, n as ParseNodeInfoOptions, o as JsonValue, p as nodeInfoToJson, r as getNodeInfo, s as NodeInfo, t as GetNodeInfoOptions, u as Services } from "../client-9DPcy_Yx.js";
3
3
  export { type GetNodeInfoOptions, InboundService, JsonValue, NodeInfo, OutboundService, type ParseNodeInfoOptions, Protocol, Services, Software, Usage, getNodeInfo, nodeInfoToJson, parseNodeInfo };
@@ -1,4 +1,4 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "../types-B1_pRFE_.js";
3
+ import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "../types-CXy2lRVU.js";
4
4
  export { getNodeInfo, nodeInfoToJson, parseNodeInfo };
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-USvfGHbR.mjs";
5
- import { n as fetchActorDocument, s as verifyKeyOwnership, t as exportJwk } from "./key-BDisDFGv.mjs";
4
+ import { n as version, t as name } from "./deno-CqGxhJxg.mjs";
5
+ import { n as fetchActorDocument, s as verifyKeyOwnership, t as exportJwk } from "./key-CH4J7bu-.mjs";
6
6
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
7
7
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
8
8
  import { getDocumentLoader } from "@fedify/vocab-runtime";
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { a as fetchActorDocument, d as name, f as version, i as exportJwk, l as validateCryptoKey, o as fetchKey, u as verifyKeyOwnership } from "./http-ixT5PjBz.js";
3
+ import { a as fetchActorDocument, d as name, f as version, i as exportJwk, l as validateCryptoKey, o as fetchKey, u as verifyKeyOwnership } from "./http-DUO4mfwi.js";
4
4
  import { getLogger } from "@logtape/logtape";
5
5
  import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, getTypeId, isActor } from "@fedify/vocab";
6
6
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
@@ -1,8 +1,8 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-USvfGHbR.mjs";
5
- import { o as validateCryptoKey, r as fetchKey } from "./key-BDisDFGv.mjs";
4
+ import { n as version, t as name } from "./deno-CqGxhJxg.mjs";
5
+ import { o as validateCryptoKey, r as fetchKey } from "./key-CH4J7bu-.mjs";
6
6
  import { Activity, DataIntegrityProof, Multikey, getTypeId } from "@fedify/vocab";
7
7
  import { SpanStatusCode, trace } from "@opentelemetry/api";
8
8
  import { asCryptoKey } from "@fedify/vocab-runtime/internal";
@@ -1,7 +1,7 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  const require_chunk = require("./chunk-DDcVe30Y.cjs");
4
- const require_http = require("./http-BAhackOL.cjs");
4
+ const require_http = require("./http-Dd2WgYHq.cjs");
5
5
  let _logtape_logtape = require("@logtape/logtape");
6
6
  let _fedify_vocab = require("@fedify/vocab");
7
7
  let _opentelemetry_api = require("@opentelemetry/api");
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-USvfGHbR.mjs";
5
- import { r as doubleKnockScoped } from "./http-BGjEnY4L.mjs";
4
+ import { n as version, t as name } from "./deno-CqGxhJxg.mjs";
5
+ import { r as doubleKnockScoped } from "./http-BcKYM_M1.mjs";
6
6
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
7
7
  import { FetchError, UrlError } from "@fedify/vocab-runtime";
8
8
  import { openDirectFetch, openPublicFetch } from "@fedify/vocab-runtime/internal";
@@ -7,8 +7,8 @@ import { i as assertExists, t as assertStringIncludes } from "../std__assert-Dfl
7
7
  import { r as assertFalse, t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
8
8
  import { t as assert } from "../assert-BhQd8QHP.mjs";
9
9
  import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
10
- import { t as exportJwk } from "../key-BDisDFGv.mjs";
11
- import { a as formatRfc9421SignatureParameters, c as signRequest, i as formatRfc9421Signature, l as timingSafeEqual, n as doubleKnock, o as parseRfc9421Signature, r as doubleKnockScoped, s as parseRfc9421SignatureInput, t as createRfc9421SignatureBase, u as verifyRequest } from "../http-BGjEnY4L.mjs";
10
+ import { t as exportJwk } from "../key-CH4J7bu-.mjs";
11
+ import { a as formatRfc9421SignatureParameters, c as signRequest, i as formatRfc9421Signature, l as timingSafeEqual, n as doubleKnock, o as parseRfc9421Signature, r as doubleKnockScoped, s as parseRfc9421SignatureInput, t as createRfc9421SignatureBase, u as verifyRequest } from "../http-BcKYM_M1.mjs";
12
12
  import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-CCxRJhWa.mjs";
13
13
  import { mockDocumentLoader, test } from "@fedify/fixture";
14
14
  import { FetchError, exportSpki } from "@fedify/vocab-runtime";
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { a as ActorCallbackSetters, c as SenderKeyPair, d as exportJwk, l as HttpMessageSignaturesSpecDeterminer, n as Context, r as InboxContext, s as InboxListenerSetters, t as ActorKeyPairsDispatcher, u as signRequest } from "../callback-ySj5p3Ml.mjs";
3
+ import { a as ActorCallbackSetters, c as SenderKeyPair, d as exportJwk, l as HttpMessageSignaturesSpecDeterminer, n as Context, r as InboxContext, s as InboxListenerSetters, t as ActorKeyPairsDispatcher, u as signRequest } from "../callback-Bmi_V7Ai.mjs";
4
4
  import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, Recipient } from "@fedify/vocab";
5
5
  import { TracerProvider } from "@opentelemetry/api";
6
6
  import { AuthenticatedDocumentLoaderFactory, CryptoKeyLike, CryptoKeyPairLike, DocumentLoader, DocumentLoaderFactoryOptions, exportMultibaseKey, exportSpki } from "@fedify/vocab-runtime";
@@ -6,9 +6,9 @@ import { n as assertStrictEquals } from "../std__assert-DflMZha5.mjs";
6
6
  import { r as assertFalse, t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
7
7
  import { t as assert } from "../assert-BhQd8QHP.mjs";
8
8
  import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
9
- import { a as importJwk, i as generateCryptoKeyPair, o as validateCryptoKey, r as fetchKey, t as exportJwk } from "../key-BDisDFGv.mjs";
9
+ import { a as importJwk, i as generateCryptoKeyPair, o as validateCryptoKey, r as fetchKey, t as exportJwk } from "../key-CH4J7bu-.mjs";
10
10
  import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CCxRJhWa.mjs";
11
- import { v as wrapContextLoaderForJsonLd } from "../ld-CjHkfxXf.mjs";
11
+ import { v as wrapContextLoaderForJsonLd } from "../ld-nCaXr4W2.mjs";
12
12
  import { mockDocumentLoader, test } from "@fedify/fixture";
13
13
  import { CryptographicKey, Multikey, Person } from "@fedify/vocab";
14
14
  import { FetchError, UrlError, getDocumentLoader } from "@fedify/vocab-runtime";
@@ -5,9 +5,9 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { r as assertFalse, t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
6
6
  import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
7
7
  import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
8
- import { i as generateCryptoKeyPair } from "../key-BDisDFGv.mjs";
8
+ import { i as generateCryptoKeyPair } from "../key-CH4J7bu-.mjs";
9
9
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CCxRJhWa.mjs";
10
- import { _ as verifySignature, a as compactJsonLd, c as detachSignature, d as hasVerifiableSignature, g as verifyJsonLd, i as attachSignature, m as signJsonLd, n as UnsafeJsonLdError, o as createSignature, p as isInvalidUrlTypeError, s as describeSignatureShape, u as hasSignature } from "../ld-CjHkfxXf.mjs";
10
+ import { _ as verifySignature, a as compactJsonLd, c as detachSignature, d as hasVerifiableSignature, g as verifyJsonLd, i as attachSignature, m as signJsonLd, n as UnsafeJsonLdError, o as createSignature, p as isInvalidUrlTypeError, s as describeSignatureShape, u as hasSignature } from "../ld-nCaXr4W2.mjs";
11
11
  import { t as ldSignatureWithoutCreated } from "../ld-signature-_KYhPsqt.mjs";
12
12
  import { mockDocumentLoader, test } from "@fedify/fixture";
13
13
  import { Create, CryptographicKey, Note } from "@fedify/vocab";
package/dist/sig/mod.cjs CHANGED
@@ -1,8 +1,8 @@
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_http = require("../http-BAhackOL.cjs");
5
- const require_proof = require("../proof-BOemJGRl.cjs");
4
+ const require_http = require("../http-Dd2WgYHq.cjs");
5
+ const require_proof = require("../proof-MoO82jAG.cjs");
6
6
  exports.attachSignature = require_proof.attachSignature;
7
7
  exports.createProof = require_proof.createProof;
8
8
  exports.createSignature = require_proof.createSignature;
package/dist/sig/mod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { c as importJwk, i as exportJwk, n as signRequest, o as fetchKey, r as verifyRequest, s as generateCryptoKeyPair } from "../http-ixT5PjBz.js";
4
- import { a as doesActorOwnKey, b as verifyJsonLd, d as createSignature, i as verifyProof, l as attachSignature, n as signObject, o as getKeyOwner, p as detachSignature, r as verifyObject, t as createProof, v as signJsonLd, x as verifySignature } from "../proof-BiTmCpLq.js";
3
+ import { c as importJwk, i as exportJwk, n as signRequest, o as fetchKey, r as verifyRequest, s as generateCryptoKeyPair } from "../http-DUO4mfwi.js";
4
+ import { a as doesActorOwnKey, b as verifyJsonLd, d as createSignature, i as verifyProof, l as attachSignature, n as signObject, o as getKeyOwner, p as detachSignature, r as verifyObject, t as createProof, v as signJsonLd, x as verifySignature } from "../proof-BQTBsTGc.js";
5
5
  export { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, exportJwk, fetchKey, generateCryptoKeyPair, getKeyOwner, importJwk, signJsonLd, signObject, signRequest, verifyJsonLd, verifyObject, verifyProof, verifyRequest, verifySignature };
@@ -6,7 +6,7 @@ import "../std__assert-DflMZha5.mjs";
6
6
  import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
7
7
  import { t as assert } from "../assert-BhQd8QHP.mjs";
8
8
  import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-CCxRJhWa.mjs";
9
- import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-CyoKKXIR.mjs";
9
+ import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-RdxrumqL.mjs";
10
10
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
11
11
  import { Create, CryptographicKey, lookupObject } from "@fedify/vocab";
12
12
  //#region src/sig/owner.test.ts