@fedify/fedify 1.9.0-pr.407.1541 → 1.9.0-pr.421.1746
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.
- package/dist/actor-B2pAR8hn.cjs +42606 -0
- package/dist/{actor-Ci9FEnz7.js → actor-BGkVHk1D.js} +6951 -2127
- package/dist/{actor-Ch5yFYFG.d.ts → actor-C1Euqngb.d.ts} +1 -1
- package/dist/{actor-CgxU5g3T.js → actor-CRMvoMgB.js} +1 -1
- package/dist/actor-Ydzhc8dj.d.cts +128 -0
- package/dist/{authdocloader-C1mRjUL0.js → authdocloader-1wvQznSP.js} +6 -6
- package/dist/authdocloader-B6vfY0DQ.cjs +58 -0
- package/dist/{authdocloader-BzYD_FmX.js → authdocloader-BaK01biC.js} +3 -3
- package/dist/{builder-BA9imTs-.js → builder-BYjzwwU1.js} +14 -8
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/{client-a0QdQSaG.js → client-CchEe2DS.js} +1 -1
- package/dist/client-DjT_tegg.d.cts +294 -0
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +13 -0
- package/dist/compat/mod.d.ts +7 -7
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +16 -16
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/{context-DFruNLny.d.ts → context-CXUibY4L.d.ts} +179 -116
- package/dist/context-CwUAkopp.d.cts +2324 -0
- package/dist/docloader-BeO6Nvv8.cjs +4862 -0
- package/dist/{docloader-B1FKn22p.js → docloader-Bf4PXDNP.js} +188 -8
- package/dist/docloader-D-MrRyHl.d.cts +219 -0
- package/dist/{esm-BnTQrd7h.js → esm-DKBIHBc7.js} +1 -1
- package/dist/federation/builder.test.js +5 -5
- package/dist/federation/collection.test.js +3 -3
- package/dist/federation/handler.test.js +17 -17
- package/dist/federation/idempotency.test.d.ts +3 -0
- package/dist/federation/idempotency.test.js +202 -0
- package/dist/federation/inbox.test.js +4 -4
- package/dist/federation/keycache.test.js +4 -4
- package/dist/federation/kv.test.js +4 -3
- package/dist/federation/middleware.test.js +18 -18
- package/dist/federation/mod.cjs +29 -0
- package/dist/federation/mod.d.cts +13 -0
- package/dist/federation/mod.d.ts +7 -7
- package/dist/federation/mod.js +15 -15
- package/dist/federation/mq.test.js +3 -3
- package/dist/federation/retry.test.js +3 -3
- package/dist/federation/router.test.js +3 -3
- package/dist/federation/send.test.js +10 -10
- package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
- package/dist/federation-H2_En3j5.cjs +244 -0
- package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
- package/dist/http-B1_DzfAU.d.cts +253 -0
- package/dist/{http-_F1-otnG.js → http-BciknU_m.js} +7 -7
- package/dist/http-BkgY_K-o.cjs +826 -0
- package/dist/{http-BJUVXM-v.js → http-CvT-8K7A.js} +3 -3
- package/dist/{http-D8Q4xH0d.d.ts → http-wsGR6KkT.d.ts} +1 -1
- package/dist/{inbox-BdmFE-7t.js → inbox-DmOmHCt8.js} +29 -7
- package/dist/key-BNpAX-yy.cjs +290 -0
- package/dist/{key-BwUPZ9c4.js → key-Bf8wecsW.js} +3 -3
- package/dist/{key-6mpld0vV.js → key-Btn1rSKF.js} +5 -5
- package/dist/key-C-s397Qs.cjs +10 -0
- package/dist/{key-BjMZVyIc.js → key-CZzHTxwc.js} +2 -2
- package/dist/key-DlGLd9iL.js +10 -0
- package/dist/{keycache-C6v3brY3.js → keycache-BRLbFuE4.js} +1 -1
- package/dist/{keys-C4_uagjj.js → keys-DgqkndRb.js} +1 -1
- package/dist/kv-63Cil1MD.d.cts +81 -0
- package/dist/{ld-DjtcmRNX.js → ld-v-iyFVSd.js} +4 -4
- package/dist/lookup-6OyofAxv.cjs +137 -0
- package/dist/{lookup-CHXemfKP.js → lookup-8ZcpBTR8.js} +21 -12
- package/dist/{lookup-BacM-mU2.js → lookup-DxJ0NLYS.js} +4 -4
- package/dist/middleware-C7PiPtdo.cjs +4271 -0
- package/dist/middleware-CnRFgcDM.cjs +17 -0
- package/dist/middleware-CvThFfEG.js +26 -0
- package/dist/middleware-DG81e5gf.js +17 -0
- package/dist/{middleware-D229H6sF.js → middleware-DRE7WmH1.js} +96 -65
- package/dist/{middleware-Chvh9WwC.js → middleware-LZN4mAnb.js} +57 -54
- package/dist/mod-BUbqxBev.d.cts +307 -0
- package/dist/{mod-CiXjux2r.d.ts → mod-BcObK1Lz.d.ts} +2 -2
- package/dist/mod-C2tOeRkN.d.cts +1 -0
- package/dist/{mod-Cy6pkZSn.d.ts → mod-CDObsV1d.d.ts} +19 -1
- package/dist/{mod-BAuhKa9d.d.ts → mod-CIbqfZW0.d.ts} +1 -1
- package/dist/{mod-B7Pc0I7F.d.ts → mod-DgcYoyZK.d.ts} +2 -2
- package/dist/mod-Dt-G9ZOS.d.cts +102 -0
- package/dist/mod-FZd39qVq.d.cts +1 -0
- package/dist/mod-fjqfsrty.d.cts +266 -0
- package/dist/mod-jQ4OODsl.d.cts +113 -0
- package/dist/mod-mXx9V0q5.d.cts +80 -0
- package/dist/mod.cjs +152 -0
- package/dist/mod.d.cts +17 -0
- package/dist/mod.d.ts +10 -10
- package/dist/mod.js +20 -20
- package/dist/mq-B7R1Q-M5.d.cts +140 -0
- package/dist/nodeinfo/client.test.js +5 -5
- package/dist/nodeinfo/handler.test.js +16 -16
- package/dist/nodeinfo/mod.cjs +13 -0
- package/dist/nodeinfo/mod.d.cts +5 -0
- package/dist/nodeinfo/mod.js +6 -6
- package/dist/nodeinfo/semver.test.js +3 -3
- package/dist/nodeinfo/types.test.js +3 -3
- package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
- package/dist/nodeinfo-DfycQ8Wf.js +4 -0
- package/dist/owner-6KSEp9eV.d.cts +67 -0
- package/dist/{owner-D38zBIMc.d.ts → owner-BbeUDvOu.d.ts} +2 -2
- package/dist/{owner-C_Ovx3OW.js → owner-DiaqwZNX.js} +2 -2
- package/dist/{proof-Cn9ubQ_4.js → proof-BJmMlvgv.js} +9 -9
- package/dist/{proof-DsTmMO9a.js → proof-BLrU2QqY.js} +3 -3
- package/dist/proof-uoL7KsPK.cjs +673 -0
- package/dist/runtime/authdocloader.test.js +9 -9
- package/dist/runtime/docloader.test.js +4 -4
- package/dist/runtime/key.test.js +5 -5
- package/dist/runtime/langstr.test.js +3 -3
- package/dist/runtime/link.test.d.ts +3 -0
- package/dist/runtime/link.test.js +61 -0
- package/dist/runtime/mod.cjs +25 -0
- package/dist/runtime/mod.d.cts +6 -0
- package/dist/runtime/mod.d.ts +3 -3
- package/dist/runtime/mod.js +10 -10
- package/dist/runtime/multibase/multibase.test.js +3 -3
- package/dist/runtime/url.test.js +3 -3
- package/dist/runtime-C58AJWSv.cjs +4 -0
- package/dist/runtime-DPYEDf-o.js +4 -0
- package/dist/{send-B_t14nZe.js → send-Bh9H1ZtH.js} +2 -2
- package/dist/sig/http.test.js +9 -9
- package/dist/sig/key.test.js +6 -6
- package/dist/sig/ld.test.js +7 -7
- package/dist/sig/mod.cjs +30 -0
- package/dist/sig/mod.d.cts +8 -0
- package/dist/sig/mod.d.ts +5 -5
- package/dist/sig/mod.js +10 -10
- package/dist/sig/owner.test.js +7 -7
- package/dist/sig/proof.test.js +7 -7
- package/dist/sig-ByHXzqUi.cjs +4 -0
- package/dist/sig-Cj3tk-ig.js +4 -0
- package/dist/testing/docloader.test.js +3 -3
- package/dist/testing/mod.d.ts +385 -110
- package/dist/testing/mod.js +3 -3
- package/dist/{testing-BWnZ_sj_.js → testing-wv9xgBFV.js} +2 -2
- package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
- package/dist/transformers-CoBS-oFG.cjs +116 -0
- package/dist/{type-B8vENQVR.js → type-JHkkALfe.js} +7261 -2257
- package/dist/{types-vtD95MgU.js → types-D-8qHCG5.js} +4 -4
- package/dist/types-SEdRdlKp.cjs +488 -0
- package/dist/vocab/actor.test.js +5 -5
- package/dist/vocab/lookup.test.js +255 -5
- package/dist/vocab/mod.cjs +87 -0
- package/dist/vocab/mod.d.cts +6 -0
- package/dist/vocab/mod.d.ts +3 -3
- package/dist/vocab/mod.js +7 -7
- package/dist/vocab/type.test.js +3 -3
- package/dist/vocab/vocab.test.js +433 -9
- package/dist/vocab-BZ2XJ4IH.cjs +291 -0
- package/dist/{vocab-BEEm2I6u.d.ts → vocab-CDHNj5zp.d.ts} +290 -0
- package/dist/{vocab-BQIHm1R2.js → vocab-Cb3CeS7_.js} +26 -17
- package/dist/vocab-Cfs0937i.d.cts +14919 -0
- package/dist/webfinger/handler.test.js +16 -16
- package/dist/webfinger/lookup.test.js +4 -4
- package/dist/webfinger/mod.cjs +9 -0
- package/dist/webfinger/mod.d.cts +4 -0
- package/dist/webfinger/mod.js +6 -6
- package/dist/webfinger-BjOEdFPs.cjs +4 -0
- package/dist/webfinger-De_bU0iE.js +4 -0
- package/dist/x/cfworkers.cjs +100 -0
- package/dist/x/cfworkers.d.cts +59 -0
- package/dist/x/cfworkers.js +3 -3
- package/dist/x/cfworkers.test.js +3 -3
- package/dist/x/hono.cjs +61 -0
- package/dist/x/hono.d.cts +54 -0
- package/dist/x/hono.d.ts +6 -6
- package/dist/x/hono.js +3 -3
- package/dist/x/sveltekit.cjs +69 -0
- package/dist/x/sveltekit.d.cts +46 -0
- package/dist/x/sveltekit.d.ts +6 -6
- package/dist/x/sveltekit.js +3 -3
- package/package.json +68 -13
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/key-MAzA0B5q.js +0 -10
- package/dist/middleware-BmxFy3Oa.js +0 -17
- package/dist/middleware-DJi4jhq9.js +0 -26
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/webfinger-C3GIyXIg.js +0 -4
package/dist/vocab/vocab.test.js
CHANGED
@@ -3,18 +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-
|
6
|
+
import { Activity, Announce, Collection, Create, CryptographicKey, Follow, Hashtag, LanguageString, Link, Note, Object as Object$1, OrderedCollectionPage, Person, Place, Question, Source, decode, vocab_exports } from "../type-JHkkALfe.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-
|
11
|
-
import { mockDocumentLoader, test } from "../testing-
|
10
|
+
import "../lookup-8ZcpBTR8.js";
|
11
|
+
import { mockDocumentLoader, test } from "../testing-wv9xgBFV.js";
|
12
12
|
import "../std__assert-X-_kMxKM.js";
|
13
13
|
import { assertFalse, assertRejects } from "../assert_rejects-DiIiJbZn.js";
|
14
14
|
import "../assert_is_error-BPGph1Jx.js";
|
15
15
|
import { assertNotEquals } from "../assert_not_equals-f3m3epl3.js";
|
16
16
|
import { assertThrows } from "../assert_throws-BOO88avQ.js";
|
17
|
-
import { ed25519PublicKey, rsaPublicKey1 } from "../keys-
|
17
|
+
import { ed25519PublicKey, rsaPublicKey1 } from "../keys-DgqkndRb.js";
|
18
18
|
import { pascalCase } from "es-toolkit";
|
19
19
|
import { parseLanguageTag } from "@phensley/language-tag";
|
20
20
|
import { Validator } from "@cfworker/json-schema";
|
@@ -2203,10 +2203,25 @@ const scalarTypes = {
|
|
2203
2203
|
dataCheck(v) {
|
2204
2204
|
return `typeof ${v} === "object" && "@id" in ${v}
|
2205
2205
|
&& typeof ${v}["@id"] === "string"
|
2206
|
-
&& ${v}["@id"] !== ""
|
2207
|
-
},
|
2208
|
-
decoder(v) {
|
2209
|
-
return
|
2206
|
+
&& ${v}["@id"] !== ""`;
|
2207
|
+
},
|
2208
|
+
decoder(v, baseUrlVar) {
|
2209
|
+
return `${v}["@id"].startsWith("at://")
|
2210
|
+
? new URL("at://" +
|
2211
|
+
encodeURIComponent(
|
2212
|
+
${v}["@id"].includes("/", 5)
|
2213
|
+
? ${v}["@id"].slice(5, ${v}["@id"].indexOf("/", 5))
|
2214
|
+
: ${v}["@id"].slice(5)
|
2215
|
+
) +
|
2216
|
+
(
|
2217
|
+
${v}["@id"].includes("/", 5)
|
2218
|
+
? ${v}["@id"].slice(${v}["@id"].indexOf("/", 5))
|
2219
|
+
: ""
|
2220
|
+
)
|
2221
|
+
)
|
2222
|
+
: URL.canParse(${v}["@id"]) && ${baseUrlVar}
|
2223
|
+
? new URL(${v}["@id"])
|
2224
|
+
: new URL(${v}["@id"], ${baseUrlVar})`;
|
2210
2225
|
}
|
2211
2226
|
},
|
2212
2227
|
"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString": {
|
@@ -2820,6 +2835,7 @@ test({
|
|
2820
2835
|
test("Person.fromJsonLd()", async () => {
|
2821
2836
|
const person = await Person.fromJsonLd({
|
2822
2837
|
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
2838
|
+
"id": "https://todon.eu/users/hongminhee",
|
2823
2839
|
"publicKey": {
|
2824
2840
|
"id": "https://todon.eu/users/hongminhee#main-key",
|
2825
2841
|
"owner": "https://todon.eu/users/hongminhee",
|
@@ -2827,7 +2843,8 @@ test("Person.fromJsonLd()", async () => {
|
|
2827
2843
|
}
|
2828
2844
|
}, {
|
2829
2845
|
documentLoader: mockDocumentLoader,
|
2830
|
-
contextLoader: mockDocumentLoader
|
2846
|
+
contextLoader: mockDocumentLoader,
|
2847
|
+
baseUrl: new URL("https://todon.eu/")
|
2831
2848
|
});
|
2832
2849
|
assertEquals(person.publicKeyId, new URL("https://todon.eu/users/hongminhee#main-key"));
|
2833
2850
|
const publicKey = await person.getPublicKey({ documentLoader: mockDocumentLoader });
|
@@ -3024,6 +3041,413 @@ test("Actor.getOutbox()", async () => {
|
|
3024
3041
|
assertInstanceOf(outbox, OrderedCollectionPage);
|
3025
3042
|
assertEquals(outbox.totalItems, 1);
|
3026
3043
|
});
|
3044
|
+
test("Link.fromJsonLd()", async () => {
|
3045
|
+
const link = await Link.fromJsonLd({
|
3046
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3047
|
+
"type": "Link",
|
3048
|
+
"rel": "canonical",
|
3049
|
+
"href": "at://did:plc:ia76kvnndjutgedggx2ibrem/app.bsky.feed.post/3lyxjjs27jkqg"
|
3050
|
+
});
|
3051
|
+
assertEquals(link.rel, "canonical");
|
3052
|
+
assertEquals(link.href, new URL("at://did%3Aplc%3Aia76kvnndjutgedggx2ibrem/app.bsky.feed.post/3lyxjjs27jkqg"));
|
3053
|
+
const link2 = await Link.fromJsonLd({
|
3054
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3055
|
+
"type": "Link",
|
3056
|
+
"href": "at://bnewbold.bsky.team/app.bsky.feed.post/3jwdwj2ctlk26"
|
3057
|
+
});
|
3058
|
+
assertEquals(link2.href, new URL("at://bnewbold.bsky.team/app.bsky.feed.post/3jwdwj2ctlk26"));
|
3059
|
+
const link3 = await Link.fromJsonLd({
|
3060
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3061
|
+
"type": "Link",
|
3062
|
+
"href": "at://did:plc:ia76kvnndjutgedggx2ibrem"
|
3063
|
+
});
|
3064
|
+
assertEquals(link3.href, new URL("at://did%3Aplc%3Aia76kvnndjutgedggx2ibrem"));
|
3065
|
+
});
|
3066
|
+
test("Person.fromJsonLd() with relative URLs", async () => {
|
3067
|
+
const json = {
|
3068
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
3069
|
+
id: "https://example.com/ap/actors/019382d3-63d7-7cf7-86e8-91e2551c306c",
|
3070
|
+
type: "Person",
|
3071
|
+
name: "Test User",
|
3072
|
+
icon: {
|
3073
|
+
type: "Image",
|
3074
|
+
url: "/avatars/test-avatar.jpg"
|
3075
|
+
}
|
3076
|
+
};
|
3077
|
+
const person = await Person.fromJsonLd(json, {
|
3078
|
+
documentLoader: mockDocumentLoader,
|
3079
|
+
contextLoader: mockDocumentLoader
|
3080
|
+
});
|
3081
|
+
const icon = await person.getIcon();
|
3082
|
+
assertEquals(icon?.url, new URL("https://example.com/avatars/test-avatar.jpg"));
|
3083
|
+
const json2 = {
|
3084
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
3085
|
+
id: "https://example.com/ap/actors/019382d3-63d7-7cf7-86e8-91e2551c306c",
|
3086
|
+
type: "Person",
|
3087
|
+
name: "Test User",
|
3088
|
+
icon: {
|
3089
|
+
id: "https://media.example.com/avatars/test-avatar.jpg",
|
3090
|
+
type: "Image",
|
3091
|
+
url: "/avatars/test-avatar.jpg"
|
3092
|
+
}
|
3093
|
+
};
|
3094
|
+
const person2 = await Person.fromJsonLd(json2, {
|
3095
|
+
documentLoader: mockDocumentLoader,
|
3096
|
+
contextLoader: mockDocumentLoader
|
3097
|
+
});
|
3098
|
+
const icon2 = await person2.getIcon();
|
3099
|
+
assertEquals(icon2?.url, new URL("https://media.example.com/avatars/test-avatar.jpg"));
|
3100
|
+
});
|
3101
|
+
test("Person.fromJsonLd() with relative URLs and baseUrl", async () => {
|
3102
|
+
const json = {
|
3103
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
3104
|
+
"id": "https://example.com/ap/actors/019382d3-63d7-7cf7-86e8-91e2551c306c",
|
3105
|
+
"type": "Person",
|
3106
|
+
"name": "Test User",
|
3107
|
+
"icon": {
|
3108
|
+
"type": "Image",
|
3109
|
+
"url": "/avatars/test-avatar.jpg"
|
3110
|
+
}
|
3111
|
+
};
|
3112
|
+
const personWithBase = await Person.fromJsonLd(json, {
|
3113
|
+
documentLoader: mockDocumentLoader,
|
3114
|
+
contextLoader: mockDocumentLoader,
|
3115
|
+
baseUrl: new URL("https://example.com")
|
3116
|
+
});
|
3117
|
+
const icon = await personWithBase.getIcon();
|
3118
|
+
assertEquals(icon?.url, new URL("https://example.com/avatars/test-avatar.jpg"));
|
3119
|
+
});
|
3120
|
+
test("FEP-fe34: Trust tracking in object construction", async () => {
|
3121
|
+
const note = new Note({
|
3122
|
+
id: new URL("https://example.com/note"),
|
3123
|
+
content: "Hello World"
|
3124
|
+
});
|
3125
|
+
const create = new Create({
|
3126
|
+
id: new URL("https://example.com/create"),
|
3127
|
+
actor: new URL("https://example.com/actor"),
|
3128
|
+
object: note
|
3129
|
+
});
|
3130
|
+
assertEquals(create.objectId, new URL("https://example.com/note"));
|
3131
|
+
const result = await create.getObject();
|
3132
|
+
assertEquals(result, note);
|
3133
|
+
assertEquals(result?.content, "Hello World");
|
3134
|
+
});
|
3135
|
+
test("FEP-fe34: Trust tracking in object cloning", () => {
|
3136
|
+
const originalNote = new Note({
|
3137
|
+
id: new URL("https://example.com/note"),
|
3138
|
+
content: "Original content"
|
3139
|
+
});
|
3140
|
+
const create = new Create({
|
3141
|
+
id: new URL("https://example.com/create"),
|
3142
|
+
actor: new URL("https://example.com/actor"),
|
3143
|
+
object: originalNote
|
3144
|
+
});
|
3145
|
+
const newNote = new Note({
|
3146
|
+
id: new URL("https://example.com/new-note"),
|
3147
|
+
content: "New content"
|
3148
|
+
});
|
3149
|
+
const clonedCreate = create.clone({ object: newNote });
|
3150
|
+
assertEquals(clonedCreate.objectId, new URL("https://example.com/new-note"));
|
3151
|
+
});
|
3152
|
+
test("FEP-fe34: crossOrigin ignore behavior (default)", async () => {
|
3153
|
+
const crossOriginDocumentLoader = async (url) => {
|
3154
|
+
if (url === "https://different-origin.com/note") return {
|
3155
|
+
documentUrl: url,
|
3156
|
+
contextUrl: null,
|
3157
|
+
document: {
|
3158
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3159
|
+
"@type": "Note",
|
3160
|
+
"@id": "https://malicious.com/fake-note",
|
3161
|
+
"content": "This is a spoofed note"
|
3162
|
+
}
|
3163
|
+
};
|
3164
|
+
throw new Error("Document not found");
|
3165
|
+
};
|
3166
|
+
const create = new Create({
|
3167
|
+
id: new URL("https://example.com/create"),
|
3168
|
+
actor: new URL("https://example.com/actor"),
|
3169
|
+
object: new URL("https://different-origin.com/note")
|
3170
|
+
});
|
3171
|
+
const result = await create.getObject({ documentLoader: crossOriginDocumentLoader });
|
3172
|
+
assertEquals(result, null);
|
3173
|
+
});
|
3174
|
+
test("FEP-fe34: crossOrigin throw behavior", async () => {
|
3175
|
+
const crossOriginDocumentLoader = async (url) => {
|
3176
|
+
if (url === "https://different-origin.com/note") return {
|
3177
|
+
documentUrl: url,
|
3178
|
+
contextUrl: null,
|
3179
|
+
document: {
|
3180
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3181
|
+
"@type": "Note",
|
3182
|
+
"@id": "https://malicious.com/fake-note",
|
3183
|
+
"content": "This is a spoofed note"
|
3184
|
+
}
|
3185
|
+
};
|
3186
|
+
throw new Error("Document not found");
|
3187
|
+
};
|
3188
|
+
const create = new Create({
|
3189
|
+
id: new URL("https://example.com/create"),
|
3190
|
+
actor: new URL("https://example.com/actor"),
|
3191
|
+
object: new URL("https://different-origin.com/note")
|
3192
|
+
});
|
3193
|
+
await assertRejects(() => create.getObject({
|
3194
|
+
documentLoader: crossOriginDocumentLoader,
|
3195
|
+
crossOrigin: "throw"
|
3196
|
+
}), Error, "The object's @id (https://malicious.com/fake-note) has a different origin than the document URL (https://different-origin.com/note)");
|
3197
|
+
});
|
3198
|
+
test("FEP-fe34: crossOrigin trust behavior", async () => {
|
3199
|
+
const crossOriginDocumentLoader = async (url) => {
|
3200
|
+
if (url === "https://different-origin.com/note") return {
|
3201
|
+
documentUrl: url,
|
3202
|
+
contextUrl: null,
|
3203
|
+
document: {
|
3204
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3205
|
+
"@type": "Note",
|
3206
|
+
"@id": "https://malicious.com/fake-note",
|
3207
|
+
"content": "This is a spoofed note"
|
3208
|
+
}
|
3209
|
+
};
|
3210
|
+
throw new Error("Document not found");
|
3211
|
+
};
|
3212
|
+
const create = new Create({
|
3213
|
+
id: new URL("https://example.com/create"),
|
3214
|
+
actor: new URL("https://example.com/actor"),
|
3215
|
+
object: new URL("https://different-origin.com/note")
|
3216
|
+
});
|
3217
|
+
const result = await create.getObject({
|
3218
|
+
documentLoader: crossOriginDocumentLoader,
|
3219
|
+
crossOrigin: "trust"
|
3220
|
+
});
|
3221
|
+
assertInstanceOf(result, Note);
|
3222
|
+
assertEquals(result?.id, new URL("https://malicious.com/fake-note"));
|
3223
|
+
assertEquals(result?.content, "This is a spoofed note");
|
3224
|
+
});
|
3225
|
+
test("FEP-fe34: Same origin objects are trusted", async () => {
|
3226
|
+
const sameOriginDocumentLoader = async (url) => {
|
3227
|
+
if (url === "https://example.com/note") return {
|
3228
|
+
documentUrl: url,
|
3229
|
+
contextUrl: null,
|
3230
|
+
document: {
|
3231
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3232
|
+
"@type": "Note",
|
3233
|
+
"@id": "https://example.com/note",
|
3234
|
+
"content": "This is a legitimate note"
|
3235
|
+
}
|
3236
|
+
};
|
3237
|
+
throw new Error("Document not found");
|
3238
|
+
};
|
3239
|
+
const create = new Create({
|
3240
|
+
id: new URL("https://example.com/create"),
|
3241
|
+
actor: new URL("https://example.com/actor"),
|
3242
|
+
object: new URL("https://example.com/note")
|
3243
|
+
});
|
3244
|
+
const result = await create.getObject({ documentLoader: sameOriginDocumentLoader });
|
3245
|
+
assertInstanceOf(result, Note);
|
3246
|
+
assertEquals(result?.id, new URL("https://example.com/note"));
|
3247
|
+
assertEquals(result?.content, "This is a legitimate note");
|
3248
|
+
});
|
3249
|
+
test("FEP-fe34: Embedded cross-origin objects from JSON-LD are ignored by default", async () => {
|
3250
|
+
const createDocumentLoader = async (url) => {
|
3251
|
+
if (url === "https://example.com/create") return {
|
3252
|
+
documentUrl: url,
|
3253
|
+
contextUrl: null,
|
3254
|
+
document: {
|
3255
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3256
|
+
"@type": "Create",
|
3257
|
+
"@id": "https://example.com/create",
|
3258
|
+
"actor": "https://example.com/actor",
|
3259
|
+
"object": {
|
3260
|
+
"@type": "Note",
|
3261
|
+
"@id": "https://different-origin.com/note",
|
3262
|
+
"content": "Embedded note from JSON-LD"
|
3263
|
+
}
|
3264
|
+
}
|
3265
|
+
};
|
3266
|
+
throw new Error("Document not found");
|
3267
|
+
};
|
3268
|
+
const create = await Create.fromJsonLd(await createDocumentLoader("https://example.com/create").then((r) => r.document), { documentLoader: createDocumentLoader });
|
3269
|
+
const objectDocumentLoader = async (url) => {
|
3270
|
+
if (url === "https://different-origin.com/note") return {
|
3271
|
+
documentUrl: url,
|
3272
|
+
contextUrl: null,
|
3273
|
+
document: {
|
3274
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3275
|
+
"@type": "Note",
|
3276
|
+
"@id": "https://different-origin.com/note",
|
3277
|
+
"content": "Legitimate note from origin"
|
3278
|
+
}
|
3279
|
+
};
|
3280
|
+
throw new Error("Document not found");
|
3281
|
+
};
|
3282
|
+
const result = await create.getObject({ documentLoader: objectDocumentLoader });
|
3283
|
+
assertInstanceOf(result, Note);
|
3284
|
+
assertEquals(result?.content, "Legitimate note from origin");
|
3285
|
+
});
|
3286
|
+
test("FEP-fe34: Constructor vs JSON-LD parsing trust difference", async () => {
|
3287
|
+
const constructorCreate = new Create({
|
3288
|
+
id: new URL("https://example.com/create"),
|
3289
|
+
actor: new URL("https://example.com/actor"),
|
3290
|
+
object: new Note({
|
3291
|
+
id: new URL("https://different-origin.com/note"),
|
3292
|
+
content: "Constructor embedded note"
|
3293
|
+
})
|
3294
|
+
});
|
3295
|
+
const constructorResult = await constructorCreate.getObject();
|
3296
|
+
assertEquals(constructorResult?.content, "Constructor embedded note");
|
3297
|
+
const jsonLdCreate = await Create.fromJsonLd({
|
3298
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3299
|
+
"@type": "Create",
|
3300
|
+
"@id": "https://example.com/create",
|
3301
|
+
"actor": "https://example.com/actor",
|
3302
|
+
"object": {
|
3303
|
+
"@type": "Note",
|
3304
|
+
"@id": "https://different-origin.com/note",
|
3305
|
+
"content": "JSON-LD embedded note"
|
3306
|
+
}
|
3307
|
+
});
|
3308
|
+
const documentLoader = async (url) => {
|
3309
|
+
if (url === "https://different-origin.com/note") return {
|
3310
|
+
documentUrl: url,
|
3311
|
+
contextUrl: null,
|
3312
|
+
document: {
|
3313
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3314
|
+
"@type": "Note",
|
3315
|
+
"@id": "https://different-origin.com/note",
|
3316
|
+
"content": "Fetched from origin"
|
3317
|
+
}
|
3318
|
+
};
|
3319
|
+
throw new Error("Document not found");
|
3320
|
+
};
|
3321
|
+
const jsonLdResult = await jsonLdCreate.getObject({ documentLoader });
|
3322
|
+
assertEquals(jsonLdResult?.content, "Fetched from origin");
|
3323
|
+
});
|
3324
|
+
test("FEP-fe34: Array properties respect cross-origin policy", async () => {
|
3325
|
+
const crossOriginDocumentLoader = async (url) => {
|
3326
|
+
if (url === "https://different-origin.com/note1") return {
|
3327
|
+
documentUrl: url,
|
3328
|
+
contextUrl: null,
|
3329
|
+
document: {
|
3330
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3331
|
+
"@type": "Note",
|
3332
|
+
"@id": "https://malicious.com/fake-note1",
|
3333
|
+
"content": "Fake note 1"
|
3334
|
+
}
|
3335
|
+
};
|
3336
|
+
else if (url === "https://example.com/note2") return {
|
3337
|
+
documentUrl: url,
|
3338
|
+
contextUrl: null,
|
3339
|
+
document: {
|
3340
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3341
|
+
"@type": "Note",
|
3342
|
+
"@id": "https://example.com/note2",
|
3343
|
+
"content": "Legitimate note 2"
|
3344
|
+
}
|
3345
|
+
};
|
3346
|
+
throw new Error("Document not found");
|
3347
|
+
};
|
3348
|
+
const collection = new Collection({
|
3349
|
+
id: new URL("https://example.com/collection"),
|
3350
|
+
items: [new URL("https://different-origin.com/note1"), new URL("https://example.com/note2")]
|
3351
|
+
});
|
3352
|
+
const items = [];
|
3353
|
+
for await (const item of collection.getItems({ documentLoader: crossOriginDocumentLoader })) items.push(item);
|
3354
|
+
assertEquals(items.length, 1);
|
3355
|
+
assertInstanceOf(items[0], Note);
|
3356
|
+
assertEquals(items[0].content, "Legitimate note 2");
|
3357
|
+
});
|
3358
|
+
test("FEP-fe34: Array properties with crossOrigin trust option", 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({
|
3388
|
+
documentLoader: crossOriginDocumentLoader,
|
3389
|
+
crossOrigin: "trust"
|
3390
|
+
})) items.push(item);
|
3391
|
+
assertEquals(items.length, 2);
|
3392
|
+
assertInstanceOf(items[0], Note);
|
3393
|
+
assertInstanceOf(items[1], Note);
|
3394
|
+
assertEquals(items[0].content, "Fake note 1");
|
3395
|
+
assertEquals(items[1].content, "Legitimate note 2");
|
3396
|
+
});
|
3397
|
+
test("FEP-fe34: Embedded objects in arrays from JSON-LD respect cross-origin policy", async () => {
|
3398
|
+
const collectionDocumentLoader = async (url) => {
|
3399
|
+
if (url === "https://example.com/collection") return {
|
3400
|
+
documentUrl: url,
|
3401
|
+
contextUrl: null,
|
3402
|
+
document: {
|
3403
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3404
|
+
"@type": "Collection",
|
3405
|
+
"@id": "https://example.com/collection",
|
3406
|
+
"items": [{
|
3407
|
+
"@type": "Note",
|
3408
|
+
"@id": "https://example.com/trusted-note",
|
3409
|
+
"content": "Trusted embedded note from JSON-LD"
|
3410
|
+
}, {
|
3411
|
+
"@type": "Note",
|
3412
|
+
"@id": "https://different-origin.com/untrusted-note",
|
3413
|
+
"content": "Untrusted embedded note from JSON-LD"
|
3414
|
+
}]
|
3415
|
+
}
|
3416
|
+
};
|
3417
|
+
throw new Error("Document not found");
|
3418
|
+
};
|
3419
|
+
const collection = await Collection.fromJsonLd(await collectionDocumentLoader("https://example.com/collection").then((r) => r.document), { documentLoader: collectionDocumentLoader });
|
3420
|
+
const itemDocumentLoader = async (url) => {
|
3421
|
+
if (url === "https://example.com/trusted-note") return {
|
3422
|
+
documentUrl: url,
|
3423
|
+
contextUrl: null,
|
3424
|
+
document: {
|
3425
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3426
|
+
"@type": "Note",
|
3427
|
+
"@id": "https://example.com/trusted-note",
|
3428
|
+
"content": "Trusted note from origin"
|
3429
|
+
}
|
3430
|
+
};
|
3431
|
+
else if (url === "https://different-origin.com/untrusted-note") return {
|
3432
|
+
documentUrl: url,
|
3433
|
+
contextUrl: null,
|
3434
|
+
document: {
|
3435
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3436
|
+
"@type": "Note",
|
3437
|
+
"@id": "https://different-origin.com/untrusted-note",
|
3438
|
+
"content": "Legitimate note from actual origin"
|
3439
|
+
}
|
3440
|
+
};
|
3441
|
+
throw new Error("Document not found");
|
3442
|
+
};
|
3443
|
+
const items = [];
|
3444
|
+
for await (const item of collection.getItems({ documentLoader: itemDocumentLoader })) items.push(item);
|
3445
|
+
assertEquals(items.length, 2);
|
3446
|
+
assertInstanceOf(items[0], Note);
|
3447
|
+
assertEquals(items[0].content, "Trusted embedded note from JSON-LD");
|
3448
|
+
assertInstanceOf(items[1], Note);
|
3449
|
+
assertEquals(items[1].content, "Legitimate note from actual origin");
|
3450
|
+
});
|
3027
3451
|
function getAllProperties(type, types$1) {
|
3028
3452
|
const props = type.properties;
|
3029
3453
|
if (type.extends != null) props.push(...getAllProperties(types$1[type.extends], types$1));
|