@fedify/fedify 2.0.1 → 2.0.2-dev.415

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