@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
@@ -0,0 +1,86 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ require('../lookup-CfFkONZD.cjs');
6
+ const require_actor = require('../actor-Ba9Z1eNJ.cjs');
7
+ const require_vocab = require('../vocab-DFaWWYDn.cjs');
8
+
9
+ exports.Accept = require_actor.Accept;
10
+ exports.Activity = require_actor.Activity;
11
+ exports.Add = require_actor.Add;
12
+ exports.Announce = require_actor.Announce;
13
+ exports.Application = require_actor.Application;
14
+ exports.Arrive = require_actor.Arrive;
15
+ exports.Article = require_actor.Article;
16
+ exports.Audio = require_actor.Audio;
17
+ exports.Block = require_actor.Block;
18
+ exports.ChatMessage = require_actor.ChatMessage;
19
+ exports.Collection = require_actor.Collection;
20
+ exports.CollectionPage = require_actor.CollectionPage;
21
+ exports.Create = require_actor.Create;
22
+ exports.CryptographicKey = require_actor.CryptographicKey;
23
+ exports.DataIntegrityProof = require_actor.DataIntegrityProof;
24
+ exports.Delete = require_actor.Delete;
25
+ exports.DidService = require_actor.DidService;
26
+ exports.Dislike = require_actor.Dislike;
27
+ exports.Document = require_actor.Document;
28
+ exports.Emoji = require_actor.Emoji;
29
+ exports.EmojiReact = require_actor.EmojiReact;
30
+ exports.Endpoints = require_actor.Endpoints;
31
+ exports.Event = require_actor.Event;
32
+ exports.Export = require_actor.Export;
33
+ exports.Flag = require_actor.Flag;
34
+ exports.Follow = require_actor.Follow;
35
+ exports.Group = require_actor.Group;
36
+ exports.Hashtag = require_actor.Hashtag;
37
+ exports.Ignore = require_actor.Ignore;
38
+ exports.Image = require_actor.Image;
39
+ exports.IntransitiveActivity = require_actor.IntransitiveActivity;
40
+ exports.Invite = require_actor.Invite;
41
+ exports.Join = require_actor.Join;
42
+ exports.Leave = require_actor.Leave;
43
+ exports.Like = require_actor.Like;
44
+ exports.Link = require_actor.Link;
45
+ exports.Listen = require_actor.Listen;
46
+ exports.Mention = require_actor.Mention;
47
+ exports.Move = require_actor.Move;
48
+ exports.Multikey = require_actor.Multikey;
49
+ exports.Note = require_actor.Note;
50
+ exports.Object = require_actor.Object$1;
51
+ exports.Offer = require_actor.Offer;
52
+ exports.OrderedCollection = require_actor.OrderedCollection;
53
+ exports.OrderedCollectionPage = require_actor.OrderedCollectionPage;
54
+ exports.Organization = require_actor.Organization;
55
+ exports.PUBLIC_COLLECTION = require_vocab.PUBLIC_COLLECTION;
56
+ exports.Page = require_actor.Page;
57
+ exports.Person = require_actor.Person;
58
+ exports.Place = require_actor.Place;
59
+ exports.Profile = require_actor.Profile;
60
+ exports.PropertyValue = require_actor.PropertyValue;
61
+ exports.Question = require_actor.Question;
62
+ exports.Read = require_actor.Read;
63
+ exports.Reject = require_actor.Reject;
64
+ exports.Relationship = require_actor.Relationship;
65
+ exports.Remove = require_actor.Remove;
66
+ exports.Service = require_actor.Service;
67
+ exports.Source = require_actor.Source;
68
+ exports.TentativeAccept = require_actor.TentativeAccept;
69
+ exports.TentativeReject = require_actor.TentativeReject;
70
+ exports.Tombstone = require_actor.Tombstone;
71
+ exports.Travel = require_actor.Travel;
72
+ exports.Undo = require_actor.Undo;
73
+ exports.Update = require_actor.Update;
74
+ exports.Video = require_actor.Video;
75
+ exports.View = require_actor.View;
76
+ exports.getActorClassByTypeName = require_actor.getActorClassByTypeName;
77
+ exports.getActorHandle = require_actor.getActorHandle;
78
+ exports.getActorTypeName = require_actor.getActorTypeName;
79
+ exports.getTypeId = require_actor.getTypeId;
80
+ exports.isActor = require_actor.isActor;
81
+ exports.isFediverseHandle = require_vocab.isFediverseHandle;
82
+ exports.lookupObject = require_vocab.lookupObject;
83
+ exports.normalizeActorHandle = require_actor.normalizeActorHandle;
84
+ exports.parseFediverseHandle = require_vocab.parseFediverseHandle;
85
+ exports.toAcctUrl = require_vocab.toAcctUrl;
86
+ exports.traverseCollection = require_vocab.traverseCollection;
@@ -0,0 +1,4 @@
1
+ import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View } from "../vocab-CeDBzu-f.cjs";
2
+ import { Actor, ActorTypeName, GetActorHandleOptions, NormalizeActorHandleOptions, Recipient, getActorClassByTypeName, getActorHandle, getActorTypeName, isActor, normalizeActorHandle } from "../actor-f2NtjyCg.cjs";
3
+ import { FediverseHandle, LookupObjectOptions, PUBLIC_COLLECTION, TraverseCollectionOptions, getTypeId, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "../mod-BxRCHTz-.cjs";
4
+ export { Accept, Activity, Actor, ActorTypeName, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, FediverseHandle, Flag, Follow, GetActorHandleOptions, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, LookupObjectOptions, Mention, Move, Multikey, NormalizeActorHandleOptions, Note, Object$1 as Object, Offer, OrderedCollection, OrderedCollectionPage, Organization, PUBLIC_COLLECTION, Page, Person, Place, Profile, PropertyValue, Question, Read, Recipient, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, TraverseCollectionOptions, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, isFediverseHandle, lookupObject, normalizeActorHandle, parseFediverseHandle, toAcctUrl, traverseCollection };
@@ -1,8 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import "../kv-C7sopW2E.js";
4
- import "../docloader-CxWcuWqQ.js";
5
- import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View } from "../vocab-SOE1ifCr.js";
6
- import { Actor, ActorTypeName, GetActorHandleOptions, NormalizeActorHandleOptions, Recipient, getActorClassByTypeName, getActorHandle, getActorTypeName, isActor, normalizeActorHandle } from "../actor-C22bXuuC.js";
7
- import { FediverseHandle, LookupObjectOptions, PUBLIC_COLLECTION, TraverseCollectionOptions, getTypeId, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "../mod-Cxt4Kpf6.js";
3
+ import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View } from "../vocab-BCWe1Ih5.js";
4
+ import { Actor, ActorTypeName, GetActorHandleOptions, NormalizeActorHandleOptions, Recipient, getActorClassByTypeName, getActorHandle, getActorTypeName, isActor, normalizeActorHandle } from "../actor-DqFajh9s.js";
5
+ import { FediverseHandle, LookupObjectOptions, PUBLIC_COLLECTION, TraverseCollectionOptions, getTypeId, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "../mod-BlVovdcy.js";
8
6
  export { Accept, Activity, Actor, ActorTypeName, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, FediverseHandle, Flag, Follow, GetActorHandleOptions, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, LookupObjectOptions, Mention, Move, Multikey, NormalizeActorHandleOptions, Note, Object$1 as Object, Offer, OrderedCollection, OrderedCollectionPage, Organization, PUBLIC_COLLECTION, Page, Person, Place, Profile, PropertyValue, Question, Read, Recipient, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, TraverseCollectionOptions, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, isFediverseHandle, lookupObject, normalizeActorHandle, parseFediverseHandle, toAcctUrl, traverseCollection };
package/dist/vocab/mod.js CHANGED
@@ -1,10 +1,9 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import "../docloader-DEhniCVa.js";
6
- import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, normalizeActorHandle } from "../actor-CTAuCsWy.js";
7
- import "../lookup-dtdr2ftf.js";
8
- import { PUBLIC_COLLECTION, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "../vocab-CvD6Vbml.js";
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import "../lookup-CHkCVZTU.js";
6
+ import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, normalizeActorHandle } from "../actor-DzhunPC_.js";
7
+ import { PUBLIC_COLLECTION, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "../vocab-BnR3nIU9.js";
9
8
 
10
9
  export { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object$1 as Object, Offer, OrderedCollection, OrderedCollectionPage, Organization, PUBLIC_COLLECTION, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, isFediverseHandle, lookupObject, normalizeActorHandle, parseFediverseHandle, toAcctUrl, traverseCollection };
@@ -3,10 +3,9 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Person, getTypeId } from "../type-SK-d7Tbw.js";
6
+ import { Person, getTypeId } from "../lookup-DQRtjvb1.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
- import "../lookup-Bn_HEC_d.js";
9
- import { test } from "../testing-Z2omCvKy.js";
8
+ import { test } from "../testing-g4UC4liW.js";
10
9
 
11
10
  //#region src/vocab/type.test.ts
12
11
  test("getTypeId()", () => {
@@ -3,19 +3,18 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Activity, Announce, Collection, Create, CryptographicKey, Follow, Hashtag, LanguageString, Note, Object as Object$1, OrderedCollectionPage, Person, Place, Question, Source, decode, vocab_exports } from "../type-SK-d7Tbw.js";
6
+ import { Activity, Announce, Collection, Create, CryptographicKey, Follow, Hashtag, Link, Note, Object as Object$1, OrderedCollectionPage, Person, Place, Question, Source, vocab_exports } from "../lookup-DQRtjvb1.js";
7
7
  import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
8
  import { assert } from "../assert-MZs1qjMx.js";
9
9
  import { assertInstanceOf } from "../assert_instance_of-DHz7EHNU.js";
10
- import "../lookup-Bn_HEC_d.js";
11
- import { mockDocumentLoader, test } from "../testing-Z2omCvKy.js";
12
- import "../std__assert-X-_kMxKM.js";
13
- import { assertFalse, assertRejects } from "../assert_rejects-DiIiJbZn.js";
14
- import "../assert_is_error-BPGph1Jx.js";
15
- import { assertNotEquals } from "../assert_not_equals-f3m3epl3.js";
16
- import { assertThrows } from "../assert_throws-BOO88avQ.js";
17
- import { ed25519PublicKey, rsaPublicKey1 } from "../keys-zZwiKkfx.js";
10
+ import { mockDocumentLoader, test } from "../testing-g4UC4liW.js";
11
+ import "../std__assert-DWivtrGR.js";
12
+ import { assertFalse, assertRejects } from "../assert_rejects-Ce45JcFg.js";
13
+ import { assertThrows } from "../assert_throws-BNXdRGWP.js";
14
+ import { assertNotEquals } from "../assert_not_equals-C80BG-_5.js";
15
+ import { ed25519PublicKey, rsaPublicKey1 } from "../keys-DMHs8XNn.js";
18
16
  import { pascalCase } from "es-toolkit";
17
+ import { LanguageString, decodeMultibase } from "@fedify/vocab-runtime";
19
18
  import { Validator } from "@cfworker/json-schema";
20
19
  import { readFile, readdir } from "node:fs/promises";
21
20
  import { join } from "node:path";
@@ -2238,10 +2237,25 @@ const scalarTypes = {
2238
2237
  dataCheck(v) {
2239
2238
  return `typeof ${v} === "object" && "@id" in ${v}
2240
2239
  && typeof ${v}["@id"] === "string"
2241
- && ${v}["@id"] !== "" && ${v}["@id"] !== "/"`;
2242
- },
2243
- decoder(v) {
2244
- return `new URL(${v}["@id"])`;
2240
+ && ${v}["@id"] !== ""`;
2241
+ },
2242
+ decoder(v, baseUrlVar) {
2243
+ return `${v}["@id"].startsWith("at://")
2244
+ ? new URL("at://" +
2245
+ encodeURIComponent(
2246
+ ${v}["@id"].includes("/", 5)
2247
+ ? ${v}["@id"].slice(5, ${v}["@id"].indexOf("/", 5))
2248
+ : ${v}["@id"].slice(5)
2249
+ ) +
2250
+ (
2251
+ ${v}["@id"].includes("/", 5)
2252
+ ? ${v}["@id"].slice(${v}["@id"].indexOf("/", 5))
2253
+ : ""
2254
+ )
2255
+ )
2256
+ : URL.canParse(${v}["@id"]) && ${baseUrlVar}
2257
+ ? new URL(${v}["@id"])
2258
+ : new URL(${v}["@id"], ${baseUrlVar})`;
2245
2259
  }
2246
2260
  },
2247
2261
  "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString": {
@@ -2719,7 +2733,7 @@ test("Activity.fromJsonLd()", async () => {
2719
2733
  assertEquals(proofs[0].cryptosuite, "eddsa-jcs-2022");
2720
2734
  assertEquals(proofs[0].verificationMethodId, new URL("https://server.example/users/alice#ed25519-key"));
2721
2735
  assertEquals(proofs[0].proofPurpose, "assertionMethod");
2722
- assertEquals(proofs[0].proofValue, decode("z3sXaxjKs4M3BRicwWA9peyNPJvJqxtGsDmpt1jjoHCjgeUf71TRFz56osPSfDErszyLp5Ks1EhYSgpDaNM977Rg2"));
2736
+ assertEquals(proofs[0].proofValue, decodeMultibase("z3sXaxjKs4M3BRicwWA9peyNPJvJqxtGsDmpt1jjoHCjgeUf71TRFz56osPSfDErszyLp5Ks1EhYSgpDaNM977Rg2"));
2723
2737
  assertEquals(proofs[0].created, Temporal.Instant.from("2023-02-24T23:36:38Z"));
2724
2738
  });
2725
2739
  test({
@@ -2855,6 +2869,7 @@ test({
2855
2869
  test("Person.fromJsonLd()", async () => {
2856
2870
  const person = await Person.fromJsonLd({
2857
2871
  "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
2872
+ "id": "https://todon.eu/users/hongminhee",
2858
2873
  "publicKey": {
2859
2874
  "id": "https://todon.eu/users/hongminhee#main-key",
2860
2875
  "owner": "https://todon.eu/users/hongminhee",
@@ -2862,7 +2877,8 @@ test("Person.fromJsonLd()", async () => {
2862
2877
  }
2863
2878
  }, {
2864
2879
  documentLoader: mockDocumentLoader,
2865
- contextLoader: mockDocumentLoader
2880
+ contextLoader: mockDocumentLoader,
2881
+ baseUrl: new URL("https://todon.eu/")
2866
2882
  });
2867
2883
  assertEquals(person.publicKeyId, new URL("https://todon.eu/users/hongminhee#main-key"));
2868
2884
  const publicKey = await person.getPublicKey({ documentLoader: mockDocumentLoader });
@@ -3059,6 +3075,413 @@ test("Actor.getOutbox()", async () => {
3059
3075
  assertInstanceOf(outbox, OrderedCollectionPage);
3060
3076
  assertEquals(outbox.totalItems, 1);
3061
3077
  });
3078
+ test("Link.fromJsonLd()", async () => {
3079
+ const link = await Link.fromJsonLd({
3080
+ "@context": "https://www.w3.org/ns/activitystreams",
3081
+ "type": "Link",
3082
+ "rel": "canonical",
3083
+ "href": "at://did:plc:ia76kvnndjutgedggx2ibrem/app.bsky.feed.post/3lyxjjs27jkqg"
3084
+ });
3085
+ assertEquals(link.rel, "canonical");
3086
+ assertEquals(link.href, new URL("at://did%3Aplc%3Aia76kvnndjutgedggx2ibrem/app.bsky.feed.post/3lyxjjs27jkqg"));
3087
+ const link2 = await Link.fromJsonLd({
3088
+ "@context": "https://www.w3.org/ns/activitystreams",
3089
+ "type": "Link",
3090
+ "href": "at://bnewbold.bsky.team/app.bsky.feed.post/3jwdwj2ctlk26"
3091
+ });
3092
+ assertEquals(link2.href, new URL("at://bnewbold.bsky.team/app.bsky.feed.post/3jwdwj2ctlk26"));
3093
+ const link3 = await Link.fromJsonLd({
3094
+ "@context": "https://www.w3.org/ns/activitystreams",
3095
+ "type": "Link",
3096
+ "href": "at://did:plc:ia76kvnndjutgedggx2ibrem"
3097
+ });
3098
+ assertEquals(link3.href, new URL("at://did%3Aplc%3Aia76kvnndjutgedggx2ibrem"));
3099
+ });
3100
+ test("Person.fromJsonLd() with relative URLs", async () => {
3101
+ const json = {
3102
+ "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
3103
+ id: "https://example.com/ap/actors/019382d3-63d7-7cf7-86e8-91e2551c306c",
3104
+ type: "Person",
3105
+ name: "Test User",
3106
+ icon: {
3107
+ type: "Image",
3108
+ url: "/avatars/test-avatar.jpg"
3109
+ }
3110
+ };
3111
+ const person = await Person.fromJsonLd(json, {
3112
+ documentLoader: mockDocumentLoader,
3113
+ contextLoader: mockDocumentLoader
3114
+ });
3115
+ const icon = await person.getIcon();
3116
+ assertEquals(icon?.url, new URL("https://example.com/avatars/test-avatar.jpg"));
3117
+ const json2 = {
3118
+ "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
3119
+ id: "https://example.com/ap/actors/019382d3-63d7-7cf7-86e8-91e2551c306c",
3120
+ type: "Person",
3121
+ name: "Test User",
3122
+ icon: {
3123
+ id: "https://media.example.com/avatars/test-avatar.jpg",
3124
+ type: "Image",
3125
+ url: "/avatars/test-avatar.jpg"
3126
+ }
3127
+ };
3128
+ const person2 = await Person.fromJsonLd(json2, {
3129
+ documentLoader: mockDocumentLoader,
3130
+ contextLoader: mockDocumentLoader
3131
+ });
3132
+ const icon2 = await person2.getIcon();
3133
+ assertEquals(icon2?.url, new URL("https://media.example.com/avatars/test-avatar.jpg"));
3134
+ });
3135
+ test("Person.fromJsonLd() with relative URLs and baseUrl", async () => {
3136
+ const json = {
3137
+ "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
3138
+ "id": "https://example.com/ap/actors/019382d3-63d7-7cf7-86e8-91e2551c306c",
3139
+ "type": "Person",
3140
+ "name": "Test User",
3141
+ "icon": {
3142
+ "type": "Image",
3143
+ "url": "/avatars/test-avatar.jpg"
3144
+ }
3145
+ };
3146
+ const personWithBase = await Person.fromJsonLd(json, {
3147
+ documentLoader: mockDocumentLoader,
3148
+ contextLoader: mockDocumentLoader,
3149
+ baseUrl: new URL("https://example.com")
3150
+ });
3151
+ const icon = await personWithBase.getIcon();
3152
+ assertEquals(icon?.url, new URL("https://example.com/avatars/test-avatar.jpg"));
3153
+ });
3154
+ test("FEP-fe34: Trust tracking in object construction", async () => {
3155
+ const note = new Note({
3156
+ id: new URL("https://example.com/note"),
3157
+ content: "Hello World"
3158
+ });
3159
+ const create = new Create({
3160
+ id: new URL("https://example.com/create"),
3161
+ actor: new URL("https://example.com/actor"),
3162
+ object: note
3163
+ });
3164
+ assertEquals(create.objectId, new URL("https://example.com/note"));
3165
+ const result = await create.getObject();
3166
+ assertEquals(result, note);
3167
+ assertEquals(result?.content, "Hello World");
3168
+ });
3169
+ test("FEP-fe34: Trust tracking in object cloning", () => {
3170
+ const originalNote = new Note({
3171
+ id: new URL("https://example.com/note"),
3172
+ content: "Original content"
3173
+ });
3174
+ const create = new Create({
3175
+ id: new URL("https://example.com/create"),
3176
+ actor: new URL("https://example.com/actor"),
3177
+ object: originalNote
3178
+ });
3179
+ const newNote = new Note({
3180
+ id: new URL("https://example.com/new-note"),
3181
+ content: "New content"
3182
+ });
3183
+ const clonedCreate = create.clone({ object: newNote });
3184
+ assertEquals(clonedCreate.objectId, new URL("https://example.com/new-note"));
3185
+ });
3186
+ test("FEP-fe34: crossOrigin ignore behavior (default)", async () => {
3187
+ const crossOriginDocumentLoader = async (url) => {
3188
+ if (url === "https://different-origin.com/note") return {
3189
+ documentUrl: url,
3190
+ contextUrl: null,
3191
+ document: {
3192
+ "@context": "https://www.w3.org/ns/activitystreams",
3193
+ "@type": "Note",
3194
+ "@id": "https://malicious.com/fake-note",
3195
+ "content": "This is a spoofed note"
3196
+ }
3197
+ };
3198
+ throw new Error("Document not found");
3199
+ };
3200
+ const create = new Create({
3201
+ id: new URL("https://example.com/create"),
3202
+ actor: new URL("https://example.com/actor"),
3203
+ object: new URL("https://different-origin.com/note")
3204
+ });
3205
+ const result = await create.getObject({ documentLoader: crossOriginDocumentLoader });
3206
+ assertEquals(result, null);
3207
+ });
3208
+ test("FEP-fe34: crossOrigin throw behavior", async () => {
3209
+ const crossOriginDocumentLoader = async (url) => {
3210
+ if (url === "https://different-origin.com/note") return {
3211
+ documentUrl: url,
3212
+ contextUrl: null,
3213
+ document: {
3214
+ "@context": "https://www.w3.org/ns/activitystreams",
3215
+ "@type": "Note",
3216
+ "@id": "https://malicious.com/fake-note",
3217
+ "content": "This is a spoofed note"
3218
+ }
3219
+ };
3220
+ throw new Error("Document not found");
3221
+ };
3222
+ const create = new Create({
3223
+ id: new URL("https://example.com/create"),
3224
+ actor: new URL("https://example.com/actor"),
3225
+ object: new URL("https://different-origin.com/note")
3226
+ });
3227
+ await assertRejects(() => create.getObject({
3228
+ documentLoader: crossOriginDocumentLoader,
3229
+ crossOrigin: "throw"
3230
+ }), Error, "The object's @id (https://malicious.com/fake-note) has a different origin than the document URL (https://different-origin.com/note)");
3231
+ });
3232
+ test("FEP-fe34: crossOrigin trust behavior", async () => {
3233
+ const crossOriginDocumentLoader = async (url) => {
3234
+ if (url === "https://different-origin.com/note") return {
3235
+ documentUrl: url,
3236
+ contextUrl: null,
3237
+ document: {
3238
+ "@context": "https://www.w3.org/ns/activitystreams",
3239
+ "@type": "Note",
3240
+ "@id": "https://malicious.com/fake-note",
3241
+ "content": "This is a spoofed note"
3242
+ }
3243
+ };
3244
+ throw new Error("Document not found");
3245
+ };
3246
+ const create = new Create({
3247
+ id: new URL("https://example.com/create"),
3248
+ actor: new URL("https://example.com/actor"),
3249
+ object: new URL("https://different-origin.com/note")
3250
+ });
3251
+ const result = await create.getObject({
3252
+ documentLoader: crossOriginDocumentLoader,
3253
+ crossOrigin: "trust"
3254
+ });
3255
+ assertInstanceOf(result, Note);
3256
+ assertEquals(result?.id, new URL("https://malicious.com/fake-note"));
3257
+ assertEquals(result?.content, "This is a spoofed note");
3258
+ });
3259
+ test("FEP-fe34: Same origin objects are trusted", async () => {
3260
+ const sameOriginDocumentLoader = async (url) => {
3261
+ if (url === "https://example.com/note") return {
3262
+ documentUrl: url,
3263
+ contextUrl: null,
3264
+ document: {
3265
+ "@context": "https://www.w3.org/ns/activitystreams",
3266
+ "@type": "Note",
3267
+ "@id": "https://example.com/note",
3268
+ "content": "This is a legitimate note"
3269
+ }
3270
+ };
3271
+ throw new Error("Document not found");
3272
+ };
3273
+ const create = new Create({
3274
+ id: new URL("https://example.com/create"),
3275
+ actor: new URL("https://example.com/actor"),
3276
+ object: new URL("https://example.com/note")
3277
+ });
3278
+ const result = await create.getObject({ documentLoader: sameOriginDocumentLoader });
3279
+ assertInstanceOf(result, Note);
3280
+ assertEquals(result?.id, new URL("https://example.com/note"));
3281
+ assertEquals(result?.content, "This is a legitimate note");
3282
+ });
3283
+ test("FEP-fe34: Embedded cross-origin objects from JSON-LD are ignored by default", async () => {
3284
+ const createDocumentLoader = async (url) => {
3285
+ if (url === "https://example.com/create") return {
3286
+ documentUrl: url,
3287
+ contextUrl: null,
3288
+ document: {
3289
+ "@context": "https://www.w3.org/ns/activitystreams",
3290
+ "@type": "Create",
3291
+ "@id": "https://example.com/create",
3292
+ "actor": "https://example.com/actor",
3293
+ "object": {
3294
+ "@type": "Note",
3295
+ "@id": "https://different-origin.com/note",
3296
+ "content": "Embedded note from JSON-LD"
3297
+ }
3298
+ }
3299
+ };
3300
+ throw new Error("Document not found");
3301
+ };
3302
+ const create = await Create.fromJsonLd(await createDocumentLoader("https://example.com/create").then((r) => r.document), { documentLoader: createDocumentLoader });
3303
+ const objectDocumentLoader = async (url) => {
3304
+ if (url === "https://different-origin.com/note") return {
3305
+ documentUrl: url,
3306
+ contextUrl: null,
3307
+ document: {
3308
+ "@context": "https://www.w3.org/ns/activitystreams",
3309
+ "@type": "Note",
3310
+ "@id": "https://different-origin.com/note",
3311
+ "content": "Legitimate note from origin"
3312
+ }
3313
+ };
3314
+ throw new Error("Document not found");
3315
+ };
3316
+ const result = await create.getObject({ documentLoader: objectDocumentLoader });
3317
+ assertInstanceOf(result, Note);
3318
+ assertEquals(result?.content, "Legitimate note from origin");
3319
+ });
3320
+ test("FEP-fe34: Constructor vs JSON-LD parsing trust difference", async () => {
3321
+ const constructorCreate = new Create({
3322
+ id: new URL("https://example.com/create"),
3323
+ actor: new URL("https://example.com/actor"),
3324
+ object: new Note({
3325
+ id: new URL("https://different-origin.com/note"),
3326
+ content: "Constructor embedded note"
3327
+ })
3328
+ });
3329
+ const constructorResult = await constructorCreate.getObject();
3330
+ assertEquals(constructorResult?.content, "Constructor embedded note");
3331
+ const jsonLdCreate = await Create.fromJsonLd({
3332
+ "@context": "https://www.w3.org/ns/activitystreams",
3333
+ "@type": "Create",
3334
+ "@id": "https://example.com/create",
3335
+ "actor": "https://example.com/actor",
3336
+ "object": {
3337
+ "@type": "Note",
3338
+ "@id": "https://different-origin.com/note",
3339
+ "content": "JSON-LD embedded note"
3340
+ }
3341
+ });
3342
+ const documentLoader = async (url) => {
3343
+ if (url === "https://different-origin.com/note") return {
3344
+ documentUrl: url,
3345
+ contextUrl: null,
3346
+ document: {
3347
+ "@context": "https://www.w3.org/ns/activitystreams",
3348
+ "@type": "Note",
3349
+ "@id": "https://different-origin.com/note",
3350
+ "content": "Fetched from origin"
3351
+ }
3352
+ };
3353
+ throw new Error("Document not found");
3354
+ };
3355
+ const jsonLdResult = await jsonLdCreate.getObject({ documentLoader });
3356
+ assertEquals(jsonLdResult?.content, "Fetched from origin");
3357
+ });
3358
+ test("FEP-fe34: Array properties respect cross-origin policy", async () => {
3359
+ const crossOriginDocumentLoader = async (url) => {
3360
+ if (url === "https://different-origin.com/note1") return {
3361
+ documentUrl: url,
3362
+ contextUrl: null,
3363
+ document: {
3364
+ "@context": "https://www.w3.org/ns/activitystreams",
3365
+ "@type": "Note",
3366
+ "@id": "https://malicious.com/fake-note1",
3367
+ "content": "Fake note 1"
3368
+ }
3369
+ };
3370
+ else if (url === "https://example.com/note2") return {
3371
+ documentUrl: url,
3372
+ contextUrl: null,
3373
+ document: {
3374
+ "@context": "https://www.w3.org/ns/activitystreams",
3375
+ "@type": "Note",
3376
+ "@id": "https://example.com/note2",
3377
+ "content": "Legitimate note 2"
3378
+ }
3379
+ };
3380
+ throw new Error("Document not found");
3381
+ };
3382
+ const collection = new Collection({
3383
+ id: new URL("https://example.com/collection"),
3384
+ items: [new URL("https://different-origin.com/note1"), new URL("https://example.com/note2")]
3385
+ });
3386
+ const items = [];
3387
+ for await (const item of collection.getItems({ documentLoader: crossOriginDocumentLoader })) items.push(item);
3388
+ assertEquals(items.length, 1);
3389
+ assertInstanceOf(items[0], Note);
3390
+ assertEquals(items[0].content, "Legitimate note 2");
3391
+ });
3392
+ test("FEP-fe34: Array properties with crossOrigin trust option", async () => {
3393
+ const crossOriginDocumentLoader = async (url) => {
3394
+ if (url === "https://different-origin.com/note1") return {
3395
+ documentUrl: url,
3396
+ contextUrl: null,
3397
+ document: {
3398
+ "@context": "https://www.w3.org/ns/activitystreams",
3399
+ "@type": "Note",
3400
+ "@id": "https://malicious.com/fake-note1",
3401
+ "content": "Fake note 1"
3402
+ }
3403
+ };
3404
+ else if (url === "https://example.com/note2") return {
3405
+ documentUrl: url,
3406
+ contextUrl: null,
3407
+ document: {
3408
+ "@context": "https://www.w3.org/ns/activitystreams",
3409
+ "@type": "Note",
3410
+ "@id": "https://example.com/note2",
3411
+ "content": "Legitimate note 2"
3412
+ }
3413
+ };
3414
+ throw new Error("Document not found");
3415
+ };
3416
+ const collection = new Collection({
3417
+ id: new URL("https://example.com/collection"),
3418
+ items: [new URL("https://different-origin.com/note1"), new URL("https://example.com/note2")]
3419
+ });
3420
+ const items = [];
3421
+ for await (const item of collection.getItems({
3422
+ documentLoader: crossOriginDocumentLoader,
3423
+ crossOrigin: "trust"
3424
+ })) items.push(item);
3425
+ assertEquals(items.length, 2);
3426
+ assertInstanceOf(items[0], Note);
3427
+ assertInstanceOf(items[1], Note);
3428
+ assertEquals(items[0].content, "Fake note 1");
3429
+ assertEquals(items[1].content, "Legitimate note 2");
3430
+ });
3431
+ test("FEP-fe34: Embedded objects in arrays from JSON-LD respect cross-origin policy", async () => {
3432
+ const collectionDocumentLoader = async (url) => {
3433
+ if (url === "https://example.com/collection") return {
3434
+ documentUrl: url,
3435
+ contextUrl: null,
3436
+ document: {
3437
+ "@context": "https://www.w3.org/ns/activitystreams",
3438
+ "@type": "Collection",
3439
+ "@id": "https://example.com/collection",
3440
+ "items": [{
3441
+ "@type": "Note",
3442
+ "@id": "https://example.com/trusted-note",
3443
+ "content": "Trusted embedded note from JSON-LD"
3444
+ }, {
3445
+ "@type": "Note",
3446
+ "@id": "https://different-origin.com/untrusted-note",
3447
+ "content": "Untrusted embedded note from JSON-LD"
3448
+ }]
3449
+ }
3450
+ };
3451
+ throw new Error("Document not found");
3452
+ };
3453
+ const collection = await Collection.fromJsonLd(await collectionDocumentLoader("https://example.com/collection").then((r) => r.document), { documentLoader: collectionDocumentLoader });
3454
+ const itemDocumentLoader = async (url) => {
3455
+ if (url === "https://example.com/trusted-note") return {
3456
+ documentUrl: url,
3457
+ contextUrl: null,
3458
+ document: {
3459
+ "@context": "https://www.w3.org/ns/activitystreams",
3460
+ "@type": "Note",
3461
+ "@id": "https://example.com/trusted-note",
3462
+ "content": "Trusted note from origin"
3463
+ }
3464
+ };
3465
+ else if (url === "https://different-origin.com/untrusted-note") return {
3466
+ documentUrl: url,
3467
+ contextUrl: null,
3468
+ document: {
3469
+ "@context": "https://www.w3.org/ns/activitystreams",
3470
+ "@type": "Note",
3471
+ "@id": "https://different-origin.com/untrusted-note",
3472
+ "content": "Legitimate note from actual origin"
3473
+ }
3474
+ };
3475
+ throw new Error("Document not found");
3476
+ };
3477
+ const items = [];
3478
+ for await (const item of collection.getItems({ documentLoader: itemDocumentLoader })) items.push(item);
3479
+ assertEquals(items.length, 2);
3480
+ assertInstanceOf(items[0], Note);
3481
+ assertEquals(items[0].content, "Trusted embedded note from JSON-LD");
3482
+ assertInstanceOf(items[1], Note);
3483
+ assertEquals(items[1].content, "Legitimate note from actual origin");
3484
+ });
3062
3485
  function getAllProperties(type, types$1) {
3063
3486
  const props = type.properties;
3064
3487
  if (type.extends != null) props.push(...getAllProperties(types$1[type.extends], types$1));