@fedify/relay 2.0.17 → 2.0.19
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/dist/litepub.test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-
|
|
4
|
+
import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-ovfqt1Qm.js";
|
|
5
5
|
import { MemoryKvStore, signRequest } from "@fedify/fedify";
|
|
6
6
|
import { createRelay } from "@fedify/relay";
|
|
7
7
|
import { Accept, Announce, Create, Delete, Follow, Move, Note, Person, Undo, Update } from "@fedify/vocab";
|
package/dist/mastodon.test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-
|
|
4
|
+
import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-ovfqt1Qm.js";
|
|
5
5
|
import { MemoryKvStore, signRequest } from "@fedify/fedify";
|
|
6
6
|
import { createRelay } from "@fedify/relay";
|
|
7
7
|
import { Create, Delete, Follow, Move, Note, Person, Undo, Update } from "@fedify/vocab";
|
|
@@ -25514,7 +25514,7 @@ const preloadedContexts = {
|
|
|
25514
25514
|
} }
|
|
25515
25515
|
};
|
|
25516
25516
|
var name = "@fedify/vocab-runtime";
|
|
25517
|
-
var version = "2.0.
|
|
25517
|
+
var version = "2.0.19";
|
|
25518
25518
|
const parametersNeedLowerCase = ["rel", "type"];
|
|
25519
25519
|
const regexpLinkWhitespace = /[\n\r\s\t]/;
|
|
25520
25520
|
function validateURI(uri) {
|
|
@@ -25796,29 +25796,137 @@ function validatePublicIpAddress(address, family) {
|
|
|
25796
25796
|
throw new UrlError(`Invalid or private address: ${address}`);
|
|
25797
25797
|
}
|
|
25798
25798
|
function isValidPublicIPv4Address(address) {
|
|
25799
|
-
const parts = address
|
|
25800
|
-
|
|
25801
|
-
|
|
25802
|
-
|
|
25803
|
-
if (first === 169 && second === 254) return false;
|
|
25804
|
-
if (first === 172 && second >= 16 && second <= 31) return false;
|
|
25805
|
-
if (first === 192 && second === 168) return false;
|
|
25806
|
-
return true;
|
|
25799
|
+
const parts = parseIPv4Address(address);
|
|
25800
|
+
if (parts == null) return false;
|
|
25801
|
+
const value = ipv4PartsToNumber(parts);
|
|
25802
|
+
return !nonPublicIPv4Prefixes.some(({ base, prefix }) => matchesIPv4Prefix(value, base, prefix));
|
|
25807
25803
|
}
|
|
25808
25804
|
function isValidPublicIPv6Address(address) {
|
|
25809
|
-
|
|
25810
|
-
if (
|
|
25811
|
-
|
|
25812
|
-
|
|
25805
|
+
const words = parseIPv6Address(address);
|
|
25806
|
+
if (words == null) return false;
|
|
25807
|
+
if (nonPublicIPv6Prefixes.some(({ words: prefixWords, prefix }) => matchesIPv6Prefix(words, prefixWords, prefix))) return false;
|
|
25808
|
+
for (const { extractIPv4, prefix, words: prefixWords } of ipv6WithIPv4Prefixes) {
|
|
25809
|
+
if (!matchesIPv6Prefix(words, prefixWords, prefix)) continue;
|
|
25810
|
+
const ipv4Address = extractIPv4(words);
|
|
25811
|
+
if (ipv4Address != null && !isValidPublicIPv4Address(ipv4Address)) return false;
|
|
25812
|
+
}
|
|
25813
|
+
return true;
|
|
25813
25814
|
}
|
|
25814
25815
|
function expandIPv6Address(address) {
|
|
25815
25816
|
address = address.toLowerCase();
|
|
25817
|
+
const ipv4Delimiter = address.lastIndexOf(":");
|
|
25818
|
+
if (address.includes(".") && ipv4Delimiter >= 0) {
|
|
25819
|
+
const ipv4Parts = parseIPv4Address(address.substring(ipv4Delimiter + 1));
|
|
25820
|
+
if (ipv4Parts == null) return address;
|
|
25821
|
+
const high = (ipv4Parts[0] << 8) + ipv4Parts[1];
|
|
25822
|
+
const low = (ipv4Parts[2] << 8) + ipv4Parts[3];
|
|
25823
|
+
address = address.substring(0, ipv4Delimiter + 1) + high.toString(16) + ":" + low.toString(16);
|
|
25824
|
+
}
|
|
25816
25825
|
if (address === "::") return "0000:0000:0000:0000:0000:0000:0000:0000";
|
|
25817
25826
|
if (address.startsWith("::")) address = "0000" + address;
|
|
25818
25827
|
if (address.endsWith("::")) address = address + "0000";
|
|
25819
25828
|
address = address.replace("::", ":0000".repeat(8 - (address.match(/:/g) || []).length) + ":");
|
|
25820
25829
|
return address.split(":").map((part) => part.padStart(4, "0")).join(":");
|
|
25821
25830
|
}
|
|
25831
|
+
const nonPublicIPv4Prefixes = [
|
|
25832
|
+
ipv4Prefix("0.0.0.0/8", "RFC 6890"),
|
|
25833
|
+
ipv4Prefix("10.0.0.0/8", "RFC 1918"),
|
|
25834
|
+
ipv4Prefix("100.64.0.0/10", "RFC 6598"),
|
|
25835
|
+
ipv4Prefix("127.0.0.0/8", "RFC 1122"),
|
|
25836
|
+
ipv4Prefix("169.254.0.0/16", "RFC 3927"),
|
|
25837
|
+
ipv4Prefix("172.16.0.0/12", "RFC 1918"),
|
|
25838
|
+
ipv4Prefix("192.0.0.0/24", "RFC 6890"),
|
|
25839
|
+
ipv4Prefix("192.0.2.0/24", "RFC 5737"),
|
|
25840
|
+
ipv4Prefix("192.88.99.0/24", "RFC 7526"),
|
|
25841
|
+
ipv4Prefix("192.168.0.0/16", "RFC 1918"),
|
|
25842
|
+
ipv4Prefix("198.18.0.0/15", "RFC 2544"),
|
|
25843
|
+
ipv4Prefix("198.51.100.0/24", "RFC 5737"),
|
|
25844
|
+
ipv4Prefix("203.0.113.0/24", "RFC 5737"),
|
|
25845
|
+
ipv4Prefix("224.0.0.0/4", "RFC 5771"),
|
|
25846
|
+
ipv4Prefix("240.0.0.0/4", "RFC 1112")
|
|
25847
|
+
];
|
|
25848
|
+
const nonPublicIPv6Prefixes = [
|
|
25849
|
+
ipv6Prefix("::/16", "RFC 4291"),
|
|
25850
|
+
ipv6Prefix("2001::/32", "RFC 4380"),
|
|
25851
|
+
ipv6Prefix("2002::/16", "RFC 3056"),
|
|
25852
|
+
ipv6Prefix("64:ff9b:1::/48", "RFC 8215"),
|
|
25853
|
+
ipv6Prefix("fc00::/7", "RFC 4193"),
|
|
25854
|
+
ipv6Prefix("fe80::/10", "RFC 4291"),
|
|
25855
|
+
ipv6Prefix("ff00::/8", "RFC 4291")
|
|
25856
|
+
];
|
|
25857
|
+
const ipv6WithIPv4Prefixes = [{
|
|
25858
|
+
...ipv6Prefix("64:ff9b::/96", "RFC 6052"),
|
|
25859
|
+
extractIPv4: (words) => ipv4FromWords(words[6], words[7])
|
|
25860
|
+
}];
|
|
25861
|
+
function ipv4Prefix(cidr, rfc) {
|
|
25862
|
+
const [address, prefixText] = cidr.split("/");
|
|
25863
|
+
const prefix = parseInt(prefixText, 10);
|
|
25864
|
+
const parts = parseIPv4Address(address);
|
|
25865
|
+
if (parts == null || !Number.isInteger(prefix) || prefix < 0 || prefix > 32) throw new Error(`Invalid IPv4 prefix: ${cidr}`);
|
|
25866
|
+
return {
|
|
25867
|
+
cidr,
|
|
25868
|
+
base: ipv4PartsToNumber(parts),
|
|
25869
|
+
prefix,
|
|
25870
|
+
rfc
|
|
25871
|
+
};
|
|
25872
|
+
}
|
|
25873
|
+
function ipv6Prefix(cidr, rfc) {
|
|
25874
|
+
const [address, prefixText] = cidr.split("/");
|
|
25875
|
+
const prefix = parseInt(prefixText, 10);
|
|
25876
|
+
const words = parseIPv6Address(address);
|
|
25877
|
+
if (words == null || !Number.isInteger(prefix) || prefix < 0 || prefix > 128) throw new Error(`Invalid IPv6 prefix: ${cidr}`);
|
|
25878
|
+
return {
|
|
25879
|
+
cidr,
|
|
25880
|
+
words,
|
|
25881
|
+
prefix,
|
|
25882
|
+
rfc
|
|
25883
|
+
};
|
|
25884
|
+
}
|
|
25885
|
+
function parseIPv4Address(address) {
|
|
25886
|
+
const parts = address.split(".").map((part) => {
|
|
25887
|
+
if (!/^\d+$/.test(part)) return NaN;
|
|
25888
|
+
return parseInt(part, 10);
|
|
25889
|
+
});
|
|
25890
|
+
if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) return null;
|
|
25891
|
+
return parts;
|
|
25892
|
+
}
|
|
25893
|
+
function parseIPv6Address(address) {
|
|
25894
|
+
const parts = expandIPv6Address(address).split(":");
|
|
25895
|
+
if (parts.length !== 8) return null;
|
|
25896
|
+
const words = parts.map((part) => {
|
|
25897
|
+
if (!/^[0-9a-f]{1,4}$/i.test(part)) return NaN;
|
|
25898
|
+
return parseInt(part, 16);
|
|
25899
|
+
});
|
|
25900
|
+
if (words.some((word) => !Number.isInteger(word) || word < 0 || word > 65535)) return null;
|
|
25901
|
+
return words;
|
|
25902
|
+
}
|
|
25903
|
+
function ipv4PartsToNumber(parts) {
|
|
25904
|
+
return parts[0] * 2 ** 24 + parts[1] * 2 ** 16 + parts[2] * 2 ** 8 + parts[3];
|
|
25905
|
+
}
|
|
25906
|
+
function ipv4FromWords(highWord, lowWord) {
|
|
25907
|
+
return [
|
|
25908
|
+
highWord >> 8,
|
|
25909
|
+
highWord & 255,
|
|
25910
|
+
lowWord >> 8,
|
|
25911
|
+
lowWord & 255
|
|
25912
|
+
].join(".");
|
|
25913
|
+
}
|
|
25914
|
+
function matchesIPv4Prefix(address, prefixBase, prefixLength) {
|
|
25915
|
+
const blockSize = 2 ** (32 - prefixLength);
|
|
25916
|
+
return Math.floor(address / blockSize) === Math.floor(prefixBase / blockSize);
|
|
25917
|
+
}
|
|
25918
|
+
function matchesIPv6Prefix(address, prefixWords, prefixLength) {
|
|
25919
|
+
let remaining = prefixLength;
|
|
25920
|
+
for (let i = 0; i < 8 && remaining > 0; i++) if (remaining >= 16) {
|
|
25921
|
+
if (address[i] !== prefixWords[i]) return false;
|
|
25922
|
+
remaining -= 16;
|
|
25923
|
+
} else {
|
|
25924
|
+
const mask = 65535 << 16 - remaining & 65535;
|
|
25925
|
+
if ((address[i] & mask) !== (prefixWords[i] & mask)) return false;
|
|
25926
|
+
remaining = 0;
|
|
25927
|
+
}
|
|
25928
|
+
return true;
|
|
25929
|
+
}
|
|
25822
25930
|
const logger = getLogger([
|
|
25823
25931
|
"fedify",
|
|
25824
25932
|
"runtime",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/relay",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.19",
|
|
4
4
|
"description": "ActivityPub relay support for Fedify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fedify",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@js-temporal/polyfill": "^0.5.1",
|
|
52
52
|
"@logtape/logtape": "^2.0.0",
|
|
53
|
-
"@fedify/
|
|
54
|
-
"@fedify/
|
|
53
|
+
"@fedify/vocab": "2.0.19",
|
|
54
|
+
"@fedify/fedify": "^2.0.19"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"tsdown": "^0.21.6",
|
|
58
58
|
"typescript": "^6.0.0",
|
|
59
59
|
"urlpattern-polyfill": "^10.1.0",
|
|
60
|
-
"@fedify/vocab-runtime": "^2.0.
|
|
60
|
+
"@fedify/vocab-runtime": "^2.0.19"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build:self": "tsdown",
|