@fedify/fedify 2.0.0-pr.412.1559 → 2.0.0-pr.412.1794

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