@fedify/relay 2.3.2 → 2.3.4

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-CotT7pb3.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-CotT7pb3.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";
@@ -25650,10 +25650,27 @@ const preloadedContexts = {
25650
25650
  "@id": "toot:attributionDomains",
25651
25651
  "@type": "@id"
25652
25652
  }
25653
+ } },
25654
+ "https://purl.archive.org/miscellany": { "@context": {
25655
+ "as": "https://www.w3.org/ns/activitystreams#",
25656
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
25657
+ "Hashtag": "as:Hashtag",
25658
+ "manuallyApprovesFollowers": {
25659
+ "@id": "as:manuallyApprovesFollowers",
25660
+ "@type": "xsd:boolean"
25661
+ },
25662
+ "movedTo": {
25663
+ "@id": "as:movedTo",
25664
+ "@type": "@id"
25665
+ },
25666
+ "sensitive": {
25667
+ "@id": "as:sensitive",
25668
+ "@type": "xsd:boolean"
25669
+ }
25653
25670
  } }
25654
25671
  };
25655
25672
  var name = "@fedify/vocab-runtime";
25656
- var version = "2.3.2";
25673
+ var version = "2.3.4";
25657
25674
  const parametersNeedLowerCase = ["rel", "type"];
25658
25675
  const regexpLinkWhitespace = /[\n\r\s\t]/;
25659
25676
  function validateURI(uri) {
@@ -25902,8 +25919,8 @@ function logRequest(logger, request) {
25902
25919
  });
25903
25920
  }
25904
25921
  var UrlError = class extends Error {
25905
- constructor(message) {
25906
- super(message);
25922
+ constructor(message, options) {
25923
+ super(message, options);
25907
25924
  this.name = "UrlError";
25908
25925
  }
25909
25926
  };
@@ -25931,10 +25948,37 @@ async function validatePublicUrl(url) {
25931
25948
  let addresses;
25932
25949
  try {
25933
25950
  addresses = await lookup(hostname, { all: true });
25934
- } catch {
25935
- addresses = [];
25951
+ } catch (error) {
25952
+ throw new UrlError("DNS lookup failed", { cause: error });
25953
+ }
25954
+ validateLookupAddresses(addresses);
25955
+ }
25956
+ /**
25957
+ * Validates the IP addresses returned by `node:dns.lookup()`.
25958
+ *
25959
+ * Cloudflare Workers' `node:dns` implementation currently maps every record
25960
+ * in a DNS-over-HTTPS `Answer` array—including CNAME records—to a
25961
+ * `LookupAddress`, even though Node.js specifies that the `address` field must
25962
+ * contain an IPv4 or IPv6 literal. See:
25963
+ * https://github.com/cloudflare/workerd/issues/6886
25964
+ *
25965
+ * Work around that bug by ignoring non-IP entries only when the lookup also
25966
+ * returns at least one actual IP address. This remains fail-closed: a result
25967
+ * containing no IP addresses is rejected, and every returned IP address is
25968
+ * still validated and must be public. This workaround can be revisited once
25969
+ * the Workerd issue is fixed in supported Cloudflare Workers runtimes.
25970
+ *
25971
+ * @internal
25972
+ */
25973
+ function validateLookupAddresses(addresses) {
25974
+ let ipAddressCount = 0;
25975
+ for (const { address } of addresses) {
25976
+ const family = isIP(address);
25977
+ if (family === 0) continue;
25978
+ ipAddressCount++;
25979
+ validatePublicIpAddress(address, family);
25936
25980
  }
25937
- for (const { address, family } of addresses) validatePublicIpAddress(address, family);
25981
+ if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address");
25938
25982
  }
25939
25983
  function validatePublicIpAddress(address, family) {
25940
25984
  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.4",
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/fedify": "^2.3.4",
54
+ "@fedify/vocab": "2.3.4"
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.4"
61
61
  },
62
62
  "scripts": {
63
63
  "build:self": "tsdown",