@fedify/relay 2.3.2 → 2.3.3

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-JcUVDWBP.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-DVZsnuvg.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-JcUVDWBP.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-DVZsnuvg.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";
@@ -25653,7 +25653,7 @@ const preloadedContexts = {
25653
25653
  } }
25654
25654
  };
25655
25655
  var name = "@fedify/vocab-runtime";
25656
- var version = "2.3.2";
25656
+ var version = "2.3.3";
25657
25657
  const parametersNeedLowerCase = ["rel", "type"];
25658
25658
  const regexpLinkWhitespace = /[\n\r\s\t]/;
25659
25659
  function validateURI(uri) {
@@ -25902,8 +25902,8 @@ function logRequest(logger, request) {
25902
25902
  });
25903
25903
  }
25904
25904
  var UrlError = class extends Error {
25905
- constructor(message) {
25906
- super(message);
25905
+ constructor(message, options) {
25906
+ super(message, options);
25907
25907
  this.name = "UrlError";
25908
25908
  }
25909
25909
  };
@@ -25931,10 +25931,37 @@ async function validatePublicUrl(url) {
25931
25931
  let addresses;
25932
25932
  try {
25933
25933
  addresses = await lookup(hostname, { all: true });
25934
- } catch {
25935
- addresses = [];
25934
+ } catch (error) {
25935
+ throw new UrlError("DNS lookup failed", { cause: error });
25936
25936
  }
25937
- for (const { address, family } of addresses) validatePublicIpAddress(address, family);
25937
+ validateLookupAddresses(addresses);
25938
+ }
25939
+ /**
25940
+ * Validates the IP addresses returned by `node:dns.lookup()`.
25941
+ *
25942
+ * Cloudflare Workers' `node:dns` implementation currently maps every record
25943
+ * in a DNS-over-HTTPS `Answer` array—including CNAME records—to a
25944
+ * `LookupAddress`, even though Node.js specifies that the `address` field must
25945
+ * contain an IPv4 or IPv6 literal. See:
25946
+ * https://github.com/cloudflare/workerd/issues/6886
25947
+ *
25948
+ * Work around that bug by ignoring non-IP entries only when the lookup also
25949
+ * returns at least one actual IP address. This remains fail-closed: a result
25950
+ * containing no IP addresses is rejected, and every returned IP address is
25951
+ * still validated and must be public. This workaround can be revisited once
25952
+ * the Workerd issue is fixed in supported Cloudflare Workers runtimes.
25953
+ *
25954
+ * @internal
25955
+ */
25956
+ function validateLookupAddresses(addresses) {
25957
+ let ipAddressCount = 0;
25958
+ for (const { address } of addresses) {
25959
+ const family = isIP(address);
25960
+ if (family === 0) continue;
25961
+ ipAddressCount++;
25962
+ validatePublicIpAddress(address, family);
25963
+ }
25964
+ if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address");
25938
25965
  }
25939
25966
  function validatePublicIpAddress(address, family) {
25940
25967
  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.3.2",
3
+ "version": "2.3.3",
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.2.0",
53
- "@fedify/fedify": "^2.3.2",
54
- "@fedify/vocab": "2.3.2"
53
+ "@fedify/vocab": "2.3.3",
54
+ "@fedify/fedify": "^2.3.3"
55
55
  },
56
56
  "devDependencies": {
57
57
  "tsdown": "^0.22.0",
58
58
  "typescript": "^6.0.0",
59
59
  "urlpattern-polyfill": "^10.1.0",
60
- "@fedify/vocab-runtime": "^2.3.2"
60
+ "@fedify/vocab-runtime": "^2.3.3"
61
61
  },
62
62
  "scripts": {
63
63
  "build:self": "tsdown",