@fedify/fedify 2.0.0-dev.1875 → 2.0.0-dev.196

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 (283) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +68 -35
  3. package/dist/{builder-CLT_zIyw.js → builder-R1Sfe-tb.js} +5 -3
  4. package/dist/{client-BsGzbnV-.d.ts → client-CUTUGgvJ.d.ts} +18 -18
  5. package/dist/{client-pY7-3icS.js → client-Dg7OfUDA.js} +28 -23
  6. package/dist/{client-94iWEfQa.d.cts → client-by-PEGAJ.d.cts} +18 -18
  7. package/dist/compat/mod.cjs +1 -1
  8. package/dist/compat/mod.d.cts +6 -11
  9. package/dist/compat/mod.d.ts +6 -11
  10. package/dist/compat/mod.js +1 -1
  11. package/dist/compat/transformers.test.js +22 -21
  12. package/dist/context-Bns6uTJq.js +109 -0
  13. package/dist/{context-DG0huGW-.d.ts → context-C7vzWilY.d.ts} +200 -65
  14. package/dist/{context-DJ8aSy2Q.d.cts → context-CrB9RFy5.d.cts} +200 -65
  15. package/dist/deno-i60L3ZJW.js +117 -0
  16. package/dist/{testing-CW4N8vgf.js → dist-B5f6a8Tt.js} +90 -110
  17. package/dist/{docloader-BkhI_RcC.js → docloader-BuOglEYx.js} +3 -3
  18. package/dist/{esm-DOqAYjlY.js → esm-DGl7uK1r.js} +32 -17
  19. package/dist/federation/builder.test.js +7 -5
  20. package/dist/federation/collection.test.js +2 -3
  21. package/dist/federation/handler.test.js +110 -22
  22. package/dist/federation/idempotency.test.js +23 -22
  23. package/dist/federation/inbox.test.js +4 -3
  24. package/dist/federation/keycache.test.js +4 -4
  25. package/dist/federation/kv.test.js +56 -3
  26. package/dist/federation/middleware.test.js +95 -93
  27. package/dist/federation/mod.cjs +8 -10
  28. package/dist/federation/mod.d.cts +7 -12
  29. package/dist/federation/mod.d.ts +7 -12
  30. package/dist/federation/mod.js +8 -11
  31. package/dist/federation/mq.test.js +5 -4
  32. package/dist/federation/negotiation.test.js +2 -3
  33. package/dist/federation/retry.test.js +2 -3
  34. package/dist/federation/router.test.js +2 -2
  35. package/dist/federation/send.test.js +51 -9
  36. package/dist/{webfinger/handler.test.js → federation/webfinger.test.js} +24 -22
  37. package/dist/{federation-CRpdnOMS.cjs → federation-B431K2gm.cjs} +22 -0
  38. package/dist/{federation-jcR8-ZxP.js → federation-BbZwNNWj.js} +28 -6
  39. package/dist/{http-DmUiHemJ.js → http-B5BgMxiO.js} +119 -9
  40. package/dist/{http-DarlEN23.cjs → http-B_jtB30-.cjs} +132 -16
  41. package/dist/{http-M8k5mKc0.d.cts → http-ClB3pLcL.d.cts} +1 -1
  42. package/dist/{http-BbO0ejuk.d.ts → http-DLBDPal9.d.ts} +1 -1
  43. package/dist/{http-BIYwcgTd.js → http-uzkhnm0W.js} +3 -2
  44. package/dist/{inbox-Dbt8hLxb.js → inbox-CxrUTds4.js} +2 -1
  45. package/dist/{key-BcT6cdMK.js → key-DBHCloAO.js} +3 -3
  46. package/dist/{keycache-B8aIeTgt.js → keycache-DRxpZ5r9.js} +1 -1
  47. package/dist/{keys-Bs-0Hapk.js → keys-ZbcByPg9.js} +1 -1
  48. package/dist/{kv-Bxr0Q87_.d.cts → kv-B4vFhIYL.d.cts} +30 -1
  49. package/dist/{kv-BKNZ-Tb-.d.ts → kv-CYySNrsn.d.ts} +30 -1
  50. package/dist/{kv-CRZrzyXm.js → kv-QzKcOQgP.js} +22 -0
  51. package/dist/{kv-cache-DN9pfMBe.js → kv-cache-BEeqyGER.js} +14 -1
  52. package/dist/{kv-cache-B5TLf2fI.js → kv-cache-BqWqxam4.js} +2 -2
  53. package/dist/{kv-cache-BWWu8RyL.cjs → kv-cache-DY6hQ8Rf.cjs} +2 -2
  54. package/dist/{ld-DR6mmQjt.js → ld-CZgNIUGN.js} +4 -3
  55. package/dist/{middleware-B09KVcU4.cjs → middleware-BaoVtoMl.cjs} +210 -194
  56. package/dist/{middleware-B_rzGWsn.js → middleware-BqPcChYv.js} +164 -154
  57. package/dist/middleware-CnrWiFJI.cjs +12 -0
  58. package/dist/{middleware-Aqt52eK0.js → middleware-CxwWsgSo.js} +162 -165
  59. package/dist/middleware-DoFisLae.js +26 -0
  60. package/dist/middleware-ZN9cd_L8.js +12 -0
  61. package/dist/{mod-0noXw66R.d.cts → mod-0p9zUdzg.d.cts} +6 -6
  62. package/dist/mod-0qnPv4EC.d.cts +62 -0
  63. package/dist/{mod-DgdBYYa0.d.cts → mod-BrS8tiad.d.cts} +2 -2
  64. package/dist/mod-C3SOvTD1.d.ts +64 -0
  65. package/dist/{mod-DJcZDvjA.d.cts → mod-D6pS5_xJ.d.cts} +4 -4
  66. package/dist/{mod-B2iOw50L.d.ts → mod-jOa7W503.d.ts} +2 -2
  67. package/dist/{mod-BoHnwOCs.d.ts → mod-waqu-BL_.d.ts} +4 -4
  68. package/dist/{mod-B9M-8jm2.d.ts → mod-xc20HhMD.d.ts} +6 -6
  69. package/dist/mod.cjs +11 -93
  70. package/dist/mod.d.cts +11 -16
  71. package/dist/mod.d.ts +11 -16
  72. package/dist/mod.js +11 -15
  73. package/dist/nodeinfo/client.test.js +3 -4
  74. package/dist/nodeinfo/handler.test.js +22 -21
  75. package/dist/nodeinfo/mod.cjs +2 -2
  76. package/dist/nodeinfo/mod.d.cts +2 -2
  77. package/dist/nodeinfo/mod.d.ts +2 -2
  78. package/dist/nodeinfo/mod.js +2 -2
  79. package/dist/nodeinfo/types.test.js +2 -3
  80. package/dist/otel/exporter.test.js +893 -0
  81. package/dist/otel/mod.cjs +256 -0
  82. package/dist/otel/mod.d.cts +230 -0
  83. package/dist/otel/mod.d.ts +232 -0
  84. package/dist/otel/mod.js +255 -0
  85. package/dist/{owner-DEgLiB7Z.js → owner-BDvRiO5T.js} +44 -8
  86. package/dist/{owner-kQRGVXG1.d.ts → owner-BgI8C-VY.d.ts} +1 -2
  87. package/dist/{owner-B4HbyP8s.d.cts → owner-C-zfmVAD.d.cts} +1 -2
  88. package/dist/{proof-AhMjXzru.js → proof-DzFse-Bn.js} +46 -11
  89. package/dist/{proof-p3cmdfis.js → proof-XEPY5YKg.js} +3 -2
  90. package/dist/{proof-CbB_yXKu.cjs → proof-vmNsq1AQ.cjs} +63 -28
  91. package/dist/router-D9eI0s4b.js +118 -0
  92. package/dist/{send-CcKJ-npK.js → send-BdhhZ2MN.js} +9 -4
  93. package/dist/sig/http.test.js +6 -7
  94. package/dist/sig/key.test.js +5 -5
  95. package/dist/sig/ld.test.js +6 -6
  96. package/dist/sig/mod.cjs +3 -5
  97. package/dist/sig/mod.d.cts +3 -5
  98. package/dist/sig/mod.d.ts +3 -5
  99. package/dist/sig/mod.js +3 -5
  100. package/dist/sig/owner.test.js +29 -6
  101. package/dist/sig/proof.test.js +6 -6
  102. package/dist/testing/mod.d.ts +70 -6999
  103. package/dist/testing/mod.js +4 -3
  104. package/dist/{transformers-CoBS-oFG.cjs → transformers-BjBg6Lag.cjs} +2 -2
  105. package/dist/{transformers-BFT6d7J5.js → transformers-N_ip_y4P.js} +2 -2
  106. package/dist/{types-BtUjyi5y.js → types-8l28uC8o.js} +30 -25
  107. package/dist/{types-CWgzGaqk.cjs → types-B6z6CqIz.cjs} +30 -25
  108. package/dist/{types-C2XVl6gj.js → types-CPz01LGH.js} +3 -3
  109. package/dist/utils/docloader.test.js +7 -8
  110. package/dist/utils/kv-cache.test.js +5 -3
  111. package/dist/utils/mod.cjs +3 -5
  112. package/dist/utils/mod.d.cts +3 -4
  113. package/dist/utils/mod.d.ts +3 -4
  114. package/dist/utils/mod.js +3 -5
  115. package/package.json +25 -67
  116. package/dist/actor-BQuDqoKQ.cjs +0 -42079
  117. package/dist/actor-CmPnJ0G7.js +0 -146
  118. package/dist/actor-CtTW_fTc.js +0 -41647
  119. package/dist/actor-DqFajh9s.d.ts +0 -130
  120. package/dist/actor-f2NtjyCg.d.cts +0 -128
  121. package/dist/denokv-CCssOzMJ.js +0 -57
  122. package/dist/fixtures/activitypub.academy/users/brauca_darradiul.json +0 -83
  123. package/dist/fixtures/example.com/announce.json +0 -6
  124. package/dist/fixtures/example.com/collection.json +0 -19
  125. package/dist/fixtures/example.com/create.json +0 -6
  126. package/dist/fixtures/example.com/cross-origin-actor.json +0 -6
  127. package/dist/fixtures/example.com/hong-gildong.json +0 -11
  128. package/dist/fixtures/example.com/invite.json +0 -7
  129. package/dist/fixtures/example.com/key.json +0 -7
  130. package/dist/fixtures/example.com/key2.json +0 -6
  131. package/dist/fixtures/example.com/object.json +0 -6
  132. package/dist/fixtures/example.com/orderedcollectionpage.json +0 -24
  133. package/dist/fixtures/example.com/paged/a.json +0 -13
  134. package/dist/fixtures/example.com/paged/b.json +0 -16
  135. package/dist/fixtures/example.com/paged-collection.json +0 -6
  136. package/dist/fixtures/example.com/person.json +0 -22
  137. package/dist/fixtures/example.com/person2.json +0 -40
  138. package/dist/fixtures/example.com/test.json +0 -5
  139. package/dist/fixtures/example.com/users/handle.json +0 -16
  140. package/dist/fixtures/example.com/wrong-type.json +0 -3
  141. package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +0 -6
  142. package/dist/fixtures/oeee.cafe/ap/users/3609fd4e-d51d-4db8-9f04-4189815864dd.json +0 -24
  143. package/dist/fixtures/remote.domain/users/bob.json +0 -20
  144. package/dist/fixtures/server.example/users/alice.json +0 -20
  145. package/dist/fixtures/w3id.org/identity/v1.json +0 -152
  146. package/dist/fixtures/w3id.org/security/data-integrity/v1.json +0 -74
  147. package/dist/fixtures/w3id.org/security/multikey/v1.json +0 -35
  148. package/dist/fixtures/w3id.org/security/v1.json +0 -50
  149. package/dist/fixtures/wizard.casa/users/hongminhee.json +0 -69
  150. package/dist/fixtures/www.w3.org/ns/activitystreams.json +0 -379
  151. package/dist/fixtures/www.w3.org/ns/did/v1.json +0 -58
  152. package/dist/lookup-Bhv7efZB.js +0 -42183
  153. package/dist/lookup-DdpqU9Gb.js +0 -258
  154. package/dist/lookup-EHJhdA8l.cjs +0 -270
  155. package/dist/middleware-C_Sa9J23.cjs +0 -15
  156. package/dist/middleware-DGwP3i-w.js +0 -15
  157. package/dist/middleware-Xyxj43cy.js +0 -26
  158. package/dist/mod-BlVovdcy.d.ts +0 -309
  159. package/dist/mod-BxRCHTz-.d.cts +0 -307
  160. package/dist/mod-C2tOeRkN.d.cts +0 -1
  161. package/dist/mod-C58MZ7Wx.d.cts +0 -113
  162. package/dist/mod-Ds0mpFZU.d.ts +0 -115
  163. package/dist/mod-xIj-IT58.d.ts +0 -2
  164. package/dist/mq-CUKlBw08.d.ts +0 -143
  165. package/dist/mq-DcJPkXD5.d.cts +0 -140
  166. package/dist/src/vocab/accept.yaml +0 -15
  167. package/dist/src/vocab/activity.yaml +0 -98
  168. package/dist/src/vocab/add.yaml +0 -16
  169. package/dist/src/vocab/announce.yaml +0 -30
  170. package/dist/src/vocab/application.yaml +0 -324
  171. package/dist/src/vocab/arrive.yaml +0 -15
  172. package/dist/src/vocab/article.yaml +0 -46
  173. package/dist/src/vocab/audio.yaml +0 -11
  174. package/dist/src/vocab/block.yaml +0 -16
  175. package/dist/src/vocab/chatmessage.yaml +0 -50
  176. package/dist/src/vocab/collection.yaml +0 -154
  177. package/dist/src/vocab/collectionpage.yaml +0 -55
  178. package/dist/src/vocab/create.yaml +0 -28
  179. package/dist/src/vocab/dataintegrityproof.yaml +0 -56
  180. package/dist/src/vocab/delete.yaml +0 -27
  181. package/dist/src/vocab/didservice.yaml +0 -22
  182. package/dist/src/vocab/dislike.yaml +0 -14
  183. package/dist/src/vocab/document.yaml +0 -31
  184. package/dist/src/vocab/emoji.yaml +0 -12
  185. package/dist/src/vocab/emojireact.yaml +0 -17
  186. package/dist/src/vocab/endpoints.yaml +0 -85
  187. package/dist/src/vocab/event.yaml +0 -11
  188. package/dist/src/vocab/export.yaml +0 -9
  189. package/dist/src/vocab/flag.yaml +0 -15
  190. package/dist/src/vocab/follow.yaml +0 -19
  191. package/dist/src/vocab/group.yaml +0 -324
  192. package/dist/src/vocab/hashtag.yaml +0 -14
  193. package/dist/src/vocab/ignore.yaml +0 -14
  194. package/dist/src/vocab/image.yaml +0 -9
  195. package/dist/src/vocab/intransitiveactivity.yaml +0 -15
  196. package/dist/src/vocab/invite.yaml +0 -14
  197. package/dist/src/vocab/join.yaml +0 -14
  198. package/dist/src/vocab/key.yaml +0 -28
  199. package/dist/src/vocab/leave.yaml +0 -14
  200. package/dist/src/vocab/like.yaml +0 -16
  201. package/dist/src/vocab/link.yaml +0 -101
  202. package/dist/src/vocab/listen.yaml +0 -12
  203. package/dist/src/vocab/mention.yaml +0 -9
  204. package/dist/src/vocab/move.yaml +0 -15
  205. package/dist/src/vocab/multikey.yaml +0 -36
  206. package/dist/src/vocab/note.yaml +0 -48
  207. package/dist/src/vocab/object.yaml +0 -404
  208. package/dist/src/vocab/offer.yaml +0 -15
  209. package/dist/src/vocab/orderedcollection.yaml +0 -39
  210. package/dist/src/vocab/orderedcollectionpage.yaml +0 -50
  211. package/dist/src/vocab/organization.yaml +0 -324
  212. package/dist/src/vocab/page.yaml +0 -11
  213. package/dist/src/vocab/person.yaml +0 -324
  214. package/dist/src/vocab/place.yaml +0 -75
  215. package/dist/src/vocab/profile.yaml +0 -26
  216. package/dist/src/vocab/propertyvalue.yaml +0 -32
  217. package/dist/src/vocab/question.yaml +0 -103
  218. package/dist/src/vocab/read.yaml +0 -13
  219. package/dist/src/vocab/reject.yaml +0 -14
  220. package/dist/src/vocab/relationship.yaml +0 -52
  221. package/dist/src/vocab/remove.yaml +0 -14
  222. package/dist/src/vocab/service.yaml +0 -324
  223. package/dist/src/vocab/source.yaml +0 -26
  224. package/dist/src/vocab/tentativeaccept.yaml +0 -14
  225. package/dist/src/vocab/tentativereject.yaml +0 -14
  226. package/dist/src/vocab/tombstone.yaml +0 -24
  227. package/dist/src/vocab/travel.yaml +0 -16
  228. package/dist/src/vocab/undo.yaml +0 -26
  229. package/dist/src/vocab/update.yaml +0 -58
  230. package/dist/src/vocab/video.yaml +0 -11
  231. package/dist/src/vocab/view.yaml +0 -13
  232. package/dist/testing/docloader.test.js +0 -22
  233. package/dist/vocab/actor.test.js +0 -5963
  234. package/dist/vocab/lookup.test.d.ts +0 -3
  235. package/dist/vocab/lookup.test.js +0 -454
  236. package/dist/vocab/mod.cjs +0 -86
  237. package/dist/vocab/mod.d.cts +0 -4
  238. package/dist/vocab/mod.d.ts +0 -6
  239. package/dist/vocab/mod.js +0 -9
  240. package/dist/vocab/type.test.d.ts +0 -3
  241. package/dist/vocab/type.test.js +0 -24
  242. package/dist/vocab/vocab.test.d.ts +0 -3
  243. package/dist/vocab/vocab.test.js +0 -9397
  244. package/dist/vocab-BCWe1Ih5.d.ts +0 -14905
  245. package/dist/vocab-CeDBzu-f.d.cts +0 -14903
  246. package/dist/vocab-CuAJ4Tbh.js +0 -255
  247. package/dist/vocab-DCYaqGPG.cjs +0 -291
  248. package/dist/webfinger/handler.test.d.ts +0 -3
  249. package/dist/webfinger/lookup.test.d.ts +0 -3
  250. package/dist/webfinger/lookup.test.js +0 -193
  251. package/dist/webfinger/mod.cjs +0 -8
  252. package/dist/webfinger/mod.d.cts +0 -2
  253. package/dist/webfinger/mod.d.ts +0 -4
  254. package/dist/webfinger/mod.js +0 -8
  255. package/dist/webfinger-C72Y8lrh.js +0 -4
  256. package/dist/webfinger-vAtLmxOF.cjs +0 -4
  257. package/dist/x/cfworkers.cjs +0 -100
  258. package/dist/x/cfworkers.d.cts +0 -59
  259. package/dist/x/cfworkers.d.ts +0 -61
  260. package/dist/x/cfworkers.js +0 -98
  261. package/dist/x/cfworkers.test.d.ts +0 -3
  262. package/dist/x/cfworkers.test.js +0 -177
  263. package/dist/x/hono.cjs +0 -61
  264. package/dist/x/hono.d.cts +0 -53
  265. package/dist/x/hono.d.ts +0 -55
  266. package/dist/x/hono.js +0 -60
  267. package/dist/x/sveltekit.cjs +0 -69
  268. package/dist/x/sveltekit.d.cts +0 -45
  269. package/dist/x/sveltekit.d.ts +0 -47
  270. package/dist/x/sveltekit.js +0 -68
  271. /package/dist/{collection-BzWsN9pB.js → collection-CcnIw1qY.js} +0 -0
  272. /package/dist/{testing/docloader.test.d.ts → federation/webfinger.test.d.ts} +0 -0
  273. /package/dist/{mod-CVgZgliM.d.ts → mod-1E3W847c.d.ts} +0 -0
  274. /package/dist/{mod-B-hUPT2N.d.cts → mod-C81L6_lQ.d.cts} +0 -0
  275. /package/dist/{negotiation-C4nFufNk.js → negotiation-5NPJL6zp.js} +0 -0
  276. /package/dist/{nodeinfo-BnthBobC.js → nodeinfo-BlLsRSiT.js} +0 -0
  277. /package/dist/{nodeinfo-CdN0rEnZ.cjs → nodeinfo-DuMYTpbZ.cjs} +0 -0
  278. /package/dist/{vocab/actor.test.d.ts → otel/exporter.test.d.ts} +0 -0
  279. /package/dist/{retry-CfF8Gn4d.js → retry-D4GJ670a.js} +0 -0
  280. /package/dist/{sig-C34-oHBl.js → sig-CwuONEzF.js} +0 -0
  281. /package/dist/{sig-YYj5tCnr.cjs → sig-DeXX2xnj.cjs} +0 -0
  282. /package/dist/{utils-DyRU1gdZ.cjs → utils-Db0ZmjcD.cjs} +0 -0
  283. /package/dist/{utils-D-Va7aXC.js → utils-Wranxuoe.js} +0 -0
@@ -3,22 +3,21 @@
3
3
  const { URLPattern } = require("urlpattern-polyfill");
4
4
 
5
5
  const require_chunk = require('./chunk-DqRYRqnO.cjs');
6
- const require_transformers = require('./transformers-CoBS-oFG.cjs');
7
- const require_lookup = require('./lookup-EHJhdA8l.cjs');
8
- const require_actor = require('./actor-BQuDqoKQ.cjs');
9
- const require_http = require('./http-DarlEN23.cjs');
10
- const require_proof = require('./proof-CbB_yXKu.cjs');
11
- const require_types = require('./types-CWgzGaqk.cjs');
12
- const require_kv_cache = require('./kv-cache-BWWu8RyL.cjs');
13
- const require_vocab = require('./vocab-DCYaqGPG.cjs');
6
+ const require_transformers = require('./transformers-BjBg6Lag.cjs');
7
+ const require_http = require('./http-B_jtB30-.cjs');
8
+ const require_proof = require('./proof-vmNsq1AQ.cjs');
9
+ const require_types = require('./types-B6z6CqIz.cjs');
10
+ const require_kv_cache = require('./kv-cache-DY6hQ8Rf.cjs');
14
11
  const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
12
+ const __fedify_vocab = require_chunk.__toESM(require("@fedify/vocab"));
15
13
  const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
16
- const __fedify_vocab_runtime = require_chunk.__toESM(require("@fedify/vocab-runtime"));
17
14
  const es_toolkit = require_chunk.__toESM(require("es-toolkit"));
18
15
  const uri_template_router = require_chunk.__toESM(require("uri-template-router"));
19
16
  const url_template = require_chunk.__toESM(require("url-template"));
20
17
  const byte_encodings_hex = require_chunk.__toESM(require("byte-encodings/hex"));
21
18
  const __opentelemetry_semantic_conventions = require_chunk.__toESM(require("@opentelemetry/semantic-conventions"));
19
+ const __fedify_vocab_runtime = require_chunk.__toESM(require("@fedify/vocab-runtime"));
20
+ const __fedify_webfinger = require_chunk.__toESM(require("@fedify/webfinger"));
22
21
  const node_url = require_chunk.__toESM(require("node:url"));
23
22
 
24
23
  //#region src/federation/inbox.ts
@@ -42,7 +41,7 @@ var InboxListenerSet = class InboxListenerSet {
42
41
  if (inboxListeners == null) return null;
43
42
  while (true) {
44
43
  if (inboxListeners.has(cls)) break;
45
- if (cls === require_actor.Activity) return null;
44
+ if (cls === __fedify_vocab.Activity) return null;
46
45
  cls = globalThis.Object.getPrototypeOf(cls);
47
46
  }
48
47
  const listener = inboxListeners.get(cls);
@@ -63,7 +62,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
63
62
  ]);
64
63
  let cacheKey = null;
65
64
  if (activity.id != null) {
66
- const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, require_actor.getTypeId(activity).href);
65
+ const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, (0, __fedify_vocab.getTypeId)(activity).href);
67
66
  const strategy = idempotencyStrategy ?? "per-inbox";
68
67
  let keyString;
69
68
  if (typeof strategy === "function") {
@@ -142,7 +141,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
142
141
  return "enqueued";
143
142
  }
144
143
  tracerProvider = tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
145
- const tracer = tracerProvider.getTracer(require_lookup.deno_default.name, require_lookup.deno_default.version);
144
+ const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
146
145
  return await tracer.startActiveSpan("activitypub.dispatch_inbox_listener", { kind: __opentelemetry_api.SpanKind.INTERNAL }, async (span$1) => {
147
146
  const dispatched = inboxListeners?.dispatchWithClass(activity);
148
147
  if (dispatched == null) {
@@ -152,7 +151,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
152
151
  });
153
152
  span$1.setStatus({
154
153
  code: __opentelemetry_api.SpanStatusCode.UNSET,
155
- message: `Unsupported activity type: ${require_actor.getTypeId(activity).href}`
154
+ message: `Unsupported activity type: ${(0, __fedify_vocab.getTypeId)(activity).href}`
156
155
  });
157
156
  span$1.end();
158
157
  return "unsupportedActivity";
@@ -160,7 +159,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
160
159
  const { class: cls, listener } = dispatched;
161
160
  span$1.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
162
161
  try {
163
- await listener(inboxContextFactory(recipient, json, activity?.id?.href, require_actor.getTypeId(activity).href), activity);
162
+ await listener(inboxContextFactory(recipient, json, activity?.id?.href, (0, __fedify_vocab.getTypeId)(activity).href), activity);
164
163
  } catch (error) {
165
164
  try {
166
165
  await inboxErrorHandler?.(ctx, error);
@@ -339,7 +338,7 @@ var FederationBuilderImpl = class {
339
338
  this.collectionTypeIds = {};
340
339
  }
341
340
  async build(options) {
342
- const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-C_Sa9J23.cjs"));
341
+ const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-CnrWiFJI.cjs"));
343
342
  const f = new FederationImpl$1(options);
344
343
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
345
344
  f.router = this.router.clone();
@@ -365,7 +364,7 @@ var FederationBuilderImpl = class {
365
364
  return f;
366
365
  }
367
366
  _getTracer() {
368
- return __opentelemetry_api.trace.getTracer(require_lookup.deno_default.name, require_lookup.deno_default.version);
367
+ return __opentelemetry_api.trace.getTracer(require_http.deno_default.name, require_http.deno_default.version);
369
368
  }
370
369
  setActorDispatcher(path, dispatcher) {
371
370
  if (this.router.has("actor")) throw new RouterError("Actor dispatcher already set.");
@@ -385,7 +384,7 @@ var FederationBuilderImpl = class {
385
384
  const actor$1 = await dispatcher(context$2, identifier);
386
385
  span.setAttribute("activitypub.actor.id", (actor$1?.id ?? context$2.getActorUri(identifier)).href);
387
386
  if (actor$1 == null) span.setStatus({ code: __opentelemetry_api.SpanStatusCode.ERROR });
388
- else span.setAttribute("activitypub.actor.type", require_actor.getTypeId(actor$1).href);
387
+ else span.setAttribute("activitypub.actor.type", (0, __fedify_vocab.getTypeId)(actor$1).href);
389
388
  return actor$1;
390
389
  } catch (error) {
391
390
  span.setStatus({
@@ -508,7 +507,7 @@ var FederationBuilderImpl = class {
508
507
  const object = await dispatcher(ctx, values);
509
508
  span.setAttribute("activitypub.object.id", (object?.id ?? ctx.getObjectUri(cls, values)).href);
510
509
  if (object == null) span.setStatus({ code: __opentelemetry_api.SpanStatusCode.ERROR });
511
- else span.setAttribute("activitypub.object.type", require_actor.getTypeId(object).href);
510
+ else span.setAttribute("activitypub.object.type", (0, __fedify_vocab.getTypeId)(object).href);
512
511
  return object;
513
512
  } catch (e) {
514
513
  span.setStatus({
@@ -923,10 +922,10 @@ var KvKeyCache = class {
923
922
  const serialized = await this.kv.get([...this.prefix, keyId.href]);
924
923
  if (serialized == null) return void 0;
925
924
  try {
926
- return await require_actor.CryptographicKey.fromJsonLd(serialized, this.options);
925
+ return await __fedify_vocab.CryptographicKey.fromJsonLd(serialized, this.options);
927
926
  } catch {
928
927
  try {
929
- return await require_actor.Multikey.fromJsonLd(serialized, this.options);
928
+ return await __fedify_vocab.Multikey.fromJsonLd(serialized, this.options);
930
929
  } catch {
931
930
  await this.kv.delete([...this.prefix, keyId.href]);
932
931
  return void 0;
@@ -1112,7 +1111,7 @@ async function handleObject(request, { values, context: context$2, objectDispatc
1112
1111
  async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$2, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound }) {
1113
1112
  const spanName = name.trim().replace(/\s+/g, "_");
1114
1113
  tracerProvider = tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
1115
- const tracer = tracerProvider.getTracer(require_lookup.deno_default.name, require_lookup.deno_default.version);
1114
+ const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
1116
1115
  const url = new URL(request.url);
1117
1116
  const cursor = url.searchParams.get("cursor");
1118
1117
  if (collectionCallbacks == null) return await onNotFound(request);
@@ -1126,7 +1125,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
1126
1125
  kind: __opentelemetry_api.SpanKind.SERVER,
1127
1126
  attributes: {
1128
1127
  "activitypub.collection.id": baseUri.href,
1129
- "activitypub.collection.type": require_actor.OrderedCollection.typeId.href
1128
+ "activitypub.collection.type": __fedify_vocab.OrderedCollection.typeId.href
1130
1129
  }
1131
1130
  }, async (span) => {
1132
1131
  if (totalItems != null) span.setAttribute("activitypub.collection.total_items", Number(totalItems));
@@ -1150,7 +1149,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
1150
1149
  }
1151
1150
  });
1152
1151
  if (itemsOrResponse instanceof Response) return itemsOrResponse;
1153
- collection = new require_actor.OrderedCollection({
1152
+ collection = new __fedify_vocab.OrderedCollection({
1154
1153
  id: baseUri,
1155
1154
  totalItems: totalItems == null ? null : Number(totalItems),
1156
1155
  items: filterCollectionItems(itemsOrResponse, name, filterPredicate)
@@ -1164,7 +1163,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
1164
1163
  last = new URL(context$2.url);
1165
1164
  last.searchParams.set("cursor", lastCursor);
1166
1165
  }
1167
- collection = new require_actor.OrderedCollection({
1166
+ collection = new __fedify_vocab.OrderedCollection({
1168
1167
  id: baseUri,
1169
1168
  totalItems: totalItems == null ? null : Number(totalItems),
1170
1169
  first,
@@ -1178,7 +1177,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
1178
1177
  kind: __opentelemetry_api.SpanKind.SERVER,
1179
1178
  attributes: {
1180
1179
  "activitypub.collection.id": uri.href,
1181
- "activitypub.collection.type": require_actor.OrderedCollectionPage.typeId.href,
1180
+ "activitypub.collection.type": __fedify_vocab.OrderedCollectionPage.typeId.href,
1182
1181
  "fedify.collection.cursor": cursor
1183
1182
  }
1184
1183
  }, async (span) => {
@@ -1214,7 +1213,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
1214
1213
  }
1215
1214
  const partOf = new URL(context$2.url);
1216
1215
  partOf.searchParams.delete("cursor");
1217
- collection = new require_actor.OrderedCollectionPage({
1216
+ collection = new __fedify_vocab.OrderedCollectionPage({
1218
1217
  id: uri,
1219
1218
  prev,
1220
1219
  next,
@@ -1262,7 +1261,7 @@ function filterCollectionItems(items, collectionName, filterPredicate) {
1262
1261
  let logged = false;
1263
1262
  for (const item of items) {
1264
1263
  let mappedItem;
1265
- if (item instanceof require_actor.Object || item instanceof require_actor.Link || item instanceof URL) mappedItem = item;
1264
+ if (item instanceof __fedify_vocab.Object || item instanceof __fedify_vocab.Link || item instanceof URL) mappedItem = item;
1266
1265
  else if (item.id == null) continue;
1267
1266
  else mappedItem = item.id;
1268
1267
  if (filterPredicate != null && !filterPredicate(item)) {
@@ -1289,7 +1288,7 @@ function filterCollectionItems(items, collectionName, filterPredicate) {
1289
1288
  */
1290
1289
  async function handleInbox(request, options) {
1291
1290
  const tracerProvider = options.tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
1292
- const tracer = tracerProvider.getTracer(require_lookup.deno_default.name, require_lookup.deno_default.version);
1291
+ const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
1293
1292
  return await tracer.startActiveSpan("activitypub.inbox", {
1294
1293
  kind: options.queue == null ? __opentelemetry_api.SpanKind.SERVER : __opentelemetry_api.SpanKind.PRODUCER,
1295
1294
  attributes: { "activitypub.shared_inbox": options.recipient == null }
@@ -1417,14 +1416,14 @@ async function handleInboxInternal(request, parameters, span) {
1417
1416
  recipient,
1418
1417
  json
1419
1418
  });
1420
- activity = await require_actor.Activity.fromJsonLd(jsonWithoutSig, ctx);
1419
+ activity = await __fedify_vocab.Activity.fromJsonLd(jsonWithoutSig, ctx);
1421
1420
  } else {
1422
1421
  logger$1.debug("Linked Data Signatures are not verified.", {
1423
1422
  recipient,
1424
1423
  json
1425
1424
  });
1426
1425
  try {
1427
- activity = await require_proof.verifyObject(require_actor.Activity, jsonWithoutSig, {
1426
+ activity = await require_proof.verifyObject(__fedify_vocab.Activity, jsonWithoutSig, {
1428
1427
  contextLoader: ctx.contextLoader,
1429
1428
  documentLoader: ctx.documentLoader,
1430
1429
  keyCache,
@@ -1487,10 +1486,17 @@ async function handleInboxInternal(request, parameters, span) {
1487
1486
  } else logger$1.debug("HTTP Signatures are verified.", { recipient });
1488
1487
  httpSigKey = key;
1489
1488
  }
1490
- activity = await require_actor.Activity.fromJsonLd(jsonWithoutSig, ctx);
1489
+ activity = await __fedify_vocab.Activity.fromJsonLd(jsonWithoutSig, ctx);
1491
1490
  }
1492
1491
  if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
1493
- span.setAttribute("activitypub.activity.type", require_actor.getTypeId(activity).href);
1492
+ span.setAttribute("activitypub.activity.type", (0, __fedify_vocab.getTypeId)(activity).href);
1493
+ span.addEvent("activitypub.activity.received", {
1494
+ "activitypub.activity.json": JSON.stringify(json),
1495
+ "activitypub.activity.verified": activity != null,
1496
+ "ld_signatures.verified": ldSigVerified,
1497
+ "http_signatures.verified": httpSigKey != null,
1498
+ "http_signatures.key_id": httpSigKey?.id?.href ?? ""
1499
+ });
1494
1500
  if (httpSigKey != null && !await require_proof.doesActorOwnKey(activity, httpSigKey, ctx)) {
1495
1501
  logger$1.error("The signer ({keyId}) and the actor ({actorId}) do not match.", {
1496
1502
  activity: json,
@@ -1563,7 +1569,7 @@ async function _handleCustomCollection(request, { name, values, context: context
1563
1569
  verifyDefined(callbacks);
1564
1570
  await authIfNeeded(context$2, values, callbacks);
1565
1571
  const cursor = new URL(request.url).searchParams.get("cursor");
1566
- return await new CustomCollectionHandler(name, values, context$2, callbacks, tracerProvider, require_actor.Collection, require_actor.CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
1572
+ return await new CustomCollectionHandler(name, values, context$2, callbacks, tracerProvider, __fedify_vocab.Collection, __fedify_vocab.CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
1567
1573
  }
1568
1574
  /**
1569
1575
  * Handles an ordered collection request.
@@ -1581,7 +1587,7 @@ async function _handleOrderedCollection(request, { name, values, context: contex
1581
1587
  verifyDefined(callbacks);
1582
1588
  await authIfNeeded(context$2, values, callbacks);
1583
1589
  const cursor = new URL(request.url).searchParams.get("cursor");
1584
- return await new CustomCollectionHandler(name, values, context$2, callbacks, tracerProvider, require_actor.OrderedCollection, require_actor.OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
1590
+ return await new CustomCollectionHandler(name, values, context$2, callbacks, tracerProvider, __fedify_vocab.OrderedCollection, __fedify_vocab.OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
1585
1591
  }
1586
1592
  /**
1587
1593
  * Handling custom collections with support for pagination and filtering.
@@ -1641,7 +1647,7 @@ var CustomCollectionHandler = class {
1641
1647
  this.CollectionPage = CollectionPage$1;
1642
1648
  this.filterPredicate = filterPredicate;
1643
1649
  this.name = this.name.trim().replace(/\s+/g, "_");
1644
- this.#tracer = this.tracerProvider.getTracer(require_lookup.deno_default.name, require_lookup.deno_default.version);
1650
+ this.#tracer = this.tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
1645
1651
  this.#id = new URL(this.context.url);
1646
1652
  this.#dispatcher = callbacks.dispatcher.bind(callbacks);
1647
1653
  }
@@ -2031,139 +2037,6 @@ function handleNodeInfoJrd(_request, context$2) {
2031
2037
  return Promise.resolve(response);
2032
2038
  }
2033
2039
 
2034
- //#endregion
2035
- //#region src/webfinger/handler.ts
2036
- const logger = (0, __logtape_logtape.getLogger)([
2037
- "fedify",
2038
- "webfinger",
2039
- "server"
2040
- ]);
2041
- /**
2042
- * Handles a WebFinger request. You would not typically call this function
2043
- * directly, but instead use {@link Federation.fetch} method.
2044
- * @param request The WebFinger request to handle.
2045
- * @param parameters The parameters for handling the request.
2046
- * @returns The response to the request.
2047
- */
2048
- async function handleWebFinger(request, options) {
2049
- if (options.tracer == null) return await handleWebFingerInternal(request, options);
2050
- return await options.tracer.startActiveSpan("webfinger.handle", { kind: __opentelemetry_api.SpanKind.SERVER }, async (span) => {
2051
- try {
2052
- const response = await handleWebFingerInternal(request, options);
2053
- span.setStatus({ code: response.ok ? __opentelemetry_api.SpanStatusCode.UNSET : __opentelemetry_api.SpanStatusCode.ERROR });
2054
- return response;
2055
- } catch (error) {
2056
- span.setStatus({
2057
- code: __opentelemetry_api.SpanStatusCode.ERROR,
2058
- message: String(error)
2059
- });
2060
- throw error;
2061
- } finally {
2062
- span.end();
2063
- }
2064
- });
2065
- }
2066
- async function handleWebFingerInternal(request, { context: context$2, host, actorDispatcher, actorHandleMapper, actorAliasMapper, onNotFound, span, webFingerLinksDispatcher }) {
2067
- if (actorDispatcher == null) {
2068
- logger.error("Actor dispatcher is not set.");
2069
- return await onNotFound(request);
2070
- }
2071
- const resource = context$2.url.searchParams.get("resource");
2072
- if (resource == null) return new Response("Missing resource parameter.", { status: 400 });
2073
- span?.setAttribute("webfinger.resource", resource);
2074
- let resourceUrl;
2075
- try {
2076
- resourceUrl = new URL(resource);
2077
- } catch (e) {
2078
- if (e instanceof TypeError) return new Response("Invalid resource URL.", { status: 400 });
2079
- throw e;
2080
- }
2081
- span?.setAttribute("webfinger.resource.scheme", resourceUrl.protocol.replace(/:$/, ""));
2082
- async function mapUsernameToIdentifier(username) {
2083
- if (actorHandleMapper == null) {
2084
- logger.error("No actor handle mapper is set; use the WebFinger username {username} as the actor's internal identifier.", { username });
2085
- return username;
2086
- }
2087
- const identifier$1 = await actorHandleMapper(context$2, username);
2088
- if (identifier$1 == null) {
2089
- logger.error("Actor {username} not found.", { username });
2090
- return null;
2091
- }
2092
- return identifier$1;
2093
- }
2094
- let identifier = null;
2095
- const uriParsed = context$2.parseUri(resourceUrl);
2096
- if (uriParsed?.type != "actor") {
2097
- const match = /^acct:([^@]+)@([^@]+)$/.exec(resource);
2098
- if (match == null) {
2099
- const result = await actorAliasMapper?.(context$2, resourceUrl);
2100
- if (result == null) return await onNotFound(request);
2101
- if ("identifier" in result) identifier = result.identifier;
2102
- else identifier = await mapUsernameToIdentifier(result.username);
2103
- } else {
2104
- const portMatch = /:\d+$/.exec(match[2]);
2105
- const normalizedHost = portMatch == null ? (0, node_url.domainToASCII)(match[2].toLowerCase()) : (0, node_url.domainToASCII)(match[2].substring(0, portMatch.index).toLowerCase()) + portMatch[0];
2106
- if (normalizedHost != context$2.url.host && normalizedHost != host) return await onNotFound(request);
2107
- else {
2108
- identifier = await mapUsernameToIdentifier(match[1]);
2109
- resourceUrl = new URL(`acct:${match[1]}@${normalizedHost}`);
2110
- }
2111
- }
2112
- } else identifier = uriParsed.identifier;
2113
- if (identifier == null) return await onNotFound(request);
2114
- const actor = await actorDispatcher(context$2, identifier);
2115
- if (actor == null) {
2116
- logger.error("Actor {identifier} not found.", { identifier });
2117
- return await onNotFound(request);
2118
- }
2119
- const links = [{
2120
- rel: "self",
2121
- href: context$2.getActorUri(identifier).href,
2122
- type: "application/activity+json"
2123
- }];
2124
- for (const url of actor.urls) if (url instanceof require_actor.Link && url.href != null) links.push({
2125
- rel: url.rel ?? "http://webfinger.net/rel/profile-page",
2126
- href: url.href.href,
2127
- type: url.mediaType == null ? void 0 : url.mediaType
2128
- });
2129
- else if (url instanceof URL) links.push({
2130
- rel: "http://webfinger.net/rel/profile-page",
2131
- href: url.href
2132
- });
2133
- for await (const image of actor.getIcons()) {
2134
- if (image.url?.href == null) continue;
2135
- const link = {
2136
- rel: "http://webfinger.net/rel/avatar",
2137
- href: image.url.href.toString()
2138
- };
2139
- if (image.mediaType != null) link.type = image.mediaType;
2140
- links.push(link);
2141
- }
2142
- if (webFingerLinksDispatcher != null) {
2143
- const customLinks = await webFingerLinksDispatcher(context$2, resourceUrl);
2144
- if (customLinks != null) for (const link of customLinks) links.push(link);
2145
- }
2146
- const aliases = [];
2147
- if (resourceUrl.protocol != "acct:" && actor.preferredUsername != null) {
2148
- aliases.push(`acct:${actor.preferredUsername}@${host ?? context$2.url.host}`);
2149
- if (host != null && host !== context$2.url.host) aliases.push(`acct:${actor.preferredUsername}@${context$2.url.host}`);
2150
- }
2151
- if (resourceUrl.href !== context$2.getActorUri(identifier).href) aliases.push(context$2.getActorUri(identifier).href);
2152
- if (resourceUrl.protocol === "acct:" && host != null && host !== context$2.url.host && !resourceUrl.href.endsWith(`@${host}`)) {
2153
- const username = resourceUrl.href.replace(/^acct:/, "").replace(/@.*$/, "");
2154
- aliases.push(`acct:${username}@${host}`);
2155
- }
2156
- const jrd = {
2157
- subject: resourceUrl.href,
2158
- aliases,
2159
- links
2160
- };
2161
- return new Response(JSON.stringify(jrd), { headers: {
2162
- "Content-Type": "application/jrd+json",
2163
- "Access-Control-Allow-Origin": "*"
2164
- } });
2165
- }
2166
-
2167
2040
  //#endregion
2168
2041
  //#region src/federation/retry.ts
2169
2042
  /**
@@ -2232,7 +2105,7 @@ function extractInboxes({ recipients, preferSharedInbox, excludeBaseUris }) {
2232
2105
  */
2233
2106
  function sendActivity(options) {
2234
2107
  const tracerProvider = options.tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
2235
- const tracer = tracerProvider.getTracer(require_lookup.deno_default.name, require_lookup.deno_default.version);
2108
+ const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
2236
2109
  return tracer.startActiveSpan("activitypub.send_activity", {
2237
2110
  kind: __opentelemetry_api.SpanKind.CLIENT,
2238
2111
  attributes: { "activitypub.shared_inbox": options.sharedInbox ?? false }
@@ -2243,7 +2116,7 @@ function sendActivity(options) {
2243
2116
  await sendActivityInternal({
2244
2117
  ...options,
2245
2118
  tracerProvider
2246
- });
2119
+ }, span);
2247
2120
  } catch (e) {
2248
2121
  span.setStatus({
2249
2122
  code: __opentelemetry_api.SpanStatusCode.ERROR,
@@ -2255,7 +2128,7 @@ function sendActivity(options) {
2255
2128
  }
2256
2129
  });
2257
2130
  }
2258
- async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }) {
2131
+ async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }, span) {
2259
2132
  const logger$1 = (0, __logtape_logtape.getLogger)([
2260
2133
  "fedify",
2261
2134
  "federation",
@@ -2310,6 +2183,143 @@ async function sendActivityInternal({ activity, activityId, keys, inbox, headers
2310
2183
  });
2311
2184
  throw new Error(`Failed to send activity ${activityId} to ${inbox.href} (${response.status} ${response.statusText}):\n${error}`);
2312
2185
  }
2186
+ span.addEvent("activitypub.activity.sent", {
2187
+ "activitypub.activity.json": JSON.stringify(activity),
2188
+ "activitypub.inbox.url": inbox.href,
2189
+ "activitypub.activity.id": activityId ?? ""
2190
+ });
2191
+ }
2192
+
2193
+ //#endregion
2194
+ //#region src/federation/webfinger.ts
2195
+ const logger = (0, __logtape_logtape.getLogger)([
2196
+ "fedify",
2197
+ "webfinger",
2198
+ "server"
2199
+ ]);
2200
+ /**
2201
+ * Handles a WebFinger request. You would not typically call this function
2202
+ * directly, but instead use {@link Federation.fetch} method.
2203
+ * @param request The WebFinger request to handle.
2204
+ * @param parameters The parameters for handling the request.
2205
+ * @returns The response to the request.
2206
+ */
2207
+ async function handleWebFinger(request, options) {
2208
+ if (options.tracer == null) return await handleWebFingerInternal(request, options);
2209
+ return await options.tracer.startActiveSpan("webfinger.handle", { kind: __opentelemetry_api.SpanKind.SERVER }, async (span) => {
2210
+ try {
2211
+ const response = await handleWebFingerInternal(request, options);
2212
+ span.setStatus({ code: response.ok ? __opentelemetry_api.SpanStatusCode.UNSET : __opentelemetry_api.SpanStatusCode.ERROR });
2213
+ return response;
2214
+ } catch (error) {
2215
+ span.setStatus({
2216
+ code: __opentelemetry_api.SpanStatusCode.ERROR,
2217
+ message: String(error)
2218
+ });
2219
+ throw error;
2220
+ } finally {
2221
+ span.end();
2222
+ }
2223
+ });
2224
+ }
2225
+ async function handleWebFingerInternal(request, { context: context$2, host, actorDispatcher, actorHandleMapper, actorAliasMapper, onNotFound, span, webFingerLinksDispatcher }) {
2226
+ if (actorDispatcher == null) {
2227
+ logger.error("Actor dispatcher is not set.");
2228
+ return await onNotFound(request);
2229
+ }
2230
+ const resource = context$2.url.searchParams.get("resource");
2231
+ if (resource == null) return new Response("Missing resource parameter.", { status: 400 });
2232
+ span?.setAttribute("webfinger.resource", resource);
2233
+ let resourceUrl;
2234
+ try {
2235
+ resourceUrl = new URL(resource);
2236
+ } catch (e) {
2237
+ if (e instanceof TypeError) return new Response("Invalid resource URL.", { status: 400 });
2238
+ throw e;
2239
+ }
2240
+ span?.setAttribute("webfinger.resource.scheme", resourceUrl.protocol.replace(/:$/, ""));
2241
+ async function mapUsernameToIdentifier(username) {
2242
+ if (actorHandleMapper == null) {
2243
+ logger.error("No actor handle mapper is set; use the WebFinger username {username} as the actor's internal identifier.", { username });
2244
+ return username;
2245
+ }
2246
+ const identifier$1 = await actorHandleMapper(context$2, username);
2247
+ if (identifier$1 == null) {
2248
+ logger.error("Actor {username} not found.", { username });
2249
+ return null;
2250
+ }
2251
+ return identifier$1;
2252
+ }
2253
+ let identifier = null;
2254
+ const uriParsed = context$2.parseUri(resourceUrl);
2255
+ if (uriParsed?.type != "actor") {
2256
+ const match = /^acct:([^@]+)@([^@]+)$/.exec(resource);
2257
+ if (match == null) {
2258
+ const result = await actorAliasMapper?.(context$2, resourceUrl);
2259
+ if (result == null) return await onNotFound(request);
2260
+ if ("identifier" in result) identifier = result.identifier;
2261
+ else identifier = await mapUsernameToIdentifier(result.username);
2262
+ } else {
2263
+ const portMatch = /:\d+$/.exec(match[2]);
2264
+ const normalizedHost = portMatch == null ? (0, node_url.domainToASCII)(match[2].toLowerCase()) : (0, node_url.domainToASCII)(match[2].substring(0, portMatch.index).toLowerCase()) + portMatch[0];
2265
+ if (normalizedHost != context$2.url.host && normalizedHost != host) return await onNotFound(request);
2266
+ else {
2267
+ identifier = await mapUsernameToIdentifier(match[1]);
2268
+ resourceUrl = new URL(`acct:${match[1]}@${normalizedHost}`);
2269
+ }
2270
+ }
2271
+ } else identifier = uriParsed.identifier;
2272
+ if (identifier == null) return await onNotFound(request);
2273
+ const actor = await actorDispatcher(context$2, identifier);
2274
+ if (actor == null) {
2275
+ logger.error("Actor {identifier} not found.", { identifier });
2276
+ return await onNotFound(request);
2277
+ }
2278
+ const links = [{
2279
+ rel: "self",
2280
+ href: context$2.getActorUri(identifier).href,
2281
+ type: "application/activity+json"
2282
+ }];
2283
+ for (const url of actor.urls) if (url instanceof __fedify_vocab.Link && url.href != null) links.push({
2284
+ rel: url.rel ?? "http://webfinger.net/rel/profile-page",
2285
+ href: url.href.href,
2286
+ type: url.mediaType == null ? void 0 : url.mediaType
2287
+ });
2288
+ else if (url instanceof URL) links.push({
2289
+ rel: "http://webfinger.net/rel/profile-page",
2290
+ href: url.href
2291
+ });
2292
+ for await (const image of actor.getIcons()) {
2293
+ if (image.url?.href == null) continue;
2294
+ links.push({
2295
+ rel: "http://webfinger.net/rel/avatar",
2296
+ href: image.url.href.toString(),
2297
+ ...image.mediaType != null && { type: image.mediaType }
2298
+ });
2299
+ }
2300
+ if (webFingerLinksDispatcher != null) {
2301
+ const customLinks = await webFingerLinksDispatcher(context$2, resourceUrl);
2302
+ if (customLinks != null) for (const link of customLinks) links.push(link);
2303
+ }
2304
+ const aliases = [];
2305
+ if (resourceUrl.protocol != "acct:" && actor.preferredUsername != null) {
2306
+ aliases.push(`acct:${actor.preferredUsername}@${host ?? context$2.url.host}`);
2307
+ if (host != null && host !== context$2.url.host) aliases.push(`acct:${actor.preferredUsername}@${context$2.url.host}`);
2308
+ }
2309
+ if (resourceUrl.href !== context$2.getActorUri(identifier).href) aliases.push(context$2.getActorUri(identifier).href);
2310
+ if (resourceUrl.protocol === "acct:" && host != null && host !== context$2.url.host && !resourceUrl.href.endsWith(`@${host}`)) {
2311
+ const username = resourceUrl.href.replace(/^acct:/, "").replace(/@.*$/, "");
2312
+ aliases.push(`acct:${username}@${host}`);
2313
+ }
2314
+ const jrd = {
2315
+ subject: resourceUrl.href,
2316
+ aliases,
2317
+ links
2318
+ };
2319
+ return new Response(JSON.stringify(jrd), { headers: {
2320
+ "Content-Type": "application/jrd+json",
2321
+ "Access-Control-Allow-Origin": "*"
2322
+ } });
2313
2323
  }
2314
2324
 
2315
2325
  //#endregion
@@ -2434,7 +2444,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2434
2444
  this.router.add("/.well-known/nodeinfo", "nodeInfoJrd");
2435
2445
  }
2436
2446
  _getTracer() {
2437
- return this.tracerProvider.getTracer(require_lookup.deno_default.name, require_lookup.deno_default.version);
2447
+ return this.tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
2438
2448
  }
2439
2449
  async _startQueueInternal(ctxData, signal, queue) {
2440
2450
  if (this.inboxQueue == null && this.outboxQueue == null) return;
@@ -2534,7 +2544,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2534
2544
  keyId: new URL(keyId),
2535
2545
  privateKey: await require_http.importJwk(privateKey, "private")
2536
2546
  })));
2537
- const activity = await require_actor.Activity.fromJsonLd(message.activity, {
2547
+ const activity = await __fedify_vocab.Activity.fromJsonLd(message.activity, {
2538
2548
  contextLoader: this.contextLoaderFactory({
2539
2549
  allowPrivateAddress: this.allowPrivateAddress,
2540
2550
  userAgent: this.userAgent
@@ -2596,7 +2606,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2596
2606
  message: String(error)
2597
2607
  });
2598
2608
  const loaderOptions = this.#getLoaderOptions(message.baseUrl);
2599
- const activity = await require_actor.Activity.fromJsonLd(message.activity, {
2609
+ const activity = await __fedify_vocab.Activity.fromJsonLd(message.activity, {
2600
2610
  contextLoader: this.contextLoaderFactory(loaderOptions),
2601
2611
  documentLoader: rsaKeyPair == null ? this.documentLoaderFactory(loaderOptions) : this.authenticatedDocumentLoaderFactory(rsaKeyPair, loaderOptions),
2602
2612
  tracerProvider: this.tracerProvider
@@ -2650,8 +2660,8 @@ var FederationImpl = class extends FederationBuilderImpl {
2650
2660
  const identity = await this.sharedInboxKeyDispatcher(context$2);
2651
2661
  if (identity != null) context$2 = this.#createContext(baseUrl, ctxData, { documentLoader: "identifier" in identity || "username" in identity || "handle" in identity ? await context$2.getDocumentLoader(identity) : context$2.getDocumentLoader(identity) });
2652
2662
  }
2653
- const activity = await require_actor.Activity.fromJsonLd(message.activity, context$2);
2654
- span.setAttribute("activitypub.activity.type", require_actor.getTypeId(activity).href);
2663
+ const activity = await __fedify_vocab.Activity.fromJsonLd(message.activity, context$2);
2664
+ span.setAttribute("activitypub.activity.type", (0, __fedify_vocab.getTypeId)(activity).href);
2655
2665
  if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
2656
2666
  const cacheKey = activity.id == null ? null : [
2657
2667
  ...this.kvPrefixes.activityIdempotence,
@@ -2680,7 +2690,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2680
2690
  });
2681
2691
  span$1.setStatus({
2682
2692
  code: __opentelemetry_api.SpanStatusCode.ERROR,
2683
- message: `Unsupported activity type: ${require_actor.getTypeId(activity).href}`
2693
+ message: `Unsupported activity type: ${(0, __fedify_vocab.getTypeId)(activity).href}`
2684
2694
  });
2685
2695
  span$1.end();
2686
2696
  return;
@@ -2688,7 +2698,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2688
2698
  const { class: cls, listener } = dispatched;
2689
2699
  span$1.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
2690
2700
  try {
2691
- await listener(context$2.toInboxContext(message.identifier, message.activity, activity.id?.href, require_actor.getTypeId(activity).href), activity);
2701
+ await listener(context$2.toInboxContext(message.identifier, message.activity, activity.id?.href, (0, __fedify_vocab.getTypeId)(activity).href), activity);
2692
2702
  } catch (error) {
2693
2703
  try {
2694
2704
  await this.inboxErrorHandler?.(context$2, error);
@@ -2860,7 +2870,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2860
2870
  keys,
2861
2871
  activity: jsonLd,
2862
2872
  activityId: activity.id?.href,
2863
- activityType: require_actor.getTypeId(activity).href,
2873
+ activityType: (0, __fedify_vocab.getTypeId)(activity).href,
2864
2874
  inbox: new URL(inbox),
2865
2875
  sharedInbox: inboxes[inbox].sharedInbox,
2866
2876
  headers: collectionSync == null ? void 0 : new Headers({ "Collection-Synchronization": await buildCollectionSynchronizationHeader(collectionSync, inboxes[inbox].actorIds) }),
@@ -2894,7 +2904,7 @@ var FederationImpl = class extends FederationBuilderImpl {
2894
2904
  keys: keyJwkPairs,
2895
2905
  activity: jsonLd,
2896
2906
  activityId: activity.id?.href,
2897
- activityType: require_actor.getTypeId(activity).href,
2907
+ activityType: (0, __fedify_vocab.getTypeId)(activity).href,
2898
2908
  inbox,
2899
2909
  sharedInbox: inboxes[inbox].sharedInbox,
2900
2910
  started: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3449,12 +3459,12 @@ var ContextImpl = class ContextImpl {
3449
3459
  for (const keyPair of keyPairs) {
3450
3460
  const newPair = {
3451
3461
  ...keyPair,
3452
- cryptographicKey: new require_actor.CryptographicKey({
3462
+ cryptographicKey: new __fedify_vocab.CryptographicKey({
3453
3463
  id: keyPair.keyId,
3454
3464
  owner,
3455
3465
  publicKey: keyPair.publicKey
3456
3466
  }),
3457
- multikey: new require_actor.Multikey({
3467
+ multikey: new __fedify_vocab.Multikey({
3458
3468
  id: keyPair.keyId,
3459
3469
  controller: owner,
3460
3470
  publicKey: keyPair.publicKey
@@ -3540,7 +3550,7 @@ var ContextImpl = class ContextImpl {
3540
3550
  return this.federation.authenticatedDocumentLoaderFactory(identity);
3541
3551
  }
3542
3552
  lookupObject(identifier, options = {}) {
3543
- return require_vocab.lookupObject(identifier, {
3553
+ return (0, __fedify_vocab.lookupObject)(identifier, {
3544
3554
  ...options,
3545
3555
  documentLoader: options.documentLoader ?? this.documentLoader,
3546
3556
  contextLoader: options.contextLoader ?? this.contextLoader,
@@ -3550,7 +3560,7 @@ var ContextImpl = class ContextImpl {
3550
3560
  });
3551
3561
  }
3552
3562
  traverseCollection(collection, options = {}) {
3553
- return require_vocab.traverseCollection(collection, {
3563
+ return (0, __fedify_vocab.traverseCollection)(collection, {
3554
3564
  ...options,
3555
3565
  documentLoader: options.documentLoader ?? this.documentLoader,
3556
3566
  contextLoader: options.contextLoader ?? this.contextLoader
@@ -3568,7 +3578,7 @@ var ContextImpl = class ContextImpl {
3568
3578
  });
3569
3579
  }
3570
3580
  lookupWebFinger(resource, options = {}) {
3571
- return require_lookup.lookupWebFinger(resource, {
3581
+ return (0, __fedify_webfinger.lookupWebFinger)(resource, {
3572
3582
  ...options,
3573
3583
  userAgent: options.userAgent ?? this.federation.userAgent,
3574
3584
  tracerProvider: options.tracerProvider ?? this.tracerProvider,
@@ -3576,11 +3586,11 @@ var ContextImpl = class ContextImpl {
3576
3586
  });
3577
3587
  }
3578
3588
  sendActivity(sender, recipients, activity, options = {}) {
3579
- const tracer = this.tracerProvider.getTracer(require_lookup.deno_default.name, require_lookup.deno_default.version);
3589
+ const tracer = this.tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
3580
3590
  return tracer.startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
3581
3591
  kind: this.federation.outboxQueue == null || options.immediate ? __opentelemetry_api.SpanKind.CLIENT : __opentelemetry_api.SpanKind.PRODUCER,
3582
3592
  attributes: {
3583
- "activitypub.activity.type": require_actor.getTypeId(activity).href,
3593
+ "activitypub.activity.type": (0, __fedify_vocab.getTypeId)(activity).href,
3584
3594
  "activitypub.activity.to": activity.toIds.map((to) => to.href),
3585
3595
  "activitypub.activity.cc": activity.toIds.map((cc) => cc.href),
3586
3596
  "activitypub.activity.bto": activity.btoIds.map((bto) => bto.href),
@@ -3692,7 +3702,7 @@ var ContextImpl = class ContextImpl {
3692
3702
  contextLoader: this.contextLoader
3693
3703
  }),
3694
3704
  activityId: activity.id?.href,
3695
- activityType: require_actor.getTypeId(activity).href,
3705
+ activityType: (0, __fedify_vocab.getTypeId)(activity).href,
3696
3706
  collectionSync: opts.collectionSync,
3697
3707
  traceContext: carrier
3698
3708
  };
@@ -3722,10 +3732,10 @@ var ContextImpl = class ContextImpl {
3722
3732
  }
3723
3733
  routeActivity(recipient, activity, options = {}) {
3724
3734
  const tracerProvider = this.tracerProvider ?? this.tracerProvider;
3725
- const tracer = tracerProvider.getTracer(require_lookup.deno_default.name, require_lookup.deno_default.version);
3735
+ const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
3726
3736
  return tracer.startActiveSpan("activitypub.inbox", {
3727
3737
  kind: this.federation.inboxQueue == null || options.immediate ? __opentelemetry_api.SpanKind.INTERNAL : __opentelemetry_api.SpanKind.PRODUCER,
3728
- attributes: { "activitypub.activity.type": require_actor.getTypeId(activity).href }
3738
+ attributes: { "activitypub.activity.type": (0, __fedify_vocab.getTypeId)(activity).href }
3729
3739
  }, async (span) => {
3730
3740
  if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
3731
3741
  if (activity.toIds.length > 0) span.setAttribute("activitypub.activity.to", activity.toIds.map((to) => to.href));
@@ -3759,7 +3769,7 @@ var ContextImpl = class ContextImpl {
3759
3769
  const contextLoader = options.contextLoader ?? this.contextLoader;
3760
3770
  const json = await activity.toJsonLd({ contextLoader });
3761
3771
  const keyCache = new KvKeyCache(this.federation.kv, this.federation.kvPrefixes.publicKey, this);
3762
- const verified = await require_proof.verifyObject(require_actor.Activity, json, {
3772
+ const verified = await require_proof.verifyObject(__fedify_vocab.Activity, json, {
3763
3773
  contextLoader,
3764
3774
  documentLoader: options.documentLoader ?? this.documentLoader,
3765
3775
  tracerProvider: options.tracerProvider ?? this.tracerProvider,
@@ -3785,7 +3795,7 @@ var ContextImpl = class ContextImpl {
3785
3795
  activityId: activity.id.href
3786
3796
  });
3787
3797
  return false;
3788
- } else if (!(fetched instanceof require_actor.Activity)) {
3798
+ } else if (!(fetched instanceof __fedify_vocab.Activity)) {
3789
3799
  logger$1.debug("Fetched object is not an Activity.", {
3790
3800
  recipient,
3791
3801
  activity: await fetched.toJsonLd({ contextLoader })
@@ -3940,7 +3950,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
3940
3950
  });
3941
3951
  }
3942
3952
  forwardActivity(forwarder, recipients, options) {
3943
- const tracer = this.tracerProvider.getTracer(require_lookup.deno_default.name, require_lookup.deno_default.version);
3953
+ const tracer = this.tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
3944
3954
  return tracer.startActiveSpan("activitypub.outbox", {
3945
3955
  kind: this.federation.outboxQueue == null || options?.immediate ? __opentelemetry_api.SpanKind.CLIENT : __opentelemetry_api.SpanKind.PRODUCER,
3946
3956
  attributes: { "activitypub.activity.type": this.activityType }
@@ -3992,7 +4002,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
3992
4002
  if (!require_proof.hasSignature(this.activity)) {
3993
4003
  let hasProof;
3994
4004
  try {
3995
- const activity = await require_actor.Activity.fromJsonLd(this.activity, this);
4005
+ const activity = await __fedify_vocab.Activity.fromJsonLd(this.activity, this);
3996
4006
  hasProof = await activity.getProof() != null;
3997
4007
  } catch {
3998
4008
  hasProof = false;
@@ -4211,6 +4221,12 @@ Object.defineProperty(exports, 'digest', {
4211
4221
  return digest;
4212
4222
  }
4213
4223
  });
4224
+ Object.defineProperty(exports, 'handleWebFinger', {
4225
+ enumerable: true,
4226
+ get: function () {
4227
+ return handleWebFinger;
4228
+ }
4229
+ });
4214
4230
  Object.defineProperty(exports, 'respondWithObject', {
4215
4231
  enumerable: true,
4216
4232
  get: function () {