@fedify/fedify 2.2.12 → 2.2.13

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 (102) hide show
  1. package/dist/{assert_instance_of-C4Ri6VuN.mjs → assert-BhQd8QHP.mjs} +19 -1
  2. package/dist/{builder-TJzcpmDm.mjs → builder-uTlVksLw.mjs} +3 -3
  3. package/dist/{client-dx126nMS.mjs → client-CQ7zd8tW.mjs} +78 -4
  4. package/dist/compat/mod.d.cts +1 -1
  5. package/dist/compat/mod.d.ts +1 -1
  6. package/dist/compat/outgoing-jsonld.test.mjs +1 -1
  7. package/dist/compat/public-audience.test.mjs +1 -1
  8. package/dist/compat/transformers.test.mjs +3 -4
  9. package/dist/{context-BU-1O90h.d.ts → context-Bt2jnbC7.d.ts} +4 -3
  10. package/dist/{context-DVA8wHZ0.d.cts → context-Cls_M1HU.d.cts} +4 -3
  11. package/dist/{deno-DeYUdFal.mjs → deno-Cg_cZHcI.mjs} +1 -1
  12. package/dist/{docloader-CXH2XqYP.mjs → docloader-BwXP5fDH.mjs} +2 -2
  13. package/dist/federation/builder.test.mjs +2 -2
  14. package/dist/federation/collection.test.mjs +1 -1
  15. package/dist/federation/handler.test.mjs +127 -10
  16. package/dist/federation/idempotency.test.mjs +4 -4
  17. package/dist/federation/inbox.test.mjs +1 -1
  18. package/dist/federation/keycache.test.mjs +44 -10
  19. package/dist/federation/kv.test.mjs +1 -1
  20. package/dist/federation/middleware.test.mjs +103 -15
  21. package/dist/federation/mod.cjs +1 -1
  22. package/dist/federation/mod.d.cts +2 -2
  23. package/dist/federation/mod.d.ts +2 -2
  24. package/dist/federation/mod.js +1 -1
  25. package/dist/federation/mq.test.mjs +1 -1
  26. package/dist/federation/negotiation.test.mjs +2 -2
  27. package/dist/federation/retry.test.mjs +1 -1
  28. package/dist/federation/router.test.mjs +1 -1
  29. package/dist/federation/send.test.mjs +138 -6
  30. package/dist/federation/temporal.test.mjs +2 -2
  31. package/dist/federation/webfinger.test.mjs +2 -2
  32. package/dist/{http-79lZeYEo.mjs → http-B3V9unT4.mjs} +3 -3
  33. package/dist/{http-D6cIKrI1.cjs → http-BdbKIiay.cjs} +166 -6
  34. package/dist/{http-CNsxTbVr.js → http-DaLdtguq.js} +155 -7
  35. package/dist/{http-BDZeS5om.d.ts → http-Dl00HXr4.d.ts} +1 -1
  36. package/dist/{http-C87EWkO0.d.cts → http-DqZhyEso.d.cts} +1 -1
  37. package/dist/{key-B4kUuy3o.mjs → key-CLRfRmA_.mjs} +154 -6
  38. package/dist/{keycache-EGATflN-.mjs → keycache-C1aVprwy.mjs} +12 -4
  39. package/dist/{kv-cache-BtXEUvHT.cjs → kv-cache-K6eHO_YH.cjs} +1 -1
  40. package/dist/{kv-cache-CIZ1m-94.js → kv-cache-TPuR5wYg.js} +1 -1
  41. package/dist/{ld-2R9vZ_ym.mjs → ld-C0s4f-GU.mjs} +2 -2
  42. package/dist/{middleware-DsEAPFhi.js → middleware-BDRZkGPG.js} +90 -14
  43. package/dist/{middleware-CjrIRAsQ.cjs → middleware-BDc7xyOx.cjs} +90 -14
  44. package/dist/{middleware-D5NE6PkU.mjs → middleware-BsDiZP9H.mjs} +31 -20
  45. package/dist/{middleware-2bSnAJOQ.cjs → middleware-D6bGiZn6.cjs} +1 -1
  46. package/dist/{middleware-_qt3kHUU.mjs → middleware-uaOjlLEG.mjs} +1 -1
  47. package/dist/{mod-BhU_H1I_.d.ts → mod-0MWo2Nu5.d.ts} +1 -1
  48. package/dist/{mod-DXY9JF28.d.cts → mod-D2JyWtW3.d.cts} +1 -1
  49. package/dist/{mod-q-NFLW6B.d.cts → mod-DNvnDTS7.d.cts} +1 -1
  50. package/dist/{mod-BVt6iTmH.d.ts → mod-DaiJDJdQ.d.ts} +1 -1
  51. package/dist/{mod-B0rWmfW5.d.cts → mod-DzPMtIV3.d.cts} +1 -1
  52. package/dist/{mod-DHO9lk3D.d.ts → mod-ej_rLx8h.d.ts} +1 -1
  53. package/dist/mod.cjs +5 -5
  54. package/dist/mod.d.cts +6 -6
  55. package/dist/mod.d.ts +6 -6
  56. package/dist/mod.js +5 -5
  57. package/dist/nodeinfo/client.test.mjs +28 -1
  58. package/dist/nodeinfo/handler.test.mjs +2 -2
  59. package/dist/nodeinfo/mod.cjs +1 -1
  60. package/dist/nodeinfo/mod.js +1 -1
  61. package/dist/nodeinfo/types.test.mjs +1 -1
  62. package/dist/otel/exporter.test.mjs +1 -1
  63. package/dist/{outgoing-jsonld-CfUItkGW.mjs → outgoing-jsonld-Dc2OXyB-.mjs} +1 -1
  64. package/dist/{owner-CnngXDNJ.d.ts → owner-B3hNQCG8.d.cts} +12 -1
  65. package/dist/{owner-DEvZuyOE.d.cts → owner-CiBPcC6F.d.ts} +12 -1
  66. package/dist/owner-DLbN_4jZ.mjs +175 -0
  67. package/dist/{proof-CmtXtaul.cjs → proof-CTIG9UEI.cjs} +112 -58
  68. package/dist/{proof-BzTt6nlk.mjs → proof-CW3Zrxmd.mjs} +4 -4
  69. package/dist/{proof-BhW_iARR.js → proof-CqyprEYB.js} +112 -58
  70. package/dist/{send-CZwOs7XD.mjs → send-B5QvdrZ1.mjs} +64 -6
  71. package/dist/sig/accept.test.mjs +1 -1
  72. package/dist/sig/http.test.mjs +4 -4
  73. package/dist/sig/key.test.mjs +170 -3
  74. package/dist/sig/ld.test.mjs +56 -4
  75. package/dist/sig/mod.cjs +2 -2
  76. package/dist/sig/mod.d.cts +3 -3
  77. package/dist/sig/mod.d.ts +3 -3
  78. package/dist/sig/mod.js +2 -2
  79. package/dist/sig/owner.test.mjs +105 -6
  80. package/dist/sig/proof.test.mjs +73 -5
  81. package/dist/{temporal-BYCnXIGk.mjs → temporal-CFLRXAcm.mjs} +1 -1
  82. package/dist/{types-m8u9L86X.cjs → types-DWs-qZaY.cjs} +94 -2
  83. package/dist/{types-DTONwNqL.js → types-sXITXcWa.js} +78 -4
  84. package/dist/utils/docloader.test.mjs +28 -4
  85. package/dist/utils/kv-cache.test.mjs +1 -1
  86. package/dist/utils/mod.cjs +1 -1
  87. package/dist/utils/mod.d.cts +1 -1
  88. package/dist/utils/mod.d.ts +1 -1
  89. package/dist/utils/mod.js +1 -1
  90. package/package.json +6 -6
  91. package/dist/assert-DikXweDx.mjs +0 -23
  92. package/dist/owner-CqYsVXcd.mjs +0 -120
  93. /package/dist/{accept-CPkZzmGN.mjs → accept-Dd__NiUL.mjs} +0 -0
  94. /package/dist/{activity-listener-ell7W1s9.mjs → activity-listener-IojJ9SVl.mjs} +0 -0
  95. /package/dist/{collection-D-HqUuA2.mjs → collection-DnoYNwBC.mjs} +0 -0
  96. /package/dist/{keys-DGu1NFwu.mjs → keys-BAK-tUlf.mjs} +0 -0
  97. /package/dist/{kv-rV3vodCc.mjs → kv-CX8qfaad.mjs} +0 -0
  98. /package/dist/{kv-cache-DYsF2MhP.mjs → kv-cache-FsT1ljhs.mjs} +0 -0
  99. /package/dist/{negotiation-SQvQgUqe.mjs → negotiation-BHtZN6Y1.mjs} +0 -0
  100. /package/dist/{public-audience-Ci-r-4Q-.mjs → public-audience-CS1udGkN.mjs} +0 -0
  101. /package/dist/{retry-v_sGLH1d.mjs → retry-bMXBL97A.mjs} +0 -0
  102. /package/dist/{types-J53Kw7so.mjs → types-s4mCTGkT.mjs} +0 -0
@@ -6,23 +6,22 @@ import { n as RouterError } from "../router-CrMLXoOr.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
7
7
  import "../std__assert-CRDpx_HF.mjs";
8
8
  import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
9
- import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
9
+ import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
10
10
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
11
11
  import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
12
12
  import { t as assertStrictEquals } from "../assert_strict_equals-Dmjbg-bA.mjs";
13
- import { t as assert } from "../assert-DikXweDx.mjs";
14
- import { l as verifyRequest, s as signRequest } from "../http-79lZeYEo.mjs";
15
- import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
16
- import { t as getAuthenticatedDocumentLoader } from "../docloader-CXH2XqYP.mjs";
17
- import { a as compactJsonLd, h as verifyJsonLd, p as signJsonLd, s as detachSignature } from "../ld-2R9vZ_ym.mjs";
18
- import { t as doesActorOwnKey } from "../owner-CqYsVXcd.mjs";
19
- import { i as verifyObject, r as signObject } from "../proof-BzTt6nlk.mjs";
20
- import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
21
- import { i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-D5NE6PkU.mjs";
13
+ import { l as verifyRequest, s as signRequest } from "../http-B3V9unT4.mjs";
14
+ import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
15
+ import { t as getAuthenticatedDocumentLoader } from "../docloader-BwXP5fDH.mjs";
16
+ import { a as compactJsonLd, h as verifyJsonLd, p as signJsonLd, s as detachSignature } from "../ld-C0s4f-GU.mjs";
17
+ import { t as doesActorOwnKey } from "../owner-DLbN_4jZ.mjs";
18
+ import { i as verifyObject, r as signObject } from "../proof-CW3Zrxmd.mjs";
19
+ import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
20
+ import { i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-BsDiZP9H.mjs";
22
21
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
23
22
  import * as vocab from "@fedify/vocab";
24
23
  import { Create, Offer, Person, getTypeId, lookupObject } from "@fedify/vocab";
25
- import { FetchError, getDocumentLoader } from "@fedify/vocab-runtime";
24
+ import { FetchError, UrlError, getDocumentLoader } from "@fedify/vocab-runtime";
26
25
  import { configure, reset } from "@logtape/logtape";
27
26
  import serialize from "json-canon";
28
27
  //#region ../fixture/src/fixtures/example.com/create.json
@@ -1484,7 +1483,7 @@ test("Federation.setOutboxListeners()", async (t) => {
1484
1483
  const records = [];
1485
1484
  await reset();
1486
1485
  esm_default.spyGlobal();
1487
- esm_default.post("https://remote.example/inbox", {
1486
+ esm_default.post("https://example.com/inbox", {
1488
1487
  status: 202,
1489
1488
  body: "Accepted"
1490
1489
  });
@@ -1510,7 +1509,7 @@ test("Federation.setOutboxListeners()", async (t) => {
1510
1509
  federation.setOutboxListeners("/users/{identifier}/outbox").on(vocab.Activity, async (ctx, activity) => {
1511
1510
  await ctx.sendActivity({ identifier: ctx.identifier }, new vocab.Person({
1512
1511
  id: new URL("https://remote.example/users/alice"),
1513
- inbox: new URL("https://remote.example/inbox")
1512
+ inbox: new URL("https://example.com/inbox")
1514
1513
  }), activity);
1515
1514
  }).authorize((ctx, identifier) => {
1516
1515
  return identifier === "john" && ctx.request.headers.get("authorization") === "Bearer token";
@@ -1586,7 +1585,7 @@ test("Federation.setOutboxListeners()", async (t) => {
1586
1585
  let ldsVerified = false;
1587
1586
  await reset();
1588
1587
  esm_default.spyGlobal();
1589
- esm_default.post("https://remote.example/inbox", async (cl) => {
1588
+ esm_default.post("https://example.com/inbox", async (cl) => {
1590
1589
  const verifyOptions = {
1591
1590
  documentLoader: mockDocumentLoader,
1592
1591
  contextLoader: mockDocumentLoader
@@ -1619,7 +1618,7 @@ test("Federation.setOutboxListeners()", async (t) => {
1619
1618
  keyId: rsaPublicKey2.id
1620
1619
  }], {
1621
1620
  id: new URL("https://remote.example/users/alice"),
1622
- inboxId: new URL("https://remote.example/inbox")
1621
+ inboxId: new URL("https://example.com/inbox")
1623
1622
  }, { skipIfUnsigned: true });
1624
1623
  }).authorize((ctx, identifier) => {
1625
1624
  return identifier === "person2" && ctx.request.headers.get("authorization") === "Bearer token";
@@ -3563,6 +3562,7 @@ test("FederationImpl.processQueuedTask() permanent failure", async (t) => {
3563
3562
  return Promise.resolve();
3564
3563
  }
3565
3564
  },
3565
+ allowPrivateAddress: true,
3566
3566
  ...options.permanentFailureStatusCodes ? { permanentFailureStatusCodes: options.permanentFailureStatusCodes } : {}
3567
3567
  });
3568
3568
  federation.setInboxListeners("/users/{identifier}/inbox", "/inbox");
@@ -4570,5 +4570,93 @@ test("KvSpecDeterminer", async (t) => {
4570
4570
  assertEquals(spec, "rfc9421");
4571
4571
  });
4572
4572
  });
4573
+ test("ContextImpl.sendActivity() honors the private-address policy", async (t) => {
4574
+ for (const allowPrivateAddress of [false, true]) await t.step(`allowPrivateAddress: ${allowPrivateAddress}`, async () => {
4575
+ const inbox = "http://127.0.0.1/inbox";
4576
+ esm_default.mockGlobal().post(inbox, 202);
4577
+ try {
4578
+ const ctx = createFederation({
4579
+ kv: new MemoryKvStore(),
4580
+ allowPrivateAddress
4581
+ }).createContext(new URL("https://example.com/"));
4582
+ const send = () => ctx.sendActivity({
4583
+ privateKey: ed25519PrivateKey,
4584
+ keyId: ed25519Multikey.id
4585
+ }, new Person({
4586
+ id: new URL("https://example.com/recipient"),
4587
+ inbox: new URL(inbox)
4588
+ }), new Create({
4589
+ id: new URL("https://example.com/activity"),
4590
+ actor: new URL("https://example.com/person")
4591
+ }), { immediate: true });
4592
+ if (allowPrivateAddress) {
4593
+ await send();
4594
+ assertEquals(esm_default.callHistory.calls(inbox).length, 1);
4595
+ } else {
4596
+ await assertRejects(send, UrlError);
4597
+ assertEquals(esm_default.callHistory.calls(inbox).length, 0);
4598
+ }
4599
+ } finally {
4600
+ esm_default.hardReset();
4601
+ }
4602
+ });
4603
+ });
4604
+ test("Federation.fetch() bounds inbox bodies before dispatch", async () => {
4605
+ let dispatched = false;
4606
+ const json = JSON.stringify({
4607
+ "@context": "https://www.w3.org/ns/activitystreams",
4608
+ id: "https://example.com/activities/bounded",
4609
+ type: "Create",
4610
+ actor: "https://example.com/actor"
4611
+ });
4612
+ const size = 16 * 1024 * 1024;
4613
+ const federation = createFederation({
4614
+ kv: new MemoryKvStore(),
4615
+ skipSignatureVerification: true,
4616
+ contextLoaderFactory: () => mockDocumentLoader
4617
+ });
4618
+ federation.setActorDispatcher("/actors/{identifier}", () => new Person({ id: new URL("https://example.com/actor") }));
4619
+ federation.setInboxListeners("/actors/{identifier}/inbox", "/inbox").on(Create, () => {
4620
+ dispatched = true;
4621
+ });
4622
+ for (const contentLength of [
4623
+ void 0,
4624
+ "1",
4625
+ String(size + 1)
4626
+ ]) {
4627
+ assertEquals((await federation.fetch(new Request("https://example.com/inbox", {
4628
+ method: "POST",
4629
+ headers: contentLength == null ? {} : { "Content-Length": contentLength },
4630
+ body: json.padEnd(size + 1)
4631
+ }), { contextData: void 0 })).status, 413);
4632
+ assertFalse(dispatched);
4633
+ }
4634
+ let canceled = false;
4635
+ let pulls = 0;
4636
+ const body = new ReadableStream({
4637
+ pull(controller) {
4638
+ pulls++;
4639
+ controller.enqueue(new Uint8Array(64 * 1024));
4640
+ },
4641
+ cancel() {
4642
+ canceled = true;
4643
+ }
4644
+ }, { highWaterMark: 0 });
4645
+ const request = new Request("https://example.com/inbox", {
4646
+ method: "POST",
4647
+ body,
4648
+ duplex: "half"
4649
+ });
4650
+ assertEquals((await federation.fetch(request, { contextData: void 0 })).status, 413);
4651
+ await new Promise((resolve) => setTimeout(resolve, 0));
4652
+ assert(canceled);
4653
+ assert(pulls <= 260);
4654
+ assertFalse(dispatched);
4655
+ assertEquals((await federation.fetch(new Request("https://example.com/inbox", {
4656
+ method: "POST",
4657
+ body: json
4658
+ }), { contextData: void 0 })).status, 202);
4659
+ assert(dispatched);
4660
+ });
4573
4661
  //#endregion
4574
4662
  export {};
@@ -2,7 +2,7 @@ const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  require("../chunk-DDcVe30Y.cjs");
5
- const require_middleware = require("../middleware-CjrIRAsQ.cjs");
5
+ const require_middleware = require("../middleware-BDc7xyOx.cjs");
6
6
  let es_toolkit = require("es-toolkit");
7
7
  //#region src/federation/kv.ts
8
8
  /**
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { $ as ActorAliasMapper, A as FederationKvPrefixes, B as Router, C as IdempotencyKeyCallback, Ct as SendActivityError, D as ObjectCallbackSetters, Dt as digest, E as InboxListenerSetters, Et as buildCollectionSynchronizationHeader, F as RetryContext, G as respondWithObject, H as RouterOptions, I as RetryPolicy, J as InProcessMessageQueueOptions, K as respondWithObjectIfAcceptable, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, P as CreateExponentialBackoffPolicyOptions, Q as ParallelMessageQueue, R as Message, S as FederationStartQueueOptions, St as WebFingerLinksDispatcher, T as InboxChallengePolicy, Tt as PageItems, U as RouterRouteResult, V as RouterError, W as RespondWithObjectOptions, X as MessageQueueEnqueueOptions, Y as MessageQueue, Z as MessageQueueListenOptions, _ as Federatable, _t as OutboxListenerErrorHandler, a as GetSignedKeyOptions, at as CollectionCursor, b as FederationFetchOptions, bt as UnverifiedActivityHandler, c as ParseUriResult, ct as CustomCollectionCursor, d as SendActivityOptions, dt as InboxListener, et as ActorDispatcher, f as SendActivityOptionsForCollection, ft as NodeInfoDispatcher, g as CustomCollectionCallbackSetters, gt as OutboxListener, h as ConstructorWithTypeId, ht as OutboxErrorHandler, i as GetActorOptions, it as CollectionCounter, j as FederationOrigin, k as Rfc6570Expression, l as RequestContext, lt as CustomCollectionDispatcher, m as CollectionCallbackSetters, mt as ObjectDispatcher, n as Context, nt as ActorKeyPairsDispatcher, o as InboxContext, ot as CollectionDispatcher, p as ActorCallbackSetters, pt as ObjectAuthorizePredicate, q as InProcessMessageQueue, r as ForwardActivityOptions, rt as AuthorizePredicate, s as OutboxContext, st as CustomCollectionCounter, t as ActorKeyPair, tt as ActorHandleMapper, u as RouteActivityOptions, ut as InboxErrorHandler, v as Federation, vt as OutboxPermanentFailureHandler, w as IdempotencyStrategy, wt as SenderKeyPair, x as FederationOptions, xt as UnverifiedActivityReason, y as FederationBuilder, yt as SharedInboxKeyDispatcher, z as createFederationBuilder } from "../context-DVA8wHZ0.cjs";
2
+ import { $ as ActorAliasMapper, A as FederationKvPrefixes, B as Router, C as IdempotencyKeyCallback, Ct as SendActivityError, D as ObjectCallbackSetters, Dt as digest, E as InboxListenerSetters, Et as buildCollectionSynchronizationHeader, F as RetryContext, G as respondWithObject, H as RouterOptions, I as RetryPolicy, J as InProcessMessageQueueOptions, K as respondWithObjectIfAcceptable, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, P as CreateExponentialBackoffPolicyOptions, Q as ParallelMessageQueue, R as Message, S as FederationStartQueueOptions, St as WebFingerLinksDispatcher, T as InboxChallengePolicy, Tt as PageItems, U as RouterRouteResult, V as RouterError, W as RespondWithObjectOptions, X as MessageQueueEnqueueOptions, Y as MessageQueue, Z as MessageQueueListenOptions, _ as Federatable, _t as OutboxListenerErrorHandler, a as GetSignedKeyOptions, at as CollectionCursor, b as FederationFetchOptions, bt as UnverifiedActivityHandler, c as ParseUriResult, ct as CustomCollectionCursor, d as SendActivityOptions, dt as InboxListener, et as ActorDispatcher, f as SendActivityOptionsForCollection, ft as NodeInfoDispatcher, g as CustomCollectionCallbackSetters, gt as OutboxListener, h as ConstructorWithTypeId, ht as OutboxErrorHandler, i as GetActorOptions, it as CollectionCounter, j as FederationOrigin, k as Rfc6570Expression, l as RequestContext, lt as CustomCollectionDispatcher, m as CollectionCallbackSetters, mt as ObjectDispatcher, n as Context, nt as ActorKeyPairsDispatcher, o as InboxContext, ot as CollectionDispatcher, p as ActorCallbackSetters, pt as ObjectAuthorizePredicate, q as InProcessMessageQueue, r as ForwardActivityOptions, rt as AuthorizePredicate, s as OutboxContext, st as CustomCollectionCounter, t as ActorKeyPair, tt as ActorHandleMapper, u as RouteActivityOptions, ut as InboxErrorHandler, v as Federation, vt as OutboxPermanentFailureHandler, w as IdempotencyStrategy, wt as SenderKeyPair, x as FederationOptions, xt as UnverifiedActivityReason, y as FederationBuilder, yt as SharedInboxKeyDispatcher, z as createFederationBuilder } from "../context-Cls_M1HU.cjs";
3
3
  import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-gJ8LYbxX.cjs";
4
- import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-q-NFLW6B.cjs";
4
+ import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-DNvnDTS7.cjs";
5
5
  export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetActorOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { $ as ActorAliasMapper, A as FederationKvPrefixes, B as Router, C as IdempotencyKeyCallback, Ct as SendActivityError, D as ObjectCallbackSetters, Dt as digest, E as InboxListenerSetters, Et as buildCollectionSynchronizationHeader, F as RetryContext, G as respondWithObject, H as RouterOptions, I as RetryPolicy, J as InProcessMessageQueueOptions, K as respondWithObjectIfAcceptable, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, P as CreateExponentialBackoffPolicyOptions, Q as ParallelMessageQueue, R as Message, S as FederationStartQueueOptions, St as WebFingerLinksDispatcher, T as InboxChallengePolicy, Tt as PageItems, U as RouterRouteResult, V as RouterError, W as RespondWithObjectOptions, X as MessageQueueEnqueueOptions, Y as MessageQueue, Z as MessageQueueListenOptions, _ as Federatable, _t as OutboxListenerErrorHandler, a as GetSignedKeyOptions, at as CollectionCursor, b as FederationFetchOptions, bt as UnverifiedActivityHandler, c as ParseUriResult, ct as CustomCollectionCursor, d as SendActivityOptions, dt as InboxListener, et as ActorDispatcher, f as SendActivityOptionsForCollection, ft as NodeInfoDispatcher, g as CustomCollectionCallbackSetters, gt as OutboxListener, h as ConstructorWithTypeId, ht as OutboxErrorHandler, i as GetActorOptions, it as CollectionCounter, j as FederationOrigin, k as Rfc6570Expression, l as RequestContext, lt as CustomCollectionDispatcher, m as CollectionCallbackSetters, mt as ObjectDispatcher, n as Context, nt as ActorKeyPairsDispatcher, o as InboxContext, ot as CollectionDispatcher, p as ActorCallbackSetters, pt as ObjectAuthorizePredicate, q as InProcessMessageQueue, r as ForwardActivityOptions, rt as AuthorizePredicate, s as OutboxContext, st as CustomCollectionCounter, t as ActorKeyPair, tt as ActorHandleMapper, u as RouteActivityOptions, ut as InboxErrorHandler, v as Federation, vt as OutboxPermanentFailureHandler, w as IdempotencyStrategy, wt as SenderKeyPair, x as FederationOptions, xt as UnverifiedActivityReason, y as FederationBuilder, yt as SharedInboxKeyDispatcher, z as createFederationBuilder } from "../context-BU-1O90h.js";
2
+ import { $ as ActorAliasMapper, A as FederationKvPrefixes, B as Router, C as IdempotencyKeyCallback, Ct as SendActivityError, D as ObjectCallbackSetters, Dt as digest, E as InboxListenerSetters, Et as buildCollectionSynchronizationHeader, F as RetryContext, G as respondWithObject, H as RouterOptions, I as RetryPolicy, J as InProcessMessageQueueOptions, K as respondWithObjectIfAcceptable, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, P as CreateExponentialBackoffPolicyOptions, Q as ParallelMessageQueue, R as Message, S as FederationStartQueueOptions, St as WebFingerLinksDispatcher, T as InboxChallengePolicy, Tt as PageItems, U as RouterRouteResult, V as RouterError, W as RespondWithObjectOptions, X as MessageQueueEnqueueOptions, Y as MessageQueue, Z as MessageQueueListenOptions, _ as Federatable, _t as OutboxListenerErrorHandler, a as GetSignedKeyOptions, at as CollectionCursor, b as FederationFetchOptions, bt as UnverifiedActivityHandler, c as ParseUriResult, ct as CustomCollectionCursor, d as SendActivityOptions, dt as InboxListener, et as ActorDispatcher, f as SendActivityOptionsForCollection, ft as NodeInfoDispatcher, g as CustomCollectionCallbackSetters, gt as OutboxListener, h as ConstructorWithTypeId, ht as OutboxErrorHandler, i as GetActorOptions, it as CollectionCounter, j as FederationOrigin, k as Rfc6570Expression, l as RequestContext, lt as CustomCollectionDispatcher, m as CollectionCallbackSetters, mt as ObjectDispatcher, n as Context, nt as ActorKeyPairsDispatcher, o as InboxContext, ot as CollectionDispatcher, p as ActorCallbackSetters, pt as ObjectAuthorizePredicate, q as InProcessMessageQueue, r as ForwardActivityOptions, rt as AuthorizePredicate, s as OutboxContext, st as CustomCollectionCounter, t as ActorKeyPair, tt as ActorHandleMapper, u as RouteActivityOptions, ut as InboxErrorHandler, v as Federation, vt as OutboxPermanentFailureHandler, w as IdempotencyStrategy, wt as SenderKeyPair, x as FederationOptions, xt as UnverifiedActivityReason, y as FederationBuilder, yt as SharedInboxKeyDispatcher, z as createFederationBuilder } from "../context-Bt2jnbC7.js";
3
3
  import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-D6hNiMTK.js";
4
- import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-BVt6iTmH.js";
4
+ import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-DaiJDJdQ.js";
5
5
  export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetActorOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-DsEAPFhi.js";
3
+ import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-BDRZkGPG.js";
4
4
  import { isEqual } from "es-toolkit";
5
5
  //#region src/federation/kv.ts
6
6
  /**
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { n as assertGreater, r as assertGreaterOrEqual } from "../std__assert-CRDpx_HF.mjs";
6
6
  import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
7
- import { t as assert } from "../assert-DikXweDx.mjs";
7
+ import { t as assert } from "../assert-BhQd8QHP.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  import { delay } from "es-toolkit";
10
10
  //#region src/federation/mq.ts
@@ -3,8 +3,8 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import "../std__assert-CRDpx_HF.mjs";
5
5
  import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
6
- import { t as assert } from "../assert-DikXweDx.mjs";
7
- import { t as acceptsJsonLd } from "../negotiation-SQvQgUqe.mjs";
6
+ import { t as assert } from "../assert-BhQd8QHP.mjs";
7
+ import { t as acceptsJsonLd } from "../negotiation-BHtZN6Y1.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/federation/negotiation.test.ts
10
10
  test("acceptsJsonLd()", () => {
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { l as AssertionError, t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
6
- import { t as createExponentialBackoffPolicy } from "../retry-v_sGLH1d.mjs";
6
+ import { t as createExponentialBackoffPolicy } from "../retry-bMXBL97A.mjs";
7
7
  import { test } from "@fedify/fixture";
8
8
  //#region src/federation/retry.test.ts
9
9
  test("createExponentialBackoffPolicy()", () => {
@@ -5,8 +5,8 @@ import { n as RouterError, t as Router } from "../router-CrMLXoOr.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-CRDpx_HF.mjs";
7
7
  import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
8
+ import { t as assert } from "../assert-BhQd8QHP.mjs";
8
9
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
9
- import { t as assert } from "../assert-DikXweDx.mjs";
10
10
  import { test } from "@fedify/fixture";
11
11
  //#region src/federation/router.test.ts
12
12
  function setUp(options = {}) {
@@ -5,15 +5,15 @@ import { t as esm_default } from "../esm-DVILvP5e.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-CRDpx_HF.mjs";
7
7
  import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
8
- import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
8
+ import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
9
9
  import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
10
- import { t as assert } from "../assert-DikXweDx.mjs";
11
- import { l as verifyRequest } from "../http-79lZeYEo.mjs";
12
- import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
13
- import { t as doesActorOwnKey } from "../owner-CqYsVXcd.mjs";
14
- import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-CZwOs7XD.mjs";
10
+ import { l as verifyRequest } from "../http-B3V9unT4.mjs";
11
+ import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
12
+ import { t as doesActorOwnKey } from "../owner-DLbN_4jZ.mjs";
13
+ import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-B5QvdrZ1.mjs";
15
14
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
16
15
  import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
16
+ import { UrlError } from "@fedify/vocab-runtime";
17
17
  //#region src/federation/send.test.ts
18
18
  test("extractInboxes()", () => {
19
19
  const recipients = [
@@ -415,5 +415,137 @@ test("sendActivity() records OpenTelemetry span events", async (t) => {
415
415
  esm_default.hardReset();
416
416
  });
417
417
  });
418
+ for (const signed of [false, true]) {
419
+ const keys = [{
420
+ privateKey: signed ? rsaPrivateKey2 : ed25519PrivateKey,
421
+ keyId: signed ? rsaPublicKey2.id : ed25519Multikey.id
422
+ }];
423
+ test(`sendActivity() validates destinations (signed: ${signed})`, async (t) => {
424
+ const activity = {
425
+ type: "Create",
426
+ id: "https://example.com/activity"
427
+ };
428
+ const publicInbox = "https://8.8.8.8/inbox";
429
+ const privateInbox = "http://127.0.0.1/inbox";
430
+ for (const target of [
431
+ privateInbox,
432
+ "http://169.254.169.254/",
433
+ "http://[::1]/"
434
+ ]) await t.step(`rejects ${target} before fetching`, async () => {
435
+ esm_default.mockGlobal().catch(202);
436
+ try {
437
+ await assertRejects(() => sendActivity({
438
+ activity,
439
+ keys,
440
+ inbox: new URL(target)
441
+ }), UrlError);
442
+ assertEquals(esm_default.callHistory.calls().length, 0);
443
+ } finally {
444
+ esm_default.hardReset();
445
+ }
446
+ });
447
+ for (const status of [
448
+ 301,
449
+ 302,
450
+ 303,
451
+ 307,
452
+ 308
453
+ ]) for (const allowPrivateAddress of [false, true]) await t.step(`${status} private redirect, opt-in: ${allowPrivateAddress}`, async () => {
454
+ esm_default.mockGlobal();
455
+ esm_default.route(publicInbox, {
456
+ status,
457
+ headers: { Location: privateInbox }
458
+ });
459
+ esm_default.route(privateInbox, 202);
460
+ try {
461
+ const send = () => sendActivity({
462
+ activity,
463
+ keys,
464
+ inbox: new URL(publicInbox),
465
+ allowPrivateAddress
466
+ });
467
+ if (allowPrivateAddress) {
468
+ await send();
469
+ const calls = esm_default.callHistory.calls(privateInbox);
470
+ assertEquals(calls.length, 1);
471
+ const request = calls[0].request;
472
+ const preservesBody = signed || status === 307 || status === 308;
473
+ assertEquals(request.method, preservesBody ? "POST" : "GET");
474
+ assertEquals(await request.clone().text(), preservesBody ? JSON.stringify(activity) : "");
475
+ } else {
476
+ await assertRejects(send, UrlError);
477
+ assertEquals(esm_default.callHistory.calls(privateInbox).length, 0);
478
+ }
479
+ } finally {
480
+ esm_default.hardReset();
481
+ }
482
+ });
483
+ await t.step("rejects a private destination after a public redirect", async () => {
484
+ esm_default.mockGlobal().route(publicInbox, {
485
+ status: 307,
486
+ headers: { Location: "/next" }
487
+ }).route("https://8.8.8.8/next", {
488
+ status: 308,
489
+ headers: { Location: privateInbox }
490
+ }).route(privateInbox, 202);
491
+ try {
492
+ await assertRejects(() => sendActivity({
493
+ activity,
494
+ keys,
495
+ inbox: new URL(publicInbox)
496
+ }), UrlError);
497
+ assertEquals(esm_default.callHistory.calls(privateInbox).length, 0);
498
+ } finally {
499
+ esm_default.hardReset();
500
+ }
501
+ });
502
+ await t.step("limits redirect loops", async () => {
503
+ esm_default.mockGlobal().route(publicInbox, {
504
+ status: 307,
505
+ headers: { Location: publicInbox }
506
+ });
507
+ try {
508
+ await assertRejects(() => sendActivity({
509
+ activity,
510
+ keys,
511
+ inbox: new URL(publicInbox)
512
+ }));
513
+ assert(esm_default.callHistory.calls().length <= 21);
514
+ } finally {
515
+ esm_default.hardReset();
516
+ }
517
+ });
518
+ await t.step("allows a direct private inbox with opt-in", async () => {
519
+ esm_default.mockGlobal().route(privateInbox, 202);
520
+ try {
521
+ await sendActivity({
522
+ activity,
523
+ keys,
524
+ inbox: new URL(privateInbox),
525
+ allowPrivateAddress: true
526
+ });
527
+ assertEquals(esm_default.callHistory.calls(privateInbox).length, 1);
528
+ } finally {
529
+ esm_default.hardReset();
530
+ }
531
+ });
532
+ await t.step("allows relative public redirects", async () => {
533
+ esm_default.mockGlobal().route(publicInbox, {
534
+ status: 307,
535
+ headers: { Location: "/next" }
536
+ }).route("https://8.8.8.8/next", 202);
537
+ try {
538
+ await sendActivity({
539
+ activity,
540
+ keys,
541
+ inbox: new URL(publicInbox)
542
+ });
543
+ assertEquals(esm_default.callHistory.calls("https://8.8.8.8/next").length, 1);
544
+ } finally {
545
+ esm_default.hardReset();
546
+ }
547
+ });
548
+ });
549
+ }
418
550
  //#endregion
419
551
  export {};
@@ -3,8 +3,8 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import "../std__assert-CRDpx_HF.mjs";
5
5
  import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
6
- import { t as assert } from "../assert-DikXweDx.mjs";
7
- import { t as hasMalformedKnownTemporalLiteral } from "../temporal-BYCnXIGk.mjs";
6
+ import { t as assert } from "../assert-BhQd8QHP.mjs";
7
+ import { t as hasMalformedKnownTemporalLiteral } from "../temporal-CFLRXAcm.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/federation/temporal.test.ts
10
10
  test("hasMalformedKnownTemporalLiteral() detects expanded proof timestamps", async () => {
@@ -4,8 +4,8 @@ globalThis.addEventListener = () => {};
4
4
  import { r as createRequestContext } from "../context-Dk_tacqz.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-CRDpx_HF.mjs";
7
- import { t as MemoryKvStore } from "../kv-rV3vodCc.mjs";
8
- import { o as createFederation, s as handleWebFinger } from "../middleware-D5NE6PkU.mjs";
7
+ import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
8
+ import { o as createFederation, s as handleWebFinger } from "../middleware-BsDiZP9H.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  import { Image, Link, Person, Tombstone } from "@fedify/vocab";
11
11
  //#region src/federation/webfinger.test.ts
@@ -1,9 +1,9 @@
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-DeYUdFal.mjs";
5
- import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-CPkZzmGN.mjs";
6
- import { o as validateCryptoKey, r as fetchKeyDetailed } from "./key-B4kUuy3o.mjs";
4
+ import { n as version, t as name } from "./deno-Cg_cZHcI.mjs";
5
+ import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-Dd__NiUL.mjs";
6
+ import { i as fetchKeyDetailed, s as validateCryptoKey } from "./key-CLRfRmA_.mjs";
7
7
  import { CryptographicKey } from "@fedify/vocab";
8
8
  import { SpanStatusCode, trace } from "@opentelemetry/api";
9
9
  import { FetchError } from "@fedify/vocab-runtime";