@fedify/vocab 2.0.35-dev.2480 → 2.0.35-dev.2485
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 +1 -1
- package/dist/mod.js +1 -1
- package/dist-tests/actor.test.mjs +1 -1
- package/dist-tests/{deno-CE4EWORO.mjs → deno-CMV97EJ4.mjs} +1 -1
- package/dist-tests/lookup.test.mjs +21 -7
- package/dist-tests/vocab.test.mjs +10 -2
- package/package.json +4 -4
- package/src/lookup.test.ts +25 -5
- package/src/vocab.test.ts +13 -2
package/deno.json
CHANGED
package/dist/mod.cjs
CHANGED
|
@@ -33,7 +33,7 @@ let _fedify_vocab_runtime_temporal = require("@fedify/vocab-runtime/temporal");
|
|
|
33
33
|
let es_toolkit = require("es-toolkit");
|
|
34
34
|
//#region deno.json
|
|
35
35
|
var name = "@fedify/vocab";
|
|
36
|
-
var version = "2.0.35-dev.
|
|
36
|
+
var version = "2.0.35-dev.2485+75206550";
|
|
37
37
|
//#endregion
|
|
38
38
|
//#region src/type.ts
|
|
39
39
|
function getTypeId(object) {
|
package/dist/mod.js
CHANGED
|
@@ -9,7 +9,7 @@ import { isTemporalDuration, isTemporalInstant } from "@fedify/vocab-runtime/tem
|
|
|
9
9
|
import { delay } from "es-toolkit";
|
|
10
10
|
//#region deno.json
|
|
11
11
|
var name = "@fedify/vocab";
|
|
12
|
-
var version = "2.0.35-dev.
|
|
12
|
+
var version = "2.0.35-dev.2485+75206550";
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/type.ts
|
|
15
15
|
function getTypeId(object) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
3
|
import { b as Service, g as Person, h as Organization, i as Application, l as Group, w as __exportAll } from "./vocab-4POt9BSw.mjs";
|
|
4
|
-
import { n as version, r as esm_default, t as name } from "./deno-
|
|
4
|
+
import { n as version, r as esm_default, t as name } from "./deno-CMV97EJ4.mjs";
|
|
5
5
|
import { t as getTypeId } from "./type-Cf-vxmre.mjs";
|
|
6
6
|
import { test } from "@fedify/fixture";
|
|
7
7
|
import { deepStrictEqual, ok, rejects, strictEqual, throws } from "node:assert/strict";
|
|
@@ -1204,6 +1204,6 @@ var esm_default = new class FetchMock {
|
|
|
1204
1204
|
//#endregion
|
|
1205
1205
|
//#region deno.json
|
|
1206
1206
|
var name = "@fedify/vocab";
|
|
1207
|
-
var version = "2.0.35-dev.
|
|
1207
|
+
var version = "2.0.35-dev.2485+75206550";
|
|
1208
1208
|
//#endregion
|
|
1209
1209
|
export { version as n, esm_default as r, name as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
3
|
import { a as Collection, f as Note, g as Person, p as Object$1 } from "./vocab-4POt9BSw.mjs";
|
|
4
|
-
import { n as version, r as esm_default, t as name } from "./deno-
|
|
4
|
+
import { n as version, r as esm_default, t as name } from "./deno-CMV97EJ4.mjs";
|
|
5
5
|
import { t as getTypeId } from "./type-Cf-vxmre.mjs";
|
|
6
6
|
import { t as assertInstanceOf } from "./utils-CE8Dk5hm.mjs";
|
|
7
7
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
@@ -220,6 +220,7 @@ async function* traverseCollection(collection, options = {}) {
|
|
|
220
220
|
}
|
|
221
221
|
//#endregion
|
|
222
222
|
//#region src/lookup.test.ts
|
|
223
|
+
const allowPrivateAddress = { allowPrivateAddress: true };
|
|
223
224
|
test("lookupObject()", {
|
|
224
225
|
sanitizeResources: false,
|
|
225
226
|
sanitizeOps: false
|
|
@@ -247,7 +248,8 @@ test("lookupObject()", {
|
|
|
247
248
|
});
|
|
248
249
|
const options = {
|
|
249
250
|
documentLoader: mockDocumentLoader,
|
|
250
|
-
contextLoader: mockDocumentLoader
|
|
251
|
+
contextLoader: mockDocumentLoader,
|
|
252
|
+
...allowPrivateAddress
|
|
251
253
|
};
|
|
252
254
|
await t.step("actor", async () => {
|
|
253
255
|
const person = await lookupObject("@johndoe@example.com", options);
|
|
@@ -538,15 +540,18 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
538
540
|
throw new Error(`Unexpected URL: ${url}`);
|
|
539
541
|
};
|
|
540
542
|
deepStrictEqual(await lookupObject("@user@example.com", {
|
|
543
|
+
...allowPrivateAddress,
|
|
541
544
|
documentLoader: webfingerDocumentLoader,
|
|
542
545
|
contextLoader: mockDocumentLoader
|
|
543
546
|
}), null);
|
|
544
547
|
await rejects(() => lookupObject("@user@example.com", {
|
|
548
|
+
...allowPrivateAddress,
|
|
545
549
|
documentLoader: webfingerDocumentLoader,
|
|
546
550
|
contextLoader: mockDocumentLoader,
|
|
547
551
|
crossOrigin: "throw"
|
|
548
552
|
}), Error, "The object's @id (https://malicious.com/fake-actor) has a different origin than the document URL (https://different-origin.com/actor)");
|
|
549
553
|
const result2 = await lookupObject("@user@example.com", {
|
|
554
|
+
...allowPrivateAddress,
|
|
550
555
|
documentLoader: webfingerDocumentLoader,
|
|
551
556
|
contextLoader: mockDocumentLoader,
|
|
552
557
|
crossOrigin: "trust"
|
|
@@ -617,11 +622,20 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
617
622
|
const errorDocumentLoader = async (_url) => {
|
|
618
623
|
throw new Error("Network error");
|
|
619
624
|
};
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
+
esm_default.spyGlobal();
|
|
626
|
+
esm_default.get("begin:https://example.com/.well-known/webfinger", 404);
|
|
627
|
+
let result;
|
|
628
|
+
try {
|
|
629
|
+
result = await lookupObject("https://example.com/note", {
|
|
630
|
+
...allowPrivateAddress,
|
|
631
|
+
documentLoader: errorDocumentLoader,
|
|
632
|
+
contextLoader: mockDocumentLoader,
|
|
633
|
+
crossOrigin: "throw"
|
|
634
|
+
});
|
|
635
|
+
} finally {
|
|
636
|
+
esm_default.hardReset();
|
|
637
|
+
}
|
|
638
|
+
deepStrictEqual(result, null);
|
|
625
639
|
});
|
|
626
640
|
await t.step("malformed JSON handling with cross-origin policy", async () => {
|
|
627
641
|
const malformedJsonDocumentLoader = async (url) => {
|
|
@@ -363,7 +363,11 @@ test({
|
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
365
|
});
|
|
366
|
-
deepStrictEqual(await new Activity({ object: new URL("https://example.com/not-found") }).getObject({
|
|
366
|
+
deepStrictEqual(await new Activity({ object: new URL("https://example.com/not-found") }).getObject({
|
|
367
|
+
documentLoader: mockDocumentLoader,
|
|
368
|
+
contextLoader: mockDocumentLoader,
|
|
369
|
+
suppressError: true
|
|
370
|
+
}), null);
|
|
367
371
|
const object3 = await (await Activity.fromJsonLd({
|
|
368
372
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
369
373
|
type: "Create",
|
|
@@ -400,7 +404,11 @@ test({
|
|
|
400
404
|
assertInstanceOf(objects[1], Object$1);
|
|
401
405
|
deepStrictEqual(objects[1].name, "Second object");
|
|
402
406
|
const activity2 = new Activity({ objects: [new URL("https://example.com/not-found"), new Object$1({ name: "Second object" })] });
|
|
403
|
-
const objects2 = await Array.fromAsync(activity2.getObjects({
|
|
407
|
+
const objects2 = await Array.fromAsync(activity2.getObjects({
|
|
408
|
+
documentLoader: mockDocumentLoader,
|
|
409
|
+
contextLoader: mockDocumentLoader,
|
|
410
|
+
suppressError: true
|
|
411
|
+
}));
|
|
404
412
|
deepStrictEqual(objects2.length, 1);
|
|
405
413
|
assertInstanceOf(objects2[0], Object$1);
|
|
406
414
|
deepStrictEqual(objects2[0].name, "Second object");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/vocab",
|
|
3
|
-
"version": "2.0.35-dev.
|
|
3
|
+
"version": "2.0.35-dev.2485+75206550",
|
|
4
4
|
"homepage": "https://fedify.dev/",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"es-toolkit": "1.43.0",
|
|
47
47
|
"jsonld": "^9.0.0",
|
|
48
48
|
"pkijs": "^3.3.3",
|
|
49
|
-
"@fedify/vocab-tools": "2.0.35-dev.
|
|
50
|
-
"@fedify/vocab-runtime": "2.0.35-dev.
|
|
51
|
-
"@fedify/webfinger": "2.0.35-dev.
|
|
49
|
+
"@fedify/vocab-tools": "2.0.35-dev.2485+75206550",
|
|
50
|
+
"@fedify/vocab-runtime": "2.0.35-dev.2485+75206550",
|
|
51
|
+
"@fedify/webfinger": "2.0.35-dev.2485+75206550"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^22.17.0",
|
package/src/lookup.test.ts
CHANGED
|
@@ -9,6 +9,12 @@ import { lookupObject, traverseCollection } from "./lookup.ts";
|
|
|
9
9
|
import { assertInstanceOf } from "./utils.ts";
|
|
10
10
|
import { Collection, Note, Object, Person } from "./vocab.ts";
|
|
11
11
|
|
|
12
|
+
// lookupObject() accepts this option without declaring it, since Fedify's
|
|
13
|
+
// Context passes it. It makes WebFinger lookups use the global fetch()
|
|
14
|
+
// (fetch-mock here) without resolving hostnames, so that the tests do not
|
|
15
|
+
// depend on the real DNS:
|
|
16
|
+
const allowPrivateAddress = { allowPrivateAddress: true };
|
|
17
|
+
|
|
12
18
|
test("lookupObject()", {
|
|
13
19
|
sanitizeResources: false,
|
|
14
20
|
sanitizeOps: false,
|
|
@@ -42,6 +48,7 @@ test("lookupObject()", {
|
|
|
42
48
|
const options = {
|
|
43
49
|
documentLoader: mockDocumentLoader,
|
|
44
50
|
contextLoader: mockDocumentLoader,
|
|
51
|
+
...allowPrivateAddress,
|
|
45
52
|
};
|
|
46
53
|
|
|
47
54
|
await t.step("actor", async () => {
|
|
@@ -479,6 +486,7 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
479
486
|
|
|
480
487
|
// Default behavior should return null
|
|
481
488
|
const result1 = await lookupObject("@user@example.com", {
|
|
489
|
+
...allowPrivateAddress,
|
|
482
490
|
documentLoader: webfingerDocumentLoader,
|
|
483
491
|
contextLoader: mockDocumentLoader,
|
|
484
492
|
});
|
|
@@ -488,6 +496,7 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
488
496
|
await rejects(
|
|
489
497
|
() =>
|
|
490
498
|
lookupObject("@user@example.com", {
|
|
499
|
+
...allowPrivateAddress,
|
|
491
500
|
documentLoader: webfingerDocumentLoader,
|
|
492
501
|
contextLoader: mockDocumentLoader,
|
|
493
502
|
crossOrigin: "throw",
|
|
@@ -498,6 +507,7 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
498
507
|
|
|
499
508
|
// With crossOrigin: trust, should return the object
|
|
500
509
|
const result2 = await lookupObject("@user@example.com", {
|
|
510
|
+
...allowPrivateAddress,
|
|
501
511
|
documentLoader: webfingerDocumentLoader,
|
|
502
512
|
contextLoader: mockDocumentLoader,
|
|
503
513
|
crossOrigin: "trust",
|
|
@@ -597,12 +607,22 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
597
607
|
throw new Error("Network error");
|
|
598
608
|
};
|
|
599
609
|
|
|
610
|
+
// The WebFinger fallback must not reach the network:
|
|
611
|
+
fetchMock.spyGlobal();
|
|
612
|
+
fetchMock.get("begin:https://example.com/.well-known/webfinger", 404);
|
|
613
|
+
|
|
600
614
|
// Network errors should not be confused with cross-origin errors
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
615
|
+
let result;
|
|
616
|
+
try {
|
|
617
|
+
result = await lookupObject("https://example.com/note", {
|
|
618
|
+
...allowPrivateAddress,
|
|
619
|
+
documentLoader: errorDocumentLoader,
|
|
620
|
+
contextLoader: mockDocumentLoader,
|
|
621
|
+
crossOrigin: "throw",
|
|
622
|
+
});
|
|
623
|
+
} finally {
|
|
624
|
+
fetchMock.hardReset();
|
|
625
|
+
}
|
|
606
626
|
|
|
607
627
|
// Should return null because the document loader failed,
|
|
608
628
|
// not because of cross-origin policy
|
package/src/vocab.test.ts
CHANGED
|
@@ -548,7 +548,14 @@ test({
|
|
|
548
548
|
const activity2 = new Activity({
|
|
549
549
|
object: new URL("https://example.com/not-found"),
|
|
550
550
|
});
|
|
551
|
-
deepStrictEqual(
|
|
551
|
+
deepStrictEqual(
|
|
552
|
+
await activity2.getObject({
|
|
553
|
+
documentLoader: mockDocumentLoader,
|
|
554
|
+
contextLoader: mockDocumentLoader,
|
|
555
|
+
suppressError: true,
|
|
556
|
+
}),
|
|
557
|
+
null,
|
|
558
|
+
);
|
|
552
559
|
|
|
553
560
|
const activity3 = await Activity.fromJsonLd({
|
|
554
561
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
@@ -603,7 +610,11 @@ test({
|
|
|
603
610
|
],
|
|
604
611
|
});
|
|
605
612
|
const objects2 = await Array.fromAsync(
|
|
606
|
-
activity2.getObjects({
|
|
613
|
+
activity2.getObjects({
|
|
614
|
+
documentLoader: mockDocumentLoader,
|
|
615
|
+
contextLoader: mockDocumentLoader,
|
|
616
|
+
suppressError: true,
|
|
617
|
+
}),
|
|
607
618
|
);
|
|
608
619
|
deepStrictEqual(objects2.length, 1);
|
|
609
620
|
assertInstanceOf(objects2[0], Object);
|