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