@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
package/deno.json
CHANGED
|
@@ -184,8 +184,10 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
|
184
184
|
* - <https://www.w3.org/ns/activitystreams>
|
|
185
185
|
* - <https://w3id.org/security/v1>
|
|
186
186
|
* - <https://w3id.org/security/data-integrity/v1>
|
|
187
|
+
* - <https://w3id.org/security/data-integrity/v2>
|
|
187
188
|
* - <https://www.w3.org/ns/did/v1>
|
|
188
189
|
* - <https://w3id.org/security/multikey/v1>
|
|
190
|
+
* - <https://w3id.org/fep/ef61>
|
|
189
191
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
190
192
|
* - <http://schema.org/>
|
|
191
193
|
* @param options Options for the document loader.
|
|
@@ -184,8 +184,10 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
|
184
184
|
* - <https://www.w3.org/ns/activitystreams>
|
|
185
185
|
* - <https://w3id.org/security/v1>
|
|
186
186
|
* - <https://w3id.org/security/data-integrity/v1>
|
|
187
|
+
* - <https://w3id.org/security/data-integrity/v2>
|
|
187
188
|
* - <https://www.w3.org/ns/did/v1>
|
|
188
189
|
* - <https://w3id.org/security/multikey/v1>
|
|
190
|
+
* - <https://w3id.org/fep/ef61>
|
|
189
191
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
190
192
|
* - <http://schema.org/>
|
|
191
193
|
* @param options Options for the document loader.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const require_url = require("../url-
|
|
3
|
+
const require_url = require("../url-DD4F0ULf.cjs");
|
|
4
4
|
const require_jsonld = require("../jsonld.cjs");
|
|
5
5
|
//#region src/internal/jsonld-cache.ts
|
|
6
6
|
const noJsonLdContext = Symbol("noJsonLdContext");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as formatIri, c as haveSameIriOrigin, s as haveSameFe34Origin } from "../url-
|
|
2
|
+
import { a as formatIri, c as haveSameIriOrigin, s as haveSameFe34Origin } from "../url-DGVbSVVi.js";
|
|
3
3
|
import jsonld_default from "../jsonld.js";
|
|
4
4
|
//#region src/internal/jsonld-cache.ts
|
|
5
5
|
const noJsonLdContext = Symbol("noJsonLdContext");
|
package/dist/mod.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_chunk = require("./chunk-M78iaK0I.cjs");
|
|
4
|
-
const require_url = require("./url-
|
|
4
|
+
const require_url = require("./url-DD4F0ULf.cjs");
|
|
5
5
|
let _logtape_logtape = require("@logtape/logtape");
|
|
6
6
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
7
7
|
let node_process = require("node:process");
|
|
@@ -469,10 +469,6 @@ const preloadedContexts = {
|
|
|
469
469
|
"id": "@id",
|
|
470
470
|
"type": "@type",
|
|
471
471
|
"@protected": true,
|
|
472
|
-
"digestMultibase": {
|
|
473
|
-
"@id": "https://w3id.org/security#digestMultibase",
|
|
474
|
-
"@type": "https://w3id.org/security#multibase"
|
|
475
|
-
},
|
|
476
472
|
"proof": {
|
|
477
473
|
"@id": "https://w3id.org/security#proof",
|
|
478
474
|
"@type": "@id",
|
|
@@ -4309,6 +4305,14 @@ const preloadedContexts = {
|
|
|
4309
4305
|
"@type": "@id"
|
|
4310
4306
|
}
|
|
4311
4307
|
} },
|
|
4308
|
+
"https://w3id.org/fep/ef61": { "@context": {
|
|
4309
|
+
"gateways": {
|
|
4310
|
+
"@id": "https://w3id.org/fep/ef61/gateways",
|
|
4311
|
+
"@type": "@id",
|
|
4312
|
+
"@container": "@list"
|
|
4313
|
+
},
|
|
4314
|
+
"digestMultibase": "https://www.w3.org/ns/credentials/v2#digestMultibase"
|
|
4315
|
+
} },
|
|
4312
4316
|
"https://join-lemmy.org/context.json": { "@context": ["https://w3id.org/security/v1", {
|
|
4313
4317
|
"as": "https://www.w3.org/ns/activitystreams#",
|
|
4314
4318
|
"lemmy": "https://join-lemmy.org/ns#",
|
|
@@ -4367,7 +4371,7 @@ const preloadedContexts = {
|
|
|
4367
4371
|
//#endregion
|
|
4368
4372
|
//#region deno.json
|
|
4369
4373
|
var name = "@fedify/vocab-runtime";
|
|
4370
|
-
var version = "2.4.0-dev.
|
|
4374
|
+
var version = "2.4.0-dev.1655+b8f3c3d5";
|
|
4371
4375
|
//#endregion
|
|
4372
4376
|
//#region src/link.ts
|
|
4373
4377
|
const parametersNeedLowerCase = ["rel", "type"];
|
|
@@ -4798,8 +4802,10 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
4798
4802
|
* - <https://www.w3.org/ns/activitystreams>
|
|
4799
4803
|
* - <https://w3id.org/security/v1>
|
|
4800
4804
|
* - <https://w3id.org/security/data-integrity/v1>
|
|
4805
|
+
* - <https://w3id.org/security/data-integrity/v2>
|
|
4801
4806
|
* - <https://www.w3.org/ns/did/v1>
|
|
4802
4807
|
* - <https://w3id.org/security/multikey/v1>
|
|
4808
|
+
* - <https://w3id.org/fep/ef61>
|
|
4803
4809
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
4804
4810
|
* - <http://schema.org/>
|
|
4805
4811
|
* @param options Options for the document loader.
|
|
@@ -4930,8 +4936,8 @@ function validateCryptoKey(key, type) {
|
|
|
4930
4936
|
}
|
|
4931
4937
|
//#endregion
|
|
4932
4938
|
//#region src/multibase/util.ts
|
|
4933
|
-
const textDecoder = new TextDecoder();
|
|
4934
|
-
const decodeText = (bytes) => textDecoder.decode(bytes);
|
|
4939
|
+
const textDecoder$1 = new TextDecoder();
|
|
4940
|
+
const decodeText = (bytes) => textDecoder$1.decode(bytes);
|
|
4935
4941
|
const textEncoder = new TextEncoder();
|
|
4936
4942
|
const encodeText = (text) => textEncoder.encode(text);
|
|
4937
4943
|
function concat(arrs, length) {
|
|
@@ -5520,6 +5526,143 @@ function parseDecimal(value) {
|
|
|
5520
5526
|
return normalized;
|
|
5521
5527
|
}
|
|
5522
5528
|
//#endregion
|
|
5529
|
+
//#region src/digest.ts
|
|
5530
|
+
const SHA2_256_MULTIHASH_CODE = 18;
|
|
5531
|
+
const SHA2_256_DIGEST_LENGTH = 32;
|
|
5532
|
+
const MAX_DIGEST_MULTIBASE_LENGTH = 1 + (SHA2_256_DIGEST_LENGTH + 2) * 8;
|
|
5533
|
+
const textDecoder = new TextDecoder();
|
|
5534
|
+
const getArrayBufferByteLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength")?.get;
|
|
5535
|
+
function isCanonicalVarintPrefix(data, prefix) {
|
|
5536
|
+
const canonical = addMulticodecPrefix(prefix.code, new Uint8Array());
|
|
5537
|
+
if (canonical.length !== prefix.prefixLength) return false;
|
|
5538
|
+
for (let i = 0; i < canonical.length; i++) if (data[i] !== canonical[i]) return false;
|
|
5539
|
+
return true;
|
|
5540
|
+
}
|
|
5541
|
+
function toWebCryptoBytes(bytes) {
|
|
5542
|
+
if (getArrayBufferByteLength != null) try {
|
|
5543
|
+
getArrayBufferByteLength.call(bytes.buffer);
|
|
5544
|
+
return bytes;
|
|
5545
|
+
} catch {}
|
|
5546
|
+
return new Uint8Array(bytes);
|
|
5547
|
+
}
|
|
5548
|
+
/**
|
|
5549
|
+
* Computes the SHA-256 digest of a byte sequence and encodes it as a
|
|
5550
|
+
* base58-btc multibase multihash suitable for FEP-ef61's
|
|
5551
|
+
* `digestMultibase` property.
|
|
5552
|
+
*
|
|
5553
|
+
* @param bytes The bytes to digest.
|
|
5554
|
+
* @returns The base58-btc multibase-encoded SHA-256 multihash.
|
|
5555
|
+
* @since 2.4.0
|
|
5556
|
+
*/
|
|
5557
|
+
async function computeDigestMultibase(bytes) {
|
|
5558
|
+
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", toWebCryptoBytes(bytes)));
|
|
5559
|
+
const multihash = addMulticodecPrefix(SHA2_256_MULTIHASH_CODE, addMulticodecPrefix(digest.length, digest));
|
|
5560
|
+
return textDecoder.decode(encodeMultibase("base58btc", multihash));
|
|
5561
|
+
}
|
|
5562
|
+
/**
|
|
5563
|
+
* Parses and validates a SHA-256 `digestMultibase` value.
|
|
5564
|
+
*
|
|
5565
|
+
* @param value The multibase-encoded multihash to parse.
|
|
5566
|
+
* @returns The digest algorithm and raw digest bytes.
|
|
5567
|
+
* @throws {TypeError} If the value is malformed or uses an unsupported hash
|
|
5568
|
+
* algorithm.
|
|
5569
|
+
* @since 2.4.0
|
|
5570
|
+
*/
|
|
5571
|
+
function parseDigestMultibase(value) {
|
|
5572
|
+
if (value.length > MAX_DIGEST_MULTIBASE_LENGTH) throw new TypeError("Invalid digestMultibase encoding.");
|
|
5573
|
+
let multihash;
|
|
5574
|
+
try {
|
|
5575
|
+
multihash = decodeMultibase(value);
|
|
5576
|
+
} catch (error) {
|
|
5577
|
+
throw new TypeError("Invalid digestMultibase encoding.", { cause: error });
|
|
5578
|
+
}
|
|
5579
|
+
const encoding = encodingFromBaseData(value);
|
|
5580
|
+
if (value !== textDecoder.decode(encodeMultibase(encoding.name, multihash))) throw new TypeError("Invalid digestMultibase encoding.");
|
|
5581
|
+
let algorithmPrefix;
|
|
5582
|
+
try {
|
|
5583
|
+
algorithmPrefix = getMulticodecPrefix(multihash);
|
|
5584
|
+
} catch (error) {
|
|
5585
|
+
throw new TypeError("Invalid digestMultibase multihash.", { cause: error });
|
|
5586
|
+
}
|
|
5587
|
+
if (!isCanonicalVarintPrefix(multihash, algorithmPrefix)) throw new TypeError("Invalid digestMultibase multihash.");
|
|
5588
|
+
if (algorithmPrefix.code !== SHA2_256_MULTIHASH_CODE) throw new TypeError(`Unsupported digest algorithm: 0x${algorithmPrefix.code.toString(16)}`);
|
|
5589
|
+
const lengthAndDigest = multihash.subarray(algorithmPrefix.prefixLength);
|
|
5590
|
+
let lengthPrefix;
|
|
5591
|
+
try {
|
|
5592
|
+
lengthPrefix = getMulticodecPrefix(lengthAndDigest);
|
|
5593
|
+
} catch (error) {
|
|
5594
|
+
throw new TypeError("Invalid digestMultibase multihash.", { cause: error });
|
|
5595
|
+
}
|
|
5596
|
+
if (!isCanonicalVarintPrefix(lengthAndDigest, lengthPrefix)) throw new TypeError("Invalid digestMultibase multihash.");
|
|
5597
|
+
const digest = lengthAndDigest.slice(lengthPrefix.prefixLength);
|
|
5598
|
+
if (lengthPrefix.code !== SHA2_256_DIGEST_LENGTH || digest.length !== SHA2_256_DIGEST_LENGTH) throw new TypeError("Invalid SHA-256 digest length.");
|
|
5599
|
+
return {
|
|
5600
|
+
algorithm: "sha2-256",
|
|
5601
|
+
digest
|
|
5602
|
+
};
|
|
5603
|
+
}
|
|
5604
|
+
function extractDigestMultibase(value) {
|
|
5605
|
+
const hashlink = typeof value === "string" ? value : value.href;
|
|
5606
|
+
const match = /^hl:([^:\r\n\u2028\u2029]+)$/i.exec(hashlink);
|
|
5607
|
+
if (match == null || match[0].length !== hashlink.length) throw new TypeError("Invalid simple hashlink.");
|
|
5608
|
+
return match[1];
|
|
5609
|
+
}
|
|
5610
|
+
/**
|
|
5611
|
+
* Parses a metadata-free `hl:` hashlink and validates its resource digest.
|
|
5612
|
+
*
|
|
5613
|
+
* @param value The simple hashlink to parse.
|
|
5614
|
+
* @returns The `digestMultibase` value carried by the hashlink.
|
|
5615
|
+
* @throws {TypeError} If the hashlink is malformed, contains metadata, or
|
|
5616
|
+
* carries an invalid or unsupported digest.
|
|
5617
|
+
* @since 2.4.0
|
|
5618
|
+
*/
|
|
5619
|
+
function parseHashlink(value) {
|
|
5620
|
+
const digestMultibase = extractDigestMultibase(value);
|
|
5621
|
+
parseDigestMultibase(digestMultibase);
|
|
5622
|
+
return { digestMultibase };
|
|
5623
|
+
}
|
|
5624
|
+
/**
|
|
5625
|
+
* Creates a metadata-free `hl:` hashlink from a `digestMultibase` value.
|
|
5626
|
+
*
|
|
5627
|
+
* @param digestMultibase The SHA-256 multibase multihash to embed.
|
|
5628
|
+
* @returns The simple hashlink.
|
|
5629
|
+
* @throws {TypeError} If the digest is malformed or unsupported.
|
|
5630
|
+
* @since 2.4.0
|
|
5631
|
+
*/
|
|
5632
|
+
function createHashlink(digestMultibase) {
|
|
5633
|
+
parseDigestMultibase(digestMultibase);
|
|
5634
|
+
return `hl:${digestMultibase}`;
|
|
5635
|
+
}
|
|
5636
|
+
/**
|
|
5637
|
+
* Verifies that bytes match a SHA-256 `digestMultibase` value.
|
|
5638
|
+
*
|
|
5639
|
+
* @param bytes The bytes to verify.
|
|
5640
|
+
* @param digestMultibase The expected digest.
|
|
5641
|
+
* @returns Whether the bytes match the digest.
|
|
5642
|
+
* @throws {TypeError} If the digest is malformed or unsupported.
|
|
5643
|
+
* @since 2.4.0
|
|
5644
|
+
*/
|
|
5645
|
+
async function verifyDigestMultibase(bytes, digestMultibase) {
|
|
5646
|
+
const expected = parseDigestMultibase(digestMultibase).digest;
|
|
5647
|
+
const actual = new Uint8Array(await crypto.subtle.digest("SHA-256", toWebCryptoBytes(bytes)));
|
|
5648
|
+
if (expected.length !== actual.length) return false;
|
|
5649
|
+
let difference = 0;
|
|
5650
|
+
for (let i = 0; i < expected.length; i++) difference |= expected[i] ^ actual[i];
|
|
5651
|
+
return difference === 0;
|
|
5652
|
+
}
|
|
5653
|
+
/**
|
|
5654
|
+
* Verifies that bytes match the resource digest in a simple hashlink.
|
|
5655
|
+
*
|
|
5656
|
+
* @param bytes The bytes to verify.
|
|
5657
|
+
* @param hashlink The simple hashlink containing the expected digest.
|
|
5658
|
+
* @returns Whether the bytes match the hashlink digest.
|
|
5659
|
+
* @throws {TypeError} If the hashlink or digest is malformed or unsupported.
|
|
5660
|
+
* @since 2.4.0
|
|
5661
|
+
*/
|
|
5662
|
+
async function verifyHashlink(bytes, hashlink) {
|
|
5663
|
+
return await verifyDigestMultibase(bytes, extractDigestMultibase(hashlink));
|
|
5664
|
+
}
|
|
5665
|
+
//#endregion
|
|
5523
5666
|
//#region src/langstr.ts
|
|
5524
5667
|
/**
|
|
5525
5668
|
* A language-tagged string which corresponds to the `rdf:langString` type.
|
|
@@ -5554,7 +5697,9 @@ exports.UrlError = require_url.UrlError;
|
|
|
5554
5697
|
exports.arePortableUrisEqual = require_url.arePortableUrisEqual;
|
|
5555
5698
|
exports.canParseDecimal = canParseDecimal;
|
|
5556
5699
|
exports.canonicalizePortableUri = require_url.canonicalizePortableUri;
|
|
5700
|
+
exports.computeDigestMultibase = computeDigestMultibase;
|
|
5557
5701
|
exports.createActivityPubRequest = createActivityPubRequest;
|
|
5702
|
+
exports.createHashlink = createHashlink;
|
|
5558
5703
|
exports.decodeMultibase = decodeMultibase;
|
|
5559
5704
|
exports.encodeMultibase = encodeMultibase;
|
|
5560
5705
|
exports.encodingFromBaseData = encodingFromBaseData;
|
|
@@ -5575,12 +5720,18 @@ exports.importPem = importPem;
|
|
|
5575
5720
|
exports.importPkcs1 = importPkcs1;
|
|
5576
5721
|
exports.importSpki = importSpki;
|
|
5577
5722
|
exports.isDecimal = isDecimal;
|
|
5723
|
+
exports.isGatewayUrl = require_url.isGatewayUrl;
|
|
5578
5724
|
exports.isValidPublicIPv4Address = require_url.isValidPublicIPv4Address;
|
|
5579
5725
|
exports.isValidPublicIPv6Address = require_url.isValidPublicIPv6Address;
|
|
5580
5726
|
exports.logRequest = logRequest;
|
|
5581
5727
|
exports.parseDecimal = parseDecimal;
|
|
5582
5728
|
exports.parseDidKeyVerificationMethod = parseDidKeyVerificationMethod;
|
|
5729
|
+
exports.parseDigestMultibase = parseDigestMultibase;
|
|
5730
|
+
exports.parseGatewayUrl = require_url.parseGatewayUrl;
|
|
5731
|
+
exports.parseHashlink = parseHashlink;
|
|
5583
5732
|
exports.parseIri = require_url.parseIri;
|
|
5584
5733
|
exports.parseJsonLdId = require_url.parseJsonLdId;
|
|
5585
5734
|
exports.preloadedContexts = preloadedContexts;
|
|
5586
5735
|
exports.validatePublicUrl = require_url.validatePublicUrl;
|
|
5736
|
+
exports.verifyDigestMultibase = verifyDigestMultibase;
|
|
5737
|
+
exports.verifyHashlink = verifyHashlink;
|
package/dist/mod.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { a as DocumentLoaderOptions, c as getDocumentLoader, d as FetchError, f as GetUserAgentOptions, h as logRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as getUserAgent, n as DocumentLoader, o as GetDocumentLoaderOptions, p as createActivityPubRequest, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as CreateRequestOptions } from "./docloader-
|
|
2
|
+
import { a as DocumentLoaderOptions, c as getDocumentLoader, d as FetchError, f as GetUserAgentOptions, h as logRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as getUserAgent, n as DocumentLoader, o as GetDocumentLoaderOptions, p as createActivityPubRequest, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as CreateRequestOptions } from "./docloader-D2DTRiyA.cjs";
|
|
3
3
|
import { TracerProvider } from "@opentelemetry/api";
|
|
4
4
|
|
|
5
5
|
//#region src/contexts.d.ts
|
|
@@ -204,6 +204,87 @@ declare function canParseDecimal(value: string): boolean;
|
|
|
204
204
|
*/
|
|
205
205
|
declare function parseDecimal(value: string): Decimal;
|
|
206
206
|
//#endregion
|
|
207
|
+
//#region src/digest.d.ts
|
|
208
|
+
/**
|
|
209
|
+
* A parsed SHA-256 resource digest.
|
|
210
|
+
*
|
|
211
|
+
* @since 2.4.0
|
|
212
|
+
*/
|
|
213
|
+
interface ParsedDigestMultibase {
|
|
214
|
+
/** The multihash algorithm represented by the digest. */
|
|
215
|
+
readonly algorithm: "sha2-256";
|
|
216
|
+
/** The raw 32-byte SHA-256 digest. */
|
|
217
|
+
readonly digest: Uint8Array;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* A parsed simple hashlink.
|
|
221
|
+
*
|
|
222
|
+
* @since 2.4.0
|
|
223
|
+
*/
|
|
224
|
+
interface ParsedHashlink {
|
|
225
|
+
/** The multibase-encoded multihash carried by the hashlink. */
|
|
226
|
+
readonly digestMultibase: string;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Computes the SHA-256 digest of a byte sequence and encodes it as a
|
|
230
|
+
* base58-btc multibase multihash suitable for FEP-ef61's
|
|
231
|
+
* `digestMultibase` property.
|
|
232
|
+
*
|
|
233
|
+
* @param bytes The bytes to digest.
|
|
234
|
+
* @returns The base58-btc multibase-encoded SHA-256 multihash.
|
|
235
|
+
* @since 2.4.0
|
|
236
|
+
*/
|
|
237
|
+
declare function computeDigestMultibase(bytes: Uint8Array): Promise<string>;
|
|
238
|
+
/**
|
|
239
|
+
* Parses and validates a SHA-256 `digestMultibase` value.
|
|
240
|
+
*
|
|
241
|
+
* @param value The multibase-encoded multihash to parse.
|
|
242
|
+
* @returns The digest algorithm and raw digest bytes.
|
|
243
|
+
* @throws {TypeError} If the value is malformed or uses an unsupported hash
|
|
244
|
+
* algorithm.
|
|
245
|
+
* @since 2.4.0
|
|
246
|
+
*/
|
|
247
|
+
declare function parseDigestMultibase(value: string): ParsedDigestMultibase;
|
|
248
|
+
/**
|
|
249
|
+
* Parses a metadata-free `hl:` hashlink and validates its resource digest.
|
|
250
|
+
*
|
|
251
|
+
* @param value The simple hashlink to parse.
|
|
252
|
+
* @returns The `digestMultibase` value carried by the hashlink.
|
|
253
|
+
* @throws {TypeError} If the hashlink is malformed, contains metadata, or
|
|
254
|
+
* carries an invalid or unsupported digest.
|
|
255
|
+
* @since 2.4.0
|
|
256
|
+
*/
|
|
257
|
+
declare function parseHashlink(value: string | URL): ParsedHashlink;
|
|
258
|
+
/**
|
|
259
|
+
* Creates a metadata-free `hl:` hashlink from a `digestMultibase` value.
|
|
260
|
+
*
|
|
261
|
+
* @param digestMultibase The SHA-256 multibase multihash to embed.
|
|
262
|
+
* @returns The simple hashlink.
|
|
263
|
+
* @throws {TypeError} If the digest is malformed or unsupported.
|
|
264
|
+
* @since 2.4.0
|
|
265
|
+
*/
|
|
266
|
+
declare function createHashlink(digestMultibase: string): string;
|
|
267
|
+
/**
|
|
268
|
+
* Verifies that bytes match a SHA-256 `digestMultibase` value.
|
|
269
|
+
*
|
|
270
|
+
* @param bytes The bytes to verify.
|
|
271
|
+
* @param digestMultibase The expected digest.
|
|
272
|
+
* @returns Whether the bytes match the digest.
|
|
273
|
+
* @throws {TypeError} If the digest is malformed or unsupported.
|
|
274
|
+
* @since 2.4.0
|
|
275
|
+
*/
|
|
276
|
+
declare function verifyDigestMultibase(bytes: Uint8Array, digestMultibase: string): Promise<boolean>;
|
|
277
|
+
/**
|
|
278
|
+
* Verifies that bytes match the resource digest in a simple hashlink.
|
|
279
|
+
*
|
|
280
|
+
* @param bytes The bytes to verify.
|
|
281
|
+
* @param hashlink The simple hashlink containing the expected digest.
|
|
282
|
+
* @returns Whether the bytes match the hashlink digest.
|
|
283
|
+
* @throws {TypeError} If the hashlink or digest is malformed or unsupported.
|
|
284
|
+
* @since 2.4.0
|
|
285
|
+
*/
|
|
286
|
+
declare function verifyHashlink(bytes: Uint8Array, hashlink: string | URL): Promise<boolean>;
|
|
287
|
+
//#endregion
|
|
207
288
|
//#region src/langstr.d.ts
|
|
208
289
|
/**
|
|
209
290
|
* A language-tagged string which corresponds to the `rdf:langString` type.
|
|
@@ -375,6 +456,14 @@ declare function haveSameFe34Origin(left: string | URL, right: string | URL): bo
|
|
|
375
456
|
*/
|
|
376
457
|
declare function haveSameIriOrigin(left: URL, right: URL): boolean;
|
|
377
458
|
/**
|
|
459
|
+
* Checks whether the URL is an FEP-ef61 gateway base URI.
|
|
460
|
+
*/
|
|
461
|
+
declare function isGatewayUrl(url: URL): boolean;
|
|
462
|
+
/**
|
|
463
|
+
* Parses and validates an FEP-ef61 gateway base URI.
|
|
464
|
+
*/
|
|
465
|
+
declare function parseGatewayUrl(url: string): URL;
|
|
466
|
+
/**
|
|
378
467
|
* Validates a URL to prevent SSRF attacks.
|
|
379
468
|
*/
|
|
380
469
|
declare function validatePublicUrl(url: string): Promise<void>;
|
|
@@ -382,4 +471,4 @@ declare function isValidPublicIPv4Address(address: string): boolean;
|
|
|
382
471
|
declare function isValidPublicIPv6Address(address: string): boolean;
|
|
383
472
|
declare function expandIPv6Address(address: string): string;
|
|
384
473
|
//#endregion
|
|
385
|
-
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DidKeyVerificationMethod, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, type Json, LanguageString, type PropertyPreprocessor, type PropertyPreprocessorContext, type RemoteDocument, UrlError, arePortableUrisEqual, canParseDecimal, canonicalizePortableUri, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportDidKey, exportMultibaseKey, exportSpki, formatIri, getDocumentLoader, getFe34Origin, getRemoteDocument, getUserAgent, haveSameFe34Origin, haveSameIriOrigin, importDidKey, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, parseDidKeyVerificationMethod, parseIri, parseJsonLdId, preloadedContexts, validatePublicUrl };
|
|
474
|
+
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DidKeyVerificationMethod, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, type Json, LanguageString, type ParsedDigestMultibase, type ParsedHashlink, type PropertyPreprocessor, type PropertyPreprocessorContext, type RemoteDocument, UrlError, arePortableUrisEqual, canParseDecimal, canonicalizePortableUri, computeDigestMultibase, createActivityPubRequest, createHashlink, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportDidKey, exportMultibaseKey, exportSpki, formatIri, getDocumentLoader, getFe34Origin, getRemoteDocument, getUserAgent, haveSameFe34Origin, haveSameIriOrigin, importDidKey, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isGatewayUrl, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, parseDidKeyVerificationMethod, parseDigestMultibase, parseGatewayUrl, parseHashlink, parseIri, parseJsonLdId, preloadedContexts, validatePublicUrl, verifyDigestMultibase, verifyHashlink };
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { a as DocumentLoaderOptions, c as getDocumentLoader, d as FetchError, f as GetUserAgentOptions, h as logRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as getUserAgent, n as DocumentLoader, o as GetDocumentLoaderOptions, p as createActivityPubRequest, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as CreateRequestOptions } from "./docloader-
|
|
2
|
+
import { a as DocumentLoaderOptions, c as getDocumentLoader, d as FetchError, f as GetUserAgentOptions, h as logRequest, i as DocumentLoaderFactoryOptions, l as getRemoteDocument, m as getUserAgent, n as DocumentLoader, o as GetDocumentLoaderOptions, p as createActivityPubRequest, r as DocumentLoaderFactory, s as RemoteDocument, t as AuthenticatedDocumentLoaderFactory, u as CreateRequestOptions } from "./docloader-C_dir7Xb.js";
|
|
3
3
|
import { TracerProvider } from "@opentelemetry/api";
|
|
4
4
|
|
|
5
5
|
//#region src/contexts.d.ts
|
|
@@ -204,6 +204,87 @@ declare function canParseDecimal(value: string): boolean;
|
|
|
204
204
|
*/
|
|
205
205
|
declare function parseDecimal(value: string): Decimal;
|
|
206
206
|
//#endregion
|
|
207
|
+
//#region src/digest.d.ts
|
|
208
|
+
/**
|
|
209
|
+
* A parsed SHA-256 resource digest.
|
|
210
|
+
*
|
|
211
|
+
* @since 2.4.0
|
|
212
|
+
*/
|
|
213
|
+
interface ParsedDigestMultibase {
|
|
214
|
+
/** The multihash algorithm represented by the digest. */
|
|
215
|
+
readonly algorithm: "sha2-256";
|
|
216
|
+
/** The raw 32-byte SHA-256 digest. */
|
|
217
|
+
readonly digest: Uint8Array;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* A parsed simple hashlink.
|
|
221
|
+
*
|
|
222
|
+
* @since 2.4.0
|
|
223
|
+
*/
|
|
224
|
+
interface ParsedHashlink {
|
|
225
|
+
/** The multibase-encoded multihash carried by the hashlink. */
|
|
226
|
+
readonly digestMultibase: string;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Computes the SHA-256 digest of a byte sequence and encodes it as a
|
|
230
|
+
* base58-btc multibase multihash suitable for FEP-ef61's
|
|
231
|
+
* `digestMultibase` property.
|
|
232
|
+
*
|
|
233
|
+
* @param bytes The bytes to digest.
|
|
234
|
+
* @returns The base58-btc multibase-encoded SHA-256 multihash.
|
|
235
|
+
* @since 2.4.0
|
|
236
|
+
*/
|
|
237
|
+
declare function computeDigestMultibase(bytes: Uint8Array): Promise<string>;
|
|
238
|
+
/**
|
|
239
|
+
* Parses and validates a SHA-256 `digestMultibase` value.
|
|
240
|
+
*
|
|
241
|
+
* @param value The multibase-encoded multihash to parse.
|
|
242
|
+
* @returns The digest algorithm and raw digest bytes.
|
|
243
|
+
* @throws {TypeError} If the value is malformed or uses an unsupported hash
|
|
244
|
+
* algorithm.
|
|
245
|
+
* @since 2.4.0
|
|
246
|
+
*/
|
|
247
|
+
declare function parseDigestMultibase(value: string): ParsedDigestMultibase;
|
|
248
|
+
/**
|
|
249
|
+
* Parses a metadata-free `hl:` hashlink and validates its resource digest.
|
|
250
|
+
*
|
|
251
|
+
* @param value The simple hashlink to parse.
|
|
252
|
+
* @returns The `digestMultibase` value carried by the hashlink.
|
|
253
|
+
* @throws {TypeError} If the hashlink is malformed, contains metadata, or
|
|
254
|
+
* carries an invalid or unsupported digest.
|
|
255
|
+
* @since 2.4.0
|
|
256
|
+
*/
|
|
257
|
+
declare function parseHashlink(value: string | URL): ParsedHashlink;
|
|
258
|
+
/**
|
|
259
|
+
* Creates a metadata-free `hl:` hashlink from a `digestMultibase` value.
|
|
260
|
+
*
|
|
261
|
+
* @param digestMultibase The SHA-256 multibase multihash to embed.
|
|
262
|
+
* @returns The simple hashlink.
|
|
263
|
+
* @throws {TypeError} If the digest is malformed or unsupported.
|
|
264
|
+
* @since 2.4.0
|
|
265
|
+
*/
|
|
266
|
+
declare function createHashlink(digestMultibase: string): string;
|
|
267
|
+
/**
|
|
268
|
+
* Verifies that bytes match a SHA-256 `digestMultibase` value.
|
|
269
|
+
*
|
|
270
|
+
* @param bytes The bytes to verify.
|
|
271
|
+
* @param digestMultibase The expected digest.
|
|
272
|
+
* @returns Whether the bytes match the digest.
|
|
273
|
+
* @throws {TypeError} If the digest is malformed or unsupported.
|
|
274
|
+
* @since 2.4.0
|
|
275
|
+
*/
|
|
276
|
+
declare function verifyDigestMultibase(bytes: Uint8Array, digestMultibase: string): Promise<boolean>;
|
|
277
|
+
/**
|
|
278
|
+
* Verifies that bytes match the resource digest in a simple hashlink.
|
|
279
|
+
*
|
|
280
|
+
* @param bytes The bytes to verify.
|
|
281
|
+
* @param hashlink The simple hashlink containing the expected digest.
|
|
282
|
+
* @returns Whether the bytes match the hashlink digest.
|
|
283
|
+
* @throws {TypeError} If the hashlink or digest is malformed or unsupported.
|
|
284
|
+
* @since 2.4.0
|
|
285
|
+
*/
|
|
286
|
+
declare function verifyHashlink(bytes: Uint8Array, hashlink: string | URL): Promise<boolean>;
|
|
287
|
+
//#endregion
|
|
207
288
|
//#region src/langstr.d.ts
|
|
208
289
|
/**
|
|
209
290
|
* A language-tagged string which corresponds to the `rdf:langString` type.
|
|
@@ -375,6 +456,14 @@ declare function haveSameFe34Origin(left: string | URL, right: string | URL): bo
|
|
|
375
456
|
*/
|
|
376
457
|
declare function haveSameIriOrigin(left: URL, right: URL): boolean;
|
|
377
458
|
/**
|
|
459
|
+
* Checks whether the URL is an FEP-ef61 gateway base URI.
|
|
460
|
+
*/
|
|
461
|
+
declare function isGatewayUrl(url: URL): boolean;
|
|
462
|
+
/**
|
|
463
|
+
* Parses and validates an FEP-ef61 gateway base URI.
|
|
464
|
+
*/
|
|
465
|
+
declare function parseGatewayUrl(url: string): URL;
|
|
466
|
+
/**
|
|
378
467
|
* Validates a URL to prevent SSRF attacks.
|
|
379
468
|
*/
|
|
380
469
|
declare function validatePublicUrl(url: string): Promise<void>;
|
|
@@ -382,4 +471,4 @@ declare function isValidPublicIPv4Address(address: string): boolean;
|
|
|
382
471
|
declare function isValidPublicIPv6Address(address: string): boolean;
|
|
383
472
|
declare function expandIPv6Address(address: string): string;
|
|
384
473
|
//#endregion
|
|
385
|
-
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DidKeyVerificationMethod, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, type Json, LanguageString, type PropertyPreprocessor, type PropertyPreprocessorContext, type RemoteDocument, UrlError, arePortableUrisEqual, canParseDecimal, canonicalizePortableUri, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportDidKey, exportMultibaseKey, exportSpki, formatIri, getDocumentLoader, getFe34Origin, getRemoteDocument, getUserAgent, haveSameFe34Origin, haveSameIriOrigin, importDidKey, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, parseDidKeyVerificationMethod, parseIri, parseJsonLdId, preloadedContexts, validatePublicUrl };
|
|
474
|
+
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DidKeyVerificationMethod, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, type Json, LanguageString, type ParsedDigestMultibase, type ParsedHashlink, type PropertyPreprocessor, type PropertyPreprocessorContext, type RemoteDocument, UrlError, arePortableUrisEqual, canParseDecimal, canonicalizePortableUri, computeDigestMultibase, createActivityPubRequest, createHashlink, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportDidKey, exportMultibaseKey, exportSpki, formatIri, getDocumentLoader, getFe34Origin, getRemoteDocument, getUserAgent, haveSameFe34Origin, haveSameIriOrigin, importDidKey, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isGatewayUrl, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, parseDidKeyVerificationMethod, parseDigestMultibase, parseGatewayUrl, parseHashlink, parseIri, parseJsonLdId, preloadedContexts, validatePublicUrl, verifyDigestMultibase, verifyHashlink };
|