@fedify/vocab 2.3.0-dev.1274 → 2.3.0-dev.1280
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/deno.json +1 -1
- package/dist/mod.cjs +1573 -652
- package/dist/mod.d.cts +30 -2
- package/dist/mod.d.ts +30 -2
- package/dist/mod.js +1573 -653
- package/dist-tests/{actor-CaUOaviw.mjs → actor-BM-a5Qzw.mjs} +2 -2
- package/dist-tests/actor.test.mjs +2 -2
- package/dist-tests/lookup.test.mjs +2 -2
- package/dist-tests/object.yaml +6 -0
- package/dist-tests/type.test.mjs +1 -1
- package/dist-tests/{vocab-B0Z-tH4q.mjs → vocab-BBRml5cy.mjs} +1571 -651
- package/dist-tests/vocab.test.mjs +338 -1
- package/package.json +4 -4
- package/src/mod.ts +1 -0
- package/src/object.yaml +6 -0
- package/src/preprocessors.ts +48 -0
- package/src/vocab.test.ts +455 -0
package/src/vocab.test.ts
CHANGED
|
@@ -1844,6 +1844,461 @@ test("Person.fromJsonLd() with relative URLs and baseUrl", async () => {
|
|
|
1844
1844
|
);
|
|
1845
1845
|
});
|
|
1846
1846
|
|
|
1847
|
+
test("Object.fromJsonLd() normalizes Link icon to Image", async () => {
|
|
1848
|
+
const json = {
|
|
1849
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1850
|
+
"type": "Note",
|
|
1851
|
+
"content": "Hello",
|
|
1852
|
+
"icon": {
|
|
1853
|
+
"type": "Link",
|
|
1854
|
+
"href": "https://example.com/icon.png",
|
|
1855
|
+
"mediaType": "image/png",
|
|
1856
|
+
"name": "Icon",
|
|
1857
|
+
"width": 64,
|
|
1858
|
+
"height": 64,
|
|
1859
|
+
},
|
|
1860
|
+
};
|
|
1861
|
+
const obj = await Object.fromJsonLd(json, {
|
|
1862
|
+
documentLoader: mockDocumentLoader,
|
|
1863
|
+
contextLoader: mockDocumentLoader,
|
|
1864
|
+
});
|
|
1865
|
+
const icon = await obj.getIcon();
|
|
1866
|
+
deepStrictEqual(
|
|
1867
|
+
icon?.url?.href,
|
|
1868
|
+
"https://example.com/icon.png",
|
|
1869
|
+
);
|
|
1870
|
+
deepStrictEqual(icon?.mediaType, "image/png");
|
|
1871
|
+
deepStrictEqual(icon?.names, ["Icon"]);
|
|
1872
|
+
deepStrictEqual(icon?.width, 64);
|
|
1873
|
+
deepStrictEqual(icon?.height, 64);
|
|
1874
|
+
});
|
|
1875
|
+
|
|
1876
|
+
test("Object.fromJsonLd() normalizes Link image to Image", async () => {
|
|
1877
|
+
const json = {
|
|
1878
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1879
|
+
"type": "Note",
|
|
1880
|
+
"content": "Hello",
|
|
1881
|
+
"image": {
|
|
1882
|
+
"type": "Link",
|
|
1883
|
+
"href": "https://example.com/banner.png",
|
|
1884
|
+
"mediaType": "image/png",
|
|
1885
|
+
"width": 800,
|
|
1886
|
+
"height": 200,
|
|
1887
|
+
},
|
|
1888
|
+
};
|
|
1889
|
+
const obj = await Object.fromJsonLd(json, {
|
|
1890
|
+
documentLoader: mockDocumentLoader,
|
|
1891
|
+
contextLoader: mockDocumentLoader,
|
|
1892
|
+
});
|
|
1893
|
+
const images = [];
|
|
1894
|
+
for await (const img of obj.getImages()) {
|
|
1895
|
+
images.push(img);
|
|
1896
|
+
}
|
|
1897
|
+
deepStrictEqual(images[0]?.url?.href, "https://example.com/banner.png");
|
|
1898
|
+
deepStrictEqual(images[0]?.mediaType, "image/png");
|
|
1899
|
+
deepStrictEqual(images[0]?.width, 800);
|
|
1900
|
+
deepStrictEqual(images[0]?.height, 200);
|
|
1901
|
+
});
|
|
1902
|
+
|
|
1903
|
+
test("Object.fromJsonLd() normalizes Link icon with relative URL", async () => {
|
|
1904
|
+
const json = {
|
|
1905
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1906
|
+
"type": "Note",
|
|
1907
|
+
"id": "https://example.com/notes/1",
|
|
1908
|
+
"content": "Hello",
|
|
1909
|
+
"icon": {
|
|
1910
|
+
"type": "Link",
|
|
1911
|
+
"href": "/icons/icon.png",
|
|
1912
|
+
},
|
|
1913
|
+
};
|
|
1914
|
+
const obj = await Object.fromJsonLd(json, {
|
|
1915
|
+
documentLoader: mockDocumentLoader,
|
|
1916
|
+
contextLoader: mockDocumentLoader,
|
|
1917
|
+
});
|
|
1918
|
+
const icon = await obj.getIcon();
|
|
1919
|
+
deepStrictEqual(
|
|
1920
|
+
icon?.url?.href,
|
|
1921
|
+
"https://example.com/icons/icon.png",
|
|
1922
|
+
);
|
|
1923
|
+
});
|
|
1924
|
+
|
|
1925
|
+
test(
|
|
1926
|
+
"Object.fromJsonLd() normalizes Link icon with relative id and baseUrl",
|
|
1927
|
+
async () => {
|
|
1928
|
+
const json = {
|
|
1929
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1930
|
+
"type": "Note",
|
|
1931
|
+
"id": "/notes/1",
|
|
1932
|
+
"content": "Hello",
|
|
1933
|
+
"icon": {
|
|
1934
|
+
"type": "Link",
|
|
1935
|
+
"href": "/icons/icon.png",
|
|
1936
|
+
},
|
|
1937
|
+
};
|
|
1938
|
+
const obj = await Object.fromJsonLd(json, {
|
|
1939
|
+
documentLoader: mockDocumentLoader,
|
|
1940
|
+
contextLoader: mockDocumentLoader,
|
|
1941
|
+
baseUrl: new URL("https://example.com/"),
|
|
1942
|
+
});
|
|
1943
|
+
const icon = await obj.getIcon();
|
|
1944
|
+
deepStrictEqual(obj.id?.href, "https://example.com/notes/1");
|
|
1945
|
+
deepStrictEqual(
|
|
1946
|
+
icon?.url?.href,
|
|
1947
|
+
"https://example.com/icons/icon.png",
|
|
1948
|
+
);
|
|
1949
|
+
},
|
|
1950
|
+
);
|
|
1951
|
+
|
|
1952
|
+
test("Object.fromJsonLd() decodes Image icon with relative id and baseUrl", async () => {
|
|
1953
|
+
const json = {
|
|
1954
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1955
|
+
"type": "Note",
|
|
1956
|
+
"id": "/notes/1",
|
|
1957
|
+
"content": "Hello",
|
|
1958
|
+
"icon": {
|
|
1959
|
+
"type": "Image",
|
|
1960
|
+
"url": "/icons/icon.png",
|
|
1961
|
+
},
|
|
1962
|
+
};
|
|
1963
|
+
const obj = await Object.fromJsonLd(json, {
|
|
1964
|
+
documentLoader: mockDocumentLoader,
|
|
1965
|
+
contextLoader: mockDocumentLoader,
|
|
1966
|
+
baseUrl: new URL("https://example.com/"),
|
|
1967
|
+
});
|
|
1968
|
+
const icon = await obj.getIcon();
|
|
1969
|
+
deepStrictEqual(obj.id?.href, "https://example.com/notes/1");
|
|
1970
|
+
deepStrictEqual(
|
|
1971
|
+
icon?.url?.href,
|
|
1972
|
+
"https://example.com/icons/icon.png",
|
|
1973
|
+
);
|
|
1974
|
+
});
|
|
1975
|
+
|
|
1976
|
+
test("Object.fromJsonLd() decodes compact icon id with relative id and baseUrl", async () => {
|
|
1977
|
+
const json = {
|
|
1978
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1979
|
+
"type": "Note",
|
|
1980
|
+
"id": "/notes/1",
|
|
1981
|
+
"content": "Hello",
|
|
1982
|
+
"icon": "/icons/icon.png",
|
|
1983
|
+
};
|
|
1984
|
+
const obj = await Object.fromJsonLd(json, {
|
|
1985
|
+
documentLoader: mockDocumentLoader,
|
|
1986
|
+
contextLoader: mockDocumentLoader,
|
|
1987
|
+
baseUrl: new URL("https://example.com/"),
|
|
1988
|
+
});
|
|
1989
|
+
deepStrictEqual(obj.id?.href, "https://example.com/notes/1");
|
|
1990
|
+
deepStrictEqual(
|
|
1991
|
+
obj.iconId?.href,
|
|
1992
|
+
"https://example.com/icons/icon.png",
|
|
1993
|
+
);
|
|
1994
|
+
});
|
|
1995
|
+
|
|
1996
|
+
test("Object.fromJsonLd() resolves compact icon id against document base", async () => {
|
|
1997
|
+
const json = {
|
|
1998
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1999
|
+
"type": "Note",
|
|
2000
|
+
"id": "../notes/1",
|
|
2001
|
+
"content": "Hello",
|
|
2002
|
+
"icon": "icon.png",
|
|
2003
|
+
};
|
|
2004
|
+
const obj = await Object.fromJsonLd(json, {
|
|
2005
|
+
documentLoader: mockDocumentLoader,
|
|
2006
|
+
contextLoader: mockDocumentLoader,
|
|
2007
|
+
baseUrl: new URL("https://example.com/outbox/page.json"),
|
|
2008
|
+
});
|
|
2009
|
+
deepStrictEqual(obj.id?.href, "https://example.com/outbox/notes/1");
|
|
2010
|
+
deepStrictEqual(
|
|
2011
|
+
obj.iconId?.href,
|
|
2012
|
+
"https://example.com/outbox/icon.png",
|
|
2013
|
+
);
|
|
2014
|
+
});
|
|
2015
|
+
|
|
2016
|
+
test("Object.fromJsonLd() skips blank node compact icon id", async () => {
|
|
2017
|
+
const json = {
|
|
2018
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2019
|
+
"type": "Note",
|
|
2020
|
+
"id": "/notes/1",
|
|
2021
|
+
"content": "Hello",
|
|
2022
|
+
"icon": { "@id": "_:b0" },
|
|
2023
|
+
};
|
|
2024
|
+
const obj = await Object.fromJsonLd(json, {
|
|
2025
|
+
documentLoader: mockDocumentLoader,
|
|
2026
|
+
contextLoader: mockDocumentLoader,
|
|
2027
|
+
baseUrl: new URL("https://example.com/"),
|
|
2028
|
+
});
|
|
2029
|
+
deepStrictEqual(obj.id?.href, "https://example.com/notes/1");
|
|
2030
|
+
deepStrictEqual(obj.iconId, null);
|
|
2031
|
+
});
|
|
2032
|
+
|
|
2033
|
+
test("Object.fromJsonLd() resolves compact icon id against baseUrl for did id", async () => {
|
|
2034
|
+
const json = {
|
|
2035
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2036
|
+
"type": "Note",
|
|
2037
|
+
"id": "did:plc:example",
|
|
2038
|
+
"content": "Hello",
|
|
2039
|
+
"icon": "/icons/icon.png",
|
|
2040
|
+
};
|
|
2041
|
+
const obj = await Object.fromJsonLd(json, {
|
|
2042
|
+
documentLoader: mockDocumentLoader,
|
|
2043
|
+
contextLoader: mockDocumentLoader,
|
|
2044
|
+
baseUrl: new URL("https://example.com/notes/1"),
|
|
2045
|
+
});
|
|
2046
|
+
deepStrictEqual(obj.id?.href, "did:plc:example");
|
|
2047
|
+
deepStrictEqual(
|
|
2048
|
+
obj.iconId?.href,
|
|
2049
|
+
"https://example.com/icons/icon.png",
|
|
2050
|
+
);
|
|
2051
|
+
});
|
|
2052
|
+
|
|
2053
|
+
test(
|
|
2054
|
+
"Object.getIcon() resolves relative Link href without id via cached re-parse",
|
|
2055
|
+
async () => {
|
|
2056
|
+
const json = {
|
|
2057
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2058
|
+
"type": "Note",
|
|
2059
|
+
"content": "Hello",
|
|
2060
|
+
"icon": {
|
|
2061
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2062
|
+
"type": "Link",
|
|
2063
|
+
"href": "/icons/star.png",
|
|
2064
|
+
"mediaType": "image/png",
|
|
2065
|
+
},
|
|
2066
|
+
};
|
|
2067
|
+
const obj = await Object.fromJsonLd(json, {
|
|
2068
|
+
documentLoader: mockDocumentLoader,
|
|
2069
|
+
contextLoader: mockDocumentLoader,
|
|
2070
|
+
baseUrl: new URL("https://example.com/"),
|
|
2071
|
+
});
|
|
2072
|
+
// getIcon() is called WITHOUT explicit baseUrl — the accessor
|
|
2073
|
+
// should reuse the baseUrl that was set during fromJsonLd().
|
|
2074
|
+
const icon = await obj.getIcon();
|
|
2075
|
+
deepStrictEqual(
|
|
2076
|
+
icon?.url?.href,
|
|
2077
|
+
"https://example.com/icons/star.png",
|
|
2078
|
+
);
|
|
2079
|
+
deepStrictEqual(icon?.mediaType, "image/png");
|
|
2080
|
+
},
|
|
2081
|
+
);
|
|
2082
|
+
|
|
2083
|
+
test(
|
|
2084
|
+
"Object.fromJsonLd() resolves Link href against document base, not object id",
|
|
2085
|
+
async () => {
|
|
2086
|
+
const json = {
|
|
2087
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2088
|
+
"type": "Note",
|
|
2089
|
+
"id": "../notes/1",
|
|
2090
|
+
"content": "Hello",
|
|
2091
|
+
"icon": {
|
|
2092
|
+
"type": "Link",
|
|
2093
|
+
"href": "icon.png",
|
|
2094
|
+
},
|
|
2095
|
+
};
|
|
2096
|
+
const obj = await Object.fromJsonLd(json, {
|
|
2097
|
+
documentLoader: mockDocumentLoader,
|
|
2098
|
+
contextLoader: mockDocumentLoader,
|
|
2099
|
+
baseUrl: new URL("https://example.com/outbox/page.json"),
|
|
2100
|
+
});
|
|
2101
|
+
const icon = await obj.getIcon();
|
|
2102
|
+
deepStrictEqual(obj.id?.href, "https://example.com/outbox/notes/1");
|
|
2103
|
+
deepStrictEqual(
|
|
2104
|
+
icon?.url?.href,
|
|
2105
|
+
"https://example.com/outbox/icon.png",
|
|
2106
|
+
);
|
|
2107
|
+
},
|
|
2108
|
+
);
|
|
2109
|
+
|
|
2110
|
+
test(
|
|
2111
|
+
"Object.getIcon() resolves cached relative Link href against baseUrl for did id",
|
|
2112
|
+
async () => {
|
|
2113
|
+
const json = {
|
|
2114
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2115
|
+
"type": "Note",
|
|
2116
|
+
"id": "did:plc:example",
|
|
2117
|
+
"content": "Hello",
|
|
2118
|
+
"icon": {
|
|
2119
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2120
|
+
"type": "Link",
|
|
2121
|
+
"href": "/icons/star.png",
|
|
2122
|
+
"mediaType": "image/png",
|
|
2123
|
+
},
|
|
2124
|
+
};
|
|
2125
|
+
const obj = await Object.fromJsonLd(json, {
|
|
2126
|
+
documentLoader: mockDocumentLoader,
|
|
2127
|
+
contextLoader: mockDocumentLoader,
|
|
2128
|
+
baseUrl: new URL("https://example.com/notes/1"),
|
|
2129
|
+
});
|
|
2130
|
+
const icon = await obj.getIcon();
|
|
2131
|
+
deepStrictEqual(obj.id?.href, "did:plc:example");
|
|
2132
|
+
deepStrictEqual(
|
|
2133
|
+
icon?.url?.href,
|
|
2134
|
+
"https://example.com/icons/star.png",
|
|
2135
|
+
);
|
|
2136
|
+
deepStrictEqual(icon?.mediaType, "image/png");
|
|
2137
|
+
},
|
|
2138
|
+
);
|
|
2139
|
+
|
|
2140
|
+
test(
|
|
2141
|
+
"Object.getIcon() ignores mutation of caller's baseUrl after fromJsonLd()",
|
|
2142
|
+
async () => {
|
|
2143
|
+
const origBaseUrl = new URL("https://example.com/");
|
|
2144
|
+
const json = {
|
|
2145
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2146
|
+
"type": "Note",
|
|
2147
|
+
"content": "Hello",
|
|
2148
|
+
"icon": {
|
|
2149
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2150
|
+
"type": "Link",
|
|
2151
|
+
"href": "/icons/star.png",
|
|
2152
|
+
"mediaType": "image/png",
|
|
2153
|
+
},
|
|
2154
|
+
};
|
|
2155
|
+
const obj = await Object.fromJsonLd(json, {
|
|
2156
|
+
documentLoader: mockDocumentLoader,
|
|
2157
|
+
contextLoader: mockDocumentLoader,
|
|
2158
|
+
baseUrl: origBaseUrl,
|
|
2159
|
+
});
|
|
2160
|
+
// Mutate the caller's URL after construction.
|
|
2161
|
+
origBaseUrl.href = "https://attacker.example/";
|
|
2162
|
+
const icon = await obj.getIcon();
|
|
2163
|
+
deepStrictEqual(
|
|
2164
|
+
icon?.url?.href,
|
|
2165
|
+
"https://example.com/icons/star.png",
|
|
2166
|
+
);
|
|
2167
|
+
deepStrictEqual(icon?.mediaType, "image/png");
|
|
2168
|
+
},
|
|
2169
|
+
);
|
|
2170
|
+
|
|
2171
|
+
test(
|
|
2172
|
+
"Object.fromJsonLd() does not resolve blank node @id against baseUrl",
|
|
2173
|
+
async () => {
|
|
2174
|
+
const json = {
|
|
2175
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2176
|
+
"type": "Note",
|
|
2177
|
+
"id": "_:b0",
|
|
2178
|
+
};
|
|
2179
|
+
const obj = await Object.fromJsonLd(json, {
|
|
2180
|
+
documentLoader: mockDocumentLoader,
|
|
2181
|
+
contextLoader: mockDocumentLoader,
|
|
2182
|
+
baseUrl: new URL("https://example.com/"),
|
|
2183
|
+
});
|
|
2184
|
+
// Blank node identifiers must not be resolved against baseUrl.
|
|
2185
|
+
deepStrictEqual(obj.id, null);
|
|
2186
|
+
},
|
|
2187
|
+
);
|
|
2188
|
+
|
|
2189
|
+
test(
|
|
2190
|
+
"Object.fromJsonLd() handles blank node @id without baseUrl",
|
|
2191
|
+
() => {
|
|
2192
|
+
const obj = Object.fromJsonLd({
|
|
2193
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2194
|
+
"type": "Note",
|
|
2195
|
+
"id": "_:b0",
|
|
2196
|
+
}, {
|
|
2197
|
+
documentLoader: mockDocumentLoader,
|
|
2198
|
+
contextLoader: mockDocumentLoader,
|
|
2199
|
+
});
|
|
2200
|
+
// Blank node identifier without baseUrl must not throw.
|
|
2201
|
+
return obj.then((o) => deepStrictEqual(o.id, null));
|
|
2202
|
+
},
|
|
2203
|
+
);
|
|
2204
|
+
|
|
2205
|
+
test(
|
|
2206
|
+
"Object.getAttachments() resolves relative url via stored _baseUrl",
|
|
2207
|
+
async () => {
|
|
2208
|
+
const json = {
|
|
2209
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2210
|
+
"type": "Note",
|
|
2211
|
+
"content": "Hello",
|
|
2212
|
+
"attachment": {
|
|
2213
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2214
|
+
"type": "Document",
|
|
2215
|
+
"url": "/files/report.pdf",
|
|
2216
|
+
"mediaType": "application/pdf",
|
|
2217
|
+
},
|
|
2218
|
+
};
|
|
2219
|
+
const obj = await Object.fromJsonLd(json, {
|
|
2220
|
+
documentLoader: mockDocumentLoader,
|
|
2221
|
+
contextLoader: mockDocumentLoader,
|
|
2222
|
+
baseUrl: new URL("https://example.com/"),
|
|
2223
|
+
});
|
|
2224
|
+
// getAttachments() without explicit baseUrl should use stored _baseUrl.
|
|
2225
|
+
const attachments = [];
|
|
2226
|
+
for await (const a of obj.getAttachments()) {
|
|
2227
|
+
attachments.push(a);
|
|
2228
|
+
}
|
|
2229
|
+
deepStrictEqual(attachments.length, 1);
|
|
2230
|
+
// deno-lint-ignore no-explicit-any
|
|
2231
|
+
const doc = attachments[0] as any;
|
|
2232
|
+
deepStrictEqual(
|
|
2233
|
+
doc?.url?.href,
|
|
2234
|
+
"https://example.com/files/report.pdf",
|
|
2235
|
+
);
|
|
2236
|
+
deepStrictEqual(doc?.mediaType, "application/pdf");
|
|
2237
|
+
},
|
|
2238
|
+
);
|
|
2239
|
+
|
|
2240
|
+
test("Object.fromJsonLd() normalizes multiple Link icons", async () => {
|
|
2241
|
+
const json = {
|
|
2242
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2243
|
+
"type": "Note",
|
|
2244
|
+
"content": "Hello",
|
|
2245
|
+
"icon": [
|
|
2246
|
+
{ "type": "Link", "href": "https://example.com/a.png" },
|
|
2247
|
+
{ "type": "Image", "url": "https://example.com/b.png" },
|
|
2248
|
+
],
|
|
2249
|
+
};
|
|
2250
|
+
const obj = await Object.fromJsonLd(json, {
|
|
2251
|
+
documentLoader: mockDocumentLoader,
|
|
2252
|
+
contextLoader: mockDocumentLoader,
|
|
2253
|
+
});
|
|
2254
|
+
const icons = [];
|
|
2255
|
+
for await (const i of obj.getIcons()) {
|
|
2256
|
+
icons.push(i);
|
|
2257
|
+
}
|
|
2258
|
+
deepStrictEqual(icons.length, 2);
|
|
2259
|
+
deepStrictEqual(icons[0]?.url?.href, "https://example.com/a.png");
|
|
2260
|
+
deepStrictEqual(icons[1]?.url?.href, "https://example.com/b.png");
|
|
2261
|
+
});
|
|
2262
|
+
|
|
2263
|
+
test("Object.getIcon() normalizes fetched Link document to Image", async () => {
|
|
2264
|
+
const linkDocUrl = "https://example.com/icons/avatar-link";
|
|
2265
|
+
const linkDoc = {
|
|
2266
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2267
|
+
type: "Link",
|
|
2268
|
+
href: "https://example.com/avatars/user.png",
|
|
2269
|
+
mediaType: "image/png",
|
|
2270
|
+
width: 128,
|
|
2271
|
+
height: 128,
|
|
2272
|
+
};
|
|
2273
|
+
const docLoader = async (url: string) => {
|
|
2274
|
+
if (url === linkDocUrl) {
|
|
2275
|
+
return {
|
|
2276
|
+
document: linkDoc,
|
|
2277
|
+
documentUrl: url,
|
|
2278
|
+
contextUrl: null,
|
|
2279
|
+
};
|
|
2280
|
+
}
|
|
2281
|
+
return await mockDocumentLoader(url);
|
|
2282
|
+
};
|
|
2283
|
+
|
|
2284
|
+
const person = new Person({
|
|
2285
|
+
id: new URL("https://example.com/ap/actors/test-user"),
|
|
2286
|
+
icon: new URL(linkDocUrl),
|
|
2287
|
+
});
|
|
2288
|
+
|
|
2289
|
+
const icon = await person.getIcon({
|
|
2290
|
+
documentLoader: docLoader,
|
|
2291
|
+
contextLoader: mockDocumentLoader,
|
|
2292
|
+
});
|
|
2293
|
+
deepStrictEqual(
|
|
2294
|
+
icon?.url?.href,
|
|
2295
|
+
"https://example.com/avatars/user.png",
|
|
2296
|
+
);
|
|
2297
|
+
deepStrictEqual(icon?.mediaType, "image/png");
|
|
2298
|
+
deepStrictEqual(icon?.width, 128);
|
|
2299
|
+
deepStrictEqual(icon?.height, 128);
|
|
2300
|
+
});
|
|
2301
|
+
|
|
1847
2302
|
test("FEP-fe34: Trust tracking in object construction", async () => {
|
|
1848
2303
|
// Test that objects created with embedded objects have trust set
|
|
1849
2304
|
const note = new Note({
|