@fedify/vocab 2.4.0-dev.2129 → 2.4.0-dev.2141
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 +736 -442
- package/dist/mod.d.cts +2458 -1
- package/dist/mod.d.ts +2458 -1
- package/dist/mod.js +736 -442
- package/dist-tests/{actor-Jl479WDt.mjs → actor-QEQj1qb5.mjs} +2 -2
- package/dist-tests/actor.test.mjs +3 -3
- package/dist-tests/{esm-CU6UbTlZ.mjs → esm-CxYTzURx.mjs} +1 -1
- package/dist-tests/gateway.test.mjs +362 -18
- package/dist-tests/{lookup-YM9st5n8.mjs → lookup-CcRxP9xc.mjs} +2 -2
- package/dist-tests/lookup.test.mjs +3 -3
- package/dist-tests/portable-lookup.test.mjs +4 -4
- package/dist-tests/signed-representation.test.mjs +1 -1
- package/dist-tests/translation.test.mjs +3 -3
- package/dist-tests/type.test.mjs +1 -1
- package/dist-tests/{vocab-DFtGFGsb.mjs → vocab-CVEaA48h.mjs} +735 -441
- package/dist-tests/vocab.test.mjs +2 -2
- package/package.json +4 -4
- package/src/gateway.test.ts +452 -45
- package/src/lookup.ts +15 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { F as Person, P as Organization, U as Service, a as Application, b as Group } from "./vocab-
|
|
3
|
+
import { F as Person, P as Organization, U as Service, a as Application, b as Group } from "./vocab-CVEaA48h.mjs";
|
|
4
4
|
import { t as getTypeId } from "./type-BMdjm4Eg.mjs";
|
|
5
5
|
import { canonicalizePortableUri, formatIri, fromCompatibleEf61Id, isGatewayUrl } from "@fedify/vocab-runtime";
|
|
6
6
|
import { lookupWebFinger } from "@fedify/webfinger";
|
|
@@ -8,7 +8,7 @@ import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
|
8
8
|
import { domainToASCII, domainToUnicode } from "node:url";
|
|
9
9
|
//#region deno.json
|
|
10
10
|
var name = "@fedify/vocab";
|
|
11
|
-
var version = "2.4.0-dev.
|
|
11
|
+
var version = "2.4.0-dev.2141+881cc858";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/actor.ts
|
|
14
14
|
const ACTOR_DISCOVERY_HISTOGRAM_BUCKETS = [
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { F as Person, P as Organization, Q as __exportAll, U as Service, a as Application, b as Group } from "./vocab-
|
|
4
|
-
import { t as esm_default } from "./esm-
|
|
5
|
-
import { a as normalizeActorHandle, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-
|
|
3
|
+
import { F as Person, P as Organization, Q as __exportAll, U as Service, a as Application, b as Group } from "./vocab-CVEaA48h.mjs";
|
|
4
|
+
import { t as esm_default } from "./esm-CxYTzURx.mjs";
|
|
5
|
+
import { a as normalizeActorHandle, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-QEQj1qb5.mjs";
|
|
6
6
|
import { createTestMeterProvider, test } from "@fedify/fixture";
|
|
7
7
|
import { deepStrictEqual, ok, rejects, strictEqual, throws } from "node:assert/strict";
|
|
8
8
|
//#region ../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/esm/check/precondition/PreconditionFailure.js
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { $ as __toESM, Z as __commonJSMin } from "./vocab-
|
|
3
|
+
import { $ as __toESM, Z as __commonJSMin } from "./vocab-CVEaA48h.mjs";
|
|
4
4
|
//#endregion
|
|
5
5
|
//#region ../../node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.mjs
|
|
6
6
|
var import_glob_to_regexp = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { F as Person, M as OrderedCollection, S as Image, c as CollectionPage, k as Note, s as Collection, u as Create } from "./vocab-
|
|
4
|
-
import { t as esm_default } from "./esm-
|
|
5
|
-
import { n as traverseCollection, t as lookupObject } from "./lookup-
|
|
3
|
+
import { F as Person, M as OrderedCollection, S as Image, c as CollectionPage, k as Note, s as Collection, u as Create } from "./vocab-CVEaA48h.mjs";
|
|
4
|
+
import { t as esm_default } from "./esm-CxYTzURx.mjs";
|
|
5
|
+
import { n as traverseCollection, t as lookupObject } from "./lookup-CcRxP9xc.mjs";
|
|
6
6
|
import { t as assertInstanceOf } from "./utils-Df2odC27.mjs";
|
|
7
7
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
8
8
|
import { deepStrictEqual, ok, rejects } from "node:assert/strict";
|
|
@@ -1481,10 +1481,11 @@ test("objects use the verifyPortableObject option they were parsed with by defau
|
|
|
1481
1481
|
}), Note);
|
|
1482
1482
|
deepStrictEqual(verifier.calls.length, 2);
|
|
1483
1483
|
});
|
|
1484
|
-
await t.step("an explicit option
|
|
1484
|
+
await t.step("an explicit option is passed on to fetched objects", async () => {
|
|
1485
1485
|
const stored = createRecordingVerifier();
|
|
1486
1486
|
const given = createRecordingVerifier();
|
|
1487
|
-
const
|
|
1487
|
+
const activity = await createCompatibleActivity(compatibleNoteId, void 0, { verifyPortableObject: stored });
|
|
1488
|
+
const object = await activity.getObject({
|
|
1488
1489
|
documentLoader,
|
|
1489
1490
|
contextLoader: mockDocumentLoader,
|
|
1490
1491
|
verifyPortableObject: given
|
|
@@ -1496,18 +1497,8 @@ test("objects use the verifyPortableObject option they were parsed with by defau
|
|
|
1496
1497
|
contextLoader: mockDocumentLoader,
|
|
1497
1498
|
gateways: ["https://gw.example"]
|
|
1498
1499
|
});
|
|
1499
|
-
deepStrictEqual([stored.calls.length, given.calls.length], [
|
|
1500
|
-
|
|
1501
|
-
documentLoader,
|
|
1502
|
-
contextLoader: mockDocumentLoader,
|
|
1503
|
-
verifyPortableObject: given
|
|
1504
|
-
});
|
|
1505
|
-
assertInstanceOf(object2, Note);
|
|
1506
|
-
await rejects(async () => await object2.getAttribution({
|
|
1507
|
-
documentLoader,
|
|
1508
|
-
contextLoader: mockDocumentLoader,
|
|
1509
|
-
gateways: ["https://gw.example"]
|
|
1510
|
-
}), TypeError);
|
|
1500
|
+
deepStrictEqual([stored.calls.length, given.calls.length], [0, 2]);
|
|
1501
|
+
ok(getDefaultVerifier(activity) === stored);
|
|
1511
1502
|
});
|
|
1512
1503
|
await t.step("lookupObject()", async () => {
|
|
1513
1504
|
const verifier = createRecordingVerifier();
|
|
@@ -1540,7 +1531,360 @@ test("objects use the verifyPortableObject option they were parsed with by defau
|
|
|
1540
1531
|
verifyPortableObject: verifier
|
|
1541
1532
|
})).getIcon({ documentLoader });
|
|
1542
1533
|
assertInstanceOf(icon, Image);
|
|
1543
|
-
ok(icon
|
|
1534
|
+
ok(getDefaultVerifier(icon) === verifier);
|
|
1535
|
+
});
|
|
1536
|
+
});
|
|
1537
|
+
function getDefaultVerifier(object) {
|
|
1538
|
+
return object._verifyPortableObject;
|
|
1539
|
+
}
|
|
1540
|
+
test("accessors pass the verifier of a call on to the objects they fetch", async (t) => {
|
|
1541
|
+
const actorId = `ap://${did}/actor`;
|
|
1542
|
+
const attributedNote = (id) => ({
|
|
1543
|
+
...note(id),
|
|
1544
|
+
attributedTo: actorId
|
|
1545
|
+
});
|
|
1546
|
+
const actor = {
|
|
1547
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1548
|
+
id: actorId,
|
|
1549
|
+
type: "Person",
|
|
1550
|
+
inbox: `${actorId}/inbox`
|
|
1551
|
+
};
|
|
1552
|
+
const actorUrl = gatewayUrl("https://gw.example", "/actor");
|
|
1553
|
+
const plainNoteUrl = "https://example.com/notes/1";
|
|
1554
|
+
const plainActivityUrl = "https://example.com/activities/1";
|
|
1555
|
+
const options = {
|
|
1556
|
+
documentLoader: createLoader({
|
|
1557
|
+
[compatibleNoteId]: attributedNote(compatibleNoteId),
|
|
1558
|
+
[actorUrl]: actor,
|
|
1559
|
+
[plainNoteUrl]: {
|
|
1560
|
+
...attributedNote(plainNoteUrl),
|
|
1561
|
+
id: plainNoteUrl
|
|
1562
|
+
},
|
|
1563
|
+
[plainActivityUrl]: {
|
|
1564
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1565
|
+
type: "Create",
|
|
1566
|
+
id: plainActivityUrl,
|
|
1567
|
+
object: compatibleNoteId
|
|
1568
|
+
}
|
|
1569
|
+
}),
|
|
1570
|
+
contextLoader: mockDocumentLoader
|
|
1571
|
+
};
|
|
1572
|
+
const secondHop = {
|
|
1573
|
+
...options,
|
|
1574
|
+
gateways: ["https://gw.example"]
|
|
1575
|
+
};
|
|
1576
|
+
await t.step("from objects without a default", async () => {
|
|
1577
|
+
const roots = [
|
|
1578
|
+
["constructed", async () => new Create({
|
|
1579
|
+
id: new URL(gatewayUrl("https://gw.example", "/activities/1")),
|
|
1580
|
+
object: new URL(compatibleNoteId)
|
|
1581
|
+
}, { contextLoader: mockDocumentLoader })],
|
|
1582
|
+
["parsed", () => createCompatibleActivity(compatibleNoteId)],
|
|
1583
|
+
["looked up", async () => {
|
|
1584
|
+
const found = await lookupObject(plainActivityUrl, options);
|
|
1585
|
+
assertInstanceOf(found, Create);
|
|
1586
|
+
return found;
|
|
1587
|
+
}]
|
|
1588
|
+
];
|
|
1589
|
+
for (const [name, createRoot] of roots) {
|
|
1590
|
+
const verifier = createRecordingVerifier();
|
|
1591
|
+
const root = await createRoot();
|
|
1592
|
+
ok(getDefaultVerifier(root) == null, name);
|
|
1593
|
+
const object = await root.getObject({
|
|
1594
|
+
...options,
|
|
1595
|
+
verifyPortableObject: verifier
|
|
1596
|
+
});
|
|
1597
|
+
assertInstanceOf(object, Note);
|
|
1598
|
+
deepStrictEqual(verifier.calls.length, 1, name);
|
|
1599
|
+
assertInstanceOf(await object.getAttribution(secondHop), Person);
|
|
1600
|
+
deepStrictEqual(verifier.calls.length, 2, name);
|
|
1601
|
+
ok(getDefaultVerifier(root) == null, name);
|
|
1602
|
+
const verifier2 = createRecordingVerifier();
|
|
1603
|
+
const objects = await Array.fromAsync((await createRoot()).getObjects({
|
|
1604
|
+
...options,
|
|
1605
|
+
verifyPortableObject: verifier2
|
|
1606
|
+
}));
|
|
1607
|
+
deepStrictEqual(objects.length, 1, name);
|
|
1608
|
+
assertInstanceOf(objects[0], Note);
|
|
1609
|
+
const authors = await Array.fromAsync(objects[0].getAttributions(secondHop));
|
|
1610
|
+
deepStrictEqual(authors.length, 1, name);
|
|
1611
|
+
assertInstanceOf(authors[0], Person);
|
|
1612
|
+
deepStrictEqual(verifier2.calls.length, 2, name);
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
await t.step("precedence", async () => {
|
|
1616
|
+
const stored = createRecordingVerifier();
|
|
1617
|
+
const given = createRecordingVerifier();
|
|
1618
|
+
const override = createRecordingVerifier();
|
|
1619
|
+
const counts = () => [
|
|
1620
|
+
stored.calls.length,
|
|
1621
|
+
given.calls.length,
|
|
1622
|
+
override.calls.length
|
|
1623
|
+
];
|
|
1624
|
+
const byDefault = await (await createCompatibleActivity(compatibleNoteId, void 0, { verifyPortableObject: stored })).getObject({
|
|
1625
|
+
...options,
|
|
1626
|
+
inheritPortableObjectVerifier: false
|
|
1627
|
+
});
|
|
1628
|
+
assertInstanceOf(byDefault, Note);
|
|
1629
|
+
ok(getDefaultVerifier(byDefault) === stored);
|
|
1630
|
+
deepStrictEqual(counts(), [
|
|
1631
|
+
1,
|
|
1632
|
+
0,
|
|
1633
|
+
0
|
|
1634
|
+
]);
|
|
1635
|
+
const optedOut = await (await createCompatibleActivity(compatibleNoteId, void 0, { verifyPortableObject: stored })).getObject({
|
|
1636
|
+
...options,
|
|
1637
|
+
verifyPortableObject: given,
|
|
1638
|
+
inheritPortableObjectVerifier: false
|
|
1639
|
+
});
|
|
1640
|
+
assertInstanceOf(optedOut, Note);
|
|
1641
|
+
deepStrictEqual(counts(), [
|
|
1642
|
+
1,
|
|
1643
|
+
1,
|
|
1644
|
+
0
|
|
1645
|
+
]);
|
|
1646
|
+
ok(getDefaultVerifier(optedOut) === stored);
|
|
1647
|
+
assertInstanceOf(await optedOut.getAttribution(secondHop), Person);
|
|
1648
|
+
deepStrictEqual(counts(), [
|
|
1649
|
+
2,
|
|
1650
|
+
1,
|
|
1651
|
+
0
|
|
1652
|
+
]);
|
|
1653
|
+
const noDefault = await (await createCompatibleActivity(compatibleNoteId)).getObject({
|
|
1654
|
+
...options,
|
|
1655
|
+
verifyPortableObject: given,
|
|
1656
|
+
inheritPortableObjectVerifier: false
|
|
1657
|
+
});
|
|
1658
|
+
assertInstanceOf(noDefault, Note);
|
|
1659
|
+
deepStrictEqual(counts(), [
|
|
1660
|
+
2,
|
|
1661
|
+
2,
|
|
1662
|
+
0
|
|
1663
|
+
]);
|
|
1664
|
+
ok(getDefaultVerifier(noDefault) == null);
|
|
1665
|
+
await rejects(async () => await noDefault.getAttribution(secondHop), TypeError);
|
|
1666
|
+
const inherited = await (await createCompatibleActivity(compatibleNoteId, void 0, { verifyPortableObject: stored })).getObject({
|
|
1667
|
+
...options,
|
|
1668
|
+
verifyPortableObject: given
|
|
1669
|
+
});
|
|
1670
|
+
assertInstanceOf(inherited, Note);
|
|
1671
|
+
deepStrictEqual(counts(), [
|
|
1672
|
+
2,
|
|
1673
|
+
3,
|
|
1674
|
+
0
|
|
1675
|
+
]);
|
|
1676
|
+
ok(getDefaultVerifier(inherited) === given);
|
|
1677
|
+
assertInstanceOf(await inherited.getAttribution({
|
|
1678
|
+
...secondHop,
|
|
1679
|
+
verifyPortableObject: override
|
|
1680
|
+
}), Person);
|
|
1681
|
+
deepStrictEqual(counts(), [
|
|
1682
|
+
2,
|
|
1683
|
+
3,
|
|
1684
|
+
1
|
|
1685
|
+
]);
|
|
1686
|
+
const optedOuts = await Array.fromAsync((await createCompatibleActivity([compatibleNoteId], void 0, { verifyPortableObject: stored })).getObjects({
|
|
1687
|
+
...options,
|
|
1688
|
+
verifyPortableObject: given,
|
|
1689
|
+
inheritPortableObjectVerifier: false
|
|
1690
|
+
}));
|
|
1691
|
+
deepStrictEqual(optedOuts.length, 1);
|
|
1692
|
+
ok(getDefaultVerifier(optedOuts[0]) === stored);
|
|
1693
|
+
});
|
|
1694
|
+
await t.step("ordinary HTTP(S) responses", async () => {
|
|
1695
|
+
const given = createRecordingVerifier();
|
|
1696
|
+
const stored = createRecordingVerifier();
|
|
1697
|
+
const object = await (await createHttpActivity(plainNoteUrl)).getObject({
|
|
1698
|
+
...options,
|
|
1699
|
+
verifyPortableObject: given
|
|
1700
|
+
});
|
|
1701
|
+
assertInstanceOf(object, Note);
|
|
1702
|
+
deepStrictEqual(given.calls.length, 0);
|
|
1703
|
+
ok(getDefaultVerifier(object) === given);
|
|
1704
|
+
assertInstanceOf(await object.getAttribution(secondHop), Person);
|
|
1705
|
+
deepStrictEqual(given.calls.length, 1);
|
|
1706
|
+
const { referrer } = given.calls[0].options;
|
|
1707
|
+
ok(referrer?.object === object);
|
|
1708
|
+
deepStrictEqual(referrer?.acceptance, void 0);
|
|
1709
|
+
const optedOut = await (await Create.fromJsonLd({
|
|
1710
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1711
|
+
type: "Create",
|
|
1712
|
+
id: plainActivityUrl,
|
|
1713
|
+
object: plainNoteUrl
|
|
1714
|
+
}, {
|
|
1715
|
+
contextLoader: mockDocumentLoader,
|
|
1716
|
+
verifyPortableObject: stored
|
|
1717
|
+
})).getObject({
|
|
1718
|
+
...options,
|
|
1719
|
+
verifyPortableObject: given,
|
|
1720
|
+
inheritPortableObjectVerifier: false
|
|
1721
|
+
});
|
|
1722
|
+
assertInstanceOf(optedOut, Note);
|
|
1723
|
+
ok(getDefaultVerifier(optedOut) === stored);
|
|
1724
|
+
});
|
|
1725
|
+
await t.step("HTTP(S) responses that stand for portable objects", async () => {
|
|
1726
|
+
const redirecting = createRedirectingLoader({ [plainNoteUrl]: {
|
|
1727
|
+
documentUrl: compatibleNoteId,
|
|
1728
|
+
document: attributedNote(compatibleNoteId)
|
|
1729
|
+
} });
|
|
1730
|
+
const given = createRecordingVerifier();
|
|
1731
|
+
const object = await (await createHttpActivity(plainNoteUrl)).getObject({
|
|
1732
|
+
documentLoader: redirecting,
|
|
1733
|
+
contextLoader: mockDocumentLoader,
|
|
1734
|
+
verifyPortableObject: given
|
|
1735
|
+
});
|
|
1736
|
+
assertInstanceOf(object, Note);
|
|
1737
|
+
deepStrictEqual(given.calls.length, 1);
|
|
1738
|
+
ok(getDefaultVerifier(object) === given);
|
|
1739
|
+
const optedOut = await (await createHttpActivity(plainNoteUrl)).getObject({
|
|
1740
|
+
documentLoader: redirecting,
|
|
1741
|
+
contextLoader: mockDocumentLoader,
|
|
1742
|
+
verifyPortableObject: given,
|
|
1743
|
+
inheritPortableObjectVerifier: false
|
|
1744
|
+
});
|
|
1745
|
+
assertInstanceOf(optedOut, Note);
|
|
1746
|
+
deepStrictEqual(given.calls.length, 2);
|
|
1747
|
+
ok(getDefaultVerifier(optedOut) == null);
|
|
1748
|
+
});
|
|
1749
|
+
await t.step("objects that were fetched without a verifier", async () => {
|
|
1750
|
+
const activity = await createHttpActivity(compatibleNoteId);
|
|
1751
|
+
const unverified = await activity.getObject(options);
|
|
1752
|
+
assertInstanceOf(unverified, Note);
|
|
1753
|
+
ok(getDefaultVerifier(unverified) == null);
|
|
1754
|
+
const verifier = createRecordingVerifier();
|
|
1755
|
+
const verified = await activity.getObject({
|
|
1756
|
+
...options,
|
|
1757
|
+
verifyPortableObject: verifier
|
|
1758
|
+
});
|
|
1759
|
+
assertInstanceOf(verified, Note);
|
|
1760
|
+
ok(verified !== unverified);
|
|
1761
|
+
deepStrictEqual(verifier.calls.length, 1);
|
|
1762
|
+
ok(getDefaultVerifier(verified) === verifier);
|
|
1763
|
+
});
|
|
1764
|
+
await t.step("property preprocessors", async () => {
|
|
1765
|
+
const iconUrl = "https://example.com/icon";
|
|
1766
|
+
const loader = createLoader({ [iconUrl]: {
|
|
1767
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1768
|
+
type: "Link",
|
|
1769
|
+
href: "https://example.com/icon.png"
|
|
1770
|
+
} });
|
|
1771
|
+
const createPerson = () => Person.fromJsonLd({
|
|
1772
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1773
|
+
id: "https://example.com/person",
|
|
1774
|
+
type: "Person",
|
|
1775
|
+
icon: iconUrl
|
|
1776
|
+
}, { contextLoader: mockDocumentLoader });
|
|
1777
|
+
const verifier = createVerifier();
|
|
1778
|
+
const icon = await (await createPerson()).getIcon({
|
|
1779
|
+
documentLoader: loader,
|
|
1780
|
+
contextLoader: mockDocumentLoader,
|
|
1781
|
+
verifyPortableObject: verifier
|
|
1782
|
+
});
|
|
1783
|
+
assertInstanceOf(icon, Image);
|
|
1784
|
+
ok(getDefaultVerifier(icon) === verifier);
|
|
1785
|
+
const optedOut = await (await createPerson()).getIcon({
|
|
1786
|
+
documentLoader: loader,
|
|
1787
|
+
contextLoader: mockDocumentLoader,
|
|
1788
|
+
verifyPortableObject: verifier,
|
|
1789
|
+
inheritPortableObjectVerifier: false
|
|
1790
|
+
});
|
|
1791
|
+
assertInstanceOf(optedOut, Image);
|
|
1792
|
+
ok(getDefaultVerifier(optedOut) == null);
|
|
1793
|
+
});
|
|
1794
|
+
await t.step("embedded objects keep the parent's default", async () => {
|
|
1795
|
+
const embedded = attributedNote(`ap://${did}/objects/2`);
|
|
1796
|
+
const withoutContext = { ...embedded };
|
|
1797
|
+
delete withoutContext["@context"];
|
|
1798
|
+
for (const [name, value] of [["with @context", embedded], ["without @context", withoutContext]]) for (const stored of [void 0, createRecordingVerifier()]) {
|
|
1799
|
+
const given = createRecordingVerifier();
|
|
1800
|
+
const object = await (await createCompatibleActivity(value, `ap://${did}/activities/1`, stored == null ? {} : { verifyPortableObject: stored })).getObject({
|
|
1801
|
+
...options,
|
|
1802
|
+
verifyPortableObject: given
|
|
1803
|
+
});
|
|
1804
|
+
assertInstanceOf(object, Note);
|
|
1805
|
+
ok(getDefaultVerifier(object) === stored, name);
|
|
1806
|
+
deepStrictEqual(given.calls.length, 0, name);
|
|
1807
|
+
}
|
|
1808
|
+
});
|
|
1809
|
+
await t.step("cached objects", async () => {
|
|
1810
|
+
const weak = createRecordingVerifier();
|
|
1811
|
+
const strict = createRecordingVerifier();
|
|
1812
|
+
for (const [first, second] of [[weak, strict], [strict, weak]]) {
|
|
1813
|
+
const activity = await createCompatibleActivity(compatibleNoteId);
|
|
1814
|
+
const object = await activity.getObject({
|
|
1815
|
+
...options,
|
|
1816
|
+
verifyPortableObject: first
|
|
1817
|
+
});
|
|
1818
|
+
assertInstanceOf(object, Note);
|
|
1819
|
+
const before = second.calls.length;
|
|
1820
|
+
const cached = await activity.getObject({
|
|
1821
|
+
...options,
|
|
1822
|
+
verifyPortableObject: second
|
|
1823
|
+
});
|
|
1824
|
+
ok(cached === object);
|
|
1825
|
+
ok(getDefaultVerifier(cached) === first);
|
|
1826
|
+
deepStrictEqual(second.calls.length, before);
|
|
1827
|
+
}
|
|
1828
|
+
});
|
|
1829
|
+
await t.step("traverseCollection()", async () => {
|
|
1830
|
+
const collectionUrl = "https://example.com/collection";
|
|
1831
|
+
const pageUrl = "https://example.com/collection?page=1";
|
|
1832
|
+
const loader = createLoader({
|
|
1833
|
+
...Object.fromEntries([
|
|
1834
|
+
compatibleNoteId,
|
|
1835
|
+
actorUrl,
|
|
1836
|
+
plainNoteUrl
|
|
1837
|
+
].map((url) => [url, url === plainNoteUrl ? {
|
|
1838
|
+
...attributedNote(plainNoteUrl),
|
|
1839
|
+
id: plainNoteUrl
|
|
1840
|
+
} : url === actorUrl ? actor : attributedNote(compatibleNoteId)])),
|
|
1841
|
+
[pageUrl]: {
|
|
1842
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1843
|
+
id: pageUrl,
|
|
1844
|
+
type: "OrderedCollectionPage",
|
|
1845
|
+
orderedItems: [
|
|
1846
|
+
{
|
|
1847
|
+
id: "https://example.com/notes/2",
|
|
1848
|
+
type: "Note",
|
|
1849
|
+
attributedTo: actorId
|
|
1850
|
+
},
|
|
1851
|
+
plainNoteUrl,
|
|
1852
|
+
compatibleNoteId
|
|
1853
|
+
]
|
|
1854
|
+
}
|
|
1855
|
+
});
|
|
1856
|
+
const createCollection = () => OrderedCollection.fromJsonLd({
|
|
1857
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1858
|
+
id: collectionUrl,
|
|
1859
|
+
type: "OrderedCollection",
|
|
1860
|
+
first: pageUrl
|
|
1861
|
+
}, { contextLoader: mockDocumentLoader });
|
|
1862
|
+
const verifier = createRecordingVerifier();
|
|
1863
|
+
const items = await Array.fromAsync(traverseCollection(await createCollection(), {
|
|
1864
|
+
documentLoader: loader,
|
|
1865
|
+
contextLoader: mockDocumentLoader,
|
|
1866
|
+
verifyPortableObject: verifier
|
|
1867
|
+
}));
|
|
1868
|
+
deepStrictEqual(items.length, 3);
|
|
1869
|
+
deepStrictEqual(verifier.calls.length, 1);
|
|
1870
|
+
for (const item of items) {
|
|
1871
|
+
assertInstanceOf(item, Note);
|
|
1872
|
+
ok(getDefaultVerifier(item) === verifier);
|
|
1873
|
+
assertInstanceOf(await item.getAttribution({
|
|
1874
|
+
documentLoader: loader,
|
|
1875
|
+
contextLoader: mockDocumentLoader,
|
|
1876
|
+
gateways: ["https://gw.example"]
|
|
1877
|
+
}), Person);
|
|
1878
|
+
}
|
|
1879
|
+
deepStrictEqual(verifier.calls.length, 4);
|
|
1880
|
+
const optedOut = await Array.fromAsync(traverseCollection(await createCollection(), {
|
|
1881
|
+
documentLoader: loader,
|
|
1882
|
+
contextLoader: mockDocumentLoader,
|
|
1883
|
+
verifyPortableObject: verifier,
|
|
1884
|
+
inheritPortableObjectVerifier: false
|
|
1885
|
+
}));
|
|
1886
|
+
deepStrictEqual(optedOut.length, 3);
|
|
1887
|
+
for (const item of optedOut) ok(getDefaultVerifier(item) == null);
|
|
1544
1888
|
});
|
|
1545
1889
|
});
|
|
1546
1890
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { A as Object$1 } from "./vocab-
|
|
4
|
-
import { i as isActor, o as name, s as version } from "./actor-
|
|
3
|
+
import { A as Object$1 } from "./vocab-CVEaA48h.mjs";
|
|
4
|
+
import { i as isActor, o as name, s as version } from "./actor-QEQj1qb5.mjs";
|
|
5
5
|
import { t as getTypeId } from "./type-BMdjm4Eg.mjs";
|
|
6
6
|
import { canonicalizePortableUri, formatIri, getDocumentLoader, haveSameFe34Origin, haveSameIriOrigin, parseIri } from "@fedify/vocab-runtime";
|
|
7
7
|
import { lookupWebFinger } from "@fedify/webfinger";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { A as Object$1, F as Person, k as Note, s as Collection } from "./vocab-
|
|
4
|
-
import { t as esm_default } from "./esm-
|
|
5
|
-
import { n as traverseCollection, t as lookupObject } from "./lookup-
|
|
3
|
+
import { A as Object$1, F as Person, k as Note, s as Collection } from "./vocab-CVEaA48h.mjs";
|
|
4
|
+
import { t as esm_default } from "./esm-CxYTzURx.mjs";
|
|
5
|
+
import { n as traverseCollection, t as lookupObject } from "./lookup-CcRxP9xc.mjs";
|
|
6
6
|
import { t as assertInstanceOf } from "./utils-Df2odC27.mjs";
|
|
7
7
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
8
8
|
import { deepStrictEqual, equal, ok, rejects } from "node:assert/strict";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { F as Person } from "./vocab-
|
|
4
|
-
import { t as esm_default } from "./esm-
|
|
5
|
-
import { n as getActorHandle } from "./actor-
|
|
6
|
-
import { t as lookupObject } from "./lookup-
|
|
3
|
+
import { F as Person } from "./vocab-CVEaA48h.mjs";
|
|
4
|
+
import { t as esm_default } from "./esm-CxYTzURx.mjs";
|
|
5
|
+
import { n as getActorHandle } from "./actor-QEQj1qb5.mjs";
|
|
6
|
+
import { t as lookupObject } from "./lookup-CcRxP9xc.mjs";
|
|
7
7
|
import { t as assertInstanceOf } from "./utils-Df2odC27.mjs";
|
|
8
8
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
9
9
|
import { deepStrictEqual, equal, rejects } from "node:assert/strict";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { M as OrderedCollection, X as vocab_exports, i as Announce, k as Note, u as Create, z as Question } from "./vocab-
|
|
3
|
+
import { M as OrderedCollection, X as vocab_exports, i as Announce, k as Note, u as Create, z as Question } from "./vocab-CVEaA48h.mjs";
|
|
4
4
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
5
5
|
import { deepStrictEqual, ok } from "node:assert/strict";
|
|
6
6
|
import { isMarkerSafeContext, retainSignedRepresentation } from "@fedify/vocab-runtime/internal/signed-representation";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { A as Object$1, E as Link, F as Person, K as Translation, L as PropertyValue, P as Organization, U as Service, a as Application, b as Group, k as Note, o as Article, q as Update, s as Collection, u as Create } from "./vocab-
|
|
4
|
-
import "./actor-
|
|
5
|
-
import "./lookup-
|
|
3
|
+
import { A as Object$1, E as Link, F as Person, K as Translation, L as PropertyValue, P as Organization, U as Service, a as Application, b as Group, k as Note, o as Article, q as Update, s as Collection, u as Create } from "./vocab-CVEaA48h.mjs";
|
|
4
|
+
import "./actor-QEQj1qb5.mjs";
|
|
5
|
+
import "./lookup-CcRxP9xc.mjs";
|
|
6
6
|
import { test } from "@fedify/fixture";
|
|
7
7
|
import { deepStrictEqual, ok, rejects } from "node:assert/strict";
|
|
8
8
|
import { LanguageString as LanguageString$1, getDocumentLoader, preloadedContexts } from "@fedify/vocab-runtime";
|
package/dist-tests/type.test.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { E as Link, F as Person, J as getEntityTypeById, Y as isEntityType } from "./vocab-
|
|
3
|
+
import { E as Link, F as Person, J as getEntityTypeById, Y as isEntityType } from "./vocab-CVEaA48h.mjs";
|
|
4
4
|
import { t as getTypeId } from "./type-BMdjm4Eg.mjs";
|
|
5
5
|
import { test } from "@fedify/fixture";
|
|
6
6
|
import { deepStrictEqual } from "node:assert/strict";
|