@fedify/vocab 2.4.0-dev.2115 → 2.4.0-dev.2127

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.
@@ -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-BHtBRusa.mjs";
3
+ import { F as Person, P as Organization, U as Service, a as Application, b as Group } from "./vocab-DFtGFGsb.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.2115+e2feaf2b";
11
+ var version = "2.4.0-dev.2127+c41ce2eb";
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-BHtBRusa.mjs";
4
- import { t as esm_default } from "./esm-C9nxP5_e.mjs";
5
- import { a as normalizeActorHandle, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-DE2vFZqt.mjs";
3
+ import { F as Person, P as Organization, Q as __exportAll, U as Service, a as Application, b as Group } from "./vocab-DFtGFGsb.mjs";
4
+ import { t as esm_default } from "./esm-CU6UbTlZ.mjs";
5
+ import { a as normalizeActorHandle, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-Ccca2qzB.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-BHtBRusa.mjs";
3
+ import { $ as __toESM, Z as __commonJSMin } from "./vocab-DFtGFGsb.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, c as CollectionPage, k as Note, s as Collection, u as Create } from "./vocab-BHtBRusa.mjs";
4
- import { t as esm_default } from "./esm-C9nxP5_e.mjs";
5
- import { n as traverseCollection } from "./lookup-56N6dAfT.mjs";
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-DFtGFGsb.mjs";
4
+ import { t as esm_default } from "./esm-CU6UbTlZ.mjs";
5
+ import { n as traverseCollection, t as lookupObject } from "./lookup-CspwEMVG.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";
@@ -1297,5 +1297,251 @@ test("singular accessors drop anonymous objects embedded in unsecured collection
1297
1297
  deepStrictEqual(await outbox.getFirst(options), null);
1298
1298
  deepStrictEqual(await Array.fromAsync(traverseCollection(outbox, options)), []);
1299
1299
  });
1300
+ function createCompatibleActivity(object, id = gatewayUrl("https://gw.example", "/activities/1"), options = {}) {
1301
+ return Create.fromJsonLd({
1302
+ "@context": "https://www.w3.org/ns/activitystreams",
1303
+ type: "Create",
1304
+ id,
1305
+ object
1306
+ }, {
1307
+ contextLoader: mockDocumentLoader,
1308
+ ...options
1309
+ });
1310
+ }
1311
+ test("accessors of objects with compatible identifiers dereference references as portable objects", async (t) => {
1312
+ await t.step("verifying the object at the reference", async () => {
1313
+ const documentLoader = createLoader({ [compatibleNoteId]: {
1314
+ ...note(),
1315
+ id: compatibleNoteId
1316
+ } });
1317
+ const verifier = createRecordingVerifier();
1318
+ const activity = await createCompatibleActivity(compatibleNoteId);
1319
+ const object = await activity.getObject({
1320
+ documentLoader,
1321
+ contextLoader: mockDocumentLoader,
1322
+ verifyPortableObject: verifier
1323
+ });
1324
+ assertInstanceOf(object, Note);
1325
+ deepStrictEqual(object.id, new URL(compatibleNoteId));
1326
+ deepStrictEqual(documentLoader.fetched, [compatibleNoteId]);
1327
+ deepStrictEqual(verifier.calls.length, 1);
1328
+ deepStrictEqual(verifier.calls[0].options.gatewayHints, [new URL("https://gw.example")]);
1329
+ ok(verifier.calls[0].options.referrer?.object === activity);
1330
+ deepStrictEqual(verifier.calls[0].options.referrer?.acceptance, void 0);
1331
+ });
1332
+ await t.step("rejecting an unsigned object at the reference", async () => {
1333
+ const documentLoader = createLoader({ [compatibleNoteId]: {
1334
+ ...note(),
1335
+ id: compatibleNoteId
1336
+ } });
1337
+ deepStrictEqual(await (await createCompatibleActivity(compatibleNoteId)).getObject({
1338
+ documentLoader,
1339
+ contextLoader: mockDocumentLoader,
1340
+ verifyPortableObject: createVerifier(false)
1341
+ }), null);
1342
+ deepStrictEqual(await Array.fromAsync((await createCompatibleActivity([compatibleNoteId])).getObjects({
1343
+ documentLoader,
1344
+ contextLoader: mockDocumentLoader,
1345
+ verifyPortableObject: createVerifier(false),
1346
+ crossOrigin: "trust"
1347
+ })), []);
1348
+ });
1349
+ await t.step("without verifyPortableObject", async () => {
1350
+ const documentLoader = createLoader({ [compatibleNoteId]: {
1351
+ ...note(),
1352
+ id: compatibleNoteId
1353
+ } });
1354
+ const activity = await createCompatibleActivity(compatibleNoteId);
1355
+ await rejects(async () => await activity.getObject({
1356
+ documentLoader,
1357
+ contextLoader: mockDocumentLoader
1358
+ }), TypeError);
1359
+ deepStrictEqual(await activity.getObject({
1360
+ documentLoader,
1361
+ contextLoader: mockDocumentLoader,
1362
+ suppressError: true
1363
+ }), null);
1364
+ deepStrictEqual(documentLoader.fetched, []);
1365
+ });
1366
+ await t.step("embedded objects with compatible identifiers", async () => {
1367
+ const documentLoader = createLoader({ [compatibleNoteId]: note() });
1368
+ const verifier = createRecordingVerifier();
1369
+ const object = await (await createCompatibleActivity({
1370
+ type: "Note",
1371
+ id: compatibleNoteId,
1372
+ content: "Embedded"
1373
+ })).getObject({
1374
+ documentLoader,
1375
+ contextLoader: mockDocumentLoader,
1376
+ verifyPortableObject: verifier
1377
+ });
1378
+ assertInstanceOf(object, Note);
1379
+ deepStrictEqual(object.content, "Portable note");
1380
+ deepStrictEqual(verifier.calls.length, 1);
1381
+ });
1382
+ await t.step("objects with malformed compatible identifiers", async () => {
1383
+ const malformedId = `${gatewayUrl("https://gw.example", "/activities/1")}?@gateway=https%3A%2F%2Fgw2.example`;
1384
+ const activity = await createCompatibleActivity(objectId, malformedId);
1385
+ await rejects(async () => await activity.getObject({
1386
+ documentLoader: createLoader({}),
1387
+ contextLoader: mockDocumentLoader
1388
+ }), TypeError);
1389
+ const plainUrl = "https://example.com/notes/1";
1390
+ const plainLoader = createLoader({ [plainUrl]: {
1391
+ ...note(),
1392
+ id: plainUrl
1393
+ } });
1394
+ deepStrictEqual((await (await createCompatibleActivity(plainUrl, malformedId)).getObject({
1395
+ documentLoader: plainLoader,
1396
+ contextLoader: mockDocumentLoader
1397
+ }))?.id, new URL(plainUrl));
1398
+ const claimLoader = createLoader({ [plainUrl]: note() });
1399
+ await rejects(async () => await (await createCompatibleActivity(plainUrl, malformedId)).getObject({
1400
+ documentLoader: claimLoader,
1401
+ contextLoader: mockDocumentLoader
1402
+ }), TypeError);
1403
+ });
1404
+ await t.step("objects with ordinary HTTP(S) identifiers", async () => {
1405
+ const documentLoader = createLoader({ [compatibleNoteId]: {
1406
+ ...note(),
1407
+ id: compatibleNoteId
1408
+ } });
1409
+ deepStrictEqual((await (await createHttpActivity(compatibleNoteId)).getObject({
1410
+ documentLoader,
1411
+ contextLoader: mockDocumentLoader
1412
+ }))?.id, new URL(compatibleNoteId));
1413
+ });
1414
+ });
1415
+ test("objects use the verifyPortableObject option they were parsed with by default", async (t) => {
1416
+ const attributedNote = (id) => ({
1417
+ ...note(id),
1418
+ attributedTo: `ap://${did}/actor`
1419
+ });
1420
+ const actor = {
1421
+ "@context": "https://www.w3.org/ns/activitystreams",
1422
+ id: `ap://${did}/actor`,
1423
+ type: "Person",
1424
+ inbox: `ap://${did}/actor/inbox`
1425
+ };
1426
+ const documentLoader = createLoader({
1427
+ [compatibleNoteId]: attributedNote(compatibleNoteId),
1428
+ [gatewayUrl("https://gw.example", "/actor")]: actor
1429
+ });
1430
+ await t.step("fromJsonLd()", async () => {
1431
+ const verifier = createRecordingVerifier();
1432
+ const object = await (await createCompatibleActivity(compatibleNoteId, void 0, { verifyPortableObject: verifier })).getObject({
1433
+ documentLoader,
1434
+ contextLoader: mockDocumentLoader
1435
+ });
1436
+ assertInstanceOf(object, Note);
1437
+ deepStrictEqual(verifier.calls.length, 1);
1438
+ assertInstanceOf(await object.getAttribution({
1439
+ documentLoader,
1440
+ contextLoader: mockDocumentLoader,
1441
+ gateways: ["https://gw.example"]
1442
+ }), Person);
1443
+ deepStrictEqual(verifier.calls.length, 2);
1444
+ const embedded = await (await createCompatibleActivity(attributedNote(`ap://${did}/objects/2`), `ap://${did}/activities/1`, { verifyPortableObject: verifier })).getObject({
1445
+ documentLoader,
1446
+ contextLoader: mockDocumentLoader
1447
+ });
1448
+ assertInstanceOf(embedded, Note);
1449
+ assertInstanceOf(await embedded.getAttribution({
1450
+ documentLoader,
1451
+ contextLoader: mockDocumentLoader,
1452
+ gateways: ["https://gw.example"]
1453
+ }), Person);
1454
+ deepStrictEqual(verifier.calls.length, 3);
1455
+ });
1456
+ await t.step("the constructor and clone()", async () => {
1457
+ const verifier = createRecordingVerifier();
1458
+ const activity = new Create({
1459
+ id: new URL(gatewayUrl("https://gw.example", "/activities/1")),
1460
+ object: new URL(compatibleNoteId)
1461
+ }, {
1462
+ contextLoader: mockDocumentLoader,
1463
+ verifyPortableObject: verifier
1464
+ });
1465
+ assertInstanceOf(await activity.getObject({
1466
+ documentLoader,
1467
+ contextLoader: mockDocumentLoader
1468
+ }), Note);
1469
+ deepStrictEqual(verifier.calls.length, 1);
1470
+ const clone = activity.clone({ object: new URL(compatibleNoteId) });
1471
+ await rejects(async () => await clone.getObject({
1472
+ documentLoader,
1473
+ contextLoader: mockDocumentLoader
1474
+ }), TypeError);
1475
+ assertInstanceOf(await activity.clone({ object: new URL(compatibleNoteId) }, {
1476
+ contextLoader: mockDocumentLoader,
1477
+ verifyPortableObject: verifier
1478
+ }).getObject({
1479
+ documentLoader,
1480
+ contextLoader: mockDocumentLoader
1481
+ }), Note);
1482
+ deepStrictEqual(verifier.calls.length, 2);
1483
+ });
1484
+ await t.step("an explicit option applies to that call only", async () => {
1485
+ const stored = createRecordingVerifier();
1486
+ const given = createRecordingVerifier();
1487
+ const object = await (await createCompatibleActivity(compatibleNoteId, void 0, { verifyPortableObject: stored })).getObject({
1488
+ documentLoader,
1489
+ contextLoader: mockDocumentLoader,
1490
+ verifyPortableObject: given
1491
+ });
1492
+ assertInstanceOf(object, Note);
1493
+ deepStrictEqual([stored.calls.length, given.calls.length], [0, 1]);
1494
+ await object.getAttribution({
1495
+ documentLoader,
1496
+ contextLoader: mockDocumentLoader,
1497
+ gateways: ["https://gw.example"]
1498
+ });
1499
+ deepStrictEqual([stored.calls.length, given.calls.length], [1, 1]);
1500
+ const object2 = await (await createCompatibleActivity(compatibleNoteId)).getObject({
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);
1511
+ });
1512
+ await t.step("lookupObject()", async () => {
1513
+ const verifier = createRecordingVerifier();
1514
+ const object = await lookupObject(compatibleNoteId, {
1515
+ documentLoader,
1516
+ contextLoader: mockDocumentLoader,
1517
+ verifyPortableObject: verifier
1518
+ });
1519
+ assertInstanceOf(object, Note);
1520
+ deepStrictEqual(verifier.calls.length, 1);
1521
+ assertInstanceOf(await object.getAttribution({
1522
+ documentLoader,
1523
+ contextLoader: mockDocumentLoader,
1524
+ gateways: ["https://gw.example"]
1525
+ }), Person);
1526
+ deepStrictEqual(verifier.calls.length, 2);
1527
+ });
1528
+ await t.step("property preprocessors", async () => {
1529
+ const verifier = createVerifier();
1530
+ const icon = await (await Person.fromJsonLd({
1531
+ "@context": "https://www.w3.org/ns/activitystreams",
1532
+ id: `ap://${did}/actor`,
1533
+ type: "Person",
1534
+ icon: {
1535
+ type: "Link",
1536
+ href: "https://example.com/icon.png"
1537
+ }
1538
+ }, {
1539
+ contextLoader: mockDocumentLoader,
1540
+ verifyPortableObject: verifier
1541
+ })).getIcon({ documentLoader });
1542
+ assertInstanceOf(icon, Image);
1543
+ ok(icon._verifyPortableObject === verifier);
1544
+ });
1545
+ });
1300
1546
  //#endregion
1301
1547
  export {};
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "temporal-polyfill";
2
2
  globalThis.addEventListener = () => {};
3
- import { A as Object$1 } from "./vocab-BHtBRusa.mjs";
4
- import { i as isActor, o as name, s as version } from "./actor-DE2vFZqt.mjs";
3
+ import { A as Object$1 } from "./vocab-DFtGFGsb.mjs";
4
+ import { i as isActor, o as name, s as version } from "./actor-Ccca2qzB.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";
@@ -279,6 +279,7 @@ async function lookupObjectInternal(identifier, options = {}) {
279
279
  documentLoader,
280
280
  contextLoader: snapshot?.loader ?? options.contextLoader,
281
281
  tracerProvider: options.tracerProvider,
282
+ verifyPortableObject: options.verifyPortableObject,
282
283
  baseUrl: documentUrl
283
284
  });
284
285
  } catch (error) {
@@ -419,6 +420,7 @@ async function dereference({ options, documentLoader }, id, gateways, extra = {}
419
420
  documentLoader,
420
421
  contextLoader,
421
422
  tracerProvider,
423
+ verifyPortableObject: options.verifyPortableObject,
422
424
  baseUrl
423
425
  })
424
426
  });
@@ -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-BHtBRusa.mjs";
4
- import { t as esm_default } from "./esm-C9nxP5_e.mjs";
5
- import { n as traverseCollection, t as lookupObject } from "./lookup-56N6dAfT.mjs";
3
+ import { A as Object$1, F as Person, k as Note, s as Collection } from "./vocab-DFtGFGsb.mjs";
4
+ import { t as esm_default } from "./esm-CU6UbTlZ.mjs";
5
+ import { n as traverseCollection, t as lookupObject } from "./lookup-CspwEMVG.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-BHtBRusa.mjs";
4
- import { t as esm_default } from "./esm-C9nxP5_e.mjs";
5
- import { n as getActorHandle } from "./actor-DE2vFZqt.mjs";
6
- import { t as lookupObject } from "./lookup-56N6dAfT.mjs";
3
+ import { F as Person } from "./vocab-DFtGFGsb.mjs";
4
+ import { t as esm_default } from "./esm-CU6UbTlZ.mjs";
5
+ import { n as getActorHandle } from "./actor-Ccca2qzB.mjs";
6
+ import { t as lookupObject } from "./lookup-CspwEMVG.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-BHtBRusa.mjs";
3
+ import { M as OrderedCollection, X as vocab_exports, i as Announce, k as Note, u as Create, z as Question } from "./vocab-DFtGFGsb.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-BHtBRusa.mjs";
4
- import "./actor-DE2vFZqt.mjs";
5
- import "./lookup-56N6dAfT.mjs";
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-DFtGFGsb.mjs";
4
+ import "./actor-Ccca2qzB.mjs";
5
+ import "./lookup-CspwEMVG.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";
@@ -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-BHtBRusa.mjs";
3
+ import { E as Link, F as Person, J as getEntityTypeById, Y as isEntityType } from "./vocab-DFtGFGsb.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";