@fedify/fedify 2.0.1 → 2.0.2-dev.407

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 (97) hide show
  1. package/dist/{builder-CqPrSnE5.js → builder-CmXCvILP.js} +3 -3
  2. package/dist/client-BxMZiQaD.d.ts +224 -0
  3. package/dist/client-C97KOq3x.d.cts +222 -0
  4. package/dist/compat/mod.d.cts +6 -6
  5. package/dist/compat/mod.d.ts +6 -6
  6. package/dist/compat/transformers.test.js +11 -11
  7. package/dist/context-Dy5ro7zD.d.ts +2515 -0
  8. package/dist/context-o4OhjMHe.d.cts +2513 -0
  9. package/dist/{deno-CIi8RNND.js → deno-r4zOZb6i.js} +1 -1
  10. package/dist/{docloader-CmrEfaGw.js → docloader-B3FBDYHA.js} +2 -2
  11. package/dist/federation/builder.test.js +3 -3
  12. package/dist/federation/handler.test.js +11 -11
  13. package/dist/federation/idempotency.test.js +11 -11
  14. package/dist/federation/inbox.test.js +2 -2
  15. package/dist/federation/middleware.test.js +11 -11
  16. package/dist/federation/mod.cjs +4 -4
  17. package/dist/federation/mod.d.cts +6 -6
  18. package/dist/federation/mod.d.ts +6 -6
  19. package/dist/federation/mod.js +4 -4
  20. package/dist/federation/send.test.js +5 -5
  21. package/dist/federation/webfinger.test.js +11 -11
  22. package/dist/{http-Dvox_xrq.js → http-B2qDw-ld.js} +2 -2
  23. package/dist/{http-BjroyS-9.cjs → http-BeDhqNdl.cjs} +1 -1
  24. package/dist/{http-CCsNu78I.js → http-Cu7-n4zt.js} +1 -1
  25. package/dist/http-Cz3MlXAZ.d.cts +244 -0
  26. package/dist/http-DkHdFfrc.d.ts +246 -0
  27. package/dist/{inbox-CiTdVhJQ.js → inbox-COVt7NM_.js} +1 -1
  28. package/dist/{key-C7JS89OH.js → key-D3c7zdQ4.js} +1 -1
  29. package/dist/kv-BL4nlICN.d.cts +110 -0
  30. package/dist/kv-DXEUEP6z.d.ts +113 -0
  31. package/dist/{kv-cache-BqFnozz0.cjs → kv-cache-BXA2Q9DI.cjs} +1 -1
  32. package/dist/{kv-cache-6b2ldIo-.js → kv-cache-CtV4175p.js} +1 -1
  33. package/dist/{ld-C8i1kViF.js → ld-B5-SoHWy.js} +2 -2
  34. package/dist/middleware-BDtfAFen.cjs +12 -0
  35. package/dist/{middleware-DqJ1cmZE.cjs → middleware-BjvalmrW.cjs} +4 -4
  36. package/dist/{middleware-CfL_Pd6a.js → middleware-CyrPv2j3.js} +4 -4
  37. package/dist/{middleware-B3GuN6Gj.js → middleware-D1v2KqML.js} +4 -4
  38. package/dist/{middleware-B4Bgz0MJ.js → middleware-Dp0_BtQF.js} +10 -10
  39. package/dist/{middleware-0fnsG0v7.js → middleware-DsPC0qJ_.js} +11 -11
  40. package/dist/mod-Bm_GwNTL.d.cts +80 -0
  41. package/dist/mod-CIR7gJW8.d.ts +64 -0
  42. package/dist/mod-CwZXZJ9d.d.ts +91 -0
  43. package/dist/mod-DPkRU3EK.d.cts +266 -0
  44. package/dist/mod-DQWhp0xs.d.ts +82 -0
  45. package/dist/mod-DUWcVv49.d.ts +268 -0
  46. package/dist/mod-DXsQakeS.d.cts +89 -0
  47. package/dist/mod-DwqZ5l67.d.cts +62 -0
  48. package/dist/mod.cjs +4 -4
  49. package/dist/mod.d.cts +9 -9
  50. package/dist/mod.d.ts +9 -9
  51. package/dist/mod.js +4 -4
  52. package/dist/nodeinfo/handler.test.js +11 -11
  53. package/dist/nodeinfo/mod.d.cts +1 -1
  54. package/dist/nodeinfo/mod.d.ts +1 -1
  55. package/dist/otel/mod.d.cts +145 -145
  56. package/dist/otel/mod.d.ts +145 -145
  57. package/dist/owner-1AbPBOOZ.d.cts +66 -0
  58. package/dist/{owner-BOSWh-ha.js → owner-KwXXBWZ3.js} +1 -1
  59. package/dist/owner-gd0Q9FuU.d.ts +68 -0
  60. package/dist/{proof-C8qvlfLD.cjs → proof-BcQ-0Eck.cjs} +1 -1
  61. package/dist/{proof-D61EYfPl.js → proof-DqYaOkxv.js} +1 -1
  62. package/dist/{proof-BeT_MFIx.js → proof-S-df7nOa.js} +2 -2
  63. package/dist/{send-D7lC06r9.js → send-BFqsdYMW.js} +2 -2
  64. package/dist/sig/http.test.js +3 -3
  65. package/dist/sig/key.test.js +2 -2
  66. package/dist/sig/ld.test.js +3 -3
  67. package/dist/sig/mod.cjs +2 -2
  68. package/dist/sig/mod.d.cts +3 -3
  69. package/dist/sig/mod.d.ts +3 -3
  70. package/dist/sig/mod.js +2 -2
  71. package/dist/sig/owner.test.js +3 -3
  72. package/dist/sig/proof.test.js +3 -3
  73. package/dist/utils/docloader.test.js +4 -4
  74. package/dist/utils/mod.cjs +2 -2
  75. package/dist/utils/mod.d.cts +3 -3
  76. package/dist/utils/mod.d.ts +3 -3
  77. package/dist/utils/mod.js +2 -2
  78. package/package.json +6 -6
  79. package/dist/client-CwkOPN13.d.cts +0 -222
  80. package/dist/client-a7NwzhA2.d.ts +0 -224
  81. package/dist/context-BdNW_8a3.d.cts +0 -2554
  82. package/dist/context-C-GVKcJR.d.ts +0 -2556
  83. package/dist/http-CCEu-x1_.d.cts +0 -253
  84. package/dist/http-CODSJcKx.d.ts +0 -255
  85. package/dist/kv-g9jFc34-.d.cts +0 -110
  86. package/dist/kv-jg_8SMc1.d.ts +0 -113
  87. package/dist/middleware-DILzU8Ot.cjs +0 -12
  88. package/dist/mod-5PNty1K9.d.cts +0 -80
  89. package/dist/mod-BcpEGTWV.d.cts +0 -62
  90. package/dist/mod-COO7VMcm.d.cts +0 -266
  91. package/dist/mod-CevNbUol.d.ts +0 -91
  92. package/dist/mod-CtO31FCx.d.ts +0 -64
  93. package/dist/mod-Da9fNDyC.d.ts +0 -82
  94. package/dist/mod-ErTjUJs9.d.cts +0 -89
  95. package/dist/mod-q2IR8UiH.d.ts +0 -268
  96. package/dist/owner-9yZ5Ibsb.d.cts +0 -66
  97. package/dist/owner-DQYAbVmX.d.ts +0 -68
@@ -1,2554 +0,0 @@
1
- import { GetNodeInfoOptions, JsonValue, NodeInfo } from "./client-CwkOPN13.cjs";
2
- import { HttpMessageSignaturesSpec } from "./http-CCEu-x1_.cjs";
3
- import { GetKeyOwnerOptions } from "./owner-9yZ5Ibsb.cjs";
4
- import { KvKey, KvStore } from "./kv-g9jFc34-.cjs";
5
- import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, TraverseCollectionOptions } from "@fedify/vocab";
6
- import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
7
- import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
8
- import { Span, Tracer, TracerProvider } from "@opentelemetry/api";
9
-
10
- //#region src/compat/types.d.ts
11
- /**
12
- * A function that transforms an activity object.
13
- * @since 1.4.0
14
- */
15
- type ActivityTransformer<TContextData> = (activity: Activity, context: Context<TContextData>) => Activity;
16
- //#endregion
17
- //#region src/federation/collection.d.ts
18
- /**
19
- * A page of items.
20
- */
21
- interface PageItems<TItem> {
22
- readonly prevCursor?: string | null;
23
- readonly nextCursor?: string | null;
24
- readonly items: readonly TItem[];
25
- }
26
- /**
27
- * Calculates the [partial follower collection digest][1].
28
- *
29
- * [1]: https://w3id.org/fep/8fcf#partial-follower-collection-digest
30
- * @param uris The URIs to calculate the digest. Duplicate URIs are ignored.
31
- * @returns The digest.
32
- */
33
- declare function digest(uris: Iterable<string | URL>): Promise<Uint8Array>;
34
- /**
35
- * Builds [`Collection-Synchronization`][1] header content.
36
- *
37
- * [1]: https://w3id.org/fep/8fcf#the-collection-synchronization-http-header
38
- *
39
- * @param collectionId The sender's followers collection URI.
40
- * @param actorIds The actor URIs to digest.
41
- * @returns The header content.
42
- */
43
- declare function buildCollectionSynchronizationHeader(collectionId: string | URL, actorIds: Iterable<string | URL>): Promise<string>;
44
- //#endregion
45
- //#region src/federation/send.d.ts
46
- /**
47
- * A key pair for an actor who sends an activity.
48
- * @since 0.10.0
49
- */
50
- interface SenderKeyPair {
51
- /**
52
- * The actor's private key to sign the request.
53
- */
54
- readonly privateKey: CryptoKey;
55
- /**
56
- * The public key ID that corresponds to the private key.
57
- */
58
- readonly keyId: URL;
59
- }
60
- /**
61
- * Parameters for {@link sendActivity}.
62
- */
63
-
64
- /**
65
- * An error that is thrown when an activity fails to send to a remote inbox.
66
- * It contains structured information about the failure, including the HTTP
67
- * status code, the inbox URL, and the response body.
68
- * @since 2.0.0
69
- */
70
- declare class SendActivityError extends Error {
71
- /**
72
- * The inbox URL that the activity was being sent to.
73
- */
74
- readonly inbox: URL;
75
- /**
76
- * The HTTP status code returned by the inbox.
77
- */
78
- readonly statusCode: number;
79
- /**
80
- * The response body from the inbox, if any. Note that this may be
81
- * truncated to a maximum of 1 KiB to prevent excessive memory consumption
82
- * when remote servers return large error pages (e.g., Cloudflare error pages).
83
- * If truncated, the string will end with `"… (truncated)"`.
84
- */
85
- readonly responseBody: string;
86
- /**
87
- * Creates a new {@link SendActivityError}.
88
- * @param inbox The inbox URL.
89
- * @param statusCode The HTTP status code.
90
- * @param message The error message.
91
- * @param responseBody The response body.
92
- */
93
- constructor(inbox: URL, statusCode: number, message: string, responseBody: string);
94
- }
95
- //#endregion
96
- //#region src/federation/callback.d.ts
97
- /**
98
- * A callback that dispatches a {@link NodeInfo} object.
99
- *
100
- * @template TContextData The context data to pass to the {@link Context}.
101
- */
102
- type NodeInfoDispatcher<TContextData> = (context: RequestContext<TContextData>) => NodeInfo | Promise<NodeInfo>;
103
- /**
104
- * A callback that dispatches a array of {@link Link}.
105
- *
106
- * @template TContextData The context data to pass to the {@link Context}.
107
- * @param resource The URL queried via WebFinger.
108
- * @returns Links related to the queried resource.
109
- */
110
- type WebFingerLinksDispatcher<TContextData> = (context: RequestContext<TContextData>, resource: URL) => readonly Link$1[] | Promise<readonly Link$1[]>;
111
- /**
112
- * A callback that dispatches an {@link Actor} object.
113
- *
114
- * @template TContextData The context data to pass to the {@link Context}.
115
- * @param context The request context.
116
- * @param identifier The actor's internal identifier or username.
117
- */
118
- type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, identifier: string) => Actor | null | Promise<Actor | null>;
119
- /**
120
- * A callback that dispatches key pairs for an actor.
121
- *
122
- * @template TContextData The context data to pass to the {@link Context}.
123
- * @param context The context.
124
- * @param identifier The actor's internal identifier or username.
125
- * @returns The key pairs.
126
- * @since 0.10.0
127
- */
128
- type ActorKeyPairsDispatcher<TContextData> = (context: Context<TContextData>, identifier: string) => CryptoKeyPair[] | Promise<CryptoKeyPair[]>;
129
- /**
130
- * A callback that maps a WebFinger username to the corresponding actor's
131
- * internal identifier, or `null` if the username is not found.
132
- * @template TContextData The context data to pass to the {@link Context}.
133
- * @param context The context.
134
- * @param username The WebFinger username.
135
- * @returns The actor's internal identifier, or `null` if the username is not
136
- * found.
137
- * @since 0.15.0
138
- */
139
- type ActorHandleMapper<TContextData> = (context: Context<TContextData>, username: string) => string | null | Promise<string | null>;
140
- /**
141
- * A callback that maps a WebFinger query to the corresponding actor's
142
- * internal identifier or username, or `null` if the query is not found.
143
- * @template TContextData The context data to pass to the {@link Context}.
144
- * @param context The request context.
145
- * @param resource The URL that was queried through WebFinger.
146
- * @returns The actor's internal identifier or username, or `null` if the query
147
- * is not found.
148
- * @since 1.4.0
149
- */
150
- type ActorAliasMapper<TContextData> = (context: RequestContext<TContextData>, resource: URL) => {
151
- identifier: string;
152
- } | {
153
- username: string;
154
- } | null | Promise<{
155
- identifier: string;
156
- } | {
157
- username: string;
158
- } | null>;
159
- /**
160
- * A callback that dispatches an object.
161
- *
162
- * @template TContextData The context data to pass to the {@link Context}.
163
- * @template TObject The type of object to dispatch.
164
- * @template TParam The parameter names of the requested URL.
165
- * @since 0.7.0
166
- */
167
- type ObjectDispatcher<TContextData, TObject extends Object$1, TParam extends string> = (context: RequestContext<TContextData>, values: Record<TParam, string>) => TObject | null | Promise<TObject | null>;
168
- /**
169
- * A callback that dispatches a collection.
170
- *
171
- * @template TItem The type of items in the collection.
172
- * @template TContext The type of the context. {@link Context} or
173
- * {@link RequestContext}.
174
- * @template TContextData The context data to pass to the `TContext`.
175
- * @template TFilter The type of the filter, if any.
176
- * @param context The context.
177
- * @param identifier The internal identifier or the username of the collection
178
- * owner.
179
- * @param cursor The cursor to start the collection from, or `null` to dispatch
180
- * the entire collection without pagination.
181
- * @param filter The filter to apply to the collection, if any.
182
- */
183
- type CollectionDispatcher<TItem, TContext extends Context<TContextData>, TContextData, TFilter> = (context: TContext, identifier: string, cursor: string | null, filter?: TFilter) => PageItems<TItem> | null | Promise<PageItems<TItem> | null>;
184
- /**
185
- * A callback that counts the number of items in a collection.
186
- *
187
- * @template TContextData The context data to pass to the {@link Context}.
188
- * @param context The context.
189
- * @param identifier The internal identifier or the username of the collection
190
- * owner.
191
- * @param filter The filter to apply to the collection, if any.
192
- */
193
- type CollectionCounter<TContextData, TFilter> = (context: RequestContext<TContextData>, identifier: string, filter?: TFilter) => number | bigint | null | Promise<number | bigint | null>;
194
- /**
195
- * A callback that returns a cursor for a collection.
196
- *
197
- * @template TContext The type of the context. {@link Context} or
198
- * {@link RequestContext}.
199
- * @template TContextData The context data to pass to the {@link Context}.
200
- * @template TFilter The type of the filter, if any.
201
- * @param context The context.
202
- * @param identifier The internal identifier or the username of the collection
203
- * owner.
204
- * @param filter The filter to apply to the collection, if any.
205
- */
206
- type CollectionCursor<TContext extends Context<TContextData>, TContextData, TFilter> = (context: TContext, identifier: string, filter?: TFilter) => string | null | Promise<string | null>;
207
- /**
208
- * A callback that listens for activities in an inbox.
209
- *
210
- * @template TContextData The context data to pass to the {@link Context}.
211
- * @template TActivity The type of activity to listen for.
212
- * @param context The inbox context.
213
- * @param activity The activity that was received.
214
- */
215
- type InboxListener<TContextData, TActivity extends Activity> = (context: InboxContext<TContextData>, activity: TActivity) => void | Promise<void>;
216
- /**
217
- * A callback that handles errors in an inbox.
218
- *
219
- * @template TContextData The context data to pass to the {@link Context}.
220
- * @param context The inbox context.
221
- */
222
- type InboxErrorHandler<TContextData> = (context: Context<TContextData>, error: Error) => void | Promise<void>;
223
- /**
224
- * A callback that dispatches the key pair for the authenticated document loader
225
- * of the {@link Context} passed to the shared inbox listener.
226
- *
227
- * @template TContextData The context data to pass to the {@link Context}.
228
- * @param context The context.
229
- * @returns The username or the internal identifier of the actor or the key pair
230
- * for the authenticated document loader of the {@link Context} passed
231
- * to the shared inbox listener. If `null` is returned, the request is
232
- * not authorized.
233
- * @since 0.11.0
234
- */
235
- type SharedInboxKeyDispatcher<TContextData> = (context: Context<TContextData>) => SenderKeyPair | {
236
- identifier: string;
237
- } | {
238
- username: string;
239
- } | null | Promise<SenderKeyPair | {
240
- identifier: string;
241
- } | {
242
- username: string;
243
- } | null>;
244
- /**
245
- * A callback that handles errors during outbox processing.
246
- *
247
- * @param error The error that occurred.
248
- * @param activity The activity that caused the error. If it is `null`, the
249
- * error occurred during deserializing the activity.
250
- * @since 0.6.0
251
- */
252
- type OutboxErrorHandler = (error: Error, activity: Activity | null) => void | Promise<void>;
253
- /**
254
- * A callback that handles permanent delivery failures when sending activities
255
- * to remote inboxes.
256
- *
257
- * This handler is called when an inbox returns an HTTP status code that
258
- * indicates permanent failure (such as `410 Gone` or `404 Not Found`),
259
- * allowing the application to clean up followers that are no longer reachable.
260
- *
261
- * Unlike {@link OutboxErrorHandler}, which is called for every delivery failure
262
- * (including retries), this handler is called only once for permanent failures,
263
- * after which delivery is not retried.
264
- *
265
- * If any errors are thrown in this callback, they are caught, logged,
266
- * and ignored.
267
- *
268
- * @template TContextData The context data to pass to the {@link Context}.
269
- * @param context The context.
270
- * @param values The delivery failure information.
271
- * @since 2.0.0
272
- */
273
- type OutboxPermanentFailureHandler<TContextData> = (context: Context<TContextData>, values: {
274
- /** The inbox URL that failed. */
275
- readonly inbox: URL;
276
- /** The activity that failed to deliver. */
277
- readonly activity: Activity;
278
- /** The error that occurred. */
279
- readonly error: SendActivityError;
280
- /** The HTTP status code returned by the inbox. */
281
- readonly statusCode: number;
282
- /**
283
- * The actor IDs that were supposed to receive the activity at this inbox.
284
- */
285
- readonly actorIds: readonly URL[];
286
- }) => void | Promise<void>;
287
- /**
288
- * A callback that determines if a request is authorized or not.
289
- *
290
- * @template TContextData The context data to pass to the {@link Context}.
291
- * @param context The request context.
292
- * @param identifier The internal identifier of the actor that is being requested.
293
- * @param signedKey *Deprecated in Fedify 1.5.0 in favor of
294
- * {@link RequestContext.getSignedKey} method.*
295
- * The key that was used to sign the request, or `null` if
296
- * the request was not signed or the signature was invalid.
297
- * @param signedKeyOwner *Deprecated in Fedify 1.5.0 in favor of
298
- * {@link RequestContext.getSignedKeyOwner} method.*
299
- * The actor that owns the key that was used to sign the
300
- * request, or `null` if the request was not signed or the
301
- * signature was invalid, or if the key is not associated
302
- * with an actor.
303
- * @returns `true` if the request is authorized, `false` otherwise.
304
- * @since 0.7.0
305
- */
306
- type AuthorizePredicate<TContextData> = (context: RequestContext<TContextData>, identifier: string, signedKey: CryptographicKey | null, signedKeyOwner: Actor | null) => boolean | Promise<boolean>;
307
- /**
308
- * A callback that determines if a request is authorized or not.
309
- *
310
- * @template TContextData The context data to pass to the {@link Context}.
311
- * @template TParam The parameter names of the requested URL.
312
- * @param context The request context.
313
- * @param values The parameters of the requested URL.
314
- * @param signedKey *Deprecated in Fedify 1.5.0 in favor of
315
- * {@link RequestContext.getSignedKey} method.*
316
- * The key that was used to sign the request, or `null` if
317
- * the request was not signed or the signature was invalid.
318
- * @param signedKeyOwner *Deprecated in Fedify 1.5.0 in favor of
319
- * {@link RequestContext.getSignedKeyOwner} method.*
320
- * The actor that owns the key that was used to sign the
321
- * request, or `null` if the request was not signed or the
322
- * signature was invalid, or if the key is not associated
323
- * with an actor.
324
- * @returns `true` if the request is authorized, `false` otherwise.
325
- * @since 0.7.0
326
- */
327
- type ObjectAuthorizePredicate<TContextData, TParam extends string> = (context: RequestContext<TContextData>, values: Record<TParam, string>, signedKey: CryptographicKey | null, signedKeyOwner: Actor | null) => boolean | Promise<boolean>;
328
- /**
329
- * A callback that dispatches a custom collection.
330
- *
331
- * @template TItem The type of items in the collection.
332
- * @template TParams The parameter names of the requested URL.
333
- * @template TContext The type of the context. {@link Context} or
334
- * {@link RequestContext}.
335
- * @template TContextData The context data to pass to the `TContext`.
336
- * @template TFilter The type of the filter, if any.
337
- * @param context The context.
338
- * @param values The parameters of the requested URL.
339
- * @param cursor The cursor to start the collection from, or `null` to dispatch
340
- * the entire collection without pagination.
341
- * @since 1.8.0
342
- */
343
- type CustomCollectionDispatcher<TItem, TParam extends string, TContext extends Context<TContextData>, TContextData> = (context: TContext, values: Record<TParam, string>, cursor: string | null) => PageItems<TItem> | null | Promise<PageItems<TItem> | null>;
344
- /**
345
- * A callback that counts the number of items in a custom collection.
346
- *
347
- * @template TParams The parameter names of the requested URL.
348
- * @template TContextData The context data to pass to the {@link Context}.
349
- * @param context The context.
350
- * @param values The parameters of the requested URL.
351
- * @since 1.8.0
352
- */
353
- type CustomCollectionCounter<TParam extends string, TContextData> = (context: RequestContext<TContextData>, values: Record<TParam, string>) => number | bigint | null | Promise<number | bigint | null>;
354
- /**
355
- * A callback that returns a cursor for a custom collection.
356
- *
357
- * @template TParams The parameter names of the requested URL.
358
- * @template TContext The type of the context. {@link Context} or
359
- * {@link RequestContext}.
360
- * @template TContextData The context data to pass to the {@link Context}.
361
- * @template TFilter The type of the filter, if any.
362
- * @param context The context.
363
- * @param values The parameters of the requested URL.
364
- * @since 1.8.0
365
- */
366
- type CustomCollectionCursor<TParam extends string, TContext extends Context<TContextData>, TContextData> = (context: TContext, values: Record<TParam, string>) => string | null | Promise<string | null>;
367
- //#endregion
368
- //#region src/federation/mq.d.ts
369
- /**
370
- * Additional options for enqueuing a message in a queue.
371
- *
372
- * @since 0.5.0
373
- */
374
- interface MessageQueueEnqueueOptions {
375
- /**
376
- * The delay before the message is enqueued. No delay by default.
377
- *
378
- * It must not be negative.
379
- */
380
- readonly delay?: Temporal.Duration;
381
- /**
382
- * An optional key that ensures messages with the same ordering key are
383
- * processed sequentially (one at a time). Messages with different ordering
384
- * keys (or no ordering key) may be processed in parallel.
385
- *
386
- * This is useful for ensuring that related messages are processed in order,
387
- * such as ensuring that a `Delete` activity is processed after a `Create`
388
- * activity for the same object.
389
- *
390
- * @since 2.0.0
391
- */
392
- readonly orderingKey?: string;
393
- }
394
- /**
395
- * Additional options for listening to a message queue.
396
- *
397
- * @since 1.0.0
398
- */
399
- interface MessageQueueListenOptions {
400
- /**
401
- * The signal to abort listening to the message queue.
402
- */
403
- signal?: AbortSignal;
404
- }
405
- /**
406
- * An abstract interface for a message queue.
407
- *
408
- * @since 0.5.0
409
- */
410
- interface MessageQueue {
411
- /**
412
- * Whether the message queue backend provides native retry mechanisms.
413
- * When `true`, Fedify will skip its own retry logic and rely on the backend
414
- * to handle retries. When `false` or omitted, Fedify will handle retries
415
- * using its own retry policies.
416
- *
417
- * @default `false`
418
- * @since 1.7.0
419
- */
420
- readonly nativeRetrial?: boolean;
421
- /**
422
- * Enqueues a message in the queue.
423
- * @param message The message to enqueue.
424
- * @param options Additional options for enqueuing the message.
425
- */
426
- enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
427
- /**
428
- * Enqueues multiple messages in the queue. This operation is optional,
429
- * and may not be supported by all implementations. If not supported,
430
- * Fedify will invoke {@link enqueue} for each message.
431
- *
432
- * @param messages The messages to enqueue.
433
- * @param options Additional options for enqueuing the messages.
434
- */
435
- enqueueMany?: (messages: readonly any[], options?: MessageQueueEnqueueOptions) => Promise<void>;
436
- /**
437
- * Listens for messages in the queue.
438
- * @param handler The handler for messages in the queue.
439
- * @param options Additional options for listening to the message queue.
440
- * @returns A promise that resolves when the listening is done. It never
441
- * rejects, and is resolved when the signal is aborted. If no
442
- * signal is provided, it never resolves.
443
- */
444
- listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
445
- }
446
- /**
447
- * Additional options for {@link InProcessMessageQueue}.
448
- * @since 1.0.0
449
- */
450
- interface InProcessMessageQueueOptions {
451
- /**
452
- * The interval to poll for messages in the queue. 5 seconds by default.
453
- * @default `{ seconds: 5 }`
454
- */
455
- pollInterval?: Temporal.Duration | Temporal.DurationLike;
456
- }
457
- /**
458
- * A message queue that processes messages in the same process.
459
- * Do not use this in production as it does neither persist messages nor
460
- * distribute them across multiple processes.
461
- *
462
- * @since 0.5.0
463
- */
464
- declare class InProcessMessageQueue implements MessageQueue {
465
- #private;
466
- /**
467
- * In-process message queue does not provide native retry mechanisms.
468
- * @since 1.7.0
469
- */
470
- readonly nativeRetrial = false;
471
- /**
472
- * Constructs a new {@link InProcessMessageQueue} with the given options.
473
- * @param options Additional options for the in-process message queue.
474
- */
475
- constructor(options?: InProcessMessageQueueOptions);
476
- enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
477
- enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
478
- listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
479
- }
480
- /**
481
- * A message queue that processes messages in parallel. It takes another
482
- * {@link MessageQueue}, and processes messages in parallel up to a certain
483
- * number of workers.
484
- *
485
- * Actually, it's rather a decorator than a queue itself.
486
- *
487
- * Note that the workers do not run in truly parallel, in the sense that they
488
- * are not running in separate threads or processes. They are running in the
489
- * same process, but are scheduled to run in parallel. Hence, this is useful
490
- * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
491
- * workloads.
492
- *
493
- * When using `ParallelMessageQueue`, the ordering guarantee is preserved
494
- * *only if* the underlying queue implementation delivers messages in a wrapper
495
- * format that includes the `__fedify_ordering_key__` property. Currently,
496
- * only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
497
- * For other queue implementations (e.g., `InProcessMessageQueue`,
498
- * `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
499
- * `AmqpMessageQueue`), the ordering key cannot be detected by
500
- * `ParallelMessageQueue`, so ordering guarantees are handled by those
501
- * implementations directly rather than at the `ParallelMessageQueue` level.
502
- *
503
- * Messages with the same ordering key will never be processed concurrently
504
- * by different workers, ensuring sequential processing within each key.
505
- * Messages with different ordering keys (or no ordering key) can still be
506
- * processed in parallel.
507
- *
508
- * @since 1.0.0
509
- */
510
- declare class ParallelMessageQueue implements MessageQueue {
511
- #private;
512
- readonly queue: MessageQueue;
513
- readonly workers: number;
514
- /**
515
- * Inherits the native retry capability from the wrapped queue.
516
- * @since 1.7.0
517
- */
518
- readonly nativeRetrial?: boolean;
519
- /**
520
- * Constructs a new {@link ParallelMessageQueue} with the given queue and
521
- * number of workers.
522
- * @param queue The message queue to use under the hood. Note that
523
- * {@link ParallelMessageQueue} cannot be nested.
524
- * @param workers The number of workers to process messages in parallel.
525
- * @throws {TypeError} If the given queue is an instance of
526
- * {@link ParallelMessageQueue}.
527
- */
528
- constructor(queue: MessageQueue, workers: number);
529
- enqueue(message: any, options?: MessageQueueEnqueueOptions): Promise<void>;
530
- enqueueMany(messages: readonly any[], options?: MessageQueueEnqueueOptions): Promise<void>;
531
- listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
532
- }
533
- //#endregion
534
- //#region src/federation/handler.d.ts
535
- /**
536
- * Options for the {@link respondWithObject} and
537
- * {@link respondWithObjectIfAcceptable} functions.
538
- * @since 0.3.0
539
- */
540
- interface RespondWithObjectOptions {
541
- /**
542
- * The document loader to use for compacting JSON-LD.
543
- * @since 0.8.0
544
- */
545
- contextLoader: DocumentLoader;
546
- }
547
- /**
548
- * Responds with the given object in JSON-LD format.
549
- *
550
- * @param object The object to respond with.
551
- * @param options Options.
552
- * @since 0.3.0
553
- */
554
- declare function respondWithObject(object: Object$1, options?: RespondWithObjectOptions): Promise<Response>;
555
- /**
556
- * Responds with the given object in JSON-LD format if the request accepts
557
- * JSON-LD.
558
- *
559
- * @param object The object to respond with.
560
- * @param request The request to check for JSON-LD acceptability.
561
- * @param options Options.
562
- * @since 0.3.0
563
- */
564
- declare function respondWithObjectIfAcceptable(object: Object$1, request: Request, options?: RespondWithObjectOptions): Promise<Response | null>;
565
- //#endregion
566
- //#region src/federation/router.d.ts
567
- /**
568
- * Options for the {@link Router}.
569
- * @since 0.12.0
570
- */
571
- interface RouterOptions {
572
- /**
573
- * Whether to ignore trailing slashes when matching paths.
574
- */
575
- trailingSlashInsensitive?: boolean;
576
- }
577
- /**
578
- * The result of {@link Router.route} method.
579
- * @since 1.3.0
580
- */
581
- interface RouterRouteResult {
582
- /**
583
- * The matched route name.
584
- */
585
- name: string;
586
- /**
587
- * The URL template of the matched route.
588
- */
589
- template: string;
590
- /**
591
- * The values extracted from the URL.
592
- */
593
- values: Record<string, string>;
594
- }
595
- /**
596
- * URL router and constructor based on URI Template
597
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
598
- */
599
- declare class Router {
600
- #private;
601
- /**
602
- * Whether to ignore trailing slashes when matching paths.
603
- * @since 1.6.0
604
- */
605
- trailingSlashInsensitive: boolean;
606
- /**
607
- * Create a new {@link Router}.
608
- * @param options Options for the router.
609
- */
610
- constructor(options?: RouterOptions);
611
- clone(): Router;
612
- /**
613
- * Checks if a path name exists in the router.
614
- * @param name The name of the path.
615
- * @returns `true` if the path name exists, otherwise `false`.
616
- */
617
- has(name: string): boolean;
618
- /**
619
- * Adds a new path rule to the router.
620
- * @param template The path pattern.
621
- * @param name The name of the path.
622
- * @returns The names of the variables in the path pattern.
623
- */
624
- add(template: string, name: string): Set<string>;
625
- /**
626
- * Resolves a path name and values from a URL, if any match.
627
- * @param url The URL to resolve.
628
- * @returns The name of the path and its values, if any match. Otherwise,
629
- * `null`.
630
- */
631
- route(url: string): RouterRouteResult | null;
632
- /**
633
- * Constructs a URL/path from a path name and values.
634
- * @param name The name of the path.
635
- * @param values The values to expand the path with.
636
- * @returns The URL/path, if the name exists. Otherwise, `null`.
637
- */
638
- build(name: string, values: Record<string, string>): string | null;
639
- }
640
- /**
641
- * An error thrown by the {@link Router}.
642
- */
643
- declare class RouterError extends Error {
644
- /**
645
- * Create a new {@link RouterError}.
646
- * @param message The error message.
647
- */
648
- constructor(message: string);
649
- }
650
- //#endregion
651
- //#region src/federation/builder.d.ts
652
- /**
653
- * Creates a new {@link FederationBuilder} instance.
654
- * @returns A new {@link FederationBuilder} instance.
655
- * @since 1.6.0
656
- */
657
- declare function createFederationBuilder<TContextData>(): FederationBuilder<TContextData>;
658
- //#endregion
659
- //#region src/federation/queue.d.ts
660
- interface SenderKeyJwkPair {
661
- readonly keyId: string;
662
- readonly privateKey: JsonWebKey;
663
- }
664
- /**
665
- * A message that represents a task to be processed by the background worker.
666
- * The concrete type of the message depends on the `type` property.
667
- *
668
- * Please do not depend on the concrete types of the messages, as they may
669
- * change in the future. You should treat the `Message` type as an opaque
670
- * type.
671
- * @since 1.6.0
672
- */
673
- type Message = FanoutMessage | OutboxMessage | InboxMessage;
674
- interface FanoutMessage {
675
- readonly type: "fanout";
676
- readonly id: ReturnType<typeof crypto.randomUUID>;
677
- readonly baseUrl: string;
678
- readonly keys: readonly SenderKeyJwkPair[];
679
- readonly inboxes: Readonly<Record<string, {
680
- readonly actorIds: readonly string[];
681
- readonly sharedInbox: boolean;
682
- }>>;
683
- readonly activity: unknown;
684
- readonly activityId?: string;
685
- readonly activityType: string;
686
- readonly collectionSync?: string;
687
- readonly orderingKey?: string;
688
- readonly traceContext: Readonly<Record<string, string>>;
689
- }
690
- interface OutboxMessage {
691
- readonly type: "outbox";
692
- readonly id: ReturnType<typeof crypto.randomUUID>;
693
- readonly baseUrl: string;
694
- readonly keys: readonly SenderKeyJwkPair[];
695
- readonly activity: unknown;
696
- readonly activityId?: string;
697
- readonly activityType: string;
698
- readonly inbox: string;
699
- readonly sharedInbox: boolean;
700
- readonly actorIds?: readonly string[];
701
- readonly started: string;
702
- readonly attempt: number;
703
- readonly headers: Readonly<Record<string, string>>;
704
- readonly orderingKey?: string;
705
- readonly traceContext: Readonly<Record<string, string>>;
706
- }
707
- interface InboxMessage {
708
- readonly type: "inbox";
709
- readonly id: ReturnType<typeof crypto.randomUUID>;
710
- readonly baseUrl: string;
711
- readonly activity: unknown;
712
- readonly started: string;
713
- readonly attempt: number;
714
- readonly identifier: string | null;
715
- readonly traceContext: Readonly<Record<string, string>>;
716
- }
717
- //#endregion
718
- //#region src/federation/retry.d.ts
719
- /**
720
- * The context passed to a {@link RetryPolicy} callback.
721
- * @since 0.12.0
722
- */
723
- interface RetryContext {
724
- /**
725
- * The elapsed time since the first attempt.
726
- */
727
- readonly elapsedTime: Temporal.Duration;
728
- /**
729
- * The number of attempts so far.
730
- */
731
- readonly attempts: number;
732
- }
733
- /**
734
- * A policy that determines the delay before the next retry.
735
- * @param context The retry context.
736
- * @returns The delay before the next retry, or `null` to stop retrying.
737
- * It must not negative.
738
- * @since 0.12.0
739
- */
740
- type RetryPolicy = (context: RetryContext) => Temporal.Duration | null;
741
- /**
742
- * Options for {@link createExponentialBackoffPolicy} function.
743
- * @since 0.12.0
744
- */
745
- interface CreateExponentialBackoffPolicyOptions {
746
- /**
747
- * The initial delay before the first retry. Defaults to 1 second.
748
- */
749
- readonly initialDelay?: Temporal.DurationLike;
750
- /**
751
- * The maximum delay between retries. Defaults to 12 hours.
752
- */
753
- readonly maxDelay?: Temporal.DurationLike;
754
- /**
755
- * The maximum number of attempts before giving up.
756
- * Defaults to 10.
757
- */
758
- readonly maxAttempts?: number;
759
- /**
760
- * The factor to multiply the previous delay by for each retry.
761
- * Defaults to 2.
762
- */
763
- readonly factor?: number;
764
- /**
765
- * Whether to add jitter to the delay to avoid synchronization.
766
- * Turned on by default.
767
- */
768
- readonly jitter?: boolean;
769
- }
770
- /**
771
- * Creates an exponential backoff retry policy. The delay between retries
772
- * starts at the `initialDelay` and is multiplied by the `factor` for each
773
- * subsequent retry, up to the `maxDelay`. The policy will give up after
774
- * `maxAttempts` attempts. The actual delay is randomized to avoid
775
- * synchronization (jitter).
776
- * @param options The options for the policy.
777
- * @returns The retry policy.
778
- * @since 0.12.0
779
- */
780
- declare function createExponentialBackoffPolicy(options?: CreateExponentialBackoffPolicyOptions): RetryPolicy;
781
- //#endregion
782
- //#region src/federation/middleware.d.ts
783
- /**
784
- * Configures the task queues for sending and receiving activities.
785
- * @since 1.3.0
786
- */
787
- interface FederationQueueOptions {
788
- /**
789
- * The message queue for incoming activities. If not provided, incoming
790
- * activities will not be queued and will be processed immediately.
791
- */
792
- readonly inbox?: MessageQueue;
793
- /**
794
- * The message queue for outgoing activities. If not provided, outgoing
795
- * activities will not be queued and will be sent immediately.
796
- */
797
- readonly outbox?: MessageQueue;
798
- /**
799
- * The message queue for fanning out outgoing activities. If not provided,
800
- * outgoing activities will not be fanned out in the background, but will be
801
- * fanned out immediately, which causes slow response times on
802
- * {@link Context.sendActivity} calls.
803
- */
804
- readonly fanout?: MessageQueue;
805
- }
806
- /**
807
- * Prefixes for namespacing keys in the Deno KV store.
808
- */
809
- interface FederationKvPrefixes {
810
- /**
811
- * The key prefix used for storing whether activities have already been
812
- * processed or not.
813
- * @default `["_fedify", "activityIdempotence"]`
814
- */
815
- readonly activityIdempotence: KvKey;
816
- /**
817
- * The key prefix used for storing remote JSON-LD documents.
818
- * @default `["_fedify", "remoteDocument"]`
819
- */
820
- readonly remoteDocument: KvKey;
821
- /**
822
- * The key prefix used for caching public keys.
823
- * @default `["_fedify", "publicKey"]`
824
- * @since 0.12.0
825
- */
826
- readonly publicKey: KvKey;
827
- /**
828
- * The key prefix used for caching HTTP Message Signatures specs.
829
- * The cached spec is used to reduce the number of requests to make signed
830
- * requests ("double-knocking" technique).
831
- * @default `["_fedify", "httpMessageSignaturesSpec"]`
832
- * @since 1.6.0
833
- */
834
- readonly httpMessageSignaturesSpec: KvKey;
835
- }
836
- /**
837
- * Options for {@link FederationOptions.origin} when it is not a string.
838
- * @since 1.5.0
839
- */
840
- interface FederationOrigin {
841
- /**
842
- * The canonical hostname for fediverse handles (which are looked up through
843
- * WebFinger). This is used for WebFinger lookups. It has to be a valid
844
- * hostname, e.g., `"example.com"`.
845
- */
846
- handleHost: string;
847
- /**
848
- * The canonical origin for web URLs. This is used for constructing absolute
849
- * URLs. It has to start with either `"http://"` or `"https://"`, and must
850
- * not contain a path or query string, e.g., `"https://example.com"`.
851
- */
852
- webOrigin: string;
853
- }
854
- /**
855
- * Create a new {@link Federation} instance.
856
- * @param parameters Parameters for initializing the instance.
857
- * @returns A new {@link Federation} instance.
858
- * @since 0.10.0
859
- */
860
- declare function createFederation<TContextData>(options: FederationOptions<TContextData>): Federation<TContextData>;
861
- //#endregion
862
- //#region src/federation/federation.d.ts
863
- /**
864
- * Options for {@link Federation.startQueue} method.
865
- * @since 1.0.0
866
- */
867
- interface FederationStartQueueOptions {
868
- /**
869
- * The signal to abort the task queue.
870
- */
871
- signal?: AbortSignal;
872
- /**
873
- * Starts the task worker only for the specified queue. If unspecified,
874
- * which is the default, the task worker starts for all three queues:
875
- * inbox, outbox, and fanout.
876
- * @since 1.3.0
877
- */
878
- queue?: "inbox" | "outbox" | "fanout";
879
- }
880
- /**
881
- * A common interface between {@link Federation} and {@link FederationBuilder}.
882
- * @template TContextData The context data to pass to the {@link Context}.
883
- * @since 1.6.0
884
- */
885
- interface Federatable<TContextData> {
886
- /**
887
- * Registers a NodeInfo dispatcher.
888
- * @param path The URI path pattern for the NodeInfo dispatcher. The syntax
889
- * is based on URI Template
890
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
891
- * must have no variables.
892
- * @param dispatcher A NodeInfo dispatcher callback to register.
893
- * @throws {RouterError} Thrown if the path pattern is invalid.
894
- */
895
- setNodeInfoDispatcher(path: string, dispatcher: NodeInfoDispatcher<TContextData>): void;
896
- /**
897
- * Registers a links dispatcher to WebFinger
898
- * @param dispatcher A links dispatcher callback to register.
899
- */
900
- setWebFingerLinksDispatcher(dispatcher: WebFingerLinksDispatcher<TContextData>): void;
901
- /**
902
- * Registers an actor dispatcher.
903
- *
904
- * @example
905
- * ``` typescript
906
- * federation.setActorDispatcher(
907
- * "/users/{identifier}",
908
- * async (ctx, identifier) => {
909
- * return new Person({
910
- * id: ctx.getActorUri(identifier),
911
- * // ...
912
- * });
913
- * }
914
- * );
915
- * ```
916
- *
917
- * @param path The URI path pattern for the actor dispatcher. The syntax is
918
- * based on URI Template
919
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
920
- * must have one variable: `{identifier}`.
921
- * @param dispatcher An actor dispatcher callback to register.
922
- * @returns An object with methods to set other actor dispatcher callbacks.
923
- * @throws {RouterError} Thrown if the path pattern is invalid.
924
- */
925
- setActorDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: ActorDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
926
- /**
927
- * Registers an object dispatcher.
928
- *
929
- * @template TContextData The context data to pass to the {@link Context}.
930
- * @template TObject The type of object to dispatch.
931
- * @template TParam The parameter names of the requested URL.
932
- * @param cls The Activity Vocabulary class of the object to dispatch.
933
- * @param path The URI path pattern for the object dispatcher. The syntax is
934
- * based on URI Template
935
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
936
- * must have one or more variables.
937
- * @param dispatcher An object dispatcher callback to register.
938
- */
939
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
940
- /**
941
- * Registers an object dispatcher.
942
- *
943
- * @template TContextData The context data to pass to the {@link Context}.
944
- * @template TObject The type of object to dispatch.
945
- * @template TParam The parameter names of the requested URL.
946
- * @param cls The Activity Vocabulary class of the object to dispatch.
947
- * @param path The URI path pattern for the object dispatcher. The syntax is
948
- * based on URI Template
949
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
950
- * must have one or more variables.
951
- * @param dispatcher An object dispatcher callback to register.
952
- */
953
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
954
- /**
955
- * Registers an object dispatcher.
956
- *
957
- * @template TContextData The context data to pass to the {@link Context}.
958
- * @template TObject The type of object to dispatch.
959
- * @template TParam The parameter names of the requested URL.
960
- * @param cls The Activity Vocabulary class of the object to dispatch.
961
- * @param path The URI path pattern for the object dispatcher. The syntax is
962
- * based on URI Template
963
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
964
- * must have one or more variables.
965
- * @param dispatcher An object dispatcher callback to register.
966
- */
967
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
968
- /**
969
- * Registers an object dispatcher.
970
- *
971
- * @template TContextData The context data to pass to the {@link Context}.
972
- * @template TObject The type of object to dispatch.
973
- * @template TParam The parameter names of the requested URL.
974
- * @param cls The Activity Vocabulary class of the object to dispatch.
975
- * @param path The URI path pattern for the object dispatcher. The syntax is
976
- * based on URI Template
977
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
978
- * must have one or more variables.
979
- * @param dispatcher An object dispatcher callback to register.
980
- */
981
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
982
- /**
983
- * Registers an object dispatcher.
984
- *
985
- * @template TContextData The context data to pass to the {@link Context}.
986
- * @template TObject The type of object to dispatch.
987
- * @template TParam The parameter names of the requested URL.
988
- * @param cls The Activity Vocabulary class of the object to dispatch.
989
- * @param path The URI path pattern for the object dispatcher. The syntax is
990
- * based on URI Template
991
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
992
- * must have one or more variables.
993
- * @param dispatcher An object dispatcher callback to register.
994
- */
995
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
996
- /**
997
- * Registers an object dispatcher.
998
- *
999
- * @template TContextData The context data to pass to the {@link Context}.
1000
- * @template TObject The type of object to dispatch.
1001
- * @template TParam The parameter names of the requested URL.
1002
- * @param cls The Activity Vocabulary class of the object to dispatch.
1003
- * @param path The URI path pattern for the object dispatcher. The syntax is
1004
- * based on URI Template
1005
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
1006
- * must have one or more variables.
1007
- * @param dispatcher An object dispatcher callback to register.
1008
- */
1009
- setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
1010
- /**
1011
- * Registers an inbox dispatcher.
1012
- *
1013
- * @param path The URI path pattern for the inbox dispatcher. The syntax is
1014
- * based on URI Template
1015
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
1016
- * must have one variable: `{identifier}`, and must match
1017
- * the inbox listener path.
1018
- * @param dispatcher An inbox dispatcher callback to register.
1019
- * @throws {@link RouterError} Thrown if the path pattern is invalid.
1020
- */
1021
- setInboxDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
1022
- /**
1023
- * Registers an outbox dispatcher.
1024
- *
1025
- * @example
1026
- * ``` typescript
1027
- * federation.setOutboxDispatcher(
1028
- * "/users/{identifier}/outbox",
1029
- * async (ctx, identifier, options) => {
1030
- * let items: Activity[];
1031
- * let nextCursor: string;
1032
- * // ...
1033
- * return { items, nextCursor };
1034
- * }
1035
- * );
1036
- * ```
1037
- *
1038
- * @param path The URI path pattern for the outbox dispatcher. The syntax is
1039
- * based on URI Template
1040
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
1041
- * must have one variable: `{identifier}`.
1042
- * @param dispatcher An outbox dispatcher callback to register.
1043
- * @throws {@link RouterError} Thrown if the path pattern is invalid.
1044
- */
1045
- setOutboxDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
1046
- /**
1047
- * Registers a following collection dispatcher.
1048
- * @param path The URI path pattern for the following collection. The syntax
1049
- * is based on URI Template
1050
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
1051
- * must have one variable: `{identifier}`.
1052
- * @param dispatcher A following collection callback to register.
1053
- * @returns An object with methods to set other following collection
1054
- * callbacks.
1055
- * @throws {RouterError} Thrown if the path pattern is invalid.
1056
- */
1057
- setFollowingDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Actor | URL, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
1058
- /**
1059
- * Registers a followers collection dispatcher.
1060
- * @param path The URI path pattern for the followers collection. The syntax
1061
- * is based on URI Template
1062
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
1063
- * must have one variable: `{identifier}`.
1064
- * @param dispatcher A followers collection callback to register.
1065
- * @returns An object with methods to set other followers collection
1066
- * callbacks.
1067
- * @throws {@link RouterError} Thrown if the path pattern is invalid.
1068
- */
1069
- setFollowersDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Recipient, Context<TContextData>, TContextData, URL>): CollectionCallbackSetters<Context<TContextData>, TContextData, URL>;
1070
- /**
1071
- * Registers a liked collection dispatcher.
1072
- * @param path The URI path pattern for the liked collection. The syntax
1073
- * is based on URI Template
1074
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
1075
- * must have one variable: `{identifier}`.
1076
- * @param dispatcher A liked collection callback to register.
1077
- * @returns An object with methods to set other liked collection
1078
- * callbacks.
1079
- * @throws {@link RouterError} Thrown if the path pattern is invalid.
1080
- */
1081
- setLikedDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Object$1 | URL, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
1082
- /**
1083
- * Registers a featured collection dispatcher.
1084
- * @param path The URI path pattern for the featured collection. The syntax
1085
- * is based on URI Template
1086
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
1087
- * must have one variable: `{identifier}`.
1088
- * @param dispatcher A featured collection callback to register.
1089
- * @returns An object with methods to set other featured collection
1090
- * callbacks.
1091
- * @throws {@link RouterError} Thrown if the path pattern is invalid.
1092
- */
1093
- setFeaturedDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Object$1, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
1094
- /**
1095
- * Registers a featured tags collection dispatcher.
1096
- * @param path The URI path pattern for the featured tags collection.
1097
- * The syntax is based on URI Template
1098
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
1099
- * must have one variable: `{identifier}`.
1100
- * @param dispatcher A featured tags collection callback to register.
1101
- * @returns An object with methods to set other featured tags collection
1102
- * callbacks.
1103
- * @throws {@link RouterError} Thrown if the path pattern is invalid.
1104
- */
1105
- setFeaturedTagsDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Hashtag, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
1106
- /**
1107
- * Assigns the URL path for the inbox and starts setting inbox listeners.
1108
- *
1109
- * @example
1110
- * ``` typescript
1111
- * federation
1112
- * .setInboxListeners("/users/{identifier}/inbox", "/inbox")
1113
- * .on(Follow, async (ctx, follow) => {
1114
- * const from = await follow.getActor(ctx);
1115
- * if (!isActor(from)) return;
1116
- * // ...
1117
- * })
1118
- * .on(Undo, async (ctx, undo) => {
1119
- * // ...
1120
- * });
1121
- * ```
1122
- *
1123
- * @param inboxPath The URI path pattern for the inbox. The syntax is based
1124
- * on URI Template
1125
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
1126
- * The path must have one variable: `{identifier}`, and must
1127
- * match the inbox dispatcher path.
1128
- * @param sharedInboxPath An optional URI path pattern for the shared inbox.
1129
- * The syntax is based on URI Template
1130
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
1131
- * The path must have no variables.
1132
- * @returns An object to register inbox listeners.
1133
- * @throws {RouterError} Thrown if the path pattern is invalid.
1134
- */
1135
- setInboxListeners(inboxPath: `${string}${Rfc6570Expression<"identifier">}${string}`, sharedInboxPath?: string): InboxListenerSetters<TContextData>;
1136
- /**
1137
- * Registers a collection of objects dispatcher.
1138
- *
1139
- * @template TContextData The context data to pass to the {@link Context}.
1140
- * @template TObject The type of objects to dispatch.
1141
- * @template TParam The parameter names of the requested URL.
1142
- * @param name A unique name for the collection dispatcher.
1143
- * @param itemType The Activity Vocabulary class of the object to dispatch.
1144
- * @param path The URI path pattern for the collection dispatcher.
1145
- * The syntax is based on URI Template
1146
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
1147
- * The path must have one or more variables.
1148
- * @param dispatcher A collection dispatcher callback to register.
1149
- */
1150
- setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
1151
- /**
1152
- * Registers a collection of objects dispatcher.
1153
- *
1154
- * @template TContextData The context data to pass to the {@link Context}.
1155
- * @template TObject The type of objects to dispatch.
1156
- * @template TParam The parameter names of the requested URL.
1157
- * @param name A unique name for the collection dispatcher.
1158
- * @param itemType The Activity Vocabulary class of the object to dispatch.
1159
- * @param path The URI path pattern for the collection dispatcher.
1160
- * The syntax is based on URI Template
1161
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
1162
- * The path must have one or more variables.
1163
- * @param dispatcher A collection dispatcher callback to register.
1164
- */
1165
- setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
1166
- /**
1167
- * Registers a collection of objects dispatcher.
1168
- *
1169
- * @template TContextData The context data to pass to the {@link Context}.
1170
- * @template TObject The type of objects to dispatch.
1171
- * @template TParam The parameter names of the requested URL.
1172
- * @param name A unique name for the collection dispatcher.
1173
- * @param itemType The Activity Vocabulary class of the object to dispatch.
1174
- * @param path The URI path pattern for the collection dispatcher.
1175
- * The syntax is based on URI Template
1176
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
1177
- * The path must have one or more variables.
1178
- * @param dispatcher A collection dispatcher callback to register.
1179
- */
1180
- setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
1181
- /**
1182
- * Registers an ordered collection of objects dispatcher.
1183
- *
1184
- * @template TContextData The context data to pass to the {@link Context}.
1185
- * @template TObject The type of objects to dispatch.
1186
- * @template TParam The parameter names of the requested URL.
1187
- * @param name A unique name for the collection dispatcher.
1188
- * @param itemType The Activity Vocabulary class of the object to dispatch.
1189
- * @param path The URI path pattern for the collection dispatcher.
1190
- * The syntax is based on URI Template
1191
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
1192
- * The path must have one or more variables.
1193
- * @param dispatcher A collection dispatcher callback to register.
1194
- */
1195
- setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
1196
- /**
1197
- * Registers an ordered collection of objects dispatcher.
1198
- *
1199
- * @template TContextData The context data to pass to the {@link Context}.
1200
- * @template TObject The type of objects to dispatch.
1201
- * @template TParam The parameter names of the requested URL.
1202
- * @param name A unique name for the collection dispatcher.
1203
- * @param itemType The Activity Vocabulary class of the object to dispatch.
1204
- * @param path The URI path pattern for the collection dispatcher.
1205
- * The syntax is based on URI Template
1206
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
1207
- * The path must have one or more variables.
1208
- * @param dispatcher A collection dispatcher callback to register.
1209
- */
1210
- setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
1211
- /**
1212
- * Registers an ordered collection of objects dispatcher.
1213
- *
1214
- * @template TContextData The context data to pass to the {@link Context}.
1215
- * @template TObject The type of objects to dispatch.
1216
- * @template TParam The parameter names of the requested URL.
1217
- * @param name A unique name for the collection dispatcher.
1218
- * @param itemType The Activity Vocabulary class of the object to dispatch.
1219
- * @param path The URI path pattern for the collection dispatcher.
1220
- * The syntax is based on URI Template
1221
- * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
1222
- * The path must have one or more variables.
1223
- * @param dispatcher A collection dispatcher callback to register.
1224
- */
1225
- setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
1226
- /**
1227
- * Registers a handler for permanent delivery failures.
1228
- *
1229
- * This handler is called when an inbox returns an HTTP status code
1230
- * that indicates permanent failure (`410 Gone`, `404 Not Found`, etc.),
1231
- * allowing the application to clean up followers that are no longer
1232
- * reachable.
1233
- *
1234
- * Unlike `onOutboxError`, which is called for every delivery failure
1235
- * (including retries), this handler is called only once for permanent
1236
- * failures, after which delivery is not retried.
1237
- *
1238
- * @param handler A callback to handle permanent failures.
1239
- * @since 2.0.0
1240
- */
1241
- setOutboxPermanentFailureHandler(handler: OutboxPermanentFailureHandler<TContextData>): void;
1242
- }
1243
- /**
1244
- * An object that registers federation-related business logic and dispatches
1245
- * requests to the appropriate handlers.
1246
- *
1247
- * It also provides a middleware interface for handling requests before your
1248
- * web framework's router; see {@link Federation.fetch}.
1249
- * @template TContextData The context data to pass to the {@link Context}.
1250
- * @since 0.13.0
1251
- */
1252
- interface Federation<TContextData> extends Federatable<TContextData> {
1253
- /**
1254
- * Manually start the task queue.
1255
- *
1256
- * This method is useful when you set the `manuallyStartQueue` option to
1257
- * `true` in the {@link createFederation} function.
1258
- * @param contextData The context data to pass to the context.
1259
- * @param options Additional options for starting the queue.
1260
- */
1261
- startQueue(contextData: TContextData, options?: FederationStartQueueOptions): Promise<void>;
1262
- /**
1263
- * Processes a queued message task. This method handles different types of
1264
- * tasks such as fanout, outbox, and inbox messages.
1265
- *
1266
- * Note that you usually do not need to call this method directly unless you
1267
- * are deploying your federated application on a platform that does not
1268
- * support long-running processing, such as Cloudflare Workers.
1269
- * @param contextData The context data to pass to the context.
1270
- * @param message The message that represents the task to be processed.
1271
- * @returns A promise that resolves when the message has been processed.
1272
- * @since 1.6.0
1273
- */
1274
- processQueuedTask(contextData: TContextData, message: Message): Promise<void>;
1275
- /**
1276
- * Create a new context.
1277
- * @param baseUrl The base URL of the server. The `pathname` remains root,
1278
- * and the `search` and `hash` are stripped.
1279
- * @param contextData The context data to pass to the context.
1280
- * @returns The new context.
1281
- */
1282
- createContext(baseUrl: URL, contextData: TContextData): Context<TContextData>;
1283
- /**
1284
- * Create a new context for a request.
1285
- * @param request The request object.
1286
- * @param contextData The context data to pass to the context.
1287
- * @returns The new request context.
1288
- */
1289
- createContext(request: Request, contextData: TContextData): RequestContext<TContextData>;
1290
- /**
1291
- * Handles a request related to federation. If a request is not related to
1292
- * federation, the `onNotFound` or `onNotAcceptable` callback is called.
1293
- *
1294
- * Usually, this method is called from a server's request handler or
1295
- * a web framework's middleware.
1296
- *
1297
- * @param request The request object.
1298
- * @param parameters The parameters for handling the request.
1299
- * @returns The response to the request.
1300
- */
1301
- fetch(request: Request, options: FederationFetchOptions<TContextData>): Promise<Response>;
1302
- }
1303
- /**
1304
- * A builder for creating a {@link Federation} object. It defers the actual
1305
- * instantiation of the {@link Federation} object until the {@link build}
1306
- * method is called so that dispatchers and listeners can be registered
1307
- * before the {@link Federation} object is instantiated.
1308
- * @template TContextData The context data to pass to the {@link Context}.
1309
- * @since 1.6.0
1310
- */
1311
- interface FederationBuilder<TContextData> extends Federatable<TContextData> {
1312
- /**
1313
- * Builds the federation object.
1314
- * @returns The federation object.
1315
- */
1316
- build(options: FederationOptions<TContextData>): Promise<Federation<TContextData>>;
1317
- }
1318
- /**
1319
- * Options for creating a {@link Federation} object.
1320
- * @template TContextData The context data to pass to the {@link Context}.
1321
- * @since 1.6.0
1322
- */
1323
- interface FederationOptions<TContextData> {
1324
- /**
1325
- * The key–value store used for caching, outbox queues, and inbox idempotence.
1326
- */
1327
- kv: KvStore;
1328
- /**
1329
- * Prefixes for namespacing keys in the Deno KV store. By default, all keys
1330
- * are prefixed with `["_fedify"]`.
1331
- */
1332
- kvPrefixes?: Partial<FederationKvPrefixes>;
1333
- /**
1334
- * The message queue for sending and receiving activities. If not provided,
1335
- * activities will not be queued and will be processed immediately.
1336
- *
1337
- * If a `MessageQueue` is provided, both the `inbox` and `outbox` queues
1338
- * will be set to the same queue.
1339
- *
1340
- * If a `FederationQueueOptions` object is provided, you can set the queues
1341
- * separately (since Fedify 1.3.0).
1342
- */
1343
- queue?: FederationQueueOptions | MessageQueue;
1344
- /**
1345
- * Whether to start the task queue manually or automatically.
1346
- *
1347
- * If `true`, the task queue will not start automatically and you need to
1348
- * manually start it by calling the {@link Federation.startQueue} method.
1349
- *
1350
- * If `false`, the task queue will start automatically as soon as
1351
- * the first task is enqueued.
1352
- *
1353
- * By default, the queue starts automatically.
1354
- *
1355
- * @since 0.12.0
1356
- */
1357
- manuallyStartQueue?: boolean;
1358
- /**
1359
- * The canonical base URL of the server. This is used for constructing
1360
- * absolute URLs and fediverse handles.
1361
- * @since 1.5.0
1362
- */
1363
- origin?: string | FederationOrigin;
1364
- /**
1365
- * A custom JSON-LD document loader factory. By default, this uses
1366
- * the built-in cache-backed loader that fetches remote documents over
1367
- * HTTP(S).
1368
- * @since 1.4.0
1369
- */
1370
- documentLoaderFactory?: DocumentLoaderFactory;
1371
- /**
1372
- * A custom JSON-LD context loader factory. By default, this uses the same
1373
- * loader as the document loader.
1374
- * @since 1.4.0
1375
- */
1376
- contextLoaderFactory?: DocumentLoaderFactory;
1377
- /**
1378
- * A factory function that creates an authenticated document loader for a
1379
- * given identity. This is used for fetching documents that require
1380
- * authentication.
1381
- */
1382
- authenticatedDocumentLoaderFactory?: AuthenticatedDocumentLoaderFactory;
1383
- /**
1384
- * Whether to allow fetching private network addresses in the document loader.
1385
- *
1386
- * If turned on, {@link FederationOptions.documentLoader},
1387
- * {@link FederationOptions.contextLoader}, and
1388
- * {@link FederationOptions.authenticatedDocumentLoaderFactory}
1389
- * cannot be configured.
1390
- *
1391
- * Mostly useful for testing purposes. *Do not use in production.*
1392
- *
1393
- * Turned off by default.
1394
- * @since 0.15.0
1395
- */
1396
- allowPrivateAddress?: boolean;
1397
- /**
1398
- * Options for making `User-Agent` strings for HTTP requests.
1399
- * If a string is provided, it is used as the `User-Agent` header.
1400
- * If an object is provided, it is passed to the {@link getUserAgent}
1401
- * function.
1402
- * @since 1.3.0
1403
- */
1404
- userAgent?: GetUserAgentOptions | string;
1405
- /**
1406
- * A callback that handles errors during outbox processing. Note that this
1407
- * callback can be called multiple times for the same activity, because
1408
- * the delivery is retried according to the backoff schedule until it
1409
- * succeeds or reaches the maximum retry count.
1410
- *
1411
- * If any errors are thrown in this callback, they are ignored.
1412
- */
1413
- onOutboxError?: OutboxErrorHandler;
1414
- /**
1415
- * HTTP status codes that should be treated as permanent delivery failures.
1416
- * When an inbox returns one of these codes, the delivery will not be retried
1417
- * and the permanent failure handler (if registered via
1418
- * {@link Federatable.setOutboxPermanentFailureHandler}) will be called.
1419
- *
1420
- * By default, `[404, 410]`.
1421
- *
1422
- * @since 2.0.0
1423
- */
1424
- permanentFailureStatusCodes?: readonly number[];
1425
- /**
1426
- * The time window for verifying HTTP Signatures of incoming requests. If the
1427
- * request is older or newer than this window, it is rejected. Or if it is
1428
- * `false`, the request's timestamp is not checked at all.
1429
- *
1430
- * By default, the window is an hour.
1431
- */
1432
- signatureTimeWindow?: Temporal.Duration | Temporal.DurationLike | false;
1433
- /**
1434
- * Whether to skip HTTP Signatures verification for incoming activities.
1435
- * This is useful for testing purposes, but should not be used in production.
1436
- *
1437
- * By default, this is `false` (i.e., signatures are verified).
1438
- * @since 0.13.0
1439
- */
1440
- skipSignatureVerification?: boolean;
1441
- /**
1442
- * The HTTP Signatures specification to use for the first signature
1443
- * attempt when communicating with unknown servers. This option affects
1444
- * the "double-knocking" mechanism as described in the ActivityPub HTTP
1445
- * Signature documentation.
1446
- *
1447
- * When making HTTP requests to servers that haven't been encountered before,
1448
- * Fedify will first attempt to sign the request using the specified
1449
- * signature specification. If the request fails, it will retry with the
1450
- * alternative specification.
1451
- *
1452
- * Defaults to `"rfc9421"` (HTTP Message Signatures).
1453
- *
1454
- * @see {@link https://swicg.github.io/activitypub-http-signature/#how-to-upgrade-supported-versions}
1455
- * @default `"rfc9421"`
1456
- * @since 1.7.0
1457
- */
1458
- firstKnock?: HttpMessageSignaturesSpec;
1459
- /**
1460
- * The retry policy for sending activities to recipients' inboxes.
1461
- * By default, this uses an exponential backoff strategy with a maximum of
1462
- * 10 attempts and a maximum delay of 12 hours.
1463
- * @since 0.12.0
1464
- */
1465
- outboxRetryPolicy?: RetryPolicy;
1466
- /**
1467
- * The retry policy for processing incoming activities. By default, this
1468
- * uses an exponential backoff strategy with a maximum of 10 attempts and a
1469
- * maximum delay of 12 hours.
1470
- * @since 0.12.0
1471
- */
1472
- inboxRetryPolicy?: RetryPolicy;
1473
- /**
1474
- * Activity transformers that are applied to outgoing activities. It is
1475
- * useful for adjusting outgoing activities to satisfy some ActivityPub
1476
- * implementations.
1477
- *
1478
- * By default, {@link defaultActivityTransformers} are applied.
1479
- * @since 1.4.0
1480
- */
1481
- activityTransformers?: readonly ActivityTransformer<TContextData>[];
1482
- /**
1483
- * Whether the router should be insensitive to trailing slashes in the URL
1484
- * paths. For example, if this option is `true`, `/foo` and `/foo/` are
1485
- * treated as the same path. Turned off by default.
1486
- * @since 0.12.0
1487
- */
1488
- trailingSlashInsensitive?: boolean;
1489
- /**
1490
- * The OpenTelemetry tracer provider for tracing operations. If not provided,
1491
- * the default global tracer provider is used.
1492
- * @since 1.3.0
1493
- */
1494
- tracerProvider?: TracerProvider;
1495
- }
1496
- /**
1497
- * Additional settings for the actor dispatcher.
1498
- *
1499
- * ``` typescript
1500
- * const federation = createFederation<void>({ ... });
1501
- * federation
1502
- * .setActorDispatcher("/users/{identifier}", async (ctx, identifier) => {
1503
- * // ...
1504
- * })
1505
- * .setKeyPairsDispatcher(async (ctxData, identifier) => {
1506
- * // ...
1507
- * });
1508
- * ```
1509
- */
1510
- interface ActorCallbackSetters<TContextData> {
1511
- /**
1512
- * Sets the key pairs dispatcher for actors.
1513
- * @param dispatcher A callback that returns the key pairs for an actor.
1514
- * @returns The setters object so that settings can be chained.
1515
- * @since 0.10.0
1516
- */
1517
- setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
1518
- /**
1519
- * Sets the callback function that maps a WebFinger username to
1520
- * the corresponding actor's identifier. If it's omitted, the identifier
1521
- * is assumed to be the same as the WebFinger username, which makes your
1522
- * actors have the immutable handles. If you want to let your actors change
1523
- * their fediverse handles, you should set this dispatcher.
1524
- * @param mapper A callback that maps a WebFinger username to
1525
- * the corresponding actor's identifier.
1526
- * @returns The setters object so that settings can be chained.
1527
- * @since 0.15.0
1528
- */
1529
- mapHandle(mapper: ActorHandleMapper<TContextData>): ActorCallbackSetters<TContextData>;
1530
- /**
1531
- * Sets the callback function that maps a WebFinger query to the corresponding
1532
- * actor's identifier or username. If it's omitted, the WebFinger handler
1533
- * only supports the actor URIs and `acct:` URIs. If you want to support
1534
- * other queries, you should set this dispatcher.
1535
- * @param mapper A callback that maps a WebFinger query to the corresponding
1536
- * actor's identifier or username.
1537
- * @returns The setters object so that settings can be chained.
1538
- * @since 1.4.0
1539
- */
1540
- mapAlias(mapper: ActorAliasMapper<TContextData>): ActorCallbackSetters<TContextData>;
1541
- /**
1542
- * Specifies the conditions under which requests are authorized.
1543
- * @param predicate A callback that returns whether a request is authorized.
1544
- * @returns The setters object so that settings can be chained.
1545
- * @since 0.7.0
1546
- */
1547
- authorize(predicate: AuthorizePredicate<TContextData>): ActorCallbackSetters<TContextData>;
1548
- }
1549
- /**
1550
- * Additional settings for an object dispatcher.
1551
- */
1552
- interface ObjectCallbackSetters<TContextData, TObject extends Object$1, TParam extends string> {
1553
- /**
1554
- * Specifies the conditions under which requests are authorized.
1555
- * @param predicate A callback that returns whether a request is authorized.
1556
- * @returns The setters object so that settings can be chained.
1557
- * @since 0.7.0
1558
- */
1559
- authorize(predicate: ObjectAuthorizePredicate<TContextData, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
1560
- }
1561
- /**
1562
- * Additional settings for a collection dispatcher.
1563
- *
1564
- * @template TContext The type of the context. {@link Context} or
1565
- * {@link RequestContext}.
1566
- * @template TContextData The context data to pass to the {@link Context}.
1567
- * @template TFilter The type of filter for the collection.
1568
- */
1569
- interface CollectionCallbackSetters<TContext extends Context<TContextData>, TContextData, TFilter> {
1570
- /**
1571
- * Sets the counter for the collection.
1572
- * @param counter A callback that returns the number of items in the collection.
1573
- * @returns The setters object so that settings can be chained.
1574
- */
1575
- setCounter(counter: CollectionCounter<TContextData, TFilter>): CollectionCallbackSetters<TContext, TContextData, TFilter>;
1576
- /**
1577
- * Sets the first cursor for the collection.
1578
- * @param cursor The cursor for the first item in the collection.
1579
- * @returns The setters object so that settings can be chained.
1580
- */
1581
- setFirstCursor(cursor: CollectionCursor<TContext, TContextData, TFilter>): CollectionCallbackSetters<TContext, TContextData, TFilter>;
1582
- /**
1583
- * Sets the last cursor for the collection.
1584
- * @param cursor The cursor for the last item in the collection.
1585
- * @returns The setters object so that settings can be chained.
1586
- */
1587
- setLastCursor(cursor: CollectionCursor<TContext, TContextData, TFilter>): CollectionCallbackSetters<TContext, TContextData, TFilter>;
1588
- /**
1589
- * Specifies the conditions under which requests are authorized.
1590
- * @param predicate A callback that returns whether a request is authorized.
1591
- * @returns The setters object so that settings can be chained.
1592
- * @since 0.7.0
1593
- */
1594
- authorize(predicate: AuthorizePredicate<TContextData>): CollectionCallbackSetters<TContext, TContextData, TFilter>;
1595
- }
1596
- /**
1597
- * The strategy for handling activity idempotency in inbox processing.
1598
- *
1599
- * - `"global"`: Activities are deduplicated globally across all inboxes and
1600
- * origins. The same activity ID will be processed only once, regardless
1601
- * of which inbox receives it or which server sent it.
1602
- *
1603
- * - `"per-origin"`: Activities are deduplicated per receiving server's origin.
1604
- * The same activity ID will be processed only once on each receiving server,
1605
- * but can be processed separately on different receiving servers. This had
1606
- * been the default behavior in Fedify 1.x versions.
1607
- *
1608
- * - `"per-inbox"`: Activities are deduplicated per inbox. The same activity
1609
- * ID can be processed once per inbox, allowing the same activity to be
1610
- * delivered to multiple inboxes independently. This follows standard
1611
- * ActivityPub behavior and is the default strategy since Fedify 2.0.0.
1612
- *
1613
- * @since 1.9.0
1614
- */
1615
- type IdempotencyStrategy = "global" | "per-origin" | "per-inbox";
1616
- /**
1617
- * A callback to generate a custom idempotency key for an activity.
1618
- * Returns the cache key to use, or null to skip idempotency checking.
1619
- * @template TContextData The context data to pass to the {@link InboxContext}.
1620
- * @param ctx The inbox context.
1621
- * @param activity The activity being processed.
1622
- * @returns The idempotency key to use for caching, or null to skip caching.
1623
- * @since 1.9.0
1624
- */
1625
- type IdempotencyKeyCallback<TContextData> = (ctx: InboxContext<TContextData>, activity: Activity) => string | null | Promise<string | null>;
1626
- /**
1627
- * Registry for inbox listeners for different activity types.
1628
- */
1629
- interface InboxListenerSetters<TContextData> {
1630
- /**
1631
- * Registers a listener for a specific incoming activity type.
1632
- *
1633
- * @param type A subclass of {@link Activity} to listen to.
1634
- * @param listener A callback to handle an incoming activity.
1635
- * @returns The setters object so that settings can be chained.
1636
- */
1637
- on<TActivity extends Activity>(type: new (...args: any[]) => TActivity, listener: InboxListener<TContextData, TActivity>): InboxListenerSetters<TContextData>;
1638
- /**
1639
- * Registers an error handler for inbox listeners. Any exceptions thrown
1640
- * from the listeners are caught and passed to this handler.
1641
- *
1642
- * @param handler A callback to handle an error.
1643
- * @returns The setters object so that settings can be chained.
1644
- */
1645
- onError(handler: InboxErrorHandler<TContextData>): InboxListenerSetters<TContextData>;
1646
- /**
1647
- * Configures a callback to dispatch the key pair for the authenticated
1648
- * document loader of the {@link Context} passed to the shared inbox listener.
1649
- *
1650
- * @param dispatcher A callback to dispatch the key pair for the authenticated
1651
- * document loader.
1652
- * @returns The setters object so that settings can be chained.
1653
- * @since 0.11.0
1654
- */
1655
- setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData>): InboxListenerSetters<TContextData>;
1656
- /**
1657
- * Configures the strategy for handling activity idempotency in inbox processing.
1658
- *
1659
- * @example
1660
- * Use per-inbox strategy (standard ActivityPub behavior):
1661
- * ```
1662
- * federation
1663
- * .setInboxListeners("/users/{identifier}/inbox", "/inbox")
1664
- * .withIdempotency("per-inbox");
1665
- * ```
1666
- *
1667
- * Use custom strategy:
1668
- * ```
1669
- * federation
1670
- * .setInboxListeners("/users/{identifier}/inbox", "/inbox")
1671
- * .withIdempotency((ctx, activity) => {
1672
- * // Return null to skip idempotency
1673
- * return `${ctx.origin}:${activity.id?.href}:${ctx.recipient}`;
1674
- * });
1675
- * ```
1676
- *
1677
- * @param strategy The idempotency strategy to use. Can be:
1678
- * - `"global"`: Activities are deduplicated across all inboxes and origins
1679
- * - `"per-origin"`: Activities are deduplicated per inbox origin
1680
- * - `"per-inbox"`: Activities are deduplicated per inbox
1681
- * - A custom callback function that returns the cache key to use
1682
- * @returns The setters object so that settings can be chained.
1683
- * @since 1.9.0
1684
- */
1685
- withIdempotency(strategy: IdempotencyStrategy | IdempotencyKeyCallback<TContextData>): InboxListenerSetters<TContextData>;
1686
- }
1687
- /**
1688
- * Parameters of {@link Federation.fetch} method.
1689
- *
1690
- * @template TContextData The context data to pass to the {@link Context}.
1691
- * @since 0.6.0
1692
- */
1693
- interface FederationFetchOptions<TContextData> {
1694
- /**
1695
- * The context data to pass to the {@link Context}.
1696
- */
1697
- contextData: TContextData;
1698
- /**
1699
- * A callback to handle a request when the route is not found.
1700
- * If not provided, a 404 response is returned.
1701
- * @param request The request object.
1702
- * @returns The response to the request.
1703
- */
1704
- onNotFound?: (request: Request) => Response | Promise<Response>;
1705
- /**
1706
- * A callback to handle a request when the request's `Accept` header is not
1707
- * acceptable. If not provided, a 406 response is returned.
1708
- * @param request The request object.
1709
- * @returns The response to the request.
1710
- */
1711
- onNotAcceptable?: (request: Request) => Response | Promise<Response>;
1712
- /**
1713
- * A callback to handle a request when the request is unauthorized.
1714
- * If not provided, a 401 response is returned.
1715
- * @param request The request object.
1716
- * @returns The response to the request.
1717
- * @since 0.7.0
1718
- */
1719
- onUnauthorized?: (request: Request) => Response | Promise<Response>;
1720
- }
1721
- /**
1722
- * Additional settings for a custom collection dispatcher.
1723
- *
1724
- * @template TParam The type of the parameters in the URL path.
1725
- * @template TContext The type of the context. {@link Context} or
1726
- * {@link RequestContext}.
1727
- * @template TContextData The context data to pass to the {@link Context}.
1728
- * @template TFilter The type of filter for the collection.
1729
- */
1730
- interface CustomCollectionCallbackSetters<TParam extends string, TContext extends Context<TContextData>, TContextData> {
1731
- /**
1732
- * Sets the counter for the custom collection.
1733
- * @param counter A callback that returns the number of items in the custom collection.
1734
- * @returns The setters object so that settings can be chained.
1735
- */
1736
- setCounter(counter: CustomCollectionCounter<TParam, TContextData>): CustomCollectionCallbackSetters<TParam, TContext, TContextData>;
1737
- /**
1738
- * Sets the first cursor for the custom collection.
1739
- * @param cursor The cursor for the first item in the custom collection.
1740
- * @returns The setters object so that settings can be chained.
1741
- */
1742
- setFirstCursor(cursor: CustomCollectionCursor<TParam, TContext, TContextData>): CustomCollectionCallbackSetters<TParam, TContext, TContextData>;
1743
- /**
1744
- * Sets the last cursor for the custom collection.
1745
- * @param cursor The cursor for the last item in the custom collection.
1746
- * @returns The setters object so that settings can be chained.
1747
- */
1748
- setLastCursor(cursor: CustomCollectionCursor<TParam, TContext, TContextData>): CustomCollectionCallbackSetters<TParam, TContext, TContextData>;
1749
- /**
1750
- * Specifies the conditions under which requests are authorized.
1751
- * @param predicate A callback that returns whether a request is authorized.
1752
- * @returns The setters object so that settings can be chained.
1753
- * @since 0.7.0
1754
- */
1755
- authorize(predicate: ObjectAuthorizePredicate<TContextData, string>): CustomCollectionCallbackSetters<TParam, TContext, TContextData>;
1756
- }
1757
- /**
1758
- * Represents an object with a type ID, which is either a constructor or an
1759
- * instance of the object.
1760
- *
1761
- * @template TObject The type of the object.
1762
- */
1763
- type ConstructorWithTypeId<TObject extends Object$1> = (new (...args: any[]) => TObject) & {
1764
- typeId: URL;
1765
- };
1766
- /**
1767
- * Defines a union of all valid RFC 6570 URI Template expressions for a given
1768
- * parameter name.
1769
- *
1770
- * RFC 6570 specifies a syntax for URI templates, allowing for variable
1771
- * expansion. This type captures all Level 1-4 operator expressions for a
1772
- * single, named variable.
1773
- *
1774
- * The supported expression types are:
1775
- * - `{Param}`: Simple string expansion
1776
- * - `+{Param}`: Reserved string expansion
1777
- * - `#{Param}`: Fragment expansion
1778
- * - `{.Param}`: Label expansion with a dot-prefix
1779
- * - `{/Param}`: Path segment expansion
1780
- * - `{;Param}`: Path-style parameter expansion
1781
- * - `{?Param}`: Query component expansion
1782
- * - `{&Param}`: Query continuation expansion
1783
- *
1784
- * @template Param The name of the parameter to be used in the expressions.
1785
- * @example
1786
- * ```ts
1787
- * type UserIdExpression = Rfc6570Expression<"userId">;
1788
- *
1789
- * // The variable `userPath` can be assigned any of the valid expressions.
1790
- * const userPath: UserIdExpression = "{/userId}";
1791
- * ```
1792
- * @see {@link https://tools.ietf.org/html/rfc6570} for the full specification.
1793
- */
1794
- type Rfc6570Expression<Param extends string> = `{${Param}}` | `{+${Param}}` | `{#${Param}}` | `{.${Param}}` | `{/${Param}}` | `{;${Param}}` | `{?${Param}}` | `{&${Param}}`;
1795
- //#endregion
1796
- //#region src/federation/context.d.ts
1797
- /**
1798
- * A context.
1799
- */
1800
- interface Context<TContextData> {
1801
- /**
1802
- * The origin of the federated server, including the scheme (`http://` or
1803
- * `https://`) and the host (e.g., `example.com:8080`).
1804
- * @since 0.12.0
1805
- */
1806
- readonly origin: string;
1807
- /**
1808
- * The canonical origin of the federated server, including the scheme
1809
- * (`http://` or `https://`) and the host (e.g., `example.com:8080`).
1810
- *
1811
- * When the associated {@link Federation} object does not have any explicit
1812
- * canonical origin, it is the same as the {@link Context.origin}.
1813
- * @since 1.5.0
1814
- */
1815
- readonly canonicalOrigin: string;
1816
- /**
1817
- * The host of the federated server, including the hostname
1818
- * (e.g., `example.com`) and the port following a colon (e.g., `:8080`)
1819
- * if it is not the default port for the scheme.
1820
- * @since 0.12.0
1821
- */
1822
- readonly host: string;
1823
- /**
1824
- * The hostname of the federated server (e.g., `example.com`). This is
1825
- * the same as the host without the port.
1826
- * @since 0.12.0
1827
- */
1828
- readonly hostname: string;
1829
- /**
1830
- * The user-defined data associated with the context.
1831
- */
1832
- readonly data: TContextData;
1833
- /**
1834
- * The OpenTelemetry tracer provider.
1835
- * @since 1.3.0
1836
- */
1837
- readonly tracerProvider: TracerProvider;
1838
- /**
1839
- * The document loader for loading remote JSON-LD documents.
1840
- */
1841
- readonly documentLoader: DocumentLoader;
1842
- /**
1843
- * The context loader for loading remote JSON-LD contexts.
1844
- */
1845
- readonly contextLoader: DocumentLoader;
1846
- /**
1847
- * The federation object that this context belongs to.
1848
- * @since 1.6.0
1849
- */
1850
- readonly federation: Federation<TContextData>;
1851
- /**
1852
- * Creates a new context with the same properties as this one,
1853
- * but with the given data.
1854
- * @param data The new data to associate with the context.
1855
- * @returns A new context with the same properties as this one,
1856
- * but with the given data.
1857
- * @since 1.6.0
1858
- */
1859
- clone(data: TContextData): Context<TContextData>;
1860
- /**
1861
- * Builds the URI of the NodeInfo document.
1862
- * @returns The NodeInfo URI.
1863
- * @throws {RouterError} If no NodeInfo dispatcher is available.
1864
- * @since 0.2.0
1865
- */
1866
- getNodeInfoUri(): URL;
1867
- /**
1868
- * Builds the URI of an actor with the given identifier.
1869
- * @param identifier The actor's identifier.
1870
- * @returns The actor's URI.
1871
- * @throws {RouterError} If no actor dispatcher is available.
1872
- */
1873
- getActorUri(identifier: string): URL;
1874
- /**
1875
- * Builds the URI of an object with the given class and values.
1876
- * @param cls The class of the object.
1877
- * @param values The values to pass to the object dispatcher.
1878
- * @returns The object's URI.
1879
- * @throws {RouterError} If no object dispatcher is available for the class.
1880
- * @throws {TypeError} If values are invalid.
1881
- * @since 0.7.0
1882
- */
1883
- getObjectUri<TObject extends Object$1>(cls: ConstructorWithTypeId<TObject>, values: Record<string, string>): URL;
1884
- /**
1885
- * Builds the URI of an actor's outbox with the given identifier.
1886
- * @param identifier The actor's identifier.
1887
- * @returns The actor's outbox URI.
1888
- * @throws {RouterError} If no outbox dispatcher is available.
1889
- */
1890
- getOutboxUri(identifier: string): URL;
1891
- /**
1892
- * Builds the URI of the shared inbox.
1893
- * @returns The shared inbox URI.
1894
- * @throws {RouterError} If no inbox listener is available.
1895
- */
1896
- getInboxUri(): URL;
1897
- /**
1898
- * Builds the URI of an actor's inbox with the given identifier.
1899
- * @param identifier The actor's identifier.
1900
- * @returns The actor's inbox URI.
1901
- * @throws {RouterError} If no inbox listener is available.
1902
- */
1903
- getInboxUri(identifier: string): URL;
1904
- /**
1905
- * Builds the URI of an actor's following collection with the given
1906
- * identifier.
1907
- * @param identifier The actor's identifier.
1908
- * @returns The actor's following collection URI.
1909
- * @throws {RouterError} If no following collection is available.
1910
- */
1911
- getFollowingUri(identifier: string): URL;
1912
- /**
1913
- * Builds the URI of an actor's followers collection with the given
1914
- * identifier.
1915
- * @param identifier The actor's identifier.
1916
- * @returns The actor's followers collection URI.
1917
- * @throws {RouterError} If no followers collection is available.
1918
- */
1919
- getFollowersUri(identifier: string): URL;
1920
- /**
1921
- * Builds the URI of an actor's liked collection with the given identifier.
1922
- * @param identifier The actor's identifier.
1923
- * @returns The actor's liked collection URI.
1924
- * @throws {RouterError} If no liked collection is available.
1925
- * @since 0.11.0
1926
- */
1927
- getLikedUri(identifier: string): URL;
1928
- /**
1929
- * Builds the URI of an actor's featured collection with the given identifier.
1930
- * @param identifier The actor's identifier.
1931
- * @returns The actor's featured collection URI.
1932
- * @throws {RouterError} If no featured collection is available.
1933
- * @since 0.11.0
1934
- */
1935
- getFeaturedUri(identifier: string): URL;
1936
- /**
1937
- * Builds the URI of an actor's featured tags collection with the given
1938
- * identifier.
1939
- * @param identifier The actor's identifier.
1940
- * @returns The actor's featured tags collection URI.
1941
- * @throws {RouterError} If no featured tags collection is available.
1942
- * @since 0.11.0
1943
- */
1944
- getFeaturedTagsUri(identifier: string): URL;
1945
- /**
1946
- * Determines the type of the URI and extracts the associated data.
1947
- * @param uri The URI to parse.
1948
- * @returns The result of parsing the URI. If `null` is given or
1949
- * the URI is not recognized, `null` is returned.
1950
- * @since 0.9.0
1951
- */
1952
- parseUri(uri: URL | null): ParseUriResult | null;
1953
- /**
1954
- * Gets the key pairs for an actor.
1955
- * @param identifier The actor's identifier.
1956
- * @returns An async iterable of the actor's key pairs. It can be empty.
1957
- * @since 0.10.0
1958
- */
1959
- getActorKeyPairs(identifier: string): Promise<ActorKeyPair[]>;
1960
- /**
1961
- * Gets an authenticated {@link DocumentLoader} for the given identity.
1962
- * Note that an authenticated document loader intentionally does not cache
1963
- * the fetched documents.
1964
- * @param identity The identity to get the document loader for.
1965
- * The actor's identifier or username.
1966
- * @returns The authenticated document loader.
1967
- * @throws {Error} If the identity is not valid.
1968
- * @throws {TypeError} If the key is invalid or unsupported.
1969
- * @since 0.4.0
1970
- */
1971
- getDocumentLoader(identity: {
1972
- identifier: string;
1973
- } | {
1974
- username: string;
1975
- }): Promise<DocumentLoader>;
1976
- /**
1977
- * Gets an authenticated {@link DocumentLoader} for the given identity.
1978
- * Note that an authenticated document loader intentionally does not cache
1979
- * the fetched documents.
1980
- * @param identity The identity to get the document loader for.
1981
- * The actor's key pair.
1982
- * @returns The authenticated document loader.
1983
- * @throws {TypeError} If the key is invalid or unsupported.
1984
- * @since 0.4.0
1985
- */
1986
- getDocumentLoader(identity: {
1987
- keyId: URL;
1988
- privateKey: CryptoKey;
1989
- }): DocumentLoader;
1990
- /**
1991
- * Looks up an ActivityStreams object by its URI (including `acct:` URIs)
1992
- * or a fediverse handle (e.g., `@user@server` or `user@server`).
1993
- *
1994
- * @example
1995
- * ``` typescript
1996
- * // Look up an actor by its fediverse handle:
1997
- * await ctx.lookupObject("@hongminhee@fosstodon.org");
1998
- * // returning a `Person` object.
1999
- *
2000
- * // A fediverse handle can omit the leading '@':
2001
- * await ctx.lookupObject("hongminhee@fosstodon.org");
2002
- * // returning a `Person` object.
2003
- *
2004
- * // A `acct:` URI can be used as well:
2005
- * await ctx.lookupObject("acct:hongminhee@fosstodon.org");
2006
- * // returning a `Person` object.
2007
- *
2008
- * // Look up an object by its URI:
2009
- * await ctx.lookupObject("https://todon.eu/@hongminhee/112060633798771581");
2010
- * // returning a `Note` object.
2011
- *
2012
- * // It can be a `URL` object as well:
2013
- * await ctx.lookupObject(
2014
- * new URL("https://todon.eu/@hongminhee/112060633798771581")
2015
- * );
2016
- * // returning a `Note` object.
2017
- * ```
2018
- *
2019
- * It's almost the same as the {@link lookupObject} function, but it uses
2020
- * the context's document loader and context loader by default.
2021
- *
2022
- * @param identifier The URI or fediverse handle to look up.
2023
- * @param options Lookup options.
2024
- * @returns The object, or `null` if not found.
2025
- * @since 0.15.0
2026
- */
2027
- lookupObject(identifier: string | URL, options?: LookupObjectOptions): Promise<Object$1 | null>;
2028
- /**
2029
- * Traverses a collection, yielding each item in the collection.
2030
- * If the collection is paginated, it will fetch the next page
2031
- * automatically.
2032
- *
2033
- * @example
2034
- * ``` typescript
2035
- * const collection = await ctx.lookupObject(collectionUrl);
2036
- * if (collection instanceof Collection) {
2037
- * for await (const item of ctx.traverseCollection(collection)) {
2038
- * console.log(item.id?.href);
2039
- * }
2040
- * }
2041
- * ```
2042
- *
2043
- * It's almost the same as the {@link traverseCollection} function, but it
2044
- * uses the context's document loader and context loader by default.
2045
- * @param collection The collection to traverse.
2046
- * @param options Options for traversing the collection.
2047
- * @returns An async iterable of each item in the collection.
2048
- * @since 1.1.0
2049
- */
2050
- traverseCollection(collection: Collection, options?: TraverseCollectionOptions): AsyncIterable<Object$1 | Link>;
2051
- /**
2052
- * Fetches the NodeInfo document from the given URL.
2053
- * @param url The base URL of the server. If `options.direct` is turned off
2054
- * (default), the NodeInfo document will be fetched from
2055
- * the `.well-known` location of this URL (hence the only origin
2056
- * of the URL is used). If `options.direct` is turned on,
2057
- * the NodeInfo document will be fetched from the given URL.
2058
- * @param options Options for fetching the NodeInfo document.
2059
- * @returns The NodeInfo document if it could be fetched successfully.
2060
- * Otherwise, `undefined` is returned.
2061
- * @since 1.4.0
2062
- */
2063
- lookupNodeInfo(url: URL | string, options?: GetNodeInfoOptions & {
2064
- parse?: "strict" | "best-effort";
2065
- }): Promise<NodeInfo | undefined>;
2066
- /**
2067
- * Fetches the NodeInfo document from the given URL.
2068
- * @param url The base URL of the server. If `options.direct` is turned off
2069
- * (default), the NodeInfo document will be fetched from
2070
- * the `.well-known` location of this URL (hence the only origin
2071
- * of the URL is used). If `options.direct` is turned on,
2072
- * the NodeInfo document will be fetched from the given URL.
2073
- * @param options Options for fetching the NodeInfo document.
2074
- * @returns The NodeInfo document if it could be fetched successfully.
2075
- * Otherwise, `undefined` is returned.
2076
- * @since 1.4.0
2077
- */
2078
- lookupNodeInfo(url: URL | string, options?: GetNodeInfoOptions & {
2079
- parse: "none";
2080
- }): Promise<JsonValue | undefined>;
2081
- /**
2082
- * Looks up a WebFinger resource.
2083
- *
2084
- * It's almost the same as the {@link lookupWebFinger} function, but it uses
2085
- * the context's configuration by default.
2086
- *
2087
- * @param resource The resource URL to look up.
2088
- * @param options Extra options for looking up the resource.
2089
- * @returns The resource descriptor, or `null` if not found.
2090
- * @since 1.6.0
2091
- */
2092
- lookupWebFinger(resource: URL | string, options?: LookupWebFingerOptions): Promise<ResourceDescriptor | null>;
2093
- /**
2094
- * Sends an activity to recipients' inboxes.
2095
- * @param sender The sender's identifier or the sender's username or
2096
- * the sender's key pair(s).
2097
- * @param recipients The recipients of the activity.
2098
- * @param activity The activity to send.
2099
- * @param options Options for sending the activity.
2100
- */
2101
- sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
2102
- identifier: string;
2103
- } | {
2104
- username: string;
2105
- }, recipients: Recipient | Recipient[], activity: Activity, options?: SendActivityOptions): Promise<void>;
2106
- /**
2107
- * Sends an activity to the inboxes of the sender's followers.
2108
- * @param sender The sender's identifier or the sender's username.
2109
- * @param recipients In this case, it must be `"followers"`.
2110
- * @param activity The activity to send.
2111
- * @param options Options for sending the activity.
2112
- * @throws {Error} If no followers collection is registered.
2113
- * @since 0.14.0
2114
- */
2115
- sendActivity(sender: {
2116
- identifier: string;
2117
- } | {
2118
- username: string;
2119
- }, recipients: "followers", activity: Activity, options?: SendActivityOptionsForCollection): Promise<void>;
2120
- /**
2121
- * Manually routes an activity to the appropriate inbox listener.
2122
- *
2123
- * It is useful for routing an activity that is not received from the network,
2124
- * or for routing an activity that is enclosed in another activity.
2125
- *
2126
- * Note that the activity will be verified if it has Object Integrity Proofs
2127
- * or is equivalent to the actual remote object. If the activity is not
2128
- * verified, it will be rejected.
2129
- * @param recipient The recipient of the activity. If it is `null`,
2130
- * the activity will be routed to the shared inbox.
2131
- * Otherwise, the activity will be routed to the personal
2132
- * inbox of the recipient with the given identifier.
2133
- * @param activity The activity to route. It must have a proof or
2134
- * a dereferenceable `id` to verify the activity.
2135
- * @param options Options for routing the activity.
2136
- * @returns `true` if the activity is successfully verified and routed.
2137
- * Otherwise, `false`.
2138
- * @since 1.3.0
2139
- */
2140
- routeActivity(recipient: string | null, activity: Activity, options?: RouteActivityOptions): Promise<boolean>;
2141
- /**
2142
- * Builds the URI of a collection of objects with the given name and values.
2143
- * @param name The name of the collection, which can be a string or a symbol.
2144
- * @param values The values of the URI parameters.
2145
- * @return The URI of the collection.
2146
- * @throws {RouterError} If no object dispatcher is available for the name.
2147
- * @throws {TypeError} If values are invalid.
2148
- * @since 1.8.0
2149
- */
2150
- getCollectionUri<TParam extends Record<string, string>>(name: string | symbol, values: TParam): URL;
2151
- }
2152
- /**
2153
- * A context for a request.
2154
- */
2155
- interface RequestContext<TContextData> extends Context<TContextData> {
2156
- /**
2157
- * The request object.
2158
- */
2159
- readonly request: Request;
2160
- /**
2161
- * The URL of the request.
2162
- */
2163
- readonly url: URL;
2164
- /**
2165
- * Creates a new context with the same properties as this one,
2166
- * but with the given data.
2167
- * @param data The new data to associate with the context.
2168
- * @returns A new context with the same properties as this one,
2169
- * but with the given data.
2170
- * @since 1.6.0
2171
- */
2172
- clone(data: TContextData): RequestContext<TContextData>;
2173
- /**
2174
- * Gets an {@link Actor} object for the given identifier.
2175
- * @param identifier The actor's identifier.
2176
- * @returns The actor object, or `null` if the actor is not found.
2177
- * @throws {Error} If no actor dispatcher is available.
2178
- * @since 0.7.0
2179
- */
2180
- getActor(identifier: string): Promise<Actor | null>;
2181
- /**
2182
- * Gets an object of the given class with the given values.
2183
- * @param cls The class to instantiate.
2184
- * @param values The values to pass to the object dispatcher.
2185
- * @returns The object of the given class with the given values, or `null`
2186
- * if the object is not found.
2187
- * @throws {Error} If no object dispatcher is available for the class.
2188
- * @throws {TypeError} If values are invalid.
2189
- * @since 0.7.0
2190
- */
2191
- getObject<TObject extends Object$1>(cls: ConstructorWithTypeId<TObject>, values: Record<string, string>): Promise<TObject | null>;
2192
- /**
2193
- * Gets the public key of the sender, if any exists and it is verified.
2194
- * Otherwise, `null` is returned.
2195
- *
2196
- * This can be used for implementing [authorized fetch] (also known as
2197
- * secure mode) in ActivityPub.
2198
- *
2199
- * [authorized fetch]: https://swicg.github.io/activitypub-http-signature/#authorized-fetch
2200
- *
2201
- * @returns The public key of the sender, or `null` if the sender is not verified.
2202
- * @since 0.7.0
2203
- */
2204
- getSignedKey(): Promise<CryptographicKey | null>;
2205
- /**
2206
- * Gets the public key of the sender, if any exists and it is verified.
2207
- * Otherwise, `null` is returned.
2208
- *
2209
- * This can be used for implementing [authorized fetch] (also known as
2210
- * secure mode) in ActivityPub.
2211
- *
2212
- * [authorized fetch]: https://swicg.github.io/activitypub-http-signature/#authorized-fetch
2213
- *
2214
- * @param options Options for getting the signed key. You usually may want to
2215
- * specify the custom `documentLoader` so that making
2216
- * an HTTP request to the sender's server is signed with
2217
- * your [instance actor].
2218
- * @returns The public key of the sender, or `null` if the sender is not verified.
2219
- * @since 1.5.0
2220
- *
2221
- * [instance actor]: https://swicg.github.io/activitypub-http-signature/#instance-actor
2222
- */
2223
- getSignedKey(options: GetSignedKeyOptions): Promise<CryptographicKey | null>;
2224
- /**
2225
- * Gets the owner of the signed key, if any exists and it is verified.
2226
- * Otherwise, `null` is returned.
2227
- *
2228
- * This can be used for implementing [authorized fetch] (also known as
2229
- * secure mode) in ActivityPub.
2230
- *
2231
- * [authorized fetch]: https://swicg.github.io/activitypub-http-signature/#authorized-fetch
2232
- *
2233
- * @returns The owner of the signed key, or `null` if the key is not verified
2234
- * or the owner is not found.
2235
- * @since 0.7.0
2236
- */
2237
- getSignedKeyOwner(): Promise<Actor | null>;
2238
- /**
2239
- * Gets the owner of the signed key, if any exists and it is verified.
2240
- * Otherwise, `null` is returned.
2241
- *
2242
- * This can be used for implementing [authorized fetch] (also known as
2243
- * secure mode) in ActivityPub.
2244
- *
2245
- * [authorized fetch]: https://swicg.github.io/activitypub-http-signature/#authorized-fetch
2246
- *
2247
- * @param options Options for getting the key owner. You usually may want to
2248
- * specify the custom `documentLoader` so that making
2249
- * an HTTP request to the key owner's server is signed with
2250
- * your [instance actor].
2251
- * @returns The owner of the signed key, or `null` if the key is not verified
2252
- * or the owner is not found.
2253
- * @since 1.5.0
2254
- *
2255
- * [instance actor]: https://swicg.github.io/activitypub-http-signature/#instance-actor
2256
- */
2257
- getSignedKeyOwner(options: GetKeyOwnerOptions): Promise<Actor | null>;
2258
- }
2259
- /**
2260
- * A context for inbox listeners.
2261
- * @since 1.0.0
2262
- */
2263
- interface InboxContext<TContextData> extends Context<TContextData> {
2264
- /**
2265
- * The identifier of the recipient of the inbox. If the inbox is a shared
2266
- * inbox, it is `null`.
2267
- * @since 1.2.0
2268
- */
2269
- readonly recipient: string | null;
2270
- /**
2271
- * Creates a new context with the same properties as this one,
2272
- * but with the given data.
2273
- * @param data The new data to associate with the context.
2274
- * @returns A new context with the same properties as this one,
2275
- * but with the given data.
2276
- * @since 1.6.0
2277
- */
2278
- clone(data: TContextData): InboxContext<TContextData>;
2279
- /**
2280
- * Forwards a received activity to the recipients' inboxes. The forwarded
2281
- * activity will be signed in HTTP Signatures by the forwarder, but its
2282
- * payload will not be modified, i.e., Linked Data Signatures and Object
2283
- * Integrity Proofs will not be added. Therefore, if the activity is not
2284
- * signed (i.e., it has neither Linked Data Signatures nor Object Integrity
2285
- * Proofs), the recipient probably will not trust the activity.
2286
- * @param forwarder The forwarder's identifier or the forwarder's username
2287
- * or the forwarder's key pair(s).
2288
- * @param recipients The recipients of the activity.
2289
- * @param options Options for forwarding the activity.
2290
- * @since 1.0.0
2291
- */
2292
- forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
2293
- identifier: string;
2294
- } | {
2295
- username: string;
2296
- }, recipients: Recipient | Recipient[], options?: ForwardActivityOptions): Promise<void>;
2297
- /**
2298
- * Forwards a received activity to the recipients' inboxes. The forwarded
2299
- * activity will be signed in HTTP Signatures by the forwarder, but its
2300
- * payload will not be modified, i.e., Linked Data Signatures and Object
2301
- * Integrity Proofs will not be added. Therefore, if the activity is not
2302
- * signed (i.e., it has neither Linked Data Signatures nor Object Integrity
2303
- * Proofs), the recipient probably will not trust the activity.
2304
- * @param forwarder The forwarder's identifier or the forwarder's username.
2305
- * @param recipients In this case, it must be `"followers"`.
2306
- * @param options Options for forwarding the activity.
2307
- * @since 1.0.0
2308
- */
2309
- forwardActivity(forwarder: {
2310
- identifier: string;
2311
- } | {
2312
- username: string;
2313
- }, recipients: "followers", options?: ForwardActivityOptions): Promise<void>;
2314
- }
2315
- /**
2316
- * A result of parsing an URI.
2317
- */
2318
- type ParseUriResult =
2319
- /**
2320
- * The case of an actor URI.
2321
- */
2322
- {
2323
- readonly type: "actor";
2324
- readonly identifier: string;
2325
- }
2326
- /**
2327
- * The case of an object URI.
2328
- */ | {
2329
- readonly type: "object";
2330
- readonly class: ConstructorWithTypeId<Object$1>;
2331
- readonly typeId: URL;
2332
- readonly values: Record<string, string>;
2333
- }
2334
- /**
2335
- * The case of an shared inbox URI.
2336
- */ | {
2337
- readonly type: "inbox";
2338
- readonly identifier: undefined;
2339
- }
2340
- /**
2341
- * The case of an personal inbox URI.
2342
- */ | {
2343
- readonly type: "inbox";
2344
- readonly identifier: string;
2345
- }
2346
- /**
2347
- * The case of an outbox collection URI.
2348
- */ | {
2349
- readonly type: "outbox";
2350
- readonly identifier: string;
2351
- }
2352
- /**
2353
- * The case of a following collection URI.
2354
- */ | {
2355
- readonly type: "following";
2356
- readonly identifier: string;
2357
- }
2358
- /**
2359
- * The case of a followers collection URI.
2360
- */ | {
2361
- readonly type: "followers";
2362
- readonly identifier: string;
2363
- }
2364
- /**
2365
- * The case of a liked collection URI.
2366
- * @since 0.11.0
2367
- */ | {
2368
- readonly type: "liked";
2369
- readonly identifier: string;
2370
- }
2371
- /**
2372
- * The case of a featured collection URI.
2373
- * @since 0.11.0
2374
- */ | {
2375
- readonly type: "featured";
2376
- readonly identifier: string;
2377
- }
2378
- /**
2379
- * The case of a featured tags collection URI.
2380
- * @since 0.11.0
2381
- */ | {
2382
- readonly type: "featuredTags";
2383
- readonly identifier: string;
2384
- }
2385
- /**
2386
- * The case of a custom collection URI.
2387
- * @since 1.8.0
2388
- */ | {
2389
- readonly type: "collection";
2390
- readonly name: string | symbol;
2391
- readonly class: ConstructorWithTypeId<Object$1>;
2392
- readonly typeId: URL;
2393
- readonly values: Record<string, string>;
2394
- }
2395
- /**
2396
- * The case of a custom ordered collection URI.
2397
- * @since 1.8.0
2398
- */ | {
2399
- readonly type: "orderedCollection";
2400
- readonly name: string | symbol;
2401
- readonly class: ConstructorWithTypeId<Object$1>;
2402
- readonly typeId: URL;
2403
- readonly values: Record<string, string>;
2404
- };
2405
- /**
2406
- * Options for {@link Context.sendActivity} method.
2407
- */
2408
- interface SendActivityOptions {
2409
- /**
2410
- * Whether to prefer the shared inbox for the recipients.
2411
- */
2412
- readonly preferSharedInbox?: boolean;
2413
- /**
2414
- * Whether to send the activity immediately, without enqueuing it.
2415
- * If `true`, the activity will be sent immediately and the retrial
2416
- * policy will not be applied.
2417
- *
2418
- * @since 0.3.0
2419
- */
2420
- readonly immediate?: boolean;
2421
- /**
2422
- * Determines how activities are queued when sent to multiple recipients.
2423
- *
2424
- * - "auto" (default): Automatically chooses optimal strategy based on
2425
- * recipient count.
2426
- * - "skip": Always enqueues individual messages per recipient,
2427
- * bypassing the fanout queue. Use when payload needs to vary per recipient.
2428
- * - "force": Always uses fanout queue regardless of recipient count.
2429
- * Useful for testing or special cases.
2430
- *
2431
- * This option is ignored when `immediate: true` is specified, as immediate
2432
- * delivery bypasses all queuing mechanisms.
2433
- *
2434
- * @default `"auto"`
2435
- * @since 1.5.0
2436
- */
2437
- readonly fanout?: "auto" | "skip" | "force";
2438
- /**
2439
- * The base URIs to exclude from the recipients' inboxes. It is useful
2440
- * for excluding the recipients having the same shared inbox with the sender.
2441
- *
2442
- * Note that the only `origin` parts of the `URL`s are compared.
2443
- *
2444
- * @since 0.9.0
2445
- */
2446
- readonly excludeBaseUris?: readonly URL[];
2447
- /**
2448
- * An optional key to ensure ordered delivery of activities. Activities with
2449
- * the same `orderingKey` are guaranteed to be delivered in the order they
2450
- * were enqueued, per recipient server.
2451
- *
2452
- * Typical use case: pass the object ID (e.g., `Note` ID) to ensure that
2453
- * `Create`, `Update`, and `Delete` activities for the same object are
2454
- * delivered in order.
2455
- *
2456
- * When omitted, no ordering is guaranteed (maximum parallelism).
2457
- *
2458
- * @since 2.0.0
2459
- */
2460
- readonly orderingKey?: string;
2461
- }
2462
- /**
2463
- * Options for {@link Context.sendActivity} method when sending to a collection.
2464
- * @since 1.5.0
2465
- */
2466
- interface SendActivityOptionsForCollection extends SendActivityOptions {
2467
- /**
2468
- * Whether to synchronize the collection using `Collection-Synchronization`
2469
- * header ([FEP-8fcf]).
2470
- *
2471
- * [FEP-8fcf]: https://w3id.org/fep/8fcf
2472
- */
2473
- syncCollection?: boolean;
2474
- }
2475
- /**
2476
- * Options for {@link InboxContext.forwardActivity} method.
2477
- * @since 1.0.0
2478
- */
2479
- type ForwardActivityOptions = Omit<SendActivityOptions, "fanout"> & {
2480
- /**
2481
- * Whether to skip forwarding the activity if it is not signed, i.e., it has
2482
- * neither Linked Data Signatures nor Object Integrity Proofs.
2483
- *
2484
- * If the activity is not signed, the recipient probably will not trust the
2485
- * activity. Therefore, it is recommended to skip forwarding the activity
2486
- * if it is not signed.
2487
- */
2488
- skipIfUnsigned: boolean;
2489
- };
2490
- /**
2491
- * Options for {@link Context.routeActivity} method.
2492
- * @since 1.3.0
2493
- */
2494
- interface RouteActivityOptions {
2495
- /**
2496
- * Whether to skip enqueuing the activity and invoke the listener immediately.
2497
- * If no inbox queue is available, this option is ignored and the activity
2498
- * will be always invoked immediately.
2499
- * @default false
2500
- */
2501
- immediate?: boolean;
2502
- /**
2503
- * The document loader for loading remote JSON-LD documents.
2504
- */
2505
- documentLoader?: DocumentLoader;
2506
- /**
2507
- * The context loader for loading remote JSON-LD contexts.
2508
- */
2509
- contextLoader?: DocumentLoader;
2510
- /**
2511
- * The OpenTelemetry tracer provider. If omitted, the global tracer provider
2512
- * is used.
2513
- */
2514
- tracerProvider?: TracerProvider;
2515
- }
2516
- /**
2517
- * Options for {@link Context.getSignedKey} method.
2518
- * @since 1.5.0
2519
- */
2520
- interface GetSignedKeyOptions {
2521
- /**
2522
- * The document loader for loading remote JSON-LD documents.
2523
- */
2524
- documentLoader?: DocumentLoader;
2525
- /**
2526
- * The context loader for loading remote JSON-LD contexts.
2527
- */
2528
- contextLoader?: DocumentLoader;
2529
- /**
2530
- * The OpenTelemetry tracer provider. If omitted, the global tracer provider
2531
- * is used.
2532
- */
2533
- tracerProvider?: TracerProvider;
2534
- }
2535
- /**
2536
- * A pair of a public key and a private key in various formats.
2537
- * @since 0.10.0
2538
- */
2539
- interface ActorKeyPair extends CryptoKeyPair {
2540
- /**
2541
- * The URI of the public key, which is used for verifying HTTP Signatures.
2542
- */
2543
- readonly keyId: URL;
2544
- /**
2545
- * A {@link CryptographicKey} instance of the public key.
2546
- */
2547
- readonly cryptographicKey: CryptographicKey;
2548
- /**
2549
- * A {@link Multikey} instance of the public key.
2550
- */
2551
- readonly multikey: Multikey;
2552
- }
2553
- //#endregion
2554
- export { ActivityTransformer, 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, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };