@fedify/fedify 2.5.0-dev.2687 → 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 (244) hide show
  1. package/dist/federation/mod.cjs +1 -1
  2. package/dist/federation/mod.js +1 -1
  3. package/dist/{federation-pFFwPyoZ.cjs → federation-JvzYDx0P.cjs} +3 -3
  4. package/dist/{http-CXX-QPzs.cjs → http-BG5cDmTS.cjs} +1 -1
  5. package/dist/{http-T7h9GBAN.js → http-MUf125Jc.js} +1 -1
  6. package/dist/{kv-cache-C6XX_fwz.cjs → kv-cache-A2po7h0_.cjs} +1 -1
  7. package/dist/{kv-cache-EFcb1kkU.js → kv-cache-CbWc1BZA.js} +1 -1
  8. package/dist/{middleware-Bj91r7r2.js → middleware-DzzdJ7Wz.js} +3 -3
  9. package/dist/mod.cjs +4 -4
  10. package/dist/mod.js +4 -4
  11. package/dist/{portable-collection-Do5QA2oy.js → portable-collection-CAer9RWN.js} +1 -1
  12. package/dist/{portable-collection-BOl9oKrt.cjs → portable-collection-d8w7TCn9.cjs} +1 -1
  13. package/dist/sig/mod.cjs +2 -2
  14. package/dist/sig/mod.js +2 -2
  15. package/dist/utils/mod.cjs +1 -1
  16. package/dist/utils/mod.js +1 -1
  17. package/package.json +22 -9
  18. package/skills/fedify/SKILL.md +10 -0
  19. package/dist/accept-CPVqki78.mjs +0 -145
  20. package/dist/activity-listener-CELFAodc.mjs +0 -44
  21. package/dist/assert-D1Eafmd_.mjs +0 -23
  22. package/dist/assert_equals-Z6IcEbWU.mjs +0 -987
  23. package/dist/assert_exists-cffSpJ7X.mjs +0 -28
  24. package/dist/assert_false-CPdRnc3E.mjs +0 -23
  25. package/dist/assert_greater_or_equal-BlafOF4-.mjs +0 -31
  26. package/dist/assert_instance_of-mrXWWNY-.mjs +0 -37
  27. package/dist/assert_not_equals-CpPK2t89.mjs +0 -30
  28. package/dist/assert_rejects-CTptdYck.mjs +0 -39
  29. package/dist/assert_strict_equals-CYvBmkpC.mjs +0 -42
  30. package/dist/assert_throws-BYITOvPO.mjs +0 -74
  31. package/dist/assertion_error-B-cx0fFA.mjs +0 -31
  32. package/dist/audience-CHQ-FlLD.mjs +0 -95
  33. package/dist/builder-D1FP_5nQ.mjs +0 -911
  34. package/dist/circuit-breaker-XJ53md4S.mjs +0 -544
  35. package/dist/circuit-breaker-test-utils-DW6YC_Pe.mjs +0 -14
  36. package/dist/client-5SIFzW3q.mjs +0 -441
  37. package/dist/codec-C6rTrpIp.mjs +0 -147
  38. package/dist/collection-CnnP1UAv.mjs +0 -44
  39. package/dist/compat/outgoing-jsonld.test.d.mts +0 -2
  40. package/dist/compat/outgoing-jsonld.test.mjs +0 -257
  41. package/dist/compat/public-audience.test.d.mts +0 -2
  42. package/dist/compat/public-audience.test.mjs +0 -187
  43. package/dist/compat/secured-document.test.d.mts +0 -2
  44. package/dist/compat/secured-document.test.mjs +0 -58
  45. package/dist/compat/transformers.test.d.mts +0 -2
  46. package/dist/compat/transformers.test.mjs +0 -62
  47. package/dist/compound-proof-DSHhnOEW.mjs +0 -1019
  48. package/dist/context-LgGFFSz7.mjs +0 -146
  49. package/dist/deno-C50ikGBU.mjs +0 -8
  50. package/dist/dist-_geWsuaI.mjs +0 -189
  51. package/dist/docloader-BY-SEID0.mjs +0 -136
  52. package/dist/esm-BHXXx4Wx.mjs +0 -1233
  53. package/dist/exporter-DVG68ozH.mjs +0 -263
  54. package/dist/federation/audience.test.d.mts +0 -2
  55. package/dist/federation/audience.test.mjs +0 -130
  56. package/dist/federation/builder.test.d.mts +0 -2
  57. package/dist/federation/builder.test.mjs +0 -396
  58. package/dist/federation/circuit-breaker.test.d.mts +0 -2
  59. package/dist/federation/circuit-breaker.test.mjs +0 -1277
  60. package/dist/federation/collection.test.d.mts +0 -2
  61. package/dist/federation/collection.test.mjs +0 -21
  62. package/dist/federation/compound-fanout.test.d.mts +0 -2
  63. package/dist/federation/compound-fanout.test.mjs +0 -231
  64. package/dist/federation/handler-compound-proof.test.d.mts +0 -2
  65. package/dist/federation/handler-compound-proof.test.mjs +0 -384
  66. package/dist/federation/handler.test.d.mts +0 -2
  67. package/dist/federation/handler.test.mjs +0 -5445
  68. package/dist/federation/hashlink-media.test.d.mts +0 -2
  69. package/dist/federation/hashlink-media.test.mjs +0 -422
  70. package/dist/federation/idempotency.test.d.mts +0 -2
  71. package/dist/federation/idempotency.test.mjs +0 -207
  72. package/dist/federation/inbox-actorless.test.d.mts +0 -2
  73. package/dist/federation/inbox-actorless.test.mjs +0 -522
  74. package/dist/federation/inbox-authentication.test.d.mts +0 -2
  75. package/dist/federation/inbox-authentication.test.mjs +0 -220
  76. package/dist/federation/inbox-report.test.d.mts +0 -2
  77. package/dist/federation/inbox-report.test.mjs +0 -719
  78. package/dist/federation/inbox-view.test.d.mts +0 -2
  79. package/dist/federation/inbox-view.test.mjs +0 -369
  80. package/dist/federation/inbox.test.d.mts +0 -2
  81. package/dist/federation/inbox.test.mjs +0 -139
  82. package/dist/federation/keycache.test.d.mts +0 -2
  83. package/dist/federation/keycache.test.mjs +0 -337
  84. package/dist/federation/kv.test.d.mts +0 -2
  85. package/dist/federation/kv.test.mjs +0 -88
  86. package/dist/federation/metrics.test.d.mts +0 -2
  87. package/dist/federation/metrics.test.mjs +0 -634
  88. package/dist/federation/middleware.test.d.mts +0 -2
  89. package/dist/federation/middleware.test.mjs +0 -9314
  90. package/dist/federation/mq.test.d.mts +0 -2
  91. package/dist/federation/mq.test.mjs +0 -591
  92. package/dist/federation/negotiation.test.d.mts +0 -2
  93. package/dist/federation/negotiation.test.mjs +0 -18
  94. package/dist/federation/outbound-body.test.d.mts +0 -2
  95. package/dist/federation/outbound-body.test.mjs +0 -149
  96. package/dist/federation/outbound-capture.test.d.mts +0 -2
  97. package/dist/federation/outbound-capture.test.mjs +0 -394
  98. package/dist/federation/outbound-dispatch.test.d.mts +0 -2
  99. package/dist/federation/outbound-dispatch.test.mjs +0 -368
  100. package/dist/federation/outbound-document.test.d.mts +0 -2
  101. package/dist/federation/outbound-document.test.mjs +0 -171
  102. package/dist/federation/outbound-provenance.test.d.mts +0 -2
  103. package/dist/federation/outbound-provenance.test.mjs +0 -543
  104. package/dist/federation/outbound-report.test.d.mts +0 -2
  105. package/dist/federation/outbound-report.test.mjs +0 -5475
  106. package/dist/federation/outbound-workers.test.d.mts +0 -2
  107. package/dist/federation/outbound-workers.test.mjs +0 -64
  108. package/dist/federation/outbound-workflow.test.d.mts +0 -2
  109. package/dist/federation/outbound-workflow.test.mjs +0 -154
  110. package/dist/federation/outgoing-proof.test.d.mts +0 -2
  111. package/dist/federation/outgoing-proof.test.mjs +0 -933
  112. package/dist/federation/portable-actor.test.d.mts +0 -2
  113. package/dist/federation/portable-actor.test.mjs +0 -496
  114. package/dist/federation/portable-chain.test.d.mts +0 -2
  115. package/dist/federation/portable-chain.test.mjs +0 -370
  116. package/dist/federation/portable-collection.test.d.mts +0 -2
  117. package/dist/federation/portable-collection.test.mjs +0 -832
  118. package/dist/federation/portable-delivery.test.d.mts +0 -2
  119. package/dist/federation/portable-delivery.test.mjs +0 -845
  120. package/dist/federation/portable-gateway-keys.test.d.mts +0 -2
  121. package/dist/federation/portable-gateway-keys.test.mjs +0 -692
  122. package/dist/federation/portable-inbox.test.d.mts +0 -2
  123. package/dist/federation/portable-inbox.test.mjs +0 -1960
  124. package/dist/federation/portable-parse-uri.test.d.mts +0 -2
  125. package/dist/federation/portable-parse-uri.test.mjs +0 -348
  126. package/dist/federation/portable-route-activity.test.d.mts +0 -2
  127. package/dist/federation/portable-route-activity.test.mjs +0 -259
  128. package/dist/federation/portable.test.d.mts +0 -2
  129. package/dist/federation/portable.test.mjs +0 -1072
  130. package/dist/federation/retry.test.d.mts +0 -2
  131. package/dist/federation/retry.test.mjs +0 -42
  132. package/dist/federation/router.test.d.mts +0 -2
  133. package/dist/federation/router.test.mjs +0 -123
  134. package/dist/federation/send.test.d.mts +0 -2
  135. package/dist/federation/send.test.mjs +0 -1421
  136. package/dist/federation/tasks/codec.test.d.mts +0 -2
  137. package/dist/federation/tasks/codec.test.mjs +0 -302
  138. package/dist/federation/tasks/enqueue.test.d.mts +0 -2
  139. package/dist/federation/tasks/enqueue.test.mjs +0 -1095
  140. package/dist/federation/tasks/tasks.test.d.mts +0 -2
  141. package/dist/federation/tasks/tasks.test.mjs +0 -1229
  142. package/dist/federation/temporal.test.d.mts +0 -2
  143. package/dist/federation/temporal.test.mjs +0 -71
  144. package/dist/federation/webfinger.test.d.mts +0 -2
  145. package/dist/federation/webfinger.test.mjs +0 -944
  146. package/dist/http-BXbQQZDM.mjs +0 -1449
  147. package/dist/inbox-authentication-CgonVRkg.mjs +0 -198
  148. package/dist/inbox-cS97XzOD.mjs +0 -399
  149. package/dist/inbox-view-D-d0Ar6o.mjs +0 -385
  150. package/dist/key-owner-evidence-APB6NpSk.mjs +0 -108
  151. package/dist/keycache-N2opu4-3.mjs +0 -221
  152. package/dist/keys-DIJNHW-Y.mjs +0 -120
  153. package/dist/kv-DBRWVx3Q.mjs +0 -104
  154. package/dist/kv-DCHkaJ9-.mjs +0 -92
  155. package/dist/kv-cache-fgbLHGVL.mjs +0 -121
  156. package/dist/ld-BpkhkDGj.mjs +0 -1752
  157. package/dist/map-local-context-conflict-DOYEEJ3u.mjs +0 -204
  158. package/dist/map-local-create-note-B0SeXJms.mjs +0 -214
  159. package/dist/metrics-Uqf8GomB.mjs +0 -818
  160. package/dist/middleware-DcXzz-YK.mjs +0 -9971
  161. package/dist/middleware-DgwZkvJR.mjs +0 -5
  162. package/dist/mq-eF96QxUT.mjs +0 -288
  163. package/dist/negotiation-BAKO9nih.mjs +0 -96
  164. package/dist/nodeinfo/client.test.d.mts +0 -2
  165. package/dist/nodeinfo/client.test.mjs +0 -1364
  166. package/dist/nodeinfo/handler.test.d.mts +0 -2
  167. package/dist/nodeinfo/handler.test.mjs +0 -94
  168. package/dist/nodeinfo/types.test.d.mts +0 -2
  169. package/dist/nodeinfo/types.test.mjs +0 -192
  170. package/dist/otel/exporter.test.d.mts +0 -2
  171. package/dist/otel/exporter.test.mjs +0 -887
  172. package/dist/outbound-body-CckPA5gc.mjs +0 -83
  173. package/dist/outbound-capture-DVgnRzlf.mjs +0 -184
  174. package/dist/outbound-document-BMgwLXTY.mjs +0 -179
  175. package/dist/outgoing-jsonld-4IJqPYos.mjs +0 -205
  176. package/dist/owner-BVenIFg1.mjs +0 -267
  177. package/dist/portable-collection-DIk9gpjL.mjs +0 -418
  178. package/dist/portable-key-C7pVaHNR.mjs +0 -549
  179. package/dist/portable-key-id-Ca30-hOa.mjs +0 -248
  180. package/dist/proof-BlfZ95--.mjs +0 -1420
  181. package/dist/public-audience--klBIOk1.mjs +0 -197
  182. package/dist/retry-zX5xw5e0.mjs +0 -34
  183. package/dist/router-u5O5KCQr.mjs +0 -156
  184. package/dist/secured-document-CxzZZ9nL.mjs +0 -35
  185. package/dist/send-DEGHPGFk.mjs +0 -710
  186. package/dist/sig/accept.test.d.mts +0 -2
  187. package/dist/sig/accept.test.mjs +0 -416
  188. package/dist/sig/compound-proof-discovery.test.d.mts +0 -2
  189. package/dist/sig/compound-proof-discovery.test.mjs +0 -331
  190. package/dist/sig/compound-proof-producer.test.d.mts +0 -2
  191. package/dist/sig/compound-proof-producer.test.mjs +0 -107
  192. package/dist/sig/compound-proof-verification.test.d.mts +0 -2
  193. package/dist/sig/compound-proof-verification.test.mjs +0 -1017
  194. package/dist/sig/compound-proof.test.d.mts +0 -2
  195. package/dist/sig/compound-proof.test.mjs +0 -411
  196. package/dist/sig/http.test.d.mts +0 -2
  197. package/dist/sig/http.test.mjs +0 -3328
  198. package/dist/sig/key-owner-evidence.test.d.mts +0 -2
  199. package/dist/sig/key-owner-evidence.test.mjs +0 -100
  200. package/dist/sig/key.test.d.mts +0 -2
  201. package/dist/sig/key.test.mjs +0 -1250
  202. package/dist/sig/ld.test.d.mts +0 -2
  203. package/dist/sig/ld.test.mjs +0 -1044
  204. package/dist/sig/mitra-receive-interop.test.d.mts +0 -2
  205. package/dist/sig/mitra-receive-interop.test.mjs +0 -260
  206. package/dist/sig/mitra-send-interop.test.d.mts +0 -2
  207. package/dist/sig/mitra-send-interop.test.mjs +0 -461
  208. package/dist/sig/owner.test.d.mts +0 -2
  209. package/dist/sig/owner.test.mjs +0 -202
  210. package/dist/sig/portable-collection.test.d.mts +0 -2
  211. package/dist/sig/portable-collection.test.mjs +0 -697
  212. package/dist/sig/portable-interop.test.d.mts +0 -2
  213. package/dist/sig/portable-interop.test.mjs +0 -156
  214. package/dist/sig/portable-key-id.test.d.mts +0 -2
  215. package/dist/sig/portable-key-id.test.mjs +0 -67
  216. package/dist/sig/portable-key.test.d.mts +0 -2
  217. package/dist/sig/portable-key.test.mjs +0 -1438
  218. package/dist/sig/proof.test.d.mts +0 -2
  219. package/dist/sig/proof.test.mjs +0 -2638
  220. package/dist/sig/tootik-request-interop.test.d.mts +0 -2
  221. package/dist/sig/tootik-request-interop.test.mjs +0 -190
  222. package/dist/sig/tootik-send-interop.test.d.mts +0 -2
  223. package/dist/sig/tootik-send-interop.test.mjs +0 -331
  224. package/dist/sig/verification.test.d.mts +0 -2
  225. package/dist/sig/verification.test.mjs +0 -310
  226. package/dist/std__assert-DvMDRPes.mjs +0 -8
  227. package/dist/tasks-BCUmQbbz.mjs +0 -77
  228. package/dist/temporal-B4oQ8HpW.mjs +0 -95
  229. package/dist/testing/context.test.d.mts +0 -2
  230. package/dist/testing/context.test.mjs +0 -19
  231. package/dist/testing/kv.test.d.mts +0 -2
  232. package/dist/testing/kv.test.mjs +0 -101
  233. package/dist/testing/mod.d.mts +0 -6099
  234. package/dist/testing/mod.mjs +0 -9
  235. package/dist/testing-vrnD5Uaa.mjs +0 -8
  236. package/dist/types-DE_LV1JB.mjs +0 -46
  237. package/dist/utils/docloader.test.d.mts +0 -2
  238. package/dist/utils/docloader.test.mjs +0 -1076
  239. package/dist/utils/kv-cache.test.d.mts +0 -2
  240. package/dist/utils/kv-cache.test.mjs +0 -261
  241. package/dist/verification-C3954hQh.mjs +0 -5
  242. package/dist/verification-Dpfcw8ml.mjs +0 -105
  243. package/dist/vocab/cjs.test.d.mts +0 -2
  244. 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-DcXzz-YK.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-BlfZ95--.mjs";
10
- import { n as ed25519PrivateKey, r as ed25519PublicKey } from "../keys-DIJNHW-Y.mjs";
11
- import { o as createFederation } from "../middleware-DcXzz-YK.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";