@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,2 +0,0 @@
1
- import { Temporal } from "temporal-polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
@@ -1,348 +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 assertFalse } from "../assert_false-CPdRnc3E.mjs";
7
- import "../std__assert-DvMDRPes.mjs";
8
- import { t as assert } from "../assert-D1Eafmd_.mjs";
9
- import { r as ed25519PublicKey } from "../keys-DIJNHW-Y.mjs";
10
- import { o as createFederation } from "../middleware-D_W_LdJN.mjs";
11
- import { Note, Object as Object$1, Person } from "@fedify/vocab";
12
- import { exportDidKey, parseIri } from "@fedify/vocab-runtime";
13
- import { test } from "@fedify/fixture";
14
- //#region src/federation/portable-parse-uri.test.ts
15
- const did = await exportDidKey(ed25519PublicKey.publicKey);
16
- const otherDid = await exportDidKey((await crypto.subtle.generateKey("Ed25519", true, ["sign", "verify"])).publicKey);
17
- const encodedDid = encodeURIComponent(did);
18
- const ORIGIN = "https://example.com";
19
- const NOTE_TYPE_ID = new URL("https://www.w3.org/ns/activitystreams#Note");
20
- const OBJECT_TYPE_ID = new URL("https://www.w3.org/ns/activitystreams#Object");
21
- function createTestFederation() {
22
- const calls = [];
23
- const federation = createFederation({ kv: new MemoryKvStore() });
24
- federation.setActorDispatcher("/users/{identifier}", (_ctx, identifier) => {
25
- calls.push(`actor:${identifier}`);
26
- return new Person({});
27
- }).mapActorAlias("/bot", "bot").mapPortableActorId((_ctx, identifier) => {
28
- calls.push(`portableActorId:${identifier}`);
29
- return null;
30
- });
31
- federation.setObjectDispatcher(Note, "/users/{identifier}/notes/{id}", () => {
32
- calls.push("object");
33
- return null;
34
- });
35
- federation.setInboxListeners("/users/{identifier}/inbox", "/inbox");
36
- federation.setOutboxDispatcher("/users/{identifier}/outbox", () => null);
37
- federation.setFollowingDispatcher("/users/{identifier}/following", () => null);
38
- federation.setFollowersDispatcher("/users/{identifier}/followers", () => null);
39
- federation.setLikedDispatcher("/users/{identifier}/liked", () => null);
40
- federation.setFeaturedDispatcher("/users/{identifier}/featured", () => null);
41
- federation.setFeaturedTagsDispatcher("/users/{identifier}/tags", () => null);
42
- federation.setCollectionDispatcher("bookmarks", Object$1, "/users/{identifier}/bookmarks", () => null).mapPortableOwner((_ctx, values) => {
43
- calls.push(`portableOwner:${values.identifier}`);
44
- return values.identifier;
45
- });
46
- federation.setOrderedCollectionDispatcher("pins", Note, "/users/{identifier}/pins", () => null);
47
- return {
48
- federation,
49
- ctx: federation.createContext(new URL(ORIGIN)),
50
- calls
51
- };
52
- }
53
- function portableId(path, authority = did) {
54
- return parseIri(`ap+ef61://${authority}${path}`);
55
- }
56
- function compatibleId(path, origin = ORIGIN, authority = did) {
57
- return new URL(`${origin}/.well-known/apgateway/${authority}${path}`);
58
- }
59
- function parsePortable(ctx, uri) {
60
- return ctx.parseUri(uri, { portable: true });
61
- }
62
- test("Context.parseUri() does not recognize portable IDs by default", () => {
63
- const { ctx } = createTestFederation();
64
- for (const uri of [
65
- portableId("/users/alice"),
66
- parseIri(`ap://${did}/users/alice`),
67
- compatibleId("/users/alice"),
68
- compatibleId("/users/alice", "https://gateway.example")
69
- ]) {
70
- assertEquals(ctx.parseUri(uri), null, uri.href);
71
- assertEquals(ctx.parseUri(uri, {}), null, uri.href);
72
- assertEquals(ctx.parseUri(uri, { portable: false }), null, uri.href);
73
- }
74
- });
75
- test("Context.parseUri() keeps the results of ordinary URIs", () => {
76
- const { ctx } = createTestFederation();
77
- for (const path of [
78
- "/users/alice",
79
- "/bot",
80
- "/users/alice/notes/123",
81
- "/inbox",
82
- "/users/alice/inbox",
83
- "/users/alice/outbox",
84
- "/users/alice/following",
85
- "/users/alice/followers",
86
- "/users/alice/liked",
87
- "/users/alice/featured",
88
- "/users/alice/tags",
89
- "/users/alice/bookmarks",
90
- "/users/alice/pins",
91
- "/nowhere"
92
- ]) {
93
- const uri = new URL(path, ORIGIN);
94
- const result = ctx.parseUri(uri);
95
- assertEquals(parsePortable(ctx, uri), result, path);
96
- if (result != null) assertFalse("authority" in result, path);
97
- }
98
- assertEquals(parsePortable(ctx, new URL("https://other.example/users/alice")), null);
99
- assertEquals(ctx.parseUri(null, { portable: true }), null);
100
- });
101
- test("Context.parseUri() recognizes portable IDs", () => {
102
- const { ctx, calls } = createTestFederation();
103
- const identifier = "alice";
104
- const cases = [
105
- ["/users/alice", {
106
- type: "actor",
107
- identifier,
108
- authority: did
109
- }],
110
- ["/bot", {
111
- type: "actor",
112
- identifier: "bot",
113
- authority: did
114
- }],
115
- ["/users/alice/notes/123", {
116
- type: "object",
117
- class: Note,
118
- typeId: NOTE_TYPE_ID,
119
- values: {
120
- identifier,
121
- id: "123"
122
- },
123
- authority: did
124
- }],
125
- ["/users/alice/inbox", {
126
- type: "inbox",
127
- identifier,
128
- authority: did
129
- }],
130
- ["/users/alice/outbox", {
131
- type: "outbox",
132
- identifier,
133
- authority: did
134
- }],
135
- ["/users/alice/following", {
136
- type: "following",
137
- identifier,
138
- authority: did
139
- }],
140
- ["/users/alice/followers", {
141
- type: "followers",
142
- identifier,
143
- authority: did
144
- }],
145
- ["/users/alice/liked", {
146
- type: "liked",
147
- identifier,
148
- authority: did
149
- }],
150
- ["/users/alice/featured", {
151
- type: "featured",
152
- identifier,
153
- authority: did
154
- }],
155
- ["/users/alice/tags", {
156
- type: "featuredTags",
157
- identifier,
158
- authority: did
159
- }],
160
- ["/users/alice/bookmarks", {
161
- type: "collection",
162
- name: "bookmarks",
163
- class: Object$1,
164
- typeId: OBJECT_TYPE_ID,
165
- values: { identifier },
166
- authority: did
167
- }],
168
- ["/users/alice/pins", {
169
- type: "orderedCollection",
170
- name: "pins",
171
- class: Note,
172
- typeId: NOTE_TYPE_ID,
173
- values: { identifier },
174
- authority: did
175
- }]
176
- ];
177
- for (const [path, expected] of cases) for (const uri of [
178
- portableId(path),
179
- parseIri(`ap://${did}${path}`),
180
- new URL(`ap+ef61://${encodedDid}${path}`),
181
- new URL(`ap://${encodedDid}${path}`),
182
- compatibleId(path),
183
- compatibleId(path, "https://gateway.example"),
184
- compatibleId(path, "http://localhost:8000")
185
- ]) assertEquals(parsePortable(ctx, uri), expected, uri.href);
186
- assertEquals(calls, []);
187
- });
188
- test("Context.parseUri() round-trips the portable ID helpers", () => {
189
- const { ctx } = createTestFederation();
190
- const uris = [
191
- [ctx.getPortableActorUri("alice", did), "actor"],
192
- [ctx.getPortableObjectUri(Note, {
193
- identifier: "alice",
194
- id: "1"
195
- }, did), "object"],
196
- [ctx.getPortableInboxUri("alice", did), "inbox"],
197
- [ctx.getPortableOutboxUri("alice", did), "outbox"],
198
- [ctx.getPortableFollowingUri("alice", did), "following"],
199
- [ctx.getPortableFollowersUri("alice", did), "followers"],
200
- [ctx.getPortableLikedUri("alice", did), "liked"],
201
- [ctx.getPortableFeaturedUri("alice", did), "featured"],
202
- [ctx.getPortableFeaturedTagsUri("alice", did), "featuredTags"],
203
- [ctx.getPortableCollectionUri("bookmarks", { identifier: "alice" }, did), "collection"],
204
- [ctx.getPortableCollectionUri("pins", { identifier: "alice" }, did), "orderedCollection"]
205
- ];
206
- for (const [uri, type] of uris) {
207
- const result = parsePortable(ctx, uri);
208
- assertEquals(result?.type, type, uri.href);
209
- assertEquals(result?.authority, did, uri.href);
210
- }
211
- });
212
- test("Context.parseUri() returns any DID for the caller to check", () => {
213
- const { ctx } = createTestFederation();
214
- assertEquals(parsePortable(ctx, portableId("/users/alice", otherDid)), {
215
- type: "actor",
216
- identifier: "alice",
217
- authority: otherDid
218
- });
219
- assertEquals(parsePortable(ctx, compatibleId("/users/alice", "https://gateway.example", otherDid)), {
220
- type: "actor",
221
- identifier: "alice",
222
- authority: otherDid
223
- });
224
- assertEquals(parsePortable(ctx, portableId("/users/alice", "did:web:example.com")), {
225
- type: "actor",
226
- identifier: "alice",
227
- authority: "did:web:example.com"
228
- });
229
- assertEquals(parsePortable(ctx, parseIri(`ap://DID:KEY:${did.slice(8)}/users/alice`)), {
230
- type: "actor",
231
- identifier: "alice",
232
- authority: did
233
- });
234
- assertEquals(parsePortable(ctx, new URL(`ap://DID%3Akey%3A${did.slice(8)}/users/alice`)), {
235
- type: "actor",
236
- identifier: "alice",
237
- authority: did
238
- });
239
- });
240
- test("Context.parseUri() ignores the query and fragment of portable IDs", () => {
241
- const { ctx } = createTestFederation();
242
- const expected = {
243
- type: "actor",
244
- identifier: "alice",
245
- authority: did
246
- };
247
- const hint = "@gateway=https%3A%2F%2Fgateway.example";
248
- for (const uri of [
249
- parseIri(`ap://${did}/users/alice?${hint}`),
250
- portableId("/users/alice#main-key"),
251
- new URL(`${compatibleId("/users/alice").href}?${hint}`),
252
- new URL(`${compatibleId("/users/alice").href}#main-key`)
253
- ]) assertEquals(parsePortable(ctx, uri), expected, uri.href);
254
- });
255
- test("Context.parseUri() routes portable paths like ordinary ones", () => {
256
- const { ctx } = createTestFederation();
257
- for (const path of [
258
- "/users/alice/",
259
- "/users/alice/notes/",
260
- "/users"
261
- ]) {
262
- const ordinary = ctx.parseUri(new URL(path, ORIGIN));
263
- const expected = ordinary == null ? null : {
264
- ...ordinary,
265
- authority: did
266
- };
267
- assertEquals(parsePortable(ctx, portableId(path)), expected, path);
268
- assertEquals(parsePortable(ctx, compatibleId(path)), expected, path);
269
- }
270
- });
271
- test("Context.parseUri() does not recognize unroutable portable IDs", () => {
272
- const { ctx } = createTestFederation();
273
- for (const uri of [
274
- portableId("/nowhere"),
275
- compatibleId("/nowhere"),
276
- portableId("/inbox"),
277
- compatibleId("/inbox"),
278
- compatibleId("/inbox", "https://gateway.example"),
279
- new URL(`${ORIGIN}/.well-known/apgateway`),
280
- new URL(`${ORIGIN}/.well-known/apgateway/users/alice`),
281
- new URL(`${ORIGIN}/.well-known/apgateway/hl:zQmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n`)
282
- ]) assertEquals(parsePortable(ctx, uri), null, uri.href);
283
- });
284
- test("Context.parseUri() does not recognize malformed portable IDs", () => {
285
- const { ctx } = createTestFederation();
286
- const base64UrlDid = `did:key:u${did.slice(8).slice(1)}`;
287
- for (const uri of [
288
- new URL(`ap+ef61://${encodeURIComponent(base64UrlDid)}/users/alice`),
289
- compatibleId("/users/alice", ORIGIN, base64UrlDid),
290
- new URL("ap+ef61://did%3Akey/users/alice"),
291
- new URL("ap+ef61://example.com/users/alice"),
292
- compatibleId("/users/alice", ORIGIN, "did:"),
293
- compatibleId("/users/alice", "https://gateway.example", "did:key"),
294
- new URL(`ap+ef61://${encodedDid}/users/%ZZ`),
295
- new URL(`${compatibleId("/users/").href}%ZZ`),
296
- new URL(`ap+ef61://user:pass@${encodedDid}/users/alice`),
297
- new URL(`https://user:pass@gateway.example/.well-known/apgateway/${did}/users/alice`)
298
- ]) assertEquals(parsePortable(ctx, uri), null, uri.href);
299
- });
300
- test("Context.parseUri() prefers the application's routes", () => {
301
- const federation = createFederation({ kv: new MemoryKvStore() });
302
- federation.setActorDispatcher("/users/{identifier}", () => null);
303
- federation.setObjectDispatcher(Note, "/.well-known/apgateway/{+did}/users/{identifier}/notes/{id}", () => null);
304
- federation.setNodeInfoDispatcher(`/.well-known/apgateway/${did}/users/alice`, () => ({
305
- software: {
306
- name: "test",
307
- version: "1.0.0"
308
- },
309
- protocols: ["activitypub"],
310
- usage: {
311
- users: {},
312
- localPosts: 0,
313
- localComments: 0
314
- }
315
- }));
316
- const ctx = federation.createContext(new URL(ORIGIN));
317
- assertEquals(parsePortable(ctx, compatibleId("/users/alice")), null);
318
- assertEquals(parsePortable(ctx, compatibleId("/users/alice", "https://gateway.example")), {
319
- type: "actor",
320
- identifier: "alice",
321
- authority: did
322
- });
323
- const note = parsePortable(ctx, compatibleId("/users/alice/notes/1"));
324
- assert(note?.type === "object");
325
- assertEquals(note.values, {
326
- did,
327
- identifier: "alice",
328
- id: "1"
329
- });
330
- assertFalse("authority" in note);
331
- assertEquals(parsePortable(ctx, portableId("/users/alice")), {
332
- type: "actor",
333
- identifier: "alice",
334
- authority: did
335
- });
336
- });
337
- test("RequestContext.parseUri() recognizes portable IDs", () => {
338
- const { federation } = createTestFederation();
339
- const ctx = federation.createContext(new Request(compatibleId("/users/alice")), void 0);
340
- assertEquals(ctx.parseUri(portableId("/users/alice")), null);
341
- assertEquals(ctx.parseUri(portableId("/users/alice", otherDid), { portable: true }), {
342
- type: "actor",
343
- identifier: "alice",
344
- authority: otherDid
345
- });
346
- });
347
- //#endregion
348
- export {};
@@ -1,2 +0,0 @@
1
- import { Temporal } from "temporal-polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
@@ -1,259 +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 assertFalse } from "../assert_false-CPdRnc3E.mjs";
7
- import "../std__assert-DvMDRPes.mjs";
8
- import { t as assert } from "../assert-D1Eafmd_.mjs";
9
- import { s as signObject } from "../proof-Y7omSVvc.mjs";
10
- import { n as ed25519PrivateKey, r as ed25519PublicKey } from "../keys-DIJNHW-Y.mjs";
11
- import { o as createFederation } from "../middleware-D_W_LdJN.mjs";
12
- import { Create, Note } from "@fedify/vocab";
13
- import { exportDidKey, formatIri, parseIri, toCompatibleEf61Id } from "@fedify/vocab-runtime";
14
- import { mockDocumentLoader, test } from "@fedify/fixture";
15
- //#region src/federation/portable-route-activity.test.ts
16
- const did = await exportDidKey(ed25519PublicKey.publicKey);
17
- const keyId = new URL(`${did}#${did.slice(8)}`);
18
- const otherKeyPair = await crypto.subtle.generateKey("Ed25519", true, ["sign", "verify"]);
19
- const otherDid = await exportDidKey(otherKeyPair.publicKey);
20
- const otherKeyId = new URL(`${otherDid}#${otherDid.slice(8)}`);
21
- const GATEWAY = "https://gw.example";
22
- function portableId(authority, path) {
23
- return parseIri(`ap+ef61://${authority}${path}`);
24
- }
25
- function compatibleId(authority, path, gateway = GATEWAY) {
26
- return new URL(`${gateway}/.well-known/apgateway/${authority}${path}`);
27
- }
28
- async function sign(activity, signer) {
29
- return await signObject(activity, signer === "did" ? ed25519PrivateKey : otherKeyPair.privateKey, signer === "did" ? keyId : otherKeyId, { contextLoader: mockDocumentLoader });
30
- }
31
- /**
32
- * Routes a `Create` activity with the given ID through
33
- * `Context.routeActivity()`. Unless `activity` is an `Activity`, the routed
34
- * activity has no proof, so that it is trusted only if it can be dereferenced
35
- * by its ID, which serves `served`.
36
- * @returns Whether the activity was routed, and the IDs of the actors of
37
- * the activities that reached the inbox listener.
38
- */
39
- async function route(activity, { served, actors } = {}) {
40
- const documents = /* @__PURE__ */ new Map();
41
- if (served != null && activity instanceof URL) {
42
- const document = await served.toJsonLd({ contextLoader: mockDocumentLoader });
43
- documents.set(activity.href, document);
44
- if (activity.protocol === "ap+ef61:") {
45
- documents.set(formatIri(activity), document);
46
- documents.set(toCompatibleEf61Id(activity, GATEWAY).href, document);
47
- }
48
- }
49
- const documentLoader = (url, options) => {
50
- if (documents.has(url)) return Promise.resolve({
51
- contextUrl: null,
52
- documentUrl: url,
53
- document: documents.get(url)
54
- });
55
- return mockDocumentLoader(url, options);
56
- };
57
- const federation = createFederation({
58
- kv: new MemoryKvStore(),
59
- documentLoaderFactory: () => documentLoader,
60
- contextLoaderFactory: () => mockDocumentLoader
61
- });
62
- const received = [];
63
- federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, (_ctx, create) => {
64
- received.push(...create.actorIds.map((id) => id.href));
65
- });
66
- return {
67
- routed: await federation.createContext(new URL("https://example.com/")).routeActivity(null, activity instanceof URL ? new Create({
68
- id: activity,
69
- actors: [...actors ?? served?.actorIds ?? []]
70
- }) : activity),
71
- received
72
- };
73
- }
74
- async function portableCreate(id, actors, signer = "did") {
75
- return await sign(new Create({
76
- id,
77
- actors: [...actors],
78
- object: new Note({ content: "Hello" })
79
- }), signer);
80
- }
81
- test("Context.routeActivity() rejects portable activities attributed to other DIDs", async (t) => {
82
- const cases = [
83
- [
84
- "ap+ef61: IDs",
85
- portableId(did, "/activities/1"),
86
- [portableId(otherDid, "/actor")]
87
- ],
88
- [
89
- "compatible identifiers on one gateway",
90
- compatibleId(did, "/activities/1"),
91
- [compatibleId(otherDid, "/actor")]
92
- ],
93
- [
94
- "compatible activity ID and ap+ef61: actor ID",
95
- compatibleId(did, "/activities/1"),
96
- [portableId(otherDid, "/actor")]
97
- ],
98
- [
99
- "ap+ef61: activity ID and compatible actor ID",
100
- portableId(did, "/activities/1"),
101
- [compatibleId(otherDid, "/actor")]
102
- ],
103
- [
104
- "one of multiple actors with another DID",
105
- portableId(did, "/activities/1"),
106
- [portableId(did, "/actor"), portableId(otherDid, "/actor")]
107
- ],
108
- [
109
- "ap+ef61: activity ID and HTTP(S) actor ID",
110
- portableId(did, "/activities/1"),
111
- [new URL("https://example.com/person")]
112
- ],
113
- [
114
- "compatible activity ID and HTTP(S) actor ID on the gateway",
115
- compatibleId(did, "/activities/1"),
116
- [new URL(`${GATEWAY}/users/alice`)]
117
- ]
118
- ];
119
- for (const [name, id, actors] of cases) await t.step(name, async () => {
120
- const served = await portableCreate(id, actors);
121
- assertEquals(await route(id, { served }), {
122
- routed: false,
123
- received: []
124
- });
125
- assertEquals(await route(served), {
126
- routed: false,
127
- received: []
128
- });
129
- });
130
- });
131
- test("Context.routeActivity() accepts portable activities of the same DID", async (t) => {
132
- const cases = [
133
- [
134
- "ap+ef61: IDs",
135
- portableId(did, "/activities/1"),
136
- [portableId(did, "/actor")]
137
- ],
138
- [
139
- "compatible identifiers on one gateway",
140
- compatibleId(did, "/activities/1"),
141
- [compatibleId(did, "/actor")]
142
- ],
143
- [
144
- "compatible identifiers on different gateways",
145
- compatibleId(did, "/activities/1"),
146
- [compatibleId(did, "/actor", "https://gw2.example")]
147
- ],
148
- [
149
- "compatible activity ID and ap+ef61: actor ID",
150
- compatibleId(did, "/activities/1"),
151
- [portableId(did, "/actor")]
152
- ],
153
- [
154
- "ap+ef61: activity ID and compatible actor ID",
155
- portableId(did, "/activities/1"),
156
- [compatibleId(did, "/actor")]
157
- ],
158
- [
159
- "actor ID with a location hint",
160
- portableId(did, "/activities/1"),
161
- [portableId(did, `/actor?@gateway=${encodeURIComponent(GATEWAY)}`)]
162
- ]
163
- ];
164
- for (const [name, id, actors] of cases) await t.step(name, async () => {
165
- const served = await portableCreate(id, actors);
166
- const expected = {
167
- routed: true,
168
- received: actors.map((actor) => actor.href)
169
- };
170
- assertEquals(await route(id, { served }), expected);
171
- assertEquals(await route(served), expected);
172
- });
173
- });
174
- test("Context.routeActivity() compares portable activity IDs canonically", async (t) => {
175
- const id = portableId(did, "/activities/1");
176
- const actors = [portableId(did, "/actor")];
177
- await t.step("compatible ID serving an ap+ef61: ID", async () => {
178
- const served = await portableCreate(id, actors);
179
- const { routed } = await route(compatibleId(did, "/activities/1"), { served });
180
- assert(routed);
181
- });
182
- await t.step("ap+ef61: ID serving a compatible ID", async () => {
183
- const served = await portableCreate(compatibleId(did, "/activities/1"), actors);
184
- const { routed } = await route(id, { served });
185
- assert(routed);
186
- });
187
- await t.step("ap+ef61: ID with a location hint", async () => {
188
- const served = await portableCreate(id, actors);
189
- const { routed } = await route(portableId(did, `/activities/1?@gateway=${encodeURIComponent(GATEWAY)}`), { served });
190
- assert(routed);
191
- });
192
- await t.step("another path of the same DID", async () => {
193
- const served = await portableCreate(portableId(did, "/activities/2"), actors);
194
- const { routed } = await route(id, { served });
195
- assertFalse(routed);
196
- });
197
- await t.step("another fragment of the same DID", async () => {
198
- const served = await portableCreate(portableId(did, "/activities/1#other"), actors);
199
- const { routed } = await route(id, { served });
200
- assertFalse(routed);
201
- });
202
- });
203
- test("Context.routeActivity() rejects proofs of other DIDs for portable actors", async () => {
204
- const id = portableId(did, "/activities/1");
205
- const actors = [portableId(did, "/actor")];
206
- assertEquals(await route(await portableCreate(id, actors, "otherDid")), {
207
- routed: false,
208
- received: []
209
- });
210
- assertEquals(await route(await portableCreate(id, actors)), {
211
- routed: true,
212
- received: actors.map((actor) => actor.href)
213
- });
214
- });
215
- test("Context.routeActivity() keeps comparing web origins of HTTP(S) IDs", async (t) => {
216
- const cases = [
217
- [
218
- "same origin",
219
- new URL("https://remote.example/activities/1"),
220
- new URL("https://remote.example/users/alice"),
221
- true
222
- ],
223
- [
224
- "same origin with an explicit default port",
225
- new URL("https://remote.example/activities/1"),
226
- new URL("https://remote.example:443/users/alice"),
227
- true
228
- ],
229
- [
230
- "another origin",
231
- new URL("https://remote.example/activities/1"),
232
- new URL("https://other.example/users/alice"),
233
- false
234
- ],
235
- [
236
- "another port",
237
- new URL("https://remote.example/activities/1"),
238
- new URL("https://remote.example:8443/users/alice"),
239
- false
240
- ],
241
- [
242
- "compatible actor ID on the same host",
243
- new URL("https://remote.example/activities/1"),
244
- compatibleId(did, "/actor", "https://remote.example"),
245
- false
246
- ]
247
- ];
248
- for (const [name, id, actor, expected] of cases) await t.step(name, async () => {
249
- const served = new Create({
250
- id,
251
- actor
252
- });
253
- const { routed, received } = await route(id, { served });
254
- assertEquals(routed, expected);
255
- assertEquals(received, expected ? [actor.href] : []);
256
- });
257
- });
258
- //#endregion
259
- export {};
@@ -1,2 +0,0 @@
1
- import { Temporal } from "temporal-polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";