@fedify/relay 2.2.7 → 2.2.9

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-Ca7lcriL.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-Ca7lcriL.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";
@@ -21992,6 +21992,23 @@ var joinmastodon_default = { "@context": {
21992
21992
  "@type": "@id"
21993
21993
  }
21994
21994
  } };
21995
+ var miscellany_default = { "@context": {
21996
+ "as": "https://www.w3.org/ns/activitystreams#",
21997
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
21998
+ "Hashtag": "as:Hashtag",
21999
+ "manuallyApprovesFollowers": {
22000
+ "@id": "as:manuallyApprovesFollowers",
22001
+ "@type": "xsd:boolean"
22002
+ },
22003
+ "movedTo": {
22004
+ "@id": "as:movedTo",
22005
+ "@type": "@id"
22006
+ },
22007
+ "sensitive": {
22008
+ "@id": "as:sensitive",
22009
+ "@type": "xsd:boolean"
22010
+ }
22011
+ } };
21995
22012
  var schemaorg_default = { "@context": {
21996
22013
  "type": "@type",
21997
22014
  "id": "@id",
@@ -25576,10 +25593,11 @@ const preloadedContexts = {
25576
25593
  "https://gotosocial.org/ns": gotosocial_default,
25577
25594
  "https://w3id.org/fep/5711": fep_5711_default,
25578
25595
  "https://join-lemmy.org/context.json": join_lemmy_default,
25579
- "http://joinmastodon.org/ns": joinmastodon_default
25596
+ "http://joinmastodon.org/ns": joinmastodon_default,
25597
+ "https://purl.archive.org/miscellany": miscellany_default
25580
25598
  };
25581
25599
  var name = "@fedify/vocab-runtime";
25582
- var version = "2.2.7";
25600
+ var version = "2.2.9";
25583
25601
  const parametersNeedLowerCase = ["rel", "type"];
25584
25602
  const regexpLinkWhitespace = /[\n\r\s\t]/;
25585
25603
  function validateURI(uri) {
@@ -25828,8 +25846,8 @@ function logRequest(logger, request) {
25828
25846
  });
25829
25847
  }
25830
25848
  var UrlError = class extends Error {
25831
- constructor(message) {
25832
- super(message);
25849
+ constructor(message, options) {
25850
+ super(message, options);
25833
25851
  this.name = "UrlError";
25834
25852
  }
25835
25853
  };
@@ -25857,10 +25875,37 @@ async function validatePublicUrl(url) {
25857
25875
  let addresses;
25858
25876
  try {
25859
25877
  addresses = await lookup(hostname, { all: true });
25860
- } catch {
25861
- addresses = [];
25878
+ } catch (error) {
25879
+ throw new UrlError("DNS lookup failed", { cause: error });
25880
+ }
25881
+ validateLookupAddresses(addresses);
25882
+ }
25883
+ /**
25884
+ * Validates the IP addresses returned by `node:dns.lookup()`.
25885
+ *
25886
+ * Cloudflare Workers' `node:dns` implementation currently maps every record
25887
+ * in a DNS-over-HTTPS `Answer` array—including CNAME records—to a
25888
+ * `LookupAddress`, even though Node.js specifies that the `address` field must
25889
+ * contain an IPv4 or IPv6 literal. See:
25890
+ * https://github.com/cloudflare/workerd/issues/6886
25891
+ *
25892
+ * Work around that bug by ignoring non-IP entries only when the lookup also
25893
+ * returns at least one actual IP address. This remains fail-closed: a result
25894
+ * containing no IP addresses is rejected, and every returned IP address is
25895
+ * still validated and must be public. This workaround can be revisited once
25896
+ * the Workerd issue is fixed in supported Cloudflare Workers runtimes.
25897
+ *
25898
+ * @internal
25899
+ */
25900
+ function validateLookupAddresses(addresses) {
25901
+ let ipAddressCount = 0;
25902
+ for (const { address } of addresses) {
25903
+ const family = isIP(address);
25904
+ if (family === 0) continue;
25905
+ ipAddressCount++;
25906
+ validatePublicIpAddress(address, family);
25862
25907
  }
25863
- for (const { address, family } of addresses) validatePublicIpAddress(address, family);
25908
+ if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address");
25864
25909
  }
25865
25910
  function validatePublicIpAddress(address, family) {
25866
25911
  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.9",
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.9",
54
+ "@fedify/vocab": "2.2.9"
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.9"
61
61
  },
62
62
  "scripts": {
63
63
  "build:self": "tsdown",