@fedify/relay 2.0.22 → 2.0.23

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-Cwik1BH2.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-B7Fct7HN.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-Cwik1BH2.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-B7Fct7HN.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.22";
25517
+ var version = "2.0.23";
25518
25518
  const parametersNeedLowerCase = ["rel", "type"];
25519
25519
  const regexpLinkWhitespace = /[\n\r\s\t]/;
25520
25520
  function validateURI(uri) {
@@ -25757,8 +25757,8 @@ function logRequest(logger, request) {
25757
25757
  });
25758
25758
  }
25759
25759
  var UrlError = class extends Error {
25760
- constructor(message) {
25761
- super(message);
25760
+ constructor(message, options) {
25761
+ super(message, options);
25762
25762
  this.name = "UrlError";
25763
25763
  }
25764
25764
  };
@@ -25786,10 +25786,37 @@ async function validatePublicUrl(url) {
25786
25786
  let addresses;
25787
25787
  try {
25788
25788
  addresses = await lookup(hostname, { all: true });
25789
- } catch {
25790
- addresses = [];
25789
+ } catch (error) {
25790
+ throw new UrlError("DNS lookup failed", { cause: error });
25791
+ }
25792
+ validateLookupAddresses(addresses);
25793
+ }
25794
+ /**
25795
+ * Validates the IP addresses returned by `node:dns.lookup()`.
25796
+ *
25797
+ * Cloudflare Workers' `node:dns` implementation currently maps every record
25798
+ * in a DNS-over-HTTPS `Answer` array—including CNAME records—to a
25799
+ * `LookupAddress`, even though Node.js specifies that the `address` field must
25800
+ * contain an IPv4 or IPv6 literal. See:
25801
+ * https://github.com/cloudflare/workerd/issues/6886
25802
+ *
25803
+ * Work around that bug by ignoring non-IP entries only when the lookup also
25804
+ * returns at least one actual IP address. This remains fail-closed: a result
25805
+ * containing no IP addresses is rejected, and every returned IP address is
25806
+ * still validated and must be public. This workaround can be revisited once
25807
+ * the Workerd issue is fixed in supported Cloudflare Workers runtimes.
25808
+ *
25809
+ * @internal
25810
+ */
25811
+ function validateLookupAddresses(addresses) {
25812
+ let ipAddressCount = 0;
25813
+ for (const { address } of addresses) {
25814
+ const family = isIP(address);
25815
+ if (family === 0) continue;
25816
+ ipAddressCount++;
25817
+ validatePublicIpAddress(address, family);
25791
25818
  }
25792
- for (const { address, family } of addresses) validatePublicIpAddress(address, family);
25819
+ if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address");
25793
25820
  }
25794
25821
  function validatePublicIpAddress(address, family) {
25795
25822
  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.0.22",
3
+ "version": "2.0.23",
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/fedify": "^2.0.22",
54
- "@fedify/vocab": "2.0.22"
53
+ "@fedify/fedify": "^2.0.23",
54
+ "@fedify/vocab": "2.0.23"
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.22"
60
+ "@fedify/vocab-runtime": "^2.0.23"
61
61
  },
62
62
  "scripts": {
63
63
  "build:self": "tsdown",