@fedify/fedify 2.3.16-dev.2841 → 2.3.16

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 (108) hide show
  1. package/dist/attachment-arrays-BlfpZlWF.mjs +16 -0
  2. package/dist/{builder-G4wSHQX-.mjs → builder-D4GE1Gmi.mjs} +3 -3
  3. package/dist/callback-kR_sx2zZ.d.mts +2661 -0
  4. package/dist/{client-BIBzqEIp.d.cts → client-9DPcy_Yx.d.ts} +16 -0
  5. package/dist/{client-jE7oGvRh.d.ts → client-B3ruDgWg.d.cts} +16 -0
  6. package/dist/{client-DpUNYKla.mjs → client-DFgYVbUA.mjs} +86 -11
  7. package/dist/compat/attachment-arrays.test.d.mts +2 -0
  8. package/dist/compat/attachment-arrays.test.mjs +255 -0
  9. package/dist/compat/mod.d.cts +1 -1
  10. package/dist/compat/mod.d.ts +1 -1
  11. package/dist/compat/outgoing-jsonld.test.mjs +1 -1
  12. package/dist/compat/public-audience.test.mjs +1 -1
  13. package/dist/compat/transformers.test.mjs +1 -1
  14. package/dist/{context-CE_Tj_Oc.d.cts → context-CEE8vl-b.d.cts} +31 -14
  15. package/dist/{context-H_5tZXg-.d.ts → context-CTJwXHRu.d.ts} +31 -14
  16. package/dist/{deno-DmDVx5sE.mjs → deno-FtdqgHJA.mjs} +1 -1
  17. package/dist/{docloader-0fjyUmvI.mjs → docloader-B9iU4DP2.mjs} +2 -2
  18. package/dist/federation/attachment-responses.test.d.mts +2 -0
  19. package/dist/federation/attachment-responses.test.mjs +182 -0
  20. package/dist/federation/builder.test.mjs +1 -1
  21. package/dist/federation/circuit-breaker.test.mjs +2 -2
  22. package/dist/federation/collection.test.mjs +1 -1
  23. package/dist/federation/delivery-attachments.test.d.mts +2 -0
  24. package/dist/federation/delivery-attachments.test.mjs +288 -0
  25. package/dist/federation/handler.test.mjs +208 -16
  26. package/dist/federation/idempotency.test.mjs +2 -2
  27. package/dist/federation/inbox.test.mjs +2 -2
  28. package/dist/federation/metrics.test.mjs +1 -1
  29. package/dist/federation/middleware.test.mjs +1191 -16
  30. package/dist/federation/mod.cjs +1 -1
  31. package/dist/federation/mod.d.cts +2 -2
  32. package/dist/federation/mod.d.ts +2 -2
  33. package/dist/federation/mod.js +1 -1
  34. package/dist/federation/negotiation.test.mjs +1 -1
  35. package/dist/federation/retry.test.mjs +1 -1
  36. package/dist/federation/send.test.mjs +293 -3
  37. package/dist/federation/temporal.test.mjs +25 -1
  38. package/dist/federation/webfinger.test.mjs +1 -1
  39. package/dist/{http-CKX94hfh.cjs → http-2RyDQ0tE.cjs} +6 -4
  40. package/dist/{http-DmP0sr2l.d.ts → http-Bs5mXWlH.d.ts} +3 -3
  41. package/dist/{http-CZPYFK3b.d.cts → http-D8DgRhHU.d.cts} +3 -3
  42. package/dist/{http-DCK-QQfE.mjs → http-D8tiOrZf.mjs} +7 -5
  43. package/dist/{http-DwIMsxu9.js → http-mLeLYFj-.js} +6 -4
  44. package/dist/{inbox-Bx6PCMeE.mjs → inbox-Dy8awbi8.mjs} +2 -2
  45. package/dist/{key-SkLDUmPM.mjs → key-o1SmN5s0.mjs} +4 -3
  46. package/dist/{kv-cache-BaJOO6O3.mjs → kv-cache-BwUrzCVO.mjs} +1 -1
  47. package/dist/{kv-cache-BnZ4KLMY.cjs → kv-cache-CI6Z0WiS.cjs} +1 -1
  48. package/dist/{kv-cache-xIexNacM.js → kv-cache-Dsq8C8D8.js} +1 -1
  49. package/dist/{ld-DUG6cq9q.mjs → ld-DCKrqj9y.mjs} +155 -22
  50. package/dist/ld-signature-Dgz_b89j.mjs +23 -0
  51. package/dist/{metrics-D3OnAgfj.mjs → metrics-CaoYRhNH.mjs} +1 -1
  52. package/dist/{middleware-CUwjLKp3.mjs → middleware-4p3opEMT.mjs} +1 -1
  53. package/dist/{middleware-C9RexCTx.cjs → middleware-CP-8P7kk.cjs} +492 -117
  54. package/dist/{middleware-DU2jy5eY.js → middleware-Cce0nLDw.js} +491 -117
  55. package/dist/{middleware-zEy-wJYI.mjs → middleware-D31fNcY4.mjs} +399 -109
  56. package/dist/{mod-C_gFmeNq.d.cts → mod-BD0-_vya.d.ts} +31 -13
  57. package/dist/{mod-HQXFvOHs.d.ts → mod-BMX6nsHP.d.cts} +31 -13
  58. package/dist/{mod-CDFFESfL.d.ts → mod-BTvP5Hva.d.ts} +1 -1
  59. package/dist/{mod-DMjhnFbg.d.ts → mod-DgMTlwUO.d.ts} +3 -3
  60. package/dist/{mod-DDVkmZ_h.d.cts → mod-Q1Fo3FJk.d.cts} +3 -3
  61. package/dist/{mod-DDjtbkZO.d.cts → mod-n51LED4J.d.cts} +1 -1
  62. package/dist/mod.cjs +5 -5
  63. package/dist/mod.d.cts +8 -8
  64. package/dist/mod.d.ts +8 -8
  65. package/dist/mod.js +5 -5
  66. package/dist/nodeinfo/client.test.mjs +432 -4
  67. package/dist/nodeinfo/handler.test.mjs +1 -1
  68. package/dist/nodeinfo/mod.cjs +1 -1
  69. package/dist/nodeinfo/mod.d.cts +1 -1
  70. package/dist/nodeinfo/mod.d.ts +1 -1
  71. package/dist/nodeinfo/mod.js +1 -1
  72. package/dist/nodeinfo/types.test.mjs +1 -1
  73. package/dist/{outgoing-jsonld-D4iTv7uM.mjs → outgoing-jsonld-BZEAVK_Q.mjs} +38 -8
  74. package/dist/{owner-Baf_LRb2.mjs → owner-Bdj0nHhf.mjs} +2 -2
  75. package/dist/{proof-CNGy7TJL.js → proof-B9XJiyz-.js} +1030 -858
  76. package/dist/{proof-BdAFbOFg.cjs → proof-CmcP8yqP.cjs} +1243 -1059
  77. package/dist/{proof-LTsbjXnQ.mjs → proof-DrbjYma9.mjs} +41 -16
  78. package/dist/{send-DOf5y1nB.mjs → send-VD_WG3dN.mjs} +100 -22
  79. package/dist/sig/http.test.mjs +2 -2
  80. package/dist/sig/key-types.test.d.mts +218 -0
  81. package/dist/sig/key-types.test.mjs +8 -0
  82. package/dist/sig/key.test.mjs +2 -2
  83. package/dist/sig/ld.test.mjs +573 -8
  84. package/dist/sig/mod.cjs +2 -2
  85. package/dist/sig/mod.d.cts +3 -3
  86. package/dist/sig/mod.d.ts +3 -3
  87. package/dist/sig/mod.js +2 -2
  88. package/dist/sig/owner.test.mjs +1 -1
  89. package/dist/sig/proof.test.mjs +96 -4
  90. package/dist/{temporal-fl4sM1Gs.mjs → temporal-CMvoB-vD.mjs} +3 -5
  91. package/dist/testing/mod.d.mts +2 -2476
  92. package/dist/{types-DOvyymM4.cjs → types-BWx7zw3Y.cjs} +85 -10
  93. package/dist/{types-B1_pRFE_.js → types-Dx_w2JSM.js} +86 -11
  94. package/dist/utils/docloader.test.mjs +2 -2
  95. package/dist/utils/kv-cache.test.mjs +1 -1
  96. package/dist/utils/mod.cjs +1 -1
  97. package/dist/utils/mod.d.cts +1 -1
  98. package/dist/utils/mod.d.ts +1 -1
  99. package/dist/utils/mod.js +1 -1
  100. package/package.json +7 -7
  101. /package/dist/{activity-listener-tztVvlNb.mjs → activity-listener-BeTGV3wc.mjs} +0 -0
  102. /package/dist/{circuit-breaker-D1fxthDI.mjs → circuit-breaker-B1fLHmg2.mjs} +0 -0
  103. /package/dist/{circuit-breaker-test-utils-CAdwjgMi.mjs → circuit-breaker-test-utils-BGHm_MsT.mjs} +0 -0
  104. /package/dist/{collection-Cc3DVAhE.mjs → collection-Dp5ky45w.mjs} +0 -0
  105. /package/dist/{negotiation-DDstyBvc.mjs → negotiation-DC8nG6J_.mjs} +0 -0
  106. /package/dist/{public-audience-Dp4ZScSr.mjs → public-audience-rnYUGj8a.mjs} +0 -0
  107. /package/dist/{retry-CXg_MBI-.mjs → retry-C4G_vIgv.mjs} +0 -0
  108. /package/dist/{types-J53Kw7so.mjs → types-BFowWFTT.mjs} +0 -0
@@ -1,11 +1,11 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-BIBzqEIp.cjs";
3
- import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-CZPYFK3b.cjs";
2
+ import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-B3ruDgWg.cjs";
3
+ import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-D8DgRhHU.cjs";
4
4
  import { n as GetKeyOwnerOptions } from "./owner-B3hNQCG8.cjs";
5
5
  import { n as KvStore, t as KvKey } from "./kv-CZKl1IUS.cjs";
6
6
  import { r as MessageQueue } from "./mq-D8uSFzxe.cjs";
7
7
  import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
8
- import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
8
+ import { AuthenticatedDocumentLoaderFactory, CryptoKeyLike, CryptoKeyPairLike, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
9
9
  import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
10
10
  import { MeterProvider, Span, Tracer, TracerProvider } from "@opentelemetry/api";
11
11
  //#region src/compat/types.d.ts
@@ -235,13 +235,18 @@ declare function buildCollectionSynchronizationHeader(collectionId: string | URL
235
235
  //#region src/federation/send.d.ts
236
236
  /**
237
237
  * A key pair for an actor who sends an activity.
238
+ *
239
+ * The private key type is parameterized so that Fedify can accept keys from
240
+ * `node:crypto` at its input boundaries while `SenderKeyPair` still exposes the
241
+ * ambient `CryptoKey` type by default.
242
+ * @template TKey The type of the private key.
238
243
  * @since 0.10.0
239
244
  */
240
- interface SenderKeyPair {
245
+ interface SenderKeyPair<TKey extends CryptoKeyLike = CryptoKey> {
241
246
  /**
242
247
  * The actor's private key to sign the request.
243
248
  */
244
- readonly privateKey: CryptoKey;
249
+ readonly privateKey: TKey;
245
250
  /**
246
251
  * The public key ID that corresponds to the private key.
247
252
  */
@@ -311,13 +316,19 @@ type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, ide
311
316
  /**
312
317
  * A callback that dispatches key pairs for an actor.
313
318
  *
319
+ * The returned key pairs may come from any supported runtime, including keys
320
+ * obtained from `node:crypto`'s Web Crypto API, so the key pair type is
321
+ * parameterized. It defaults to the ambient `CryptoKeyPair` type for
322
+ * compatibility with code that calls a dispatcher directly.
323
+ *
314
324
  * @template TContextData The context data to pass to the {@link Context}.
325
+ * @template TKeyPair The type of the key pairs the dispatcher returns.
315
326
  * @param context The context.
316
327
  * @param identifier The actor's internal identifier or username.
317
328
  * @returns The key pairs.
318
329
  * @since 0.10.0
319
330
  */
320
- type ActorKeyPairsDispatcher<TContextData> = (context: Context<TContextData>, identifier: string) => CryptoKeyPair[] | Promise<CryptoKeyPair[]>;
331
+ type ActorKeyPairsDispatcher<TContextData, TKeyPair extends CryptoKeyPairLike = CryptoKeyPair> = (context: Context<TContextData>, identifier: string) => TKeyPair[] | Promise<TKeyPair[]>;
321
332
  /**
322
333
  * A callback that maps a WebFinger username to the corresponding actor's
323
334
  * internal identifier, or `null` if the username is not found.
@@ -466,11 +477,11 @@ type OutboxListenerErrorHandler<TContextData> = (context: OutboxContext<TContext
466
477
  * not authorized.
467
478
  * @since 0.11.0
468
479
  */
469
- type SharedInboxKeyDispatcher<TContextData> = (context: Context<TContextData>) => SenderKeyPair | {
480
+ type SharedInboxKeyDispatcher<TContextData, TKeyPair extends CryptoKeyLike = CryptoKey> = (context: Context<TContextData>) => SenderKeyPair<TKeyPair> | {
470
481
  identifier: string;
471
482
  } | {
472
483
  username: string;
473
- } | null | Promise<SenderKeyPair | {
484
+ } | null | Promise<SenderKeyPair<TKeyPair> | {
474
485
  identifier: string;
475
486
  } | {
476
487
  username: string;
@@ -1483,6 +1494,12 @@ interface FederationOptions<TContextData> {
1483
1494
  *
1484
1495
  * By default, the queue starts automatically.
1485
1496
  *
1497
+ * Automatic startup is best-effort: if a queue cannot start listening,
1498
+ * a warning is logged once per federation instance and the failed worker is
1499
+ * not retried, while an explicit {@link Federation.startQueue} call rejects.
1500
+ * Runtimes that consume the queue elsewhere, such as Cloudflare Workers with
1501
+ * {@link Federation.processQueuedTask}, should set this to `true`.
1502
+ *
1486
1503
  * @since 0.12.0
1487
1504
  */
1488
1505
  manuallyStartQueue?: boolean;
@@ -1687,7 +1704,7 @@ interface ActorCallbackSetters<TContextData> {
1687
1704
  * @returns The setters object so that settings can be chained.
1688
1705
  * @since 0.10.0
1689
1706
  */
1690
- setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
1707
+ setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData, CryptoKeyPairLike>): ActorCallbackSetters<TContextData>;
1691
1708
  /**
1692
1709
  * Sets the callback function that maps a WebFinger username to
1693
1710
  * the corresponding actor's identifier. If it's omitted, the identifier
@@ -1898,7 +1915,7 @@ interface InboxListenerSetters<TContextData> {
1898
1915
  * @returns The setters object so that settings can be chained.
1899
1916
  * @since 0.11.0
1900
1917
  */
1901
- setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData>): InboxListenerSetters<TContextData>;
1918
+ setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData, CryptoKeyLike>): InboxListenerSetters<TContextData>;
1902
1919
  /**
1903
1920
  * Configures the strategy for handling activity idempotency in inbox processing.
1904
1921
  *
@@ -2236,7 +2253,7 @@ interface Context<TContextData> {
2236
2253
  */
2237
2254
  getDocumentLoader(identity: {
2238
2255
  keyId: URL;
2239
- privateKey: CryptoKey;
2256
+ privateKey: CryptoKeyLike;
2240
2257
  }): DocumentLoader;
2241
2258
  /**
2242
2259
  * Looks up an ActivityStreams object by its URI (including `acct:` URIs)
@@ -2349,7 +2366,7 @@ interface Context<TContextData> {
2349
2366
  * @param activity The activity to send.
2350
2367
  * @param options Options for sending the activity.
2351
2368
  */
2352
- sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
2369
+ sendActivity(sender: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
2353
2370
  identifier: string;
2354
2371
  } | {
2355
2372
  username: string;
@@ -2622,7 +2639,7 @@ interface InboxContext<TContextData> extends Context<TContextData> {
2622
2639
  * @param options Options for forwarding the activity.
2623
2640
  * @since 1.0.0
2624
2641
  */
2625
- forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
2642
+ forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
2626
2643
  identifier: string;
2627
2644
  } | {
2628
2645
  username: string;
@@ -2680,7 +2697,7 @@ interface OutboxContext<TContextData> extends Context<TContextData> {
2680
2697
  * @param options Options for forwarding the activity.
2681
2698
  * @since 2.2.0
2682
2699
  */
2683
- forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
2700
+ forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
2684
2701
  identifier: string;
2685
2702
  } | {
2686
2703
  username: string;
@@ -1,13 +1,13 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-jE7oGvRh.js";
3
- import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-DmP0sr2l.js";
2
+ import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-9DPcy_Yx.js";
3
+ import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-Bs5mXWlH.js";
4
4
  import { n as GetKeyOwnerOptions } from "./owner-CiBPcC6F.js";
5
5
  import { n as KvStore, t as KvKey } from "./kv-CxaI4eGo.js";
6
6
  import { r as MessageQueue } from "./mq-D-nlpY04.js";
7
7
  import { Router } from "@fedify/uri-template";
8
8
  import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
9
9
  import { MeterProvider, Span, Tracer, TracerProvider } from "@opentelemetry/api";
10
- import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
10
+ import { AuthenticatedDocumentLoaderFactory, CryptoKeyLike, CryptoKeyPairLike, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
11
11
  import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
12
12
  import { MeterProvider as MeterProvider$1, MetricReader } from "@opentelemetry/sdk-metrics";
13
13
 
@@ -238,13 +238,18 @@ declare function buildCollectionSynchronizationHeader(collectionId: string | URL
238
238
  //#region src/federation/send.d.ts
239
239
  /**
240
240
  * A key pair for an actor who sends an activity.
241
+ *
242
+ * The private key type is parameterized so that Fedify can accept keys from
243
+ * `node:crypto` at its input boundaries while `SenderKeyPair` still exposes the
244
+ * ambient `CryptoKey` type by default.
245
+ * @template TKey The type of the private key.
241
246
  * @since 0.10.0
242
247
  */
243
- interface SenderKeyPair {
248
+ interface SenderKeyPair<TKey extends CryptoKeyLike = CryptoKey> {
244
249
  /**
245
250
  * The actor's private key to sign the request.
246
251
  */
247
- readonly privateKey: CryptoKey;
252
+ readonly privateKey: TKey;
248
253
  /**
249
254
  * The public key ID that corresponds to the private key.
250
255
  */
@@ -314,13 +319,19 @@ type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, ide
314
319
  /**
315
320
  * A callback that dispatches key pairs for an actor.
316
321
  *
322
+ * The returned key pairs may come from any supported runtime, including keys
323
+ * obtained from `node:crypto`'s Web Crypto API, so the key pair type is
324
+ * parameterized. It defaults to the ambient `CryptoKeyPair` type for
325
+ * compatibility with code that calls a dispatcher directly.
326
+ *
317
327
  * @template TContextData The context data to pass to the {@link Context}.
328
+ * @template TKeyPair The type of the key pairs the dispatcher returns.
318
329
  * @param context The context.
319
330
  * @param identifier The actor's internal identifier or username.
320
331
  * @returns The key pairs.
321
332
  * @since 0.10.0
322
333
  */
323
- type ActorKeyPairsDispatcher<TContextData> = (context: Context<TContextData>, identifier: string) => CryptoKeyPair[] | Promise<CryptoKeyPair[]>;
334
+ type ActorKeyPairsDispatcher<TContextData, TKeyPair extends CryptoKeyPairLike = CryptoKeyPair> = (context: Context<TContextData>, identifier: string) => TKeyPair[] | Promise<TKeyPair[]>;
324
335
  /**
325
336
  * A callback that maps a WebFinger username to the corresponding actor's
326
337
  * internal identifier, or `null` if the username is not found.
@@ -469,11 +480,11 @@ type OutboxListenerErrorHandler<TContextData> = (context: OutboxContext<TContext
469
480
  * not authorized.
470
481
  * @since 0.11.0
471
482
  */
472
- type SharedInboxKeyDispatcher<TContextData> = (context: Context<TContextData>) => SenderKeyPair | {
483
+ type SharedInboxKeyDispatcher<TContextData, TKeyPair extends CryptoKeyLike = CryptoKey> = (context: Context<TContextData>) => SenderKeyPair<TKeyPair> | {
473
484
  identifier: string;
474
485
  } | {
475
486
  username: string;
476
- } | null | Promise<SenderKeyPair | {
487
+ } | null | Promise<SenderKeyPair<TKeyPair> | {
477
488
  identifier: string;
478
489
  } | {
479
490
  username: string;
@@ -1486,6 +1497,12 @@ interface FederationOptions<TContextData> {
1486
1497
  *
1487
1498
  * By default, the queue starts automatically.
1488
1499
  *
1500
+ * Automatic startup is best-effort: if a queue cannot start listening,
1501
+ * a warning is logged once per federation instance and the failed worker is
1502
+ * not retried, while an explicit {@link Federation.startQueue} call rejects.
1503
+ * Runtimes that consume the queue elsewhere, such as Cloudflare Workers with
1504
+ * {@link Federation.processQueuedTask}, should set this to `true`.
1505
+ *
1489
1506
  * @since 0.12.0
1490
1507
  */
1491
1508
  manuallyStartQueue?: boolean;
@@ -1690,7 +1707,7 @@ interface ActorCallbackSetters<TContextData> {
1690
1707
  * @returns The setters object so that settings can be chained.
1691
1708
  * @since 0.10.0
1692
1709
  */
1693
- setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
1710
+ setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData, CryptoKeyPairLike>): ActorCallbackSetters<TContextData>;
1694
1711
  /**
1695
1712
  * Sets the callback function that maps a WebFinger username to
1696
1713
  * the corresponding actor's identifier. If it's omitted, the identifier
@@ -1901,7 +1918,7 @@ interface InboxListenerSetters<TContextData> {
1901
1918
  * @returns The setters object so that settings can be chained.
1902
1919
  * @since 0.11.0
1903
1920
  */
1904
- setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData>): InboxListenerSetters<TContextData>;
1921
+ setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData, CryptoKeyLike>): InboxListenerSetters<TContextData>;
1905
1922
  /**
1906
1923
  * Configures the strategy for handling activity idempotency in inbox processing.
1907
1924
  *
@@ -2239,7 +2256,7 @@ interface Context<TContextData> {
2239
2256
  */
2240
2257
  getDocumentLoader(identity: {
2241
2258
  keyId: URL;
2242
- privateKey: CryptoKey;
2259
+ privateKey: CryptoKeyLike;
2243
2260
  }): DocumentLoader;
2244
2261
  /**
2245
2262
  * Looks up an ActivityStreams object by its URI (including `acct:` URIs)
@@ -2352,7 +2369,7 @@ interface Context<TContextData> {
2352
2369
  * @param activity The activity to send.
2353
2370
  * @param options Options for sending the activity.
2354
2371
  */
2355
- sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
2372
+ sendActivity(sender: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
2356
2373
  identifier: string;
2357
2374
  } | {
2358
2375
  username: string;
@@ -2625,7 +2642,7 @@ interface InboxContext<TContextData> extends Context<TContextData> {
2625
2642
  * @param options Options for forwarding the activity.
2626
2643
  * @since 1.0.0
2627
2644
  */
2628
- forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
2645
+ forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
2629
2646
  identifier: string;
2630
2647
  } | {
2631
2648
  username: string;
@@ -2683,7 +2700,7 @@ interface OutboxContext<TContextData> extends Context<TContextData> {
2683
2700
  * @param options Options for forwarding the activity.
2684
2701
  * @since 2.2.0
2685
2702
  */
2686
- forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
2703
+ forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
2687
2704
  identifier: string;
2688
2705
  } | {
2689
2706
  username: string;
@@ -3,6 +3,6 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  //#region deno.json
5
5
  var name = "@fedify/fedify";
6
- var version = "2.3.16-dev.2841+a3847aa4";
6
+ var version = "2.3.16";
7
7
  //#endregion
8
8
  export { version as n, name as t };
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { s as validateCryptoKey } from "./key-SkLDUmPM.mjs";
5
- import { r as doubleKnockScoped } from "./http-DCK-QQfE.mjs";
4
+ import { s as validateCryptoKey } from "./key-o1SmN5s0.mjs";
5
+ import { r as doubleKnockScoped } from "./http-D8tiOrZf.mjs";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  import { FetchError, UrlError, createActivityPubRequest, getRemoteDocument, logRequest } from "@fedify/vocab-runtime";
8
8
  import { openDirectFetch, openPublicFetch } from "@fedify/vocab-runtime/internal";
@@ -0,0 +1,2 @@
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
@@ -0,0 +1,182 @@
1
+ import "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
3
+ globalThis.addEventListener = () => {};
4
+ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
+ import "../std__assert-BjJn2daJ.mjs";
6
+ import { t as assert } from "../assert-CEO06XCw.mjs";
7
+ import { n as ed25519PrivateKey, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
8
+ import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
9
+ import { a as verifyProof, r as signObject } from "../proof-DrbjYma9.mjs";
10
+ import { h as respondWithObjectIfAcceptable, m as respondWithObject, o as createFederation } from "../middleware-D31fNcY4.mjs";
11
+ import { Note, Object as Object$1, OrderedCollection, PropertyValue, Service, Update } from "@fedify/vocab";
12
+ import { mockDocumentLoader, test } from "@fedify/fixture";
13
+ //#region src/federation/attachment-responses.test.ts
14
+ const ACCEPTS = ["application/activity+json", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""];
15
+ function profile(count) {
16
+ return new Service({
17
+ id: new URL("https://example.com/actors/app"),
18
+ preferredUsername: "app",
19
+ attachments: Array.from({ length: count }, (_, i) => new PropertyValue({
20
+ name: `Field ${i}`,
21
+ value: `https://example.com/${i}`
22
+ }))
23
+ });
24
+ }
25
+ function attachmentValues(value) {
26
+ if (Array.isArray(value)) return value.flatMap(attachmentValues);
27
+ if (typeof value !== "object" || value == null) return [];
28
+ return Object.entries(value).flatMap(([key, item]) => key === "@context" ? [] : key === "attachment" ? [item] : attachmentValues(item));
29
+ }
30
+ test("attachment responses: actor, object, collections and pages negotiate both media types", async () => {
31
+ for (const count of [1, 2]) {
32
+ const actor = profile(count);
33
+ const update = new Update({
34
+ id: new URL("https://example.com/updates/1"),
35
+ actor: actor.id,
36
+ object: actor
37
+ });
38
+ const federation = createFederation({ kv: new MemoryKvStore() });
39
+ federation.setActorDispatcher("/actors/{identifier}", () => actor);
40
+ federation.setObjectDispatcher(Note, "/notes/{id}", () => new Note({ attachments: Array.from({ length: count }, () => new Note({ content: "attachment" })) }));
41
+ federation.setFollowersDispatcher("/actors/{identifier}/followers", () => ({ items: [actor] }));
42
+ federation.setCollectionDispatcher("objects", Object$1, "/collections/{id}", () => ({ items: [update] }));
43
+ federation.setOrderedCollectionDispatcher("ordered", Object$1, "/ordered/{id}", () => ({ items: [update] }));
44
+ for (const accept of ACCEPTS) for (const path of [
45
+ "/actors/app",
46
+ "/notes/1",
47
+ "/actors/app/followers",
48
+ "/actors/app/followers?cursor=a",
49
+ "/collections/1",
50
+ "/collections/1?cursor=a",
51
+ "/ordered/1",
52
+ "/ordered/1?cursor=a"
53
+ ]) {
54
+ const response = await federation.fetch(new Request(`https://example.com${path}`, { headers: { Accept: accept } }), { contextData: void 0 });
55
+ assertEquals(response.status, 200, path);
56
+ assertEquals(response.headers.get("Content-Type"), "application/activity+json");
57
+ assertEquals(response.headers.get("Vary"), "Accept");
58
+ const values = attachmentValues(await response.json());
59
+ assert(values.length > 0, path);
60
+ for (const value of values) {
61
+ assert(Array.isArray(value), path);
62
+ assertEquals(value.length, count, path);
63
+ }
64
+ }
65
+ }
66
+ });
67
+ test("attachment responses: helpers normalize without changing the vocabulary cache", async () => {
68
+ const json = await profile(1).toJsonLd();
69
+ const actor = await Service.fromJsonLd(json, { contextLoader: mockDocumentLoader });
70
+ const before = structuredClone(await actor.toJsonLd());
71
+ for (const options of [void 0, { contextLoader: mockDocumentLoader }]) {
72
+ const response = await respondWithObject(actor, options);
73
+ assert(Array.isArray((await response.json()).attachment));
74
+ for (const accept of ACCEPTS) {
75
+ const acceptable = await respondWithObjectIfAcceptable(actor, new Request("https://example.com/", { headers: { Accept: accept } }), options);
76
+ assert(acceptable != null);
77
+ assert(Array.isArray((await acceptable.json()).attachment));
78
+ assertEquals(acceptable.headers.get("Vary"), "Accept");
79
+ }
80
+ }
81
+ assertEquals(await actor.toJsonLd(), before);
82
+ assertEquals(await respondWithObjectIfAcceptable(actor, new Request("https://example.com/", { headers: { Accept: "text/html" } })), null);
83
+ });
84
+ test("attachment responses: cached actor with deep JSON data remains servable", async () => {
85
+ let data = "leaf";
86
+ for (let i = 0; i < 70; i++) data = { child: data };
87
+ const original = {
88
+ "@context": ["https://www.w3.org/ns/activitystreams", { data: {
89
+ "@id": "https://example.com/data",
90
+ "@type": "@json"
91
+ } }],
92
+ type: "Service",
93
+ id: "https://example.com/actors/app",
94
+ preferredUsername: "app",
95
+ attachment: {
96
+ type: "Note",
97
+ content: "cached attachment"
98
+ },
99
+ data
100
+ };
101
+ const actor = await Service.fromJsonLd(original, { contextLoader: mockDocumentLoader });
102
+ const before = structuredClone(await actor.toJsonLd());
103
+ const federation = createFederation({ kv: new MemoryKvStore() });
104
+ federation.setActorDispatcher("/actors/{identifier}", () => actor);
105
+ for (const accept of ACCEPTS) {
106
+ const response = await federation.fetch(new Request("https://example.com/actors/app", { headers: { Accept: accept } }), { contextData: void 0 });
107
+ assertEquals(response.status, 200);
108
+ assertEquals(await response.json(), before);
109
+ }
110
+ assertEquals(await actor.toJsonLd(), before);
111
+ });
112
+ test("attachment responses: uncached collections serve unsigned cached children with deep or large JSON data", async () => {
113
+ let deep = "leaf";
114
+ for (let i = 0; i < 70; i++) deep = { child: deep };
115
+ for (const data of [deep, Array.from({ length: 100001 }, () => "leaf")]) {
116
+ const original = {
117
+ "@context": ["https://www.w3.org/ns/activitystreams", { data: {
118
+ "@id": "https://example.com/data",
119
+ "@type": "@json"
120
+ } }],
121
+ type: "Note",
122
+ id: "https://example.com/notes/cached",
123
+ content: "unsigned cached child",
124
+ data
125
+ };
126
+ const note = await Note.fromJsonLd(original, { contextLoader: mockDocumentLoader });
127
+ const before = structuredClone(await note.toJsonLd());
128
+ const collection = new OrderedCollection({ items: [note] });
129
+ const options = { contextLoader: mockDocumentLoader };
130
+ const serialized = structuredClone(await collection.toJsonLd(options));
131
+ for (const response of [await respondWithObject(collection, options), ...await Promise.all(ACCEPTS.map((accept) => respondWithObjectIfAcceptable(collection, new Request("https://example.com/", { headers: { Accept: accept } }), options)))]) {
132
+ assert(response != null);
133
+ assertEquals(response.status, 200);
134
+ assertEquals(await response.json(), serialized);
135
+ }
136
+ assertEquals(await note.toJsonLd(), before);
137
+ }
138
+ });
139
+ test("attachment responses: large cached collection remains servable", async () => {
140
+ const original = {
141
+ "@context": "https://www.w3.org/ns/activitystreams",
142
+ type: "OrderedCollection",
143
+ id: "https://example.com/collection",
144
+ orderedItems: Array.from({ length: 100001 }, (_, i) => `https://example.com/items/${i}`)
145
+ };
146
+ const collection = await OrderedCollection.fromJsonLd(original, { contextLoader: mockDocumentLoader });
147
+ const before = structuredClone(await collection.toJsonLd());
148
+ const response = await respondWithObject(collection, { contextLoader: mockDocumentLoader });
149
+ assertEquals(response.status, 200);
150
+ assertEquals(await response.json(), before);
151
+ assertEquals(await collection.toJsonLd(), before);
152
+ });
153
+ test("attachment responses: cached signed roots pass through without invalidating their JCS proof", async () => {
154
+ const signed = await signObject(new Note({
155
+ id: new URL("https://example.com/notes/signed"),
156
+ attachments: [new Note({ content: "signed attachment" })]
157
+ }), ed25519PrivateKey, ed25519Multikey.id, { contextLoader: mockDocumentLoader });
158
+ const json = await signed.toJsonLd({
159
+ format: "compact",
160
+ contextLoader: mockDocumentLoader
161
+ });
162
+ const cached = await Note.fromJsonLd(json, { contextLoader: mockDocumentLoader });
163
+ const proofs = [];
164
+ for await (const proof of signed.getProofs()) proofs.push(proof);
165
+ assertEquals(proofs.length, 1);
166
+ const verification = {
167
+ contextLoader: mockDocumentLoader,
168
+ documentLoader: mockDocumentLoader
169
+ };
170
+ assert(await verifyProof(json, proofs[0], verification) != null);
171
+ const options = { contextLoader: mockDocumentLoader };
172
+ for (const response of [await respondWithObject(cached, options), ...await Promise.all(ACCEPTS.map((accept) => respondWithObjectIfAcceptable(cached, new Request("https://example.com/", { headers: { Accept: accept } }), options)))]) {
173
+ assert(response != null);
174
+ assertEquals(response.status, 200);
175
+ const body = await response.json();
176
+ assertEquals(body, json);
177
+ assert(await verifyProof(body, proofs[0], verification) != null);
178
+ }
179
+ assertEquals(await cached.toJsonLd(), json);
180
+ });
181
+ //#endregion
182
+ export {};
@@ -6,7 +6,7 @@ import { n as assertExists } from "../std__assert-BjJn2daJ.mjs";
6
6
  import { t as assertThrows } from "../assert_throws-BbSMEFKo.mjs";
7
7
  import { t as assertStrictEquals } from "../assert_strict_equals-XEgZAlrj.mjs";
8
8
  import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
9
- import { r as createFederationBuilder } from "../builder-G4wSHQX-.mjs";
9
+ import { r as createFederationBuilder } from "../builder-D4GE1Gmi.mjs";
10
10
  import { DisallowedOperatorError, DisallowedVarSpecModifierError, DuplicateRouteVariableError, RouteTemplateOptionsNotMatchedError, RouterError } from "@fedify/uri-template";
11
11
  import { Activity, Note, Person } from "@fedify/vocab";
12
12
  import { test } from "@fedify/fixture";
@@ -5,8 +5,8 @@ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
5
  import "../std__assert-BjJn2daJ.mjs";
6
6
  import { t as assertThrows } from "../assert_throws-BbSMEFKo.mjs";
7
7
  import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
8
- import { n as normalizeCircuitBreakerOptions, r as parseCircuitBreakerKvState, t as CircuitBreaker } from "../circuit-breaker-D1fxthDI.mjs";
9
- import { t as markCircuitBreakerLegacySweepDone } from "../circuit-breaker-test-utils-CAdwjgMi.mjs";
8
+ import { n as normalizeCircuitBreakerOptions, r as parseCircuitBreakerKvState, t as CircuitBreaker } from "../circuit-breaker-B1fLHmg2.mjs";
9
+ import { t as markCircuitBreakerLegacySweepDone } from "../circuit-breaker-test-utils-BGHm_MsT.mjs";
10
10
  import { test } from "@fedify/fixture";
11
11
  //#region src/federation/circuit-breaker.test.ts
12
12
  var AlwaysConflictingKvStore = class extends MemoryKvStore {
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
5
  import "../std__assert-BjJn2daJ.mjs";
6
- import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-Cc3DVAhE.mjs";
6
+ import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-Dp5ky45w.mjs";
7
7
  import { test } from "@fedify/fixture";
8
8
  import { decodeHex } from "byte-encodings/hex";
9
9
  //#region src/federation/collection.test.ts
@@ -0,0 +1,2 @@
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";