@fedify/fedify 2.0.0-dev.1485 → 2.0.0-dev.149

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