@fedify/fedify 2.5.0-dev.2664 → 2.5.0-dev.2710

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 (266) hide show
  1. package/dist/compat/mod.d.cts +1 -1
  2. package/dist/compat/mod.d.ts +1 -1
  3. package/dist/{context-xrqq4Hrq.d.ts → context-CuLvR1Os.d.ts} +2 -2
  4. package/dist/{context-C1NqcIct.d.cts → context-apq0IBg2.d.cts} +2 -2
  5. package/dist/federation/mod.cjs +1 -1
  6. package/dist/federation/mod.d.cts +3 -3
  7. package/dist/federation/mod.d.ts +3 -3
  8. package/dist/federation/mod.js +1 -1
  9. package/dist/{federation-FbwcnRHg.cjs → federation-JvzYDx0P.cjs} +5 -5
  10. package/dist/{http-DbvOPsFZ.cjs → http-BG5cDmTS.cjs} +1 -1
  11. package/dist/{http-CWn0K5jD.js → http-MUf125Jc.js} +1 -1
  12. package/dist/{key-dwwAg5bA.d.ts → key-BZw-YiK5.d.ts} +2 -2
  13. package/dist/{key-DlHT4R6k.d.cts → key-D5fbQkKM.d.cts} +2 -2
  14. package/dist/{kv-cache-B-fOrhb-.cjs → kv-cache-A2po7h0_.cjs} +1 -1
  15. package/dist/{kv-cache-BC837EqC.js → kv-cache-CbWc1BZA.js} +1 -1
  16. package/dist/{ld-CWVpo_NM.d.cts → ld-DEi9ERHf.d.cts} +1 -1
  17. package/dist/{ld-o4LnhCYY.d.ts → ld-DlC78ioJ.d.ts} +1 -1
  18. package/dist/{middleware-n2UrG62B.js → middleware-DzzdJ7Wz.js} +5 -5
  19. package/dist/{mod-D22ZsiKi.d.ts → mod-BJRtsw7l.d.ts} +1 -1
  20. package/dist/{mod-C1nT74IG.d.cts → mod-BamwZjJx.d.cts} +1 -1
  21. package/dist/{mod-DO0epJGH.d.ts → mod-BkTi19dI.d.ts} +1 -1
  22. package/dist/{mod-CQC9xlLZ.d.ts → mod-CMtF0VVy.d.ts} +1 -1
  23. package/dist/{mod-YvA4Rk8J.d.cts → mod-D2Z9MiCm.d.cts} +1 -1
  24. package/dist/{mod-TwiQgEf3.d.cts → mod-DB2NOzQF.d.cts} +1 -1
  25. package/dist/mod.cjs +4 -4
  26. package/dist/mod.d.cts +6 -6
  27. package/dist/mod.d.ts +6 -6
  28. package/dist/mod.js +4 -4
  29. package/dist/{portable-collection-DQhIkX5a.js → portable-collection-CAer9RWN.js} +1 -1
  30. package/dist/{portable-collection-DseoiPPj.cjs → portable-collection-d8w7TCn9.cjs} +1 -1
  31. package/dist/sig/mod.cjs +2 -2
  32. package/dist/sig/mod.d.cts +3 -3
  33. package/dist/sig/mod.d.ts +3 -3
  34. package/dist/sig/mod.js +2 -2
  35. package/dist/utils/mod.cjs +1 -1
  36. package/dist/utils/mod.d.cts +1 -1
  37. package/dist/utils/mod.d.ts +1 -1
  38. package/dist/utils/mod.js +1 -1
  39. package/package.json +22 -9
  40. package/skills/fedify/SKILL.md +10 -0
  41. package/dist/accept-CPVqki78.mjs +0 -145
  42. package/dist/activity-listener-CELFAodc.mjs +0 -44
  43. package/dist/assert-D1Eafmd_.mjs +0 -23
  44. package/dist/assert_equals-Z6IcEbWU.mjs +0 -987
  45. package/dist/assert_exists-cffSpJ7X.mjs +0 -28
  46. package/dist/assert_false-CPdRnc3E.mjs +0 -23
  47. package/dist/assert_greater_or_equal-BlafOF4-.mjs +0 -31
  48. package/dist/assert_instance_of-mrXWWNY-.mjs +0 -37
  49. package/dist/assert_not_equals-CpPK2t89.mjs +0 -30
  50. package/dist/assert_rejects-CTptdYck.mjs +0 -39
  51. package/dist/assert_strict_equals-CYvBmkpC.mjs +0 -42
  52. package/dist/assert_throws-BYITOvPO.mjs +0 -74
  53. package/dist/assertion_error-B-cx0fFA.mjs +0 -31
  54. package/dist/audience-CHQ-FlLD.mjs +0 -95
  55. package/dist/builder-CGJ-NXcZ.mjs +0 -911
  56. package/dist/circuit-breaker-XJ53md4S.mjs +0 -544
  57. package/dist/circuit-breaker-test-utils-DW6YC_Pe.mjs +0 -14
  58. package/dist/client-5SIFzW3q.mjs +0 -441
  59. package/dist/codec-C6rTrpIp.mjs +0 -147
  60. package/dist/collection-CnnP1UAv.mjs +0 -44
  61. package/dist/compat/outgoing-jsonld.test.d.mts +0 -2
  62. package/dist/compat/outgoing-jsonld.test.mjs +0 -257
  63. package/dist/compat/public-audience.test.d.mts +0 -2
  64. package/dist/compat/public-audience.test.mjs +0 -187
  65. package/dist/compat/secured-document.test.d.mts +0 -2
  66. package/dist/compat/secured-document.test.mjs +0 -58
  67. package/dist/compat/transformers.test.d.mts +0 -2
  68. package/dist/compat/transformers.test.mjs +0 -62
  69. package/dist/compound-proof-CnzwOddk.mjs +0 -1019
  70. package/dist/context-LgGFFSz7.mjs +0 -146
  71. package/dist/deno-eoFpPk7W.mjs +0 -8
  72. package/dist/dist-_geWsuaI.mjs +0 -189
  73. package/dist/docloader-DwkipyL1.mjs +0 -136
  74. package/dist/esm-BHXXx4Wx.mjs +0 -1233
  75. package/dist/exporter-DVG68ozH.mjs +0 -263
  76. package/dist/federation/audience.test.d.mts +0 -2
  77. package/dist/federation/audience.test.mjs +0 -130
  78. package/dist/federation/builder.test.d.mts +0 -2
  79. package/dist/federation/builder.test.mjs +0 -396
  80. package/dist/federation/circuit-breaker.test.d.mts +0 -2
  81. package/dist/federation/circuit-breaker.test.mjs +0 -1277
  82. package/dist/federation/collection.test.d.mts +0 -2
  83. package/dist/federation/collection.test.mjs +0 -21
  84. package/dist/federation/compound-fanout.test.d.mts +0 -2
  85. package/dist/federation/compound-fanout.test.mjs +0 -231
  86. package/dist/federation/handler-compound-proof.test.d.mts +0 -2
  87. package/dist/federation/handler-compound-proof.test.mjs +0 -384
  88. package/dist/federation/handler.test.d.mts +0 -2
  89. package/dist/federation/handler.test.mjs +0 -5445
  90. package/dist/federation/hashlink-media.test.d.mts +0 -2
  91. package/dist/federation/hashlink-media.test.mjs +0 -422
  92. package/dist/federation/idempotency.test.d.mts +0 -2
  93. package/dist/federation/idempotency.test.mjs +0 -207
  94. package/dist/federation/inbox-actorless.test.d.mts +0 -2
  95. package/dist/federation/inbox-actorless.test.mjs +0 -522
  96. package/dist/federation/inbox-authentication.test.d.mts +0 -2
  97. package/dist/federation/inbox-authentication.test.mjs +0 -220
  98. package/dist/federation/inbox-report.test.d.mts +0 -2
  99. package/dist/federation/inbox-report.test.mjs +0 -719
  100. package/dist/federation/inbox-view.test.d.mts +0 -2
  101. package/dist/federation/inbox-view.test.mjs +0 -369
  102. package/dist/federation/inbox.test.d.mts +0 -2
  103. package/dist/federation/inbox.test.mjs +0 -139
  104. package/dist/federation/keycache.test.d.mts +0 -2
  105. package/dist/federation/keycache.test.mjs +0 -337
  106. package/dist/federation/kv.test.d.mts +0 -2
  107. package/dist/federation/kv.test.mjs +0 -88
  108. package/dist/federation/metrics.test.d.mts +0 -2
  109. package/dist/federation/metrics.test.mjs +0 -634
  110. package/dist/federation/middleware.test.d.mts +0 -2
  111. package/dist/federation/middleware.test.mjs +0 -9314
  112. package/dist/federation/mq.test.d.mts +0 -2
  113. package/dist/federation/mq.test.mjs +0 -591
  114. package/dist/federation/negotiation.test.d.mts +0 -2
  115. package/dist/federation/negotiation.test.mjs +0 -18
  116. package/dist/federation/outbound-body.test.d.mts +0 -2
  117. package/dist/federation/outbound-body.test.mjs +0 -149
  118. package/dist/federation/outbound-capture.test.d.mts +0 -2
  119. package/dist/federation/outbound-capture.test.mjs +0 -394
  120. package/dist/federation/outbound-dispatch.test.d.mts +0 -2
  121. package/dist/federation/outbound-dispatch.test.mjs +0 -368
  122. package/dist/federation/outbound-document.test.d.mts +0 -2
  123. package/dist/federation/outbound-document.test.mjs +0 -171
  124. package/dist/federation/outbound-provenance.test.d.mts +0 -2
  125. package/dist/federation/outbound-provenance.test.mjs +0 -543
  126. package/dist/federation/outbound-report.test.d.mts +0 -2
  127. package/dist/federation/outbound-report.test.mjs +0 -5475
  128. package/dist/federation/outbound-workers.test.d.mts +0 -2
  129. package/dist/federation/outbound-workers.test.mjs +0 -64
  130. package/dist/federation/outbound-workflow.test.d.mts +0 -2
  131. package/dist/federation/outbound-workflow.test.mjs +0 -154
  132. package/dist/federation/outgoing-proof.test.d.mts +0 -2
  133. package/dist/federation/outgoing-proof.test.mjs +0 -933
  134. package/dist/federation/portable-actor.test.d.mts +0 -2
  135. package/dist/federation/portable-actor.test.mjs +0 -496
  136. package/dist/federation/portable-chain.test.d.mts +0 -2
  137. package/dist/federation/portable-chain.test.mjs +0 -370
  138. package/dist/federation/portable-collection.test.d.mts +0 -2
  139. package/dist/federation/portable-collection.test.mjs +0 -832
  140. package/dist/federation/portable-delivery.test.d.mts +0 -2
  141. package/dist/federation/portable-delivery.test.mjs +0 -845
  142. package/dist/federation/portable-gateway-keys.test.d.mts +0 -2
  143. package/dist/federation/portable-gateway-keys.test.mjs +0 -692
  144. package/dist/federation/portable-inbox.test.d.mts +0 -2
  145. package/dist/federation/portable-inbox.test.mjs +0 -1960
  146. package/dist/federation/portable-parse-uri.test.d.mts +0 -2
  147. package/dist/federation/portable-parse-uri.test.mjs +0 -348
  148. package/dist/federation/portable-route-activity.test.d.mts +0 -2
  149. package/dist/federation/portable-route-activity.test.mjs +0 -259
  150. package/dist/federation/portable.test.d.mts +0 -2
  151. package/dist/federation/portable.test.mjs +0 -1072
  152. package/dist/federation/retry.test.d.mts +0 -2
  153. package/dist/federation/retry.test.mjs +0 -42
  154. package/dist/federation/router.test.d.mts +0 -2
  155. package/dist/federation/router.test.mjs +0 -123
  156. package/dist/federation/send.test.d.mts +0 -2
  157. package/dist/federation/send.test.mjs +0 -1421
  158. package/dist/federation/tasks/codec.test.d.mts +0 -2
  159. package/dist/federation/tasks/codec.test.mjs +0 -302
  160. package/dist/federation/tasks/enqueue.test.d.mts +0 -2
  161. package/dist/federation/tasks/enqueue.test.mjs +0 -1095
  162. package/dist/federation/tasks/tasks.test.d.mts +0 -2
  163. package/dist/federation/tasks/tasks.test.mjs +0 -1229
  164. package/dist/federation/temporal.test.d.mts +0 -2
  165. package/dist/federation/temporal.test.mjs +0 -71
  166. package/dist/federation/webfinger.test.d.mts +0 -2
  167. package/dist/federation/webfinger.test.mjs +0 -944
  168. package/dist/http-l1zKGCll.mjs +0 -1449
  169. package/dist/inbox-CWX3EBTO.mjs +0 -399
  170. package/dist/inbox-authentication-CgonVRkg.mjs +0 -198
  171. package/dist/inbox-view-DkPCF71K.mjs +0 -385
  172. package/dist/key-owner-evidence-APB6NpSk.mjs +0 -108
  173. package/dist/keycache-N2opu4-3.mjs +0 -221
  174. package/dist/keys-DIJNHW-Y.mjs +0 -120
  175. package/dist/kv-DBRWVx3Q.mjs +0 -104
  176. package/dist/kv-DCHkaJ9-.mjs +0 -92
  177. package/dist/kv-cache-8eJh4Xum.mjs +0 -121
  178. package/dist/ld-Cdt8qD-r.mjs +0 -1752
  179. package/dist/map-local-context-conflict-DOYEEJ3u.mjs +0 -204
  180. package/dist/map-local-create-note-B0SeXJms.mjs +0 -214
  181. package/dist/metrics-BnfvSPj9.mjs +0 -818
  182. package/dist/middleware-CwnXJze2.mjs +0 -5
  183. package/dist/middleware-D_W_LdJN.mjs +0 -9971
  184. package/dist/mq-eF96QxUT.mjs +0 -288
  185. package/dist/negotiation-BAKO9nih.mjs +0 -96
  186. package/dist/nodeinfo/client.test.d.mts +0 -2
  187. package/dist/nodeinfo/client.test.mjs +0 -1364
  188. package/dist/nodeinfo/handler.test.d.mts +0 -2
  189. package/dist/nodeinfo/handler.test.mjs +0 -94
  190. package/dist/nodeinfo/types.test.d.mts +0 -2
  191. package/dist/nodeinfo/types.test.mjs +0 -192
  192. package/dist/otel/exporter.test.d.mts +0 -2
  193. package/dist/otel/exporter.test.mjs +0 -887
  194. package/dist/outbound-body-CckPA5gc.mjs +0 -83
  195. package/dist/outbound-capture-DVgnRzlf.mjs +0 -184
  196. package/dist/outbound-document-BMgwLXTY.mjs +0 -179
  197. package/dist/outgoing-jsonld-4IJqPYos.mjs +0 -205
  198. package/dist/owner-DukEQnv3.mjs +0 -267
  199. package/dist/portable-collection-OHaqa11n.mjs +0 -418
  200. package/dist/portable-key-BkOLJxVz.mjs +0 -549
  201. package/dist/portable-key-id-Ca30-hOa.mjs +0 -248
  202. package/dist/proof-Y7omSVvc.mjs +0 -1420
  203. package/dist/public-audience--klBIOk1.mjs +0 -197
  204. package/dist/retry-zX5xw5e0.mjs +0 -34
  205. package/dist/router-u5O5KCQr.mjs +0 -156
  206. package/dist/secured-document-CxzZZ9nL.mjs +0 -35
  207. package/dist/send-ccQynabr.mjs +0 -710
  208. package/dist/sig/accept.test.d.mts +0 -2
  209. package/dist/sig/accept.test.mjs +0 -416
  210. package/dist/sig/compound-proof-discovery.test.d.mts +0 -2
  211. package/dist/sig/compound-proof-discovery.test.mjs +0 -331
  212. package/dist/sig/compound-proof-producer.test.d.mts +0 -2
  213. package/dist/sig/compound-proof-producer.test.mjs +0 -107
  214. package/dist/sig/compound-proof-verification.test.d.mts +0 -2
  215. package/dist/sig/compound-proof-verification.test.mjs +0 -1017
  216. package/dist/sig/compound-proof.test.d.mts +0 -2
  217. package/dist/sig/compound-proof.test.mjs +0 -411
  218. package/dist/sig/http.test.d.mts +0 -2
  219. package/dist/sig/http.test.mjs +0 -3328
  220. package/dist/sig/key-owner-evidence.test.d.mts +0 -2
  221. package/dist/sig/key-owner-evidence.test.mjs +0 -100
  222. package/dist/sig/key.test.d.mts +0 -2
  223. package/dist/sig/key.test.mjs +0 -1250
  224. package/dist/sig/ld.test.d.mts +0 -2
  225. package/dist/sig/ld.test.mjs +0 -1044
  226. package/dist/sig/mitra-receive-interop.test.d.mts +0 -2
  227. package/dist/sig/mitra-receive-interop.test.mjs +0 -260
  228. package/dist/sig/mitra-send-interop.test.d.mts +0 -2
  229. package/dist/sig/mitra-send-interop.test.mjs +0 -461
  230. package/dist/sig/owner.test.d.mts +0 -2
  231. package/dist/sig/owner.test.mjs +0 -202
  232. package/dist/sig/portable-collection.test.d.mts +0 -2
  233. package/dist/sig/portable-collection.test.mjs +0 -697
  234. package/dist/sig/portable-interop.test.d.mts +0 -2
  235. package/dist/sig/portable-interop.test.mjs +0 -156
  236. package/dist/sig/portable-key-id.test.d.mts +0 -2
  237. package/dist/sig/portable-key-id.test.mjs +0 -67
  238. package/dist/sig/portable-key.test.d.mts +0 -2
  239. package/dist/sig/portable-key.test.mjs +0 -1438
  240. package/dist/sig/proof.test.d.mts +0 -2
  241. package/dist/sig/proof.test.mjs +0 -2638
  242. package/dist/sig/tootik-request-interop.test.d.mts +0 -2
  243. package/dist/sig/tootik-request-interop.test.mjs +0 -190
  244. package/dist/sig/tootik-send-interop.test.d.mts +0 -2
  245. package/dist/sig/tootik-send-interop.test.mjs +0 -331
  246. package/dist/sig/verification.test.d.mts +0 -2
  247. package/dist/sig/verification.test.mjs +0 -310
  248. package/dist/std__assert-DvMDRPes.mjs +0 -8
  249. package/dist/tasks-BCUmQbbz.mjs +0 -77
  250. package/dist/temporal-f_K4lAVR.mjs +0 -95
  251. package/dist/testing/context.test.d.mts +0 -2
  252. package/dist/testing/context.test.mjs +0 -19
  253. package/dist/testing/kv.test.d.mts +0 -2
  254. package/dist/testing/kv.test.mjs +0 -101
  255. package/dist/testing/mod.d.mts +0 -6099
  256. package/dist/testing/mod.mjs +0 -9
  257. package/dist/testing-vrnD5Uaa.mjs +0 -8
  258. package/dist/types-DE_LV1JB.mjs +0 -46
  259. package/dist/utils/docloader.test.d.mts +0 -2
  260. package/dist/utils/docloader.test.mjs +0 -1076
  261. package/dist/utils/kv-cache.test.d.mts +0 -2
  262. package/dist/utils/kv-cache.test.mjs +0 -261
  263. package/dist/verification-C3954hQh.mjs +0 -5
  264. package/dist/verification-Dpfcw8ml.mjs +0 -105
  265. package/dist/vocab/cjs.test.d.mts +0 -2
  266. package/dist/vocab/cjs.test.mjs +0 -27
@@ -1,257 +0,0 @@
1
- import "temporal-polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
5
- import { t as assertStrictEquals } from "../assert_strict_equals-CYvBmkpC.mjs";
6
- import { n as normalizeAttachmentArrays, r as normalizeOutgoingActivityJsonLd, t as isPreloadedContextAttachmentSafe } from "../outgoing-jsonld-4IJqPYos.mjs";
7
- import { Create, Document, Note, PUBLIC_COLLECTION } from "@fedify/vocab";
8
- import { mockDocumentLoader, test } from "@fedify/fixture";
9
- //#region src/compat/outgoing-jsonld.test.ts
10
- test("normalizeAttachmentArrays() wraps scalar attachments", async () => {
11
- const object = (await normalizeAttachmentArrays({
12
- "@context": "https://www.w3.org/ns/activitystreams",
13
- type: "Create",
14
- object: {
15
- type: "Note",
16
- attachment: {
17
- type: "Document",
18
- mediaType: "image/png",
19
- url: "https://example.com/image.png"
20
- }
21
- }
22
- })).object;
23
- assertEquals(object.attachment, [{
24
- type: "Document",
25
- mediaType: "image/png",
26
- url: "https://example.com/image.png"
27
- }]);
28
- });
29
- test("normalizeAttachmentArrays() skips canonicalization for known-safe contexts", async () => {
30
- assertEquals((await normalizeAttachmentArrays({
31
- "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"],
32
- type: "Note",
33
- attachment: {
34
- type: "Document",
35
- mediaType: "image/png",
36
- url: "https://example.com/image.png"
37
- }
38
- }, () => {
39
- throw new Error("context loader should not be called");
40
- })).attachment, [{
41
- type: "Document",
42
- mediaType: "image/png",
43
- url: "https://example.com/image.png"
44
- }]);
45
- });
46
- test("isPreloadedContextAttachmentSafe() checks scoped contexts", () => {
47
- assertEquals(isPreloadedContextAttachmentSafe({ "@context": {
48
- attachment: {
49
- "@id": "as:attachment",
50
- "@type": "@id"
51
- },
52
- Example: { "@context": { attachment: {
53
- "@id": "as:attachment",
54
- "@type": "@id"
55
- } } }
56
- } }), true);
57
- assertEquals(isPreloadedContextAttachmentSafe({ "@context": { Example: { "@context": { attachment: "https://example.com/custom-attachment" } } } }), false);
58
- });
59
- test("normalizeAttachmentArrays() does not wrap JSON-LD list objects", async () => {
60
- const attachment = { "@list": [{
61
- type: "Document",
62
- url: "https://example.com/image.png"
63
- }] };
64
- assertEquals((await normalizeAttachmentArrays({
65
- "@context": "https://www.w3.org/ns/activitystreams",
66
- type: "Note",
67
- attachment
68
- }, () => {
69
- throw new Error("context loader should not be called");
70
- })).attachment, attachment);
71
- });
72
- test("normalizeAttachmentArrays() does not traverse JSON-LD value payloads", async () => {
73
- const output = await normalizeAttachmentArrays({
74
- "@context": "https://www.w3.org/ns/activitystreams",
75
- type: "Note",
76
- attachment: { type: "Document" },
77
- content: {
78
- "@type": "@json",
79
- "@value": {
80
- "@context": { attachment: "https://example.com/custom-attachment" },
81
- attachment: "https://example.com/metadata"
82
- }
83
- }
84
- }, () => {
85
- throw new Error("context loader should not be called");
86
- });
87
- assertEquals(output.attachment, [{ type: "Document" }]);
88
- assertEquals(output.content, {
89
- "@type": "@json",
90
- "@value": {
91
- "@context": { attachment: "https://example.com/custom-attachment" },
92
- attachment: "https://example.com/metadata"
93
- }
94
- });
95
- });
96
- test("normalizeAttachmentArrays() leaves attachment arrays unchanged", async () => {
97
- const attachment = [{
98
- type: "Document",
99
- mediaType: "image/png",
100
- url: "https://example.com/image.png"
101
- }];
102
- assertEquals((await normalizeAttachmentArrays({
103
- "@context": "https://www.w3.org/ns/activitystreams",
104
- type: "Note",
105
- attachment
106
- })).attachment, attachment);
107
- });
108
- test("normalizeAttachmentArrays() leaves documents without attachments unchanged", async () => {
109
- const input = {
110
- "@context": "https://www.w3.org/ns/activitystreams",
111
- type: "Note",
112
- content: "Hello"
113
- };
114
- assertEquals(await normalizeAttachmentArrays(input), input);
115
- });
116
- test("normalizeAttachmentArrays() leaves @context subtrees untouched", async () => {
117
- const output = await normalizeAttachmentArrays({
118
- "@context": ["https://www.w3.org/ns/activitystreams", { attachment: "https://example.com/custom-attachment" }],
119
- type: "Note",
120
- attachment: "https://example.com/attachment"
121
- });
122
- const context = output["@context"];
123
- assertEquals(context[1], { attachment: "https://example.com/custom-attachment" });
124
- assertEquals(output.attachment, ["https://example.com/attachment"]);
125
- });
126
- test("normalizeAttachmentArrays() bails out when wrapping changes semantics", async () => {
127
- assertEquals((await normalizeAttachmentArrays({
128
- "@context": { attachment: {
129
- "@id": "https://example.com/custom-attachment",
130
- "@type": "@json"
131
- } },
132
- attachment: { custom: true }
133
- })).attachment, { custom: true });
134
- });
135
- test("normalizeAttachmentArrays() does not poison the global prototype via a __proto__ key", async () => {
136
- await normalizeAttachmentArrays(JSON.parse(`{
137
- "@context": "https://www.w3.org/ns/activitystreams",
138
- "type": "Note",
139
- "attachment": { "type": "Document" },
140
- "__proto__": { "polluted": true }
141
- }`));
142
- assertEquals(Object.prototype.polluted, void 0);
143
- });
144
- test("normalizeAttachmentArrays() stops before blowing the stack on pathological nesting", async () => {
145
- let deep = { attachment: { type: "Document" } };
146
- for (let i = 0; i < 256; i++) deep = { object: deep };
147
- const input = {
148
- "@context": "https://www.w3.org/ns/activitystreams",
149
- type: "Create",
150
- object: deep
151
- };
152
- assertStrictEquals(await normalizeAttachmentArrays(input), input);
153
- });
154
- test("normalizeAttachmentArrays() skips canonicalization for pathological nesting", async () => {
155
- let deep = { type: "Note" };
156
- for (let i = 0; i < 256; i++) deep = { object: deep };
157
- assertEquals((await normalizeAttachmentArrays({
158
- "@context": ["https://www.w3.org/ns/activitystreams", "https://example.com/context"],
159
- type: "Note",
160
- attachment: { type: "Document" },
161
- object: deep
162
- }, () => {
163
- throw new Error("context loader should not be called");
164
- })).attachment, { type: "Document" });
165
- });
166
- test("normalizeOutgoingActivityJsonLd() applies outgoing JSON-LD workarounds", async () => {
167
- const compact = await new Create({
168
- id: new URL("https://example.com/activities/1"),
169
- actor: new URL("https://example.com/alice"),
170
- object: new Note({
171
- id: new URL("https://example.com/notes/1"),
172
- tos: [PUBLIC_COLLECTION],
173
- attachments: [new Document({
174
- mediaType: "image/png",
175
- url: new URL("https://example.com/image.png")
176
- })]
177
- }),
178
- tos: [PUBLIC_COLLECTION]
179
- }).toJsonLd({ format: "compact" });
180
- assertEquals(compact.to, "as:Public");
181
- const compactObject = compact.object;
182
- assertEquals(Array.isArray(compactObject.attachment), false);
183
- const normalized = await normalizeOutgoingActivityJsonLd(compact, mockDocumentLoader);
184
- assertEquals(normalized.to, PUBLIC_COLLECTION.href);
185
- const normalizedObject = normalized.object;
186
- assertEquals(Array.isArray(normalizedObject.attachment), true);
187
- });
188
- const securedChild = {
189
- "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"],
190
- id: "ap://did:key:z6Mkabc/objects/1",
191
- type: "Note",
192
- content: "Hello",
193
- to: "as:Public",
194
- attachment: {
195
- type: "Document",
196
- mediaType: "image/png",
197
- url: "https://example.com/image.png"
198
- },
199
- proof: {
200
- "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"],
201
- type: "DataIntegrityProof",
202
- cryptosuite: "eddsa-jcs-2022",
203
- created: "2023-02-24T23:36:38Z",
204
- verificationMethod: "did:key:z6Mkabc#z6Mkabc",
205
- proofPurpose: "assertionMethod",
206
- proofValue: "z3FXQ"
207
- }
208
- };
209
- function compoundWithSecuredChild() {
210
- return {
211
- "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"],
212
- id: "ap://did:key:z6Mkdef/activities/1",
213
- type: "Create",
214
- actor: "ap://did:key:z6Mkdef/actor",
215
- to: "as:Public",
216
- object: structuredClone(securedChild)
217
- };
218
- }
219
- test("normalizeOutgoingActivityJsonLd() can preserve a nested secured child", async () => {
220
- const preserved = await normalizeOutgoingActivityJsonLd(compoundWithSecuredChild(), mockDocumentLoader, { preserveNestedSecuredDocuments: true });
221
- assertEquals(preserved.to, PUBLIC_COLLECTION.href);
222
- assertEquals(preserved.object, securedChild);
223
- });
224
- test("normalizeOutgoingActivityJsonLd() rewrites a nested secured child by default", async () => {
225
- const normalized = await normalizeOutgoingActivityJsonLd(compoundWithSecuredChild(), mockDocumentLoader);
226
- const child = normalized.object;
227
- assertEquals(normalized.to, PUBLIC_COLLECTION.href);
228
- assertEquals(child.to, PUBLIC_COLLECTION.href);
229
- assertEquals(child.attachment, [securedChild.attachment]);
230
- });
231
- test("normalizeOutgoingActivityJsonLd() only preserves a complete secured child", async () => {
232
- const cases = {
233
- "no proof": (child) => delete child.proof,
234
- "null proof": (child) => child.proof = null,
235
- "proof set": (child) => child.proof = [securedChild.proof],
236
- "proof without a verification method": (child) => delete child.proof.verificationMethod,
237
- "incomplete proof": (child) => delete child.proof.cryptosuite,
238
- "empty proof value": (child) => child.proof.proofValue = ""
239
- };
240
- for (const [name, mutate] of Object.entries(cases)) {
241
- const input = compoundWithSecuredChild();
242
- mutate(input.object);
243
- const child = (await normalizeOutgoingActivityJsonLd(input, mockDocumentLoader, { preserveNestedSecuredDocuments: true })).object;
244
- assertEquals(child.to, PUBLIC_COLLECTION.href, name);
245
- assertEquals(child.attachment, [securedChild.attachment], name);
246
- }
247
- });
248
- test("normalizeOutgoingActivityJsonLd() still normalizes a top-level secured document", async () => {
249
- const normalized = await normalizeOutgoingActivityJsonLd({
250
- ...structuredClone(securedChild),
251
- id: "ap://did:key:z6Mkabc/objects/top-level"
252
- }, mockDocumentLoader, { preserveNestedSecuredDocuments: true });
253
- assertEquals(normalized.to, PUBLIC_COLLECTION.href);
254
- assertEquals(normalized.attachment, [securedChild.attachment]);
255
- });
256
- //#endregion
257
- export {};
@@ -1,2 +0,0 @@
1
- import { Temporal } from "temporal-polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
@@ -1,187 +0,0 @@
1
- import "temporal-polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
5
- import { t as assertNotEquals } from "../assert_not_equals-CpPK2t89.mjs";
6
- import { t as normalizePublicAudience } from "../public-audience--klBIOk1.mjs";
7
- import { Create, Follow, Note, PUBLIC_COLLECTION } from "@fedify/vocab";
8
- import { getDocumentLoader, preloadedContexts } from "@fedify/vocab-runtime";
9
- import { test } from "@fedify/fixture";
10
- //#region src/compat/public-audience.test.ts
11
- const PUBLIC_URI = PUBLIC_COLLECTION.href;
12
- const AS_CONTEXT = "https://www.w3.org/ns/activitystreams";
13
- test("normalizePublicAudience() rewrites every addressing field and both CURIE forms", async () => {
14
- const output = await normalizePublicAudience({
15
- "@context": AS_CONTEXT,
16
- type: "Note",
17
- id: "https://example.com/notes/1",
18
- to: "as:Public",
19
- cc: ["as:Public", "https://example.com/bob"],
20
- bto: "Public",
21
- bcc: ["Public"],
22
- audience: ["as:Public", "Public"]
23
- });
24
- assertEquals(output.to, PUBLIC_URI);
25
- assertEquals(output.cc, [PUBLIC_URI, "https://example.com/bob"]);
26
- assertEquals(output.bto, PUBLIC_URI);
27
- assertEquals(output.bcc, [PUBLIC_URI]);
28
- assertEquals(output.audience, [PUBLIC_URI, PUBLIC_URI]);
29
- });
30
- test("normalizePublicAudience() normalises activities serialized by @fedify/vocab", async () => {
31
- const compact = await new Create({
32
- id: new URL("https://example.com/activities/1"),
33
- actor: new URL("https://example.com/alice"),
34
- object: new Note({
35
- id: new URL("https://example.com/notes/1"),
36
- content: "Hello, world!",
37
- tos: [PUBLIC_COLLECTION]
38
- }),
39
- tos: [PUBLIC_COLLECTION],
40
- ccs: [new URL("https://example.com/followers")]
41
- }).toJsonLd({ format: "compact" });
42
- assertEquals(compact.to, "as:Public");
43
- const normalized = await normalizePublicAudience(compact, getDocumentLoader());
44
- assertEquals(normalized.to, PUBLIC_URI);
45
- const nestedObject = normalized.object;
46
- assertEquals(nestedObject.to, PUBLIC_URI);
47
- });
48
- test("normalizePublicAudience() normalises a public relay Follow object", async () => {
49
- const compact = await new Follow({
50
- id: new URL("https://example.com/activities/follow-relay"),
51
- actor: new URL("https://example.com/alice"),
52
- object: PUBLIC_COLLECTION
53
- }).toJsonLd({ format: "compact" });
54
- assertEquals(compact.object, "as:Public");
55
- assertEquals((await normalizePublicAudience(compact, getDocumentLoader())).object, PUBLIC_URI);
56
- });
57
- test("normalizePublicAudience() is a no-op without the CURIE", async () => {
58
- const input = {
59
- "@context": AS_CONTEXT,
60
- type: "Note",
61
- id: "https://example.com/notes/3",
62
- to: PUBLIC_URI
63
- };
64
- assertEquals(await normalizePublicAudience(input), input);
65
- });
66
- test("normalizePublicAudience() leaves non-addressing fields untouched", async () => {
67
- const output = await normalizePublicAudience({
68
- "@context": AS_CONTEXT,
69
- type: "Note",
70
- id: "https://example.com/notes/4",
71
- name: "as:Public",
72
- to: "as:Public"
73
- });
74
- assertEquals(output.name, "as:Public");
75
- assertEquals(output.to, PUBLIC_URI);
76
- });
77
- test("normalizePublicAudience() rewrites without canonicalization for known-safe contexts", async () => {
78
- const rejecting = () => {
79
- throw new Error("contextLoader should not be called for a known-safe @context");
80
- };
81
- assertEquals((await normalizePublicAudience({
82
- "@context": AS_CONTEXT,
83
- type: "Note",
84
- id: "https://example.com/notes/fast1",
85
- to: "as:Public"
86
- }, rejecting)).to, PUBLIC_URI);
87
- assertEquals((await normalizePublicAudience({
88
- "@context": [AS_CONTEXT, "https://w3id.org/security/data-integrity/v1"],
89
- type: "Note",
90
- id: "https://example.com/notes/fast2",
91
- to: "as:Public"
92
- }, rejecting)).to, PUBLIC_URI);
93
- });
94
- test("normalizePublicAudience() falls back to canonicalization for unknown-URL contexts", async () => {
95
- let loaderCalls = 0;
96
- const loader = (url) => {
97
- loaderCalls++;
98
- return Promise.resolve({
99
- contextUrl: null,
100
- documentUrl: url,
101
- document: preloadedContexts[AS_CONTEXT]
102
- });
103
- };
104
- assertEquals((await normalizePublicAudience({
105
- "@context": [AS_CONTEXT, "https://custom.example/ctx"],
106
- type: "Note",
107
- id: "https://example.com/notes/unknown",
108
- to: "as:Public"
109
- }, loader)).to, PUBLIC_URI);
110
- assertEquals(loaderCalls > 0, true);
111
- });
112
- test("normalizePublicAudience() leaves @context subtrees untouched", async () => {
113
- const inlineCtx = (await normalizePublicAudience({
114
- "@context": [AS_CONTEXT, { "customTerm": "as:Public" }],
115
- type: "Note",
116
- id: "https://example.com/notes/context",
117
- to: PUBLIC_URI
118
- }))["@context"][1];
119
- assertEquals(inlineCtx.customTerm, "as:Public");
120
- });
121
- test("normalizePublicAudience() does not traverse prototype-polluted keys", async () => {
122
- const polluted = Object.create({ to: "as:Public" });
123
- polluted["@context"] = AS_CONTEXT;
124
- polluted.type = "Note";
125
- polluted.id = "https://example.com/notes/proto";
126
- const output = await normalizePublicAudience(polluted);
127
- assertEquals(Object.hasOwn(output, "to"), false);
128
- });
129
- test("normalizePublicAudience() stops before blowing the stack on pathological nesting", async () => {
130
- let deep = { to: "as:Public" };
131
- for (let i = 0; i < 256; i++) deep = { nested: deep };
132
- assertEquals(typeof await normalizePublicAudience({
133
- "@context": AS_CONTEXT,
134
- type: "Note",
135
- id: "https://example.com/notes/deep",
136
- to: "as:Public",
137
- object: deep
138
- }), "object");
139
- });
140
- test("normalizePublicAudience() does not poison the global prototype via a __proto__ key", async () => {
141
- await normalizePublicAudience(JSON.parse(`{
142
- "@context": "https://www.w3.org/ns/activitystreams",
143
- "type": "Note",
144
- "id": "https://example.com/notes/proto-pollution",
145
- "to": "as:Public",
146
- "__proto__": { "polluted": true }
147
- }`));
148
- assertEquals(Object.prototype.polluted, void 0);
149
- });
150
- test("normalizePublicAudience() bails out on nested @context that redefines as:", async () => {
151
- const output = await normalizePublicAudience({
152
- "@context": AS_CONTEXT,
153
- type: "Create",
154
- id: "https://example.com/activities/nested",
155
- actor: "https://example.com/alice",
156
- to: "as:Public",
157
- object: {
158
- "@context": { "as": "https://not-activitystreams.example/" },
159
- type: "https://www.w3.org/ns/activitystreams#Note",
160
- id: "https://example.com/objects/nested",
161
- to: "as:Public"
162
- }
163
- });
164
- assertEquals(output.to, "as:Public");
165
- const nested = output.object;
166
- assertEquals(nested.to, "as:Public");
167
- });
168
- test("normalizePublicAudience() bails out when the rewrite changes semantics", async () => {
169
- const output = await normalizePublicAudience({
170
- "@context": {
171
- "as": "https://not-activitystreams.example/",
172
- "to": {
173
- "@id": "https://www.w3.org/ns/activitystreams#to",
174
- "@type": "@id"
175
- },
176
- "type": "@type",
177
- "id": "@id"
178
- },
179
- type: "https://www.w3.org/ns/activitystreams#Note",
180
- id: "https://example.com/notes/5",
181
- to: "as:Public"
182
- });
183
- assertEquals(output.to, "as:Public");
184
- assertNotEquals(output.to, PUBLIC_URI);
185
- });
186
- //#endregion
187
- export {};
@@ -1,2 +0,0 @@
1
- import { Temporal } from "temporal-polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
@@ -1,58 +0,0 @@
1
- import "temporal-polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { t as assert } from "../assert-D1Eafmd_.mjs";
5
- import { t as isSelfContainedSecuredDocument } from "../secured-document-CxzZZ9nL.mjs";
6
- import { test } from "@fedify/fixture";
7
- //#region src/compat/secured-document.test.ts
8
- function securedDocument() {
9
- return {
10
- "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"],
11
- id: "ap://did:key:z6Mkabc/objects/1",
12
- type: "Note",
13
- content: "Hello",
14
- proof: {
15
- "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"],
16
- type: "DataIntegrityProof",
17
- cryptosuite: "eddsa-jcs-2022",
18
- created: "2023-02-24T23:36:38Z",
19
- verificationMethod: "did:key:z6Mkabc#z6Mkabc",
20
- proofPurpose: "assertionMethod",
21
- proofValue: "z3FXQ"
22
- }
23
- };
24
- }
25
- test("isSelfContainedSecuredDocument() accepts a complete secured document", () => {
26
- assert(isSelfContainedSecuredDocument(securedDocument()));
27
- const expandedType = securedDocument();
28
- expandedType.proof.type = "https://w3id.org/security#DataIntegrityProof";
29
- assert(isSelfContainedSecuredDocument(expandedType));
30
- const typeArray = securedDocument();
31
- typeArray.proof.type = ["DataIntegrityProof"];
32
- assert(isSelfContainedSecuredDocument(typeArray));
33
- });
34
- test("isSelfContainedSecuredDocument() rejects anything less", () => {
35
- assert(!isSelfContainedSecuredDocument(null));
36
- assert(!isSelfContainedSecuredDocument("string"));
37
- assert(!isSelfContainedSecuredDocument([securedDocument()]));
38
- for (const mutate of [
39
- (d) => delete d["@context"],
40
- (d) => d["@context"] = null,
41
- (d) => delete d.proof,
42
- (d) => d.proof = null,
43
- (d) => d.proof = [d.proof],
44
- (d) => d.proof.type = "SomethingElse",
45
- (d) => delete d.proof.cryptosuite,
46
- (d) => delete d.proof.created,
47
- (d) => delete d.proof.verificationMethod,
48
- (d) => delete d.proof.proofPurpose,
49
- (d) => d.proof.proofValue = "",
50
- (d) => d.proof.proofValue = 42
51
- ]) {
52
- const document = securedDocument();
53
- mutate(document);
54
- assert(!isSelfContainedSecuredDocument(document));
55
- }
56
- });
57
- //#endregion
58
- export {};
@@ -1,2 +0,0 @@
1
- import { Temporal } from "temporal-polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
@@ -1,62 +0,0 @@
1
- import "temporal-polyfill";
2
- import "urlpattern-polyfill";
3
- globalThis.addEventListener = () => {};
4
- import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
5
- import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
6
- import { t as assertInstanceOf } from "../assert_instance_of-mrXWWNY-.mjs";
7
- import { t as assert } from "../assert-D1Eafmd_.mjs";
8
- import { O as actorDehydrator, k as autoIdAssigner, n as FederationImpl } from "../middleware-D_W_LdJN.mjs";
9
- import { Follow, Person } from "@fedify/vocab";
10
- import { test } from "@fedify/fixture";
11
- //#region src/compat/transformers.test.ts
12
- const context = new FederationImpl({ kv: new MemoryKvStore() }).createContext(new URL("http://example.com/"));
13
- test("autoIdAssigner", async () => {
14
- const result = autoIdAssigner(new Follow({
15
- actor: new URL("http://example.com/actors/1"),
16
- object: new Person({
17
- id: new URL("http://example.com/actors/2"),
18
- name: "Bob",
19
- preferredUsername: "bob"
20
- })
21
- }), context);
22
- const { id } = result;
23
- assertInstanceOf(id, URL);
24
- assertEquals(id.origin, "http://example.com");
25
- assertEquals(id.pathname, "/");
26
- assertEquals(id.search, "");
27
- assert(id.hash.match(/^#Follow\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/));
28
- assertEquals(await result.toJsonLd(), await new Follow({
29
- id,
30
- actor: new URL("http://example.com/actors/1"),
31
- object: new Person({
32
- id: new URL("http://example.com/actors/2"),
33
- name: "Bob",
34
- preferredUsername: "bob"
35
- })
36
- }).toJsonLd());
37
- });
38
- test("actorDehydrator()", async () => {
39
- assertEquals(await actorDehydrator(new Follow({
40
- id: new URL("http://example.com/activities/1"),
41
- actor: new Person({
42
- id: new URL("http://example.com/actors/1"),
43
- name: "Alice",
44
- preferredUsername: "alice"
45
- }),
46
- object: new Person({
47
- id: new URL("http://example.com/actors/2"),
48
- name: "Bob",
49
- preferredUsername: "bob"
50
- })
51
- }), context).toJsonLd(), await new Follow({
52
- id: new URL("http://example.com/activities/1"),
53
- actor: new URL("http://example.com/actors/1"),
54
- object: new Person({
55
- id: new URL("http://example.com/actors/2"),
56
- name: "Bob",
57
- preferredUsername: "bob"
58
- })
59
- }).toJsonLd());
60
- });
61
- //#endregion
62
- export {};