@fedify/fedify 2.2.20 → 2.2.21

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/attachment-arrays-CalAATqD.mjs +16 -0
  2. package/dist/{builder-BolQ56ab.mjs → builder-4ImvtjG4.mjs} +3 -3
  3. package/dist/callback-0KrwzutD.d.mts +2607 -0
  4. package/dist/{client-jE7oGvRh.d.ts → client-9DPcy_Yx.d.ts} +16 -0
  5. package/dist/{client-BIBzqEIp.d.cts → client-B3ruDgWg.d.cts} +16 -0
  6. package/dist/{client-DhxaVgOv.mjs → client-XYMC0Mmk.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-CFQGaq5x.d.cts → context-CjWuov0g.d.cts} +31 -14
  15. package/dist/{context-DdbLVV_k.d.ts → context-DZqI2LJD.d.ts} +31 -14
  16. package/dist/{deno-BUj4roJc.mjs → deno-AWk3S2Ug.mjs} +1 -1
  17. package/dist/{docloader-CbtF_0cD.mjs → docloader-Bogpjg4d.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/collection.test.mjs +1 -1
  22. package/dist/federation/delivery-attachments.test.d.mts +2 -0
  23. package/dist/federation/delivery-attachments.test.mjs +288 -0
  24. package/dist/federation/handler.test.mjs +208 -16
  25. package/dist/federation/idempotency.test.mjs +2 -2
  26. package/dist/federation/inbox.test.mjs +2 -2
  27. package/dist/federation/middleware.test.mjs +1184 -8
  28. package/dist/federation/mod.cjs +1 -1
  29. package/dist/federation/mod.d.cts +2 -2
  30. package/dist/federation/mod.d.ts +2 -2
  31. package/dist/federation/mod.js +1 -1
  32. package/dist/federation/negotiation.test.mjs +1 -1
  33. package/dist/federation/retry.test.mjs +1 -1
  34. package/dist/federation/send.test.mjs +283 -3
  35. package/dist/federation/temporal.test.mjs +25 -1
  36. package/dist/federation/webfinger.test.mjs +1 -1
  37. package/dist/{http-CQMVisM0.mjs → http-B3wCvgu8.mjs} +6 -4
  38. package/dist/{http-D8I7LBfx.cjs → http-BNaPJVnF.cjs} +6 -4
  39. package/dist/{http-C5g_VrA_.js → http-BpdLaGy8.js} +6 -4
  40. package/dist/{http-9IFUxdkp.d.cts → http-C8qLHs_Z.d.cts} +3 -3
  41. package/dist/{http-SbfezERn.d.ts → http-D8WmcRAF.d.ts} +3 -3
  42. package/dist/{inbox-CD8IDILN.mjs → inbox-DLy6WBXU.mjs} +1 -1
  43. package/dist/{key-C3o3DGap.mjs → key-Bhc8cQC7.mjs} +3 -2
  44. package/dist/{kv-cache-DC9LcfoC.cjs → kv-cache-Bj3CY9Jo.cjs} +1 -1
  45. package/dist/{kv-cache-CSKXXleR.js → kv-cache-CvjLUQTf.js} +1 -1
  46. package/dist/{ld-ijSr-0AB.mjs → ld-DTeykI0e.mjs} +153 -21
  47. package/dist/ld-signature-Dgz_b89j.mjs +23 -0
  48. package/dist/{middleware-DNueR0GD.cjs → middleware-BSQP4d9p.cjs} +475 -107
  49. package/dist/{middleware-DmcY2TWS.cjs → middleware-CWOzxb3o.cjs} +1 -1
  50. package/dist/{middleware-yqqfI7oJ.mjs → middleware-DkMsC5mQ.mjs} +1 -1
  51. package/dist/{middleware-sjhz30sm.js → middleware-Dx1iwFk8.js} +474 -107
  52. package/dist/{middleware-CYAaUTi5.mjs → middleware-dlGvSrXl.mjs} +386 -96
  53. package/dist/{mod-BYWp77-z.d.cts → mod-BmxqcEnU.d.ts} +30 -13
  54. package/dist/{mod-CVSKw-5H.d.cts → mod-DWEx2D4q.d.cts} +1 -1
  55. package/dist/{mod-BuRRdsfD.d.ts → mod-DnPmz3-S.d.ts} +1 -1
  56. package/dist/{mod-CM5_J_cx.d.ts → mod-INjDw-m0.d.cts} +30 -13
  57. package/dist/{mod-BRnwh2oy.d.ts → mod-REfljt0T.d.ts} +3 -3
  58. package/dist/{mod-Co7LEK9X.d.cts → mod-UvIGUHqW.d.cts} +3 -3
  59. package/dist/mod.cjs +5 -5
  60. package/dist/mod.d.cts +8 -8
  61. package/dist/mod.d.ts +8 -8
  62. package/dist/mod.js +5 -5
  63. package/dist/nodeinfo/client.test.mjs +432 -4
  64. package/dist/nodeinfo/handler.test.mjs +1 -1
  65. package/dist/nodeinfo/mod.cjs +1 -1
  66. package/dist/nodeinfo/mod.d.cts +1 -1
  67. package/dist/nodeinfo/mod.d.ts +1 -1
  68. package/dist/nodeinfo/mod.js +1 -1
  69. package/dist/nodeinfo/types.test.mjs +1 -1
  70. package/dist/{outgoing-jsonld-amccRMrV.mjs → outgoing-jsonld-DHf_DYXp.mjs} +38 -8
  71. package/dist/{owner-B8kXzD0q.mjs → owner-BsA7qMHB.mjs} +2 -2
  72. package/dist/{proof-CBQOjOgA.mjs → proof-C63Hqt9N.mjs} +40 -15
  73. package/dist/{proof-qiuGJCD7.cjs → proof-Dbz6ApNP.cjs} +1190 -1007
  74. package/dist/{proof-DKX6nASL.js → proof-QV_o5ZqS.js} +1174 -1003
  75. package/dist/{send-DRpisX_f.mjs → send-CAdpwbFX.mjs} +92 -21
  76. package/dist/sig/http.test.mjs +2 -2
  77. package/dist/sig/key-types.test.d.mts +218 -0
  78. package/dist/sig/key-types.test.mjs +8 -0
  79. package/dist/sig/key.test.mjs +2 -2
  80. package/dist/sig/ld.test.mjs +573 -8
  81. package/dist/sig/mod.cjs +2 -2
  82. package/dist/sig/mod.d.cts +3 -3
  83. package/dist/sig/mod.d.ts +3 -3
  84. package/dist/sig/mod.js +2 -2
  85. package/dist/sig/owner.test.mjs +1 -1
  86. package/dist/sig/proof.test.mjs +96 -4
  87. package/dist/{temporal-BQGEINad.mjs → temporal-B3JGkVgk.mjs} +3 -5
  88. package/dist/testing/mod.d.mts +2 -2422
  89. package/dist/{types-DOvyymM4.cjs → types-BWx7zw3Y.cjs} +85 -10
  90. package/dist/{types-B1_pRFE_.js → types-Dx_w2JSM.js} +86 -11
  91. package/dist/utils/docloader.test.mjs +2 -2
  92. package/dist/utils/mod.cjs +1 -1
  93. package/dist/utils/mod.d.cts +1 -1
  94. package/dist/utils/mod.d.ts +1 -1
  95. package/dist/utils/mod.js +1 -1
  96. package/package.json +5 -5
  97. /package/dist/{activity-listener-ell7W1s9.mjs → activity-listener-tztVvlNb.mjs} +0 -0
  98. /package/dist/{collection-D-HqUuA2.mjs → collection-CA3V5zyK.mjs} +0 -0
  99. /package/dist/{negotiation-SQvQgUqe.mjs → negotiation-VnHNB0Q5.mjs} +0 -0
  100. /package/dist/{public-audience-DpJqzPuh.mjs → public-audience-4g3_Ze4y.mjs} +0 -0
  101. /package/dist/{retry-v_sGLH1d.mjs → retry-CXg_MBI-.mjs} +0 -0
  102. /package/dist/{types-J53Kw7so.mjs → types-BFowWFTT.mjs} +0 -0
@@ -1,10 +1,10 @@
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-9IFUxdkp.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-C8qLHs_Z.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 { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
7
- import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
7
+ import { AuthenticatedDocumentLoaderFactory, CryptoKeyLike, CryptoKeyPairLike, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
8
8
  import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
9
9
  import { Span, Tracer, TracerProvider } from "@opentelemetry/api";
10
10
 
@@ -46,13 +46,18 @@ declare function buildCollectionSynchronizationHeader(collectionId: string | URL
46
46
  //#region src/federation/send.d.ts
47
47
  /**
48
48
  * A key pair for an actor who sends an activity.
49
+ *
50
+ * The private key type is parameterized so that Fedify can accept keys from
51
+ * `node:crypto` at its input boundaries while `SenderKeyPair` still exposes the
52
+ * ambient `CryptoKey` type by default.
53
+ * @template TKey The type of the private key.
49
54
  * @since 0.10.0
50
55
  */
51
- interface SenderKeyPair {
56
+ interface SenderKeyPair<TKey extends CryptoKeyLike = CryptoKey> {
52
57
  /**
53
58
  * The actor's private key to sign the request.
54
59
  */
55
- readonly privateKey: CryptoKey;
60
+ readonly privateKey: TKey;
56
61
  /**
57
62
  * The public key ID that corresponds to the private key.
58
63
  */
@@ -116,13 +121,19 @@ type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, ide
116
121
  /**
117
122
  * A callback that dispatches key pairs for an actor.
118
123
  *
124
+ * The returned key pairs may come from any supported runtime, including keys
125
+ * obtained from `node:crypto`'s Web Crypto API, so the key pair type is
126
+ * parameterized. It defaults to the ambient `CryptoKeyPair` type for
127
+ * compatibility with code that calls a dispatcher directly.
128
+ *
119
129
  * @template TContextData The context data to pass to the {@link Context}.
130
+ * @template TKeyPair The type of the key pairs the dispatcher returns.
120
131
  * @param context The context.
121
132
  * @param identifier The actor's internal identifier or username.
122
133
  * @returns The key pairs.
123
134
  * @since 0.10.0
124
135
  */
125
- type ActorKeyPairsDispatcher<TContextData> = (context: Context<TContextData>, identifier: string) => CryptoKeyPair[] | Promise<CryptoKeyPair[]>;
136
+ type ActorKeyPairsDispatcher<TContextData, TKeyPair extends CryptoKeyPairLike = CryptoKeyPair> = (context: Context<TContextData>, identifier: string) => TKeyPair[] | Promise<TKeyPair[]>;
126
137
  /**
127
138
  * A callback that maps a WebFinger username to the corresponding actor's
128
139
  * internal identifier, or `null` if the username is not found.
@@ -271,11 +282,11 @@ type OutboxListenerErrorHandler<TContextData> = (context: OutboxContext<TContext
271
282
  * not authorized.
272
283
  * @since 0.11.0
273
284
  */
274
- type SharedInboxKeyDispatcher<TContextData> = (context: Context<TContextData>) => SenderKeyPair | {
285
+ type SharedInboxKeyDispatcher<TContextData, TKeyPair extends CryptoKeyLike = CryptoKey> = (context: Context<TContextData>) => SenderKeyPair<TKeyPair> | {
275
286
  identifier: string;
276
287
  } | {
277
288
  username: string;
278
- } | null | Promise<SenderKeyPair | {
289
+ } | null | Promise<SenderKeyPair<TKeyPair> | {
279
290
  identifier: string;
280
291
  } | {
281
292
  username: string;
@@ -1481,6 +1492,12 @@ interface FederationOptions<TContextData> {
1481
1492
  *
1482
1493
  * By default, the queue starts automatically.
1483
1494
  *
1495
+ * Automatic startup is best-effort: if a queue cannot start listening,
1496
+ * a warning is logged once per federation instance and the failed worker is
1497
+ * not retried, while an explicit {@link Federation.startQueue} call rejects.
1498
+ * Runtimes that consume the queue elsewhere, such as Cloudflare Workers with
1499
+ * {@link Federation.processQueuedTask}, should set this to `true`.
1500
+ *
1484
1501
  * @since 0.12.0
1485
1502
  */
1486
1503
  manuallyStartQueue?: boolean;
@@ -1654,7 +1671,7 @@ interface ActorCallbackSetters<TContextData> {
1654
1671
  * @returns The setters object so that settings can be chained.
1655
1672
  * @since 0.10.0
1656
1673
  */
1657
- setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
1674
+ setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData, CryptoKeyPairLike>): ActorCallbackSetters<TContextData>;
1658
1675
  /**
1659
1676
  * Sets the callback function that maps a WebFinger username to
1660
1677
  * the corresponding actor's identifier. If it's omitted, the identifier
@@ -1853,7 +1870,7 @@ interface InboxListenerSetters<TContextData> {
1853
1870
  * @returns The setters object so that settings can be chained.
1854
1871
  * @since 0.11.0
1855
1872
  */
1856
- setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData>): InboxListenerSetters<TContextData>;
1873
+ setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData, CryptoKeyLike>): InboxListenerSetters<TContextData>;
1857
1874
  /**
1858
1875
  * Configures the strategy for handling activity idempotency in inbox processing.
1859
1876
  *
@@ -2186,7 +2203,7 @@ interface Context<TContextData> {
2186
2203
  */
2187
2204
  getDocumentLoader(identity: {
2188
2205
  keyId: URL;
2189
- privateKey: CryptoKey;
2206
+ privateKey: CryptoKeyLike;
2190
2207
  }): DocumentLoader;
2191
2208
  /**
2192
2209
  * Looks up an ActivityStreams object by its URI (including `acct:` URIs)
@@ -2299,7 +2316,7 @@ interface Context<TContextData> {
2299
2316
  * @param activity The activity to send.
2300
2317
  * @param options Options for sending the activity.
2301
2318
  */
2302
- sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
2319
+ sendActivity(sender: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
2303
2320
  identifier: string;
2304
2321
  } | {
2305
2322
  username: string;
@@ -2572,7 +2589,7 @@ interface InboxContext<TContextData> extends Context<TContextData> {
2572
2589
  * @param options Options for forwarding the activity.
2573
2590
  * @since 1.0.0
2574
2591
  */
2575
- forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
2592
+ forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
2576
2593
  identifier: string;
2577
2594
  } | {
2578
2595
  username: string;
@@ -2630,7 +2647,7 @@ interface OutboxContext<TContextData> extends Context<TContextData> {
2630
2647
  * @param options Options for forwarding the activity.
2631
2648
  * @since 2.2.0
2632
2649
  */
2633
- forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
2650
+ forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
2634
2651
  identifier: string;
2635
2652
  } | {
2636
2653
  username: string;
@@ -1,11 +1,11 @@
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-SbfezERn.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-D8WmcRAF.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 { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
7
7
  import { Span, Tracer, TracerProvider } from "@opentelemetry/api";
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
 
11
11
  //#region src/compat/types.d.ts
@@ -46,13 +46,18 @@ declare function buildCollectionSynchronizationHeader(collectionId: string | URL
46
46
  //#region src/federation/send.d.ts
47
47
  /**
48
48
  * A key pair for an actor who sends an activity.
49
+ *
50
+ * The private key type is parameterized so that Fedify can accept keys from
51
+ * `node:crypto` at its input boundaries while `SenderKeyPair` still exposes the
52
+ * ambient `CryptoKey` type by default.
53
+ * @template TKey The type of the private key.
49
54
  * @since 0.10.0
50
55
  */
51
- interface SenderKeyPair {
56
+ interface SenderKeyPair<TKey extends CryptoKeyLike = CryptoKey> {
52
57
  /**
53
58
  * The actor's private key to sign the request.
54
59
  */
55
- readonly privateKey: CryptoKey;
60
+ readonly privateKey: TKey;
56
61
  /**
57
62
  * The public key ID that corresponds to the private key.
58
63
  */
@@ -116,13 +121,19 @@ type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, ide
116
121
  /**
117
122
  * A callback that dispatches key pairs for an actor.
118
123
  *
124
+ * The returned key pairs may come from any supported runtime, including keys
125
+ * obtained from `node:crypto`'s Web Crypto API, so the key pair type is
126
+ * parameterized. It defaults to the ambient `CryptoKeyPair` type for
127
+ * compatibility with code that calls a dispatcher directly.
128
+ *
119
129
  * @template TContextData The context data to pass to the {@link Context}.
130
+ * @template TKeyPair The type of the key pairs the dispatcher returns.
120
131
  * @param context The context.
121
132
  * @param identifier The actor's internal identifier or username.
122
133
  * @returns The key pairs.
123
134
  * @since 0.10.0
124
135
  */
125
- type ActorKeyPairsDispatcher<TContextData> = (context: Context<TContextData>, identifier: string) => CryptoKeyPair[] | Promise<CryptoKeyPair[]>;
136
+ type ActorKeyPairsDispatcher<TContextData, TKeyPair extends CryptoKeyPairLike = CryptoKeyPair> = (context: Context<TContextData>, identifier: string) => TKeyPair[] | Promise<TKeyPair[]>;
126
137
  /**
127
138
  * A callback that maps a WebFinger username to the corresponding actor's
128
139
  * internal identifier, or `null` if the username is not found.
@@ -271,11 +282,11 @@ type OutboxListenerErrorHandler<TContextData> = (context: OutboxContext<TContext
271
282
  * not authorized.
272
283
  * @since 0.11.0
273
284
  */
274
- type SharedInboxKeyDispatcher<TContextData> = (context: Context<TContextData>) => SenderKeyPair | {
285
+ type SharedInboxKeyDispatcher<TContextData, TKeyPair extends CryptoKeyLike = CryptoKey> = (context: Context<TContextData>) => SenderKeyPair<TKeyPair> | {
275
286
  identifier: string;
276
287
  } | {
277
288
  username: string;
278
- } | null | Promise<SenderKeyPair | {
289
+ } | null | Promise<SenderKeyPair<TKeyPair> | {
279
290
  identifier: string;
280
291
  } | {
281
292
  username: string;
@@ -1481,6 +1492,12 @@ interface FederationOptions<TContextData> {
1481
1492
  *
1482
1493
  * By default, the queue starts automatically.
1483
1494
  *
1495
+ * Automatic startup is best-effort: if a queue cannot start listening,
1496
+ * a warning is logged once per federation instance and the failed worker is
1497
+ * not retried, while an explicit {@link Federation.startQueue} call rejects.
1498
+ * Runtimes that consume the queue elsewhere, such as Cloudflare Workers with
1499
+ * {@link Federation.processQueuedTask}, should set this to `true`.
1500
+ *
1484
1501
  * @since 0.12.0
1485
1502
  */
1486
1503
  manuallyStartQueue?: boolean;
@@ -1654,7 +1671,7 @@ interface ActorCallbackSetters<TContextData> {
1654
1671
  * @returns The setters object so that settings can be chained.
1655
1672
  * @since 0.10.0
1656
1673
  */
1657
- setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
1674
+ setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData, CryptoKeyPairLike>): ActorCallbackSetters<TContextData>;
1658
1675
  /**
1659
1676
  * Sets the callback function that maps a WebFinger username to
1660
1677
  * the corresponding actor's identifier. If it's omitted, the identifier
@@ -1853,7 +1870,7 @@ interface InboxListenerSetters<TContextData> {
1853
1870
  * @returns The setters object so that settings can be chained.
1854
1871
  * @since 0.11.0
1855
1872
  */
1856
- setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData>): InboxListenerSetters<TContextData>;
1873
+ setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData, CryptoKeyLike>): InboxListenerSetters<TContextData>;
1857
1874
  /**
1858
1875
  * Configures the strategy for handling activity idempotency in inbox processing.
1859
1876
  *
@@ -2186,7 +2203,7 @@ interface Context<TContextData> {
2186
2203
  */
2187
2204
  getDocumentLoader(identity: {
2188
2205
  keyId: URL;
2189
- privateKey: CryptoKey;
2206
+ privateKey: CryptoKeyLike;
2190
2207
  }): DocumentLoader;
2191
2208
  /**
2192
2209
  * Looks up an ActivityStreams object by its URI (including `acct:` URIs)
@@ -2299,7 +2316,7 @@ interface Context<TContextData> {
2299
2316
  * @param activity The activity to send.
2300
2317
  * @param options Options for sending the activity.
2301
2318
  */
2302
- sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
2319
+ sendActivity(sender: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
2303
2320
  identifier: string;
2304
2321
  } | {
2305
2322
  username: string;
@@ -2572,7 +2589,7 @@ interface InboxContext<TContextData> extends Context<TContextData> {
2572
2589
  * @param options Options for forwarding the activity.
2573
2590
  * @since 1.0.0
2574
2591
  */
2575
- forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
2592
+ forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
2576
2593
  identifier: string;
2577
2594
  } | {
2578
2595
  username: string;
@@ -2630,7 +2647,7 @@ interface OutboxContext<TContextData> extends Context<TContextData> {
2630
2647
  * @param options Options for forwarding the activity.
2631
2648
  * @since 2.2.0
2632
2649
  */
2633
- forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
2650
+ forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
2634
2651
  identifier: string;
2635
2652
  } | {
2636
2653
  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.2.20";
6
+ var version = "2.2.21";
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-C3o3DGap.mjs";
5
- import { r as doubleKnockScoped } from "./http-CQMVisM0.mjs";
4
+ import { s as validateCryptoKey } from "./key-Bhc8cQC7.mjs";
5
+ import { r as doubleKnockScoped } from "./http-B3wCvgu8.mjs";
6
6
  import { curry } from "es-toolkit";
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-Ew3jOFa3.mjs";
5
+ import "../std__assert-DNZ4Liil.mjs";
6
+ import { t as assert } from "../assert-BhQd8QHP.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-C63Hqt9N.mjs";
10
+ import { h as respondWithObjectIfAcceptable, m as respondWithObject, o as createFederation } from "../middleware-dlGvSrXl.mjs";
11
+ import { mockDocumentLoader, test } from "@fedify/fixture";
12
+ import { Note, Object as Object$1, OrderedCollection, PropertyValue, Service, Update } from "@fedify/vocab";
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 {};
@@ -7,7 +7,7 @@ import { r as assertExists } from "../std__assert-DNZ4Liil.mjs";
7
7
  import { t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
8
8
  import { t as assertStrictEquals } from "../assert_strict_equals-Dmjbg-bA.mjs";
9
9
  import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
10
- import { n as createFederationBuilder } from "../builder-BolQ56ab.mjs";
10
+ import { n as createFederationBuilder } from "../builder-4ImvtjG4.mjs";
11
11
  import { test } from "@fedify/fixture";
12
12
  import { Activity, Note, Person } from "@fedify/vocab";
13
13
  //#region src/federation/builder.test.ts
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import "../std__assert-DNZ4Liil.mjs";
6
- import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-D-HqUuA2.mjs";
6
+ import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-CA3V5zyK.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";