@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,16 +3,44 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { RouterError, __require, lookupObject, lookupWebFinger, traverseCollection } from "./lookup-Bhv7efZB.js";
6
+ import { createRequire } from "node:module";
7
7
  import { configure, getConsoleSink, getLogger, reset } from "@logtape/logtape";
8
- import { trace } from "@opentelemetry/api";
8
+ import { BasicTracerProvider, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
9
+ import { ExportResultCode } from "@opentelemetry/core";
9
10
 
10
- //#region src/testing/docloader.ts
11
- const logger = getLogger([
12
- "fedify",
13
- "testing",
14
- "docloader"
15
- ]);
11
+ //#region rolldown:runtime
12
+ var __create = Object.create;
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __getProtoOf = Object.getPrototypeOf;
17
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
18
+ var __commonJS = (cb, mod) => function() {
19
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
23
+ key = keys[i];
24
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
25
+ get: ((k) => from[k]).bind(null, key),
26
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
+ });
28
+ }
29
+ return to;
30
+ };
31
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
32
+ value: mod,
33
+ enumerable: true
34
+ }) : target, mod));
35
+ var __require$1 = /* @__PURE__ */ createRequire(import.meta.url);
36
+
37
+ //#endregion
38
+ //#region ../fixture/dist/mod.js
39
+ var __require = /* @__PURE__ */ ((x) => typeof __require$1 !== "undefined" ? __require$1 : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof __require$1 !== "undefined" ? __require$1 : a)[b] }) : x)(function(x) {
40
+ if (typeof __require$1 !== "undefined") return __require$1.apply(this, arguments);
41
+ throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
42
+ });
43
+ const logger = getLogger(["fixture", "docloader"]);
16
44
  /**
17
45
  * A mock of the document loader. This does not make any actual HTTP requests
18
46
  * towards the remote server, but looks up the local fixture files instead.
@@ -48,13 +76,14 @@ async function mockDocumentLoader(resource, _options) {
48
76
  });
49
77
  throw new Error(error);
50
78
  }
51
- const path = `./fixtures/${url.host}${url.pathname}.json`;
79
+ const pkg = "Deno" in globalThis ? "." : "@fedify/fixture";
80
+ const fixturePath = `${pkg}/fixtures/${url.host}${url.pathname}.json`;
52
81
  let document;
53
82
  try {
54
- document = (await import(path, { with: { type: "json" } })).default;
83
+ document = (await import(fixturePath, { with: { type: "json" } })).default;
55
84
  } catch (error) {
56
85
  logger.error("Failed to read fixture file {path}: {error}", {
57
- path,
86
+ path: fixturePath,
58
87
  error
59
88
  });
60
89
  throw error;
@@ -65,106 +94,57 @@ async function mockDocumentLoader(resource, _options) {
65
94
  documentUrl: resource
66
95
  };
67
96
  }
68
-
69
- //#endregion
70
- //#region src/testing/context.ts
71
- function createContext(values) {
72
- const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, tracerProvider, clone, getNodeInfoUri, getActorUri, getObjectUri, getCollectionUri, getOutboxUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject: lookupObject$1, traverseCollection: traverseCollection$1, lookupNodeInfo, lookupWebFinger: lookupWebFinger$1, sendActivity, routeActivity } = values;
73
- function throwRouteError() {
74
- throw new RouterError("Not implemented");
97
+ /**
98
+ * A test spy for OpenTelemetry spans that captures all spans and events.
99
+ */
100
+ var TestSpanExporter = class {
101
+ spans = [];
102
+ export(spans, resultCallback) {
103
+ this.spans.push(...spans);
104
+ resultCallback({ code: ExportResultCode.SUCCESS });
75
105
  }
76
- return {
77
- federation,
78
- data,
79
- origin: url.origin,
80
- canonicalOrigin: canonicalOrigin ?? url.origin,
81
- host: url.host,
82
- hostname: url.hostname,
83
- documentLoader: documentLoader ?? mockDocumentLoader,
84
- contextLoader: contextLoader ?? mockDocumentLoader,
85
- tracerProvider: tracerProvider ?? trace.getTracerProvider(),
86
- clone: clone ?? ((data$1) => createContext({
87
- ...values,
88
- data: data$1
89
- })),
90
- getNodeInfoUri: getNodeInfoUri ?? throwRouteError,
91
- getActorUri: getActorUri ?? throwRouteError,
92
- getObjectUri: getObjectUri ?? throwRouteError,
93
- getCollectionUri: getCollectionUri ?? throwRouteError,
94
- getOutboxUri: getOutboxUri ?? throwRouteError,
95
- getInboxUri: getInboxUri ?? throwRouteError,
96
- getFollowingUri: getFollowingUri ?? throwRouteError,
97
- getFollowersUri: getFollowersUri ?? throwRouteError,
98
- getLikedUri: getLikedUri ?? throwRouteError,
99
- getFeaturedUri: getFeaturedUri ?? throwRouteError,
100
- getFeaturedTagsUri: getFeaturedTagsUri ?? throwRouteError,
101
- parseUri: parseUri ?? ((_uri) => {
102
- throw new Error("Not implemented");
103
- }),
104
- getDocumentLoader: getDocumentLoader ?? ((_params) => {
105
- throw new Error("Not implemented");
106
- }),
107
- getActorKeyPairs: getActorKeyPairs ?? ((_handle) => Promise.resolve([])),
108
- lookupObject: lookupObject$1 ?? ((uri, options = {}) => {
109
- return lookupObject(uri, {
110
- documentLoader: options.documentLoader ?? documentLoader ?? mockDocumentLoader,
111
- contextLoader: options.contextLoader ?? contextLoader ?? mockDocumentLoader
112
- });
113
- }),
114
- traverseCollection: traverseCollection$1 ?? ((collection, options = {}) => {
115
- return traverseCollection(collection, {
116
- documentLoader: options.documentLoader ?? documentLoader ?? mockDocumentLoader,
117
- contextLoader: options.contextLoader ?? contextLoader ?? mockDocumentLoader
118
- });
119
- }),
120
- lookupNodeInfo: lookupNodeInfo ?? ((_params) => {
121
- throw new Error("Not implemented");
122
- }),
123
- lookupWebFinger: lookupWebFinger$1 ?? ((resource, options = {}) => {
124
- return lookupWebFinger(resource, options);
125
- }),
126
- sendActivity: sendActivity ?? ((_params) => {
127
- throw new Error("Not implemented");
128
- }),
129
- routeActivity: routeActivity ?? ((_params) => {
130
- throw new Error("Not implemented");
131
- })
132
- };
133
- }
134
- function createRequestContext(args) {
135
- return {
136
- ...createContext(args),
137
- clone: args.clone ?? ((data) => createRequestContext({
138
- ...args,
139
- data
140
- })),
141
- request: args.request ?? new Request(args.url),
142
- url: args.url,
143
- getActor: args.getActor ?? (() => Promise.resolve(null)),
144
- getObject: args.getObject ?? (() => Promise.resolve(null)),
145
- getSignedKey: args.getSignedKey ?? (() => Promise.resolve(null)),
146
- getSignedKeyOwner: args.getSignedKeyOwner ?? (() => Promise.resolve(null)),
147
- sendActivity: args.sendActivity ?? ((_params) => {
148
- throw new Error("Not implemented");
149
- })
150
- };
151
- }
152
- function createInboxContext(args) {
153
- return {
154
- ...createContext(args),
155
- clone: args.clone ?? ((data) => createInboxContext({
156
- ...args,
157
- data
158
- })),
159
- recipient: args.recipient ?? null,
160
- forwardActivity: args.forwardActivity ?? ((_params) => {
161
- throw new Error("Not implemented");
162
- })
163
- };
106
+ async forceFlush() {}
107
+ shutdown() {
108
+ this.spans = [];
109
+ return Promise.resolve();
110
+ }
111
+ /**
112
+ * Gets all spans with the given name.
113
+ */
114
+ getSpans(name) {
115
+ return this.spans.filter((span) => span.name === name);
116
+ }
117
+ /**
118
+ * Gets the first span with the given name.
119
+ */
120
+ getSpan(name) {
121
+ return this.spans.find((span) => span.name === name);
122
+ }
123
+ /**
124
+ * Gets all events from spans with the given name.
125
+ */
126
+ getEvents(spanName, eventName) {
127
+ const spans = this.getSpans(spanName);
128
+ const events = spans.flatMap((span) => span.events);
129
+ if (eventName) return events.filter((event) => event.name === eventName);
130
+ return events;
131
+ }
132
+ /**
133
+ * Clears all captured spans.
134
+ */
135
+ clear() {
136
+ this.spans = [];
137
+ }
138
+ };
139
+ /**
140
+ * Creates a test tracer provider with a test exporter.
141
+ * @returns A tuple of [tracerProvider, testExporter]
142
+ */
143
+ function createTestTracerProvider() {
144
+ const exporter = new TestSpanExporter();
145
+ const provider = new BasicTracerProvider({ spanProcessors: [new SimpleSpanProcessor(exporter)] });
146
+ return [provider, exporter];
164
147
  }
165
-
166
- //#endregion
167
- //#region src/testing/mod.ts
168
148
  const testDefinitions = [];
169
149
  function test(name, options, fn) {
170
150
  const def = typeof name === "string" ? typeof options === "function" ? {
@@ -298,4 +278,4 @@ function caller() {
298
278
  }
299
279
 
300
280
  //#endregion
301
- export { createInboxContext, createRequestContext, mockDocumentLoader, test, testDefinitions };
281
+ export { __commonJS, __toESM, createTestTracerProvider, mockDocumentLoader, test, testDefinitions };
@@ -3,11 +3,11 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { validateCryptoKey } from "./key-BcT6cdMK.js";
7
- import { doubleKnock } from "./http-BIYwcgTd.js";
6
+ import { validateCryptoKey } from "./key-DBHCloAO.js";
7
+ import { doubleKnock } from "./http-uzkhnm0W.js";
8
+ import { getLogger } from "@logtape/logtape";
8
9
  import { curry } from "es-toolkit";
9
10
  import { UrlError, createActivityPubRequest, getDocumentLoader, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
10
- import { getLogger } from "@logtape/logtape";
11
11
 
12
12
  //#region src/utils/docloader.ts
13
13
  const logger = getLogger([
@@ -3,7 +3,7 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { __commonJS, __toESM } from "./lookup-Bhv7efZB.js";
6
+ import { __commonJS, __toESM } from "./dist-B5f6a8Tt.js";
7
7
 
8
8
  //#region ../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
9
9
  var require_glob_to_regexp = __commonJS({ "../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js"(exports, module) {
@@ -115,7 +115,7 @@ function parse(input, loose) {
115
115
  }
116
116
 
117
117
  //#endregion
118
- //#region ../../node_modules/.pnpm/fetch-mock@12.5.4/node_modules/fetch-mock/dist/esm/TypeDescriptor.js
118
+ //#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/TypeDescriptor.js
119
119
  const valueTypes = new Set([
120
120
  "boolean",
121
121
  "number",
@@ -207,7 +207,7 @@ var TypeDescriptor = class TypeDescriptor {
207
207
  };
208
208
 
209
209
  //#endregion
210
- //#region ../../node_modules/.pnpm/fetch-mock@12.5.4/node_modules/fetch-mock/dist/esm/IsSubsetOf.js
210
+ //#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/IsSubsetOf.js
211
211
  const allowedTypes = new Set([
212
212
  "array",
213
213
  "object",
@@ -366,7 +366,7 @@ function dequal(foo, bar) {
366
366
  }
367
367
 
368
368
  //#endregion
369
- //#region ../../node_modules/.pnpm/fetch-mock@12.5.4/node_modules/fetch-mock/dist/esm/RequestUtils.js
369
+ //#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/RequestUtils.js
370
370
  const absoluteUrlRX = new RegExp("^[a-z]+://|^data:", "i");
371
371
  const protocolRelativeUrlRX = new RegExp("^//", "i");
372
372
  function hasCredentialsInUrl(url) {
@@ -431,6 +431,11 @@ function getPath(url) {
431
431
  const u = absoluteUrlRX.test(url) ? new URL(url) : new URL(url, "http://dummy");
432
432
  return u.pathname;
433
433
  }
434
+ function getHost(url) {
435
+ if (absoluteUrlRX.test(url)) return new URL(url).host;
436
+ else if ("location" in globalThis) return globalThis.location.host;
437
+ return null;
438
+ }
434
439
  function getQuery(url) {
435
440
  const u = absoluteUrlRX.test(url) ? new URL(url) : new URL(url, "http://dummy");
436
441
  return u.search ? u.search.substr(1) : "";
@@ -444,7 +449,7 @@ function normalizeHeaders(headers) {
444
449
  }
445
450
 
446
451
  //#endregion
447
- //#region ../../node_modules/.pnpm/fetch-mock@12.5.4/node_modules/fetch-mock/dist/esm/Matchers.js
452
+ //#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Matchers.js
448
453
  var import_glob_to_regexp = __toESM(require_glob_to_regexp(), 1);
449
454
  const isUrlMatcher = (matcher) => matcher instanceof RegExp || typeof matcher === "string" || typeof matcher === "object" && "href" in matcher;
450
455
  const isFunctionMatcher = (matcher) => typeof matcher === "function";
@@ -475,6 +480,9 @@ const stringMatchers = {
475
480
  const path = getPath(url);
476
481
  return path === targetString || path === dotlessTargetString;
477
482
  };
483
+ },
484
+ host: (targetString) => {
485
+ return ({ url }) => targetString === getHost(url);
478
486
  }
479
487
  };
480
488
  const getHeaderMatcher = ({ headers: expectedHeaders }) => {
@@ -627,7 +635,7 @@ const builtInMatchers = [
627
635
  ];
628
636
 
629
637
  //#endregion
630
- //#region ../../node_modules/.pnpm/fetch-mock@12.5.4/node_modules/fetch-mock/dist/esm/StatusTextMap.js
638
+ //#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/StatusTextMap.js
631
639
  const statusTextMap = {
632
640
  100: "Continue",
633
641
  101: "Switching Protocols",
@@ -695,7 +703,7 @@ const statusTextMap = {
695
703
  var StatusTextMap_default = statusTextMap;
696
704
 
697
705
  //#endregion
698
- //#region ../../node_modules/.pnpm/fetch-mock@12.5.4/node_modules/fetch-mock/dist/esm/Route.js
706
+ //#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Route.js
699
707
  var __classPrivateFieldSet = void 0 && (void 0).__classPrivateFieldSet || function(receiver, state, value, kind, f) {
700
708
  if (kind === "m") throw new TypeError("Private method is not writable");
701
709
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -829,7 +837,7 @@ builtInMatchers.forEach(Route.defineMatcher);
829
837
  var Route_default = Route;
830
838
 
831
839
  //#endregion
832
- //#region ../../node_modules/.pnpm/fetch-mock@12.5.4/node_modules/fetch-mock/dist/esm/Router.js
840
+ //#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Router.js
833
841
  const responseConfigProps = [
834
842
  "body",
835
843
  "headers",
@@ -881,18 +889,23 @@ var Router = class {
881
889
  throwSpecExceptions(callLog);
882
890
  return new Promise(async (resolve, reject) => {
883
891
  const { url, options, request, pendingPromises } = callLog;
892
+ let eventListenerAbortController;
884
893
  if (callLog.signal) {
885
894
  const abort = () => {
886
895
  const error = new DOMException("The operation was aborted.", "AbortError");
887
896
  const requestBody = request?.body || options?.body;
888
- if (requestBody instanceof ReadableStream) if (requestBody.locked) requestBody.getReader().cancel(error);
897
+ if (requestBody instanceof ReadableStream) if (requestBody.locked) console.warn("fetch-mock: Locked request body can't be cancelled");
889
898
  else requestBody.cancel(error);
890
- if (callLog?.response?.body) if (callLog.response.body.locked) callLog.response.body.getReader().cancel(error);
899
+ if (callLog?.response?.body) if (callLog.response.body.locked) console.warn("fetch-mock: Locked response body can't be cancelled");
891
900
  else callLog.response.body.cancel(error);
892
901
  reject(error);
893
902
  };
894
903
  if (callLog.signal.aborted) abort();
895
- callLog.signal.addEventListener("abort", abort);
904
+ eventListenerAbortController = new AbortController();
905
+ callLog.signal.addEventListener("abort", abort, {
906
+ once: true,
907
+ signal: eventListenerAbortController.signal
908
+ });
896
909
  }
897
910
  if (this.needsToReadBody(request)) options.body = await options.body;
898
911
  const routesToTry = this.fallbackRoute ? [...this.routes, this.fallbackRoute] : this.routes;
@@ -905,6 +918,8 @@ var Router = class {
905
918
  resolve(observableResponse);
906
919
  } catch (err) {
907
920
  reject(err);
921
+ } finally {
922
+ eventListenerAbortController?.abort();
908
923
  }
909
924
  else reject(/* @__PURE__ */ new Error(`fetch-mock: No response or fallback rule to cover ${options && options.method || "GET"} to ${url}`));
910
925
  });
@@ -1002,7 +1017,7 @@ var Router = class {
1002
1017
  };
1003
1018
 
1004
1019
  //#endregion
1005
- //#region ../../node_modules/.pnpm/fetch-mock@12.5.4/node_modules/fetch-mock/dist/esm/CallHistory.js
1020
+ //#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/CallHistory.js
1006
1021
  const isName = (filter) => typeof filter === "string" && /^[\da-zA-Z-]+$/.test(filter) && !["matched", "unmatched"].includes(filter);
1007
1022
  const isMatchedOrUnmatched = (filter) => typeof filter === "boolean" || ["matched", "unmatched"].includes(filter);
1008
1023
  var CallHistory = class {
@@ -1032,11 +1047,11 @@ var CallHistory = class {
1032
1047
  let calls = [...this.callLogs];
1033
1048
  if (typeof filter === "undefined" && !options) return calls;
1034
1049
  if (isMatchedOrUnmatched(filter)) {
1035
- if ([true, "matched"].includes(filter)) calls = calls.filter(({ route }) => !route.config.isFallback);
1036
- else if ([false, "unmatched"].includes(filter)) calls = calls.filter(({ route }) => Boolean(route.config.isFallback));
1050
+ if ([true, "matched"].includes(filter)) calls = calls.filter(({ route }) => !route?.config || !route.config.isFallback);
1051
+ else if ([false, "unmatched"].includes(filter)) calls = calls.filter(({ route }) => Boolean(route?.config && route.config.isFallback));
1037
1052
  if (!options) return calls;
1038
1053
  } else if (isName(filter)) {
1039
- calls = calls.filter(({ route: { config: { name } } }) => name === filter);
1054
+ calls = calls.filter(({ route }) => route?.config?.name === filter);
1040
1055
  if (!options) return calls;
1041
1056
  } else if (isUrlMatcher(filter)) options = {
1042
1057
  url: filter,
@@ -1087,7 +1102,7 @@ var CallHistory = class {
1087
1102
  var CallHistory_default = CallHistory;
1088
1103
 
1089
1104
  //#endregion
1090
- //#region ../../node_modules/.pnpm/fetch-mock@12.5.4/node_modules/fetch-mock/dist/esm/FetchMock.js
1105
+ //#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/FetchMock.js
1091
1106
  const defaultFetchMockConfig = {
1092
1107
  includeContentLength: true,
1093
1108
  matchPartialBody: false,
@@ -1220,7 +1235,7 @@ const fetchMock = new FetchMock({ ...defaultFetchMockConfig });
1220
1235
  var FetchMock_default = fetchMock;
1221
1236
 
1222
1237
  //#endregion
1223
- //#region ../../node_modules/.pnpm/fetch-mock@12.5.4/node_modules/fetch-mock/dist/esm/index.js
1238
+ //#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/index.js
1224
1239
  var esm_default = FetchMock_default;
1225
1240
 
1226
1241
  //#endregion
@@ -3,18 +3,20 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Activity, Note, Person } from "../lookup-Bhv7efZB.js";
6
+ import { test } from "../dist-B5f6a8Tt.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
- import { MemoryKvStore } from "../kv-CRZrzyXm.js";
11
- import "../inbox-Dbt8hLxb.js";
12
- import { createFederationBuilder } from "../builder-CLT_zIyw.js";
13
- import { test } from "../testing-CW4N8vgf.js";
10
+ import { MemoryKvStore } from "../kv-QzKcOQgP.js";
11
+ import "../deno-i60L3ZJW.js";
12
+ import "../router-D9eI0s4b.js";
13
+ import "../inbox-CxrUTds4.js";
14
+ import { createFederationBuilder } from "../builder-R1Sfe-tb.js";
14
15
  import { assertExists } from "../std__assert-DWivtrGR.js";
15
16
  import "../assert_rejects-Ce45JcFg.js";
16
17
  import { assertThrows } from "../assert_throws-BNXdRGWP.js";
17
18
  import "../assert_not_equals-C80BG-_5.js";
19
+ import { Activity, Note, Person } from "@fedify/vocab";
18
20
 
19
21
  //#region src/federation/builder.test.ts
20
22
  test("FederationBuilder", async (t) => {
@@ -3,12 +3,11 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import "../lookup-Bhv7efZB.js";
6
+ import { test } from "../dist-B5f6a8Tt.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
- import { buildCollectionSynchronizationHeader, digest } from "../collection-BzWsN9pB.js";
11
- import { test } from "../testing-CW4N8vgf.js";
10
+ import { buildCollectionSynchronizationHeader, digest } from "../collection-CcnIw1qY.js";
12
11
  import "../std__assert-DWivtrGR.js";
13
12
  import "../assert_rejects-Ce45JcFg.js";
14
13
  import "../assert_throws-BNXdRGWP.js";
@@ -3,35 +3,37 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Create, Note, Person } from "../lookup-Bhv7efZB.js";
6
+ import { createTestTracerProvider, mockDocumentLoader, test } from "../dist-B5f6a8Tt.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import { assert } from "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
- import { MemoryKvStore } from "../kv-CRZrzyXm.js";
11
- import { createFederation, handleActor, handleCollection, handleCustomCollection, handleInbox, handleObject, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-Aqt52eK0.js";
12
- import "../client-pY7-3icS.js";
13
- import "../types-C2XVl6gj.js";
14
- import "../actor-CmPnJ0G7.js";
15
- import "../key-BcT6cdMK.js";
16
- import { signRequest } from "../http-BIYwcgTd.js";
17
- import "../ld-DR6mmQjt.js";
18
- import "../owner-DEgLiB7Z.js";
19
- import "../proof-p3cmdfis.js";
20
- import "../docloader-BkhI_RcC.js";
21
- import "../kv-cache-DN9pfMBe.js";
22
- import { InboxListenerSet } from "../inbox-Dbt8hLxb.js";
23
- import "../builder-CLT_zIyw.js";
24
- import "../collection-BzWsN9pB.js";
25
- import "../keycache-B8aIeTgt.js";
26
- import "../negotiation-C4nFufNk.js";
27
- import "../retry-CfF8Gn4d.js";
28
- import "../send-CcKJ-npK.js";
29
- import { createInboxContext, createRequestContext, mockDocumentLoader, test } from "../testing-CW4N8vgf.js";
10
+ import { MemoryKvStore } from "../kv-QzKcOQgP.js";
11
+ import "../deno-i60L3ZJW.js";
12
+ import { createFederation, handleActor, handleCollection, handleCustomCollection, handleInbox, handleObject, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-CxwWsgSo.js";
13
+ import "../client-Dg7OfUDA.js";
14
+ import "../router-D9eI0s4b.js";
15
+ import "../types-CPz01LGH.js";
16
+ import "../key-DBHCloAO.js";
17
+ import { signRequest } from "../http-uzkhnm0W.js";
18
+ import "../ld-CZgNIUGN.js";
19
+ import "../owner-BDvRiO5T.js";
20
+ import "../proof-XEPY5YKg.js";
21
+ import "../docloader-BuOglEYx.js";
22
+ import "../kv-cache-BEeqyGER.js";
23
+ import { InboxListenerSet } from "../inbox-CxrUTds4.js";
24
+ import "../builder-R1Sfe-tb.js";
25
+ import "../collection-CcnIw1qY.js";
26
+ import "../keycache-DRxpZ5r9.js";
27
+ import "../negotiation-5NPJL6zp.js";
28
+ import "../retry-D4GJ670a.js";
29
+ import "../send-BdhhZ2MN.js";
30
30
  import "../std__assert-DWivtrGR.js";
31
31
  import "../assert_rejects-Ce45JcFg.js";
32
32
  import "../assert_throws-BNXdRGWP.js";
33
33
  import "../assert_not_equals-C80BG-_5.js";
34
- import { rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-Bs-0Hapk.js";
34
+ import { createInboxContext, createRequestContext } from "../context-Bns6uTJq.js";
35
+ import { rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-ZbcByPg9.js";
36
+ import { Create, Note, Person } from "@fedify/vocab";
35
37
 
36
38
  //#region src/federation/handler.test.ts
37
39
  test("handleActor()", async () => {
@@ -1481,5 +1483,91 @@ test("handleCustomCollection()", async () => {
1481
1483
  assertEquals(onNotFoundCalled, null);
1482
1484
  assertEquals(onUnauthorizedCalled, null);
1483
1485
  });
1486
+ test("handleInbox() records OpenTelemetry span events", async () => {
1487
+ const [tracerProvider, exporter] = createTestTracerProvider();
1488
+ const kv = new MemoryKvStore();
1489
+ const federation = createFederation({
1490
+ kv,
1491
+ tracerProvider
1492
+ });
1493
+ const activity = new Create({
1494
+ id: new URL("https://example.com/activity"),
1495
+ actor: new URL("https://example.com/users/someone"),
1496
+ object: new Note({
1497
+ id: new URL("https://example.com/note"),
1498
+ content: "Hello, world!"
1499
+ })
1500
+ });
1501
+ const request = new Request("https://example.com/users/someone/inbox", {
1502
+ method: "POST",
1503
+ headers: { "Content-Type": "application/activity+json" },
1504
+ body: JSON.stringify(await activity.toJsonLd())
1505
+ });
1506
+ const signed = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/users/someone#main-key"));
1507
+ const context = createRequestContext({
1508
+ federation,
1509
+ request: signed,
1510
+ url: new URL(signed.url),
1511
+ data: void 0,
1512
+ documentLoader: mockDocumentLoader,
1513
+ contextLoader: mockDocumentLoader,
1514
+ getActorUri(identifier) {
1515
+ return new URL(`https://example.com/users/${identifier}`);
1516
+ }
1517
+ });
1518
+ const actorDispatcher = (ctx, handle) => {
1519
+ if (handle !== "someone") return null;
1520
+ return new Person({
1521
+ id: ctx.getActorUri(handle),
1522
+ name: "Someone",
1523
+ inbox: new URL("https://example.com/users/someone/inbox"),
1524
+ publicKey: rsaPublicKey2
1525
+ });
1526
+ };
1527
+ const listeners = new InboxListenerSet();
1528
+ let receivedActivity = null;
1529
+ listeners.add(Create, (_ctx, activity$1) => {
1530
+ receivedActivity = activity$1;
1531
+ });
1532
+ const response = await handleInbox(signed, {
1533
+ recipient: "someone",
1534
+ context,
1535
+ inboxContextFactory(_activity) {
1536
+ return createInboxContext({
1537
+ ...context,
1538
+ clone: void 0
1539
+ });
1540
+ },
1541
+ kv,
1542
+ kvPrefixes: {
1543
+ activityIdempotence: ["activityIdempotence"],
1544
+ publicKey: ["publicKey"]
1545
+ },
1546
+ actorDispatcher,
1547
+ inboxListeners: listeners,
1548
+ inboxErrorHandler: void 0,
1549
+ onNotFound: (_request) => new Response("Not found", { status: 404 }),
1550
+ signatureTimeWindow: false,
1551
+ skipSignatureVerification: true,
1552
+ tracerProvider
1553
+ });
1554
+ assertEquals(response.status, 202);
1555
+ assert(receivedActivity != null);
1556
+ const spans = exporter.getSpans("activitypub.inbox");
1557
+ assertEquals(spans.length, 1);
1558
+ const span = spans[0];
1559
+ assertEquals(span.attributes["fedify.inbox.recipient"], "someone");
1560
+ assertEquals(span.attributes["activitypub.activity.id"], "https://example.com/activity");
1561
+ const events = exporter.getEvents("activitypub.inbox", "activitypub.activity.received");
1562
+ assertEquals(events.length, 1);
1563
+ const event = events[0];
1564
+ assert(event.attributes != null);
1565
+ assertEquals(event.attributes["activitypub.activity.verified"], true);
1566
+ assertEquals(event.attributes["http_signatures.verified"], false);
1567
+ assert(typeof event.attributes["activitypub.activity.json"] === "string");
1568
+ const recordedActivity = JSON.parse(event.attributes["activitypub.activity.json"]);
1569
+ assertEquals(recordedActivity.id, "https://example.com/activity");
1570
+ assertEquals(recordedActivity.type, "Create");
1571
+ });
1484
1572
 
1485
1573
  //#endregion