@fedify/relay 2.3.9-dev.2048 → 2.3.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-CVjMkH5Y.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-BK7horLp.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-CVjMkH5Y.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-BK7horLp.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;
@@ -25716,6 +25716,28 @@ const preloadedContexts = {
25716
25716
  },
25717
25717
  "digestMultibase": "https://www.w3.org/ns/credentials/v2#digestMultibase"
25718
25718
  } },
25719
+ "https://w3id.org/fep/7aa9": { "@context": {
25720
+ "FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
25721
+ "FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
25722
+ "FeatureRequest": "https://w3id.org/fep/7aa9#FeatureRequest",
25723
+ "FeatureAuthorization": "https://w3id.org/fep/7aa9#FeatureAuthorization",
25724
+ "topic": {
25725
+ "@id": "https://w3id.org/fep/7aa9#topic",
25726
+ "@type": "@id"
25727
+ },
25728
+ "featuredObject": {
25729
+ "@id": "https://w3id.org/fep/7aa9#featuredObject",
25730
+ "@type": "@id"
25731
+ },
25732
+ "canFeature": {
25733
+ "@id": "https://w3id.org/fep/7aa9#canFeature",
25734
+ "@type": "@id"
25735
+ },
25736
+ "featureAuthorization": {
25737
+ "@id": "https://w3id.org/fep/7aa9#featureAuthorization",
25738
+ "@type": "@id"
25739
+ }
25740
+ } },
25719
25741
  "https://join-lemmy.org/context.json": { "@context": ["https://w3id.org/security/v1", {
25720
25742
  "as": "https://www.w3.org/ns/activitystreams#",
25721
25743
  "lemmy": "https://join-lemmy.org/ns#",
@@ -25783,7 +25805,7 @@ const preloadedContexts = {
25783
25805
  } }
25784
25806
  };
25785
25807
  var name = "@fedify/vocab-runtime";
25786
- var version = "2.3.9-dev.2048+c88fcc8c";
25808
+ var version = "2.3.9";
25787
25809
  /**
25788
25810
  * Error thrown when fetching a JSON-LD document failed.
25789
25811
  */
@@ -26104,9 +26126,16 @@ var HttpHeaderLink = class HttpHeaderLink {
26104
26126
  }
26105
26127
  };
26106
26128
  var UrlError = class extends Error {
26129
+ /**
26130
+ * The failure category. Defaults to `"disallowed"`.
26131
+ * `"dns"` includes lookup errors and results with no usable IP addresses.
26132
+ * @since 2.0.29
26133
+ */
26134
+ reason;
26107
26135
  constructor(message, options) {
26108
26136
  super(message, options);
26109
26137
  this.name = "UrlError";
26138
+ this.reason = options?.reason ?? "disallowed";
26110
26139
  }
26111
26140
  };
26112
26141
  /**
@@ -26132,9 +26161,12 @@ async function validatePublicUrl(url) {
26132
26161
  }
26133
26162
  let addresses;
26134
26163
  try {
26135
- addresses = await lookup(hostname, { all: true });
26164
+ addresses = await dns.lookup(hostname, { all: true });
26136
26165
  } catch (error) {
26137
- throw new UrlError("DNS lookup failed", { cause: error });
26166
+ throw new UrlError("DNS lookup failed", {
26167
+ cause: error,
26168
+ reason: "dns"
26169
+ });
26138
26170
  }
26139
26171
  validateLookupAddresses(addresses);
26140
26172
  }
@@ -26163,7 +26195,7 @@ function validateLookupAddresses(addresses) {
26163
26195
  ipAddressCount++;
26164
26196
  validatePublicIpAddress(address, family);
26165
26197
  }
26166
- if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address");
26198
+ if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address", { reason: "dns" });
26167
26199
  }
26168
26200
  function validatePublicIpAddress(address, family) {
26169
26201
  if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
@@ -26397,6 +26429,8 @@ async function getRemoteDocument(url, response, fetch) {
26397
26429
  }
26398
26430
  /**
26399
26431
  * Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
26432
+ * At most 20 HTTP redirects and alternate document links are followed in total
26433
+ * per call. Revisiting a URL within that chain throws a {@link FetchError}.
26400
26434
  *
26401
26435
  * The created loader preloads the below frequently used contexts by default
26402
26436
  * (unless `options.skipPreloadedContexts` is set to `true`):
@@ -26408,6 +26442,7 @@ async function getRemoteDocument(url, response, fetch) {
26408
26442
  * - <https://www.w3.org/ns/cid/v1>
26409
26443
  * - <https://w3id.org/security/multikey/v1>
26410
26444
  * - <https://w3id.org/fep/ef61>
26445
+ * - <https://w3id.org/fep/7aa9>
26411
26446
  * - <https://purl.archive.org/socialweb/webfinger>
26412
26447
  * - <http://schema.org/>
26413
26448
  * @param options Options for the document loader.
@@ -26431,7 +26466,11 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
26431
26466
  if (!allowPrivateAddress) try {
26432
26467
  await validatePublicUrl(currentUrl);
26433
26468
  } catch (error) {
26434
- if (error instanceof UrlError) logger.error("Disallowed private URL: {url}", {
26469
+ if (error instanceof UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
26470
+ url: currentUrl,
26471
+ error
26472
+ });
26473
+ else logger.error("Disallowed private URL: {url}", {
26435
26474
  url: currentUrl,
26436
26475
  error
26437
26476
  });
@@ -26469,7 +26508,12 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
26469
26508
  }
26470
26509
  return await load(redirectUrl, options, redirected + 1, visited);
26471
26510
  }
26472
- const result = await getRemoteDocument(currentUrl, response, load);
26511
+ const result = await getRemoteDocument(currentUrl, response, async (alternateUrl) => {
26512
+ options?.signal?.throwIfAborted();
26513
+ if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
26514
+ if (visited.has(alternateUrl)) throw new FetchError(currentUrl, `Redirect loop detected: ${alternateUrl}`);
26515
+ return await load(alternateUrl, options, redirected + 1, visited);
26516
+ });
26473
26517
  span.setAttribute("docloader.document_url", result.documentUrl);
26474
26518
  if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
26475
26519
  return result;
@@ -26485,7 +26529,7 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
26485
26529
  }
26486
26530
  });
26487
26531
  }
26488
- return load;
26532
+ return (url, options) => load(url, options);
26489
26533
  }
26490
26534
  function validateCryptoKey(key, type) {
26491
26535
  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.3.9-dev.2048+c88fcc8c",
3
+ "version": "2.3.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.2.0",
53
- "@fedify/fedify": "^2.3.9-dev.2048+c88fcc8c",
54
- "@fedify/vocab": "2.3.9-dev.2048+c88fcc8c"
53
+ "@fedify/fedify": "^2.3.9",
54
+ "@fedify/vocab": "2.3.9"
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.9-dev.2048+c88fcc8c"
60
+ "@fedify/vocab-runtime": "^2.3.9"
61
61
  },
62
62
  "scripts": {
63
63
  "build:self": "tsdown",