@fedify/fedify 2.0.0-pr.412.1559 → 2.0.0-pr.412.1794

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 (204) hide show
  1. package/README.md +3 -0
  2. package/dist/{actor-Cc6B76eG.js → actor-BXHc5r-q.js} +1 -1
  3. package/dist/actor-Ba9Z1eNJ.cjs +42079 -0
  4. package/dist/{actor-C22bXuuC.d.ts → actor-DqFajh9s.d.ts} +2 -2
  5. package/dist/{actor-CTAuCsWy.js → actor-DzhunPC_.js} +7058 -2722
  6. package/dist/actor-f2NtjyCg.d.cts +128 -0
  7. package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-Ce45JcFg.js} +1 -1
  8. package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-BNXdRGWP.js} +31 -1
  9. package/dist/{builder-BOEBObR8.js → builder-u7usRsT3.js} +13 -8
  10. package/dist/chunk-DqRYRqnO.cjs +34 -0
  11. package/dist/client-94iWEfQa.d.cts +222 -0
  12. package/dist/{client-DF8anIB5.d.ts → client-BsGzbnV-.d.ts} +3 -75
  13. package/dist/{client-De-z2UnN.js → client-pY7-3icS.js} +3 -22
  14. package/dist/compat/mod.cjs +10 -0
  15. package/dist/compat/mod.d.cts +12 -0
  16. package/dist/compat/mod.d.ts +11 -12
  17. package/dist/compat/mod.js +5 -5
  18. package/dist/compat/transformers.test.js +20 -20
  19. package/dist/compat-DmDDELst.cjs +4 -0
  20. package/dist/compat-nxUqe4Z-.js +4 -0
  21. package/dist/{context-9gCpIkiz.d.ts → context-DG0huGW-.d.ts} +184 -127
  22. package/dist/context-DJ8aSy2Q.d.cts +2312 -0
  23. package/dist/{authdocloader-CLgDGafZ.js → docloader-CrbAy9Oc.js} +17 -8
  24. package/dist/{esm-CHdxdkuH.js → esm-C-Qa1zEM.js} +11 -11
  25. package/dist/federation/builder.test.js +9 -12
  26. package/dist/federation/collection.test.js +7 -9
  27. package/dist/federation/handler.test.js +27 -148
  28. package/dist/federation/idempotency.test.js +201 -0
  29. package/dist/federation/inbox.test.js +4 -6
  30. package/dist/federation/keycache.test.js +3 -4
  31. package/dist/federation/kv.test.js +7 -8
  32. package/dist/federation/middleware.test.js +242 -64
  33. package/dist/federation/mod.cjs +27 -0
  34. package/dist/federation/mod.d.cts +12 -0
  35. package/dist/federation/mod.d.ts +12 -13
  36. package/dist/federation/mod.js +13 -15
  37. package/dist/federation/mq.test.js +8 -10
  38. package/dist/federation/negotiation.test.js +26 -0
  39. package/dist/federation/retry.test.js +4 -5
  40. package/dist/federation/router.test.js +6 -8
  41. package/dist/federation/send.test.js +13 -15
  42. package/dist/federation-CRpdnOMS.cjs +244 -0
  43. package/dist/{federation-CMX7WzeL.js → federation-jcR8-ZxP.js} +3 -3
  44. package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
  45. package/dist/{http-DqSNLFNY.d.ts → http-BbO0ejuk.d.ts} +2 -2
  46. package/dist/{http-l0TEupZK.js → http-CUVx-vzb.js} +260 -10
  47. package/dist/{http-CcdM1brU.js → http-D2kIm9la.js} +3 -3
  48. package/dist/http-Dofes42e.cjs +1106 -0
  49. package/dist/http-M8k5mKc0.d.cts +253 -0
  50. package/dist/{inbox-B6DZbGNf.js → inbox-HjG5peXY.js} +24 -7
  51. package/dist/{key-CzLv1phF.js → key-CxdLUFS6.js} +3 -2
  52. package/dist/{keycache-B8HdZJSt.js → keycache-bU7COwsh.js} +1 -1
  53. package/dist/{keys-zZwiKkfx.js → keys-DMHs8XNn.js} +2 -1
  54. package/dist/kv-Bxr0Q87_.d.cts +81 -0
  55. package/dist/kv-cache-CGXcDejL.js +122 -0
  56. package/dist/kv-cache-DN9pfMBe.js +94 -0
  57. package/dist/kv-cache-Dkvbn6rg.cjs +134 -0
  58. package/dist/{ld-CBcQdZ6N.js → ld-CIhvSCCr.js} +5 -4
  59. package/dist/lookup-CHkCVZTU.js +260 -0
  60. package/dist/lookup-CfFkONZD.cjs +272 -0
  61. package/dist/{type-SK-d7Tbw.js → lookup-DQRtjvb1.js} +7266 -7087
  62. package/dist/middleware-Bot7EEwV.js +26 -0
  63. package/dist/middleware-CFJgmUMW.cjs +15 -0
  64. package/dist/{middleware-BRgu1IH8.js → middleware-CJlj5Olw.js} +86 -181
  65. package/dist/middleware-CjHl2NHA.js +15 -0
  66. package/dist/middleware-D74TgW2E.cjs +4225 -0
  67. package/dist/{middleware-CxEkcFW0.js → middleware-DMk2Mdn9.js} +117 -127
  68. package/dist/mod-0noXw66R.d.cts +107 -0
  69. package/dist/mod-B-hUPT2N.d.cts +1 -0
  70. package/dist/{mod-Drmz72EK.d.ts → mod-B2iOw50L.d.ts} +3 -3
  71. package/dist/mod-B9M-8jm2.d.ts +109 -0
  72. package/dist/{mod-Cxt4Kpf6.d.ts → mod-BlVovdcy.d.ts} +20 -2
  73. package/dist/{mod-Bqxcp7eN.d.ts → mod-BoHnwOCs.d.ts} +2 -2
  74. package/dist/mod-BxRCHTz-.d.cts +307 -0
  75. package/dist/mod-C2tOeRkN.d.cts +1 -0
  76. package/dist/mod-C58MZ7Wx.d.cts +113 -0
  77. package/dist/mod-DJcZDvjA.d.cts +80 -0
  78. package/dist/mod-DgdBYYa0.d.cts +266 -0
  79. package/dist/{mod-DBzN0aCM.d.ts → mod-Ds0mpFZU.d.ts} +1 -1
  80. package/dist/mod.cjs +137 -0
  81. package/dist/mod.d.cts +16 -0
  82. package/dist/mod.d.ts +16 -17
  83. package/dist/mod.js +19 -21
  84. package/dist/mq-DcJPkXD5.d.cts +140 -0
  85. package/dist/negotiation-C4nFufNk.js +71 -0
  86. package/dist/nodeinfo/client.test.js +30 -111
  87. package/dist/nodeinfo/handler.test.js +25 -26
  88. package/dist/nodeinfo/mod.cjs +10 -0
  89. package/dist/nodeinfo/mod.d.cts +3 -0
  90. package/dist/nodeinfo/mod.d.ts +3 -5
  91. package/dist/nodeinfo/mod.js +6 -7
  92. package/dist/nodeinfo/types.test.js +8 -15
  93. package/dist/nodeinfo-BnthBobC.js +4 -0
  94. package/dist/nodeinfo-CdN0rEnZ.cjs +4 -0
  95. package/dist/owner-B4HbyP8s.d.cts +67 -0
  96. package/dist/{owner-VEIjmR8r.js → owner-Dvh7mBvr.js} +3 -2
  97. package/dist/{owner-CQPnQVtf.d.ts → owner-kQRGVXG1.d.ts} +3 -3
  98. package/dist/proof-D0uThUvD.cjs +674 -0
  99. package/dist/{proof-DoSQAGkE.js → proof-Dgy35fzc.js} +3 -3
  100. package/dist/{proof-tgUlT8hw.js → proof-fqzaMJ4g.js} +11 -10
  101. package/dist/{send-BzS7w-QF.js → send-Drp20VO9.js} +2 -2
  102. package/dist/sig/http.test.js +13 -14
  103. package/dist/sig/key.test.js +9 -11
  104. package/dist/sig/ld.test.js +8 -10
  105. package/dist/sig/mod.cjs +28 -0
  106. package/dist/sig/mod.d.cts +6 -0
  107. package/dist/sig/mod.d.ts +5 -7
  108. package/dist/sig/mod.js +8 -10
  109. package/dist/sig/owner.test.js +10 -12
  110. package/dist/sig/proof.test.js +13 -14
  111. package/dist/sig-C34-oHBl.js +4 -0
  112. package/dist/sig-YYj5tCnr.cjs +4 -0
  113. package/dist/testing/docloader.test.js +6 -8
  114. package/dist/testing/mod.d.ts +387 -224
  115. package/dist/testing/mod.js +2 -3
  116. package/dist/{testing-Z2omCvKy.js → testing-g4UC4liW.js} +1 -2
  117. package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
  118. package/dist/transformers-CoBS-oFG.cjs +116 -0
  119. package/dist/{types-DgPvoUWN.js → types-BtUjyi5y.js} +8 -169
  120. package/dist/{types-BIgY6c-l.js → types-C2XVl6gj.js} +1 -3
  121. package/dist/types-CWgzGaqk.cjs +315 -0
  122. package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +14 -15
  123. package/dist/utils/kv-cache.test.js +209 -0
  124. package/dist/utils/mod.cjs +12 -0
  125. package/dist/utils/mod.d.cts +5 -0
  126. package/dist/utils/mod.d.ts +7 -0
  127. package/dist/utils/mod.js +11 -0
  128. package/dist/utils-D-Va7aXC.js +4 -0
  129. package/dist/utils-DyRU1gdZ.cjs +4 -0
  130. package/dist/vocab/actor.test.js +8 -10
  131. package/dist/vocab/lookup.test.js +257 -9
  132. package/dist/vocab/mod.cjs +86 -0
  133. package/dist/vocab/mod.d.cts +4 -0
  134. package/dist/vocab/mod.d.ts +3 -5
  135. package/dist/vocab/mod.js +6 -7
  136. package/dist/vocab/type.test.js +2 -3
  137. package/dist/vocab/vocab.test.js +438 -15
  138. package/dist/{vocab-SOE1ifCr.d.ts → vocab-BCWe1Ih5.d.ts} +292 -21
  139. package/dist/{vocab-CvD6Vbml.js → vocab-BnR3nIU9.js} +26 -17
  140. package/dist/vocab-CeDBzu-f.d.cts +14903 -0
  141. package/dist/{lookup-Bn_HEC_d.js → vocab-DFaWWYDn.cjs} +108 -139
  142. package/dist/webfinger/handler.test.js +24 -25
  143. package/dist/webfinger/lookup.test.js +7 -9
  144. package/dist/webfinger/mod.cjs +8 -0
  145. package/dist/webfinger/mod.d.cts +2 -0
  146. package/dist/webfinger/mod.d.ts +1 -3
  147. package/dist/webfinger/mod.js +5 -6
  148. package/dist/webfinger-C72Y8lrh.js +4 -0
  149. package/dist/webfinger-vAtLmxOF.cjs +4 -0
  150. package/dist/x/cfworkers.cjs +100 -0
  151. package/dist/x/cfworkers.d.cts +59 -0
  152. package/dist/x/cfworkers.d.ts +2 -2
  153. package/dist/x/cfworkers.js +3 -3
  154. package/dist/x/cfworkers.test.js +6 -8
  155. package/dist/x/hono.cjs +61 -0
  156. package/dist/x/hono.d.cts +53 -0
  157. package/dist/x/hono.d.ts +10 -11
  158. package/dist/x/hono.js +3 -3
  159. package/dist/x/sveltekit.cjs +69 -0
  160. package/dist/x/sveltekit.d.cts +45 -0
  161. package/dist/x/sveltekit.d.ts +10 -11
  162. package/dist/x/sveltekit.js +3 -3
  163. package/package.json +79 -23
  164. package/dist/assert_throws-BOO88avQ.js +0 -39
  165. package/dist/authdocloader-BFVqUbyo.js +0 -52
  166. package/dist/compat-Bb5myD13.js +0 -4
  167. package/dist/docloader-CxWcuWqQ.d.ts +0 -221
  168. package/dist/docloader-DEhniCVa.js +0 -4615
  169. package/dist/key-CUZQgVlf.js +0 -10
  170. package/dist/key-Deb0_wWL.js +0 -10
  171. package/dist/key-DxA6xRtZ.js +0 -260
  172. package/dist/lookup-dtdr2ftf.js +0 -131
  173. package/dist/middleware-BE_geSiJ.js +0 -17
  174. package/dist/middleware-BnU6hzVp.js +0 -26
  175. package/dist/mod-TFoH2Ql8.d.ts +0 -104
  176. package/dist/nodeinfo/semver.test.js +0 -143
  177. package/dist/nodeinfo-CyEbLjHs.js +0 -4
  178. package/dist/runtime/docloader.test.js +0 -522
  179. package/dist/runtime/key.test.js +0 -103
  180. package/dist/runtime/langstr.test.d.ts +0 -3
  181. package/dist/runtime/langstr.test.js +0 -39
  182. package/dist/runtime/mod.d.ts +0 -8
  183. package/dist/runtime/mod.js +0 -13
  184. package/dist/runtime/multibase/multibase.test.d.ts +0 -3
  185. package/dist/runtime/multibase/multibase.test.js +0 -358
  186. package/dist/runtime/url.test.d.ts +0 -3
  187. package/dist/runtime/url.test.js +0 -45
  188. package/dist/runtime-BSkOVUWM.js +0 -4
  189. package/dist/semver-dArNLkR9.js +0 -149
  190. package/dist/sig-BXJO--F9.js +0 -4
  191. package/dist/webfinger-C3GIyXIg.js +0 -4
  192. /package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-C80BG-_5.js} +0 -0
  193. /package/dist/{collection-CSzG2j1P.js → collection-BzWsN9pB.js} +0 -0
  194. /package/dist/{denokv-Bv33Xxea.js → denokv-CCssOzMJ.js} +0 -0
  195. /package/dist/{nodeinfo/semver.test.d.ts → federation/idempotency.test.d.ts} +0 -0
  196. /package/dist/{runtime/authdocloader.test.d.ts → federation/negotiation.test.d.ts} +0 -0
  197. /package/dist/{kv-C7sopW2E.d.ts → kv-BKNZ-Tb-.d.ts} +0 -0
  198. /package/dist/{mod-1pDWKvUL.d.ts → mod-CVgZgliM.d.ts} +0 -0
  199. /package/dist/{mod-g0xFzAP9.d.ts → mod-xIj-IT58.d.ts} +0 -0
  200. /package/dist/{mq-CRGm1e_F.d.ts → mq-CUKlBw08.d.ts} +0 -0
  201. /package/dist/{retry-D4GJ670a.js → retry-CfF8Gn4d.js} +0 -0
  202. /package/dist/{std__assert-X-_kMxKM.js → std__assert-DWivtrGR.js} +0 -0
  203. /package/dist/{runtime → utils}/docloader.test.d.ts +0 -0
  204. /package/dist/{runtime/key.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
@@ -3,25 +3,24 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { UrlError } from "../type-SK-d7Tbw.js";
6
+ import "../lookup-DQRtjvb1.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
- import "../lookup-Bn_HEC_d.js";
11
- import "../actor-Cc6B76eG.js";
12
- import "../key-CzLv1phF.js";
13
- import { verifyRequest } from "../http-CcdM1brU.js";
14
- import { getAuthenticatedDocumentLoader } from "../authdocloader-CLgDGafZ.js";
15
- import { mockDocumentLoader, test } from "../testing-Z2omCvKy.js";
16
- import "../std__assert-X-_kMxKM.js";
17
- import { assertRejects } from "../assert_rejects-DiIiJbZn.js";
18
- import "../assert_is_error-BPGph1Jx.js";
19
- import "../assert_not_equals-f3m3epl3.js";
20
- import "../assert_throws-BOO88avQ.js";
21
- import { rsaPrivateKey2 } from "../keys-zZwiKkfx.js";
22
- import { esm_default } from "../esm-CHdxdkuH.js";
10
+ import "../actor-BXHc5r-q.js";
11
+ import "../key-CxdLUFS6.js";
12
+ import { verifyRequest } from "../http-D2kIm9la.js";
13
+ import { getAuthenticatedDocumentLoader } from "../docloader-CrbAy9Oc.js";
14
+ import { mockDocumentLoader, test } from "../testing-g4UC4liW.js";
15
+ import "../std__assert-DWivtrGR.js";
16
+ import { assertRejects } from "../assert_rejects-Ce45JcFg.js";
17
+ import "../assert_throws-BNXdRGWP.js";
18
+ import "../assert_not_equals-C80BG-_5.js";
19
+ import { rsaPrivateKey2 } from "../keys-DMHs8XNn.js";
20
+ import { esm_default } from "../esm-C-Qa1zEM.js";
21
+ import { UrlError } from "@fedify/vocab-runtime";
23
22
 
24
- //#region src/runtime/authdocloader.test.ts
23
+ //#region src/utils/docloader.test.ts
25
24
  test("getAuthenticatedDocumentLoader()", async (t) => {
26
25
  esm_default.spyGlobal();
27
26
  esm_default.get("begin:https://example.com/object", async (cl) => {
@@ -0,0 +1,209 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+ globalThis.addEventListener = () => {};
5
+
6
+ import "../lookup-DQRtjvb1.js";
7
+ import { MockKvStore, kvCache } from "../kv-cache-DN9pfMBe.js";
8
+ import { mockDocumentLoader, test } from "../testing-g4UC4liW.js";
9
+ import { preloadedContexts } from "@fedify/vocab-runtime";
10
+ import { deepStrictEqual, throws } from "node:assert";
11
+
12
+ //#region src/utils/kv-cache.test.ts
13
+ test("kvCache()", async (t) => {
14
+ const kv = new MockKvStore();
15
+ await t.step("cached", async () => {
16
+ const loader = kvCache({
17
+ kv,
18
+ loader: mockDocumentLoader,
19
+ rules: [
20
+ ["https://example.org/", Temporal.Duration.from({ days: 1 })],
21
+ [new URL("https://example.net/"), Temporal.Duration.from({ days: 1 })],
22
+ [new URLPattern("https://example.com/*"), Temporal.Duration.from({ days: 30 })]
23
+ ],
24
+ prefix: ["_test", "cached"]
25
+ });
26
+ const result = await loader("https://example.com/object");
27
+ deepStrictEqual(result, {
28
+ contextUrl: null,
29
+ documentUrl: "https://example.com/object",
30
+ document: {
31
+ "@context": "https://www.w3.org/ns/activitystreams",
32
+ id: "https://example.com/object",
33
+ name: "Fetched object",
34
+ type: "Object"
35
+ }
36
+ });
37
+ const cache = await kv.get([
38
+ "_test",
39
+ "cached",
40
+ "https://example.com/object"
41
+ ]);
42
+ deepStrictEqual(cache, result);
43
+ await kv.set([
44
+ "_test",
45
+ "cached",
46
+ "https://example.org/"
47
+ ], {
48
+ contextUrl: null,
49
+ documentUrl: "https://example.org/",
50
+ document: { "id": "https://example.org/" }
51
+ });
52
+ const result2 = await loader("https://example.org/");
53
+ deepStrictEqual(result2, {
54
+ contextUrl: null,
55
+ documentUrl: "https://example.org/",
56
+ document: { "id": "https://example.org/" }
57
+ });
58
+ await kv.set([
59
+ "_test",
60
+ "cached",
61
+ "https://example.net/"
62
+ ], {
63
+ contextUrl: null,
64
+ documentUrl: "https://example.net/",
65
+ document: { "id": "https://example.net/" }
66
+ });
67
+ const result3 = await loader("https://example.net/");
68
+ deepStrictEqual(result3, {
69
+ contextUrl: null,
70
+ documentUrl: "https://example.net/",
71
+ document: { "id": "https://example.net/" }
72
+ });
73
+ });
74
+ await t.step("not cached", async () => {
75
+ const loader = kvCache({
76
+ kv,
77
+ loader: mockDocumentLoader,
78
+ rules: [],
79
+ prefix: ["_test", "not cached"]
80
+ });
81
+ const result = await loader("https://example.com/object");
82
+ deepStrictEqual(result, {
83
+ contextUrl: null,
84
+ documentUrl: "https://example.com/object",
85
+ document: {
86
+ "@context": "https://www.w3.org/ns/activitystreams",
87
+ id: "https://example.com/object",
88
+ name: "Fetched object",
89
+ type: "Object"
90
+ }
91
+ });
92
+ const cache = await kv.get([
93
+ "test2",
94
+ "not cached",
95
+ "https://example.com/object"
96
+ ]);
97
+ deepStrictEqual(cache, void 0);
98
+ });
99
+ await t.step("maximum cache duration", () => {
100
+ throws(() => kvCache({
101
+ kv,
102
+ loader: mockDocumentLoader,
103
+ rules: [["https://example.com/", Temporal.Duration.from({
104
+ days: 30,
105
+ seconds: 1
106
+ })]]
107
+ }), TypeError, "The maximum cache duration is 30 days");
108
+ throws(() => kvCache({
109
+ kv,
110
+ loader: mockDocumentLoader,
111
+ rules: [[new URLPattern("https://example.com/*"), Temporal.Duration.from({
112
+ days: 30,
113
+ seconds: 1
114
+ })]]
115
+ }), TypeError, "The maximum cache duration is 30 days");
116
+ });
117
+ await t.step("on kv store exception", async () => {
118
+ class KvStoreThrowsException {
119
+ get(_key) {
120
+ throw new Error("Failed to get key");
121
+ }
122
+ set(_key, _value, _options) {
123
+ throw new Error("Failed to set key");
124
+ }
125
+ delete(_key) {
126
+ throw new Error("Failed to delete key");
127
+ }
128
+ }
129
+ const loader = kvCache({
130
+ kv: new KvStoreThrowsException(),
131
+ loader: mockDocumentLoader,
132
+ rules: [
133
+ ["https://example.org/", Temporal.Duration.from({ days: 1 })],
134
+ [new URL("https://example.net/"), Temporal.Duration.from({ days: 1 })],
135
+ [new URLPattern("https://example.com/*"), Temporal.Duration.from({ days: 30 })]
136
+ ],
137
+ prefix: ["_test", "not cached"]
138
+ });
139
+ const result = await loader("https://example.com/object");
140
+ deepStrictEqual(result, {
141
+ contextUrl: null,
142
+ documentUrl: "https://example.com/object",
143
+ document: {
144
+ "@context": "https://www.w3.org/ns/activitystreams",
145
+ id: "https://example.com/object",
146
+ name: "Fetched object",
147
+ type: "Object"
148
+ }
149
+ });
150
+ });
151
+ await t.step("preloaded contexts bypass cache", async () => {
152
+ const kv$1 = new MockKvStore();
153
+ let loaderCalled = false;
154
+ const mockLoader = (url) => {
155
+ loaderCalled = true;
156
+ return Promise.resolve({
157
+ contextUrl: null,
158
+ documentUrl: url,
159
+ document: { "mock": "document" }
160
+ });
161
+ };
162
+ const loader = kvCache({
163
+ kv: kv$1,
164
+ loader: mockLoader,
165
+ prefix: ["_test", "preloaded"]
166
+ });
167
+ const activityStreamsUrl = "https://www.w3.org/ns/activitystreams";
168
+ loaderCalled = false;
169
+ const result = await loader(activityStreamsUrl);
170
+ deepStrictEqual(result, {
171
+ contextUrl: null,
172
+ documentUrl: activityStreamsUrl,
173
+ document: preloadedContexts[activityStreamsUrl]
174
+ });
175
+ deepStrictEqual(loaderCalled, false, "Loader should not be called for preloaded contexts");
176
+ const cachedValue = await kv$1.get([
177
+ "_test",
178
+ "preloaded",
179
+ activityStreamsUrl
180
+ ]);
181
+ deepStrictEqual(cachedValue, void 0, "Preloaded contexts should not be cached in KV store");
182
+ const securityUrl = "https://w3id.org/security/v1";
183
+ loaderCalled = false;
184
+ const result2 = await loader(securityUrl);
185
+ deepStrictEqual(result2, {
186
+ contextUrl: null,
187
+ documentUrl: securityUrl,
188
+ document: preloadedContexts[securityUrl]
189
+ });
190
+ deepStrictEqual(loaderCalled, false, "Loader should not be called for preloaded contexts");
191
+ const nonPreloadedUrl = "https://example.com/not-preloaded";
192
+ loaderCalled = false;
193
+ const result3 = await loader(nonPreloadedUrl);
194
+ deepStrictEqual(result3, {
195
+ contextUrl: null,
196
+ documentUrl: nonPreloadedUrl,
197
+ document: { "mock": "document" }
198
+ });
199
+ deepStrictEqual(loaderCalled, true, "Loader should be called for non-preloaded URLs");
200
+ const cachedValue2 = await kv$1.get([
201
+ "_test",
202
+ "preloaded",
203
+ nonPreloadedUrl
204
+ ]);
205
+ deepStrictEqual(cachedValue2, result3, "Non-preloaded URLs should be cached");
206
+ });
207
+ });
208
+
209
+ //#endregion
@@ -0,0 +1,12 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ require('../lookup-CfFkONZD.cjs');
6
+ require('../actor-Ba9Z1eNJ.cjs');
7
+ require('../http-Dofes42e.cjs');
8
+ const require_kv_cache = require('../kv-cache-Dkvbn6rg.cjs');
9
+ require('../utils-DyRU1gdZ.cjs');
10
+
11
+ exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
12
+ exports.kvCache = require_kv_cache.kvCache;
@@ -0,0 +1,5 @@
1
+ import "../vocab-CeDBzu-f.cjs";
2
+ import "../http-M8k5mKc0.cjs";
3
+ import "../kv-Bxr0Q87_.cjs";
4
+ import { getAuthenticatedDocumentLoader, kvCache } from "../mod-0noXw66R.cjs";
5
+ export { getAuthenticatedDocumentLoader, kvCache };
@@ -0,0 +1,7 @@
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
+ import "../vocab-BCWe1Ih5.js";
4
+ import "../http-BbO0ejuk.js";
5
+ import "../kv-BKNZ-Tb-.js";
6
+ import { getAuthenticatedDocumentLoader, kvCache } from "../mod-B9M-8jm2.js";
7
+ export { getAuthenticatedDocumentLoader, kvCache };
@@ -0,0 +1,11 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import "../lookup-CHkCVZTU.js";
6
+ import "../actor-DzhunPC_.js";
7
+ import "../http-CUVx-vzb.js";
8
+ import { getAuthenticatedDocumentLoader, kvCache } from "../kv-cache-CGXcDejL.js";
9
+ import "../utils-D-Va7aXC.js";
10
+
11
+ export { getAuthenticatedDocumentLoader, kvCache };
@@ -0,0 +1,4 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
@@ -0,0 +1,4 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
@@ -3,19 +3,17 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Application, Group, Organization, Person, Service, __export } from "../type-SK-d7Tbw.js";
6
+ import { Application, Group, Organization, Person, Service, __export } from "../lookup-DQRtjvb1.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import { assert } from "../assert-MZs1qjMx.js";
9
9
  import "../assert_instance_of-DHz7EHNU.js";
10
- import "../lookup-Bn_HEC_d.js";
11
- import { getActorClassByTypeName, getActorHandle, getActorTypeName, isActor, normalizeActorHandle } from "../actor-Cc6B76eG.js";
12
- import { test } from "../testing-Z2omCvKy.js";
13
- import { assertStrictEquals } from "../std__assert-X-_kMxKM.js";
14
- import { assertFalse, assertRejects } from "../assert_rejects-DiIiJbZn.js";
15
- import "../assert_is_error-BPGph1Jx.js";
16
- import "../assert_not_equals-f3m3epl3.js";
17
- import { assertThrows } from "../assert_throws-BOO88avQ.js";
18
- import { esm_default } from "../esm-CHdxdkuH.js";
10
+ import { getActorClassByTypeName, getActorHandle, getActorTypeName, isActor, normalizeActorHandle } from "../actor-BXHc5r-q.js";
11
+ import { test } from "../testing-g4UC4liW.js";
12
+ import { assertStrictEquals } from "../std__assert-DWivtrGR.js";
13
+ import { assertFalse, assertRejects } from "../assert_rejects-Ce45JcFg.js";
14
+ import { assertThrows } from "../assert_throws-BNXdRGWP.js";
15
+ import "../assert_not_equals-C80BG-_5.js";
16
+ import { esm_default } from "../esm-C-Qa1zEM.js";
19
17
 
20
18
  //#region ../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/esm/check/precondition/PreconditionFailure.js
21
19
  var PreconditionFailure = class PreconditionFailure extends Error {
@@ -3,18 +3,16 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Collection, Note, Object as Object$1, Person } from "../type-SK-d7Tbw.js";
6
+ import { Collection, Note, Object as Object$1, Person, lookupObject, traverseCollection } from "../lookup-DQRtjvb1.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import "../assert-MZs1qjMx.js";
9
9
  import { assertInstanceOf } from "../assert_instance_of-DHz7EHNU.js";
10
- import { lookupObject, traverseCollection } from "../lookup-Bn_HEC_d.js";
11
- import { mockDocumentLoader, test } from "../testing-Z2omCvKy.js";
12
- import "../std__assert-X-_kMxKM.js";
13
- import "../assert_rejects-DiIiJbZn.js";
14
- import "../assert_is_error-BPGph1Jx.js";
15
- import "../assert_not_equals-f3m3epl3.js";
16
- import "../assert_throws-BOO88avQ.js";
17
- import { esm_default } from "../esm-CHdxdkuH.js";
10
+ import { mockDocumentLoader, test } from "../testing-g4UC4liW.js";
11
+ import "../std__assert-DWivtrGR.js";
12
+ import { assertRejects } from "../assert_rejects-Ce45JcFg.js";
13
+ import "../assert_throws-BNXdRGWP.js";
14
+ import "../assert_not_equals-C80BG-_5.js";
15
+ import { esm_default } from "../esm-C-Qa1zEM.js";
18
16
 
19
17
  //#region src/vocab/lookup.test.ts
20
18
  test("lookupObject()", {
@@ -202,5 +200,255 @@ test("traverseCollection()", {
202
200
  new Note({ content: "This is a third simple note" })
203
201
  ]);
204
202
  });
203
+ test("FEP-fe34: lookupObject() cross-origin security", {
204
+ sanitizeResources: false,
205
+ sanitizeOps: false
206
+ }, async (t) => {
207
+ await t.step("crossOrigin: ignore (default) - returns null for cross-origin objects", async () => {
208
+ const crossOriginDocumentLoader = async (url) => {
209
+ if (url === "https://example.com/note") return {
210
+ documentUrl: url,
211
+ contextUrl: null,
212
+ document: {
213
+ "@context": "https://www.w3.org/ns/activitystreams",
214
+ type: "Note",
215
+ id: "https://malicious.com/fake-note",
216
+ content: "This is a spoofed note from a different origin"
217
+ }
218
+ };
219
+ throw new Error(`Unexpected URL: ${url}`);
220
+ };
221
+ const result = await lookupObject("https://example.com/note", {
222
+ documentLoader: crossOriginDocumentLoader,
223
+ contextLoader: mockDocumentLoader
224
+ });
225
+ assertEquals(result, null);
226
+ });
227
+ await t.step("crossOrigin: throw - throws error for cross-origin objects", async () => {
228
+ const crossOriginDocumentLoader = async (url) => {
229
+ if (url === "https://example.com/note") return {
230
+ documentUrl: url,
231
+ contextUrl: null,
232
+ document: {
233
+ "@context": "https://www.w3.org/ns/activitystreams",
234
+ type: "Note",
235
+ id: "https://malicious.com/fake-note",
236
+ content: "This is a spoofed note from a different origin"
237
+ }
238
+ };
239
+ throw new Error(`Unexpected URL: ${url}`);
240
+ };
241
+ await assertRejects(() => lookupObject("https://example.com/note", {
242
+ documentLoader: crossOriginDocumentLoader,
243
+ contextLoader: mockDocumentLoader,
244
+ crossOrigin: "throw"
245
+ }), Error, "The object's @id (https://malicious.com/fake-note) has a different origin than the document URL (https://example.com/note)");
246
+ });
247
+ await t.step("crossOrigin: trust - allows cross-origin objects", async () => {
248
+ const crossOriginDocumentLoader = async (url) => {
249
+ if (url === "https://example.com/note") return {
250
+ documentUrl: url,
251
+ contextUrl: null,
252
+ document: {
253
+ "@context": "https://www.w3.org/ns/activitystreams",
254
+ type: "Note",
255
+ id: "https://malicious.com/fake-note",
256
+ content: "This is a spoofed note from a different origin"
257
+ }
258
+ };
259
+ throw new Error(`Unexpected URL: ${url}`);
260
+ };
261
+ const result = await lookupObject("https://example.com/note", {
262
+ documentLoader: crossOriginDocumentLoader,
263
+ contextLoader: mockDocumentLoader,
264
+ crossOrigin: "trust"
265
+ });
266
+ assertInstanceOf(result, Note);
267
+ assertEquals(result.id, new URL("https://malicious.com/fake-note"));
268
+ assertEquals(result.content, "This is a spoofed note from a different origin");
269
+ });
270
+ await t.step("same-origin objects are always trusted", async () => {
271
+ const sameOriginDocumentLoader = async (url) => {
272
+ if (url === "https://example.com/note") return {
273
+ documentUrl: url,
274
+ contextUrl: null,
275
+ document: {
276
+ "@context": "https://www.w3.org/ns/activitystreams",
277
+ type: "Note",
278
+ id: "https://example.com/note",
279
+ content: "This is a legitimate note from the same origin"
280
+ }
281
+ };
282
+ throw new Error(`Unexpected URL: ${url}`);
283
+ };
284
+ const result = await lookupObject("https://example.com/note", {
285
+ documentLoader: sameOriginDocumentLoader,
286
+ contextLoader: mockDocumentLoader
287
+ });
288
+ assertInstanceOf(result, Note);
289
+ assertEquals(result.id, new URL("https://example.com/note"));
290
+ assertEquals(result.content, "This is a legitimate note from the same origin");
291
+ });
292
+ await t.step("objects without @id are trusted", async () => {
293
+ const noIdDocumentLoader = async (url) => {
294
+ if (url === "https://example.com/note") return {
295
+ documentUrl: url,
296
+ contextUrl: null,
297
+ document: {
298
+ "@context": "https://www.w3.org/ns/activitystreams",
299
+ type: "Note",
300
+ content: "This is a note without an ID"
301
+ }
302
+ };
303
+ throw new Error(`Unexpected URL: ${url}`);
304
+ };
305
+ const result = await lookupObject("https://example.com/note", {
306
+ documentLoader: noIdDocumentLoader,
307
+ contextLoader: mockDocumentLoader
308
+ });
309
+ assertInstanceOf(result, Note);
310
+ assertEquals(result.id, null);
311
+ assertEquals(result.content, "This is a note without an ID");
312
+ });
313
+ await t.step("WebFinger lookup with cross-origin actor URL", async () => {
314
+ esm_default.spyGlobal();
315
+ esm_default.get("begin:https://example.com/.well-known/webfinger", {
316
+ subject: "acct:user@example.com",
317
+ links: [{
318
+ rel: "self",
319
+ href: "https://different-origin.com/actor",
320
+ type: "application/activity+json"
321
+ }]
322
+ });
323
+ const webfingerDocumentLoader = async (url) => {
324
+ if (url === "https://different-origin.com/actor") return {
325
+ documentUrl: url,
326
+ contextUrl: null,
327
+ document: {
328
+ "@context": "https://www.w3.org/ns/activitystreams",
329
+ type: "Person",
330
+ id: "https://malicious.com/fake-actor",
331
+ name: "Fake Actor"
332
+ }
333
+ };
334
+ throw new Error(`Unexpected URL: ${url}`);
335
+ };
336
+ const result1 = await lookupObject("@user@example.com", {
337
+ documentLoader: webfingerDocumentLoader,
338
+ contextLoader: mockDocumentLoader
339
+ });
340
+ assertEquals(result1, null);
341
+ await assertRejects(() => lookupObject("@user@example.com", {
342
+ documentLoader: webfingerDocumentLoader,
343
+ contextLoader: mockDocumentLoader,
344
+ crossOrigin: "throw"
345
+ }), Error, "The object's @id (https://malicious.com/fake-actor) has a different origin than the document URL (https://different-origin.com/actor)");
346
+ const result2 = await lookupObject("@user@example.com", {
347
+ documentLoader: webfingerDocumentLoader,
348
+ contextLoader: mockDocumentLoader,
349
+ crossOrigin: "trust"
350
+ });
351
+ assertInstanceOf(result2, Person);
352
+ assertEquals(result2.id, new URL("https://malicious.com/fake-actor"));
353
+ esm_default.removeRoutes();
354
+ esm_default.hardReset();
355
+ });
356
+ await t.step("subdomain same-origin check", async () => {
357
+ const subdomainDocumentLoader = async (url) => {
358
+ if (url === "https://api.example.com/note") return {
359
+ documentUrl: url,
360
+ contextUrl: null,
361
+ document: {
362
+ "@context": "https://www.w3.org/ns/activitystreams",
363
+ type: "Note",
364
+ id: "https://www.example.com/note",
365
+ content: "Cross-subdomain note"
366
+ }
367
+ };
368
+ throw new Error(`Unexpected URL: ${url}`);
369
+ };
370
+ const result = await lookupObject("https://api.example.com/note", {
371
+ documentLoader: subdomainDocumentLoader,
372
+ contextLoader: mockDocumentLoader
373
+ });
374
+ assertEquals(result, null);
375
+ });
376
+ await t.step("different port same-origin check", async () => {
377
+ const differentPortDocumentLoader = async (url) => {
378
+ if (url === "https://example.com:8080/note") return {
379
+ documentUrl: url,
380
+ contextUrl: null,
381
+ document: {
382
+ "@context": "https://www.w3.org/ns/activitystreams",
383
+ type: "Note",
384
+ id: "https://example.com:9090/note",
385
+ content: "Cross-port note"
386
+ }
387
+ };
388
+ throw new Error(`Unexpected URL: ${url}`);
389
+ };
390
+ const result = await lookupObject("https://example.com:8080/note", {
391
+ documentLoader: differentPortDocumentLoader,
392
+ contextLoader: mockDocumentLoader
393
+ });
394
+ assertEquals(result, null);
395
+ });
396
+ await t.step("protocol difference same-origin check", async () => {
397
+ const differentProtocolDocumentLoader = async (url) => {
398
+ if (url === "https://example.com/note") return {
399
+ documentUrl: url,
400
+ contextUrl: null,
401
+ document: {
402
+ "@context": "https://www.w3.org/ns/activitystreams",
403
+ type: "Note",
404
+ id: "http://example.com/note",
405
+ content: "Cross-protocol note"
406
+ }
407
+ };
408
+ throw new Error(`Unexpected URL: ${url}`);
409
+ };
410
+ const result = await lookupObject("https://example.com/note", {
411
+ documentLoader: differentProtocolDocumentLoader,
412
+ contextLoader: mockDocumentLoader
413
+ });
414
+ assertEquals(result, null);
415
+ });
416
+ await t.step("error handling with crossOrigin throw option", async () => {
417
+ const errorDocumentLoader = async (_url) => {
418
+ throw new Error("Network error");
419
+ };
420
+ const result = await lookupObject("https://example.com/note", {
421
+ documentLoader: errorDocumentLoader,
422
+ contextLoader: mockDocumentLoader,
423
+ crossOrigin: "throw"
424
+ });
425
+ assertEquals(result, null);
426
+ });
427
+ await t.step("malformed JSON handling with cross-origin policy", async () => {
428
+ const malformedJsonDocumentLoader = async (url) => {
429
+ if (url === "https://example.com/note") return {
430
+ documentUrl: url,
431
+ contextUrl: null,
432
+ document: "invalid json"
433
+ };
434
+ throw new Error(`Unexpected URL: ${url}`);
435
+ };
436
+ assertEquals(await lookupObject("https://example.com/note", {
437
+ documentLoader: malformedJsonDocumentLoader,
438
+ contextLoader: mockDocumentLoader,
439
+ crossOrigin: "ignore"
440
+ }), null);
441
+ assertEquals(await lookupObject("https://example.com/note", {
442
+ documentLoader: malformedJsonDocumentLoader,
443
+ contextLoader: mockDocumentLoader,
444
+ crossOrigin: "throw"
445
+ }), null);
446
+ assertEquals(await lookupObject("https://example.com/note", {
447
+ documentLoader: malformedJsonDocumentLoader,
448
+ contextLoader: mockDocumentLoader,
449
+ crossOrigin: "trust"
450
+ }), null);
451
+ });
452
+ });
205
453
 
206
454
  //#endregion