@fedify/relay 2.2.0 → 2.2.1

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.
@@ -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-2l1sANDh.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-8I66OnAn.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";
@@ -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-2l1sANDh.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-8I66OnAn.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";
@@ -25579,7 +25579,7 @@ const preloadedContexts = {
25579
25579
  "http://joinmastodon.org/ns": joinmastodon_default
25580
25580
  };
25581
25581
  var name = "@fedify/vocab-runtime";
25582
- var version = "2.2.0";
25582
+ var version = "2.2.1";
25583
25583
  const parametersNeedLowerCase = ["rel", "type"];
25584
25584
  const regexpLinkWhitespace = /[\n\r\s\t]/;
25585
25585
  function validateURI(uri) {
@@ -25840,8 +25840,13 @@ async function validatePublicUrl(url) {
25840
25840
  const parsed = new URL(url);
25841
25841
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsed.protocol}`);
25842
25842
  let hostname = parsed.hostname;
25843
- if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.substring(1, hostname.length - 2);
25843
+ if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.slice(1, -1);
25844
25844
  if (hostname === "localhost") throw new UrlError("Localhost is not allowed");
25845
+ const hostnameFamily = isIP(hostname);
25846
+ if (hostnameFamily !== 0) {
25847
+ validatePublicIpAddress(hostname, hostnameFamily);
25848
+ return;
25849
+ }
25845
25850
  if ("Deno" in globalThis && !isIP(hostname)) {
25846
25851
  if ((await Deno.permissions.query({ name: "net" })).state !== "granted") return;
25847
25852
  }
@@ -25855,7 +25860,11 @@ async function validatePublicUrl(url) {
25855
25860
  } catch {
25856
25861
  addresses = [];
25857
25862
  }
25858
- for (const { address, family } of addresses) if (family === 4 && !isValidPublicIPv4Address(address) || family === 6 && !isValidPublicIPv6Address(address) || family < 4 || family === 5 || family > 6) throw new UrlError(`Invalid or private address: ${address}`);
25863
+ for (const { address, family } of addresses) validatePublicIpAddress(address, family);
25864
+ }
25865
+ function validatePublicIpAddress(address, family) {
25866
+ if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
25867
+ throw new UrlError(`Invalid or private address: ${address}`);
25859
25868
  }
25860
25869
  function isValidPublicIPv4Address(address) {
25861
25870
  const parts = address.split(".");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/relay",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
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.5",
53
- "@fedify/vocab": "2.2.0",
54
- "@fedify/fedify": "^2.2.0"
53
+ "@fedify/vocab": "2.2.1",
54
+ "@fedify/fedify": "^2.2.1"
55
55
  },
56
56
  "devDependencies": {
57
57
  "tsdown": "^0.21.6",
58
58
  "typescript": "^5.9.2",
59
59
  "urlpattern-polyfill": "^10.1.0",
60
- "@fedify/vocab-runtime": "^2.2.0"
60
+ "@fedify/vocab-runtime": "^2.2.1"
61
61
  },
62
62
  "scripts": {
63
63
  "build:self": "tsdown",