@fedify/vocab 2.3.14 → 2.3.15
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 +289 -219
- package/dist/mod.d.cts +70 -0
- package/dist/mod.d.ts +70 -0
- package/dist/mod.js +289 -219
- package/dist-tests/{actor-CdnIo4XD.mjs → actor-pD1GaHgZ.mjs} +2 -2
- package/dist-tests/actor.test.mjs +2 -2
- package/dist-tests/lookup.test.mjs +34 -14
- package/dist-tests/type.test.mjs +1 -1
- package/dist-tests/{vocab-Cyuznh-0.mjs → vocab-DHuK2moR.mjs} +288 -218
- package/dist-tests/vocab.test.mjs +11 -3
- package/package.json +5 -5
- package/src/lookup.test.ts +37 -11
- package/src/vocab.test.ts +13 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { B as __commonJSMin, E as Person, H as __toESM, P as Service, T as Organization, a as Application, m as Group } from "./vocab-
|
|
3
|
+
import { B as __commonJSMin, E as Person, H as __toESM, P as Service, T as Organization, a as Application, m as Group } from "./vocab-DHuK2moR.mjs";
|
|
4
4
|
import { t as getTypeId } from "./type-Cf-vxmre.mjs";
|
|
5
5
|
import { lookupWebFinger } from "@fedify/webfinger";
|
|
6
6
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -1206,7 +1206,7 @@ var esm_default = new class FetchMock {
|
|
|
1206
1206
|
//#endregion
|
|
1207
1207
|
//#region deno.json
|
|
1208
1208
|
var name = "@fedify/vocab";
|
|
1209
|
-
var version = "2.3.
|
|
1209
|
+
var version = "2.3.15";
|
|
1210
1210
|
//#endregion
|
|
1211
1211
|
//#region src/actor.ts
|
|
1212
1212
|
const ACTOR_DISCOVERY_HISTOGRAM_BUCKETS = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { E as Person, P as Service, T as Organization, V as __exportAll, a as Application, m as Group } from "./vocab-
|
|
4
|
-
import { a as normalizeActorHandle, c as esm_default, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-
|
|
3
|
+
import { E as Person, P as Service, T as Organization, V as __exportAll, a as Application, m as Group } from "./vocab-DHuK2moR.mjs";
|
|
4
|
+
import { a as normalizeActorHandle, c as esm_default, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-pD1GaHgZ.mjs";
|
|
5
5
|
import { createTestMeterProvider, test } from "@fedify/fixture";
|
|
6
6
|
import { deepStrictEqual, ok, rejects, strictEqual, throws } from "node:assert/strict";
|
|
7
7
|
//#region ../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/esm/check/precondition/PreconditionFailure.js
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { E as Person, S as Object$1, o as Collection, x as Note } from "./vocab-
|
|
4
|
-
import { c as esm_default, i as isActor, o as name, s as version } from "./actor-
|
|
3
|
+
import { E as Person, S as Object$1, o as Collection, x as Note } from "./vocab-DHuK2moR.mjs";
|
|
4
|
+
import { c as esm_default, i as isActor, o as name, s as version } from "./actor-pD1GaHgZ.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 { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
@@ -263,10 +263,12 @@ async function* traverseCollection(collection, options = {}) {
|
|
|
263
263
|
}
|
|
264
264
|
//#endregion
|
|
265
265
|
//#region src/lookup.test.ts
|
|
266
|
+
const allowPrivateAddress = { allowPrivateAddress: true };
|
|
266
267
|
test("lookupObject()", {
|
|
267
268
|
sanitizeResources: false,
|
|
268
269
|
sanitizeOps: false
|
|
269
270
|
}, async (t) => {
|
|
271
|
+
const responseTimers = [];
|
|
270
272
|
esm_default.spyGlobal();
|
|
271
273
|
esm_default.get("begin:https://example.com/.well-known/webfinger", {
|
|
272
274
|
subject: "acct:johndoe@example.com",
|
|
@@ -290,7 +292,8 @@ test("lookupObject()", {
|
|
|
290
292
|
});
|
|
291
293
|
const options = {
|
|
292
294
|
documentLoader: mockDocumentLoader,
|
|
293
|
-
contextLoader: mockDocumentLoader
|
|
295
|
+
contextLoader: mockDocumentLoader,
|
|
296
|
+
...allowPrivateAddress
|
|
294
297
|
};
|
|
295
298
|
await t.step("actor", async () => {
|
|
296
299
|
const person = await lookupObject("@johndoe@example.com", options);
|
|
@@ -329,7 +332,7 @@ test("lookupObject()", {
|
|
|
329
332
|
});
|
|
330
333
|
esm_default.removeRoutes({ includeFallback: false });
|
|
331
334
|
esm_default.get("begin:https://example.com/.well-known/webfinger", () => new Promise((resolve) => {
|
|
332
|
-
setTimeout(() => {
|
|
335
|
+
responseTimers.push(setTimeout(() => {
|
|
333
336
|
resolve({
|
|
334
337
|
subject: "acct:johndoe@example.com",
|
|
335
338
|
links: [{
|
|
@@ -338,7 +341,7 @@ test("lookupObject()", {
|
|
|
338
341
|
type: "application/activity+json"
|
|
339
342
|
}]
|
|
340
343
|
});
|
|
341
|
-
}, 1e3);
|
|
344
|
+
}, 1e3));
|
|
342
345
|
}));
|
|
343
346
|
await t.step("request cancellation", async () => {
|
|
344
347
|
const controller = new AbortController();
|
|
@@ -369,7 +372,7 @@ test("lookupObject()", {
|
|
|
369
372
|
});
|
|
370
373
|
esm_default.removeRoutes({ includeFallback: false });
|
|
371
374
|
esm_default.get("begin:https://example.com/.well-known/webfinger", () => new Promise((resolve) => {
|
|
372
|
-
setTimeout(() => {
|
|
375
|
+
responseTimers.push(setTimeout(() => {
|
|
373
376
|
resolve({
|
|
374
377
|
subject: "acct:johndoe@example.com",
|
|
375
378
|
links: [{
|
|
@@ -378,7 +381,7 @@ test("lookupObject()", {
|
|
|
378
381
|
type: "application/activity+json"
|
|
379
382
|
}]
|
|
380
383
|
});
|
|
381
|
-
}, 500);
|
|
384
|
+
}, 500));
|
|
382
385
|
}));
|
|
383
386
|
await t.step("cancellation with immediate abort", async () => {
|
|
384
387
|
const controller = new AbortController();
|
|
@@ -390,7 +393,7 @@ test("lookupObject()", {
|
|
|
390
393
|
});
|
|
391
394
|
esm_default.removeRoutes({ includeFallback: false });
|
|
392
395
|
esm_default.get("https://example.com/slow-object", () => new Promise((resolve) => {
|
|
393
|
-
setTimeout(() => {
|
|
396
|
+
responseTimers.push(setTimeout(() => {
|
|
394
397
|
resolve({
|
|
395
398
|
status: 200,
|
|
396
399
|
headers: { "Content-Type": "application/activity+json" },
|
|
@@ -400,7 +403,7 @@ test("lookupObject()", {
|
|
|
400
403
|
content: "Slow response"
|
|
401
404
|
}
|
|
402
405
|
});
|
|
403
|
-
}, 1e3);
|
|
406
|
+
}, 1e3));
|
|
404
407
|
}));
|
|
405
408
|
await t.step("direct object fetch cancellation", async () => {
|
|
406
409
|
const controller = new AbortController();
|
|
@@ -411,6 +414,7 @@ test("lookupObject()", {
|
|
|
411
414
|
controller.abort();
|
|
412
415
|
deepStrictEqual(await promise, null);
|
|
413
416
|
});
|
|
417
|
+
for (const timer of responseTimers) clearTimeout(timer);
|
|
414
418
|
esm_default.hardReset();
|
|
415
419
|
esm_default.removeRoutes();
|
|
416
420
|
});
|
|
@@ -581,15 +585,18 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
581
585
|
throw new Error(`Unexpected URL: ${url}`);
|
|
582
586
|
};
|
|
583
587
|
deepStrictEqual(await lookupObject("@user@example.com", {
|
|
588
|
+
...allowPrivateAddress,
|
|
584
589
|
documentLoader: webfingerDocumentLoader,
|
|
585
590
|
contextLoader: mockDocumentLoader
|
|
586
591
|
}), null);
|
|
587
592
|
await rejects(() => lookupObject("@user@example.com", {
|
|
593
|
+
...allowPrivateAddress,
|
|
588
594
|
documentLoader: webfingerDocumentLoader,
|
|
589
595
|
contextLoader: mockDocumentLoader,
|
|
590
596
|
crossOrigin: "throw"
|
|
591
597
|
}), Error, "The object's @id (https://malicious.com/fake-actor) has a different origin than the document URL (https://different-origin.com/actor)");
|
|
592
598
|
const result2 = await lookupObject("@user@example.com", {
|
|
599
|
+
...allowPrivateAddress,
|
|
593
600
|
documentLoader: webfingerDocumentLoader,
|
|
594
601
|
contextLoader: mockDocumentLoader,
|
|
595
602
|
crossOrigin: "trust"
|
|
@@ -660,11 +667,20 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
660
667
|
const errorDocumentLoader = async (_url) => {
|
|
661
668
|
throw new Error("Network error");
|
|
662
669
|
};
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
670
|
+
esm_default.spyGlobal();
|
|
671
|
+
esm_default.get("begin:https://example.com/.well-known/webfinger", 404);
|
|
672
|
+
let result;
|
|
673
|
+
try {
|
|
674
|
+
result = await lookupObject("https://example.com/note", {
|
|
675
|
+
...allowPrivateAddress,
|
|
676
|
+
documentLoader: errorDocumentLoader,
|
|
677
|
+
contextLoader: mockDocumentLoader,
|
|
678
|
+
crossOrigin: "throw"
|
|
679
|
+
});
|
|
680
|
+
} finally {
|
|
681
|
+
esm_default.hardReset();
|
|
682
|
+
}
|
|
683
|
+
deepStrictEqual(result, null);
|
|
668
684
|
});
|
|
669
685
|
await t.step("malformed JSON handling with cross-origin policy", async () => {
|
|
670
686
|
const malformedJsonDocumentLoader = async (url) => {
|
|
@@ -729,6 +745,7 @@ test("lookupObject() records activitypub.object.lookup counter", {
|
|
|
729
745
|
await t.step("records kind=actor for an actor result", async () => {
|
|
730
746
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
731
747
|
assertInstanceOf(await lookupObject("@johndoe@example.com", {
|
|
748
|
+
...allowPrivateAddress,
|
|
732
749
|
documentLoader: mockDocumentLoader,
|
|
733
750
|
contextLoader: mockDocumentLoader,
|
|
734
751
|
meterProvider
|
|
@@ -782,6 +799,7 @@ test("lookupObject() records activitypub.object.lookup counter", {
|
|
|
782
799
|
});
|
|
783
800
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
784
801
|
deepStrictEqual(await lookupObject("janedoe@example.com", {
|
|
802
|
+
...allowPrivateAddress,
|
|
785
803
|
documentLoader: mockDocumentLoader,
|
|
786
804
|
contextLoader: mockDocumentLoader,
|
|
787
805
|
meterProvider
|
|
@@ -811,6 +829,7 @@ test("lookupObject() records activitypub.object.lookup counter", {
|
|
|
811
829
|
});
|
|
812
830
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
813
831
|
await lookupObject("@johndoe@example.com", {
|
|
832
|
+
...allowPrivateAddress,
|
|
814
833
|
documentLoader: mockDocumentLoader,
|
|
815
834
|
contextLoader: mockDocumentLoader,
|
|
816
835
|
meterProvider
|
|
@@ -832,6 +851,7 @@ test("lookupObject() records activitypub.object.lookup counter", {
|
|
|
832
851
|
});
|
|
833
852
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
834
853
|
await lookupObject(new URL("acct:johndoe@example.com"), {
|
|
854
|
+
...allowPrivateAddress,
|
|
835
855
|
documentLoader: mockDocumentLoader,
|
|
836
856
|
contextLoader: mockDocumentLoader,
|
|
837
857
|
meterProvider
|
package/dist-tests/type.test.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { E as Person, L as getEntityTypeById, R as isEntityType, y as Link } from "./vocab-
|
|
3
|
+
import { E as Person, L as getEntityTypeById, R as isEntityType, y as Link } from "./vocab-DHuK2moR.mjs";
|
|
4
4
|
import { t as getTypeId } from "./type-Cf-vxmre.mjs";
|
|
5
5
|
import { test } from "@fedify/fixture";
|
|
6
6
|
import { deepStrictEqual } from "node:assert/strict";
|