@fedify/vocab-runtime 2.0.15-dev.968 → 2.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +1 -1
- package/dist/mod.cjs +12 -3
- package/dist/mod.js +12 -3
- package/dist/tests/docloader.test.cjs +2 -2
- package/dist/tests/docloader.test.mjs +2 -2
- package/dist/tests/{request-Ctw3lfiw.cjs → request-BfzoFjgp.cjs} +1 -1
- package/dist/tests/{request-CTFdvbMz.mjs → request-DEVBwfjq.mjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/dist/tests/{url-Djghaq0m.mjs → url-DftNtd3d.mjs} +11 -2
- package/dist/tests/{url-Cr2K-wzd.cjs → url-SR63sukb.cjs} +11 -2
- package/dist/tests/url.test.cjs +4 -1
- package/dist/tests/url.test.mjs +4 -1
- package/package.json +1 -1
- package/src/url.test.ts +6 -0
- package/src/url.ts +17 -8
package/deno.json
CHANGED
package/dist/mod.cjs
CHANGED
|
@@ -4294,7 +4294,7 @@ const preloadedContexts = {
|
|
|
4294
4294
|
//#endregion
|
|
4295
4295
|
//#region deno.json
|
|
4296
4296
|
var name = "@fedify/vocab-runtime";
|
|
4297
|
-
var version = "2.0.
|
|
4297
|
+
var version = "2.0.16";
|
|
4298
4298
|
//#endregion
|
|
4299
4299
|
//#region src/link.ts
|
|
4300
4300
|
const parametersNeedLowerCase = ["rel", "type"];
|
|
@@ -4555,8 +4555,13 @@ async function validatePublicUrl(url) {
|
|
|
4555
4555
|
const parsed = new URL(url);
|
|
4556
4556
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsed.protocol}`);
|
|
4557
4557
|
let hostname = parsed.hostname;
|
|
4558
|
-
if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.
|
|
4558
|
+
if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.slice(1, -1);
|
|
4559
4559
|
if (hostname === "localhost") throw new UrlError("Localhost is not allowed");
|
|
4560
|
+
const hostnameFamily = (0, node_net.isIP)(hostname);
|
|
4561
|
+
if (hostnameFamily !== 0) {
|
|
4562
|
+
validatePublicIpAddress(hostname, hostnameFamily);
|
|
4563
|
+
return;
|
|
4564
|
+
}
|
|
4560
4565
|
if ("Deno" in globalThis && !(0, node_net.isIP)(hostname)) {
|
|
4561
4566
|
if ((await Deno.permissions.query({ name: "net" })).state !== "granted") return;
|
|
4562
4567
|
}
|
|
@@ -4570,7 +4575,11 @@ async function validatePublicUrl(url) {
|
|
|
4570
4575
|
} catch {
|
|
4571
4576
|
addresses = [];
|
|
4572
4577
|
}
|
|
4573
|
-
for (const { address, family } of addresses)
|
|
4578
|
+
for (const { address, family } of addresses) validatePublicIpAddress(address, family);
|
|
4579
|
+
}
|
|
4580
|
+
function validatePublicIpAddress(address, family) {
|
|
4581
|
+
if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
|
|
4582
|
+
throw new UrlError(`Invalid or private address: ${address}`);
|
|
4574
4583
|
}
|
|
4575
4584
|
function isValidPublicIPv4Address(address) {
|
|
4576
4585
|
const parts = address.split(".");
|
package/dist/mod.js
CHANGED
|
@@ -4290,7 +4290,7 @@ const preloadedContexts = {
|
|
|
4290
4290
|
//#endregion
|
|
4291
4291
|
//#region deno.json
|
|
4292
4292
|
var name = "@fedify/vocab-runtime";
|
|
4293
|
-
var version = "2.0.
|
|
4293
|
+
var version = "2.0.16";
|
|
4294
4294
|
//#endregion
|
|
4295
4295
|
//#region src/link.ts
|
|
4296
4296
|
const parametersNeedLowerCase = ["rel", "type"];
|
|
@@ -4551,8 +4551,13 @@ async function validatePublicUrl(url) {
|
|
|
4551
4551
|
const parsed = new URL(url);
|
|
4552
4552
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsed.protocol}`);
|
|
4553
4553
|
let hostname = parsed.hostname;
|
|
4554
|
-
if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.
|
|
4554
|
+
if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.slice(1, -1);
|
|
4555
4555
|
if (hostname === "localhost") throw new UrlError("Localhost is not allowed");
|
|
4556
|
+
const hostnameFamily = isIP(hostname);
|
|
4557
|
+
if (hostnameFamily !== 0) {
|
|
4558
|
+
validatePublicIpAddress(hostname, hostnameFamily);
|
|
4559
|
+
return;
|
|
4560
|
+
}
|
|
4556
4561
|
if ("Deno" in globalThis && !isIP(hostname)) {
|
|
4557
4562
|
if ((await Deno.permissions.query({ name: "net" })).state !== "granted") return;
|
|
4558
4563
|
}
|
|
@@ -4566,7 +4571,11 @@ async function validatePublicUrl(url) {
|
|
|
4566
4571
|
} catch {
|
|
4567
4572
|
addresses = [];
|
|
4568
4573
|
}
|
|
4569
|
-
for (const { address, family } of addresses)
|
|
4574
|
+
for (const { address, family } of addresses) validatePublicIpAddress(address, family);
|
|
4575
|
+
}
|
|
4576
|
+
function validatePublicIpAddress(address, family) {
|
|
4577
|
+
if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
|
|
4578
|
+
throw new UrlError(`Invalid or private address: ${address}`);
|
|
4570
4579
|
}
|
|
4571
4580
|
function isValidPublicIPv4Address(address) {
|
|
4572
4581
|
const parts = address.split(".");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-BfzoFjgp.cjs");
|
|
3
3
|
const require_link = require("./link-B6ZWBZhf.cjs");
|
|
4
|
-
const require_url = require("./url-
|
|
4
|
+
const require_url = require("./url-SR63sukb.cjs");
|
|
5
5
|
let node_assert = require("node:assert");
|
|
6
6
|
let node_test = require("node:test");
|
|
7
7
|
let _logtape_logtape = require("@logtape/logtape");
|
|
@@ -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-DEVBwfjq.mjs";
|
|
2
2
|
import { t as HttpHeaderLink } from "./link-B8JGXSS2.mjs";
|
|
3
|
-
import { a as validatePublicUrl, t as UrlError } from "./url-
|
|
3
|
+
import { a as validatePublicUrl, t as UrlError } from "./url-DftNtd3d.mjs";
|
|
4
4
|
import { deepStrictEqual, ok, rejects } from "node:assert";
|
|
5
5
|
import { test } from "node:test";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -3,7 +3,7 @@ let node_process = require("node:process");
|
|
|
3
3
|
node_process = require_chunk.__toESM(node_process);
|
|
4
4
|
//#region deno.json
|
|
5
5
|
var name = "@fedify/vocab-runtime";
|
|
6
|
-
var version = "2.0.
|
|
6
|
+
var version = "2.0.16";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/request.ts
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-BfzoFjgp.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-DEVBwfjq.mjs";
|
|
2
2
|
import { deepStrictEqual } from "node:assert";
|
|
3
3
|
import { test } from "node:test";
|
|
4
4
|
import process from "node:process";
|
|
@@ -14,8 +14,13 @@ async function validatePublicUrl(url) {
|
|
|
14
14
|
const parsed = new URL(url);
|
|
15
15
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsed.protocol}`);
|
|
16
16
|
let hostname = parsed.hostname;
|
|
17
|
-
if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.
|
|
17
|
+
if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.slice(1, -1);
|
|
18
18
|
if (hostname === "localhost") throw new UrlError("Localhost is not allowed");
|
|
19
|
+
const hostnameFamily = isIP(hostname);
|
|
20
|
+
if (hostnameFamily !== 0) {
|
|
21
|
+
validatePublicIpAddress(hostname, hostnameFamily);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
19
24
|
if ("Deno" in globalThis && !isIP(hostname)) {
|
|
20
25
|
if ((await Deno.permissions.query({ name: "net" })).state !== "granted") return;
|
|
21
26
|
}
|
|
@@ -29,7 +34,11 @@ async function validatePublicUrl(url) {
|
|
|
29
34
|
} catch {
|
|
30
35
|
addresses = [];
|
|
31
36
|
}
|
|
32
|
-
for (const { address, family } of addresses)
|
|
37
|
+
for (const { address, family } of addresses) validatePublicIpAddress(address, family);
|
|
38
|
+
}
|
|
39
|
+
function validatePublicIpAddress(address, family) {
|
|
40
|
+
if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
|
|
41
|
+
throw new UrlError(`Invalid or private address: ${address}`);
|
|
33
42
|
}
|
|
34
43
|
function isValidPublicIPv4Address(address) {
|
|
35
44
|
const parts = address.split(".");
|
|
@@ -15,8 +15,13 @@ async function validatePublicUrl(url) {
|
|
|
15
15
|
const parsed = new URL(url);
|
|
16
16
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsed.protocol}`);
|
|
17
17
|
let hostname = parsed.hostname;
|
|
18
|
-
if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.
|
|
18
|
+
if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.slice(1, -1);
|
|
19
19
|
if (hostname === "localhost") throw new UrlError("Localhost is not allowed");
|
|
20
|
+
const hostnameFamily = (0, node_net.isIP)(hostname);
|
|
21
|
+
if (hostnameFamily !== 0) {
|
|
22
|
+
validatePublicIpAddress(hostname, hostnameFamily);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
20
25
|
if ("Deno" in globalThis && !(0, node_net.isIP)(hostname)) {
|
|
21
26
|
if ((await Deno.permissions.query({ name: "net" })).state !== "granted") return;
|
|
22
27
|
}
|
|
@@ -30,7 +35,11 @@ async function validatePublicUrl(url) {
|
|
|
30
35
|
} catch {
|
|
31
36
|
addresses = [];
|
|
32
37
|
}
|
|
33
|
-
for (const { address, family } of addresses)
|
|
38
|
+
for (const { address, family } of addresses) validatePublicIpAddress(address, family);
|
|
39
|
+
}
|
|
40
|
+
function validatePublicIpAddress(address, family) {
|
|
41
|
+
if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
|
|
42
|
+
throw new UrlError(`Invalid or private address: ${address}`);
|
|
34
43
|
}
|
|
35
44
|
function isValidPublicIPv4Address(address) {
|
|
36
45
|
const parts = address.split(".");
|
package/dist/tests/url.test.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_url = require("./url-
|
|
2
|
+
const require_url = require("./url-SR63sukb.cjs");
|
|
3
3
|
let node_assert = require("node:assert");
|
|
4
4
|
let node_test = require("node:test");
|
|
5
5
|
//#region src/url.test.ts
|
|
@@ -9,6 +9,8 @@ let node_test = require("node:test");
|
|
|
9
9
|
await (0, node_assert.rejects)(() => require_url.validatePublicUrl("https://localhost"), require_url.UrlError);
|
|
10
10
|
await (0, node_assert.rejects)(() => require_url.validatePublicUrl("https://127.0.0.1"), require_url.UrlError);
|
|
11
11
|
await (0, node_assert.rejects)(() => require_url.validatePublicUrl("https://[::1]"), require_url.UrlError);
|
|
12
|
+
await (0, node_assert.rejects)(() => require_url.validatePublicUrl("http://[::ffff:7f00:1]/"), require_url.UrlError);
|
|
13
|
+
await require_url.validatePublicUrl("https://[2001:db8::1]");
|
|
12
14
|
});
|
|
13
15
|
(0, node_test.test)("isValidPublicIPv4Address()", () => {
|
|
14
16
|
(0, node_assert.ok)(require_url.isValidPublicIPv4Address("8.8.8.8"));
|
|
@@ -25,6 +27,7 @@ let node_test = require("node:test");
|
|
|
25
27
|
(0, node_assert.ok)(!require_url.isValidPublicIPv6Address("fe80::1"));
|
|
26
28
|
(0, node_assert.ok)(!require_url.isValidPublicIPv6Address("ff00::1"));
|
|
27
29
|
(0, node_assert.ok)(!require_url.isValidPublicIPv6Address("::"));
|
|
30
|
+
(0, node_assert.ok)(!require_url.isValidPublicIPv6Address("::ffff:7f00:1"));
|
|
28
31
|
});
|
|
29
32
|
(0, node_test.test)("expandIPv6Address()", () => {
|
|
30
33
|
(0, node_assert.deepStrictEqual)(require_url.expandIPv6Address("::"), "0000:0000:0000:0000:0000:0000:0000:0000");
|
package/dist/tests/url.test.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as validatePublicUrl, i as isValidPublicIPv6Address, n as expandIPv6Address, r as isValidPublicIPv4Address, t as UrlError } from "./url-
|
|
1
|
+
import { a as validatePublicUrl, i as isValidPublicIPv6Address, n as expandIPv6Address, r as isValidPublicIPv4Address, t as UrlError } from "./url-DftNtd3d.mjs";
|
|
2
2
|
import { deepStrictEqual, ok, rejects } from "node:assert";
|
|
3
3
|
import { test } from "node:test";
|
|
4
4
|
//#region src/url.test.ts
|
|
@@ -8,6 +8,8 @@ test("validatePublicUrl()", async () => {
|
|
|
8
8
|
await rejects(() => validatePublicUrl("https://localhost"), UrlError);
|
|
9
9
|
await rejects(() => validatePublicUrl("https://127.0.0.1"), UrlError);
|
|
10
10
|
await rejects(() => validatePublicUrl("https://[::1]"), UrlError);
|
|
11
|
+
await rejects(() => validatePublicUrl("http://[::ffff:7f00:1]/"), UrlError);
|
|
12
|
+
await validatePublicUrl("https://[2001:db8::1]");
|
|
11
13
|
});
|
|
12
14
|
test("isValidPublicIPv4Address()", () => {
|
|
13
15
|
ok(isValidPublicIPv4Address("8.8.8.8"));
|
|
@@ -24,6 +26,7 @@ test("isValidPublicIPv6Address()", () => {
|
|
|
24
26
|
ok(!isValidPublicIPv6Address("fe80::1"));
|
|
25
27
|
ok(!isValidPublicIPv6Address("ff00::1"));
|
|
26
28
|
ok(!isValidPublicIPv6Address("::"));
|
|
29
|
+
ok(!isValidPublicIPv6Address("::ffff:7f00:1"));
|
|
27
30
|
});
|
|
28
31
|
test("expandIPv6Address()", () => {
|
|
29
32
|
deepStrictEqual(expandIPv6Address("::"), "0000:0000:0000:0000:0000:0000:0000:0000");
|
package/package.json
CHANGED
package/src/url.test.ts
CHANGED
|
@@ -19,6 +19,11 @@ test("validatePublicUrl()", async () => {
|
|
|
19
19
|
await rejects(() => validatePublicUrl("https://localhost"), UrlError);
|
|
20
20
|
await rejects(() => validatePublicUrl("https://127.0.0.1"), UrlError);
|
|
21
21
|
await rejects(() => validatePublicUrl("https://[::1]"), UrlError);
|
|
22
|
+
await rejects(
|
|
23
|
+
() => validatePublicUrl("http://[::ffff:7f00:1]/"),
|
|
24
|
+
UrlError,
|
|
25
|
+
);
|
|
26
|
+
await validatePublicUrl("https://[2001:db8::1]");
|
|
22
27
|
});
|
|
23
28
|
|
|
24
29
|
test("isValidPublicIPv4Address()", () => {
|
|
@@ -37,6 +42,7 @@ test("isValidPublicIPv6Address()", () => {
|
|
|
37
42
|
ok(!isValidPublicIPv6Address("fe80::1")); // link-local
|
|
38
43
|
ok(!isValidPublicIPv6Address("ff00::1")); // multicast
|
|
39
44
|
ok(!isValidPublicIPv6Address("::")); // unspecified
|
|
45
|
+
ok(!isValidPublicIPv6Address("::ffff:7f00:1")); // IPv4-mapped
|
|
40
46
|
});
|
|
41
47
|
|
|
42
48
|
test("expandIPv6Address()", () => {
|
package/src/url.ts
CHANGED
|
@@ -19,11 +19,16 @@ export async function validatePublicUrl(url: string): Promise<void> {
|
|
|
19
19
|
}
|
|
20
20
|
let hostname = parsed.hostname;
|
|
21
21
|
if (hostname.startsWith("[") && hostname.endsWith("]")) {
|
|
22
|
-
hostname = hostname.
|
|
22
|
+
hostname = hostname.slice(1, -1);
|
|
23
23
|
}
|
|
24
24
|
if (hostname === "localhost") {
|
|
25
25
|
throw new UrlError("Localhost is not allowed");
|
|
26
26
|
}
|
|
27
|
+
const hostnameFamily = isIP(hostname);
|
|
28
|
+
if (hostnameFamily !== 0) {
|
|
29
|
+
validatePublicIpAddress(hostname, hostnameFamily);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
27
32
|
if ("Deno" in globalThis && !isIP(hostname)) {
|
|
28
33
|
// If the `net` permission is not granted, we can't resolve the hostname.
|
|
29
34
|
// However, we can safely assume that it cannot gain access to private
|
|
@@ -50,14 +55,18 @@ export async function validatePublicUrl(url: string): Promise<void> {
|
|
|
50
55
|
addresses = [];
|
|
51
56
|
}
|
|
52
57
|
for (const { address, family } of addresses) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
validatePublicIpAddress(address, family);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function validatePublicIpAddress(address: string, family: number): void {
|
|
63
|
+
if (
|
|
64
|
+
family === 4 && isValidPublicIPv4Address(address) ||
|
|
65
|
+
family === 6 && isValidPublicIPv6Address(address)
|
|
66
|
+
) {
|
|
67
|
+
return;
|
|
60
68
|
}
|
|
69
|
+
throw new UrlError(`Invalid or private address: ${address}`);
|
|
61
70
|
}
|
|
62
71
|
|
|
63
72
|
export function isValidPublicIPv4Address(address: string): boolean {
|