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