@fedify/vocab-runtime 2.0.31-dev.2308 → 2.0.31-dev.2316
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 +2 -2
- package/dist/mod.cjs +2 -2
- package/dist/mod.js +2 -2
- package/dist/tests/{body-DGmcZ1Kz.cjs → body-BLtrczC8.cjs} +1 -1
- package/dist/tests/{body-Bx6-vXo_.mjs → body-PONsC2hg.mjs} +1 -1
- package/dist/tests/body.test.cjs +1 -1
- package/dist/tests/body.test.mjs +1 -1
- package/dist/tests/docloader.test.cjs +57 -45
- package/dist/tests/docloader.test.mjs +48 -36
- package/dist/tests/multibase/multibase.test.cjs +7 -7
- package/dist/tests/multibase/multibase.test.mjs +5 -5
- package/dist/tests/{request-BV7yaWdl.mjs → request-BD0HpfwZ.mjs} +1 -1
- package/dist/tests/{request-Ban3HXuI.cjs → request-BdKDFsbY.cjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/package.json +6 -3
- package/scripts/test-bun.mjs +18 -0
- package/src/contexts.ts +1 -1
- package/src/docloader.test.ts +99 -68
- package/src/multibase/multibase.test.ts +5 -5
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-
|
|
2
|
-
import { n as MAX_BODY_SIZE, r as readBoundedText } from "./body-
|
|
1
|
+
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-BD0HpfwZ.mjs";
|
|
2
|
+
import { n as MAX_BODY_SIZE, r as readBoundedText } from "./body-PONsC2hg.mjs";
|
|
3
3
|
import { t as HttpHeaderLink } from "./link-NUUWCdnK.mjs";
|
|
4
4
|
import { o as validatePublicUrl, t as UrlError } from "./url-DzlMS01z.mjs";
|
|
5
|
-
import { test } from "node:test";
|
|
6
5
|
import { gzipSync } from "node:zlib";
|
|
7
6
|
import { configure, getLogger, reset } from "@logtape/logtape";
|
|
8
7
|
import { deepStrictEqual, ok, rejects } from "node:assert";
|
|
9
8
|
import dns from "node:dns/promises";
|
|
9
|
+
import { test } from "@fedify/fixture";
|
|
10
10
|
import { createServer } from "node:http";
|
|
11
11
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
12
12
|
import jsonld from "jsonld/dist/jsonld.esm.js";
|
|
@@ -5712,7 +5712,7 @@ const preloadedContexts = {
|
|
|
5712
5712
|
"suspended": "toot:suspended",
|
|
5713
5713
|
"attributionDomains": {
|
|
5714
5714
|
"@id": "toot:attributionDomains",
|
|
5715
|
-
"@
|
|
5715
|
+
"@container": "@set"
|
|
5716
5716
|
}
|
|
5717
5717
|
} },
|
|
5718
5718
|
"https://purl.archive.org/miscellany": miscellany_default
|
|
@@ -5941,7 +5941,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
5941
5941
|
name: "Fetched object",
|
|
5942
5942
|
type: "Object"
|
|
5943
5943
|
} });
|
|
5944
|
-
await t.
|
|
5944
|
+
await t.step("ok", async () => {
|
|
5945
5945
|
deepStrictEqual(await fetchDocumentLoader("https://example.com/object"), {
|
|
5946
5946
|
contextUrl: null,
|
|
5947
5947
|
documentUrl: "https://example.com/object",
|
|
@@ -5984,7 +5984,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
5984
5984
|
Link: "<https://example.com/object>; rel=\"alternate\"; type=\"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"\""
|
|
5985
5985
|
}
|
|
5986
5986
|
});
|
|
5987
|
-
await t.
|
|
5987
|
+
await t.step("Link header", async () => {
|
|
5988
5988
|
deepStrictEqual(await fetchDocumentLoader("https://example.com/link-ctx"), {
|
|
5989
5989
|
contextUrl: "https://www.w3.org/ns/activitystreams",
|
|
5990
5990
|
documentUrl: "https://example.com/link-ctx",
|
|
@@ -6005,7 +6005,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6005
6005
|
}
|
|
6006
6006
|
});
|
|
6007
6007
|
});
|
|
6008
|
-
await t.
|
|
6008
|
+
await t.step("Link header relative url", async () => {
|
|
6009
6009
|
deepStrictEqual(await fetchDocumentLoader("https://example.com/link-ctx"), {
|
|
6010
6010
|
contextUrl: "https://www.w3.org/ns/activitystreams",
|
|
6011
6011
|
documentUrl: "https://example.com/link-ctx",
|
|
@@ -6026,7 +6026,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6026
6026
|
}
|
|
6027
6027
|
});
|
|
6028
6028
|
});
|
|
6029
|
-
await t.
|
|
6029
|
+
await t.step("wrong Link header syntax", async () => {
|
|
6030
6030
|
deepStrictEqual(await fetchDocumentLoader("https://example.com/obj-w-wrong-link"), {
|
|
6031
6031
|
contextUrl: null,
|
|
6032
6032
|
documentUrl: "https://example.com/obj-w-wrong-link",
|
|
@@ -6050,7 +6050,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6050
6050
|
</html>`,
|
|
6051
6051
|
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
6052
6052
|
});
|
|
6053
|
-
await t.
|
|
6053
|
+
await t.step("HTML <link>", async () => {
|
|
6054
6054
|
deepStrictEqual(await fetchDocumentLoader("https://example.com/html-link"), {
|
|
6055
6055
|
contextUrl: null,
|
|
6056
6056
|
documentUrl: "https://example.com/object",
|
|
@@ -6074,7 +6074,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6074
6074
|
</html>`,
|
|
6075
6075
|
headers: { "Content-Type": "application/xhtml+xml; charset=utf-8" }
|
|
6076
6076
|
});
|
|
6077
|
-
await t.
|
|
6077
|
+
await t.step("XHTML <link>", async () => {
|
|
6078
6078
|
deepStrictEqual(await fetchDocumentLoader("https://example.com/xhtml-link"), {
|
|
6079
6079
|
contextUrl: null,
|
|
6080
6080
|
documentUrl: "https://example.com/object",
|
|
@@ -6100,7 +6100,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6100
6100
|
</html>`,
|
|
6101
6101
|
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
6102
6102
|
});
|
|
6103
|
-
await t.
|
|
6103
|
+
await t.step("HTML <a>", async () => {
|
|
6104
6104
|
deepStrictEqual(await fetchDocumentLoader("https://example.com/html-a"), {
|
|
6105
6105
|
contextUrl: null,
|
|
6106
6106
|
documentUrl: "https://example.com/object",
|
|
@@ -6121,7 +6121,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6121
6121
|
},
|
|
6122
6122
|
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
6123
6123
|
});
|
|
6124
|
-
await t.
|
|
6124
|
+
await t.step("Wrong Content-Type", async () => {
|
|
6125
6125
|
deepStrictEqual(await fetchDocumentLoader("https://example.com/wrong-content-type"), {
|
|
6126
6126
|
contextUrl: null,
|
|
6127
6127
|
documentUrl: "https://example.com/wrong-content-type",
|
|
@@ -6134,18 +6134,33 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6134
6134
|
});
|
|
6135
6135
|
});
|
|
6136
6136
|
esm_default.get("https://example.com/404", { status: 404 });
|
|
6137
|
-
await t.
|
|
6137
|
+
await t.step("not ok", async () => {
|
|
6138
6138
|
await rejects(() => fetchDocumentLoader("https://example.com/404"), FetchError, "HTTP 404: https://example.com/404");
|
|
6139
6139
|
});
|
|
6140
|
-
await t.
|
|
6140
|
+
await t.step("preloaded contexts", async () => {
|
|
6141
6141
|
for (const [url, document] of Object.entries(preloadedContexts)) deepStrictEqual(await fetchDocumentLoader(url), {
|
|
6142
6142
|
contextUrl: null,
|
|
6143
6143
|
documentUrl: url,
|
|
6144
6144
|
document
|
|
6145
6145
|
});
|
|
6146
6146
|
});
|
|
6147
|
+
await t.step("preloaded Mastodon attribution domains", async () => {
|
|
6148
|
+
const context = ["https://www.w3.org/ns/activitystreams", "http://joinmastodon.org/ns"];
|
|
6149
|
+
const expanded = await jsonld_default.expand({
|
|
6150
|
+
"@context": context,
|
|
6151
|
+
id: "https://social.example/users/alice",
|
|
6152
|
+
type: "Person",
|
|
6153
|
+
attributionDomains: ["blog.example"]
|
|
6154
|
+
}, { documentLoader: fetchDocumentLoader });
|
|
6155
|
+
deepStrictEqual(expanded, [{
|
|
6156
|
+
"@id": "https://social.example/users/alice",
|
|
6157
|
+
"@type": ["https://www.w3.org/ns/activitystreams#Person"],
|
|
6158
|
+
"http://joinmastodon.org/ns#attributionDomains": [{ "@value": "blog.example" }]
|
|
6159
|
+
}]);
|
|
6160
|
+
deepStrictEqual((await jsonld_default.compact(expanded, context, { documentLoader: fetchDocumentLoader })).attributionDomains, ["blog.example"]);
|
|
6161
|
+
});
|
|
6147
6162
|
esm_default.get("https://www.w3.org/ns/cid/v1", { status: 503 });
|
|
6148
|
-
await t.
|
|
6163
|
+
await t.step("preloaded CID v1 context", async () => {
|
|
6149
6164
|
const url = "https://www.w3.org/ns/cid/v1";
|
|
6150
6165
|
deepStrictEqual(await fetchDocumentLoader(url), {
|
|
6151
6166
|
contextUrl: null,
|
|
@@ -6153,7 +6168,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6153
6168
|
document: cid_v1_default
|
|
6154
6169
|
});
|
|
6155
6170
|
});
|
|
6156
|
-
await t.
|
|
6171
|
+
await t.step("preloaded FEP-ef61 context", async () => {
|
|
6157
6172
|
const url = "https://w3id.org/fep/ef61";
|
|
6158
6173
|
ok(url in preloadedContexts);
|
|
6159
6174
|
deepStrictEqual(await fetchDocumentLoader(url), {
|
|
@@ -6170,7 +6185,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6170
6185
|
});
|
|
6171
6186
|
});
|
|
6172
6187
|
esm_default.get("https://w3id.org/fep/7aa9", { status: 502 });
|
|
6173
|
-
await t.
|
|
6188
|
+
await t.step("preloaded FEP-7aa9 context", async () => {
|
|
6174
6189
|
const url = "https://w3id.org/fep/7aa9";
|
|
6175
6190
|
deepStrictEqual(await fetchDocumentLoader(url), {
|
|
6176
6191
|
contextUrl: null,
|
|
@@ -6201,7 +6216,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6201
6216
|
deepStrictEqual(esm_default.callHistory.calls(url).length, 0);
|
|
6202
6217
|
});
|
|
6203
6218
|
esm_default.get("https://w3id.org/fep/6757", { status: 502 });
|
|
6204
|
-
await t.
|
|
6219
|
+
await t.step("preloaded FEP-6757 context", async () => {
|
|
6205
6220
|
const url = "https://w3id.org/fep/6757";
|
|
6206
6221
|
deepStrictEqual(await fetchDocumentLoader(url), {
|
|
6207
6222
|
contextUrl: null,
|
|
@@ -6230,7 +6245,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6230
6245
|
deepStrictEqual(esm_default.callHistory.calls(url).length, 0);
|
|
6231
6246
|
});
|
|
6232
6247
|
esm_default.get("https://w3id.org/fep/22cd", { status: 502 });
|
|
6233
|
-
await t.
|
|
6248
|
+
await t.step("preloaded FEP-22cd context", async () => {
|
|
6234
6249
|
const url = "https://w3id.org/fep/22cd";
|
|
6235
6250
|
const articleId = "https://example.com/articles/1";
|
|
6236
6251
|
const translatorId = "https://example.com/users/alice";
|
|
@@ -6308,7 +6323,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6308
6323
|
deepStrictEqual(esm_default.callHistory.calls(url).length, 0);
|
|
6309
6324
|
deepStrictEqual(esm_default.callHistory.calls("https://www.w3.org/ns/activitystreams").length, 0);
|
|
6310
6325
|
});
|
|
6311
|
-
await t.
|
|
6326
|
+
await t.step("deny non-HTTP/HTTPS", async () => {
|
|
6312
6327
|
await rejects(() => fetchDocumentLoader("ftp://localhost"), UrlError);
|
|
6313
6328
|
});
|
|
6314
6329
|
esm_default.get("https://example.com/localhost-redirect", {
|
|
@@ -6333,13 +6348,13 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6333
6348
|
name: "Fetched object",
|
|
6334
6349
|
type: "Object"
|
|
6335
6350
|
} });
|
|
6336
|
-
await t.
|
|
6351
|
+
await t.step("allowPrivateAddress: false", async () => {
|
|
6337
6352
|
await rejects(() => fetchDocumentLoader("https://localhost/object"), UrlError);
|
|
6338
6353
|
await rejects(() => fetchDocumentLoader("https://example.com/localhost-redirect"), UrlError);
|
|
6339
6354
|
await rejects(() => fetchDocumentLoader("https://example.com/localhost-link"), UrlError);
|
|
6340
6355
|
});
|
|
6341
6356
|
const fetchDocumentLoader2 = getDocumentLoader({ allowPrivateAddress: true });
|
|
6342
|
-
await t.
|
|
6357
|
+
await t.step("allowPrivateAddress: true", async () => {
|
|
6343
6358
|
const expected = {
|
|
6344
6359
|
contextUrl: null,
|
|
6345
6360
|
documentUrl: "https://localhost/object",
|
|
@@ -6362,7 +6377,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6362
6377
|
headers: { Location: `https://example.com/too-many-redirects/${Number(cl.url.split("/").at(-1)) + 1}` }
|
|
6363
6378
|
};
|
|
6364
6379
|
});
|
|
6365
|
-
await t.
|
|
6380
|
+
await t.step("too many redirects", async () => {
|
|
6366
6381
|
redirectAttempts = 0;
|
|
6367
6382
|
await rejects(() => fetchDocumentLoader("https://example.com/too-many-redirects/0"), FetchError, "Too many redirections");
|
|
6368
6383
|
deepStrictEqual(redirectAttempts, 21);
|
|
@@ -6382,7 +6397,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6382
6397
|
headers: { Location: "https://example.com/redirect-loop-a" }
|
|
6383
6398
|
};
|
|
6384
6399
|
});
|
|
6385
|
-
await t.
|
|
6400
|
+
await t.step("redirect loop", async () => {
|
|
6386
6401
|
loopAttempts = 0;
|
|
6387
6402
|
await rejects(() => fetchDocumentLoader("https://example.com/redirect-loop-a"), FetchError, "Redirect loop detected");
|
|
6388
6403
|
deepStrictEqual(loopAttempts, 2);
|
|
@@ -6395,7 +6410,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6395
6410
|
headers: { Location: "/redirect-loop-relative" }
|
|
6396
6411
|
};
|
|
6397
6412
|
});
|
|
6398
|
-
await t.
|
|
6413
|
+
await t.step("redirect loop with relative location", async () => {
|
|
6399
6414
|
relativeLoopAttempts = 0;
|
|
6400
6415
|
await rejects(() => fetchDocumentLoader("https://example.com/redirect-loop-relative"), FetchError, "Redirect loop detected");
|
|
6401
6416
|
deepStrictEqual(relativeLoopAttempts, 1);
|
|
@@ -6405,7 +6420,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6405
6420
|
body: maliciousPayload,
|
|
6406
6421
|
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
6407
6422
|
});
|
|
6408
|
-
await t.
|
|
6423
|
+
await t.step("ReDoS resistance (CVE-2025-68475)", async () => {
|
|
6409
6424
|
const start = performance.now();
|
|
6410
6425
|
await rejects(() => fetchDocumentLoader("https://example.com/redos"), SyntaxError);
|
|
6411
6426
|
const elapsed = performance.now() - start;
|
|
@@ -6491,16 +6506,13 @@ test("getRemoteDocument() bounds JSON by default", async () => {
|
|
|
6491
6506
|
deepStrictEqual(pulls, 257);
|
|
6492
6507
|
});
|
|
6493
6508
|
test("getDocumentLoader() logs DNS failures as such", async (t) => {
|
|
6494
|
-
if ("Deno" in globalThis && (await Deno.permissions.query({ name: "net" })).state !== "granted")
|
|
6495
|
-
t.skip("requires the net permission");
|
|
6496
|
-
return;
|
|
6497
|
-
}
|
|
6509
|
+
if ("Deno" in globalThis && (await Deno.permissions.query({ name: "net" })).state !== "granted") throw new Error("This DNS test requires Deno network permission (--allow-net).");
|
|
6498
6510
|
const loader = getDocumentLoader();
|
|
6499
6511
|
for (const result of [
|
|
6500
6512
|
"throws",
|
|
6501
6513
|
"empty",
|
|
6502
6514
|
"private"
|
|
6503
|
-
]) await t.
|
|
6515
|
+
]) await t.step(result, async () => {
|
|
6504
6516
|
const originalLookup = dns.lookup;
|
|
6505
6517
|
dns.lookup = (() => result === "throws" ? Promise.reject(/* @__PURE__ */ new Error("Resolver unavailable")) : Promise.resolve(result === "empty" ? [] : [{
|
|
6506
6518
|
address: "127.0.0.1",
|
|
@@ -6555,7 +6567,7 @@ test("getDocumentLoader() bounds alternate document chains", async (t) => {
|
|
|
6555
6567
|
"header",
|
|
6556
6568
|
"html",
|
|
6557
6569
|
"mixed"
|
|
6558
|
-
]) for (const hops of [20, 21]) await t.
|
|
6570
|
+
]) for (const hops of [20, 21]) await t.step(`${mode}: ${hops} hops`, async () => {
|
|
6559
6571
|
esm_default.mockGlobal();
|
|
6560
6572
|
let requests = 0;
|
|
6561
6573
|
esm_default.get(`begin:${base}`, ({ url }) => {
|
|
@@ -6584,7 +6596,7 @@ test("getDocumentLoader() bounds alternate document chains", async (t) => {
|
|
|
6584
6596
|
"alternate-redirect",
|
|
6585
6597
|
"redirect-alternate",
|
|
6586
6598
|
"redirect-intermediate"
|
|
6587
|
-
]) await t.
|
|
6599
|
+
]) await t.step(`${mode}: cycle`, async () => {
|
|
6588
6600
|
esm_default.mockGlobal();
|
|
6589
6601
|
let requests = 0;
|
|
6590
6602
|
esm_default.get(`begin:${base}`, ({ url }) => {
|
|
@@ -6606,7 +6618,7 @@ test("getDocumentLoader() bounds alternate document chains", async (t) => {
|
|
|
6606
6618
|
esm_default.hardReset();
|
|
6607
6619
|
}
|
|
6608
6620
|
});
|
|
6609
|
-
await t.
|
|
6621
|
+
await t.step("alternate followed by 20 redirects shares the limit", async () => {
|
|
6610
6622
|
esm_default.mockGlobal();
|
|
6611
6623
|
let requests = 0;
|
|
6612
6624
|
esm_default.get(`begin:${base}`, ({ url }) => {
|
|
@@ -6626,7 +6638,7 @@ test("getDocumentLoader() bounds alternate document chains", async (t) => {
|
|
|
6626
6638
|
esm_default.hardReset();
|
|
6627
6639
|
}
|
|
6628
6640
|
});
|
|
6629
|
-
await t.
|
|
6641
|
+
await t.step("relative alternate after redirect and isolated calls", async () => {
|
|
6630
6642
|
esm_default.mockGlobal();
|
|
6631
6643
|
esm_default.get(`${base}start`, Response.redirect(`${base}html`, 302));
|
|
6632
6644
|
esm_default.get(`${base}html`, alternate("./document", true));
|
|
@@ -6653,7 +6665,7 @@ test("getDocumentLoader() bounds alternate document chains", async (t) => {
|
|
|
6653
6665
|
test("getDocumentLoader() preserves cancellation across alternates", async (t) => {
|
|
6654
6666
|
const base = "https://example.com/alternate-abort/";
|
|
6655
6667
|
const loader = getDocumentLoader({ allowPrivateAddress: true });
|
|
6656
|
-
for (const html of [false, true]) await t.
|
|
6668
|
+
for (const html of [false, true]) await t.step(html ? "HTML" : "Link header", async () => {
|
|
6657
6669
|
esm_default.mockGlobal();
|
|
6658
6670
|
const controller = new AbortController();
|
|
6659
6671
|
let requests = 0;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
require("../chunk-Do9eywBl.cjs");
|
|
2
2
|
const require_multibase = require("../multibase-CnmModw0.cjs");
|
|
3
|
-
let node_test = require("node:test");
|
|
4
3
|
let node_assert = require("node:assert");
|
|
4
|
+
let _fedify_fixture = require("@fedify/fixture");
|
|
5
5
|
//#region src/multibase/multibase.test.ts
|
|
6
|
-
(0,
|
|
6
|
+
(0, _fedify_fixture.test)("multibase.encode and decode", async (t) => {
|
|
7
7
|
const testCases = [
|
|
8
8
|
[
|
|
9
9
|
"base16",
|
|
@@ -316,22 +316,22 @@ let node_assert = require("node:assert");
|
|
|
316
316
|
"Uw7fDr8O_8J-lsMO3w6_Dv_CfmI7wn6W28J-krw=="
|
|
317
317
|
]
|
|
318
318
|
];
|
|
319
|
-
for (const [name, input, expectedOutput] of testCases) await t.
|
|
319
|
+
for (const [name, input, expectedOutput] of testCases) await t.step(`Encoding/Decoding ${name} with ${input}`, () => {
|
|
320
320
|
(0, node_assert.deepStrictEqual)(require_multibase.decodeText(require_multibase.encodeMultibase(name, require_multibase.encodeText(input))), expectedOutput, `Encoding ${name} failed`);
|
|
321
321
|
(0, node_assert.deepStrictEqual)(require_multibase.decodeMultibase(expectedOutput), require_multibase.encodeText(input), `Decoding ${name} failed`);
|
|
322
322
|
(0, node_assert.deepStrictEqual)(require_multibase.decodeMultibase(require_multibase.encodeText(expectedOutput)), require_multibase.encodeText(input), `Decoding buffer of ${name} failed`);
|
|
323
323
|
});
|
|
324
|
-
await t.
|
|
324
|
+
await t.step("should allow base32pad full alphabet", () => {
|
|
325
325
|
const decoded = require_multibase.decodeMultibase("ctimaq4ygg2iegci7");
|
|
326
326
|
(0, node_assert.deepStrictEqual)(require_multibase.decodeMultibase(require_multibase.encodeMultibase("c", decoded)), decoded);
|
|
327
327
|
});
|
|
328
328
|
});
|
|
329
|
-
(0,
|
|
330
|
-
await t.
|
|
329
|
+
(0, _fedify_fixture.test)("constants", async (t) => {
|
|
330
|
+
await t.step("constants indexed by name", () => {
|
|
331
331
|
const names$1 = require_multibase.names;
|
|
332
332
|
(0, node_assert.deepStrictEqual)(Object.keys(names$1).length, 23);
|
|
333
333
|
});
|
|
334
|
-
await t.
|
|
334
|
+
await t.step("constants indexed by code", () => {
|
|
335
335
|
const codes$1 = require_multibase.codes;
|
|
336
336
|
(0, node_assert.deepStrictEqual)(Object.keys(codes$1).length, 23);
|
|
337
337
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as decodeText, i as names, n as encodeMultibase, o as encodeText, r as codes, t as decodeMultibase } from "../multibase-DLBufb99.mjs";
|
|
2
|
-
import { test } from "node:test";
|
|
3
2
|
import { deepStrictEqual } from "node:assert";
|
|
3
|
+
import { test } from "@fedify/fixture";
|
|
4
4
|
//#region src/multibase/multibase.test.ts
|
|
5
5
|
test("multibase.encode and decode", async (t) => {
|
|
6
6
|
const testCases = [
|
|
@@ -315,21 +315,21 @@ test("multibase.encode and decode", async (t) => {
|
|
|
315
315
|
"Uw7fDr8O_8J-lsMO3w6_Dv_CfmI7wn6W28J-krw=="
|
|
316
316
|
]
|
|
317
317
|
];
|
|
318
|
-
for (const [name, input, expectedOutput] of testCases) await t.
|
|
318
|
+
for (const [name, input, expectedOutput] of testCases) await t.step(`Encoding/Decoding ${name} with ${input}`, () => {
|
|
319
319
|
deepStrictEqual(decodeText(encodeMultibase(name, encodeText(input))), expectedOutput, `Encoding ${name} failed`);
|
|
320
320
|
deepStrictEqual(decodeMultibase(expectedOutput), encodeText(input), `Decoding ${name} failed`);
|
|
321
321
|
deepStrictEqual(decodeMultibase(encodeText(expectedOutput)), encodeText(input), `Decoding buffer of ${name} failed`);
|
|
322
322
|
});
|
|
323
|
-
await t.
|
|
323
|
+
await t.step("should allow base32pad full alphabet", () => {
|
|
324
324
|
const decoded = decodeMultibase("ctimaq4ygg2iegci7");
|
|
325
325
|
deepStrictEqual(decodeMultibase(encodeMultibase("c", decoded)), decoded);
|
|
326
326
|
});
|
|
327
327
|
});
|
|
328
328
|
test("constants", async (t) => {
|
|
329
|
-
await t.
|
|
329
|
+
await t.step("constants indexed by name", () => {
|
|
330
330
|
deepStrictEqual(Object.keys(names).length, 23);
|
|
331
331
|
});
|
|
332
|
-
await t.
|
|
332
|
+
await t.step("constants indexed by code", () => {
|
|
333
333
|
deepStrictEqual(Object.keys(codes).length, 23);
|
|
334
334
|
});
|
|
335
335
|
});
|
|
@@ -3,7 +3,7 @@ let node_process = require("node:process");
|
|
|
3
3
|
node_process = require_chunk.__toESM(node_process);
|
|
4
4
|
//#region deno.json
|
|
5
5
|
var name = "@fedify/vocab-runtime";
|
|
6
|
-
var version = "2.0.31-dev.
|
|
6
|
+
var version = "2.0.31-dev.2316+06462f7c";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/request.ts
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-BdKDFsbY.cjs");
|
|
3
3
|
let node_test = require("node:test");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as version, r as getUserAgent } from "./request-
|
|
1
|
+
import { o as version, r as getUserAgent } from "./request-BD0HpfwZ.mjs";
|
|
2
2
|
import { test } from "node:test";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { deepStrictEqual } from "node:assert";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/vocab-runtime",
|
|
3
|
-
"version": "2.0.31-dev.
|
|
3
|
+
"version": "2.0.31-dev.2316+06462f7c",
|
|
4
4
|
"homepage": "https://fedify.dev/",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -72,7 +72,8 @@
|
|
|
72
72
|
"@types/node": "^24.2.1",
|
|
73
73
|
"fetch-mock": "^12.5.4",
|
|
74
74
|
"tsdown": "^0.21.6",
|
|
75
|
-
"typescript": "^6.0.0"
|
|
75
|
+
"typescript": "^6.0.0",
|
|
76
|
+
"@fedify/fixture": "2.0.0"
|
|
76
77
|
},
|
|
77
78
|
"dependencies": {
|
|
78
79
|
"@js-temporal/polyfill": "^0.5.1",
|
|
@@ -89,6 +90,8 @@
|
|
|
89
90
|
"build": "pnpm --filter @fedify/vocab-runtime... run build:self",
|
|
90
91
|
"prepublish": "pnpm build",
|
|
91
92
|
"pretest": "pnpm build",
|
|
92
|
-
"test": "cd dist/tests && node --test"
|
|
93
|
+
"test": "cd dist/tests && node --test",
|
|
94
|
+
"pretest:bun": "pnpm build",
|
|
95
|
+
"test:bun": "node scripts/test-bun.mjs"
|
|
93
96
|
}
|
|
94
97
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { access, glob } from "node:fs/promises";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
|
|
5
|
+
const sources = await Array.fromAsync(glob("src/**/*.test.ts"));
|
|
6
|
+
if (sources.length === 0) throw new Error("No vocab-runtime tests found.");
|
|
7
|
+
|
|
8
|
+
const tests = sources.map((source) =>
|
|
9
|
+
source.replaceAll("\\", "/").replace(/^src\//, "dist/tests/")
|
|
10
|
+
.replace(/\.ts$/, ".mjs")
|
|
11
|
+
).sort();
|
|
12
|
+
for (const test of tests) await access(test);
|
|
13
|
+
|
|
14
|
+
const result = spawnSync("bun", ["test", "--timeout", "60000", ...tests], {
|
|
15
|
+
stdio: "inherit",
|
|
16
|
+
});
|
|
17
|
+
if (result.error) throw result.error;
|
|
18
|
+
process.exitCode = result.status ?? 1;
|
package/src/contexts.ts
CHANGED