@fedify/vocab 2.2.19 → 2.2.20
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 +282 -217
- package/dist/mod.d.cts +65 -0
- package/dist/mod.d.ts +65 -0
- package/dist/mod.js +282 -217
- package/dist-tests/actor.test.mjs +2 -2
- package/dist-tests/{deno-6CUIKmD6.mjs → deno-CE8IFnvm.mjs} +2 -2
- package/dist-tests/lookup.test.mjs +30 -14
- package/dist-tests/type.test.mjs +1 -1
- package/dist-tests/{vocab-DTY3b5Yj.mjs → vocab-C6G3QtaR.mjs} +281 -216
- package/dist-tests/vocab.test.mjs +11 -3
- package/package.json +5 -5
- package/src/lookup.test.ts +33 -11
- package/src/vocab.test.ts +13 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { E as Service, N as __exportAll, b as Person, d as Group, i as Application, y as Organization } from "./vocab-
|
|
4
|
-
import { n as version, r as esm_default, t as name } from "./deno-
|
|
3
|
+
import { E as Service, N as __exportAll, b as Person, d as Group, i as Application, y as Organization } from "./vocab-C6G3QtaR.mjs";
|
|
4
|
+
import { n as version, r as esm_default, t as name } from "./deno-CE8IFnvm.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";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { M as __commonJSMin, P as __toESM } from "./vocab-
|
|
3
|
+
import { M as __commonJSMin, P as __toESM } from "./vocab-C6G3QtaR.mjs";
|
|
4
4
|
//#region ../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
|
|
5
5
|
var require_glob_to_regexp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6
6
|
module.exports = function(glob, opts) {
|
|
@@ -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.2.
|
|
1207
|
+
var version = "2.2.20";
|
|
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
|
-
import { _ as Object$1, a as Collection, b as Person, g as Note } from "./vocab-
|
|
4
|
-
import { n as version, r as esm_default, t as name } from "./deno-
|
|
3
|
+
import { _ as Object$1, a as Collection, b as Person, g as Note } from "./vocab-C6G3QtaR.mjs";
|
|
4
|
+
import { n as version, r as esm_default, t as name } from "./deno-CE8IFnvm.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,10 +220,12 @@ 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
|
|
226
227
|
}, async (t) => {
|
|
228
|
+
const responseTimers = [];
|
|
227
229
|
esm_default.spyGlobal();
|
|
228
230
|
esm_default.get("begin:https://example.com/.well-known/webfinger", {
|
|
229
231
|
subject: "acct:johndoe@example.com",
|
|
@@ -247,7 +249,8 @@ test("lookupObject()", {
|
|
|
247
249
|
});
|
|
248
250
|
const options = {
|
|
249
251
|
documentLoader: mockDocumentLoader,
|
|
250
|
-
contextLoader: mockDocumentLoader
|
|
252
|
+
contextLoader: mockDocumentLoader,
|
|
253
|
+
...allowPrivateAddress
|
|
251
254
|
};
|
|
252
255
|
await t.step("actor", async () => {
|
|
253
256
|
const person = await lookupObject("@johndoe@example.com", options);
|
|
@@ -286,7 +289,7 @@ test("lookupObject()", {
|
|
|
286
289
|
});
|
|
287
290
|
esm_default.removeRoutes({ includeFallback: false });
|
|
288
291
|
esm_default.get("begin:https://example.com/.well-known/webfinger", () => new Promise((resolve) => {
|
|
289
|
-
setTimeout(() => {
|
|
292
|
+
responseTimers.push(setTimeout(() => {
|
|
290
293
|
resolve({
|
|
291
294
|
subject: "acct:johndoe@example.com",
|
|
292
295
|
links: [{
|
|
@@ -295,7 +298,7 @@ test("lookupObject()", {
|
|
|
295
298
|
type: "application/activity+json"
|
|
296
299
|
}]
|
|
297
300
|
});
|
|
298
|
-
}, 1e3);
|
|
301
|
+
}, 1e3));
|
|
299
302
|
}));
|
|
300
303
|
await t.step("request cancellation", async () => {
|
|
301
304
|
const controller = new AbortController();
|
|
@@ -326,7 +329,7 @@ test("lookupObject()", {
|
|
|
326
329
|
});
|
|
327
330
|
esm_default.removeRoutes({ includeFallback: false });
|
|
328
331
|
esm_default.get("begin:https://example.com/.well-known/webfinger", () => new Promise((resolve) => {
|
|
329
|
-
setTimeout(() => {
|
|
332
|
+
responseTimers.push(setTimeout(() => {
|
|
330
333
|
resolve({
|
|
331
334
|
subject: "acct:johndoe@example.com",
|
|
332
335
|
links: [{
|
|
@@ -335,7 +338,7 @@ test("lookupObject()", {
|
|
|
335
338
|
type: "application/activity+json"
|
|
336
339
|
}]
|
|
337
340
|
});
|
|
338
|
-
}, 500);
|
|
341
|
+
}, 500));
|
|
339
342
|
}));
|
|
340
343
|
await t.step("cancellation with immediate abort", async () => {
|
|
341
344
|
const controller = new AbortController();
|
|
@@ -347,7 +350,7 @@ test("lookupObject()", {
|
|
|
347
350
|
});
|
|
348
351
|
esm_default.removeRoutes({ includeFallback: false });
|
|
349
352
|
esm_default.get("https://example.com/slow-object", () => new Promise((resolve) => {
|
|
350
|
-
setTimeout(() => {
|
|
353
|
+
responseTimers.push(setTimeout(() => {
|
|
351
354
|
resolve({
|
|
352
355
|
status: 200,
|
|
353
356
|
headers: { "Content-Type": "application/activity+json" },
|
|
@@ -357,7 +360,7 @@ test("lookupObject()", {
|
|
|
357
360
|
content: "Slow response"
|
|
358
361
|
}
|
|
359
362
|
});
|
|
360
|
-
}, 1e3);
|
|
363
|
+
}, 1e3));
|
|
361
364
|
}));
|
|
362
365
|
await t.step("direct object fetch cancellation", async () => {
|
|
363
366
|
const controller = new AbortController();
|
|
@@ -368,6 +371,7 @@ test("lookupObject()", {
|
|
|
368
371
|
controller.abort();
|
|
369
372
|
deepStrictEqual(await promise, null);
|
|
370
373
|
});
|
|
374
|
+
for (const timer of responseTimers) clearTimeout(timer);
|
|
371
375
|
esm_default.hardReset();
|
|
372
376
|
esm_default.removeRoutes();
|
|
373
377
|
});
|
|
@@ -538,15 +542,18 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
538
542
|
throw new Error(`Unexpected URL: ${url}`);
|
|
539
543
|
};
|
|
540
544
|
deepStrictEqual(await lookupObject("@user@example.com", {
|
|
545
|
+
...allowPrivateAddress,
|
|
541
546
|
documentLoader: webfingerDocumentLoader,
|
|
542
547
|
contextLoader: mockDocumentLoader
|
|
543
548
|
}), null);
|
|
544
549
|
await rejects(() => lookupObject("@user@example.com", {
|
|
550
|
+
...allowPrivateAddress,
|
|
545
551
|
documentLoader: webfingerDocumentLoader,
|
|
546
552
|
contextLoader: mockDocumentLoader,
|
|
547
553
|
crossOrigin: "throw"
|
|
548
554
|
}), Error, "The object's @id (https://malicious.com/fake-actor) has a different origin than the document URL (https://different-origin.com/actor)");
|
|
549
555
|
const result2 = await lookupObject("@user@example.com", {
|
|
556
|
+
...allowPrivateAddress,
|
|
550
557
|
documentLoader: webfingerDocumentLoader,
|
|
551
558
|
contextLoader: mockDocumentLoader,
|
|
552
559
|
crossOrigin: "trust"
|
|
@@ -617,11 +624,20 @@ test("FEP-fe34: lookupObject() cross-origin security", {
|
|
|
617
624
|
const errorDocumentLoader = async (_url) => {
|
|
618
625
|
throw new Error("Network error");
|
|
619
626
|
};
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
627
|
+
esm_default.spyGlobal();
|
|
628
|
+
esm_default.get("begin:https://example.com/.well-known/webfinger", 404);
|
|
629
|
+
let result;
|
|
630
|
+
try {
|
|
631
|
+
result = await lookupObject("https://example.com/note", {
|
|
632
|
+
...allowPrivateAddress,
|
|
633
|
+
documentLoader: errorDocumentLoader,
|
|
634
|
+
contextLoader: mockDocumentLoader,
|
|
635
|
+
crossOrigin: "throw"
|
|
636
|
+
});
|
|
637
|
+
} finally {
|
|
638
|
+
esm_default.hardReset();
|
|
639
|
+
}
|
|
640
|
+
deepStrictEqual(result, null);
|
|
625
641
|
});
|
|
626
642
|
await t.step("malformed JSON handling with cross-origin policy", async () => {
|
|
627
643
|
const malformedJsonDocumentLoader = async (url) => {
|
package/dist-tests/type.test.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { A as isEntityType, b as Person, h as Link, k as getEntityTypeById } from "./vocab-
|
|
3
|
+
import { A as isEntityType, b as Person, h as Link, k as getEntityTypeById } from "./vocab-C6G3QtaR.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";
|