@fedify/fedify 2.0.1-dev.401 → 2.0.2-dev.407

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