@fedify/fedify 1.9.6 → 1.9.8

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 (274) hide show
  1. package/dist/{actor-CEGEmRll.js → actor-BTA45fXF.js} +1205 -2768
  2. package/dist/{actor-Ydzhc8dj.d.cts → actor-Be-68iJP.d.cts} +3 -3
  3. package/dist/{actor-C1Euqngb.d.ts → actor-C5AY0Tno.d.ts} +3 -3
  4. package/dist/{actor-DbpZ6pzg.js → actor-DGa1EWaV.mjs} +8 -15
  5. package/dist/{actor-DlS-Q8hE.cjs → actor-DxfJk4lY.cjs} +3112 -4674
  6. package/dist/{assert-MZs1qjMx.js → assert-DikXweDx.mjs} +5 -9
  7. package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
  8. package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
  9. package/dist/{assert_is_error-BPGph1Jx.js → assert_is_error-C50x8tnw.mjs} +5 -9
  10. package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals--wG9hV7u.mjs} +6 -13
  11. package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-CJC9ThS-.mjs} +6 -11
  12. package/dist/{assert_throws-BOO88avQ.js → assert_throws-BIL7gChy.mjs} +6 -10
  13. package/dist/{authdocloader-DUQcOTRS.js → authdocloader-BC2rYCy1.mjs} +9 -14
  14. package/dist/{authdocloader-CT_V4Z7G.cjs → authdocloader-BrhFB421.cjs} +14 -22
  15. package/dist/{authdocloader-BLqMyboS.js → authdocloader-CqtNsX_N.js} +8 -15
  16. package/dist/{builder-BO61xeXE.js → builder-CIkAhIGC.mjs} +31 -40
  17. package/dist/{client-DF8anIB5.d.ts → client-D8OSiPBT.d.ts} +2 -2
  18. package/dist/{client-UG5wpNhG.js → client-MXqit6c-.mjs} +11 -15
  19. package/dist/{client-DjT_tegg.d.cts → client-T0VFOdMw.d.cts} +2 -2
  20. package/dist/{collection-CSzG2j1P.js → collection-BD6-SZ6O.mjs} +7 -12
  21. package/dist/compat/mod.cjs +5 -8
  22. package/dist/compat/mod.d.cts +78 -12
  23. package/dist/compat/mod.d.ts +78 -12
  24. package/dist/compat/mod.js +4 -8
  25. package/dist/compat/transformers.test.mjs +62 -0
  26. package/dist/{context-CwUAkopp.d.cts → context-CACMqDzl.d.cts} +33 -26
  27. package/dist/{context-CXUibY4L.d.ts → context-K4cCphQj.d.ts} +33 -26
  28. package/dist/{denokv-Bv33Xxea.js → denokv-CoSB_Eps.mjs} +22 -11
  29. package/dist/{docloader-BIFI3OS7.cjs → docloader-BVuUhBLI.cjs} +112 -212
  30. package/dist/{docloader-fJgJeqiX.js → docloader-BoXhusJ1.js} +17 -151
  31. package/dist/{docloader-CxWcuWqQ.d.ts → docloader-DSaLRXEA.d.ts} +2 -7
  32. package/dist/{docloader-D-MrRyHl.d.cts → docloader-DpGRDZrn.d.cts} +2 -7
  33. package/dist/{esm-C1EfGjSS.js → esm-BHJ7sdNg.mjs} +49 -85
  34. package/dist/federation/{builder.test.js → builder.test.mjs} +22 -41
  35. package/dist/federation/collection.test.d.mts +2 -0
  36. package/dist/federation/collection.test.mjs +21 -0
  37. package/dist/federation/handler.test.d.mts +2 -0
  38. package/dist/federation/{handler.test.js → handler.test.mjs} +22 -49
  39. package/dist/federation/idempotency.test.d.mts +2 -0
  40. package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +29 -59
  41. package/dist/federation/inbox.test.d.mts +2 -0
  42. package/dist/federation/{inbox.test.js → inbox.test.mjs} +10 -15
  43. package/dist/federation/keycache.test.d.mts +2 -0
  44. package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -18
  45. package/dist/federation/kv.test.d.mts +2 -0
  46. package/dist/federation/{kv.test.js → kv.test.mjs} +9 -20
  47. package/dist/federation/middleware.test.d.mts +2 -0
  48. package/dist/federation/{middleware.test.js → middleware.test.mjs} +182 -197
  49. package/dist/federation/mod.cjs +223 -21
  50. package/dist/federation/mod.d.cts +4 -13
  51. package/dist/federation/mod.d.ts +4 -13
  52. package/dist/federation/mod.js +218 -18
  53. package/dist/federation/mq.test.d.mts +2 -0
  54. package/dist/federation/{mq.test.js → mq.test.mjs} +23 -38
  55. package/dist/federation/retry.test.d.mts +2 -0
  56. package/dist/federation/{retry.test.js → retry.test.mjs} +9 -14
  57. package/dist/federation/router.test.d.mts +2 -0
  58. package/dist/federation/{router.test.js → router.test.mjs} +12 -19
  59. package/dist/federation/send.test.d.mts +2 -0
  60. package/dist/federation/{send.test.js → send.test.mjs} +17 -26
  61. package/dist/{http-wsGR6KkT.d.ts → http-BZpls--H.d.ts} +5 -9
  62. package/dist/{http-CR-Eg1Uq.js → http-Bu5ZNlhZ.mjs} +16 -32
  63. package/dist/{http-B1_DzfAU.d.cts → http-C7WoprmE.d.cts} +5 -9
  64. package/dist/{http-BgopPF-8.cjs → http-DKw-O_VY.cjs} +51 -68
  65. package/dist/{http-05HxN-lp.js → http-VJbz6sKD.js} +17 -33
  66. package/dist/{inbox-DcJN1cxM.js → inbox-DkbTULXE.mjs} +17 -25
  67. package/dist/key-4fu6v0Jf.mjs +5 -0
  68. package/dist/{key-DjS1X9TG.cjs → key-B-wFdaPB.cjs} +42 -50
  69. package/dist/{key-ibMO03_0.js → key-BNMK_IVr.mjs} +12 -18
  70. package/dist/key-CancShOo.cjs +4 -0
  71. package/dist/{key-CPJcJjp-.js → key-DK3o0FEH.js} +19 -19
  72. package/dist/{keycache-CMUfqYqr.js → keycache-D-Vj8z88.mjs} +6 -10
  73. package/dist/{keys-IZ5050fT.js → keys-B27nVeIs.mjs} +6 -10
  74. package/dist/{kv-C7sopW2E.d.ts → kv-Bq9QLKm5.d.ts} +1 -1
  75. package/dist/{kv-CRZrzyXm.js → kv-DM1zFCtL.mjs} +6 -10
  76. package/dist/{kv-63Cil1MD.d.cts → kv-GIrOktyG.d.cts} +1 -1
  77. package/dist/{ld-DHNA2RSQ.js → ld-6jAVu3jV.mjs} +17 -31
  78. package/dist/{lookup-CKZfuyxA.js → lookup-BaU75j-d.js} +5 -11
  79. package/dist/{lookup-C4_dVYz7.cjs → lookup-BiIPmTwB.cjs} +16 -23
  80. package/dist/{lookup-BMAWLsP2.js → lookup-DmeJ8WUw.mjs} +8 -17
  81. package/dist/middleware-9ByEpBvV.cjs +4 -0
  82. package/dist/{middleware-CGbvIGvy.cjs → middleware-C188G4Go.cjs} +494 -547
  83. package/dist/{middleware-DrhEvfTo.js → middleware-Db1yZQaT.mjs} +276 -321
  84. package/dist/{middleware-ODfDRN3q.js → middleware-Do06X21v.js} +349 -393
  85. package/dist/middleware-DrfZEjyc.mjs +5 -0
  86. package/dist/{mod-CDObsV1d.d.ts → mod-BSwc3_rD.d.ts} +3 -3
  87. package/dist/{mod-DBzN0aCM.d.ts → mod-BTNpXcPj.d.ts} +2 -2
  88. package/dist/{mod-fjqfsrty.d.cts → mod-Chb_NKPp.d.cts} +4 -4
  89. package/dist/{mod-DgcYoyZK.d.ts → mod-DHoc3toL.d.ts} +4 -4
  90. package/dist/{mod-jQ4OODsl.d.cts → mod-DIMx6YjJ.d.cts} +2 -2
  91. package/dist/{mod-BUbqxBev.d.cts → mod-HElaq2UB.d.cts} +3 -3
  92. package/dist/mod.cjs +31 -33
  93. package/dist/mod.d.cts +15 -17
  94. package/dist/mod.d.ts +15 -17
  95. package/dist/mod.js +20 -23
  96. package/dist/{mq-B7R1Q-M5.d.cts → mq-CrItclRD.d.cts} +1 -1
  97. package/dist/{mq-CRGm1e_F.d.ts → mq-D_ZZRdby.d.ts} +1 -1
  98. package/dist/nodeinfo/client.test.d.mts +2 -0
  99. package/dist/nodeinfo/{client.test.js → client.test.mjs} +23 -45
  100. package/dist/nodeinfo/handler.test.d.mts +2 -0
  101. package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +14 -43
  102. package/dist/nodeinfo/mod.cjs +5 -9
  103. package/dist/nodeinfo/mod.d.cts +2 -5
  104. package/dist/nodeinfo/mod.d.ts +2 -5
  105. package/dist/nodeinfo/mod.js +4 -9
  106. package/dist/nodeinfo/semver.test.d.mts +2 -0
  107. package/dist/nodeinfo/{semver.test.js → semver.test.mjs} +28 -51
  108. package/dist/nodeinfo/types.test.d.mts +2 -0
  109. package/dist/nodeinfo/{types.test.js → types.test.mjs} +10 -21
  110. package/dist/{owner-DDHsHYQO.js → owner-CKuGt_T9.mjs} +10 -13
  111. package/dist/{owner-BbeUDvOu.d.ts → owner-DPAPnB0R.d.ts} +4 -4
  112. package/dist/{owner-6KSEp9eV.d.cts → owner-_rFs0ik_.d.cts} +4 -4
  113. package/dist/{proof-V1uQaB2y.js → proof-CmTtG_t-.js} +33 -57
  114. package/dist/{proof-CX7ujFFX.cjs → proof-DLOy7HYU.cjs} +112 -135
  115. package/dist/{proof-exgGRW88.js → proof-mJLL2gSA.mjs} +20 -32
  116. package/dist/{retry-D4GJ670a.js → retry-Ddbq3AcK.mjs} +4 -7
  117. package/dist/rolldown-runtime-C7fyD9f2.js +15 -0
  118. package/dist/runtime/authdocloader.test.d.mts +2 -0
  119. package/dist/runtime/{authdocloader.test.js → authdocloader.test.mjs} +16 -28
  120. package/dist/runtime/docloader.test.d.mts +2 -0
  121. package/dist/runtime/{docloader.test.js → docloader.test.mjs} +52 -72
  122. package/dist/runtime/key.test.d.mts +2 -0
  123. package/dist/runtime/{key.test.js → key.test.mjs} +27 -57
  124. package/dist/runtime/langstr.test.d.mts +2 -0
  125. package/dist/runtime/{langstr.test.js → langstr.test.mjs} +9 -19
  126. package/dist/runtime/link.test.d.mts +2 -0
  127. package/dist/runtime/{link.test.js → link.test.mjs} +7 -11
  128. package/dist/runtime/mod.cjs +7 -13
  129. package/dist/runtime/mod.d.cts +103 -6
  130. package/dist/runtime/mod.d.ts +103 -6
  131. package/dist/runtime/mod.js +6 -13
  132. package/dist/runtime/multibase/multibase.test.d.mts +2 -0
  133. package/dist/runtime/multibase/{multibase.test.js → multibase.test.mjs} +16 -33
  134. package/dist/runtime/url.test.d.mts +2 -0
  135. package/dist/runtime/{url.test.js → url.test.mjs} +10 -15
  136. package/dist/{semver-dArNLkR9.js → semver-CgD82xxg.mjs} +13 -28
  137. package/dist/{send-BfMYakUE.js → send-BsQbGuw4.mjs} +7 -12
  138. package/dist/sig/http.test.d.mts +2 -0
  139. package/dist/sig/{http.test.js → http.test.mjs} +119 -203
  140. package/dist/sig/key.test.d.mts +2 -0
  141. package/dist/sig/{key.test.js → key.test.mjs} +13 -22
  142. package/dist/sig/ld.test.d.mts +2 -0
  143. package/dist/sig/{ld.test.js → ld.test.mjs} +24 -39
  144. package/dist/sig/mod.cjs +7 -13
  145. package/dist/sig/mod.d.cts +3 -7
  146. package/dist/sig/mod.d.ts +3 -7
  147. package/dist/sig/mod.js +6 -13
  148. package/dist/sig/owner.test.d.mts +2 -0
  149. package/dist/sig/owner.test.mjs +39 -0
  150. package/dist/sig/proof.test.d.mts +2 -0
  151. package/dist/sig/{proof.test.js → proof.test.mjs} +18 -31
  152. package/dist/{std__assert-X-_kMxKM.js → std__assert-2v7gYiZp.mjs} +13 -24
  153. package/dist/testing/docloader.test.d.mts +2 -0
  154. package/dist/testing/docloader.test.mjs +12 -0
  155. package/dist/testing/{mod.d.ts → mod.d.mts} +371 -541
  156. package/dist/testing/mod.mjs +5 -0
  157. package/dist/{testing-RPOc_gVG.js → testing-DS3gcq8V.mjs} +27 -35
  158. package/dist/{transformers-CoBS-oFG.cjs → transformers-BM0M8hnW.cjs} +20 -25
  159. package/dist/{transformers-BFT6d7J5.js → transformers-BV4OeK9o.js} +3 -7
  160. package/dist/{types-Cptev2nt.js → types-BXfL-dsX.js} +18 -36
  161. package/dist/{types-BIgY6c-l.js → types-CAnkAQGM.mjs} +5 -9
  162. package/dist/{types-CGnM1vft.cjs → types-DpM4FhjW.cjs} +45 -64
  163. package/dist/vocab/actor.test.d.mts +2 -0
  164. package/dist/vocab/{actor.test.js → actor.test.mjs} +308 -550
  165. package/dist/vocab/cjs.test.d.mts +2 -0
  166. package/dist/vocab/cjs.test.mjs +14 -0
  167. package/dist/vocab/lookup.test.d.mts +2 -0
  168. package/dist/vocab/{lookup.test.js → lookup.test.mjs} +29 -45
  169. package/dist/vocab/mod.cjs +251 -16
  170. package/dist/vocab/mod.d.cts +3 -5
  171. package/dist/vocab/mod.d.ts +3 -5
  172. package/dist/vocab/mod.js +244 -10
  173. package/dist/vocab/type.test.d.mts +2 -0
  174. package/dist/vocab/type.test.mjs +16 -0
  175. package/dist/vocab/vocab.test.d.mts +2 -0
  176. package/dist/vocab/{vocab.test.js → vocab.test.mjs} +178 -311
  177. package/dist/{vocab-CDHNj5zp.d.ts → vocab-BLvSEtuz.d.cts} +2 -4
  178. package/dist/{type-COPv6pMi.js → vocab-DuW9rL1h.mjs} +1177 -2871
  179. package/dist/{vocab-Cfs0937i.d.cts → vocab-lhCS9lzq.d.ts} +4 -2
  180. package/dist/webfinger/handler.test.d.mts +2 -0
  181. package/dist/webfinger/{handler.test.js → handler.test.mjs} +23 -56
  182. package/dist/webfinger/lookup.test.d.mts +2 -0
  183. package/dist/webfinger/{lookup.test.js → lookup.test.mjs} +13 -27
  184. package/dist/webfinger/mod.cjs +5 -9
  185. package/dist/webfinger/mod.d.cts +1 -3
  186. package/dist/webfinger/mod.d.ts +1 -3
  187. package/dist/webfinger/mod.js +4 -9
  188. package/dist/x/cfworkers.cjs +25 -14
  189. package/dist/x/cfworkers.d.cts +33 -6
  190. package/dist/x/cfworkers.d.ts +33 -6
  191. package/dist/x/cfworkers.js +22 -12
  192. package/dist/x/cfworkers.test.d.mts +2 -0
  193. package/dist/x/{cfworkers.test.js → cfworkers.test.mjs} +28 -26
  194. package/dist/x/hono.cjs +25 -14
  195. package/dist/x/hono.d.cts +1 -11
  196. package/dist/x/hono.d.ts +1 -11
  197. package/dist/x/hono.js +22 -12
  198. package/dist/x/sveltekit.cjs +23 -12
  199. package/dist/x/sveltekit.d.cts +1 -11
  200. package/dist/x/sveltekit.d.ts +1 -11
  201. package/dist/x/sveltekit.js +20 -10
  202. package/package.json +2 -2
  203. package/dist/chunk-DqRYRqnO.cjs +0 -34
  204. package/dist/compat/transformers.test.d.ts +0 -3
  205. package/dist/compat/transformers.test.js +0 -86
  206. package/dist/compat-DmDDELst.cjs +0 -4
  207. package/dist/compat-nxUqe4Z-.js +0 -4
  208. package/dist/federation/builder.test.d.ts +0 -3
  209. package/dist/federation/collection.test.d.ts +0 -3
  210. package/dist/federation/collection.test.js +0 -35
  211. package/dist/federation/handler.test.d.ts +0 -3
  212. package/dist/federation/idempotency.test.d.ts +0 -3
  213. package/dist/federation/inbox.test.d.ts +0 -3
  214. package/dist/federation/keycache.test.d.ts +0 -3
  215. package/dist/federation/kv.test.d.ts +0 -3
  216. package/dist/federation/middleware.test.d.ts +0 -3
  217. package/dist/federation/mq.test.d.ts +0 -3
  218. package/dist/federation/retry.test.d.ts +0 -3
  219. package/dist/federation/router.test.d.ts +0 -3
  220. package/dist/federation/send.test.d.ts +0 -3
  221. package/dist/federation-D1U8YY9t.js +0 -226
  222. package/dist/federation-H2_En3j5.cjs +0 -244
  223. package/dist/key-BCUd8FWp.js +0 -10
  224. package/dist/key-BUardnTH.cjs +0 -10
  225. package/dist/key-Dr6H_e3K.js +0 -10
  226. package/dist/middleware-BJ83veqi.js +0 -26
  227. package/dist/middleware-CJ4W2ir5.cjs +0 -17
  228. package/dist/middleware-Ve2mHJgo.js +0 -17
  229. package/dist/mod-BcObK1Lz.d.ts +0 -82
  230. package/dist/mod-C2tOeRkN.d.cts +0 -1
  231. package/dist/mod-CIbqfZW0.d.ts +0 -104
  232. package/dist/mod-Dt-G9ZOS.d.cts +0 -102
  233. package/dist/mod-FZd39qVq.d.cts +0 -1
  234. package/dist/mod-mXx9V0q5.d.cts +0 -80
  235. package/dist/nodeinfo/client.test.d.ts +0 -3
  236. package/dist/nodeinfo/handler.test.d.ts +0 -3
  237. package/dist/nodeinfo/semver.test.d.ts +0 -3
  238. package/dist/nodeinfo/types.test.d.ts +0 -3
  239. package/dist/nodeinfo-Co9lJrWl.cjs +0 -4
  240. package/dist/nodeinfo-DfycQ8Wf.js +0 -4
  241. package/dist/runtime/authdocloader.test.d.ts +0 -3
  242. package/dist/runtime/docloader.test.d.ts +0 -3
  243. package/dist/runtime/key.test.d.ts +0 -3
  244. package/dist/runtime/langstr.test.d.ts +0 -3
  245. package/dist/runtime/link.test.d.ts +0 -3
  246. package/dist/runtime/multibase/multibase.test.d.ts +0 -3
  247. package/dist/runtime/url.test.d.ts +0 -3
  248. package/dist/runtime-C58AJWSv.cjs +0 -4
  249. package/dist/runtime-DPYEDf-o.js +0 -4
  250. package/dist/sig/http.test.d.ts +0 -3
  251. package/dist/sig/key.test.d.ts +0 -3
  252. package/dist/sig/ld.test.d.ts +0 -3
  253. package/dist/sig/owner.test.d.ts +0 -3
  254. package/dist/sig/owner.test.js +0 -52
  255. package/dist/sig/proof.test.d.ts +0 -3
  256. package/dist/sig-ByHXzqUi.cjs +0 -4
  257. package/dist/sig-Cj3tk-ig.js +0 -4
  258. package/dist/testing/docloader.test.d.ts +0 -3
  259. package/dist/testing/docloader.test.js +0 -24
  260. package/dist/testing/mod.js +0 -10
  261. package/dist/vocab/actor.test.d.ts +0 -3
  262. package/dist/vocab/lookup.test.d.ts +0 -3
  263. package/dist/vocab/type.test.d.ts +0 -3
  264. package/dist/vocab/type.test.js +0 -25
  265. package/dist/vocab/vocab.test.d.ts +0 -3
  266. package/dist/vocab-BFy1CS5L.cjs +0 -289
  267. package/dist/vocab-BPFiQ650.js +0 -253
  268. package/dist/webfinger/handler.test.d.ts +0 -3
  269. package/dist/webfinger/lookup.test.d.ts +0 -3
  270. package/dist/webfinger-BjOEdFPs.cjs +0 -4
  271. package/dist/webfinger-De_bU0iE.js +0 -4
  272. package/dist/x/cfworkers.test.d.ts +0 -3
  273. /package/dist/{mod-1pDWKvUL.d.ts → compat/transformers.test.d.mts} +0 -0
  274. /package/dist/{mod-g0xFzAP9.d.ts → federation/builder.test.d.mts} +0 -0
@@ -1,23 +1,225 @@
1
-
2
- const { Temporal } = require("@js-temporal/polyfill");
3
- const { URLPattern } = require("urlpattern-polyfill");
4
-
5
- require('../transformers-CoBS-oFG.cjs');
6
- require('../docloader-BIFI3OS7.cjs');
7
- require('../actor-DlS-Q8hE.cjs');
8
- const require_middleware = require('../middleware-CGbvIGvy.cjs');
9
- require('../lookup-C4_dVYz7.cjs');
10
- require('../key-DjS1X9TG.cjs');
11
- require('../http-BgopPF-8.cjs');
12
- require('../proof-CX7ujFFX.cjs');
13
- const require_federation = require('../federation-H2_En3j5.cjs');
14
- require('../types-CGnM1vft.cjs');
15
- require('../authdocloader-CT_V4Z7G.cjs');
16
- require('../vocab-BFy1CS5L.cjs');
17
-
18
- exports.InProcessMessageQueue = require_federation.InProcessMessageQueue;
19
- exports.MemoryKvStore = require_federation.MemoryKvStore;
20
- exports.ParallelMessageQueue = require_federation.ParallelMessageQueue;
1
+ const { Temporal } = require("@js-temporal/polyfill");
2
+ const { URLPattern } = require("urlpattern-polyfill");
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ require("../docloader-BVuUhBLI.cjs");
5
+ const require_middleware = require("../middleware-C188G4Go.cjs");
6
+ let es_toolkit = require("es-toolkit");
7
+ //#region src/federation/kv.ts
8
+ /**
9
+ * A key–value store that stores values in memory.
10
+ * Do not use this in production as it does not persist values.
11
+ *
12
+ * @since 0.5.0
13
+ */
14
+ var MemoryKvStore = class {
15
+ #values = {};
16
+ #encodeKey(key) {
17
+ return JSON.stringify(key);
18
+ }
19
+ /**
20
+ * {@inheritDoc KvStore.get}
21
+ */
22
+ get(key) {
23
+ const encodedKey = this.#encodeKey(key);
24
+ const entry = this.#values[encodedKey];
25
+ if (entry == null) return Promise.resolve(void 0);
26
+ const [value, expiration] = entry;
27
+ if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
28
+ delete this.#values[encodedKey];
29
+ return Promise.resolve(void 0);
30
+ }
31
+ return Promise.resolve(value);
32
+ }
33
+ /**
34
+ * {@inheritDoc KvStore.set}
35
+ */
36
+ set(key, value, options) {
37
+ const encodedKey = this.#encodeKey(key);
38
+ const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
39
+ this.#values[encodedKey] = [value, expiration];
40
+ return Promise.resolve();
41
+ }
42
+ /**
43
+ * {@inheritDoc KvStore.delete}
44
+ */
45
+ delete(key) {
46
+ const encodedKey = this.#encodeKey(key);
47
+ delete this.#values[encodedKey];
48
+ return Promise.resolve();
49
+ }
50
+ /**
51
+ * {@inheritDoc KvStore.cas}
52
+ */
53
+ cas(key, expectedValue, newValue, options) {
54
+ const encodedKey = this.#encodeKey(key);
55
+ const entry = this.#values[encodedKey];
56
+ let currentValue;
57
+ if (entry == null) currentValue = void 0;
58
+ else {
59
+ const [value, expiration] = entry;
60
+ if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
61
+ delete this.#values[encodedKey];
62
+ currentValue = void 0;
63
+ } else currentValue = value;
64
+ }
65
+ if (!(0, es_toolkit.isEqual)(currentValue, expectedValue)) return Promise.resolve(false);
66
+ const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
67
+ this.#values[encodedKey] = [newValue, expiration];
68
+ return Promise.resolve(true);
69
+ }
70
+ };
71
+ //#endregion
72
+ //#region src/federation/mq.ts
73
+ /**
74
+ * A message queue that processes messages in the same process.
75
+ * Do not use this in production as it does neither persist messages nor
76
+ * distribute them across multiple processes.
77
+ *
78
+ * @since 0.5.0
79
+ */
80
+ var InProcessMessageQueue = class {
81
+ #messages;
82
+ #monitors;
83
+ #pollIntervalMs;
84
+ /**
85
+ * In-process message queue does not provide native retry mechanisms.
86
+ * @since 1.7.0
87
+ */
88
+ nativeRetrial = false;
89
+ /**
90
+ * Constructs a new {@link InProcessMessageQueue} with the given options.
91
+ * @param options Additional options for the in-process message queue.
92
+ */
93
+ constructor(options = {}) {
94
+ this.#messages = [];
95
+ this.#monitors = {};
96
+ this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
97
+ }
98
+ enqueue(message, options) {
99
+ const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
100
+ if (delay > 0) {
101
+ setTimeout(() => this.enqueue(message, {
102
+ ...options,
103
+ delay: void 0
104
+ }), delay);
105
+ return Promise.resolve();
106
+ }
107
+ this.#messages.push(message);
108
+ for (const monitorId in this.#monitors) this.#monitors[monitorId]();
109
+ return Promise.resolve();
110
+ }
111
+ enqueueMany(messages, options) {
112
+ if (messages.length === 0) return Promise.resolve();
113
+ const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
114
+ if (delay > 0) {
115
+ setTimeout(() => this.enqueueMany(messages, {
116
+ ...options,
117
+ delay: void 0
118
+ }), delay);
119
+ return Promise.resolve();
120
+ }
121
+ this.#messages.push(...messages);
122
+ for (const monitorId in this.#monitors) this.#monitors[monitorId]();
123
+ return Promise.resolve();
124
+ }
125
+ async listen(handler, options = {}) {
126
+ const signal = options.signal;
127
+ while (signal == null || !signal.aborted) {
128
+ while (this.#messages.length > 0) await handler(this.#messages.shift());
129
+ await this.#wait(this.#pollIntervalMs, signal);
130
+ }
131
+ }
132
+ #wait(ms, signal) {
133
+ let timer = null;
134
+ return Promise.any([new Promise((resolve) => {
135
+ signal?.addEventListener("abort", () => {
136
+ if (timer != null) clearTimeout(timer);
137
+ resolve();
138
+ }, { once: true });
139
+ const monitorId = crypto.randomUUID();
140
+ this.#monitors[monitorId] = () => {
141
+ delete this.#monitors[monitorId];
142
+ if (timer != null) clearTimeout(timer);
143
+ resolve();
144
+ };
145
+ }), new Promise((resolve) => timer = setTimeout(resolve, ms))]);
146
+ }
147
+ };
148
+ /**
149
+ * A message queue that processes messages in parallel. It takes another
150
+ * {@link MessageQueue}, and processes messages in parallel up to a certain
151
+ * number of workers.
152
+ *
153
+ * Actually, it's rather a decorator than a queue itself.
154
+ *
155
+ * Note that the workers do not run in truly parallel, in the sense that they
156
+ * are not running in separate threads or processes. They are running in the
157
+ * same process, but are scheduled to run in parallel. Hence, this is useful
158
+ * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
159
+ * workloads.
160
+ *
161
+ * @since 1.0.0
162
+ */
163
+ var ParallelMessageQueue = class ParallelMessageQueue {
164
+ queue;
165
+ workers;
166
+ /**
167
+ * Inherits the native retry capability from the wrapped queue.
168
+ * @since 1.7.0
169
+ */
170
+ nativeRetrial;
171
+ /**
172
+ * Constructs a new {@link ParallelMessageQueue} with the given queue and
173
+ * number of workers.
174
+ * @param queue The message queue to use under the hood. Note that
175
+ * {@link ParallelMessageQueue} cannot be nested.
176
+ * @param workers The number of workers to process messages in parallel.
177
+ * @throws {TypeError} If the given queue is an instance of
178
+ * {@link ParallelMessageQueue}.
179
+ */
180
+ constructor(queue, workers) {
181
+ if (queue instanceof ParallelMessageQueue) throw new TypeError("Cannot nest ParallelMessageQueue.");
182
+ this.queue = queue;
183
+ this.workers = workers;
184
+ this.nativeRetrial = queue.nativeRetrial;
185
+ }
186
+ enqueue(message, options) {
187
+ return this.queue.enqueue(message, options);
188
+ }
189
+ async enqueueMany(messages, options) {
190
+ if (this.queue.enqueueMany == null) {
191
+ const errors = (await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)))).filter((r) => r.status === "rejected").map((r) => r.reason);
192
+ if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
193
+ else if (errors.length === 1) throw errors[0];
194
+ return;
195
+ }
196
+ await this.queue.enqueueMany(messages, options);
197
+ }
198
+ listen(handler, options = {}) {
199
+ const workers = /* @__PURE__ */ new Map();
200
+ return this.queue.listen(async (message) => {
201
+ while (workers.size >= this.workers) {
202
+ const consumedId = await Promise.any(workers.values());
203
+ workers.delete(consumedId);
204
+ }
205
+ const workerId = crypto.randomUUID();
206
+ const promise = this.#work(workerId, handler, message);
207
+ workers.set(workerId, promise);
208
+ }, options);
209
+ }
210
+ async #work(workerId, handler, message) {
211
+ await this.#sleep(0);
212
+ await handler(message);
213
+ return workerId;
214
+ }
215
+ #sleep(ms) {
216
+ return new Promise((resolve) => setTimeout(resolve, ms));
217
+ }
218
+ };
219
+ //#endregion
220
+ exports.InProcessMessageQueue = InProcessMessageQueue;
221
+ exports.MemoryKvStore = MemoryKvStore;
222
+ exports.ParallelMessageQueue = ParallelMessageQueue;
21
223
  exports.Router = require_middleware.Router;
22
224
  exports.RouterError = require_middleware.RouterError;
23
225
  exports.buildCollectionSynchronizationHeader = require_middleware.buildCollectionSynchronizationHeader;
@@ -26,4 +228,4 @@ exports.createFederation = require_middleware.createFederation;
26
228
  exports.createFederationBuilder = require_middleware.createFederationBuilder;
27
229
  exports.digest = require_middleware.digest;
28
230
  exports.respondWithObject = require_middleware.respondWithObject;
29
- exports.respondWithObjectIfAcceptable = require_middleware.respondWithObjectIfAcceptable;
231
+ exports.respondWithObjectIfAcceptable = require_middleware.respondWithObjectIfAcceptable;
@@ -1,13 +1,4 @@
1
- import { KvKey, KvStore, KvStoreSetOptions, MemoryKvStore } from "../kv-63Cil1MD.cjs";
2
- import "../docloader-D-MrRyHl.cjs";
3
- import "../client-DjT_tegg.cjs";
4
- import "../vocab-Cfs0937i.cjs";
5
- import "../actor-Ydzhc8dj.cjs";
6
- import "../http-B1_DzfAU.cjs";
7
- import "../owner-6KSEp9eV.cjs";
8
- import "../mod-BUbqxBev.cjs";
9
- import "../mod-jQ4OODsl.cjs";
10
- import { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CreateFederationOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, Message, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "../context-CwUAkopp.cjs";
11
- import { InProcessMessageQueue, InProcessMessageQueueOptions, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, ParallelMessageQueue } from "../mq-B7R1Q-M5.cjs";
12
- import "../mod-C2tOeRkN.cjs";
13
- export { 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, KvKey, KvStore, KvStoreSetOptions, MemoryKvStore, 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 };
1
+ import { i as MemoryKvStore, n as KvStore, r as KvStoreSetOptions, t as KvKey } from "../kv-GIrOktyG.cjs";
2
+ import { $ as CustomCollectionCursor, A as createFederation, B as RouterRouteResult, C as InboxListenerSetters, D as FederationKvPrefixes, E as CreateFederationOptions, F as Message, G as ActorDispatcher, H as respondWithObject, I as createFederationBuilder, J as AuthorizePredicate, K as ActorHandleMapper, L as Router, M as RetryContext, N as RetryPolicy, O as FederationOrigin, P as createExponentialBackoffPolicy, Q as CustomCollectionCounter, R as RouterError, S as IdempotencyStrategy, T as Rfc6570Expression, U as respondWithObjectIfAcceptable, V as RespondWithObjectOptions, W as ActorAliasMapper, X as CollectionCursor, Y as CollectionCounter, Z as CollectionDispatcher, _ as FederationBuilder, a as InboxContext, at as ObjectDispatcher, b as FederationStartQueueOptions, c as RouteActivityOptions, ct as WebFingerLinksDispatcher, d as ActorCallbackSetters, dt as buildCollectionSynchronizationHeader, et as CustomCollectionDispatcher, f as CollectionCallbackSetters, ft as digest, g as Federation, h as Federatable, i as GetSignedKeyOptions, it as ObjectAuthorizePredicate, j as CreateExponentialBackoffPolicyOptions, k as FederationQueueOptions, l as SendActivityOptions, lt as SenderKeyPair, m as CustomCollectionCallbackSetters, n as Context, nt as InboxListener, o as ParseUriResult, ot as OutboxErrorHandler, p as ConstructorWithTypeId, q as ActorKeyPairsDispatcher, r as ForwardActivityOptions, rt as NodeInfoDispatcher, s as RequestContext, st as SharedInboxKeyDispatcher, t as ActorKeyPair, tt as InboxErrorHandler, u as SendActivityOptionsForCollection, ut as PageItems, v as FederationFetchOptions, w as ObjectCallbackSetters, x as IdempotencyKeyCallback, y as FederationOptions, z as RouterOptions } from "../context-CACMqDzl.cjs";
3
+ import { a as MessageQueueListenOptions, i as MessageQueueEnqueueOptions, n as InProcessMessageQueueOptions, o as ParallelMessageQueue, r as MessageQueue, t as InProcessMessageQueue } from "../mq-CrItclRD.cjs";
4
+ export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, type CreateFederationOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, type FederationKvPrefixes, FederationOptions, type FederationOrigin, type FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreSetOptions, MemoryKvStore, type Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, type RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, type SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
@@ -1,15 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { KvKey, KvStore, KvStoreSetOptions, MemoryKvStore } from "../kv-C7sopW2E.js";
4
- import "../docloader-CxWcuWqQ.js";
5
- import "../client-DF8anIB5.js";
6
- import "../vocab-CDHNj5zp.js";
7
- import "../actor-C1Euqngb.js";
8
- import "../http-wsGR6KkT.js";
9
- import "../owner-BbeUDvOu.js";
10
- import "../mod-CDObsV1d.js";
11
- import "../mod-DBzN0aCM.js";
12
- import { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CreateFederationOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, Message, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "../context-CXUibY4L.js";
13
- import { InProcessMessageQueue, InProcessMessageQueueOptions, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, ParallelMessageQueue } from "../mq-CRGm1e_F.js";
14
- import "../mod-g0xFzAP9.js";
15
- export { 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, KvKey, KvStore, KvStoreSetOptions, MemoryKvStore, 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 };
3
+ import { i as MemoryKvStore, n as KvStore, r as KvStoreSetOptions, t as KvKey } from "../kv-Bq9QLKm5.js";
4
+ import { $ as CustomCollectionCursor, A as createFederation, B as RouterRouteResult, C as InboxListenerSetters, D as FederationKvPrefixes, E as CreateFederationOptions, F as Message, G as ActorDispatcher, H as respondWithObject, I as createFederationBuilder, J as AuthorizePredicate, K as ActorHandleMapper, L as Router, M as RetryContext, N as RetryPolicy, O as FederationOrigin, P as createExponentialBackoffPolicy, Q as CustomCollectionCounter, R as RouterError, S as IdempotencyStrategy, T as Rfc6570Expression, U as respondWithObjectIfAcceptable, V as RespondWithObjectOptions, W as ActorAliasMapper, X as CollectionCursor, Y as CollectionCounter, Z as CollectionDispatcher, _ as FederationBuilder, a as InboxContext, at as ObjectDispatcher, b as FederationStartQueueOptions, c as RouteActivityOptions, ct as WebFingerLinksDispatcher, d as ActorCallbackSetters, dt as buildCollectionSynchronizationHeader, et as CustomCollectionDispatcher, f as CollectionCallbackSetters, ft as digest, g as Federation, h as Federatable, i as GetSignedKeyOptions, it as ObjectAuthorizePredicate, j as CreateExponentialBackoffPolicyOptions, k as FederationQueueOptions, l as SendActivityOptions, lt as SenderKeyPair, m as CustomCollectionCallbackSetters, n as Context, nt as InboxListener, o as ParseUriResult, ot as OutboxErrorHandler, p as ConstructorWithTypeId, q as ActorKeyPairsDispatcher, r as ForwardActivityOptions, rt as NodeInfoDispatcher, s as RequestContext, st as SharedInboxKeyDispatcher, t as ActorKeyPair, tt as InboxErrorHandler, u as SendActivityOptionsForCollection, ut as PageItems, v as FederationFetchOptions, w as ObjectCallbackSetters, x as IdempotencyKeyCallback, y as FederationOptions, z as RouterOptions } from "../context-K4cCphQj.js";
5
+ import { a as MessageQueueListenOptions, i as MessageQueueEnqueueOptions, n as InProcessMessageQueueOptions, o as ParallelMessageQueue, r as MessageQueue, t as InProcessMessageQueue } from "../mq-D_ZZRdby.js";
6
+ export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, type CreateFederationOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, type FederationKvPrefixes, FederationOptions, type FederationOrigin, type FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreSetOptions, MemoryKvStore, type Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, type RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, type SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
@@ -1,18 +1,218 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import "../transformers-BFT6d7J5.js";
6
- import "../docloader-fJgJeqiX.js";
7
- import "../actor-CEGEmRll.js";
8
- import { Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-ODfDRN3q.js";
9
- import "../lookup-CKZfuyxA.js";
10
- import "../key-ibMO03_0.js";
11
- import "../http-CR-Eg1Uq.js";
12
- import "../proof-V1uQaB2y.js";
13
- import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "../federation-D1U8YY9t.js";
14
- import "../types-Cptev2nt.js";
15
- import "../authdocloader-DUQcOTRS.js";
16
- import "../vocab-BPFiQ650.js";
17
-
18
- export { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue, Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
3
+ import { a as respondWithObjectIfAcceptable, c as createFederationBuilder, i as respondWithObject, l as Router, o as buildCollectionSynchronizationHeader, r as createExponentialBackoffPolicy, s as digest, t as createFederation, u as RouterError } from "../middleware-Do06X21v.js";
4
+ import { isEqual } from "es-toolkit";
5
+ //#region src/federation/kv.ts
6
+ /**
7
+ * A key–value store that stores values in memory.
8
+ * Do not use this in production as it does not persist values.
9
+ *
10
+ * @since 0.5.0
11
+ */
12
+ var MemoryKvStore = class {
13
+ #values = {};
14
+ #encodeKey(key) {
15
+ return JSON.stringify(key);
16
+ }
17
+ /**
18
+ * {@inheritDoc KvStore.get}
19
+ */
20
+ get(key) {
21
+ const encodedKey = this.#encodeKey(key);
22
+ const entry = this.#values[encodedKey];
23
+ if (entry == null) return Promise.resolve(void 0);
24
+ const [value, expiration] = entry;
25
+ if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
26
+ delete this.#values[encodedKey];
27
+ return Promise.resolve(void 0);
28
+ }
29
+ return Promise.resolve(value);
30
+ }
31
+ /**
32
+ * {@inheritDoc KvStore.set}
33
+ */
34
+ set(key, value, options) {
35
+ const encodedKey = this.#encodeKey(key);
36
+ const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
37
+ this.#values[encodedKey] = [value, expiration];
38
+ return Promise.resolve();
39
+ }
40
+ /**
41
+ * {@inheritDoc KvStore.delete}
42
+ */
43
+ delete(key) {
44
+ const encodedKey = this.#encodeKey(key);
45
+ delete this.#values[encodedKey];
46
+ return Promise.resolve();
47
+ }
48
+ /**
49
+ * {@inheritDoc KvStore.cas}
50
+ */
51
+ cas(key, expectedValue, newValue, options) {
52
+ const encodedKey = this.#encodeKey(key);
53
+ const entry = this.#values[encodedKey];
54
+ let currentValue;
55
+ if (entry == null) currentValue = void 0;
56
+ else {
57
+ const [value, expiration] = entry;
58
+ if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
59
+ delete this.#values[encodedKey];
60
+ currentValue = void 0;
61
+ } else currentValue = value;
62
+ }
63
+ if (!isEqual(currentValue, expectedValue)) return Promise.resolve(false);
64
+ const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
65
+ this.#values[encodedKey] = [newValue, expiration];
66
+ return Promise.resolve(true);
67
+ }
68
+ };
69
+ //#endregion
70
+ //#region src/federation/mq.ts
71
+ /**
72
+ * A message queue that processes messages in the same process.
73
+ * Do not use this in production as it does neither persist messages nor
74
+ * distribute them across multiple processes.
75
+ *
76
+ * @since 0.5.0
77
+ */
78
+ var InProcessMessageQueue = class {
79
+ #messages;
80
+ #monitors;
81
+ #pollIntervalMs;
82
+ /**
83
+ * In-process message queue does not provide native retry mechanisms.
84
+ * @since 1.7.0
85
+ */
86
+ nativeRetrial = false;
87
+ /**
88
+ * Constructs a new {@link InProcessMessageQueue} with the given options.
89
+ * @param options Additional options for the in-process message queue.
90
+ */
91
+ constructor(options = {}) {
92
+ this.#messages = [];
93
+ this.#monitors = {};
94
+ this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
95
+ }
96
+ enqueue(message, options) {
97
+ const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
98
+ if (delay > 0) {
99
+ setTimeout(() => this.enqueue(message, {
100
+ ...options,
101
+ delay: void 0
102
+ }), delay);
103
+ return Promise.resolve();
104
+ }
105
+ this.#messages.push(message);
106
+ for (const monitorId in this.#monitors) this.#monitors[monitorId]();
107
+ return Promise.resolve();
108
+ }
109
+ enqueueMany(messages, options) {
110
+ if (messages.length === 0) return Promise.resolve();
111
+ const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
112
+ if (delay > 0) {
113
+ setTimeout(() => this.enqueueMany(messages, {
114
+ ...options,
115
+ delay: void 0
116
+ }), delay);
117
+ return Promise.resolve();
118
+ }
119
+ this.#messages.push(...messages);
120
+ for (const monitorId in this.#monitors) this.#monitors[monitorId]();
121
+ return Promise.resolve();
122
+ }
123
+ async listen(handler, options = {}) {
124
+ const signal = options.signal;
125
+ while (signal == null || !signal.aborted) {
126
+ while (this.#messages.length > 0) await handler(this.#messages.shift());
127
+ await this.#wait(this.#pollIntervalMs, signal);
128
+ }
129
+ }
130
+ #wait(ms, signal) {
131
+ let timer = null;
132
+ return Promise.any([new Promise((resolve) => {
133
+ signal?.addEventListener("abort", () => {
134
+ if (timer != null) clearTimeout(timer);
135
+ resolve();
136
+ }, { once: true });
137
+ const monitorId = crypto.randomUUID();
138
+ this.#monitors[monitorId] = () => {
139
+ delete this.#monitors[monitorId];
140
+ if (timer != null) clearTimeout(timer);
141
+ resolve();
142
+ };
143
+ }), new Promise((resolve) => timer = setTimeout(resolve, ms))]);
144
+ }
145
+ };
146
+ /**
147
+ * A message queue that processes messages in parallel. It takes another
148
+ * {@link MessageQueue}, and processes messages in parallel up to a certain
149
+ * number of workers.
150
+ *
151
+ * Actually, it's rather a decorator than a queue itself.
152
+ *
153
+ * Note that the workers do not run in truly parallel, in the sense that they
154
+ * are not running in separate threads or processes. They are running in the
155
+ * same process, but are scheduled to run in parallel. Hence, this is useful
156
+ * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
157
+ * workloads.
158
+ *
159
+ * @since 1.0.0
160
+ */
161
+ var ParallelMessageQueue = class ParallelMessageQueue {
162
+ queue;
163
+ workers;
164
+ /**
165
+ * Inherits the native retry capability from the wrapped queue.
166
+ * @since 1.7.0
167
+ */
168
+ nativeRetrial;
169
+ /**
170
+ * Constructs a new {@link ParallelMessageQueue} with the given queue and
171
+ * number of workers.
172
+ * @param queue The message queue to use under the hood. Note that
173
+ * {@link ParallelMessageQueue} cannot be nested.
174
+ * @param workers The number of workers to process messages in parallel.
175
+ * @throws {TypeError} If the given queue is an instance of
176
+ * {@link ParallelMessageQueue}.
177
+ */
178
+ constructor(queue, workers) {
179
+ if (queue instanceof ParallelMessageQueue) throw new TypeError("Cannot nest ParallelMessageQueue.");
180
+ this.queue = queue;
181
+ this.workers = workers;
182
+ this.nativeRetrial = queue.nativeRetrial;
183
+ }
184
+ enqueue(message, options) {
185
+ return this.queue.enqueue(message, options);
186
+ }
187
+ async enqueueMany(messages, options) {
188
+ if (this.queue.enqueueMany == null) {
189
+ const errors = (await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)))).filter((r) => r.status === "rejected").map((r) => r.reason);
190
+ if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
191
+ else if (errors.length === 1) throw errors[0];
192
+ return;
193
+ }
194
+ await this.queue.enqueueMany(messages, options);
195
+ }
196
+ listen(handler, options = {}) {
197
+ const workers = /* @__PURE__ */ new Map();
198
+ return this.queue.listen(async (message) => {
199
+ while (workers.size >= this.workers) {
200
+ const consumedId = await Promise.any(workers.values());
201
+ workers.delete(consumedId);
202
+ }
203
+ const workerId = crypto.randomUUID();
204
+ const promise = this.#work(workerId, handler, message);
205
+ workers.set(workerId, promise);
206
+ }, options);
207
+ }
208
+ async #work(workerId, handler, message) {
209
+ await this.#sleep(0);
210
+ await handler(message);
211
+ return workerId;
212
+ }
213
+ #sleep(ms) {
214
+ return new Promise((resolve) => setTimeout(resolve, ms));
215
+ }
216
+ };
217
+ //#endregion
218
+ export { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue, Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
@@ -0,0 +1,2 @@
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";