@fedify/fedify 2.0.0-dev.1604 → 2.0.0-dev.161

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 (292) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +66 -30
  3. package/dist/{assert_rejects-7UF4R_Qs.js → assert_rejects-Ce45JcFg.js} +1 -1
  4. package/dist/{assert_is_error-B035L3om.js → assert_throws-BNXdRGWP.js} +31 -1
  5. package/dist/{builder-D9zidAqR.js → builder-CulJ6Oa9.js} +15 -8
  6. package/dist/chunk-DqRYRqnO.cjs +34 -0
  7. package/dist/client-94iWEfQa.d.cts +222 -0
  8. package/dist/{client-bgSdkFa2.d.ts → client-BivSNrEg.d.ts} +1 -1
  9. package/dist/{client-Bsj0vQPr.js → client-CgMTXmAD.js} +1 -1
  10. package/dist/compat/mod.cjs +10 -0
  11. package/dist/compat/mod.d.cts +7 -0
  12. package/dist/compat/mod.d.ts +6 -12
  13. package/dist/compat/mod.js +5 -5
  14. package/dist/compat/transformers.test.js +21 -19
  15. package/dist/compat-DmDDELst.cjs +4 -0
  16. package/dist/compat-nxUqe4Z-.js +4 -0
  17. package/dist/context-Bns6uTJq.js +109 -0
  18. package/dist/{context-CDSZdQHD.d.ts → context-CYZ2i00R.d.ts} +321 -129
  19. package/dist/context-D2MrtLch.d.cts +2447 -0
  20. package/dist/deno-DIwNGswC.js +117 -0
  21. package/dist/{testing-CdBSI4xF.js → dist-B5f6a8Tt.js} +90 -111
  22. package/dist/{authdocloader-CzpPQC01.js → docloader-D2992pGD.js} +17 -8
  23. package/dist/{esm-CXF1VoeR.js → esm-DGl7uK1r.js} +32 -17
  24. package/dist/federation/builder.test.js +9 -9
  25. package/dist/federation/collection.test.js +3 -6
  26. package/dist/federation/handler.test.js +113 -145
  27. package/dist/federation/idempotency.test.js +202 -0
  28. package/dist/federation/inbox.test.js +5 -6
  29. package/dist/federation/keycache.test.js +4 -5
  30. package/dist/federation/kv.test.js +59 -7
  31. package/dist/federation/middleware.test.js +306 -111
  32. package/dist/federation/mod.cjs +25 -0
  33. package/dist/federation/mod.d.cts +7 -0
  34. package/dist/federation/mod.d.ts +7 -13
  35. package/dist/federation/mod.js +11 -16
  36. package/dist/federation/mq.test.js +7 -8
  37. package/dist/federation/negotiation.test.js +25 -0
  38. package/dist/federation/retry.test.js +2 -4
  39. package/dist/federation/router.test.js +4 -6
  40. package/dist/federation/send.test.js +53 -13
  41. package/dist/{webfinger/handler.test.js → federation/webfinger.test.js} +25 -23
  42. package/dist/federation-B431K2gm.cjs +266 -0
  43. package/dist/{federation-CMX7WzeL.js → federation-BbZwNNWj.js} +31 -9
  44. package/dist/{http-B_pxY5of.js → http-3fEbsHa0.js} +374 -14
  45. package/dist/{http-CSYNybkH.js → http-BV9SKFK0.js} +3 -2
  46. package/dist/http-C06iL_Qv.cjs +1222 -0
  47. package/dist/http-ClB3pLcL.d.cts +253 -0
  48. package/dist/{http-DqSNLFNY.d.ts → http-DLBDPal9.d.ts} +2 -2
  49. package/dist/{inbox-DoJlwIE4.js → inbox-DCV2fS3F.js} +25 -7
  50. package/dist/{key-BOzqiGbl.js → key-Bdc11xlQ.js} +3 -2
  51. package/dist/{keycache--NYDYifd.js → keycache-DRxpZ5r9.js} +1 -1
  52. package/dist/{keys-MacD9GP6.js → keys-ZbcByPg9.js} +2 -1
  53. package/dist/{kv-C7sopW2E.d.ts → kv-CtOmTRNc.d.ts} +30 -1
  54. package/dist/kv-D8q9fLkA.d.cts +110 -0
  55. package/dist/{kv-CRZrzyXm.js → kv-QzKcOQgP.js} +22 -0
  56. package/dist/kv-cache-B4-ASVht.js +122 -0
  57. package/dist/kv-cache-BEeqyGER.js +107 -0
  58. package/dist/kv-cache-CQjPwWHu.cjs +134 -0
  59. package/dist/{ld-D9oTBLrs.js → ld-C7be04RF.js} +4 -2
  60. package/dist/middleware-9RlUwILK.js +12 -0
  61. package/dist/middleware-B_mOdzoC.cjs +4242 -0
  62. package/dist/{middleware-CgNm3XOJ.js → middleware-C3xnTI2Z.js} +230 -327
  63. package/dist/{middleware-C0w2M0tb.js → middleware-C4_a2DNI.js} +272 -271
  64. package/dist/middleware-C9iGBAP1.cjs +12 -0
  65. package/dist/middleware-CYlahvpt.js +26 -0
  66. package/dist/mod-BrS8tiad.d.cts +266 -0
  67. package/dist/mod-C81L6_lQ.d.cts +1 -0
  68. package/dist/mod-CJgbdSqb.d.ts +109 -0
  69. package/dist/mod-CNNTHyBC.d.cts +80 -0
  70. package/dist/mod-CS-MS7gZ.d.cts +62 -0
  71. package/dist/{mod-RI3-KvUI.d.ts → mod-D_cmv2il.d.ts} +4 -4
  72. package/dist/mod-DcPRcifg.d.cts +107 -0
  73. package/dist/mod-DqFSzJA0.d.ts +64 -0
  74. package/dist/{mod-Drmz72EK.d.ts → mod-jOa7W503.d.ts} +3 -3
  75. package/dist/mod.cjs +55 -0
  76. package/dist/mod.d.cts +11 -0
  77. package/dist/mod.d.ts +11 -17
  78. package/dist/mod.js +15 -21
  79. package/dist/negotiation-5NPJL6zp.js +71 -0
  80. package/dist/nodeinfo/client.test.js +5 -8
  81. package/dist/nodeinfo/handler.test.js +23 -22
  82. package/dist/nodeinfo/mod.cjs +10 -0
  83. package/dist/nodeinfo/mod.d.cts +3 -0
  84. package/dist/nodeinfo/mod.d.ts +2 -4
  85. package/dist/nodeinfo/mod.js +5 -6
  86. package/dist/nodeinfo/types.test.js +4 -7
  87. package/dist/nodeinfo-BlLsRSiT.js +4 -0
  88. package/dist/nodeinfo-DuMYTpbZ.cjs +4 -0
  89. package/dist/otel/exporter.test.js +899 -0
  90. package/dist/otel/mod.cjs +262 -0
  91. package/dist/otel/mod.d.cts +230 -0
  92. package/dist/otel/mod.d.ts +232 -0
  93. package/dist/otel/mod.js +261 -0
  94. package/dist/{owner-CQPnQVtf.d.ts → owner-BgI8C-VY.d.ts} +2 -3
  95. package/dist/{owner-gB-pDKA-.js → owner-Bs5Y5twE.js} +45 -8
  96. package/dist/owner-C-zfmVAD.d.cts +66 -0
  97. package/dist/{proof-VPikK_0V.js → proof-C-751PeN.js} +50 -14
  98. package/dist/{proof-CScVkkIT.js → proof-CFwktc0B.js} +3 -2
  99. package/dist/proof-CaA7ysDp.cjs +709 -0
  100. package/dist/router-D9eI0s4b.js +118 -0
  101. package/dist/{send-flZ7H10-.js → send-C288Vw8b.js} +9 -4
  102. package/dist/sig/http.test.js +9 -11
  103. package/dist/sig/key.test.js +7 -9
  104. package/dist/sig/ld.test.js +8 -10
  105. package/dist/sig/mod.cjs +26 -0
  106. package/dist/sig/mod.d.cts +4 -0
  107. package/dist/sig/mod.d.ts +3 -7
  108. package/dist/sig/mod.js +6 -10
  109. package/dist/sig/owner.test.js +31 -10
  110. package/dist/sig/proof.test.js +11 -12
  111. package/dist/sig-CwuONEzF.js +4 -0
  112. package/dist/sig-DeXX2xnj.cjs +4 -0
  113. package/dist/testing/mod.d.ts +179 -6918
  114. package/dist/testing/mod.js +4 -4
  115. package/dist/transformers-BjBg6Lag.cjs +116 -0
  116. package/dist/{transformers-Dna8Fg7k.js → transformers-N_ip_y4P.js} +5 -5
  117. package/dist/types-Q-qkJXBV.cjs +315 -0
  118. package/dist/{types-Vo0qKhN7.js → types-hKTi53FO.js} +4 -4
  119. package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +11 -13
  120. package/dist/utils/kv-cache.test.js +211 -0
  121. package/dist/utils/mod.cjs +10 -0
  122. package/dist/utils/mod.d.cts +4 -0
  123. package/dist/utils/mod.d.ts +6 -0
  124. package/dist/utils/mod.js +9 -0
  125. package/dist/utils-Db0ZmjcD.cjs +4 -0
  126. package/dist/utils-Wranxuoe.js +4 -0
  127. package/package.json +69 -55
  128. package/dist/actor-BC3XtGTj.js +0 -37312
  129. package/dist/actor-C22bXuuC.d.ts +0 -130
  130. package/dist/actor-CmRlosMl.js +0 -146
  131. package/dist/assert_throws-53_pKeP3.js +0 -39
  132. package/dist/authdocloader-D-DICGXT.js +0 -52
  133. package/dist/compat-Bb5myD13.js +0 -4
  134. package/dist/denokv-jZ0Z2h0M.js +0 -57
  135. package/dist/docloader-CkASOfZ5.js +0 -4615
  136. package/dist/docloader-CxWcuWqQ.d.ts +0 -221
  137. package/dist/fixtures/activitypub.academy/users/brauca_darradiul.json +0 -83
  138. package/dist/fixtures/example.com/announce.json +0 -6
  139. package/dist/fixtures/example.com/collection.json +0 -19
  140. package/dist/fixtures/example.com/create.json +0 -6
  141. package/dist/fixtures/example.com/cross-origin-actor.json +0 -6
  142. package/dist/fixtures/example.com/hong-gildong.json +0 -11
  143. package/dist/fixtures/example.com/invite.json +0 -7
  144. package/dist/fixtures/example.com/key.json +0 -7
  145. package/dist/fixtures/example.com/key2.json +0 -6
  146. package/dist/fixtures/example.com/object.json +0 -6
  147. package/dist/fixtures/example.com/orderedcollectionpage.json +0 -24
  148. package/dist/fixtures/example.com/paged/a.json +0 -13
  149. package/dist/fixtures/example.com/paged/b.json +0 -16
  150. package/dist/fixtures/example.com/paged-collection.json +0 -6
  151. package/dist/fixtures/example.com/person.json +0 -22
  152. package/dist/fixtures/example.com/person2.json +0 -40
  153. package/dist/fixtures/example.com/test.json +0 -5
  154. package/dist/fixtures/example.com/users/handle.json +0 -16
  155. package/dist/fixtures/example.com/wrong-type.json +0 -3
  156. package/dist/fixtures/oeee.cafe/ap/users/3609fd4e-d51d-4db8-9f04-4189815864dd.json +0 -24
  157. package/dist/fixtures/remote.domain/users/bob.json +0 -20
  158. package/dist/fixtures/server.example/users/alice.json +0 -20
  159. package/dist/fixtures/w3id.org/identity/v1.json +0 -152
  160. package/dist/fixtures/w3id.org/security/data-integrity/v1.json +0 -74
  161. package/dist/fixtures/w3id.org/security/multikey/v1.json +0 -35
  162. package/dist/fixtures/w3id.org/security/v1.json +0 -50
  163. package/dist/fixtures/wizard.casa/users/hongminhee.json +0 -69
  164. package/dist/fixtures/www.w3.org/ns/activitystreams.json +0 -379
  165. package/dist/fixtures/www.w3.org/ns/did/v1.json +0 -58
  166. package/dist/key-Bif4eMj7.js +0 -260
  167. package/dist/key-BteSu1lX.js +0 -10
  168. package/dist/key-DWWqeyaq.js +0 -10
  169. package/dist/lookup-Cz9VSYxw.js +0 -131
  170. package/dist/lookup-DuzrBbTj.js +0 -322
  171. package/dist/middleware-CNfiKLIZ.js +0 -25
  172. package/dist/middleware-CnvU63kV.js +0 -17
  173. package/dist/mod-Cxt4Kpf6.d.ts +0 -291
  174. package/dist/mod-DBzN0aCM.d.ts +0 -115
  175. package/dist/mod-TFoH2Ql8.d.ts +0 -104
  176. package/dist/mod-g0xFzAP9.d.ts +0 -2
  177. package/dist/mq-CRGm1e_F.d.ts +0 -143
  178. package/dist/nodeinfo-CyEbLjHs.js +0 -4
  179. package/dist/runtime/docloader.test.js +0 -522
  180. package/dist/runtime/key.test.js +0 -103
  181. package/dist/runtime/langstr.test.js +0 -39
  182. package/dist/runtime/mod.d.ts +0 -8
  183. package/dist/runtime/mod.js +0 -13
  184. package/dist/runtime/multibase/multibase.test.js +0 -358
  185. package/dist/runtime/url.test.d.ts +0 -3
  186. package/dist/runtime/url.test.js +0 -45
  187. package/dist/runtime-BSkOVUWM.js +0 -4
  188. package/dist/sig-BXJO--F9.js +0 -4
  189. package/dist/src/vocab/accept.yaml +0 -15
  190. package/dist/src/vocab/activity.yaml +0 -98
  191. package/dist/src/vocab/add.yaml +0 -16
  192. package/dist/src/vocab/announce.yaml +0 -30
  193. package/dist/src/vocab/application.yaml +0 -324
  194. package/dist/src/vocab/arrive.yaml +0 -15
  195. package/dist/src/vocab/article.yaml +0 -46
  196. package/dist/src/vocab/audio.yaml +0 -11
  197. package/dist/src/vocab/block.yaml +0 -16
  198. package/dist/src/vocab/chatmessage.yaml +0 -50
  199. package/dist/src/vocab/collection.yaml +0 -154
  200. package/dist/src/vocab/collectionpage.yaml +0 -55
  201. package/dist/src/vocab/create.yaml +0 -28
  202. package/dist/src/vocab/dataintegrityproof.yaml +0 -56
  203. package/dist/src/vocab/delete.yaml +0 -27
  204. package/dist/src/vocab/didservice.yaml +0 -22
  205. package/dist/src/vocab/dislike.yaml +0 -14
  206. package/dist/src/vocab/document.yaml +0 -31
  207. package/dist/src/vocab/emoji.yaml +0 -12
  208. package/dist/src/vocab/emojireact.yaml +0 -17
  209. package/dist/src/vocab/endpoints.yaml +0 -85
  210. package/dist/src/vocab/event.yaml +0 -11
  211. package/dist/src/vocab/export.yaml +0 -9
  212. package/dist/src/vocab/flag.yaml +0 -15
  213. package/dist/src/vocab/follow.yaml +0 -19
  214. package/dist/src/vocab/group.yaml +0 -324
  215. package/dist/src/vocab/hashtag.yaml +0 -14
  216. package/dist/src/vocab/ignore.yaml +0 -14
  217. package/dist/src/vocab/image.yaml +0 -9
  218. package/dist/src/vocab/intransitiveactivity.yaml +0 -15
  219. package/dist/src/vocab/invite.yaml +0 -14
  220. package/dist/src/vocab/join.yaml +0 -14
  221. package/dist/src/vocab/key.yaml +0 -28
  222. package/dist/src/vocab/leave.yaml +0 -14
  223. package/dist/src/vocab/like.yaml +0 -16
  224. package/dist/src/vocab/link.yaml +0 -101
  225. package/dist/src/vocab/listen.yaml +0 -12
  226. package/dist/src/vocab/mention.yaml +0 -9
  227. package/dist/src/vocab/move.yaml +0 -15
  228. package/dist/src/vocab/multikey.yaml +0 -36
  229. package/dist/src/vocab/note.yaml +0 -48
  230. package/dist/src/vocab/object.yaml +0 -404
  231. package/dist/src/vocab/offer.yaml +0 -15
  232. package/dist/src/vocab/orderedcollection.yaml +0 -39
  233. package/dist/src/vocab/orderedcollectionpage.yaml +0 -50
  234. package/dist/src/vocab/organization.yaml +0 -324
  235. package/dist/src/vocab/page.yaml +0 -11
  236. package/dist/src/vocab/person.yaml +0 -324
  237. package/dist/src/vocab/place.yaml +0 -75
  238. package/dist/src/vocab/profile.yaml +0 -26
  239. package/dist/src/vocab/propertyvalue.yaml +0 -32
  240. package/dist/src/vocab/question.yaml +0 -103
  241. package/dist/src/vocab/read.yaml +0 -13
  242. package/dist/src/vocab/reject.yaml +0 -14
  243. package/dist/src/vocab/relationship.yaml +0 -52
  244. package/dist/src/vocab/remove.yaml +0 -14
  245. package/dist/src/vocab/service.yaml +0 -324
  246. package/dist/src/vocab/source.yaml +0 -26
  247. package/dist/src/vocab/tentativeaccept.yaml +0 -14
  248. package/dist/src/vocab/tentativereject.yaml +0 -14
  249. package/dist/src/vocab/tombstone.yaml +0 -24
  250. package/dist/src/vocab/travel.yaml +0 -16
  251. package/dist/src/vocab/undo.yaml +0 -26
  252. package/dist/src/vocab/update.yaml +0 -58
  253. package/dist/src/vocab/video.yaml +0 -11
  254. package/dist/src/vocab/view.yaml +0 -13
  255. package/dist/testing/docloader.test.js +0 -24
  256. package/dist/type-CAteiET0.js +0 -42007
  257. package/dist/vocab/actor.test.d.ts +0 -3
  258. package/dist/vocab/actor.test.js +0 -5965
  259. package/dist/vocab/lookup.test.d.ts +0 -3
  260. package/dist/vocab/lookup.test.js +0 -206
  261. package/dist/vocab/mod.d.ts +0 -8
  262. package/dist/vocab/mod.js +0 -10
  263. package/dist/vocab/schema.yaml +0 -247
  264. package/dist/vocab/type.test.d.ts +0 -3
  265. package/dist/vocab/type.test.js +0 -25
  266. package/dist/vocab/vocab.test.d.ts +0 -3
  267. package/dist/vocab/vocab.test.js +0 -3363
  268. package/dist/vocab-89qErSc9.js +0 -246
  269. package/dist/vocab-SOE1ifCr.d.ts +0 -14634
  270. package/dist/webfinger/handler.test.d.ts +0 -3
  271. package/dist/webfinger/lookup.test.d.ts +0 -3
  272. package/dist/webfinger/lookup.test.js +0 -195
  273. package/dist/webfinger/mod.d.ts +0 -6
  274. package/dist/webfinger/mod.js +0 -9
  275. package/dist/webfinger-C3GIyXIg.js +0 -4
  276. package/dist/x/cfworkers.d.ts +0 -61
  277. package/dist/x/cfworkers.js +0 -98
  278. package/dist/x/cfworkers.test.d.ts +0 -3
  279. package/dist/x/cfworkers.test.js +0 -179
  280. package/dist/x/hono.d.ts +0 -56
  281. package/dist/x/hono.js +0 -60
  282. package/dist/x/sveltekit.d.ts +0 -48
  283. package/dist/x/sveltekit.js +0 -68
  284. /package/dist/{runtime/authdocloader.test.d.ts → federation/idempotency.test.d.ts} +0 -0
  285. /package/dist/{runtime/docloader.test.d.ts → federation/negotiation.test.d.ts} +0 -0
  286. /package/dist/{runtime/key.test.d.ts → federation/webfinger.test.d.ts} +0 -0
  287. /package/dist/{mod-1pDWKvUL.d.ts → mod-1E3W847c.d.ts} +0 -0
  288. /package/dist/{runtime/langstr.test.d.ts → otel/exporter.test.d.ts} +0 -0
  289. /package/dist/{retry-CfF8Gn4d.js → retry-D4GJ670a.js} +0 -0
  290. /package/dist/{types-BSuWJsOm.js → types-BEdCLHqP.js} +0 -0
  291. /package/dist/{testing → utils}/docloader.test.d.ts +0 -0
  292. /package/dist/{runtime/multibase/multibase.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
@@ -3,38 +3,53 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Activity, Announce, Create, Invite, Multikey, Note, Object as Object$1, Offer, Person, fetchDocumentLoader, getTypeId } from "../type-CAteiET0.js";
6
+ import { 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 { assertInstanceOf } from "../assert_instance_of-DHz7EHNU.js";
10
- import { MemoryKvStore } from "../kv-CRZrzyXm.js";
11
- import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "../middleware-CgNm3XOJ.js";
12
- import "../client-Bsj0vQPr.js";
13
- import { RouterError, lookupObject } from "../lookup-DuzrBbTj.js";
14
- import "../types-BSuWJsOm.js";
15
- import "../actor-CmRlosMl.js";
16
- import "../key-BOzqiGbl.js";
17
- import { signRequest, verifyRequest } from "../http-CSYNybkH.js";
18
- import { getAuthenticatedDocumentLoader } from "../authdocloader-CzpPQC01.js";
19
- import { detachSignature, signJsonLd, verifyJsonLd } from "../ld-D9oTBLrs.js";
20
- import { doesActorOwnKey } from "../owner-gB-pDKA-.js";
21
- import { signObject, verifyObject } from "../proof-CScVkkIT.js";
22
- import "../inbox-DoJlwIE4.js";
23
- import "../builder-D9zidAqR.js";
10
+ import { MemoryKvStore } from "../kv-QzKcOQgP.js";
11
+ import "../deno-DIwNGswC.js";
12
+ import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "../middleware-C3xnTI2Z.js";
13
+ import "../client-CgMTXmAD.js";
14
+ import { RouterError } from "../router-D9eI0s4b.js";
15
+ import "../types-BEdCLHqP.js";
16
+ import "../key-Bdc11xlQ.js";
17
+ import { signRequest, verifyRequest } from "../http-BV9SKFK0.js";
18
+ import { detachSignature, signJsonLd, verifyJsonLd } from "../ld-C7be04RF.js";
19
+ import { doesActorOwnKey } from "../owner-Bs5Y5twE.js";
20
+ import { signObject, verifyObject } from "../proof-CFwktc0B.js";
21
+ import { fetchDocumentLoader, getAuthenticatedDocumentLoader } from "../docloader-D2992pGD.js";
22
+ import "../kv-cache-BEeqyGER.js";
23
+ import "../inbox-DCV2fS3F.js";
24
+ import "../builder-CulJ6Oa9.js";
24
25
  import "../collection-CcnIw1qY.js";
25
- import "../keycache--NYDYifd.js";
26
- import "../retry-CfF8Gn4d.js";
27
- import "../send-flZ7H10-.js";
28
- import { mockDocumentLoader, test } from "../testing-CdBSI4xF.js";
26
+ import "../keycache-DRxpZ5r9.js";
27
+ import "../negotiation-5NPJL6zp.js";
28
+ import "../retry-D4GJ670a.js";
29
+ import "../send-C288Vw8b.js";
29
30
  import { assertStrictEquals } from "../std__assert-DWivtrGR.js";
30
- import { assertFalse, assertRejects } from "../assert_rejects-7UF4R_Qs.js";
31
- import "../assert_is_error-B035L3om.js";
31
+ import { assertFalse, assertRejects } from "../assert_rejects-Ce45JcFg.js";
32
+ import { assertThrows } from "../assert_throws-BNXdRGWP.js";
32
33
  import { assertNotEquals } from "../assert_not_equals-C80BG-_5.js";
33
- import { assertThrows } from "../assert_throws-53_pKeP3.js";
34
- import { ed25519Multikey, ed25519PrivateKey, ed25519PublicKey, rsaPrivateKey2, rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-MacD9GP6.js";
35
- import { esm_default } from "../esm-CXF1VoeR.js";
34
+ import { ed25519Multikey, ed25519PrivateKey, ed25519PublicKey, rsaPrivateKey2, rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-ZbcByPg9.js";
35
+ import { esm_default } from "../esm-DGl7uK1r.js";
36
+ import * as vocab from "@fedify/vocab";
37
+ import { getTypeId, lookupObject } from "@fedify/vocab";
36
38
 
37
- //#region src/testing/fixtures/example.com/person.json
39
+ //#region ../fixture/src/fixtures/example.com/create.json
40
+ var __context$2 = "https://www.w3.org/ns/activitystreams";
41
+ var type$2 = "Create";
42
+ var id$2 = "https://example.com/create";
43
+ var actor = "https://example.com/person";
44
+ var create_default = {
45
+ "@context": __context$2,
46
+ type: type$2,
47
+ id: id$2,
48
+ actor
49
+ };
50
+
51
+ //#endregion
52
+ //#region ../fixture/src/fixtures/example.com/person.json
38
53
  var __context$1 = ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"];
39
54
  var id$1 = "https://example.com/person";
40
55
  var type$1 = "Person";
@@ -58,7 +73,7 @@ var person_default = {
58
73
  };
59
74
 
60
75
  //#endregion
61
- //#region src/testing/fixtures/example.com/person2.json
76
+ //#region ../fixture/src/fixtures/example.com/person2.json
62
77
  var __context = [
63
78
  "https://www.w3.org/ns/activitystreams",
64
79
  "https://w3id.org/security/v1",
@@ -107,7 +122,7 @@ test("createFederation()", async (t) => {
107
122
  await t.step("allowPrivateAddress", () => {
108
123
  assertThrows(() => createFederation({
109
124
  kv,
110
- contextLoader: mockDocumentLoader,
125
+ contextLoaderFactory: () => mockDocumentLoader,
111
126
  allowPrivateAddress: true
112
127
  }), TypeError);
113
128
  assertThrows(() => createFederation({
@@ -244,7 +259,7 @@ test({
244
259
  assertStrictEquals(ctx.federation, federation);
245
260
  assertThrows(() => ctx.getNodeInfoUri(), RouterError);
246
261
  assertThrows(() => ctx.getActorUri("handle"), RouterError);
247
- assertThrows(() => ctx.getObjectUri(Note, {
262
+ assertThrows(() => ctx.getObjectUri(vocab.Note, {
248
263
  handle: "handle",
249
264
  id: "id"
250
265
  }), RouterError);
@@ -261,7 +276,7 @@ test({
261
276
  assertEquals(ctx.parseUri(null), null);
262
277
  assertEquals(await ctx.getActorKeyPairs("handle"), []);
263
278
  await assertRejects(() => ctx.getDocumentLoader({ identifier: "handle" }), Error, "No actor key pairs dispatcher registered");
264
- await assertRejects(() => ctx.sendActivity({ identifier: "handle" }, [], new Create({})), Error, "No actor key pairs dispatcher registered");
279
+ await assertRejects(() => ctx.sendActivity({ identifier: "handle" }, [], new vocab.Create({})), Error, "No actor key pairs dispatcher registered");
265
280
  federation.setNodeInfoDispatcher("/nodeinfo/2.1", () => ({
266
281
  software: {
267
282
  name: "Example",
@@ -276,7 +291,7 @@ test({
276
291
  }));
277
292
  ctx = federation.createContext(new URL("https://example.com/"), 123);
278
293
  assertEquals(ctx.getNodeInfoUri(), new URL("https://example.com/nodeinfo/2.1"));
279
- federation.setActorDispatcher("/users/{identifier}", () => new Person({})).setKeyPairsDispatcher(() => [{
294
+ federation.setActorDispatcher("/users/{identifier}", () => new vocab.Person({})).setKeyPairsDispatcher(() => [{
280
295
  privateKey: rsaPrivateKey2,
281
296
  publicKey: rsaPublicKey2.publicKey
282
297
  }, {
@@ -300,7 +315,7 @@ test({
300
315
  id: new URL("https://example.com/users/handle#main-key"),
301
316
  owner: new URL("https://example.com/users/handle")
302
317
  }),
303
- multikey: new Multikey({
318
+ multikey: new vocab.Multikey({
304
319
  id: new URL("https://example.com/users/handle#main-key"),
305
320
  controller: new URL("https://example.com/users/handle"),
306
321
  publicKey: rsaPublicKey2.publicKey
@@ -313,7 +328,7 @@ test({
313
328
  id: new URL("https://example.com/users/handle#key-2"),
314
329
  owner: new URL("https://example.com/users/handle")
315
330
  }),
316
- multikey: new Multikey({
331
+ multikey: new vocab.Multikey({
317
332
  id: new URL("https://example.com/users/handle#key-2"),
318
333
  controller: new URL("https://example.com/users/handle"),
319
334
  publicKey: ed25519PublicKey.publicKey
@@ -341,8 +356,8 @@ test({
341
356
  document: true
342
357
  });
343
358
  assertEquals(await ctx.lookupObject("https://example.com/object"), null);
344
- await assertRejects(() => ctx.sendActivity({ identifier: "handle" }, [], new Create({})), TypeError, "The activity to send must have at least one actor property.");
345
- await ctx.sendActivity({ identifier: "handle" }, [], new Create({ actor: new URL("https://example.com/users/handle") }));
359
+ await assertRejects(() => ctx.sendActivity({ identifier: "handle" }, [], new vocab.Create({})), TypeError, "The activity to send must have at least one actor property.");
360
+ await ctx.sendActivity({ identifier: "handle" }, [], new vocab.Create({ actor: new URL("https://example.com/users/handle") }));
346
361
  esm_default.get("https://example.com/object", () => new Response(JSON.stringify({
347
362
  "@context": "https://www.w3.org/ns/activitystreams",
348
363
  type: "Object",
@@ -355,21 +370,21 @@ test({
355
370
  contextLoaderFactory: () => mockDocumentLoader
356
371
  });
357
372
  const ctx2 = federation2.createContext(new URL("https://example.com/"), 123);
358
- assertEquals(await ctx2.lookupObject("https://example.com/object"), new Object$1({
373
+ assertEquals(await ctx2.lookupObject("https://example.com/object"), new vocab.Object({
359
374
  id: new URL("https://example.com/object"),
360
375
  name: "Fetched object"
361
376
  }));
362
- federation.setObjectDispatcher(Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
363
- return new Note({ summary: `Note ${values.id} by ${values.identifier}` });
377
+ federation.setObjectDispatcher(vocab.Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
378
+ return new vocab.Note({ summary: `Note ${values.id} by ${values.identifier}` });
364
379
  });
365
380
  ctx = federation.createContext(new URL("https://example.com/"), 123);
366
- assertEquals(ctx.getObjectUri(Note, {
381
+ assertEquals(ctx.getObjectUri(vocab.Note, {
367
382
  identifier: "john",
368
383
  id: "123"
369
384
  }), new URL("https://example.com/users/john/notes/123"));
370
385
  assertEquals(ctx.parseUri(new URL("https://example.com/users/john/notes/123")), {
371
386
  type: "object",
372
- class: Note,
387
+ class: vocab.Note,
373
388
  typeId: new URL("https://www.w3.org/ns/activitystreams#Note"),
374
389
  values: {
375
390
  identifier: "john",
@@ -452,7 +467,7 @@ test({
452
467
  kv,
453
468
  origin: "https://ap.example.com",
454
469
  documentLoaderFactory: () => mockDocumentLoader,
455
- contextLoader: mockDocumentLoader
470
+ contextLoaderFactory: () => mockDocumentLoader
456
471
  });
457
472
  const ctx = federation.createContext(new URL("https://example.com:1234/"));
458
473
  assertEquals(ctx.origin, "https://example.com:1234");
@@ -472,7 +487,7 @@ test({
472
487
  }
473
488
  }));
474
489
  assertEquals(ctx.getNodeInfoUri(), new URL("https://ap.example.com/nodeinfo/2.1"));
475
- federation.setActorDispatcher("/users/{identifier}", () => new Person({}));
490
+ federation.setActorDispatcher("/users/{identifier}", () => new vocab.Person({}));
476
491
  assertEquals(ctx.getActorUri("handle"), new URL("https://ap.example.com/users/handle"));
477
492
  assertEquals(ctx.parseUri(new URL("https://ap.example.com/users/handle")), {
478
493
  type: "actor",
@@ -484,16 +499,16 @@ test({
484
499
  handle: "handle",
485
500
  identifier: "handle"
486
501
  });
487
- federation.setObjectDispatcher(Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
488
- return new Note({ summary: `Note ${values.id} by ${values.identifier}` });
502
+ federation.setObjectDispatcher(vocab.Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
503
+ return new vocab.Note({ summary: `Note ${values.id} by ${values.identifier}` });
489
504
  });
490
- assertEquals(ctx.getObjectUri(Note, {
505
+ assertEquals(ctx.getObjectUri(vocab.Note, {
491
506
  identifier: "john",
492
507
  id: "123"
493
508
  }), new URL("https://ap.example.com/users/john/notes/123"));
494
509
  assertEquals(ctx.parseUri(new URL("https://ap.example.com/users/john/notes/123")), {
495
510
  type: "object",
496
- class: Note,
511
+ class: vocab.Note,
497
512
  typeId: new URL("https://www.w3.org/ns/activitystreams#Note"),
498
513
  values: {
499
514
  identifier: "john",
@@ -502,7 +517,7 @@ test({
502
517
  });
503
518
  assertEquals(ctx.parseUri(new URL("https://example.com:1234/users/john/notes/123")), {
504
519
  type: "object",
505
- class: Note,
520
+ class: vocab.Note,
506
521
  typeId: new URL("https://www.w3.org/ns/activitystreams#Note"),
507
522
  values: {
508
523
  identifier: "john",
@@ -680,7 +695,7 @@ test({
680
695
  kv,
681
696
  documentLoaderFactory: () => mockDocumentLoader
682
697
  });
683
- const req = new Request("https://example.com/");
698
+ const req = new Request("https://example.com/", { headers: { "accept": "application/ld+json" } });
684
699
  const ctx = federation.createContext(req, 123);
685
700
  assertEquals(ctx.request, req);
686
701
  assertEquals(ctx.url, new URL("https://example.com/"));
@@ -689,7 +704,7 @@ test({
689
704
  assertEquals(ctx.hostname, "example.com");
690
705
  assertEquals(ctx.data, 123);
691
706
  await assertRejects(() => ctx.getActor("someone"), Error);
692
- await assertRejects(() => ctx.getObject(Note, {
707
+ await assertRejects(() => ctx.getObject(vocab.Note, {
693
708
  handle: "someone",
694
709
  id: "123"
695
710
  }), Error);
@@ -698,7 +713,7 @@ test({
698
713
  assertEquals(await ctx.getSignedKey(), null);
699
714
  assertEquals(await ctx.getSignedKeyOwner(), null);
700
715
  await assertRejects(() => ctx.getActor("someone"), Error, "No actor dispatcher registered");
701
- const signedReq = await signRequest(new Request("https://example.com/"), rsaPrivateKey2, rsaPublicKey2.id);
716
+ const signedReq = await signRequest(new Request("https://example.com/", { headers: { "accept": "application/ld+json" } }), rsaPrivateKey2, rsaPublicKey2.id);
702
717
  const signedCtx = federation.createContext(signedReq, 456);
703
718
  assertEquals(signedCtx.request, signedReq);
704
719
  assertEquals(signedCtx.url, new URL("https://example.com/"));
@@ -707,7 +722,7 @@ test({
707
722
  assertEquals(await signedCtx.getSignedKeyOwner(), null);
708
723
  assertEquals(await signedCtx.getSignedKey(), rsaPublicKey2);
709
724
  assertEquals(await signedCtx.getSignedKeyOwner(), null);
710
- const signedReq2 = await signRequest(new Request("https://example.com/"), rsaPrivateKey3, rsaPublicKey3.id);
725
+ const signedReq2 = await signRequest(new Request("https://example.com/", { headers: { "accept": "application/ld+json" } }), rsaPrivateKey3, rsaPublicKey3.id);
711
726
  const signedCtx2 = federation.createContext(signedReq2, 456);
712
727
  assertEquals(signedCtx2.request, signedReq2);
713
728
  assertEquals(signedCtx2.url, new URL("https://example.com/"));
@@ -720,27 +735,27 @@ test({
720
735
  assertEquals(await signedCtx2.getSignedKeyOwner(), expectedOwner);
721
736
  assertEquals(await signedCtx2.getSignedKey(), rsaPublicKey3);
722
737
  assertEquals(await signedCtx2.getSignedKeyOwner(), expectedOwner);
723
- federation.setActorDispatcher("/users/{identifier}", (_ctx, identifier) => new Person({ preferredUsername: identifier }));
738
+ federation.setActorDispatcher("/users/{identifier}", (_ctx, identifier) => new vocab.Person({ preferredUsername: identifier }));
724
739
  const ctx2 = federation.createContext(req, 789);
725
740
  assertEquals(ctx2.request, req);
726
741
  assertEquals(ctx2.url, new URL("https://example.com/"));
727
742
  assertEquals(ctx2.data, 789);
728
- assertEquals(await ctx2.getActor("john"), new Person({ preferredUsername: "john" }));
729
- federation.setObjectDispatcher(Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
730
- return new Note({ summary: `Note ${values.id} by ${values.identifier}` });
743
+ assertEquals(await ctx2.getActor("john"), new vocab.Person({ preferredUsername: "john" }));
744
+ federation.setObjectDispatcher(vocab.Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
745
+ return new vocab.Note({ summary: `Note ${values.id} by ${values.identifier}` });
731
746
  });
732
747
  const ctx3 = federation.createContext(req, 123);
733
748
  assertEquals(ctx3.request, req);
734
749
  assertEquals(ctx3.url, new URL("https://example.com/"));
735
750
  assertEquals(ctx3.data, 123);
736
- assertEquals(await ctx2.getObject(Note, {
751
+ assertEquals(await ctx2.getObject(vocab.Note, {
737
752
  identifier: "john",
738
753
  id: "123"
739
- }), new Note({ summary: "Note 123 by john" }));
754
+ }), new vocab.Note({ summary: "Note 123 by john" }));
740
755
  });
741
756
  await t.step("RequestContext.clone()", () => {
742
757
  const federation = createFederation({ kv });
743
- const req = new Request("https://example.com/");
758
+ const req = new Request("https://example.com/", { headers: { "accept": "application/ld+json" } });
744
759
  const ctx = federation.createContext(req, 123);
745
760
  const clone = ctx.clone(456);
746
761
  assertStrictEquals(clone.request, ctx.request);
@@ -756,6 +771,157 @@ test({
756
771
  esm_default.hardReset();
757
772
  }
758
773
  });
774
+ test("Federation.fetch()", async (t) => {
775
+ esm_default.spyGlobal();
776
+ esm_default.get("https://example.com/key2", {
777
+ headers: { "Content-Type": "application/activity+json" },
778
+ body: await rsaPublicKey2.toJsonLd({ contextLoader: mockDocumentLoader })
779
+ });
780
+ esm_default.get("begin:https://example.com/person", {
781
+ headers: { "Content-Type": "application/activity+json" },
782
+ body: person_default
783
+ });
784
+ const createTestContext = () => {
785
+ const kv = new MemoryKvStore();
786
+ const inbox = [];
787
+ const dispatches = [];
788
+ const federation = createFederation({
789
+ kv,
790
+ documentLoaderFactory: () => mockDocumentLoader,
791
+ authenticatedDocumentLoaderFactory(identity) {
792
+ const docLoader = getAuthenticatedDocumentLoader(identity);
793
+ return (url) => {
794
+ const urlObj = new URL(url);
795
+ if (urlObj.host === "example.com") return docLoader(url);
796
+ return mockDocumentLoader(url);
797
+ };
798
+ }
799
+ });
800
+ federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => {
801
+ dispatches.push(identifier);
802
+ return new vocab.Person({
803
+ id: ctx.getActorUri(identifier),
804
+ inbox: ctx.getInboxUri(identifier),
805
+ preferredUsername: identifier
806
+ });
807
+ }).setKeyPairsDispatcher(() => {
808
+ return [{
809
+ privateKey: rsaPrivateKey2,
810
+ publicKey: rsaPublicKey2.publicKey
811
+ }];
812
+ });
813
+ federation.setInboxDispatcher("/users/{identifier}/inbox", () => {
814
+ return { items: [] };
815
+ });
816
+ federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, (_ctx, activity) => {
817
+ inbox.push(activity.id.toString());
818
+ return;
819
+ });
820
+ return {
821
+ federation,
822
+ inbox,
823
+ dispatches
824
+ };
825
+ };
826
+ await t.step("GET without accepts header", async () => {
827
+ const { federation, dispatches } = createTestContext();
828
+ const response = await federation.fetch(new Request("https://example.com/users/actor", { method: "GET" }), { contextData: void 0 });
829
+ assertEquals(dispatches, []);
830
+ assertEquals(response.status, 406);
831
+ });
832
+ await t.step("POST with application/json", async () => {
833
+ const { federation, inbox } = createTestContext();
834
+ const request = await signRequest(new Request("https://example.com/users/json/inbox", {
835
+ method: "POST",
836
+ headers: {
837
+ "Accept": "application/json",
838
+ "Content-Type": "application/json"
839
+ },
840
+ body: JSON.stringify(create_default)
841
+ }), rsaPrivateKey2, rsaPublicKey2.id);
842
+ const response = await federation.fetch(request, { contextData: void 0 });
843
+ assertEquals(response.status, 202);
844
+ assertEquals(inbox.length, 1, "Expected one item in the inbox, json");
845
+ assertEquals(inbox[0], create_default.id);
846
+ });
847
+ await t.step("GET with application/json", async () => {
848
+ const { federation, dispatches } = createTestContext();
849
+ const response = await federation.fetch(new Request("https://example.com/users/json", {
850
+ method: "GET",
851
+ headers: { "Accept": "application/json" }
852
+ }), { contextData: void 0 });
853
+ assertEquals(dispatches, ["json"]);
854
+ assertEquals(response.status, 200);
855
+ });
856
+ await t.step("POST with application/ld+json", async () => {
857
+ const { federation, inbox } = createTestContext();
858
+ const request = await signRequest(new Request("https://example.com/users/ld/inbox", {
859
+ method: "POST",
860
+ headers: {
861
+ "Accept": "application/ld+json",
862
+ "Content-Type": "application/activity+json"
863
+ },
864
+ body: JSON.stringify(create_default)
865
+ }), rsaPrivateKey2, rsaPublicKey2.id);
866
+ const response = await federation.fetch(request, { contextData: void 0 });
867
+ assertEquals(response.status, 202);
868
+ assertEquals(inbox.length, 1, "Expected one inbox activity, ld+json");
869
+ assertEquals(inbox[0], create_default.id);
870
+ });
871
+ await t.step("GET with application/ld+json", async () => {
872
+ const { federation, dispatches } = createTestContext();
873
+ const request = new Request("https://example.com/users/ld", {
874
+ method: "GET",
875
+ headers: { "Accept": "application/ld+json" }
876
+ });
877
+ const response = await federation.fetch(request, { contextData: void 0 });
878
+ assertEquals(dispatches, ["ld"]);
879
+ assertEquals(response.status, 200);
880
+ });
881
+ await t.step("POST with application/activity+json", async () => {
882
+ const { federation, inbox } = createTestContext();
883
+ const request = await signRequest(new Request("https://example.com/users/activity/inbox", {
884
+ method: "POST",
885
+ headers: {
886
+ "Accept": "application/activity+json",
887
+ "Content-Type": "application/activity+json"
888
+ },
889
+ body: JSON.stringify(create_default)
890
+ }), rsaPrivateKey2, rsaPublicKey2.id);
891
+ const response = await federation.fetch(request, { contextData: void 0 });
892
+ assertEquals(response.status, 202);
893
+ assertEquals(inbox.length, 1);
894
+ assertEquals(inbox[0], create_default.id);
895
+ });
896
+ await t.step("GET with application/activity+json", async () => {
897
+ const { federation, dispatches } = createTestContext();
898
+ const request = new Request("https://example.com/users/activity", {
899
+ method: "GET",
900
+ headers: { "Accept": "application/ld+json" }
901
+ });
902
+ const response = await federation.fetch(request, { contextData: void 0 });
903
+ assertEquals(dispatches, ["activity"]);
904
+ assertEquals(response.status, 200);
905
+ });
906
+ await t.step("onNotAcceptable with GET", async () => {
907
+ const { federation } = createTestContext();
908
+ let notAcceptableCalled = false;
909
+ const response = await federation.fetch(new Request("https://example.com/users/html", {
910
+ method: "GET",
911
+ headers: { "Accept": "text/html" }
912
+ }), {
913
+ contextData: void 0,
914
+ onNotAcceptable: () => {
915
+ notAcceptableCalled = true;
916
+ return new Response("handled by onNotAcceptable", { status: 200 });
917
+ }
918
+ });
919
+ assertEquals(notAcceptableCalled, true);
920
+ assertEquals(response.status, 200);
921
+ assertEquals(await response.text(), "handled by onNotAcceptable");
922
+ });
923
+ esm_default.hardReset();
924
+ });
759
925
  test("Federation.setInboxListeners()", async (t) => {
760
926
  const kv = new MemoryKvStore();
761
927
  esm_default.spyGlobal();
@@ -805,13 +971,16 @@ test("Federation.setInboxListeners()", async (t) => {
805
971
  }
806
972
  });
807
973
  const inbox = [];
808
- federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, (ctx, create) => {
974
+ federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, (ctx, create) => {
809
975
  inbox.push([ctx, create]);
810
976
  });
811
- let response = await federation.fetch(new Request("https://example.com/inbox", { method: "POST" }), { contextData: void 0 });
977
+ let response = await federation.fetch(new Request("https://example.com/inbox", {
978
+ method: "POST",
979
+ headers: { "accept": "application/ld+json" }
980
+ }), { contextData: void 0 });
812
981
  assertEquals(inbox, []);
813
982
  assertEquals(response.status, 404);
814
- federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new Person({}) : null).setKeyPairsDispatcher(() => [{
983
+ federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new vocab.Person({}) : null).setKeyPairsDispatcher(() => [{
815
984
  privateKey: rsaPrivateKey2,
816
985
  publicKey: rsaPublicKey2.publicKey
817
986
  }]);
@@ -819,29 +988,43 @@ test("Federation.setInboxListeners()", async (t) => {
819
988
  documentLoader: mockDocumentLoader,
820
989
  contextLoader: mockDocumentLoader
821
990
  };
822
- const activity = () => new Create({
991
+ const activity = () => new vocab.Create({
823
992
  id: new URL("https://example.com/activities/" + crypto.randomUUID()),
824
993
  actor: new URL("https://example.com/person2")
825
994
  });
826
995
  response = await federation.fetch(new Request("https://example.com/inbox", {
827
996
  method: "POST",
828
- body: JSON.stringify(await activity().toJsonLd(options))
997
+ body: JSON.stringify(await activity().toJsonLd(options)),
998
+ headers: {
999
+ "accept": "application/ld+json",
1000
+ "content-type": "application/ld+json"
1001
+ }
829
1002
  }), { contextData: void 0 });
830
1003
  assertEquals(inbox, []);
831
1004
  assertEquals(response.status, 401);
832
- response = await federation.fetch(new Request("https://example.com/users/no-one/inbox", { method: "POST" }), { contextData: void 0 });
1005
+ response = await federation.fetch(new Request("https://example.com/users/no-one/inbox", {
1006
+ method: "POST",
1007
+ headers: { "accept": "application/ld+json" }
1008
+ }), { contextData: void 0 });
833
1009
  assertEquals(inbox, []);
834
1010
  assertEquals(response.status, 404);
835
1011
  response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
836
1012
  method: "POST",
837
- body: JSON.stringify(await activity().toJsonLd(options))
1013
+ body: JSON.stringify(await activity().toJsonLd(options)),
1014
+ headers: {
1015
+ "accept": "application/ld+json",
1016
+ "content-type": "application/ld+json"
1017
+ }
838
1018
  }), { contextData: void 0 });
839
1019
  assertEquals(inbox, []);
840
1020
  assertEquals(response.status, 401);
841
1021
  const activityPayload = await activity().toJsonLd(options);
842
1022
  let request = new Request("https://example.com/users/john/inbox", {
843
1023
  method: "POST",
844
- headers: { "Content-Type": "application/activity+json" },
1024
+ headers: {
1025
+ "Content-Type": "application/activity+json",
1026
+ accept: "application/ld+json"
1027
+ },
845
1028
  body: JSON.stringify(activityPayload)
846
1029
  });
847
1030
  request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
@@ -858,7 +1041,10 @@ test("Federation.setInboxListeners()", async (t) => {
858
1041
  inbox.shift();
859
1042
  request = new Request("https://another.host/users/john/inbox", {
860
1043
  method: "POST",
861
- headers: { "Content-Type": "application/activity+json" },
1044
+ headers: {
1045
+ "Content-Type": "application/activity+json",
1046
+ "accept": "application/ld+json"
1047
+ },
862
1048
  body: JSON.stringify(activityPayload)
863
1049
  });
864
1050
  request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
@@ -873,7 +1059,10 @@ test("Federation.setInboxListeners()", async (t) => {
873
1059
  inbox.shift();
874
1060
  request = new Request("https://example.com/inbox", {
875
1061
  method: "POST",
876
- headers: { "Content-Type": "application/activity+json" },
1062
+ headers: {
1063
+ "Content-Type": "application/activity+json",
1064
+ "accept": "application/ld+json"
1065
+ },
877
1066
  body: JSON.stringify(await activity().toJsonLd(options))
878
1067
  });
879
1068
  request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
@@ -888,7 +1077,10 @@ test("Federation.setInboxListeners()", async (t) => {
888
1077
  inbox.shift();
889
1078
  request = new Request("https://example.com/users/john/inbox", {
890
1079
  method: "POST",
891
- headers: { "Content-Type": "application/activity+json" },
1080
+ headers: {
1081
+ "Content-Type": "application/activity+json",
1082
+ "accept": "application/ld+json"
1083
+ },
892
1084
  body: JSON.stringify(await (await signObject(activity(), ed25519PrivateKey, ed25519Multikey.id, options)).toJsonLd(options))
893
1085
  });
894
1086
  response = await federation.fetch(request, { contextData: void 0 });
@@ -913,21 +1105,24 @@ test("Federation.setInboxListeners()", async (t) => {
913
1105
  };
914
1106
  }
915
1107
  });
916
- federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new Person({}) : null).setKeyPairsDispatcher(() => [{
1108
+ federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new vocab.Person({}) : null).setKeyPairsDispatcher(() => [{
917
1109
  privateKey: rsaPrivateKey2,
918
1110
  publicKey: rsaPublicKey2.publicKey
919
1111
  }]);
920
1112
  const error = /* @__PURE__ */ new Error("test");
921
1113
  const errors = [];
922
- federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
1114
+ federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
923
1115
  throw error;
924
1116
  }).onError((_, e) => {
925
1117
  errors.push(e);
926
1118
  });
927
- const activity = new Create({ actor: new URL("https://example.com/person") });
1119
+ const activity = new vocab.Create({ actor: new URL("https://example.com/person") });
928
1120
  let request = new Request("https://example.com/users/john/inbox", {
929
1121
  method: "POST",
930
- headers: { "Content-Type": "application/activity+json" },
1122
+ headers: {
1123
+ "Content-Type": "application/activity+json",
1124
+ "Accept": "application/activity+json"
1125
+ },
931
1126
  body: JSON.stringify(await activity.toJsonLd({ contextLoader: mockDocumentLoader }))
932
1127
  });
933
1128
  request = await signRequest(request, rsaPrivateKey2, new URL("https://example.com/key2"));
@@ -980,8 +1175,8 @@ test("FederationImpl.sendActivity()", async (t) => {
980
1175
  let json = await cl.request.json();
981
1176
  if (await verifyJsonLd(json, options)) verified.push("ld");
982
1177
  json = detachSignature(json);
983
- let activity = await verifyObject(Activity, json, options);
984
- if (activity == null) activity = await Activity.fromJsonLd(json, options);
1178
+ let activity = await verifyObject(vocab.Activity, json, options);
1179
+ if (activity == null) activity = await vocab.Activity.fromJsonLd(json, options);
985
1180
  else verified.push("proof");
986
1181
  const key = await verifyRequest(request, options);
987
1182
  if (key != null && await doesActorOwnKey(activity, key, options)) verified.push("http");
@@ -991,11 +1186,11 @@ test("FederationImpl.sendActivity()", async (t) => {
991
1186
  const kv = new MemoryKvStore();
992
1187
  const federation = new FederationImpl({
993
1188
  kv,
994
- contextLoader: mockDocumentLoader
1189
+ contextLoaderFactory: () => mockDocumentLoader
995
1190
  });
996
1191
  const context = federation.createContext(new URL("https://example.com/"));
997
1192
  await t.step("success", async () => {
998
- const activity = new Create({
1193
+ const activity = new vocab.Create({
999
1194
  id: new URL("https://example.com/activity/1"),
1000
1195
  actor: new URL("https://example.com/person")
1001
1196
  });
@@ -1070,7 +1265,7 @@ test("FederationImpl.processQueuedTask()", async (t) => {
1070
1265
  kv,
1071
1266
  queue
1072
1267
  });
1073
- federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
1268
+ federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
1074
1269
  throw new Error("Intended error for testing");
1075
1270
  });
1076
1271
  await assertRejects(() => federation.processQueuedTask(void 0, {
@@ -1132,7 +1327,7 @@ test("FederationImpl.processQueuedTask()", async (t) => {
1132
1327
  kv,
1133
1328
  queue
1134
1329
  });
1135
- federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
1330
+ federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
1136
1331
  throw new Error("Intended error for testing");
1137
1332
  });
1138
1333
  const outboxMessage = {
@@ -1217,7 +1412,7 @@ test("ContextImpl.lookupObject()", async (t) => {
1217
1412
  });
1218
1413
  const ctx = federation.createContext(new URL("https://example.com/"));
1219
1414
  const result = await ctx.lookupObject("@test@localhost");
1220
- assertInstanceOf(result, Person);
1415
+ assertInstanceOf(result, vocab.Person);
1221
1416
  assertEquals(result.id, new URL("https://localhost/actor"));
1222
1417
  assertEquals(result.preferredUsername, "test");
1223
1418
  });
@@ -1243,7 +1438,7 @@ test("ContextImpl.sendActivity()", async (t) => {
1243
1438
  collectionSyncHeader = cl.request.headers.get("Collection-Synchronization");
1244
1439
  const options = {
1245
1440
  async documentLoader(url) {
1246
- const response = await federation.fetch(new Request(url), { contextData: void 0 });
1441
+ const response = await federation.fetch(new Request(url, { headers: { "accept": "application/ld+json" } }), { contextData: void 0 });
1247
1442
  if (response.ok) return {
1248
1443
  contextUrl: null,
1249
1444
  document: await response.json(),
@@ -1266,8 +1461,8 @@ test("ContextImpl.sendActivity()", async (t) => {
1266
1461
  let json = await cl.request.json();
1267
1462
  if (await verifyJsonLd(json, options)) verified.push("ld");
1268
1463
  json = detachSignature(json);
1269
- let activity = await verifyObject(Activity, json, options);
1270
- if (activity == null) activity = await Activity.fromJsonLd(json, options);
1464
+ let activity = await verifyObject(vocab.Activity, json, options);
1465
+ if (activity == null) activity = await vocab.Activity.fromJsonLd(json, options);
1271
1466
  else verified.push("proof");
1272
1467
  const key = await verifyRequest(request, options);
1273
1468
  if (key != null && await doesActorOwnKey(activity, key, options)) verified.push("http");
@@ -1277,12 +1472,12 @@ test("ContextImpl.sendActivity()", async (t) => {
1277
1472
  const kv = new MemoryKvStore();
1278
1473
  const federation = new FederationImpl({
1279
1474
  kv,
1280
- contextLoader: mockDocumentLoader
1475
+ contextLoaderFactory: () => mockDocumentLoader
1281
1476
  });
1282
1477
  federation.setActorDispatcher("/{identifier}", async (ctx, identifier) => {
1283
1478
  if (identifier !== "1") return null;
1284
1479
  const keys = await ctx.getActorKeyPairs(identifier);
1285
- return new Person({
1480
+ return new vocab.Person({
1286
1481
  id: ctx.getActorUri(identifier),
1287
1482
  preferredUsername: "john",
1288
1483
  publicKey: keys[0].cryptographicKey,
@@ -1303,7 +1498,7 @@ test("ContextImpl.sendActivity()", async (t) => {
1303
1498
  inboxId: new URL("https://example.com/inbox")
1304
1499
  }] }));
1305
1500
  await t.step("success", async () => {
1306
- const activity = new Create({ actor: new URL("https://example.com/person") });
1501
+ const activity = new vocab.Create({ actor: new URL("https://example.com/person") });
1307
1502
  const ctx = new ContextImpl({
1308
1503
  data: void 0,
1309
1504
  federation,
@@ -1386,13 +1581,13 @@ test("ContextImpl.sendActivity()", async (t) => {
1386
1581
  };
1387
1582
  const federation2 = new FederationImpl({
1388
1583
  kv,
1389
- contextLoader: mockDocumentLoader,
1584
+ contextLoaderFactory: () => mockDocumentLoader,
1390
1585
  queue
1391
1586
  });
1392
1587
  federation2.setActorDispatcher("/{identifier}", async (ctx, identifier) => {
1393
1588
  if (identifier !== "john") return null;
1394
1589
  const keys = await ctx.getActorKeyPairs(identifier);
1395
- return new Person({
1590
+ return new vocab.Person({
1396
1591
  id: ctx.getActorUri(identifier),
1397
1592
  preferredUsername: "john",
1398
1593
  publicKey: keys[0].cryptographicKey,
@@ -1416,7 +1611,7 @@ test("ContextImpl.sendActivity()", async (t) => {
1416
1611
  contextLoader: fetchDocumentLoader
1417
1612
  });
1418
1613
  await t.step("fanout: \"force\"", async () => {
1419
- const activity = new Create({
1614
+ const activity = new vocab.Create({
1420
1615
  id: new URL("https://example.com/activity/1"),
1421
1616
  actor: new URL("https://example.com/person")
1422
1617
  });
@@ -1445,7 +1640,7 @@ test("ContextImpl.sendActivity()", async (t) => {
1445
1640
  });
1446
1641
  queue.clear();
1447
1642
  await t.step("fanout: \"skip\"", async () => {
1448
- const activity = new Create({
1643
+ const activity = new vocab.Create({
1449
1644
  id: new URL("https://example.com/activity/1"),
1450
1645
  actor: new URL("https://example.com/person")
1451
1646
  });
@@ -1460,7 +1655,7 @@ test("ContextImpl.sendActivity()", async (t) => {
1460
1655
  });
1461
1656
  queue.clear();
1462
1657
  await t.step("fanout: \"auto\"", async () => {
1463
- const activity = new Create({
1658
+ const activity = new vocab.Create({
1464
1659
  id: new URL("https://example.com/activity/1"),
1465
1660
  actor: new URL("https://example.com/person")
1466
1661
  });
@@ -1509,7 +1704,7 @@ test("ContextImpl.sendActivity()", async (t) => {
1509
1704
  documentLoader: fetchDocumentLoader,
1510
1705
  contextLoader: fetchDocumentLoader
1511
1706
  });
1512
- const activity = new Create({
1707
+ const activity = new vocab.Create({
1513
1708
  id: new URL("https://example.com/activity/1"),
1514
1709
  actor: ctx.getActorUri("1"),
1515
1710
  to: ctx.getFollowersUri("1")
@@ -1526,7 +1721,7 @@ test("ContextImpl.sendActivity()", async (t) => {
1526
1721
  documentLoader: fetchDocumentLoader,
1527
1722
  contextLoader: fetchDocumentLoader
1528
1723
  });
1529
- const activity = new Create({
1724
+ const activity = new vocab.Create({
1530
1725
  id: new URL("https://example.com/activity/2"),
1531
1726
  actor: ctx.getActorUri("1"),
1532
1727
  to: ctx.getFollowersUri("1")
@@ -1548,7 +1743,7 @@ test({
1548
1743
  async fn() {
1549
1744
  const federation = new FederationImpl({ kv: new MemoryKvStore() });
1550
1745
  const activities = [];
1551
- federation.setInboxListeners("/u/{identifier}/i", "/i").on(Offer, (ctx$1, offer) => {
1746
+ federation.setInboxListeners("/u/{identifier}/i", "/i").on(vocab.Offer, (ctx$1, offer) => {
1552
1747
  activities.push([ctx$1.recipient, offer]);
1553
1748
  });
1554
1749
  const ctx = new ContextImpl({
@@ -1558,52 +1753,52 @@ test({
1558
1753
  documentLoader: mockDocumentLoader,
1559
1754
  contextLoader: fetchDocumentLoader
1560
1755
  });
1561
- assertFalse(await ctx.routeActivity(null, new Offer({ actor: new URL("https://example.com/person") })));
1756
+ assertFalse(await ctx.routeActivity(null, new vocab.Offer({ actor: new URL("https://example.com/person") })));
1562
1757
  assertEquals(activities, []);
1563
- const signedOffer = await signObject(new Offer({ actor: new URL("https://example.com/person2") }), ed25519PrivateKey, ed25519Multikey.id);
1758
+ const signedOffer = await signObject(new vocab.Offer({ actor: new URL("https://example.com/person2") }), ed25519PrivateKey, ed25519Multikey.id);
1564
1759
  assert(await ctx.routeActivity(null, signedOffer));
1565
1760
  assertEquals(activities, [[null, signedOffer]]);
1566
- const signedInvite = await signObject(new Invite({ actor: new URL("https://example.com/person2") }), ed25519PrivateKey, ed25519Multikey.id);
1761
+ const signedInvite = await signObject(new vocab.Invite({ actor: new URL("https://example.com/person2") }), ed25519PrivateKey, ed25519Multikey.id);
1567
1762
  assert(await ctx.routeActivity("id", signedInvite));
1568
1763
  assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
1569
- assertFalse(await ctx.routeActivity(null, new Create({
1764
+ assertFalse(await ctx.routeActivity(null, new vocab.Create({
1570
1765
  id: new URL("https://example.com/not-found"),
1571
1766
  actor: new URL("https://example.com/person")
1572
1767
  })));
1573
1768
  assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
1574
- assertFalse(await ctx.routeActivity(null, new Create({
1769
+ assertFalse(await ctx.routeActivity(null, new vocab.Create({
1575
1770
  id: new URL("https://example.com/person"),
1576
1771
  actor: new URL("https://example.com/person")
1577
1772
  })));
1578
1773
  assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
1579
- assertFalse(await ctx.routeActivity(null, new Announce({
1774
+ assertFalse(await ctx.routeActivity(null, new vocab.Announce({
1580
1775
  id: new URL("https://example.com/announce#diffrent-id"),
1581
1776
  actor: new URL("https://example.com/person")
1582
1777
  })));
1583
1778
  assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
1584
- assertFalse(await ctx.routeActivity(null, new Announce({
1779
+ assertFalse(await ctx.routeActivity(null, new vocab.Announce({
1585
1780
  id: new URL("https://example.com/announce"),
1586
1781
  actor: new URL("https://example.com/person")
1587
1782
  })));
1588
1783
  assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
1589
- assertFalse(await ctx.routeActivity(null, new Create({
1784
+ assertFalse(await ctx.routeActivity(null, new vocab.Create({
1590
1785
  id: new URL("https://example.com/cross-origin-actor"),
1591
1786
  actor: new URL("https://cross-origin.com/actor")
1592
1787
  })));
1593
1788
  assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
1594
- assert(await ctx.routeActivity(null, new Create({
1789
+ assert(await ctx.routeActivity(null, new vocab.Create({
1595
1790
  id: new URL("https://example.com/create"),
1596
1791
  actor: new URL("https://example.com/person")
1597
1792
  })));
1598
1793
  assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
1599
- assert(await ctx.routeActivity(null, new Invite({
1794
+ assert(await ctx.routeActivity(null, new vocab.Invite({
1600
1795
  id: new URL("https://example.com/invite"),
1601
1796
  actor: new URL("https://example.com/person")
1602
1797
  })));
1603
1798
  assertEquals(activities, [
1604
1799
  [null, signedOffer],
1605
1800
  ["id", signedInvite],
1606
- [null, new Invite({
1801
+ [null, new vocab.Invite({
1607
1802
  id: new URL("https://example.com/invite"),
1608
1803
  actor: new URL("https://example.com/person"),
1609
1804
  object: new URL("https://example.com/object")
@@ -1625,15 +1820,15 @@ test("ContextImpl.getCollectionUri()", () => {
1625
1820
  const dispatcher = (_ctx, _values) => ({ items: [] });
1626
1821
  let url;
1627
1822
  const strName = "registered";
1628
- federation.setCollectionDispatcher(strName, Object$1, "/string-route/{id}", dispatcher);
1823
+ federation.setCollectionDispatcher(strName, vocab.Object, "/string-route/{id}", dispatcher);
1629
1824
  url = ctx.getCollectionUri(strName, values);
1630
1825
  assertEquals(url.href, `${base}/string-route/123`);
1631
1826
  const unnamedSymName = Symbol(strName);
1632
- federation.setCollectionDispatcher(unnamedSymName, Object$1, "/symbol-route/{id}", dispatcher);
1827
+ federation.setCollectionDispatcher(unnamedSymName, vocab.Object, "/symbol-route/{id}", dispatcher);
1633
1828
  url = ctx.getCollectionUri(unnamedSymName, values);
1634
1829
  assertEquals(url.href, `${base}/symbol-route/123`);
1635
1830
  const namedSymName = Symbol.for(strName);
1636
- federation.setCollectionDispatcher(namedSymName, Object$1, "/named-symbol-route/{id}", dispatcher);
1831
+ federation.setCollectionDispatcher(namedSymName, vocab.Object, "/named-symbol-route/{id}", dispatcher);
1637
1832
  url = ctx.getCollectionUri(namedSymName, values);
1638
1833
  assertEquals(url.href, `${base}/named-symbol-route/123`);
1639
1834
  const notReg = "not-registered";
@@ -1655,8 +1850,8 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
1655
1850
  let json = await cl.request.json();
1656
1851
  if (await verifyJsonLd(json, options)) verified.push("ld");
1657
1852
  json = detachSignature(json);
1658
- let activity = await verifyObject(Activity, json, options);
1659
- if (activity == null) activity = await Activity.fromJsonLd(json, options);
1853
+ let activity = await verifyObject(vocab.Activity, json, options);
1854
+ if (activity == null) activity = await vocab.Activity.fromJsonLd(json, options);
1660
1855
  else verified.push("proof");
1661
1856
  const key = await verifyRequest(request, options);
1662
1857
  if (key != null && await doesActorOwnKey(activity, key, options)) verified.push("http");
@@ -1666,7 +1861,7 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
1666
1861
  const kv = new MemoryKvStore();
1667
1862
  const federation = new FederationImpl({
1668
1863
  kv,
1669
- contextLoader: mockDocumentLoader
1864
+ contextLoaderFactory: () => mockDocumentLoader
1670
1865
  });
1671
1866
  await t.step("skip", async () => {
1672
1867
  const activity = {
@@ -1715,7 +1910,7 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
1715
1910
  assertEquals(verified, []);
1716
1911
  });
1717
1912
  await t.step("Object Integrity Proofs", async () => {
1718
- const activity = await signObject(new Create({
1913
+ const activity = await signObject(new vocab.Create({
1719
1914
  id: new URL("https://example.com/activity"),
1720
1915
  actor: new URL("https://example.com/person2")
1721
1916
  }), ed25519PrivateKey, ed25519Multikey.id, {