@fedify/vocab-runtime 2.4.0-dev.1618 → 2.4.0-dev.1655
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/{docloader-DnUMWHaJ.d.cts → docloader-C_dir7Xb.d.ts} +2 -0
- package/dist/{docloader-xRGn1azD.d.ts → docloader-D2DTRiyA.d.cts} +2 -0
- package/dist/internal/jsonld-cache.cjs +1 -1
- package/dist/internal/jsonld-cache.d.cts +1 -1
- package/dist/internal/jsonld-cache.d.ts +1 -1
- package/dist/internal/jsonld-cache.js +1 -1
- package/dist/mod.cjs +159 -8
- package/dist/mod.d.cts +91 -2
- package/dist/mod.d.ts +91 -2
- package/dist/mod.js +152 -9
- package/dist/tests/decimal.test.cjs +6 -5
- package/dist/tests/decimal.test.mjs +6 -5
- package/dist/tests/digest-BJlumPNJ.mjs +140 -0
- package/dist/tests/digest-DLwUyHCK.cjs +175 -0
- package/dist/tests/digest.test.cjs +103 -0
- package/dist/tests/digest.test.d.cts +1 -0
- package/dist/tests/digest.test.d.mts +1 -0
- package/dist/tests/digest.test.mjs +103 -0
- package/dist/tests/{docloader-QmR6VOqT.cjs → docloader-DVVWmXLI.cjs} +12 -6
- package/dist/tests/{docloader-CBVde8Va.mjs → docloader-HbEvzi-t.mjs} +12 -6
- package/dist/tests/docloader.test.cjs +3 -3
- package/dist/tests/docloader.test.mjs +3 -3
- package/dist/tests/jsonld-cache.test.cjs +1 -1
- package/dist/tests/jsonld-cache.test.mjs +1 -1
- package/dist/tests/{key-_wXwomh_.cjs → key-BcOWDLMm.cjs} +1 -1
- package/dist/tests/{key-CDGDH_vC.mjs → key-Drbw_2tw.mjs} +1 -1
- package/dist/tests/key.test.cjs +2 -2
- package/dist/tests/key.test.mjs +2 -2
- package/dist/tests/langstr.test.cjs +1 -1
- package/dist/tests/langstr.test.mjs +1 -1
- package/dist/tests/multibase/multibase.test.cjs +1 -1
- package/dist/tests/multibase/multibase.test.mjs +1 -1
- package/dist/tests/{multibase-B4bvakyA.mjs → multibase-Cluwl8OM.mjs} +12 -1
- package/dist/tests/{multibase-Bz_UUDtL.cjs → multibase-DcDQDNnI.cjs} +17 -0
- package/dist/tests/{request-BHx0fCb5.mjs → request-B6s_F7bi.mjs} +1 -1
- package/dist/tests/{request-DxSceLvB.cjs → request-DvEyU5Zf.cjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/dist/tests/{url-BvjYQdxL.cjs → url-CsOV_B_P.cjs} +26 -0
- package/dist/tests/{url-a2D8NAgh.mjs → url-Du7RQQgP.mjs} +15 -1
- package/dist/tests/url.test.cjs +18 -1
- package/dist/tests/url.test.mjs +18 -1
- package/dist/{url-Ck3dGEwH.cjs → url-DD4F0ULf.cjs} +26 -0
- package/dist/{url-m1YxGNZ0.js → url-DGVbSVVi.js} +15 -1
- package/package.json +1 -1
- package/src/contexts/fep-ef61.json +10 -0
- package/src/contexts/security-data-integrity-v1.json +0 -4
- package/src/contexts.ts +2 -0
- package/src/digest.test.ts +220 -0
- package/src/digest.ts +229 -0
- package/src/docloader.ts +2 -0
- package/src/mod.ts +12 -0
- package/src/url.test.ts +23 -0
- package/src/url.ts +23 -0
- /package/dist/tests/{langstr-CbAxaeEZ.cjs → langstr-BOQHfJDr.cjs} +0 -0
- /package/dist/tests/{langstr-Di5AvKpB.mjs → langstr-DDLc4833.mjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { t as addMulticodecPrefix } from "./multicodec-CyFp54fI.mjs";
|
|
2
|
+
import { n as encodeMultibase } from "./multibase-Cluwl8OM.mjs";
|
|
3
|
+
import { a as verifyDigestMultibase, i as parseHashlink, n as createHashlink, o as verifyHashlink, r as parseDigestMultibase, t as computeDigestMultibase } from "./digest-BJlumPNJ.mjs";
|
|
4
|
+
import { test } from "node:test";
|
|
5
|
+
import { deepStrictEqual, equal, rejects, throws } from "node:assert/strict";
|
|
6
|
+
//#region src/digest.test.ts
|
|
7
|
+
const encoder = new TextEncoder();
|
|
8
|
+
const decoder = new TextDecoder();
|
|
9
|
+
const bytes = encoder.encode("Hello World!");
|
|
10
|
+
const digestMultibase = "zQmWvQxTqbG2Z9HPJgG57jjwR154cKhbtJenbyYTWkjgF3e";
|
|
11
|
+
const hashlink = `hl:${digestMultibase}`;
|
|
12
|
+
test("computeDigestMultibase() computes a SHA-256 multihash", async () => {
|
|
13
|
+
equal(await computeDigestMultibase(bytes), digestMultibase);
|
|
14
|
+
const parsed = parseDigestMultibase(digestMultibase);
|
|
15
|
+
equal(parsed.algorithm, "sha2-256");
|
|
16
|
+
deepStrictEqual(parsed.digest, new Uint8Array(await crypto.subtle.digest("SHA-256", bytes)));
|
|
17
|
+
});
|
|
18
|
+
test("digest helpers accept SharedArrayBuffer-backed bytes", async () => {
|
|
19
|
+
const sharedBytes = new Uint8Array(new SharedArrayBuffer(bytes.length));
|
|
20
|
+
sharedBytes.set(bytes);
|
|
21
|
+
Object.defineProperty(sharedBytes, "slice", { value: () => {
|
|
22
|
+
throw new Error("Shared input must not be copied with slice().");
|
|
23
|
+
} });
|
|
24
|
+
equal(await computeDigestMultibase(sharedBytes), digestMultibase);
|
|
25
|
+
equal(await verifyDigestMultibase(sharedBytes, digestMultibase), true);
|
|
26
|
+
});
|
|
27
|
+
test("digest helpers ignore spoofed shared buffer tags", async () => {
|
|
28
|
+
const taggedBytes = bytes.slice();
|
|
29
|
+
Object.defineProperty(taggedBytes.buffer, Symbol.toStringTag, { value: "SharedArrayBuffer" });
|
|
30
|
+
Object.defineProperty(taggedBytes, "slice", { value: () => {
|
|
31
|
+
throw new Error("ArrayBuffer input must not be copied.");
|
|
32
|
+
} });
|
|
33
|
+
equal(await computeDigestMultibase(taggedBytes), digestMultibase);
|
|
34
|
+
equal(await verifyDigestMultibase(taggedBytes, digestMultibase), true);
|
|
35
|
+
});
|
|
36
|
+
test("createHashlink() and parseHashlink() round-trip simple hashlinks", () => {
|
|
37
|
+
equal(createHashlink(digestMultibase), hashlink);
|
|
38
|
+
deepStrictEqual(parseHashlink(hashlink), { digestMultibase });
|
|
39
|
+
deepStrictEqual(parseHashlink(new URL(hashlink)), { digestMultibase });
|
|
40
|
+
const base64DigestMultibase = decoder.decode(encodeMultibase("base64", addMulticodecPrefix(18, addMulticodecPrefix(32, new Uint8Array(32).fill(255)))));
|
|
41
|
+
const base64Hashlink = createHashlink(base64DigestMultibase);
|
|
42
|
+
equal(base64Hashlink, "hl:mEiD//////////////////////////////////////////w");
|
|
43
|
+
deepStrictEqual(parseHashlink(base64Hashlink), { digestMultibase: base64DigestMultibase });
|
|
44
|
+
deepStrictEqual(parseHashlink(new URL(base64Hashlink)), { digestMultibase: base64DigestMultibase });
|
|
45
|
+
});
|
|
46
|
+
test("digest and hashlink verification accepts matching bytes", async () => {
|
|
47
|
+
equal(await verifyDigestMultibase(bytes, digestMultibase), true);
|
|
48
|
+
equal(await verifyHashlink(bytes, hashlink), true);
|
|
49
|
+
equal(await verifyHashlink(bytes, new URL(hashlink)), true);
|
|
50
|
+
});
|
|
51
|
+
test("digest and hashlink verification rejects non-matching bytes", async () => {
|
|
52
|
+
const different = encoder.encode("Hello World?");
|
|
53
|
+
equal(await verifyDigestMultibase(different, digestMultibase), false);
|
|
54
|
+
equal(await verifyHashlink(different, hashlink), false);
|
|
55
|
+
});
|
|
56
|
+
test("parseDigestMultibase() rejects unsupported algorithms", () => {
|
|
57
|
+
const sha1Multihash = addMulticodecPrefix(17, addMulticodecPrefix(20, new Uint8Array(20)));
|
|
58
|
+
const value = decoder.decode(encodeMultibase("base58btc", sha1Multihash));
|
|
59
|
+
throws(() => parseDigestMultibase(value), /* @__PURE__ */ new TypeError("Unsupported digest algorithm: 0x11"));
|
|
60
|
+
});
|
|
61
|
+
test("parseDigestMultibase() rejects malformed values", async () => {
|
|
62
|
+
throws(() => parseDigestMultibase("not-multibase"), /* @__PURE__ */ new TypeError("Invalid digestMultibase encoding."));
|
|
63
|
+
const missingLength = decoder.decode(encodeMultibase("base58btc", Uint8Array.of(18)));
|
|
64
|
+
throws(() => parseDigestMultibase(missingLength), /* @__PURE__ */ new TypeError("Invalid digestMultibase multihash."));
|
|
65
|
+
const multihash = addMulticodecPrefix(18, addMulticodecPrefix(32, new Uint8Array(32)));
|
|
66
|
+
const base2 = decoder.decode(encodeMultibase("base2", multihash));
|
|
67
|
+
equal(base2.length, 273);
|
|
68
|
+
deepStrictEqual(parseDigestMultibase(base2).digest, new Uint8Array(32));
|
|
69
|
+
throws(() => parseDigestMultibase(`${base2}0`), /* @__PURE__ */ new TypeError("Invalid digestMultibase encoding."));
|
|
70
|
+
const padded = decoder.decode(encodeMultibase("base64pad", multihash));
|
|
71
|
+
equal(padded.endsWith("=="), true);
|
|
72
|
+
deepStrictEqual(parseDigestMultibase(padded).digest, new Uint8Array(32));
|
|
73
|
+
throws(() => parseDigestMultibase(padded.slice(0, -1)), /* @__PURE__ */ new TypeError("Invalid digestMultibase encoding."));
|
|
74
|
+
throws(() => createHashlink(`${padded}=`), /* @__PURE__ */ new TypeError("Invalid digestMultibase encoding."));
|
|
75
|
+
const overlongAlgorithm = decoder.decode(encodeMultibase("base58btc", Uint8Array.of(146, 0, 32, ...new Uint8Array(32))));
|
|
76
|
+
throws(() => parseDigestMultibase(overlongAlgorithm), /* @__PURE__ */ new TypeError("Invalid digestMultibase multihash."));
|
|
77
|
+
const overlongLength = decoder.decode(encodeMultibase("base58btc", Uint8Array.of(18, 160, 0, ...new Uint8Array(32))));
|
|
78
|
+
throws(() => parseDigestMultibase(overlongLength), /* @__PURE__ */ new TypeError("Invalid digestMultibase multihash."));
|
|
79
|
+
const shortDigest = decoder.decode(encodeMultibase("base58btc", addMulticodecPrefix(18, addMulticodecPrefix(31, new Uint8Array(31)))));
|
|
80
|
+
throws(() => parseDigestMultibase(shortDigest), /* @__PURE__ */ new TypeError("Invalid SHA-256 digest length."));
|
|
81
|
+
await rejects(() => verifyDigestMultibase(bytes, shortDigest), /* @__PURE__ */ new TypeError("Invalid SHA-256 digest length."));
|
|
82
|
+
});
|
|
83
|
+
test("simple hashlink helpers reject metadata and malformed forms", async () => {
|
|
84
|
+
for (const terminator of [
|
|
85
|
+
"\n",
|
|
86
|
+
"\r",
|
|
87
|
+
"\r\n",
|
|
88
|
+
"\u2028",
|
|
89
|
+
"\u2029"
|
|
90
|
+
]) {
|
|
91
|
+
const malformedHashlink = `${hashlink}${terminator}`;
|
|
92
|
+
throws(() => parseHashlink(malformedHashlink), /* @__PURE__ */ new TypeError("Invalid simple hashlink."));
|
|
93
|
+
await rejects(() => verifyHashlink(bytes, malformedHashlink), /* @__PURE__ */ new TypeError("Invalid simple hashlink."));
|
|
94
|
+
}
|
|
95
|
+
throws(() => parseHashlink(`${hashlink}:zmetadata`), /* @__PURE__ */ new TypeError("Invalid simple hashlink."));
|
|
96
|
+
await rejects(() => verifyHashlink(bytes, `${hashlink}:zmetadata`), /* @__PURE__ */ new TypeError("Invalid simple hashlink."));
|
|
97
|
+
throws(() => parseHashlink(`https://example.com/file?hl=${digestMultibase}`), /* @__PURE__ */ new TypeError("Invalid simple hashlink."));
|
|
98
|
+
throws(() => parseHashlink("hl:not-multibase"), /* @__PURE__ */ new TypeError("Invalid digestMultibase encoding."));
|
|
99
|
+
await rejects(() => verifyHashlink(bytes, "hl:not-multibase"), /* @__PURE__ */ new TypeError("Invalid digestMultibase encoding."));
|
|
100
|
+
throws(() => createHashlink("not-multibase"), /* @__PURE__ */ new TypeError("Invalid digestMultibase encoding."));
|
|
101
|
+
});
|
|
102
|
+
//#endregion
|
|
103
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require("./chunk-C2EiDwsr.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-DvEyU5Zf.cjs");
|
|
3
3
|
const require_link = require("./link-FguCydMA.cjs");
|
|
4
|
-
const require_url = require("./url-
|
|
4
|
+
const require_url = require("./url-CsOV_B_P.cjs");
|
|
5
5
|
let _logtape_logtape = require("@logtape/logtape");
|
|
6
6
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
7
7
|
//#endregion
|
|
@@ -460,10 +460,6 @@ const preloadedContexts = {
|
|
|
460
460
|
"id": "@id",
|
|
461
461
|
"type": "@type",
|
|
462
462
|
"@protected": true,
|
|
463
|
-
"digestMultibase": {
|
|
464
|
-
"@id": "https://w3id.org/security#digestMultibase",
|
|
465
|
-
"@type": "https://w3id.org/security#multibase"
|
|
466
|
-
},
|
|
467
463
|
"proof": {
|
|
468
464
|
"@id": "https://w3id.org/security#proof",
|
|
469
465
|
"@type": "@id",
|
|
@@ -4300,6 +4296,14 @@ const preloadedContexts = {
|
|
|
4300
4296
|
"@type": "@id"
|
|
4301
4297
|
}
|
|
4302
4298
|
} },
|
|
4299
|
+
"https://w3id.org/fep/ef61": { "@context": {
|
|
4300
|
+
"gateways": {
|
|
4301
|
+
"@id": "https://w3id.org/fep/ef61/gateways",
|
|
4302
|
+
"@type": "@id",
|
|
4303
|
+
"@container": "@list"
|
|
4304
|
+
},
|
|
4305
|
+
"digestMultibase": "https://www.w3.org/ns/credentials/v2#digestMultibase"
|
|
4306
|
+
} },
|
|
4303
4307
|
"https://join-lemmy.org/context.json": { "@context": ["https://w3id.org/security/v1", {
|
|
4304
4308
|
"as": "https://www.w3.org/ns/activitystreams#",
|
|
4305
4309
|
"lemmy": "https://join-lemmy.org/ns#",
|
|
@@ -4534,8 +4538,10 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
4534
4538
|
* - <https://www.w3.org/ns/activitystreams>
|
|
4535
4539
|
* - <https://w3id.org/security/v1>
|
|
4536
4540
|
* - <https://w3id.org/security/data-integrity/v1>
|
|
4541
|
+
* - <https://w3id.org/security/data-integrity/v2>
|
|
4537
4542
|
* - <https://www.w3.org/ns/did/v1>
|
|
4538
4543
|
* - <https://w3id.org/security/multikey/v1>
|
|
4544
|
+
* - <https://w3id.org/fep/ef61>
|
|
4539
4545
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
4540
4546
|
* - <http://schema.org/>
|
|
4541
4547
|
* @param options Options for the document loader.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-
|
|
1
|
+
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-B6s_F7bi.mjs";
|
|
2
2
|
import { t as HttpHeaderLink } from "./link-NUUWCdnK.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { h as validatePublicUrl, t as UrlError } from "./url-Du7RQQgP.mjs";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
6
6
|
//#endregion
|
|
@@ -459,10 +459,6 @@ const preloadedContexts = {
|
|
|
459
459
|
"id": "@id",
|
|
460
460
|
"type": "@type",
|
|
461
461
|
"@protected": true,
|
|
462
|
-
"digestMultibase": {
|
|
463
|
-
"@id": "https://w3id.org/security#digestMultibase",
|
|
464
|
-
"@type": "https://w3id.org/security#multibase"
|
|
465
|
-
},
|
|
466
462
|
"proof": {
|
|
467
463
|
"@id": "https://w3id.org/security#proof",
|
|
468
464
|
"@type": "@id",
|
|
@@ -4299,6 +4295,14 @@ const preloadedContexts = {
|
|
|
4299
4295
|
"@type": "@id"
|
|
4300
4296
|
}
|
|
4301
4297
|
} },
|
|
4298
|
+
"https://w3id.org/fep/ef61": { "@context": {
|
|
4299
|
+
"gateways": {
|
|
4300
|
+
"@id": "https://w3id.org/fep/ef61/gateways",
|
|
4301
|
+
"@type": "@id",
|
|
4302
|
+
"@container": "@list"
|
|
4303
|
+
},
|
|
4304
|
+
"digestMultibase": "https://www.w3.org/ns/credentials/v2#digestMultibase"
|
|
4305
|
+
} },
|
|
4302
4306
|
"https://join-lemmy.org/context.json": { "@context": ["https://w3id.org/security/v1", {
|
|
4303
4307
|
"as": "https://www.w3.org/ns/activitystreams#",
|
|
4304
4308
|
"lemmy": "https://join-lemmy.org/ns#",
|
|
@@ -4533,8 +4537,10 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
4533
4537
|
* - <https://www.w3.org/ns/activitystreams>
|
|
4534
4538
|
* - <https://w3id.org/security/v1>
|
|
4535
4539
|
* - <https://w3id.org/security/data-integrity/v1>
|
|
4540
|
+
* - <https://w3id.org/security/data-integrity/v2>
|
|
4536
4541
|
* - <https://www.w3.org/ns/did/v1>
|
|
4537
4542
|
* - <https://w3id.org/security/multikey/v1>
|
|
4543
|
+
* - <https://w3id.org/fep/ef61>
|
|
4538
4544
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
4539
4545
|
* - <http://schema.org/>
|
|
4540
4546
|
* @param options Options for the document loader.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-C2EiDwsr.cjs");
|
|
2
|
-
const require_docloader = require("./docloader-
|
|
3
|
-
const require_request = require("./request-
|
|
4
|
-
const require_url = require("./url-
|
|
2
|
+
const require_docloader = require("./docloader-DVVWmXLI.cjs");
|
|
3
|
+
const require_request = require("./request-DvEyU5Zf.cjs");
|
|
4
|
+
const require_url = require("./url-CsOV_B_P.cjs");
|
|
5
5
|
let node_assert = require("node:assert");
|
|
6
6
|
let node_test = require("node:test");
|
|
7
7
|
//#region ../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as getRemoteDocument, r as preloadedContexts, t as getDocumentLoader } from "./docloader-
|
|
2
|
-
import { t as FetchError } from "./request-
|
|
3
|
-
import { t as UrlError } from "./url-
|
|
1
|
+
import { n as getRemoteDocument, r as preloadedContexts, t as getDocumentLoader } from "./docloader-HbEvzi-t.mjs";
|
|
2
|
+
import { t as FetchError } from "./request-B6s_F7bi.mjs";
|
|
3
|
+
import { t as UrlError } from "./url-Du7RQQgP.mjs";
|
|
4
4
|
import { deepStrictEqual, ok, rejects } from "node:assert";
|
|
5
5
|
import { test } from "node:test";
|
|
6
6
|
//#region \0rolldown/runtime.js
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-C2EiDwsr.cjs");
|
|
2
|
-
const require_url = require("./url-
|
|
2
|
+
const require_url = require("./url-CsOV_B_P.cjs");
|
|
3
3
|
let node_assert = require("node:assert");
|
|
4
4
|
let node_test = require("node:test");
|
|
5
5
|
let jsonld_dist_jsonld_esm_js = require("jsonld/dist/jsonld.esm.js");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as formatIri, c as haveSameIriOrigin,
|
|
1
|
+
import { a as formatIri, c as haveSameIriOrigin, p as parseIri, s as haveSameFe34Origin } from "./url-Du7RQQgP.mjs";
|
|
2
2
|
import { deepStrictEqual, ok, strictEqual } from "node:assert";
|
|
3
3
|
import { test } from "node:test";
|
|
4
4
|
import jsonld from "jsonld/dist/jsonld.esm.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("./chunk-C2EiDwsr.cjs");
|
|
2
2
|
const require_multicodec = require("./multicodec-CxGVGa91.cjs");
|
|
3
|
-
const require_multibase = require("./multibase-
|
|
3
|
+
const require_multibase = require("./multibase-DcDQDNnI.cjs");
|
|
4
4
|
let asn1js = require("asn1js");
|
|
5
5
|
let byte_encodings_base64 = require("byte-encodings/base64");
|
|
6
6
|
let byte_encodings_base64url = require("byte-encodings/base64url");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as getMulticodecPrefix, r as removeMulticodecPrefix, t as addMulticodecPrefix } from "./multicodec-CyFp54fI.mjs";
|
|
2
|
-
import { n as encodeMultibase, t as decodeMultibase } from "./multibase-
|
|
2
|
+
import { n as encodeMultibase, t as decodeMultibase } from "./multibase-Cluwl8OM.mjs";
|
|
3
3
|
import { Integer, Sequence } from "asn1js";
|
|
4
4
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
5
5
|
import { decodeBase64Url } from "byte-encodings/base64url";
|
package/dist/tests/key.test.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require("./chunk-C2EiDwsr.cjs");
|
|
2
2
|
const require_multicodec = require("./multicodec-CxGVGa91.cjs");
|
|
3
|
-
const require_key = require("./key-
|
|
4
|
-
const require_multibase = require("./multibase-
|
|
3
|
+
const require_key = require("./key-BcOWDLMm.cjs");
|
|
4
|
+
const require_multibase = require("./multibase-DcDQDNnI.cjs");
|
|
5
5
|
let node_assert = require("node:assert");
|
|
6
6
|
let node_test = require("node:test");
|
|
7
7
|
//#region src/key.test.ts
|
package/dist/tests/key.test.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as addMulticodecPrefix } from "./multicodec-CyFp54fI.mjs";
|
|
2
|
-
import { a as importMultibaseKey, c as importSpki, d as importJwk, i as importDidKey, l as parseDidKeyVerificationMethod, n as exportMultibaseKey, o as importPem, r as exportSpki, s as importPkcs1, t as exportDidKey, u as exportJwk } from "./key-
|
|
3
|
-
import { n as encodeMultibase } from "./multibase-
|
|
2
|
+
import { a as importMultibaseKey, c as importSpki, d as importJwk, i as importDidKey, l as parseDidKeyVerificationMethod, n as exportMultibaseKey, o as importPem, r as exportSpki, s as importPkcs1, t as exportDidKey, u as exportJwk } from "./key-Drbw_2tw.mjs";
|
|
3
|
+
import { n as encodeMultibase } from "./multibase-Cluwl8OM.mjs";
|
|
4
4
|
import { deepStrictEqual, rejects } from "node:assert";
|
|
5
5
|
import { test } from "node:test";
|
|
6
6
|
//#region src/key.test.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-C2EiDwsr.cjs");
|
|
2
|
-
const require_langstr = require("./langstr-
|
|
2
|
+
const require_langstr = require("./langstr-BOQHfJDr.cjs");
|
|
3
3
|
let node_assert = require("node:assert");
|
|
4
4
|
let node_test = require("node:test");
|
|
5
5
|
let node_util = require("node:util");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("../chunk-C2EiDwsr.cjs");
|
|
2
|
-
const require_multibase = require("../multibase-
|
|
2
|
+
const require_multibase = require("../multibase-DcDQDNnI.cjs");
|
|
3
3
|
let node_assert = require("node:assert");
|
|
4
4
|
let node_test = require("node:test");
|
|
5
5
|
//#region src/multibase/multibase.test.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as names, i as codes, n as encodeMultibase, o as decodeText, s as encodeText, t as decodeMultibase } from "../multibase-Cluwl8OM.mjs";
|
|
2
2
|
import { deepStrictEqual } from "node:assert";
|
|
3
3
|
import { test } from "node:test";
|
|
4
4
|
//#region src/multibase/multibase.test.ts
|
|
@@ -303,5 +303,16 @@ function encoding(nameOrCode) {
|
|
|
303
303
|
else if (Object.prototype.hasOwnProperty.call(codes, nameOrCode)) return codes[nameOrCode];
|
|
304
304
|
else throw new Error(`Unsupported encoding: ${nameOrCode}`);
|
|
305
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Get encoding multibase from data
|
|
308
|
+
*
|
|
309
|
+
* @param {string|Uint8Array} data
|
|
310
|
+
* @returns {Base}
|
|
311
|
+
* @throws {Error} Will throw if the encoding is not supported
|
|
312
|
+
*/
|
|
313
|
+
function encodingFromBaseData(data) {
|
|
314
|
+
if (data instanceof Uint8Array) data = decodeText(data);
|
|
315
|
+
return encoding(data[0]);
|
|
316
|
+
}
|
|
306
317
|
//#endregion
|
|
307
|
-
export {
|
|
318
|
+
export { names as a, codes as i, encodeMultibase as n, decodeText as o, encodingFromBaseData as r, encodeText as s, decodeMultibase as t };
|
|
@@ -305,6 +305,17 @@ function encoding(nameOrCode) {
|
|
|
305
305
|
else if (Object.prototype.hasOwnProperty.call(codes, nameOrCode)) return codes[nameOrCode];
|
|
306
306
|
else throw new Error(`Unsupported encoding: ${nameOrCode}`);
|
|
307
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Get encoding multibase from data
|
|
310
|
+
*
|
|
311
|
+
* @param {string|Uint8Array} data
|
|
312
|
+
* @returns {Base}
|
|
313
|
+
* @throws {Error} Will throw if the encoding is not supported
|
|
314
|
+
*/
|
|
315
|
+
function encodingFromBaseData(data) {
|
|
316
|
+
if (data instanceof Uint8Array) data = decodeText(data);
|
|
317
|
+
return encoding(data[0]);
|
|
318
|
+
}
|
|
308
319
|
//#endregion
|
|
309
320
|
Object.defineProperty(exports, "codes", {
|
|
310
321
|
enumerable: true,
|
|
@@ -336,6 +347,12 @@ Object.defineProperty(exports, "encodeText", {
|
|
|
336
347
|
return encodeText;
|
|
337
348
|
}
|
|
338
349
|
});
|
|
350
|
+
Object.defineProperty(exports, "encodingFromBaseData", {
|
|
351
|
+
enumerable: true,
|
|
352
|
+
get: function() {
|
|
353
|
+
return encodingFromBaseData;
|
|
354
|
+
}
|
|
355
|
+
});
|
|
339
356
|
Object.defineProperty(exports, "names", {
|
|
340
357
|
enumerable: true,
|
|
341
358
|
get: function() {
|
|
@@ -3,7 +3,7 @@ let node_process = require("node:process");
|
|
|
3
3
|
node_process = require_chunk.__toESM(node_process, 1);
|
|
4
4
|
//#region deno.json
|
|
5
5
|
var name = "@fedify/vocab-runtime";
|
|
6
|
-
var version = "2.4.0-dev.
|
|
6
|
+
var version = "2.4.0-dev.1655+b8f3c3d5";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/request.ts
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-C2EiDwsr.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-DvEyU5Zf.cjs");
|
|
3
3
|
let node_assert = require("node:assert");
|
|
4
4
|
let node_test = require("node:test");
|
|
5
5
|
let node_process = require("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-B6s_F7bi.mjs";
|
|
2
2
|
import { deepStrictEqual } from "node:assert";
|
|
3
3
|
import { test } from "node:test";
|
|
4
4
|
import process from "node:process";
|
|
@@ -211,6 +211,20 @@ function parseAtUri(uri) {
|
|
|
211
211
|
return new URL("at://" + encodeURIComponent(authority) + path);
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
|
+
* Checks whether the URL is an FEP-ef61 gateway base URI.
|
|
215
|
+
*/
|
|
216
|
+
function isGatewayUrl(url) {
|
|
217
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.username === "" && url.password === "" && url.pathname === "/" && url.search === "" && url.hash === "";
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Parses and validates an FEP-ef61 gateway base URI.
|
|
221
|
+
*/
|
|
222
|
+
function parseGatewayUrl(url) {
|
|
223
|
+
const parsed = parseIri(url);
|
|
224
|
+
if (!isGatewayUrl(parsed)) throw new TypeError("FEP-ef61 gateways must be HTTP(S) base URIs with no credentials, path, query, or fragment.");
|
|
225
|
+
return parsed;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
214
228
|
* Validates a URL to prevent SSRF attacks.
|
|
215
229
|
*/
|
|
216
230
|
async function validatePublicUrl(url) {
|
|
@@ -424,6 +438,12 @@ Object.defineProperty(exports, "haveSameIriOrigin", {
|
|
|
424
438
|
return haveSameIriOrigin;
|
|
425
439
|
}
|
|
426
440
|
});
|
|
441
|
+
Object.defineProperty(exports, "isGatewayUrl", {
|
|
442
|
+
enumerable: true,
|
|
443
|
+
get: function() {
|
|
444
|
+
return isGatewayUrl;
|
|
445
|
+
}
|
|
446
|
+
});
|
|
427
447
|
Object.defineProperty(exports, "isValidPublicIPv4Address", {
|
|
428
448
|
enumerable: true,
|
|
429
449
|
get: function() {
|
|
@@ -436,6 +456,12 @@ Object.defineProperty(exports, "isValidPublicIPv6Address", {
|
|
|
436
456
|
return isValidPublicIPv6Address;
|
|
437
457
|
}
|
|
438
458
|
});
|
|
459
|
+
Object.defineProperty(exports, "parseGatewayUrl", {
|
|
460
|
+
enumerable: true,
|
|
461
|
+
get: function() {
|
|
462
|
+
return parseGatewayUrl;
|
|
463
|
+
}
|
|
464
|
+
});
|
|
439
465
|
Object.defineProperty(exports, "parseIri", {
|
|
440
466
|
enumerable: true,
|
|
441
467
|
get: function() {
|
|
@@ -210,6 +210,20 @@ function parseAtUri(uri) {
|
|
|
210
210
|
return new URL("at://" + encodeURIComponent(authority) + path);
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
|
+
* Checks whether the URL is an FEP-ef61 gateway base URI.
|
|
214
|
+
*/
|
|
215
|
+
function isGatewayUrl(url) {
|
|
216
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.username === "" && url.password === "" && url.pathname === "/" && url.search === "" && url.hash === "";
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Parses and validates an FEP-ef61 gateway base URI.
|
|
220
|
+
*/
|
|
221
|
+
function parseGatewayUrl(url) {
|
|
222
|
+
const parsed = parseIri(url);
|
|
223
|
+
if (!isGatewayUrl(parsed)) throw new TypeError("FEP-ef61 gateways must be HTTP(S) base URIs with no credentials, path, query, or fragment.");
|
|
224
|
+
return parsed;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
213
227
|
* Validates a URL to prevent SSRF attacks.
|
|
214
228
|
*/
|
|
215
229
|
async function validatePublicUrl(url) {
|
|
@@ -375,4 +389,4 @@ function matchesIPv6Prefix(address, prefixWords, prefixLength) {
|
|
|
375
389
|
return true;
|
|
376
390
|
}
|
|
377
391
|
//#endregion
|
|
378
|
-
export { formatIri as a, haveSameIriOrigin as c,
|
|
392
|
+
export { formatIri as a, haveSameIriOrigin as c, isValidPublicIPv6Address as d, parseGatewayUrl as f, validatePublicUrl as h, expandIPv6Address as i, isGatewayUrl as l, parseJsonLdId as m, arePortableUrisEqual as n, getFe34Origin as o, parseIri as p, canonicalizePortableUri as r, haveSameFe34Origin as s, UrlError as t, isValidPublicIPv4Address as u };
|
package/dist/tests/url.test.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-C2EiDwsr.cjs");
|
|
2
|
-
const require_url = require("./url-
|
|
2
|
+
const require_url = require("./url-CsOV_B_P.cjs");
|
|
3
3
|
let node_assert = require("node:assert");
|
|
4
4
|
let node_test = require("node:test");
|
|
5
5
|
//#region src/url.test.ts
|
|
@@ -228,6 +228,23 @@ let node_test = require("node:test");
|
|
|
228
228
|
(0, node_assert.deepStrictEqual)(parsed, new URL("ap+ef61://did%3Aweb%3Aexample.com%2500/u/1"));
|
|
229
229
|
(0, node_assert.deepStrictEqual)(require_url.formatIri(parsed), "ap+ef61://did:web:example.com%00/u/1");
|
|
230
230
|
});
|
|
231
|
+
(0, node_test.test)("parseGatewayUrl() accepts only HTTP(S) base URIs", () => {
|
|
232
|
+
for (const url of ["https://server.example/", "http://server.example/"]) {
|
|
233
|
+
(0, node_assert.deepStrictEqual)(require_url.parseGatewayUrl(url), new URL(url));
|
|
234
|
+
(0, node_assert.ok)(require_url.isGatewayUrl(new URL(url)));
|
|
235
|
+
}
|
|
236
|
+
for (const url of [
|
|
237
|
+
"ftp://server.example/",
|
|
238
|
+
"https://user:pass@server.example/",
|
|
239
|
+
"https://user@server.example/",
|
|
240
|
+
"https://server.example/path",
|
|
241
|
+
"https://server.example/?x=1",
|
|
242
|
+
"https://server.example/#fragment"
|
|
243
|
+
]) {
|
|
244
|
+
(0, node_assert.throws)(() => require_url.parseGatewayUrl(url), TypeError);
|
|
245
|
+
(0, node_assert.ok)(!require_url.isGatewayUrl(new URL(url)));
|
|
246
|
+
}
|
|
247
|
+
});
|
|
231
248
|
(0, node_test.test)("validatePublicUrl()", async () => {
|
|
232
249
|
await (0, node_assert.rejects)(() => require_url.validatePublicUrl("ftp://localhost"), require_url.UrlError);
|
|
233
250
|
await (0, node_assert.rejects)(() => require_url.validatePublicUrl("data:text/plain;base64,SGVsbG8sIFdvcmxkIQ=="), require_url.UrlError);
|
package/dist/tests/url.test.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as formatIri, c as haveSameIriOrigin, d as
|
|
1
|
+
import { a as formatIri, c as haveSameIriOrigin, d as isValidPublicIPv6Address, f as parseGatewayUrl, h as validatePublicUrl, i as expandIPv6Address, l as isGatewayUrl, m as parseJsonLdId, n as arePortableUrisEqual, o as getFe34Origin, p as parseIri, r as canonicalizePortableUri, s as haveSameFe34Origin, t as UrlError, u as isValidPublicIPv4Address } from "./url-Du7RQQgP.mjs";
|
|
2
2
|
import { deepStrictEqual, ok, rejects, throws } from "node:assert";
|
|
3
3
|
import { test } from "node:test";
|
|
4
4
|
//#region src/url.test.ts
|
|
@@ -227,6 +227,23 @@ test("parseIri() preserves encoded percent signs while decoding delimiters", ()
|
|
|
227
227
|
deepStrictEqual(parsed, new URL("ap+ef61://did%3Aweb%3Aexample.com%2500/u/1"));
|
|
228
228
|
deepStrictEqual(formatIri(parsed), "ap+ef61://did:web:example.com%00/u/1");
|
|
229
229
|
});
|
|
230
|
+
test("parseGatewayUrl() accepts only HTTP(S) base URIs", () => {
|
|
231
|
+
for (const url of ["https://server.example/", "http://server.example/"]) {
|
|
232
|
+
deepStrictEqual(parseGatewayUrl(url), new URL(url));
|
|
233
|
+
ok(isGatewayUrl(new URL(url)));
|
|
234
|
+
}
|
|
235
|
+
for (const url of [
|
|
236
|
+
"ftp://server.example/",
|
|
237
|
+
"https://user:pass@server.example/",
|
|
238
|
+
"https://user@server.example/",
|
|
239
|
+
"https://server.example/path",
|
|
240
|
+
"https://server.example/?x=1",
|
|
241
|
+
"https://server.example/#fragment"
|
|
242
|
+
]) {
|
|
243
|
+
throws(() => parseGatewayUrl(url), TypeError);
|
|
244
|
+
ok(!isGatewayUrl(new URL(url)));
|
|
245
|
+
}
|
|
246
|
+
});
|
|
230
247
|
test("validatePublicUrl()", async () => {
|
|
231
248
|
await rejects(() => validatePublicUrl("ftp://localhost"), UrlError);
|
|
232
249
|
await rejects(() => validatePublicUrl("data:text/plain;base64,SGVsbG8sIFdvcmxkIQ=="), UrlError);
|
|
@@ -212,6 +212,20 @@ function parseAtUri(uri) {
|
|
|
212
212
|
return new URL("at://" + encodeURIComponent(authority) + path);
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
|
+
* Checks whether the URL is an FEP-ef61 gateway base URI.
|
|
216
|
+
*/
|
|
217
|
+
function isGatewayUrl(url) {
|
|
218
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.username === "" && url.password === "" && url.pathname === "/" && url.search === "" && url.hash === "";
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Parses and validates an FEP-ef61 gateway base URI.
|
|
222
|
+
*/
|
|
223
|
+
function parseGatewayUrl(url) {
|
|
224
|
+
const parsed = parseIri(url);
|
|
225
|
+
if (!isGatewayUrl(parsed)) throw new TypeError("FEP-ef61 gateways must be HTTP(S) base URIs with no credentials, path, query, or fragment.");
|
|
226
|
+
return parsed;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
215
229
|
* Validates a URL to prevent SSRF attacks.
|
|
216
230
|
*/
|
|
217
231
|
async function validatePublicUrl(url) {
|
|
@@ -425,6 +439,12 @@ Object.defineProperty(exports, "haveSameIriOrigin", {
|
|
|
425
439
|
return haveSameIriOrigin;
|
|
426
440
|
}
|
|
427
441
|
});
|
|
442
|
+
Object.defineProperty(exports, "isGatewayUrl", {
|
|
443
|
+
enumerable: true,
|
|
444
|
+
get: function() {
|
|
445
|
+
return isGatewayUrl;
|
|
446
|
+
}
|
|
447
|
+
});
|
|
428
448
|
Object.defineProperty(exports, "isValidPublicIPv4Address", {
|
|
429
449
|
enumerable: true,
|
|
430
450
|
get: function() {
|
|
@@ -437,6 +457,12 @@ Object.defineProperty(exports, "isValidPublicIPv6Address", {
|
|
|
437
457
|
return isValidPublicIPv6Address;
|
|
438
458
|
}
|
|
439
459
|
});
|
|
460
|
+
Object.defineProperty(exports, "parseGatewayUrl", {
|
|
461
|
+
enumerable: true,
|
|
462
|
+
get: function() {
|
|
463
|
+
return parseGatewayUrl;
|
|
464
|
+
}
|
|
465
|
+
});
|
|
440
466
|
Object.defineProperty(exports, "parseIri", {
|
|
441
467
|
enumerable: true,
|
|
442
468
|
get: function() {
|
|
@@ -211,6 +211,20 @@ function parseAtUri(uri) {
|
|
|
211
211
|
return new URL("at://" + encodeURIComponent(authority) + path);
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
|
+
* Checks whether the URL is an FEP-ef61 gateway base URI.
|
|
215
|
+
*/
|
|
216
|
+
function isGatewayUrl(url) {
|
|
217
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.username === "" && url.password === "" && url.pathname === "/" && url.search === "" && url.hash === "";
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Parses and validates an FEP-ef61 gateway base URI.
|
|
221
|
+
*/
|
|
222
|
+
function parseGatewayUrl(url) {
|
|
223
|
+
const parsed = parseIri(url);
|
|
224
|
+
if (!isGatewayUrl(parsed)) throw new TypeError("FEP-ef61 gateways must be HTTP(S) base URIs with no credentials, path, query, or fragment.");
|
|
225
|
+
return parsed;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
214
228
|
* Validates a URL to prevent SSRF attacks.
|
|
215
229
|
*/
|
|
216
230
|
async function validatePublicUrl(url) {
|
|
@@ -376,4 +390,4 @@ function matchesIPv6Prefix(address, prefixWords, prefixLength) {
|
|
|
376
390
|
return true;
|
|
377
391
|
}
|
|
378
392
|
//#endregion
|
|
379
|
-
export { formatIri as a, haveSameIriOrigin as c,
|
|
393
|
+
export { formatIri as a, haveSameIriOrigin as c, isValidPublicIPv6Address as d, parseGatewayUrl as f, validatePublicUrl as h, expandIPv6Address as i, isGatewayUrl as l, parseJsonLdId as m, arePortableUrisEqual as n, getFe34Origin as o, parseIri as p, canonicalizePortableUri as r, haveSameFe34Origin as s, UrlError as t, isValidPublicIPv4Address as u };
|
package/package.json
CHANGED