@fedify/vocab-runtime 2.1.30 → 2.1.31
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 +5 -2
- package/dist/internal.cjs +6 -0
- package/dist/internal.d.cts +3 -0
- package/dist/internal.d.ts +3 -0
- package/dist/internal.js +3 -0
- package/dist/mod.cjs +105 -253
- package/dist/mod.d.cts +5 -27
- package/dist/mod.d.ts +6 -27
- package/dist/mod.js +98 -245
- package/dist/public-fetch-BC-nWJNM.d.ts +143 -0
- package/dist/public-fetch-CFnW7XMn.cjs +821 -0
- package/dist/public-fetch-DBpt3xxf.d.cts +143 -0
- package/dist/public-fetch-Dfmc_Kfy.js +772 -0
- package/dist/tests/{body-C7C_CqNA.mjs → body-B0Z2Vegb.mjs} +1 -1
- package/dist/tests/{body-Bda70xVu.cjs → body-i_FdQE3f.cjs} +1 -1
- package/dist/tests/body.test.cjs +1 -1
- package/dist/tests/body.test.mjs +1 -1
- package/dist/tests/decimal.test.cjs +6 -6
- package/dist/tests/decimal.test.mjs +6 -6
- package/dist/tests/{docloader-Bsosn1qB.mjs → docloader-dwostFF6.mjs} +102 -37
- package/dist/tests/{docloader-D5BTSARP.cjs → docloader-oZrKg7F3.cjs} +106 -35
- package/dist/tests/docloader.test.cjs +522 -1272
- package/dist/tests/docloader.test.mjs +468 -1237
- package/dist/tests/esm-CnLt0wAF.mjs +1225 -0
- package/dist/tests/esm-CxbqfkLP.cjs +1208 -0
- package/dist/tests/internal/multicodec.test.cjs +1 -1
- package/dist/tests/internal/multicodec.test.mjs +1 -1
- package/dist/tests/{key-BDIsC6hV.mjs → key-GEdpxA4M.mjs} +2 -2
- package/dist/tests/{key-BarKGLQz.cjs → key-L6ReMuUb.cjs} +2 -2
- package/dist/tests/key.test.cjs +2 -2
- package/dist/tests/key.test.mjs +2 -2
- package/dist/tests/{langstr-BsqFJupv.cjs → langstr-CZpWmpo5.cjs} +1 -1
- package/dist/tests/{langstr-ABdAOKlF.mjs → langstr-DTB4sl0a.mjs} +1 -1
- package/dist/tests/langstr.test.cjs +1 -1
- package/dist/tests/langstr.test.mjs +1 -1
- package/dist/tests/langtag.test.cjs +1 -1
- package/dist/tests/langtag.test.mjs +1 -1
- package/dist/tests/link.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/node-C3bjFjL1.mjs +84 -0
- package/dist/tests/node-DWD76vPo.cjs +90 -0
- package/dist/tests/pin-grant-CU-o367k.cjs +70 -0
- package/dist/tests/pin-grant-HW3B6SKv.mjs +53 -0
- package/dist/tests/pin-grant.test.cjs +88 -0
- package/dist/tests/pin-grant.test.d.cts +1 -0
- package/dist/tests/pin-grant.test.d.mts +1 -0
- package/dist/tests/pin-grant.test.mjs +88 -0
- package/dist/tests/pinners/bun.test.cjs +167 -0
- package/dist/tests/pinners/bun.test.d.cts +1 -0
- package/dist/tests/pinners/bun.test.d.mts +1 -0
- package/dist/tests/pinners/bun.test.mjs +167 -0
- package/dist/tests/pinners/node.test.cjs +269 -0
- package/dist/tests/pinners/node.test.d.cts +1 -0
- package/dist/tests/pinners/node.test.d.mts +1 -0
- package/dist/tests/pinners/node.test.mjs +268 -0
- package/dist/tests/pinners/pinners.test.cjs +197 -0
- package/dist/tests/pinners/pinners.test.d.cts +1 -0
- package/dist/tests/pinners/pinners.test.d.mts +1 -0
- package/dist/tests/pinners/pinners.test.mjs +197 -0
- package/dist/tests/pinners/testdata/node-child.cjs +135 -0
- package/dist/tests/pinners/testdata/node-child.d.cts +1 -0
- package/dist/tests/pinners/testdata/node-child.d.mts +1 -0
- package/dist/tests/pinners/testdata/node-child.mjs +134 -0
- package/dist/tests/pinners-BjE-YJLL.cjs +221 -0
- package/dist/tests/pinners-ZgZDx9y6.mjs +203 -0
- package/dist/tests/public-fetch-Ddjfxbwc.cjs +187 -0
- package/dist/tests/public-fetch-Yi7Vks9s.mjs +170 -0
- package/dist/tests/public-fetch.test.cjs +1074 -0
- package/dist/tests/public-fetch.test.d.cts +1 -0
- package/dist/tests/public-fetch.test.d.mts +1 -0
- package/dist/tests/public-fetch.test.mjs +1074 -0
- package/dist/tests/{request-hHQ_KvBF.cjs → request-CzYw8aEp.cjs} +1 -1
- package/dist/tests/{request-Bri8X69i.mjs → request-DY2AaRpH.mjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/dist/tests/support-D5-KVjWZ.cjs +363 -0
- package/dist/tests/support-M5ClN-no.mjs +272 -0
- package/dist/tests/{url-vZTgkIZg.cjs → url-DLuSj57U.cjs} +88 -12
- package/dist/tests/{url-3fyJuqC0.mjs → url-DQWrMGhu.mjs} +65 -13
- package/dist/tests/url.test.cjs +4 -1
- package/dist/tests/url.test.mjs +4 -1
- package/package.json +14 -3
- package/src/docloader.test.ts +696 -31
- package/src/docloader.ts +174 -67
- package/src/internal.ts +13 -0
- package/src/pin-grant.test.ts +118 -0
- package/src/pin-grant.ts +99 -0
- package/src/pinners/bun.test.ts +278 -0
- package/src/pinners/bun.ts +223 -0
- package/src/pinners/mod.ts +59 -0
- package/src/pinners/node.test.ts +415 -0
- package/src/pinners/node.ts +144 -0
- package/src/pinners/pinners.test.ts +316 -0
- package/src/pinners/testdata/node-child.ts +147 -0
- package/src/pinners/testdata/proxy-child.ts +82 -0
- package/src/pinners/testdata/support.ts +343 -0
- package/src/pinners/testdata/tls-cert.pem +12 -0
- package/src/pinners/testdata/tls-child.ts +88 -0
- package/src/pinners/testdata/tls-key.pem +5 -0
- package/src/pinners/types.ts +48 -0
- package/src/public-fetch.test.ts +1286 -0
- package/src/public-fetch.ts +338 -0
- package/src/testdata/public-fetch-deno-worker.ts +74 -0
- package/src/url.test.ts +11 -0
- package/src/url.ts +113 -22
- package/tsdown.config.ts +12 -3
- /package/dist/tests/{langtag-LDBqlxHv.mjs → langtag-D8FWxjv8.mjs} +0 -0
- /package/dist/tests/{langtag-DgySESmk.cjs → langtag-a2-s9uyi.cjs} +0 -0
- /package/dist/tests/{link-CYszIegt.mjs → link-CHMtH2-k.mjs} +0 -0
- /package/dist/tests/{multibase-8zhYPa7o.cjs → multibase-BmWaK56H.cjs} +0 -0
- /package/dist/tests/{multibase-Ds75BvXs.mjs → multibase-D642Uv3S.mjs} +0 -0
- /package/dist/tests/{multicodec-ByS9XLsw.cjs → multicodec-B-_CSt1M.cjs} +0 -0
- /package/dist/tests/{multicodec-BBPZjRfg.mjs → multicodec-caWdG98t.mjs} +0 -0
package/deno.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/vocab-runtime",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.31",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/mod.ts",
|
|
7
|
+
"./internal": "./src/internal.ts",
|
|
7
8
|
"./jsonld": "./src/jsonld.ts",
|
|
8
9
|
"./temporal": "./src/temporal.ts"
|
|
9
10
|
},
|
|
@@ -20,7 +21,8 @@
|
|
|
20
21
|
"byte-encodings": "npm:byte-encodings@^1.0.11",
|
|
21
22
|
"fetch-mock": "npm:fetch-mock@^12.5.4",
|
|
22
23
|
"jsonld": "npm:jsonld@^9.0.0",
|
|
23
|
-
"pkijs": "npm:pkijs@^3.2.5"
|
|
24
|
+
"pkijs": "npm:pkijs@^3.2.5",
|
|
25
|
+
"undici": "npm:undici@^7.30.1"
|
|
24
26
|
},
|
|
25
27
|
"exclude": [
|
|
26
28
|
"dist",
|
|
@@ -29,6 +31,7 @@
|
|
|
29
31
|
"publish": {
|
|
30
32
|
"exclude": [
|
|
31
33
|
"**/*.test.ts",
|
|
34
|
+
"src/**/testdata/",
|
|
32
35
|
"tsdown.config.ts"
|
|
33
36
|
]
|
|
34
37
|
},
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_public_fetch = require("./public-fetch-CFnW7XMn.cjs");
|
|
4
|
+
exports.openDirectFetch = require_public_fetch.openDirectFetch;
|
|
5
|
+
exports.openPublicFetch = require_public_fetch.openPublicFetch;
|
|
6
|
+
exports.withPublicFetch = require_public_fetch.withPublicFetch;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference lib="esnext.temporal" />
|
|
2
|
+
import { a as withPublicFetch, i as openPublicFetch, n as PublicFetchSession, r as openDirectFetch, t as PublicFetchOptions } from "./public-fetch-DBpt3xxf.cjs";
|
|
3
|
+
export { type PublicFetchOptions, type PublicFetchSession, openDirectFetch, openPublicFetch, withPublicFetch };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference lib="esnext.temporal" />
|
|
2
|
+
import { a as withPublicFetch, i as openPublicFetch, n as PublicFetchSession, r as openDirectFetch, t as PublicFetchOptions } from "./public-fetch-BC-nWJNM.js";
|
|
3
|
+
export { type PublicFetchOptions, type PublicFetchSession, openDirectFetch, openPublicFetch, withPublicFetch };
|
package/dist/internal.js
ADDED
package/dist/mod.cjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_chunk = require("./chunk-M78iaK0I.cjs");
|
|
4
|
+
const require_public_fetch = require("./public-fetch-CFnW7XMn.cjs");
|
|
4
5
|
let _logtape_logtape = require("@logtape/logtape");
|
|
5
6
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
6
7
|
let node_process = require("node:process");
|
|
7
8
|
node_process = require_chunk.__toESM(node_process);
|
|
8
|
-
let node_dns_promises = require("node:dns/promises");
|
|
9
|
-
node_dns_promises = require_chunk.__toESM(node_dns_promises);
|
|
10
|
-
let node_net = require("node:net");
|
|
11
9
|
let asn1js = require("asn1js");
|
|
12
10
|
let byte_encodings_base64 = require("byte-encodings/base64");
|
|
13
11
|
let byte_encodings_base64url = require("byte-encodings/base64url");
|
|
@@ -4593,7 +4591,7 @@ const preloadedContexts = {
|
|
|
4593
4591
|
//#endregion
|
|
4594
4592
|
//#region deno.json
|
|
4595
4593
|
var name = "@fedify/vocab-runtime";
|
|
4596
|
-
var version = "2.1.
|
|
4594
|
+
var version = "2.1.31";
|
|
4597
4595
|
//#endregion
|
|
4598
4596
|
//#region src/request.ts
|
|
4599
4597
|
/**
|
|
@@ -4920,216 +4918,6 @@ var HttpHeaderLink = class HttpHeaderLink {
|
|
|
4920
4918
|
}
|
|
4921
4919
|
};
|
|
4922
4920
|
//#endregion
|
|
4923
|
-
//#region src/url.ts
|
|
4924
|
-
var UrlError = class extends Error {
|
|
4925
|
-
/**
|
|
4926
|
-
* The failure category. Defaults to `"disallowed"`.
|
|
4927
|
-
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
4928
|
-
* @since 2.0.29
|
|
4929
|
-
*/
|
|
4930
|
-
reason;
|
|
4931
|
-
constructor(message, options) {
|
|
4932
|
-
super(message, options);
|
|
4933
|
-
this.name = "UrlError";
|
|
4934
|
-
this.reason = options?.reason ?? "disallowed";
|
|
4935
|
-
}
|
|
4936
|
-
};
|
|
4937
|
-
/**
|
|
4938
|
-
* Validates a URL to prevent SSRF attacks.
|
|
4939
|
-
*/
|
|
4940
|
-
async function validatePublicUrl(url) {
|
|
4941
|
-
const parsed = new URL(url);
|
|
4942
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsed.protocol}`);
|
|
4943
|
-
let hostname = parsed.hostname;
|
|
4944
|
-
if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.slice(1, -1);
|
|
4945
|
-
if (hostname === "localhost") throw new UrlError("Localhost is not allowed");
|
|
4946
|
-
const hostnameFamily = (0, node_net.isIP)(hostname);
|
|
4947
|
-
if (hostnameFamily !== 0) {
|
|
4948
|
-
validatePublicIpAddress(hostname, hostnameFamily);
|
|
4949
|
-
return;
|
|
4950
|
-
}
|
|
4951
|
-
if ("Deno" in globalThis && !(0, node_net.isIP)(hostname)) {
|
|
4952
|
-
if ((await Deno.permissions.query({ name: "net" })).state !== "granted") return;
|
|
4953
|
-
}
|
|
4954
|
-
if ("Bun" in globalThis) {
|
|
4955
|
-
if (hostname === "example.com" || hostname.endsWith(".example.com")) return;
|
|
4956
|
-
else if (hostname === "fedify-test.internal") throw new UrlError("Invalid or private address: fedify-test.internal");
|
|
4957
|
-
}
|
|
4958
|
-
let addresses;
|
|
4959
|
-
try {
|
|
4960
|
-
addresses = await node_dns_promises.default.lookup(hostname, { all: true });
|
|
4961
|
-
} catch (error) {
|
|
4962
|
-
throw new UrlError("DNS lookup failed", {
|
|
4963
|
-
cause: error,
|
|
4964
|
-
reason: "dns"
|
|
4965
|
-
});
|
|
4966
|
-
}
|
|
4967
|
-
validateLookupAddresses(addresses);
|
|
4968
|
-
}
|
|
4969
|
-
/**
|
|
4970
|
-
* Validates the IP addresses returned by `node:dns.lookup()`.
|
|
4971
|
-
*
|
|
4972
|
-
* Cloudflare Workers' `node:dns` implementation currently maps every record
|
|
4973
|
-
* in a DNS-over-HTTPS `Answer` array—including CNAME records—to a
|
|
4974
|
-
* `LookupAddress`, even though Node.js specifies that the `address` field must
|
|
4975
|
-
* contain an IPv4 or IPv6 literal. See:
|
|
4976
|
-
* https://github.com/cloudflare/workerd/issues/6886
|
|
4977
|
-
*
|
|
4978
|
-
* Work around that bug by ignoring non-IP entries only when the lookup also
|
|
4979
|
-
* returns at least one actual IP address. This remains fail-closed: a result
|
|
4980
|
-
* containing no IP addresses is rejected, and every returned IP address is
|
|
4981
|
-
* still validated and must be public. This workaround can be revisited once
|
|
4982
|
-
* the Workerd issue is fixed in supported Cloudflare Workers runtimes.
|
|
4983
|
-
*
|
|
4984
|
-
* @internal
|
|
4985
|
-
*/
|
|
4986
|
-
function validateLookupAddresses(addresses) {
|
|
4987
|
-
let ipAddressCount = 0;
|
|
4988
|
-
for (const { address } of addresses) {
|
|
4989
|
-
const family = (0, node_net.isIP)(address);
|
|
4990
|
-
if (family === 0) continue;
|
|
4991
|
-
ipAddressCount++;
|
|
4992
|
-
validatePublicIpAddress(address, family);
|
|
4993
|
-
}
|
|
4994
|
-
if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address", { reason: "dns" });
|
|
4995
|
-
}
|
|
4996
|
-
function validatePublicIpAddress(address, family) {
|
|
4997
|
-
if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
|
|
4998
|
-
throw new UrlError(`Invalid or private address: ${address}`);
|
|
4999
|
-
}
|
|
5000
|
-
function isValidPublicIPv4Address(address) {
|
|
5001
|
-
const parts = parseIPv4Address(address);
|
|
5002
|
-
if (parts == null) return false;
|
|
5003
|
-
const value = ipv4PartsToNumber(parts);
|
|
5004
|
-
return !nonPublicIPv4Prefixes.some(({ base, prefix }) => matchesIPv4Prefix(value, base, prefix));
|
|
5005
|
-
}
|
|
5006
|
-
function isValidPublicIPv6Address(address) {
|
|
5007
|
-
const words = parseIPv6Address(address);
|
|
5008
|
-
if (words == null) return false;
|
|
5009
|
-
if (nonPublicIPv6Prefixes.some(({ words: prefixWords, prefix }) => matchesIPv6Prefix(words, prefixWords, prefix))) return false;
|
|
5010
|
-
for (const { extractIPv4, prefix, words: prefixWords } of ipv6WithIPv4Prefixes) {
|
|
5011
|
-
if (!matchesIPv6Prefix(words, prefixWords, prefix)) continue;
|
|
5012
|
-
const ipv4Address = extractIPv4(words);
|
|
5013
|
-
if (ipv4Address != null && !isValidPublicIPv4Address(ipv4Address)) return false;
|
|
5014
|
-
}
|
|
5015
|
-
return true;
|
|
5016
|
-
}
|
|
5017
|
-
function expandIPv6Address(address) {
|
|
5018
|
-
address = address.toLowerCase();
|
|
5019
|
-
const ipv4Delimiter = address.lastIndexOf(":");
|
|
5020
|
-
if (address.includes(".") && ipv4Delimiter >= 0) {
|
|
5021
|
-
const ipv4Parts = parseIPv4Address(address.substring(ipv4Delimiter + 1));
|
|
5022
|
-
if (ipv4Parts == null) return address;
|
|
5023
|
-
const high = (ipv4Parts[0] << 8) + ipv4Parts[1];
|
|
5024
|
-
const low = (ipv4Parts[2] << 8) + ipv4Parts[3];
|
|
5025
|
-
address = address.substring(0, ipv4Delimiter + 1) + high.toString(16) + ":" + low.toString(16);
|
|
5026
|
-
}
|
|
5027
|
-
if (address === "::") return "0000:0000:0000:0000:0000:0000:0000:0000";
|
|
5028
|
-
if (address.startsWith("::")) address = "0000" + address;
|
|
5029
|
-
if (address.endsWith("::")) address = address + "0000";
|
|
5030
|
-
address = address.replace("::", ":0000".repeat(8 - (address.match(/:/g) || []).length) + ":");
|
|
5031
|
-
return address.split(":").map((part) => part.padStart(4, "0")).join(":");
|
|
5032
|
-
}
|
|
5033
|
-
const nonPublicIPv4Prefixes = [
|
|
5034
|
-
ipv4Prefix("0.0.0.0/8", "RFC 6890"),
|
|
5035
|
-
ipv4Prefix("10.0.0.0/8", "RFC 1918"),
|
|
5036
|
-
ipv4Prefix("100.64.0.0/10", "RFC 6598"),
|
|
5037
|
-
ipv4Prefix("127.0.0.0/8", "RFC 1122"),
|
|
5038
|
-
ipv4Prefix("169.254.0.0/16", "RFC 3927"),
|
|
5039
|
-
ipv4Prefix("172.16.0.0/12", "RFC 1918"),
|
|
5040
|
-
ipv4Prefix("192.0.0.0/24", "RFC 6890"),
|
|
5041
|
-
ipv4Prefix("192.0.2.0/24", "RFC 5737"),
|
|
5042
|
-
ipv4Prefix("192.88.99.0/24", "RFC 7526"),
|
|
5043
|
-
ipv4Prefix("192.168.0.0/16", "RFC 1918"),
|
|
5044
|
-
ipv4Prefix("198.18.0.0/15", "RFC 2544"),
|
|
5045
|
-
ipv4Prefix("198.51.100.0/24", "RFC 5737"),
|
|
5046
|
-
ipv4Prefix("203.0.113.0/24", "RFC 5737"),
|
|
5047
|
-
ipv4Prefix("224.0.0.0/4", "RFC 5771"),
|
|
5048
|
-
ipv4Prefix("240.0.0.0/4", "RFC 1112")
|
|
5049
|
-
];
|
|
5050
|
-
const nonPublicIPv6Prefixes = [
|
|
5051
|
-
ipv6Prefix("::/16", "RFC 4291"),
|
|
5052
|
-
ipv6Prefix("2001::/32", "RFC 4380"),
|
|
5053
|
-
ipv6Prefix("2002::/16", "RFC 3056"),
|
|
5054
|
-
ipv6Prefix("64:ff9b:1::/48", "RFC 8215"),
|
|
5055
|
-
ipv6Prefix("fc00::/7", "RFC 4193"),
|
|
5056
|
-
ipv6Prefix("fe80::/10", "RFC 4291"),
|
|
5057
|
-
ipv6Prefix("ff00::/8", "RFC 4291")
|
|
5058
|
-
];
|
|
5059
|
-
const ipv6WithIPv4Prefixes = [{
|
|
5060
|
-
...ipv6Prefix("64:ff9b::/96", "RFC 6052"),
|
|
5061
|
-
extractIPv4: (words) => ipv4FromWords(words[6], words[7])
|
|
5062
|
-
}];
|
|
5063
|
-
function ipv4Prefix(cidr, rfc) {
|
|
5064
|
-
const [address, prefixText] = cidr.split("/");
|
|
5065
|
-
const prefix = parseInt(prefixText, 10);
|
|
5066
|
-
const parts = parseIPv4Address(address);
|
|
5067
|
-
if (parts == null || !Number.isInteger(prefix) || prefix < 0 || prefix > 32) throw new Error(`Invalid IPv4 prefix: ${cidr}`);
|
|
5068
|
-
return {
|
|
5069
|
-
cidr,
|
|
5070
|
-
base: ipv4PartsToNumber(parts),
|
|
5071
|
-
prefix,
|
|
5072
|
-
rfc
|
|
5073
|
-
};
|
|
5074
|
-
}
|
|
5075
|
-
function ipv6Prefix(cidr, rfc) {
|
|
5076
|
-
const [address, prefixText] = cidr.split("/");
|
|
5077
|
-
const prefix = parseInt(prefixText, 10);
|
|
5078
|
-
const words = parseIPv6Address(address);
|
|
5079
|
-
if (words == null || !Number.isInteger(prefix) || prefix < 0 || prefix > 128) throw new Error(`Invalid IPv6 prefix: ${cidr}`);
|
|
5080
|
-
return {
|
|
5081
|
-
cidr,
|
|
5082
|
-
words,
|
|
5083
|
-
prefix,
|
|
5084
|
-
rfc
|
|
5085
|
-
};
|
|
5086
|
-
}
|
|
5087
|
-
function parseIPv4Address(address) {
|
|
5088
|
-
const parts = address.split(".").map((part) => {
|
|
5089
|
-
if (!/^\d+$/.test(part)) return NaN;
|
|
5090
|
-
return parseInt(part, 10);
|
|
5091
|
-
});
|
|
5092
|
-
if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) return null;
|
|
5093
|
-
return parts;
|
|
5094
|
-
}
|
|
5095
|
-
function parseIPv6Address(address) {
|
|
5096
|
-
const parts = expandIPv6Address(address).split(":");
|
|
5097
|
-
if (parts.length !== 8) return null;
|
|
5098
|
-
const words = parts.map((part) => {
|
|
5099
|
-
if (!/^[0-9a-f]{1,4}$/i.test(part)) return NaN;
|
|
5100
|
-
return parseInt(part, 16);
|
|
5101
|
-
});
|
|
5102
|
-
if (words.some((word) => !Number.isInteger(word) || word < 0 || word > 65535)) return null;
|
|
5103
|
-
return words;
|
|
5104
|
-
}
|
|
5105
|
-
function ipv4PartsToNumber(parts) {
|
|
5106
|
-
return parts[0] * 2 ** 24 + parts[1] * 2 ** 16 + parts[2] * 2 ** 8 + parts[3];
|
|
5107
|
-
}
|
|
5108
|
-
function ipv4FromWords(highWord, lowWord) {
|
|
5109
|
-
return [
|
|
5110
|
-
highWord >> 8,
|
|
5111
|
-
highWord & 255,
|
|
5112
|
-
lowWord >> 8,
|
|
5113
|
-
lowWord & 255
|
|
5114
|
-
].join(".");
|
|
5115
|
-
}
|
|
5116
|
-
function matchesIPv4Prefix(address, prefixBase, prefixLength) {
|
|
5117
|
-
const blockSize = 2 ** (32 - prefixLength);
|
|
5118
|
-
return Math.floor(address / blockSize) === Math.floor(prefixBase / blockSize);
|
|
5119
|
-
}
|
|
5120
|
-
function matchesIPv6Prefix(address, prefixWords, prefixLength) {
|
|
5121
|
-
let remaining = prefixLength;
|
|
5122
|
-
for (let i = 0; i < 8 && remaining > 0; i++) if (remaining >= 16) {
|
|
5123
|
-
if (address[i] !== prefixWords[i]) return false;
|
|
5124
|
-
remaining -= 16;
|
|
5125
|
-
} else {
|
|
5126
|
-
const mask = 65535 << 16 - remaining & 65535;
|
|
5127
|
-
if ((address[i] & mask) !== (prefixWords[i] & mask)) return false;
|
|
5128
|
-
remaining = 0;
|
|
5129
|
-
}
|
|
5130
|
-
return true;
|
|
5131
|
-
}
|
|
5132
|
-
//#endregion
|
|
5133
4921
|
//#region src/docloader.ts
|
|
5134
4922
|
const logger = (0, _logtape_logtape.getLogger)([
|
|
5135
4923
|
"fedify",
|
|
@@ -5141,13 +4929,47 @@ const DEFAULT_MAX_REDIRECTION = 20;
|
|
|
5141
4929
|
* Gets a {@link RemoteDocument} from the given response.
|
|
5142
4930
|
* @param url The URL of the document to load.
|
|
5143
4931
|
* @param response The response to get the document from.
|
|
5144
|
-
* @param fetch The function to fetch the document.
|
|
4932
|
+
* @param fetch The function to fetch the document. It is called with the URL
|
|
4933
|
+
* of an alternate document, if any, after the response body has
|
|
4934
|
+
* been either read or its cancellation has been started.
|
|
5145
4935
|
* @returns The loaded remote document.
|
|
5146
4936
|
* @throws {FetchError} If the response is not OK.
|
|
5147
4937
|
* @internal
|
|
5148
4938
|
*/
|
|
5149
4939
|
async function getRemoteDocument(url, response, fetch) {
|
|
5150
|
-
const
|
|
4940
|
+
const result = await parseRemoteDocument(url, response);
|
|
4941
|
+
if ("alternate" in result) return await fetch(result.alternate);
|
|
4942
|
+
return result.document;
|
|
4943
|
+
}
|
|
4944
|
+
/**
|
|
4945
|
+
* Starts cancelling the body of a response without waiting for it to settle.
|
|
4946
|
+
* The cancellation of a branch of a tee (e.g., a body cloned by a fetch mock)
|
|
4947
|
+
* settles only after the other branch is cancelled too, per the Streams
|
|
4948
|
+
* standard, so awaiting it could block forever. Failures are only logged.
|
|
4949
|
+
* @param response The response whose body is cancelled.
|
|
4950
|
+
* @param url The URL of the response, for logging.
|
|
4951
|
+
*/
|
|
4952
|
+
function cancelResponseBody(response, url) {
|
|
4953
|
+
response.body?.cancel().catch((error) => {
|
|
4954
|
+
logger.debug("Failed to cancel the response body from {url}: {error}", {
|
|
4955
|
+
url,
|
|
4956
|
+
error
|
|
4957
|
+
});
|
|
4958
|
+
});
|
|
4959
|
+
}
|
|
4960
|
+
/**
|
|
4961
|
+
* Gets a {@link RemoteDocument} from the given response, or the URL of an
|
|
4962
|
+
* alternate document to load instead. When an alternate document is found,
|
|
4963
|
+
* the response body has been either read or its cancellation has been started
|
|
4964
|
+
* (without waiting for it), so that the alternate document can be loaded after
|
|
4965
|
+
* the response's session is closed.
|
|
4966
|
+
* @param url The URL of the document to load.
|
|
4967
|
+
* @param response The response to get the document from.
|
|
4968
|
+
* @returns The loaded remote document, or the alternate document URL.
|
|
4969
|
+
* @throws {FetchError} If the response is not OK.
|
|
4970
|
+
*/
|
|
4971
|
+
async function parseRemoteDocument(url, response) {
|
|
4972
|
+
const documentUrl = url;
|
|
5151
4973
|
const docUrl = new URL(documentUrl);
|
|
5152
4974
|
if (!response.ok) {
|
|
5153
4975
|
logger.error("Failed to fetch document: {status} {url} {headers}", {
|
|
@@ -5184,7 +5006,8 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
5184
5006
|
alternateUrl: altUri.href,
|
|
5185
5007
|
url: documentUrl
|
|
5186
5008
|
});
|
|
5187
|
-
|
|
5009
|
+
cancelResponseBody(response, documentUrl);
|
|
5010
|
+
return { alternate: altUri.href };
|
|
5188
5011
|
}
|
|
5189
5012
|
}
|
|
5190
5013
|
}
|
|
@@ -5209,7 +5032,7 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
5209
5032
|
alternateUrl: attribs.href,
|
|
5210
5033
|
url: documentUrl
|
|
5211
5034
|
});
|
|
5212
|
-
return
|
|
5035
|
+
return { alternate: new URL(attribs.href, docUrl).href };
|
|
5213
5036
|
}
|
|
5214
5037
|
}
|
|
5215
5038
|
document = JSON.parse(html);
|
|
@@ -5219,11 +5042,11 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
5219
5042
|
url: documentUrl,
|
|
5220
5043
|
headers: Object.fromEntries(response.headers.entries())
|
|
5221
5044
|
});
|
|
5222
|
-
return {
|
|
5045
|
+
return { document: {
|
|
5223
5046
|
contextUrl,
|
|
5224
5047
|
document,
|
|
5225
5048
|
documentUrl
|
|
5226
|
-
};
|
|
5049
|
+
} };
|
|
5227
5050
|
}
|
|
5228
5051
|
/**
|
|
5229
5052
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
@@ -5249,13 +5072,58 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
5249
5072
|
* @returns The document loader.
|
|
5250
5073
|
* @since 1.3.0
|
|
5251
5074
|
*/
|
|
5252
|
-
function getDocumentLoader(
|
|
5075
|
+
function getDocumentLoader(options = {}) {
|
|
5076
|
+
return createDocumentLoader(options);
|
|
5077
|
+
}
|
|
5078
|
+
/**
|
|
5079
|
+
* The implementation of {@link getDocumentLoader}, with injectable
|
|
5080
|
+
* dependencies. This is not exported from any entry point.
|
|
5081
|
+
* @param options Options for the document loader.
|
|
5082
|
+
* @param deps The dependencies.
|
|
5083
|
+
* @returns The document loader.
|
|
5084
|
+
*/
|
|
5085
|
+
function createDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAgent } = {}, deps = {}) {
|
|
5253
5086
|
const tracer = _opentelemetry_api.trace.getTracerProvider().getTracer(name, version);
|
|
5087
|
+
async function openHop(url, signal) {
|
|
5088
|
+
try {
|
|
5089
|
+
if (deps.openHop != null) return await deps.openHop(url);
|
|
5090
|
+
return allowPrivateAddress ? await require_public_fetch.openDirectFetch(url) : await require_public_fetch.openPublicFetch(url, { signal });
|
|
5091
|
+
} catch (error) {
|
|
5092
|
+
if (error instanceof require_public_fetch.UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
|
|
5093
|
+
url,
|
|
5094
|
+
error
|
|
5095
|
+
});
|
|
5096
|
+
else logger.error("Disallowed private URL: {url}", {
|
|
5097
|
+
url,
|
|
5098
|
+
error
|
|
5099
|
+
});
|
|
5100
|
+
throw error;
|
|
5101
|
+
}
|
|
5102
|
+
}
|
|
5103
|
+
async function fetchHop(session, url, span, options) {
|
|
5104
|
+
try {
|
|
5105
|
+
const request = createActivityPubRequest(url, { userAgent });
|
|
5106
|
+
logRequest(logger, request);
|
|
5107
|
+
const response = await session.fetch(request, {
|
|
5108
|
+
redirect: "manual",
|
|
5109
|
+
signal: options?.signal
|
|
5110
|
+
});
|
|
5111
|
+
span.setAttribute("http.response.status_code", response.status);
|
|
5112
|
+
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
5113
|
+
const location = response.headers.get("Location");
|
|
5114
|
+
cancelResponseBody(response, url);
|
|
5115
|
+
return { location };
|
|
5116
|
+
}
|
|
5117
|
+
return await parseRemoteDocument(url, response);
|
|
5118
|
+
} finally {
|
|
5119
|
+
await session.close();
|
|
5120
|
+
}
|
|
5121
|
+
}
|
|
5254
5122
|
async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
|
|
5255
5123
|
options?.signal?.throwIfAborted();
|
|
5256
5124
|
const parsedUrl = new URL(url);
|
|
5257
|
-
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsedUrl.protocol}`);
|
|
5258
|
-
if (parsedUrl.username !== "" || parsedUrl.password !== "") throw new UrlError("URLs with credentials are not allowed");
|
|
5125
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new require_public_fetch.UrlError(`Unsupported protocol: ${parsedUrl.protocol}`);
|
|
5126
|
+
if (parsedUrl.username !== "" || parsedUrl.password !== "") throw new require_public_fetch.UrlError("URLs with credentials are not allowed");
|
|
5259
5127
|
const currentUrl = parsedUrl.href;
|
|
5260
5128
|
if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
|
|
5261
5129
|
logger.debug("Using preloaded context: {url}.", { url: currentUrl });
|
|
@@ -5265,33 +5133,15 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5265
5133
|
documentUrl: currentUrl
|
|
5266
5134
|
};
|
|
5267
5135
|
}
|
|
5268
|
-
|
|
5269
|
-
await validatePublicUrl(currentUrl);
|
|
5270
|
-
} catch (error) {
|
|
5271
|
-
if (error instanceof UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
|
|
5272
|
-
url: currentUrl,
|
|
5273
|
-
error
|
|
5274
|
-
});
|
|
5275
|
-
else logger.error("Disallowed private URL: {url}", {
|
|
5276
|
-
url: currentUrl,
|
|
5277
|
-
error
|
|
5278
|
-
});
|
|
5279
|
-
throw error;
|
|
5280
|
-
}
|
|
5136
|
+
const session = await openHop(currentUrl, options?.signal);
|
|
5281
5137
|
visited.add(currentUrl);
|
|
5282
5138
|
return await tracer.startActiveSpan("activitypub.fetch_document", {
|
|
5283
5139
|
kind: _opentelemetry_api.SpanKind.CLIENT,
|
|
5284
5140
|
attributes: { "url.full": currentUrl }
|
|
5285
5141
|
}, async (span) => {
|
|
5286
5142
|
try {
|
|
5287
|
-
const
|
|
5288
|
-
|
|
5289
|
-
const response = await fetch(request, {
|
|
5290
|
-
redirect: "manual",
|
|
5291
|
-
signal: options?.signal
|
|
5292
|
-
});
|
|
5293
|
-
span.setAttribute("http.response.status_code", response.status);
|
|
5294
|
-
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
5143
|
+
const outcome = await fetchHop(session, currentUrl, span, options);
|
|
5144
|
+
if ("location" in outcome) {
|
|
5295
5145
|
if (redirected >= DEFAULT_MAX_REDIRECTION) {
|
|
5296
5146
|
logger.error("Too many redirections ({redirections}) while fetching document.", {
|
|
5297
5147
|
redirections: redirected + 1,
|
|
@@ -5299,7 +5149,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5299
5149
|
});
|
|
5300
5150
|
throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
5301
5151
|
}
|
|
5302
|
-
const redirectUrl = new URL(
|
|
5152
|
+
const redirectUrl = new URL(outcome.location, currentUrl).href;
|
|
5303
5153
|
span.setAttribute("http.redirect.url", redirectUrl);
|
|
5304
5154
|
if (visited.has(redirectUrl)) {
|
|
5305
5155
|
logger.error("Detected a redirect loop while fetching document: {url} -> {redirectUrl}", {
|
|
@@ -5310,12 +5160,14 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5310
5160
|
}
|
|
5311
5161
|
return await load(redirectUrl, options, redirected + 1, visited);
|
|
5312
5162
|
}
|
|
5313
|
-
|
|
5163
|
+
let result;
|
|
5164
|
+
if ("alternate" in outcome) {
|
|
5165
|
+
const alternateUrl = outcome.alternate;
|
|
5314
5166
|
options?.signal?.throwIfAborted();
|
|
5315
5167
|
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
5316
5168
|
if (visited.has(alternateUrl)) throw new FetchError(currentUrl, `Redirect loop detected: ${alternateUrl}`);
|
|
5317
|
-
|
|
5318
|
-
}
|
|
5169
|
+
result = await load(alternateUrl, options, redirected + 1, visited);
|
|
5170
|
+
} else result = outcome.document;
|
|
5319
5171
|
span.setAttribute("docloader.document_url", result.documentUrl);
|
|
5320
5172
|
if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
|
|
5321
5173
|
return result;
|
|
@@ -5979,13 +5831,13 @@ LanguageString.prototype[Symbol.for("nodejs.util.inspect.custom")] = function(_d
|
|
|
5979
5831
|
//#endregion
|
|
5980
5832
|
exports.FetchError = FetchError;
|
|
5981
5833
|
exports.LanguageString = LanguageString;
|
|
5982
|
-
exports.UrlError = UrlError;
|
|
5834
|
+
exports.UrlError = require_public_fetch.UrlError;
|
|
5983
5835
|
exports.canParseDecimal = canParseDecimal;
|
|
5984
5836
|
exports.createActivityPubRequest = createActivityPubRequest;
|
|
5985
5837
|
exports.decodeMultibase = decodeMultibase;
|
|
5986
5838
|
exports.encodeMultibase = encodeMultibase;
|
|
5987
5839
|
exports.encodingFromBaseData = encodingFromBaseData;
|
|
5988
|
-
exports.expandIPv6Address = expandIPv6Address;
|
|
5840
|
+
exports.expandIPv6Address = require_public_fetch.expandIPv6Address;
|
|
5989
5841
|
exports.exportMultibaseKey = exportMultibaseKey;
|
|
5990
5842
|
exports.exportSpki = exportSpki;
|
|
5991
5843
|
exports.getDocumentLoader = getDocumentLoader;
|
|
@@ -5996,10 +5848,10 @@ exports.importPem = importPem;
|
|
|
5996
5848
|
exports.importPkcs1 = importPkcs1;
|
|
5997
5849
|
exports.importSpki = importSpki;
|
|
5998
5850
|
exports.isDecimal = isDecimal;
|
|
5999
|
-
exports.isValidPublicIPv4Address = isValidPublicIPv4Address;
|
|
6000
|
-
exports.isValidPublicIPv6Address = isValidPublicIPv6Address;
|
|
5851
|
+
exports.isValidPublicIPv4Address = require_public_fetch.isValidPublicIPv4Address;
|
|
5852
|
+
exports.isValidPublicIPv6Address = require_public_fetch.isValidPublicIPv6Address;
|
|
6001
5853
|
exports.logRequest = logRequest;
|
|
6002
5854
|
exports.normalizeLanguageTag = normalizeLanguageTag;
|
|
6003
5855
|
exports.parseDecimal = parseDecimal;
|
|
6004
5856
|
exports.preloadedContexts = preloadedContexts;
|
|
6005
|
-
exports.validatePublicUrl = validatePublicUrl;
|
|
5857
|
+
exports.validatePublicUrl = require_public_fetch.validatePublicUrl;
|
package/dist/mod.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
+
import { c as isValidPublicIPv4Address, l as isValidPublicIPv6Address, o as UrlError, s as expandIPv6Address, u as validatePublicUrl } from "./public-fetch-DBpt3xxf.cjs";
|
|
2
3
|
import { Logger } from "@logtape/logtape";
|
|
3
4
|
|
|
4
5
|
//#region src/contexts.d.ts
|
|
@@ -156,7 +157,9 @@ type AuthenticatedDocumentLoaderFactory = (identity: {
|
|
|
156
157
|
* Gets a {@link RemoteDocument} from the given response.
|
|
157
158
|
* @param url The URL of the document to load.
|
|
158
159
|
* @param response The response to get the document from.
|
|
159
|
-
* @param fetch The function to fetch the document.
|
|
160
|
+
* @param fetch The function to fetch the document. It is called with the URL
|
|
161
|
+
* of an alternate document, if any, after the response body has
|
|
162
|
+
* been either read or its cancellation has been started.
|
|
160
163
|
* @returns The loaded remote document.
|
|
161
164
|
* @throws {FetchError} If the response is not OK.
|
|
162
165
|
* @internal
|
|
@@ -196,11 +199,7 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
|
196
199
|
* @returns The document loader.
|
|
197
200
|
* @since 1.3.0
|
|
198
201
|
*/
|
|
199
|
-
declare function getDocumentLoader(
|
|
200
|
-
allowPrivateAddress,
|
|
201
|
-
skipPreloadedContexts,
|
|
202
|
-
userAgent
|
|
203
|
-
}?: GetDocumentLoaderOptions): DocumentLoader;
|
|
202
|
+
declare function getDocumentLoader(options?: GetDocumentLoaderOptions): DocumentLoader;
|
|
204
203
|
//#endregion
|
|
205
204
|
//#region src/key.d.ts
|
|
206
205
|
/**
|
|
@@ -448,25 +447,4 @@ declare function decodeMultibase(data: Uint8Array | string): Uint8Array;
|
|
|
448
447
|
*/
|
|
449
448
|
declare function encodingFromBaseData(data: string | Uint8Array): Base;
|
|
450
449
|
//#endregion
|
|
451
|
-
//#region src/url.d.ts
|
|
452
|
-
declare class UrlError extends Error {
|
|
453
|
-
/**
|
|
454
|
-
* The failure category. Defaults to `"disallowed"`.
|
|
455
|
-
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
456
|
-
* @since 2.0.29
|
|
457
|
-
*/
|
|
458
|
-
readonly reason: "dns" | "disallowed";
|
|
459
|
-
constructor(message: string, options?: {
|
|
460
|
-
cause?: unknown;
|
|
461
|
-
reason?: "dns" | "disallowed";
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
/**
|
|
465
|
-
* Validates a URL to prevent SSRF attacks.
|
|
466
|
-
*/
|
|
467
|
-
declare function validatePublicUrl(url: string): Promise<void>;
|
|
468
|
-
declare function isValidPublicIPv4Address(address: string): boolean;
|
|
469
|
-
declare function isValidPublicIPv6Address(address: string): boolean;
|
|
470
|
-
declare function expandIPv6Address(address: string): string;
|
|
471
|
-
//#endregion
|
|
472
450
|
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, LanguageString, type RemoteDocument, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, normalizeLanguageTag, parseDecimal, preloadedContexts, validatePublicUrl };
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
+
import { c as isValidPublicIPv4Address, l as isValidPublicIPv6Address, o as UrlError, s as expandIPv6Address, u as validatePublicUrl } from "./public-fetch-BC-nWJNM.js";
|
|
2
3
|
import { Logger } from "@logtape/logtape";
|
|
4
|
+
|
|
3
5
|
//#region src/contexts.d.ts
|
|
4
6
|
declare const preloadedContexts: Record<string, unknown>;
|
|
5
7
|
//#endregion
|
|
@@ -155,7 +157,9 @@ type AuthenticatedDocumentLoaderFactory = (identity: {
|
|
|
155
157
|
* Gets a {@link RemoteDocument} from the given response.
|
|
156
158
|
* @param url The URL of the document to load.
|
|
157
159
|
* @param response The response to get the document from.
|
|
158
|
-
* @param fetch The function to fetch the document.
|
|
160
|
+
* @param fetch The function to fetch the document. It is called with the URL
|
|
161
|
+
* of an alternate document, if any, after the response body has
|
|
162
|
+
* been either read or its cancellation has been started.
|
|
159
163
|
* @returns The loaded remote document.
|
|
160
164
|
* @throws {FetchError} If the response is not OK.
|
|
161
165
|
* @internal
|
|
@@ -195,11 +199,7 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
|
195
199
|
* @returns The document loader.
|
|
196
200
|
* @since 1.3.0
|
|
197
201
|
*/
|
|
198
|
-
declare function getDocumentLoader(
|
|
199
|
-
allowPrivateAddress,
|
|
200
|
-
skipPreloadedContexts,
|
|
201
|
-
userAgent
|
|
202
|
-
}?: GetDocumentLoaderOptions): DocumentLoader;
|
|
202
|
+
declare function getDocumentLoader(options?: GetDocumentLoaderOptions): DocumentLoader;
|
|
203
203
|
//#endregion
|
|
204
204
|
//#region src/key.d.ts
|
|
205
205
|
/**
|
|
@@ -447,25 +447,4 @@ declare function decodeMultibase(data: Uint8Array | string): Uint8Array;
|
|
|
447
447
|
*/
|
|
448
448
|
declare function encodingFromBaseData(data: string | Uint8Array): Base;
|
|
449
449
|
//#endregion
|
|
450
|
-
//#region src/url.d.ts
|
|
451
|
-
declare class UrlError extends Error {
|
|
452
|
-
/**
|
|
453
|
-
* The failure category. Defaults to `"disallowed"`.
|
|
454
|
-
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
455
|
-
* @since 2.0.29
|
|
456
|
-
*/
|
|
457
|
-
readonly reason: "dns" | "disallowed";
|
|
458
|
-
constructor(message: string, options?: {
|
|
459
|
-
cause?: unknown;
|
|
460
|
-
reason?: "dns" | "disallowed";
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Validates a URL to prevent SSRF attacks.
|
|
465
|
-
*/
|
|
466
|
-
declare function validatePublicUrl(url: string): Promise<void>;
|
|
467
|
-
declare function isValidPublicIPv4Address(address: string): boolean;
|
|
468
|
-
declare function isValidPublicIPv6Address(address: string): boolean;
|
|
469
|
-
declare function expandIPv6Address(address: string): string;
|
|
470
|
-
//#endregion
|
|
471
450
|
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type Decimal, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, LanguageString, type RemoteDocument, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, normalizeLanguageTag, parseDecimal, preloadedContexts, validatePublicUrl };
|