@fedify/relay 2.2.13 → 2.2.14

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-BFzM7PGw.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-BoqZOOtA.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-BFzM7PGw.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-BoqZOOtA.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";
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
4
4
  import { createRequire } from "node:module";
5
5
  import { getLogger } from "@logtape/logtape";
6
6
  import process$1 from "node:process";
7
- import { lookup } from "node:dns/promises";
7
+ import dns from "node:dns/promises";
8
8
  import { isIP } from "node:net";
9
9
  //#region \0rolldown/runtime.js
10
10
  var __create = Object.create;
@@ -21815,6 +21815,28 @@ var fep_5711_default = { "@context": {
21815
21815
  "@type": "@id"
21816
21816
  }
21817
21817
  } };
21818
+ var fep_7aa9_default = { "@context": {
21819
+ "FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
21820
+ "FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
21821
+ "FeatureRequest": "https://w3id.org/fep/7aa9#FeatureRequest",
21822
+ "FeatureAuthorization": "https://w3id.org/fep/7aa9#FeatureAuthorization",
21823
+ "topic": {
21824
+ "@id": "https://w3id.org/fep/7aa9#topic",
21825
+ "@type": "@id"
21826
+ },
21827
+ "featuredObject": {
21828
+ "@id": "https://w3id.org/fep/7aa9#featuredObject",
21829
+ "@type": "@id"
21830
+ },
21831
+ "canFeature": {
21832
+ "@id": "https://w3id.org/fep/7aa9#canFeature",
21833
+ "@type": "@id"
21834
+ },
21835
+ "featureAuthorization": {
21836
+ "@id": "https://w3id.org/fep/7aa9#featureAuthorization",
21837
+ "@type": "@id"
21838
+ }
21839
+ } };
21818
21840
  var fep_ef61_default = { "@context": {
21819
21841
  "gateways": {
21820
21842
  "@id": "https://w3id.org/fep/ef61/gateways",
@@ -25707,12 +25729,13 @@ const preloadedContexts = {
25707
25729
  "https://w3id.org/fep/5711": fep_5711_default,
25708
25730
  "https://www.w3.org/ns/cid/v1": cid_v1_default,
25709
25731
  "https://w3id.org/fep/ef61": fep_ef61_default,
25732
+ "https://w3id.org/fep/7aa9": fep_7aa9_default,
25710
25733
  "https://join-lemmy.org/context.json": join_lemmy_default,
25711
25734
  "http://joinmastodon.org/ns": joinmastodon_default,
25712
25735
  "https://purl.archive.org/miscellany": miscellany_default
25713
25736
  };
25714
25737
  var name = "@fedify/vocab-runtime";
25715
- var version = "2.2.13";
25738
+ var version = "2.2.14";
25716
25739
  /**
25717
25740
  * Error thrown when fetching a JSON-LD document failed.
25718
25741
  */
@@ -26033,9 +26056,16 @@ var HttpHeaderLink = class HttpHeaderLink {
26033
26056
  }
26034
26057
  };
26035
26058
  var UrlError = class extends Error {
26059
+ /**
26060
+ * The failure category. Defaults to `"disallowed"`.
26061
+ * `"dns"` includes lookup errors and results with no usable IP addresses.
26062
+ * @since 2.0.29
26063
+ */
26064
+ reason;
26036
26065
  constructor(message, options) {
26037
26066
  super(message, options);
26038
26067
  this.name = "UrlError";
26068
+ this.reason = options?.reason ?? "disallowed";
26039
26069
  }
26040
26070
  };
26041
26071
  /**
@@ -26061,9 +26091,12 @@ async function validatePublicUrl(url) {
26061
26091
  }
26062
26092
  let addresses;
26063
26093
  try {
26064
- addresses = await lookup(hostname, { all: true });
26094
+ addresses = await dns.lookup(hostname, { all: true });
26065
26095
  } catch (error) {
26066
- throw new UrlError("DNS lookup failed", { cause: error });
26096
+ throw new UrlError("DNS lookup failed", {
26097
+ cause: error,
26098
+ reason: "dns"
26099
+ });
26067
26100
  }
26068
26101
  validateLookupAddresses(addresses);
26069
26102
  }
@@ -26092,7 +26125,7 @@ function validateLookupAddresses(addresses) {
26092
26125
  ipAddressCount++;
26093
26126
  validatePublicIpAddress(address, family);
26094
26127
  }
26095
- if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address");
26128
+ if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address", { reason: "dns" });
26096
26129
  }
26097
26130
  function validatePublicIpAddress(address, family) {
26098
26131
  if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
@@ -26326,6 +26359,8 @@ async function getRemoteDocument(url, response, fetch) {
26326
26359
  }
26327
26360
  /**
26328
26361
  * Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
26362
+ * At most 20 HTTP redirects and alternate document links are followed in total
26363
+ * per call. Revisiting a URL within that chain throws a {@link FetchError}.
26329
26364
  *
26330
26365
  * The created loader preloads the below frequently used contexts by default
26331
26366
  * (unless `options.skipPreloadedContexts` is set to `true`):
@@ -26337,6 +26372,7 @@ async function getRemoteDocument(url, response, fetch) {
26337
26372
  * - <https://www.w3.org/ns/cid/v1>
26338
26373
  * - <https://w3id.org/security/multikey/v1>
26339
26374
  * - <https://w3id.org/fep/ef61>
26375
+ * - <https://w3id.org/fep/7aa9>
26340
26376
  * - <https://purl.archive.org/socialweb/webfinger>
26341
26377
  * - <http://schema.org/>
26342
26378
  * @param options Options for the document loader.
@@ -26360,7 +26396,11 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
26360
26396
  if (!allowPrivateAddress) try {
26361
26397
  await validatePublicUrl(currentUrl);
26362
26398
  } catch (error) {
26363
- if (error instanceof UrlError) logger.error("Disallowed private URL: {url}", {
26399
+ if (error instanceof UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
26400
+ url: currentUrl,
26401
+ error
26402
+ });
26403
+ else logger.error("Disallowed private URL: {url}", {
26364
26404
  url: currentUrl,
26365
26405
  error
26366
26406
  });
@@ -26398,7 +26438,12 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
26398
26438
  }
26399
26439
  return await load(redirectUrl, options, redirected + 1, visited);
26400
26440
  }
26401
- const result = await getRemoteDocument(currentUrl, response, load);
26441
+ const result = await getRemoteDocument(currentUrl, response, async (alternateUrl) => {
26442
+ options?.signal?.throwIfAborted();
26443
+ if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
26444
+ if (visited.has(alternateUrl)) throw new FetchError(currentUrl, `Redirect loop detected: ${alternateUrl}`);
26445
+ return await load(alternateUrl, options, redirected + 1, visited);
26446
+ });
26402
26447
  span.setAttribute("docloader.document_url", result.documentUrl);
26403
26448
  if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
26404
26449
  return result;
@@ -26414,7 +26459,7 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
26414
26459
  }
26415
26460
  });
26416
26461
  }
26417
- return load;
26462
+ return (url, options) => load(url, options);
26418
26463
  }
26419
26464
  function validateCryptoKey(key, type) {
26420
26465
  if (type != null && key.type !== type) throw new TypeError(`The key is not a ${type} key.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/relay",
3
- "version": "2.2.13",
3
+ "version": "2.2.14",
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.13",
54
- "@fedify/vocab": "2.2.13"
53
+ "@fedify/vocab": "2.2.14",
54
+ "@fedify/fedify": "^2.2.14"
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.13"
60
+ "@fedify/vocab-runtime": "^2.2.14"
61
61
  },
62
62
  "scripts": {
63
63
  "build:self": "tsdown",