@fedify/relay 2.2.7 → 2.2.8

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-BgQwXq2b.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-DZOno-2C.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-BgQwXq2b.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-DZOno-2C.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.7";
25582
+ var version = "2.2.8";
25583
25583
  const parametersNeedLowerCase = ["rel", "type"];
25584
25584
  const regexpLinkWhitespace = /[\n\r\s\t]/;
25585
25585
  function validateURI(uri) {
@@ -25828,8 +25828,8 @@ function logRequest(logger, request) {
25828
25828
  });
25829
25829
  }
25830
25830
  var UrlError = class extends Error {
25831
- constructor(message) {
25832
- super(message);
25831
+ constructor(message, options) {
25832
+ super(message, options);
25833
25833
  this.name = "UrlError";
25834
25834
  }
25835
25835
  };
@@ -25857,10 +25857,37 @@ async function validatePublicUrl(url) {
25857
25857
  let addresses;
25858
25858
  try {
25859
25859
  addresses = await lookup(hostname, { all: true });
25860
- } catch {
25861
- addresses = [];
25860
+ } catch (error) {
25861
+ throw new UrlError("DNS lookup failed", { cause: error });
25862
+ }
25863
+ validateLookupAddresses(addresses);
25864
+ }
25865
+ /**
25866
+ * Validates the IP addresses returned by `node:dns.lookup()`.
25867
+ *
25868
+ * Cloudflare Workers' `node:dns` implementation currently maps every record
25869
+ * in a DNS-over-HTTPS `Answer` array—including CNAME records—to a
25870
+ * `LookupAddress`, even though Node.js specifies that the `address` field must
25871
+ * contain an IPv4 or IPv6 literal. See:
25872
+ * https://github.com/cloudflare/workerd/issues/6886
25873
+ *
25874
+ * Work around that bug by ignoring non-IP entries only when the lookup also
25875
+ * returns at least one actual IP address. This remains fail-closed: a result
25876
+ * containing no IP addresses is rejected, and every returned IP address is
25877
+ * still validated and must be public. This workaround can be revisited once
25878
+ * the Workerd issue is fixed in supported Cloudflare Workers runtimes.
25879
+ *
25880
+ * @internal
25881
+ */
25882
+ function validateLookupAddresses(addresses) {
25883
+ let ipAddressCount = 0;
25884
+ for (const { address } of addresses) {
25885
+ const family = isIP(address);
25886
+ if (family === 0) continue;
25887
+ ipAddressCount++;
25888
+ validatePublicIpAddress(address, family);
25862
25889
  }
25863
- for (const { address, family } of addresses) validatePublicIpAddress(address, family);
25890
+ if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address");
25864
25891
  }
25865
25892
  function validatePublicIpAddress(address, family) {
25866
25893
  if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/relay",
3
- "version": "2.2.7",
3
+ "version": "2.2.8",
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/fedify": "^2.2.7",
54
- "@fedify/vocab": "2.2.7"
53
+ "@fedify/fedify": "^2.2.8",
54
+ "@fedify/vocab": "2.2.8"
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.2.7"
60
+ "@fedify/vocab-runtime": "^2.2.8"
61
61
  },
62
62
  "scripts": {
63
63
  "build:self": "tsdown",