@fedify/fedify 1.11.0-dev.92 → 2.0.0-dev.109

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 (276) hide show
  1. package/README.md +34 -20
  2. package/dist/{actor-BSf1RMUB.js → actor-BZTYJWzP.js} +1 -1
  3. package/dist/{actor-B6ovE-4c.js → actor-Cm25mX8I.js} +220 -705
  4. package/dist/{actor-eeONG_sv.d.ts → actor-DqFajh9s.d.ts} +2 -2
  5. package/dist/{actor-DMxe8a2S.cjs → actor-ZEAP42Ry.cjs} +952 -1479
  6. package/dist/{actor-D190nbTD.d.cts → actor-f2NtjyCg.d.cts} +2 -2
  7. package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-Ce45JcFg.js} +1 -1
  8. package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-BNXdRGWP.js} +31 -1
  9. package/dist/{builder-CvMAl7DC.js → builder-CWMz7B2F.js} +3 -4
  10. package/dist/{client-n6L4GtQL.d.cts → client-94iWEfQa.d.cts} +3 -75
  11. package/dist/{client-B3mQJNO7.d.ts → client-BsGzbnV-.d.ts} +3 -75
  12. package/dist/{client-gwmljOpB.js → client-pY7-3icS.js} +3 -22
  13. package/dist/compat/mod.d.cts +10 -12
  14. package/dist/compat/mod.d.ts +10 -12
  15. package/dist/compat/transformers.test.js +20 -20
  16. package/dist/{context-WJoO0SQs.d.cts → context-DBQ7nMCw.d.cts} +152 -27
  17. package/dist/{context-Cr5DIxq_.d.ts → context-mM0Nu5yo.d.ts} +152 -27
  18. package/dist/{authdocloader-D-v1l7De.js → docloader-BeSgUTFj.js} +17 -8
  19. package/dist/{esm-D55VN1Km.js → esm-bEFTDE2Q.js} +32 -17
  20. package/dist/federation/builder.test.js +9 -12
  21. package/dist/federation/collection.test.js +7 -9
  22. package/dist/federation/handler.test.js +28 -149
  23. package/dist/federation/idempotency.test.js +26 -27
  24. package/dist/federation/inbox.test.js +4 -6
  25. package/dist/federation/keycache.test.js +3 -4
  26. package/dist/federation/kv.test.js +6 -8
  27. package/dist/federation/middleware.test.js +270 -93
  28. package/dist/federation/mod.cjs +9 -11
  29. package/dist/federation/mod.d.cts +10 -12
  30. package/dist/federation/mod.d.ts +10 -12
  31. package/dist/federation/mod.js +9 -11
  32. package/dist/federation/mq.test.js +10 -10
  33. package/dist/federation/negotiation.test.js +26 -0
  34. package/dist/federation/retry.test.js +4 -5
  35. package/dist/federation/router.test.js +6 -8
  36. package/dist/federation/send.test.js +14 -16
  37. package/dist/{http-C9J5l76C.js → http-B8aQ8cUK.js} +256 -6
  38. package/dist/{http-C2x6TpEb.js → http-BF8Z1B-J.js} +2 -2
  39. package/dist/{http-DS9z_HzB.d.ts → http-BbO0ejuk.d.ts} +2 -2
  40. package/dist/{http-DOST1wn2.cjs → http-Dy7ENa6t.cjs} +289 -9
  41. package/dist/{http-C_1RU1U_.d.cts → http-M8k5mKc0.d.cts} +2 -2
  42. package/dist/{inbox-CeWZnS6I.js → inbox-CReikedp.js} +2 -7
  43. package/dist/{key-w6smvEIf.js → key-C85if3Ia.js} +3 -2
  44. package/dist/{keycache-DIPsFeDQ.js → keycache-BjRr5pe2.js} +1 -1
  45. package/dist/{keys-Bkp2oOoh.js → keys-do4GUlRT.js} +2 -1
  46. package/dist/{kv-DipCBaw2.d.ts → kv-BpJND1Hr.d.ts} +2 -1
  47. package/dist/{kv-BqEOXcZv.d.cts → kv-cD_d4hg-.d.cts} +2 -1
  48. package/dist/kv-cache-B4Y86MKl.js +122 -0
  49. package/dist/kv-cache-D7LFlByV.js +107 -0
  50. package/dist/kv-cache-qW5Mv9rV.cjs +134 -0
  51. package/dist/{ld-Dk2eojF9.js → ld-0Wpf83DM.js} +3 -2
  52. package/dist/{lookup-BI5Omd9s.cjs → lookup-Br9_ufLS.cjs} +134 -5
  53. package/dist/{lookup-Fk5eyxDk.js → lookup-Cj543vD4.js} +125 -2
  54. package/dist/{type-DMwrwZj3.js → lookup-D6_9czrD.js} +547 -5409
  55. package/dist/middleware-BPmn8w0u.cjs +15 -0
  56. package/dist/middleware-BXodt-Uj.js +26 -0
  57. package/dist/{middleware-BgI9lQ4P.js → middleware-Bq8dxPN6.js} +43 -146
  58. package/dist/{middleware-YNYjpKML.cjs → middleware-CDzg72dQ.cjs} +58 -104
  59. package/dist/middleware-DvA6x8_h.js +15 -0
  60. package/dist/{middleware-CNMzY5iD.js → middleware-hM1Z5nWM.js} +38 -84
  61. package/dist/{mod-DS4kJskR.d.ts → mod-BlVovdcy.d.ts} +2 -2
  62. package/dist/{mod-D5rfgGFE.d.cts → mod-BxRCHTz-.d.cts} +2 -2
  63. package/dist/{mod-CxMBb_dd.d.cts → mod-C58MZ7Wx.d.cts} +1 -1
  64. package/dist/mod-CAdoBu0x.d.ts +109 -0
  65. package/dist/{mod-BZfdiPBo.d.ts → mod-D5Z2tISD.d.ts} +3 -3
  66. package/dist/{mod-Dz5Y15Uy.d.cts → mod-DgxG-byT.d.cts} +3 -3
  67. package/dist/{mod-ChbckRnC.d.ts → mod-Ds0mpFZU.d.ts} +1 -1
  68. package/dist/{mod-OQfb33eH.d.cts → mod-Dy2fJtmN.d.cts} +2 -2
  69. package/dist/{mod-CnULG6Aa.d.ts → mod-GetHzY6F.d.ts} +2 -2
  70. package/dist/mod-fxr25Gv7.d.cts +107 -0
  71. package/dist/mod.cjs +19 -34
  72. package/dist/mod.d.cts +15 -17
  73. package/dist/mod.d.ts +15 -17
  74. package/dist/mod.js +14 -16
  75. package/dist/negotiation-C4nFufNk.js +71 -0
  76. package/dist/nodeinfo/client.test.js +30 -111
  77. package/dist/nodeinfo/handler.test.js +25 -26
  78. package/dist/nodeinfo/mod.cjs +3 -6
  79. package/dist/nodeinfo/mod.d.cts +3 -5
  80. package/dist/nodeinfo/mod.d.ts +3 -5
  81. package/dist/nodeinfo/mod.js +3 -4
  82. package/dist/nodeinfo/types.test.js +8 -15
  83. package/dist/otel/exporter.test.js +44 -70
  84. package/dist/otel/mod.cjs +17 -34
  85. package/dist/otel/mod.d.cts +5 -6
  86. package/dist/otel/mod.d.ts +5 -6
  87. package/dist/otel/mod.js +17 -34
  88. package/dist/{otel-Chy5T2Xh.js → otel-Bfe_BgOV.js} +1 -2
  89. package/dist/{owner-C_e5oYyI.js → owner-B2ziOXAb.js} +3 -2
  90. package/dist/{owner-AcrG3Xz1.d.cts → owner-B4HbyP8s.d.cts} +3 -3
  91. package/dist/{owner-8NMhXwJd.d.ts → owner-kQRGVXG1.d.ts} +3 -3
  92. package/dist/{proof-GRfyDBRU.js → proof-CN_ohUto.js} +2 -2
  93. package/dist/{proof-C5COc2tW.cjs → proof-CWQ0o-yI.cjs} +18 -17
  94. package/dist/{proof-BWebFnAY.js → proof-CXrz_moF.js} +5 -4
  95. package/dist/{send-Dd4ncQqL.js → send-Bt_ukOqY.js} +2 -2
  96. package/dist/sig/http.test.js +12 -13
  97. package/dist/sig/key.test.js +9 -11
  98. package/dist/sig/ld.test.js +8 -10
  99. package/dist/sig/mod.cjs +9 -11
  100. package/dist/sig/mod.d.cts +5 -7
  101. package/dist/sig/mod.d.ts +5 -7
  102. package/dist/sig/mod.js +5 -7
  103. package/dist/sig/owner.test.js +11 -13
  104. package/dist/sig/proof.test.js +13 -14
  105. package/dist/src/vocab/accept.yaml +1 -1
  106. package/dist/src/vocab/activity.yaml +1 -1
  107. package/dist/src/vocab/add.yaml +1 -1
  108. package/dist/src/vocab/announce.yaml +1 -1
  109. package/dist/src/vocab/application.yaml +1 -1
  110. package/dist/src/vocab/arrive.yaml +1 -1
  111. package/dist/src/vocab/article.yaml +1 -1
  112. package/dist/src/vocab/audio.yaml +1 -1
  113. package/dist/src/vocab/block.yaml +1 -1
  114. package/dist/src/vocab/chatmessage.yaml +1 -1
  115. package/dist/src/vocab/collection.yaml +1 -1
  116. package/dist/src/vocab/collectionpage.yaml +1 -1
  117. package/dist/src/vocab/create.yaml +1 -1
  118. package/dist/src/vocab/dataintegrityproof.yaml +1 -1
  119. package/dist/src/vocab/delete.yaml +1 -1
  120. package/dist/src/vocab/didservice.yaml +1 -1
  121. package/dist/src/vocab/dislike.yaml +1 -1
  122. package/dist/src/vocab/document.yaml +1 -1
  123. package/dist/src/vocab/emoji.yaml +1 -1
  124. package/dist/src/vocab/emojireact.yaml +1 -1
  125. package/dist/src/vocab/endpoints.yaml +1 -1
  126. package/dist/src/vocab/event.yaml +1 -1
  127. package/dist/src/vocab/export.yaml +1 -1
  128. package/dist/src/vocab/flag.yaml +1 -1
  129. package/dist/src/vocab/follow.yaml +1 -1
  130. package/dist/src/vocab/group.yaml +1 -1
  131. package/dist/src/vocab/hashtag.yaml +1 -1
  132. package/dist/src/vocab/ignore.yaml +1 -1
  133. package/dist/src/vocab/image.yaml +1 -1
  134. package/dist/src/vocab/intransitiveactivity.yaml +1 -1
  135. package/dist/src/vocab/invite.yaml +1 -1
  136. package/dist/src/vocab/join.yaml +1 -1
  137. package/dist/src/vocab/key.yaml +1 -1
  138. package/dist/src/vocab/leave.yaml +1 -1
  139. package/dist/src/vocab/like.yaml +1 -1
  140. package/dist/src/vocab/link.yaml +1 -1
  141. package/dist/src/vocab/listen.yaml +1 -1
  142. package/dist/src/vocab/mention.yaml +1 -1
  143. package/dist/src/vocab/move.yaml +1 -1
  144. package/dist/src/vocab/multikey.yaml +1 -1
  145. package/dist/src/vocab/note.yaml +1 -1
  146. package/dist/src/vocab/object.yaml +1 -1
  147. package/dist/src/vocab/offer.yaml +1 -1
  148. package/dist/src/vocab/orderedcollection.yaml +1 -1
  149. package/dist/src/vocab/orderedcollectionpage.yaml +1 -1
  150. package/dist/src/vocab/organization.yaml +1 -1
  151. package/dist/src/vocab/page.yaml +1 -1
  152. package/dist/src/vocab/person.yaml +1 -1
  153. package/dist/src/vocab/place.yaml +1 -1
  154. package/dist/src/vocab/profile.yaml +1 -1
  155. package/dist/src/vocab/propertyvalue.yaml +1 -1
  156. package/dist/src/vocab/question.yaml +1 -1
  157. package/dist/src/vocab/read.yaml +1 -1
  158. package/dist/src/vocab/reject.yaml +1 -1
  159. package/dist/src/vocab/relationship.yaml +1 -1
  160. package/dist/src/vocab/remove.yaml +1 -1
  161. package/dist/src/vocab/service.yaml +1 -1
  162. package/dist/src/vocab/source.yaml +1 -1
  163. package/dist/src/vocab/tentativeaccept.yaml +1 -1
  164. package/dist/src/vocab/tentativereject.yaml +1 -1
  165. package/dist/src/vocab/tombstone.yaml +1 -1
  166. package/dist/src/vocab/travel.yaml +1 -1
  167. package/dist/src/vocab/undo.yaml +1 -1
  168. package/dist/src/vocab/update.yaml +1 -1
  169. package/dist/src/vocab/video.yaml +1 -1
  170. package/dist/src/vocab/view.yaml +1 -1
  171. package/dist/testing/docloader.test.js +6 -8
  172. package/dist/testing/mod.d.ts +10 -119
  173. package/dist/testing/mod.js +2 -3
  174. package/dist/{testing-Dl_uo19c.js → testing-DcJ3qTSi.js} +1 -2
  175. package/dist/{types-CPPQlW2w.js → types-BtUjyi5y.js} +5 -166
  176. package/dist/{types-BIgY6c-l.js → types-C2XVl6gj.js} +1 -3
  177. package/dist/{types-tmeoSVgM.cjs → types-CWgzGaqk.cjs} +6 -179
  178. package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +14 -15
  179. package/dist/utils/kv-cache.test.js +212 -0
  180. package/dist/utils/mod.cjs +12 -0
  181. package/dist/utils/mod.d.cts +5 -0
  182. package/dist/utils/mod.d.ts +7 -0
  183. package/dist/utils/mod.js +11 -0
  184. package/dist/vocab/actor.test.js +8 -10
  185. package/dist/vocab/lookup.test.js +8 -10
  186. package/dist/vocab/mod.cjs +3 -4
  187. package/dist/vocab/mod.d.cts +3 -5
  188. package/dist/vocab/mod.d.ts +3 -5
  189. package/dist/vocab/mod.js +3 -4
  190. package/dist/vocab/type.test.js +2 -3
  191. package/dist/vocab/vocab.test.js +7618 -1973
  192. package/dist/{vocab-BASuuzcJ.d.ts → vocab-BCWe1Ih5.d.ts} +9 -25
  193. package/dist/{vocab-DPMmFPJ1.d.cts → vocab-CeDBzu-f.d.cts} +9 -25
  194. package/dist/{vocab-kxSYUP1j.js → vocab-DZvBYZFH.js} +3 -3
  195. package/dist/{vocab-BnNSNBil.cjs → vocab-aeFsUPtk.cjs} +5 -5
  196. package/dist/webfinger/handler.test.js +24 -25
  197. package/dist/webfinger/lookup.test.js +7 -9
  198. package/dist/webfinger/mod.cjs +2 -3
  199. package/dist/webfinger/mod.d.cts +1 -3
  200. package/dist/webfinger/mod.d.ts +1 -3
  201. package/dist/webfinger/mod.js +2 -3
  202. package/package.json +33 -66
  203. package/dist/assert_throws-BOO88avQ.js +0 -39
  204. package/dist/authdocloader-Bn3Jg414.js +0 -52
  205. package/dist/authdocloader-DmTWTYA4.cjs +0 -58
  206. package/dist/denokv-D0nfNQ1x.js +0 -57
  207. package/dist/docloader-BucCRHZI.d.ts +0 -221
  208. package/dist/docloader-CgESja7v.js +0 -4835
  209. package/dist/docloader-ChxNLZAA.d.cts +0 -219
  210. package/dist/docloader-DJCmWQFv.cjs +0 -4901
  211. package/dist/key-BUDjxXee.js +0 -10
  212. package/dist/key-Bl-6W_Cx.cjs +0 -290
  213. package/dist/key-BluX4ryA.js +0 -260
  214. package/dist/key-DWZlSSOl.cjs +0 -10
  215. package/dist/key-zkx54yxw.js +0 -10
  216. package/dist/lookup-DFrFssJ8.js +0 -336
  217. package/dist/middleware-BmGndt7n.cjs +0 -17
  218. package/dist/middleware-CxG8rL1c.js +0 -26
  219. package/dist/middleware-etnOMaDs.js +0 -17
  220. package/dist/mod-CD7gfdq3.d.ts +0 -104
  221. package/dist/mod-JUhOKMHj.d.cts +0 -102
  222. package/dist/mq-B7R1Q-M5.d.cts +0 -140
  223. package/dist/mq-CRGm1e_F.d.ts +0 -143
  224. package/dist/nodeinfo/semver.test.js +0 -143
  225. package/dist/runtime/docloader.test.js +0 -599
  226. package/dist/runtime/key.test.d.ts +0 -3
  227. package/dist/runtime/key.test.js +0 -103
  228. package/dist/runtime/langstr.test.d.ts +0 -3
  229. package/dist/runtime/langstr.test.js +0 -40
  230. package/dist/runtime/link.test.d.ts +0 -3
  231. package/dist/runtime/link.test.js +0 -61
  232. package/dist/runtime/mod.cjs +0 -25
  233. package/dist/runtime/mod.d.cts +0 -6
  234. package/dist/runtime/mod.d.ts +0 -8
  235. package/dist/runtime/mod.js +0 -13
  236. package/dist/runtime/multibase/multibase.test.d.ts +0 -3
  237. package/dist/runtime/multibase/multibase.test.js +0 -358
  238. package/dist/runtime/url.test.d.ts +0 -3
  239. package/dist/runtime/url.test.js +0 -45
  240. package/dist/semver-dArNLkR9.js +0 -149
  241. package/dist/vocab/schema.yaml +0 -247
  242. package/dist/x/cfworkers.cjs +0 -100
  243. package/dist/x/cfworkers.d.cts +0 -59
  244. package/dist/x/cfworkers.d.ts +0 -61
  245. package/dist/x/cfworkers.js +0 -98
  246. package/dist/x/cfworkers.test.d.ts +0 -3
  247. package/dist/x/cfworkers.test.js +0 -179
  248. package/dist/x/hono.cjs +0 -61
  249. package/dist/x/hono.d.cts +0 -54
  250. package/dist/x/hono.d.ts +0 -56
  251. package/dist/x/hono.js +0 -60
  252. package/dist/x/sveltekit.cjs +0 -69
  253. package/dist/x/sveltekit.d.cts +0 -46
  254. package/dist/x/sveltekit.d.ts +0 -48
  255. package/dist/x/sveltekit.js +0 -68
  256. /package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-C80BG-_5.js} +0 -0
  257. /package/dist/{collection-CSzG2j1P.js → collection-BzWsN9pB.js} +0 -0
  258. /package/dist/{nodeinfo/semver.test.d.ts → federation/negotiation.test.d.ts} +0 -0
  259. /package/dist/{federation-C15gGOh1.cjs → federation-CoW-KDKv.cjs} +0 -0
  260. /package/dist/{federation-K-xsO03l.js → federation-D0hkM4T7.js} +0 -0
  261. /package/dist/{mod-C2tOeRkN.d.cts → mod-B-hUPT2N.d.cts} +0 -0
  262. /package/dist/{mod-1pDWKvUL.d.ts → mod-CVgZgliM.d.ts} +0 -0
  263. /package/dist/{mod-FZd39qVq.d.cts → mod-CcDPcLJW.d.cts} +0 -0
  264. /package/dist/{mod-g0xFzAP9.d.ts → mod-bjzj5QIb.d.ts} +0 -0
  265. /package/dist/{nodeinfo-DfycQ8Wf.js → nodeinfo-BnthBobC.js} +0 -0
  266. /package/dist/{nodeinfo-Co9lJrWl.cjs → nodeinfo-CdN0rEnZ.cjs} +0 -0
  267. /package/dist/{retry-D4GJ670a.js → retry-CfF8Gn4d.js} +0 -0
  268. /package/dist/{runtime-DPYEDf-o.js → sig-C34-oHBl.js} +0 -0
  269. /package/dist/{runtime-C58AJWSv.cjs → sig-YYj5tCnr.cjs} +0 -0
  270. /package/dist/{std__assert-X-_kMxKM.js → std__assert-DWivtrGR.js} +0 -0
  271. /package/dist/{runtime → utils}/docloader.test.d.ts +0 -0
  272. /package/dist/{runtime/authdocloader.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
  273. /package/dist/{sig-Cj3tk-ig.js → utils-D-Va7aXC.js} +0 -0
  274. /package/dist/{sig-ByHXzqUi.cjs → utils-DyRU1gdZ.cjs} +0 -0
  275. /package/dist/{webfinger-De_bU0iE.js → webfinger-C72Y8lrh.js} +0 -0
  276. /package/dist/{webfinger-BjOEdFPs.cjs → webfinger-vAtLmxOF.cjs} +0 -0
@@ -1,599 +0,0 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
- globalThis.addEventListener = () => {};
5
-
6
- import { FetchError, UrlError, contexts_default, deno_default, getDocumentLoader, getUserAgent, kvCache } from "../type-DMwrwZj3.js";
7
- import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
- import { assert } from "../assert-MZs1qjMx.js";
9
- import "../assert_instance_of-DHz7EHNU.js";
10
- import { MemoryKvStore } from "../kv-QzKcOQgP.js";
11
- import "../lookup-DFrFssJ8.js";
12
- import { mockDocumentLoader, test } from "../testing-Dl_uo19c.js";
13
- import "../std__assert-X-_kMxKM.js";
14
- import { assertRejects } from "../assert_rejects-DiIiJbZn.js";
15
- import "../assert_is_error-BPGph1Jx.js";
16
- import "../assert_not_equals-f3m3epl3.js";
17
- import { assertThrows } from "../assert_throws-BOO88avQ.js";
18
- import { createTestTracerProvider } from "../otel-Chy5T2Xh.js";
19
- import { esm_default } from "../esm-D55VN1Km.js";
20
- import process from "node:process";
21
-
22
- //#region src/runtime/docloader.test.ts
23
- test("new FetchError()", () => {
24
- const e = new FetchError("https://example.com/", "An error message.");
25
- assertEquals(e.name, "FetchError");
26
- assertEquals(e.url, new URL("https://example.com/"));
27
- assertEquals(e.message, "https://example.com/: An error message.");
28
- const e2 = new FetchError(new URL("https://example.org/"));
29
- assertEquals(e2.url, new URL("https://example.org/"));
30
- assertEquals(e2.message, "https://example.org/");
31
- });
32
- test("getDocumentLoader()", async (t) => {
33
- const fetchDocumentLoader = getDocumentLoader();
34
- esm_default.spyGlobal();
35
- esm_default.get("https://example.com/object", { body: {
36
- "@context": "https://www.w3.org/ns/activitystreams",
37
- id: "https://example.com/object",
38
- name: "Fetched object",
39
- type: "Object"
40
- } });
41
- await t.step("ok", async () => {
42
- assertEquals(await fetchDocumentLoader("https://example.com/object"), {
43
- contextUrl: null,
44
- documentUrl: "https://example.com/object",
45
- document: {
46
- "@context": "https://www.w3.org/ns/activitystreams",
47
- id: "https://example.com/object",
48
- name: "Fetched object",
49
- type: "Object"
50
- }
51
- });
52
- });
53
- esm_default.get("https://example.com/link-ctx", {
54
- body: {
55
- id: "https://example.com/link-ctx",
56
- name: "Fetched object",
57
- type: "Object"
58
- },
59
- headers: {
60
- "Content-Type": "application/activity+json",
61
- Link: "<https://www.w3.org/ns/activitystreams>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\""
62
- }
63
- });
64
- esm_default.get("https://example.com/link-obj", { headers: {
65
- "Content-Type": "text/html; charset=utf-8",
66
- Link: "<https://example.com/object>; rel=\"alternate\"; type=\"application/activity+json\""
67
- } });
68
- esm_default.get("https://example.com/link-obj-relative", { headers: {
69
- "Content-Type": "text/html; charset=utf-8",
70
- Link: "</object>; rel=\"alternate\"; type=\"application/activity+json\""
71
- } });
72
- esm_default.get("https://example.com/obj-w-wrong-link", {
73
- body: {
74
- "@context": "https://www.w3.org/ns/activitystreams",
75
- id: "https://example.com/obj-w-wrong-link",
76
- name: "Fetched object",
77
- type: "Object"
78
- },
79
- headers: {
80
- "Content-Type": "text/html; charset=utf-8",
81
- Link: "<https://example.com/object>; rel=\"alternate\"; type=\"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"\""
82
- }
83
- });
84
- await t.step("Link header", async () => {
85
- assertEquals(await fetchDocumentLoader("https://example.com/link-ctx"), {
86
- contextUrl: "https://www.w3.org/ns/activitystreams",
87
- documentUrl: "https://example.com/link-ctx",
88
- document: {
89
- id: "https://example.com/link-ctx",
90
- name: "Fetched object",
91
- type: "Object"
92
- }
93
- });
94
- assertEquals(await fetchDocumentLoader("https://example.com/link-obj"), {
95
- contextUrl: null,
96
- documentUrl: "https://example.com/object",
97
- document: {
98
- "@context": "https://www.w3.org/ns/activitystreams",
99
- id: "https://example.com/object",
100
- name: "Fetched object",
101
- type: "Object"
102
- }
103
- });
104
- });
105
- await t.step("Link header relative url", async () => {
106
- assertEquals(await fetchDocumentLoader("https://example.com/link-ctx"), {
107
- contextUrl: "https://www.w3.org/ns/activitystreams",
108
- documentUrl: "https://example.com/link-ctx",
109
- document: {
110
- id: "https://example.com/link-ctx",
111
- name: "Fetched object",
112
- type: "Object"
113
- }
114
- });
115
- assertEquals(await fetchDocumentLoader("https://example.com/link-obj-relative"), {
116
- contextUrl: null,
117
- documentUrl: "https://example.com/object",
118
- document: {
119
- "@context": "https://www.w3.org/ns/activitystreams",
120
- id: "https://example.com/object",
121
- name: "Fetched object",
122
- type: "Object"
123
- }
124
- });
125
- });
126
- await t.step("wrong Link header syntax", async () => {
127
- assertEquals(await fetchDocumentLoader("https://example.com/obj-w-wrong-link"), {
128
- contextUrl: null,
129
- documentUrl: "https://example.com/obj-w-wrong-link",
130
- document: {
131
- "@context": "https://www.w3.org/ns/activitystreams",
132
- id: "https://example.com/obj-w-wrong-link",
133
- name: "Fetched object",
134
- type: "Object"
135
- }
136
- });
137
- });
138
- esm_default.get("https://example.com/html-link", {
139
- body: `<html>
140
- <head>
141
- <meta charset=utf-8>
142
- <link
143
- rel=alternate
144
- type='application/activity+json'
145
- href="https://example.com/object">
146
- </head>
147
- </html>`,
148
- headers: { "Content-Type": "text/html; charset=utf-8" }
149
- });
150
- await t.step("HTML <link>", async () => {
151
- assertEquals(await fetchDocumentLoader("https://example.com/html-link"), {
152
- contextUrl: null,
153
- documentUrl: "https://example.com/object",
154
- document: {
155
- "@context": "https://www.w3.org/ns/activitystreams",
156
- id: "https://example.com/object",
157
- name: "Fetched object",
158
- type: "Object"
159
- }
160
- });
161
- });
162
- esm_default.get("https://example.com/xhtml-link", {
163
- body: `<html>
164
- <head>
165
- <meta charset="utf-8" />
166
- <link
167
- rel=alternate
168
- type="application/activity+json"
169
- href="https://example.com/object" />
170
- </head>
171
- </html>`,
172
- headers: { "Content-Type": "application/xhtml+xml; charset=utf-8" }
173
- });
174
- await t.step("XHTML <link>", async () => {
175
- assertEquals(await fetchDocumentLoader("https://example.com/xhtml-link"), {
176
- contextUrl: null,
177
- documentUrl: "https://example.com/object",
178
- document: {
179
- "@context": "https://www.w3.org/ns/activitystreams",
180
- id: "https://example.com/object",
181
- name: "Fetched object",
182
- type: "Object"
183
- }
184
- });
185
- });
186
- esm_default.get("https://example.com/html-a", {
187
- body: `<html>
188
- <head>
189
- <meta charset=utf-8>
190
- </head>
191
- <body>
192
- <a
193
- rel=alternate
194
- type=application/activity+json
195
- href=https://example.com/object>test</a>
196
- </body>
197
- </html>`,
198
- headers: { "Content-Type": "text/html; charset=utf-8" }
199
- });
200
- await t.step("HTML <a>", async () => {
201
- assertEquals(await fetchDocumentLoader("https://example.com/html-a"), {
202
- contextUrl: null,
203
- documentUrl: "https://example.com/object",
204
- document: {
205
- "@context": "https://www.w3.org/ns/activitystreams",
206
- id: "https://example.com/object",
207
- name: "Fetched object",
208
- type: "Object"
209
- }
210
- });
211
- });
212
- esm_default.get("https://example.com/wrong-content-type", {
213
- body: {
214
- "@context": "https://www.w3.org/ns/activitystreams",
215
- id: "https://example.com/wrong-content-type",
216
- name: "Fetched object",
217
- type: "Object"
218
- },
219
- headers: { "Content-Type": "text/html; charset=utf-8" }
220
- });
221
- await t.step("Wrong Content-Type", async () => {
222
- assertEquals(await fetchDocumentLoader("https://example.com/wrong-content-type"), {
223
- contextUrl: null,
224
- documentUrl: "https://example.com/wrong-content-type",
225
- document: {
226
- "@context": "https://www.w3.org/ns/activitystreams",
227
- id: "https://example.com/wrong-content-type",
228
- name: "Fetched object",
229
- type: "Object"
230
- }
231
- });
232
- });
233
- esm_default.get("https://example.com/404", { status: 404 });
234
- await t.step("not ok", async () => {
235
- await assertRejects(() => fetchDocumentLoader("https://example.com/404"), FetchError, "HTTP 404: https://example.com/404");
236
- });
237
- await t.step("preloaded contexts", async () => {
238
- for (const [url, document] of Object.entries(contexts_default)) assertEquals(await fetchDocumentLoader(url), {
239
- contextUrl: null,
240
- documentUrl: url,
241
- document
242
- });
243
- });
244
- await t.step("deny non-HTTP/HTTPS", async () => {
245
- await assertRejects(() => fetchDocumentLoader("ftp://localhost"), UrlError);
246
- });
247
- esm_default.get("https://example.com/localhost-redirect", {
248
- status: 302,
249
- headers: { Location: "https://localhost/object" }
250
- });
251
- esm_default.get("https://example.com/localhost-link", {
252
- body: `<html>
253
- <head>
254
- <meta charset=utf-8>
255
- <link
256
- rel=alternate
257
- type='application/activity+json'
258
- href="https://localhost/object">
259
- </head>
260
- </html>`,
261
- headers: { "Content-Type": "text/html; charset=utf-8" }
262
- });
263
- esm_default.get("https://localhost/object", { body: {
264
- "@context": "https://www.w3.org/ns/activitystreams",
265
- id: "https://localhost/object",
266
- name: "Fetched object",
267
- type: "Object"
268
- } });
269
- await t.step("allowPrivateAddress: false", async () => {
270
- await assertRejects(() => fetchDocumentLoader("https://localhost/object"), UrlError);
271
- await assertRejects(() => fetchDocumentLoader("https://example.com/localhost-redirect"), UrlError);
272
- await assertRejects(() => fetchDocumentLoader("https://example.com/localhost-link"), UrlError);
273
- });
274
- const fetchDocumentLoader2 = getDocumentLoader({ allowPrivateAddress: true });
275
- await t.step("allowPrivateAddress: true", async () => {
276
- const expected = {
277
- contextUrl: null,
278
- documentUrl: "https://localhost/object",
279
- document: {
280
- "@context": "https://www.w3.org/ns/activitystreams",
281
- id: "https://localhost/object",
282
- name: "Fetched object",
283
- type: "Object"
284
- }
285
- };
286
- assertEquals(await fetchDocumentLoader2("https://localhost/object"), expected);
287
- assertEquals(await fetchDocumentLoader2("https://example.com/localhost-redirect"), expected);
288
- assertEquals(await fetchDocumentLoader2("https://example.com/localhost-link"), expected);
289
- });
290
- const maliciousPayload = "<a" + " a=\"b\"".repeat(30) + " ";
291
- esm_default.get("https://example.com/redos", {
292
- body: maliciousPayload,
293
- headers: { "Content-Type": "text/html; charset=utf-8" }
294
- });
295
- await t.step("ReDoS resistance (CVE-2025-68475)", async () => {
296
- const start = performance.now();
297
- await assertRejects(() => fetchDocumentLoader("https://example.com/redos"), SyntaxError);
298
- const elapsed = performance.now() - start;
299
- assert(elapsed < 1e3, `Potential ReDoS vulnerability detected: ${elapsed}ms (expected < 1000ms)`);
300
- });
301
- esm_default.hardReset();
302
- });
303
- test("kvCache()", async (t) => {
304
- const kv = new MemoryKvStore();
305
- await t.step("cached", async () => {
306
- const loader = kvCache({
307
- kv,
308
- loader: mockDocumentLoader,
309
- rules: [
310
- ["https://example.org/", Temporal.Duration.from({ days: 1 })],
311
- [new URL("https://example.net/"), Temporal.Duration.from({ days: 1 })],
312
- [new URLPattern("https://example.com/*"), Temporal.Duration.from({ days: 30 })]
313
- ],
314
- prefix: ["_test", "cached"]
315
- });
316
- const result = await loader("https://example.com/object");
317
- assertEquals(result, {
318
- contextUrl: null,
319
- documentUrl: "https://example.com/object",
320
- document: {
321
- "@context": "https://www.w3.org/ns/activitystreams",
322
- id: "https://example.com/object",
323
- name: "Fetched object",
324
- type: "Object"
325
- }
326
- });
327
- const cache = await kv.get([
328
- "_test",
329
- "cached",
330
- "https://example.com/object"
331
- ]);
332
- assertEquals(cache, result);
333
- await kv.set([
334
- "_test",
335
- "cached",
336
- "https://example.org/"
337
- ], {
338
- contextUrl: null,
339
- documentUrl: "https://example.org/",
340
- document: { "id": "https://example.org/" }
341
- });
342
- const result2 = await loader("https://example.org/");
343
- assertEquals(result2, {
344
- contextUrl: null,
345
- documentUrl: "https://example.org/",
346
- document: { "id": "https://example.org/" }
347
- });
348
- await kv.set([
349
- "_test",
350
- "cached",
351
- "https://example.net/"
352
- ], {
353
- contextUrl: null,
354
- documentUrl: "https://example.net/",
355
- document: { "id": "https://example.net/" }
356
- });
357
- const result3 = await loader("https://example.net/");
358
- assertEquals(result3, {
359
- contextUrl: null,
360
- documentUrl: "https://example.net/",
361
- document: { "id": "https://example.net/" }
362
- });
363
- });
364
- await t.step("not cached", async () => {
365
- const loader = kvCache({
366
- kv,
367
- loader: mockDocumentLoader,
368
- rules: [],
369
- prefix: ["_test", "not cached"]
370
- });
371
- const result = await loader("https://example.com/object");
372
- assertEquals(result, {
373
- contextUrl: null,
374
- documentUrl: "https://example.com/object",
375
- document: {
376
- "@context": "https://www.w3.org/ns/activitystreams",
377
- id: "https://example.com/object",
378
- name: "Fetched object",
379
- type: "Object"
380
- }
381
- });
382
- const cache = await kv.get([
383
- "test2",
384
- "not cached",
385
- "https://example.com/object"
386
- ]);
387
- assertEquals(cache, void 0);
388
- });
389
- await t.step("maximum cache duration", () => {
390
- assertThrows(() => kvCache({
391
- kv,
392
- loader: mockDocumentLoader,
393
- rules: [["https://example.com/", Temporal.Duration.from({
394
- days: 30,
395
- seconds: 1
396
- })]]
397
- }), TypeError, "The maximum cache duration is 30 days");
398
- assertThrows(() => kvCache({
399
- kv,
400
- loader: mockDocumentLoader,
401
- rules: [[new URLPattern("https://example.com/*"), Temporal.Duration.from({
402
- days: 30,
403
- seconds: 1
404
- })]]
405
- }), TypeError, "The maximum cache duration is 30 days");
406
- });
407
- await t.step("on kv store exception", async () => {
408
- class KvStoreThrowsException {
409
- get(_key) {
410
- throw new Error("Failed to get key");
411
- }
412
- set(_key, _value, _options) {
413
- throw new Error("Failed to set key");
414
- }
415
- delete(_key) {
416
- throw new Error("Failed to delete key");
417
- }
418
- }
419
- const loader = kvCache({
420
- kv: new KvStoreThrowsException(),
421
- loader: mockDocumentLoader,
422
- rules: [
423
- ["https://example.org/", Temporal.Duration.from({ days: 1 })],
424
- [new URL("https://example.net/"), Temporal.Duration.from({ days: 1 })],
425
- [new URLPattern("https://example.com/*"), Temporal.Duration.from({ days: 30 })]
426
- ],
427
- prefix: ["_test", "not cached"]
428
- });
429
- const result = await loader("https://example.com/object");
430
- assertEquals(result, {
431
- contextUrl: null,
432
- documentUrl: "https://example.com/object",
433
- document: {
434
- "@context": "https://www.w3.org/ns/activitystreams",
435
- id: "https://example.com/object",
436
- name: "Fetched object",
437
- type: "Object"
438
- }
439
- });
440
- });
441
- await t.step("preloaded contexts bypass cache", async () => {
442
- const kv$1 = new MemoryKvStore();
443
- let loaderCalled = false;
444
- const mockLoader = (url) => {
445
- loaderCalled = true;
446
- return Promise.resolve({
447
- contextUrl: null,
448
- documentUrl: url,
449
- document: { "mock": "document" }
450
- });
451
- };
452
- const loader = kvCache({
453
- kv: kv$1,
454
- loader: mockLoader,
455
- prefix: ["_test", "preloaded"]
456
- });
457
- const activityStreamsUrl = "https://www.w3.org/ns/activitystreams";
458
- loaderCalled = false;
459
- const result = await loader(activityStreamsUrl);
460
- assertEquals(result, {
461
- contextUrl: null,
462
- documentUrl: activityStreamsUrl,
463
- document: contexts_default[activityStreamsUrl]
464
- });
465
- assertEquals(loaderCalled, false, "Loader should not be called for preloaded contexts");
466
- const cachedValue = await kv$1.get([
467
- "_test",
468
- "preloaded",
469
- activityStreamsUrl
470
- ]);
471
- assertEquals(cachedValue, void 0, "Preloaded contexts should not be cached in KV store");
472
- const securityUrl = "https://w3id.org/security/v1";
473
- loaderCalled = false;
474
- const result2 = await loader(securityUrl);
475
- assertEquals(result2, {
476
- contextUrl: null,
477
- documentUrl: securityUrl,
478
- document: contexts_default[securityUrl]
479
- });
480
- assertEquals(loaderCalled, false, "Loader should not be called for preloaded contexts");
481
- const nonPreloadedUrl = "https://example.com/not-preloaded";
482
- loaderCalled = false;
483
- const result3 = await loader(nonPreloadedUrl);
484
- assertEquals(result3, {
485
- contextUrl: null,
486
- documentUrl: nonPreloadedUrl,
487
- document: { "mock": "document" }
488
- });
489
- assertEquals(loaderCalled, true, "Loader should be called for non-preloaded URLs");
490
- const cachedValue2 = await kv$1.get([
491
- "_test",
492
- "preloaded",
493
- nonPreloadedUrl
494
- ]);
495
- assertEquals(cachedValue2, result3, "Non-preloaded URLs should be cached");
496
- });
497
- });
498
- test("getUserAgent()", () => {
499
- if ("Deno" in globalThis) {
500
- assertEquals(getUserAgent(), `Fedify/${deno_default.version} (Deno/${Deno.version.deno})`);
501
- assertEquals(getUserAgent({ software: "MyApp/1.0.0" }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Deno/${Deno.version.deno})`);
502
- assertEquals(getUserAgent({ url: "https://example.com/" }), `Fedify/${deno_default.version} (Deno/${Deno.version.deno}; +https://example.com/)`);
503
- assertEquals(getUserAgent({
504
- software: "MyApp/1.0.0",
505
- url: new URL("https://example.com/")
506
- }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Deno/${Deno.version.deno}; +https://example.com/)`);
507
- } else if ("Bun" in globalThis) {
508
- assertEquals(getUserAgent(), `Fedify/${deno_default.version} (Bun/${Bun.version})`);
509
- assertEquals(getUserAgent({ software: "MyApp/1.0.0" }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Bun/${Bun.version})`);
510
- assertEquals(getUserAgent({ url: "https://example.com/" }), `Fedify/${deno_default.version} (Bun/${Bun.version}; +https://example.com/)`);
511
- assertEquals(getUserAgent({
512
- software: "MyApp/1.0.0",
513
- url: new URL("https://example.com/")
514
- }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Bun/${Bun.version}; +https://example.com/)`);
515
- } else if (navigator.userAgent === "Cloudflare-Workers") {
516
- assertEquals(getUserAgent(), `Fedify/${deno_default.version} (Cloudflare-Workers)`);
517
- assertEquals(getUserAgent({ software: "MyApp/1.0.0" }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Cloudflare-Workers)`);
518
- assertEquals(getUserAgent({ url: "https://example.com/" }), `Fedify/${deno_default.version} (Cloudflare-Workers; +https://example.com/)`);
519
- assertEquals(getUserAgent({
520
- software: "MyApp/1.0.0",
521
- url: new URL("https://example.com/")
522
- }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Cloudflare-Workers; +https://example.com/)`);
523
- } else {
524
- assertEquals(getUserAgent(), `Fedify/${deno_default.version} (Node.js/${process.versions.node})`);
525
- assertEquals(getUserAgent({ software: "MyApp/1.0.0" }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Node.js/${process.versions.node})`);
526
- assertEquals(getUserAgent({ url: "https://example.com/" }), `Fedify/${deno_default.version} (Node.js/${process.versions.node}; +https://example.com/)`);
527
- assertEquals(getUserAgent({
528
- software: "MyApp/1.0.0",
529
- url: new URL("https://example.com/")
530
- }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Node.js/${process.versions.node}; +https://example.com/)`);
531
- }
532
- });
533
- test("getDocumentLoader() records OpenTelemetry span", async (t) => {
534
- const [tracerProvider, exporter] = createTestTracerProvider();
535
- esm_default.spyGlobal();
536
- await t.step("successful fetch", async () => {
537
- esm_default.get("https://example.com/doc", {
538
- status: 200,
539
- headers: { "Content-Type": "application/activity+json" },
540
- body: JSON.stringify({
541
- "@context": "https://www.w3.org/ns/activitystreams",
542
- type: "Note"
543
- })
544
- });
545
- const loader = getDocumentLoader();
546
- const { trace } = await import("@opentelemetry/api");
547
- const originalProvider = trace.getTracerProvider();
548
- trace.setGlobalTracerProvider(tracerProvider);
549
- try {
550
- const result = await loader("https://example.com/doc");
551
- assertEquals(result.documentUrl, "https://example.com/doc");
552
- const spans = exporter.getSpans("activitypub.fetch_document");
553
- assertEquals(spans.length, 1);
554
- const span = spans[0];
555
- assertEquals(span.attributes["url.full"], "https://example.com/doc");
556
- assertEquals(span.attributes["http.response.status_code"], 200);
557
- assertEquals(span.attributes["docloader.document_url"], "https://example.com/doc");
558
- } finally {
559
- trace.setGlobalTracerProvider(originalProvider);
560
- exporter.clear();
561
- esm_default.hardReset();
562
- }
563
- });
564
- await t.step("redirect", async () => {
565
- esm_default.spyGlobal();
566
- esm_default.get("https://example.com/doc", {
567
- status: 302,
568
- headers: { "Location": "https://example.com/new-doc" }
569
- });
570
- esm_default.get("https://example.com/new-doc", {
571
- status: 200,
572
- headers: { "Content-Type": "application/activity+json" },
573
- body: JSON.stringify({
574
- "@context": "https://www.w3.org/ns/activitystreams",
575
- type: "Note"
576
- })
577
- });
578
- const loader = getDocumentLoader();
579
- const { trace } = await import("@opentelemetry/api");
580
- const originalProvider = trace.getTracerProvider();
581
- trace.setGlobalTracerProvider(tracerProvider);
582
- try {
583
- const result = await loader("https://example.com/doc");
584
- assertEquals(result.documentUrl, "https://example.com/new-doc");
585
- const spans = exporter.getSpans("activitypub.fetch_document");
586
- assertEquals(spans.length, 2);
587
- const redirectSpan = spans[spans.length - 1];
588
- assertEquals(redirectSpan.attributes["url.full"], "https://example.com/doc");
589
- assertEquals(redirectSpan.attributes["http.response.status_code"], 302);
590
- assertEquals(redirectSpan.attributes["http.redirect.url"], "https://example.com/new-doc");
591
- } finally {
592
- trace.setGlobalTracerProvider(originalProvider);
593
- exporter.clear();
594
- esm_default.hardReset();
595
- }
596
- });
597
- });
598
-
599
- //#endregion
@@ -1,3 +0,0 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};