@fedify/relay 2.4.0-dev.2155 → 2.4.0-dev.2157

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 "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-MIYz1j-u.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-Co-uPXfa.js";
5
5
  import { MemoryKvStore, signRequest } from "@fedify/fedify";
6
6
  import { createRelay } from "@fedify/relay";
7
7
  import { deepStrictEqual, ok, strictEqual } from "node:assert";
@@ -1,7 +1,7 @@
1
1
  import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-MIYz1j-u.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-Co-uPXfa.js";
5
5
  import { MemoryKvStore, signJsonLd, signRequest } from "@fedify/fedify";
6
6
  import { createRelay } from "@fedify/relay";
7
7
  import { deepStrictEqual, ok, strictEqual } from "node:assert";
package/dist/mod.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference lib="esnext.temporal" />
2
2
  import { Context, KvStore, MessageQueue } from "@fedify/fedify";
3
3
  import { Actor } from "@fedify/vocab";
4
- //#region ../vocab-runtime/dist/docloader-oRpq1nQ8.d.ts
4
+ //#region ../vocab-runtime/dist/docloader-ClQraSWr.d.ts
5
5
  /**
6
6
  * Options for making `User-Agent` string.
7
7
  * @see {@link getUserAgent}
package/dist/mod.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference lib="esnext.temporal" />
2
2
  import { Context, KvStore, MessageQueue } from "@fedify/fedify";
3
3
  import { Actor } from "@fedify/vocab";
4
- //#region ../vocab-runtime/dist/docloader-oRpq1nQ8.d.ts
4
+ //#region ../vocab-runtime/dist/docloader-ClQraSWr.d.ts
5
5
  /**
6
6
  * Options for making `User-Agent` string.
7
7
  * @see {@link getUserAgent}
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { createRequire } from "node:module";
5
5
  import "@fedify/vocab";
6
- import { lookup } from "node:dns/promises";
6
+ import dns from "node:dns/promises";
7
7
  import { isIP } from "node:net";
8
8
  import { getLogger } from "@logtape/logtape";
9
9
  import process$1 from "node:process";
@@ -31,7 +31,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  }) : target, mod));
32
32
  var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
33
33
  //#endregion
34
- //#region ../vocab-runtime/dist/contexts-DoZUIW7y.js
34
+ //#region ../vocab-runtime/dist/contexts-DPuJ4UYL.js
35
35
  const preloadedContexts = {
36
36
  "https://www.w3.org/ns/activitystreams": { "@context": {
37
37
  "@vocab": "_:",
@@ -4328,28 +4328,6 @@ const preloadedContexts = {
4328
4328
  "@type": "@id"
4329
4329
  }
4330
4330
  } },
4331
- "https://w3id.org/fep/7aa9": { "@context": {
4332
- "FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
4333
- "FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
4334
- "FeatureRequest": "https://w3id.org/fep/7aa9#FeatureRequest",
4335
- "FeatureAuthorization": "https://w3id.org/fep/7aa9#FeatureAuthorization",
4336
- "topic": {
4337
- "@id": "https://w3id.org/fep/7aa9#topic",
4338
- "@type": "@id"
4339
- },
4340
- "featuredObject": {
4341
- "@id": "https://w3id.org/fep/7aa9#featuredObject",
4342
- "@type": "@id"
4343
- },
4344
- "canFeature": {
4345
- "@id": "https://w3id.org/fep/7aa9#canFeature",
4346
- "@type": "@id"
4347
- },
4348
- "featureAuthorization": {
4349
- "@id": "https://w3id.org/fep/7aa9#featureAuthorization",
4350
- "@type": "@id"
4351
- }
4352
- } },
4353
4331
  "https://www.w3.org/ns/cid/v1": { "@context": {
4354
4332
  "@protected": true,
4355
4333
  "id": "@id",
@@ -4469,6 +4447,28 @@ const preloadedContexts = {
4469
4447
  },
4470
4448
  "digestMultibase": "https://www.w3.org/ns/credentials/v2#digestMultibase"
4471
4449
  } },
4450
+ "https://w3id.org/fep/7aa9": { "@context": {
4451
+ "FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
4452
+ "FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
4453
+ "FeatureRequest": "https://w3id.org/fep/7aa9#FeatureRequest",
4454
+ "FeatureAuthorization": "https://w3id.org/fep/7aa9#FeatureAuthorization",
4455
+ "topic": {
4456
+ "@id": "https://w3id.org/fep/7aa9#topic",
4457
+ "@type": "@id"
4458
+ },
4459
+ "featuredObject": {
4460
+ "@id": "https://w3id.org/fep/7aa9#featuredObject",
4461
+ "@type": "@id"
4462
+ },
4463
+ "canFeature": {
4464
+ "@id": "https://w3id.org/fep/7aa9#canFeature",
4465
+ "@type": "@id"
4466
+ },
4467
+ "featureAuthorization": {
4468
+ "@id": "https://w3id.org/fep/7aa9#featureAuthorization",
4469
+ "@type": "@id"
4470
+ }
4471
+ } },
4472
4472
  "https://join-lemmy.org/context.json": { "@context": ["https://w3id.org/security/v1", {
4473
4473
  "as": "https://www.w3.org/ns/activitystreams#",
4474
4474
  "lemmy": "https://join-lemmy.org/ns#",
@@ -4536,11 +4536,18 @@ const preloadedContexts = {
4536
4536
  } }
4537
4537
  };
4538
4538
  //#endregion
4539
- //#region ../vocab-runtime/dist/url-CEhi4hb4.js
4539
+ //#region ../vocab-runtime/dist/url-BHZYe8Vu.js
4540
4540
  var UrlError = class extends Error {
4541
+ /**
4542
+ * The failure category. Defaults to `"disallowed"`.
4543
+ * `"dns"` includes lookup errors and results with no usable IP addresses.
4544
+ * @since 2.0.29
4545
+ */
4546
+ reason;
4541
4547
  constructor(message, options) {
4542
4548
  super(message, options);
4543
4549
  this.name = "UrlError";
4550
+ this.reason = options?.reason ?? "disallowed";
4544
4551
  }
4545
4552
  };
4546
4553
  /**
@@ -4566,9 +4573,12 @@ async function validatePublicUrl(url) {
4566
4573
  }
4567
4574
  let addresses;
4568
4575
  try {
4569
- addresses = await lookup(hostname, { all: true });
4576
+ addresses = await dns.lookup(hostname, { all: true });
4570
4577
  } catch (error) {
4571
- throw new UrlError("DNS lookup failed", { cause: error });
4578
+ throw new UrlError("DNS lookup failed", {
4579
+ cause: error,
4580
+ reason: "dns"
4581
+ });
4572
4582
  }
4573
4583
  validateLookupAddresses(addresses);
4574
4584
  }
@@ -4597,7 +4607,7 @@ function validateLookupAddresses(addresses) {
4597
4607
  ipAddressCount++;
4598
4608
  validatePublicIpAddress(address, family);
4599
4609
  }
4600
- if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address");
4610
+ if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address", { reason: "dns" });
4601
4611
  }
4602
4612
  function validatePublicIpAddress(address, family) {
4603
4613
  if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
@@ -26104,7 +26114,7 @@ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
26104
26114
  require_build();
26105
26115
  var import_src = /* @__PURE__ */ __toESM(require_src(), 1);
26106
26116
  var name = "@fedify/vocab-runtime";
26107
- var version = "2.4.0-dev.2155+2ccc5085";
26117
+ var version = "2.4.0-dev.2157+b76e5888";
26108
26118
  /**
26109
26119
  * Error thrown when fetching a JSON-LD document failed.
26110
26120
  */
@@ -26556,6 +26566,8 @@ async function getRemoteDocument(url, response, fetch, options) {
26556
26566
  }
26557
26567
  /**
26558
26568
  * Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
26569
+ * At most 20 HTTP redirects and alternate document links are followed in total
26570
+ * per call. Revisiting a URL within that chain throws a {@link FetchError}.
26559
26571
  *
26560
26572
  * The created loader preloads the below frequently used contexts by default
26561
26573
  * (unless `options.skipPreloadedContexts` is set to `true`):
@@ -26568,6 +26580,7 @@ async function getRemoteDocument(url, response, fetch, options) {
26568
26580
  * - <https://www.w3.org/ns/cid/v1>
26569
26581
  * - <https://w3id.org/security/multikey/v1>
26570
26582
  * - <https://w3id.org/fep/ef61>
26583
+ * - <https://w3id.org/fep/7aa9>
26571
26584
  * - <https://purl.archive.org/socialweb/webfinger>
26572
26585
  * - <http://schema.org/>
26573
26586
  * @param options Options for the document loader.
@@ -26591,7 +26604,11 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
26591
26604
  if (!allowPrivateAddress) try {
26592
26605
  await validatePublicUrl(currentUrl);
26593
26606
  } catch (error) {
26594
- if (error instanceof UrlError) logger[options?.suppressError ? "warn" : "error"]("Disallowed private URL: {url}", {
26607
+ if (error instanceof UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
26608
+ url: currentUrl,
26609
+ error
26610
+ });
26611
+ else logger[options?.suppressError ? "warn" : "error"]("Disallowed private URL: {url}", {
26595
26612
  url: currentUrl,
26596
26613
  error
26597
26614
  });
@@ -26629,7 +26646,12 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
26629
26646
  }
26630
26647
  return await load(redirectUrl, options, redirected + 1, visited);
26631
26648
  }
26632
- const result = await getRemoteDocument(currentUrl, response, load, options);
26649
+ const result = await getRemoteDocument(currentUrl, response, async (alternateUrl) => {
26650
+ options?.signal?.throwIfAborted();
26651
+ if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
26652
+ if (visited.has(alternateUrl)) throw new FetchError(currentUrl, `Redirect loop detected: ${alternateUrl}`);
26653
+ return await load(alternateUrl, options, redirected + 1, visited);
26654
+ }, options);
26633
26655
  span.setAttribute("docloader.document_url", result.documentUrl);
26634
26656
  if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
26635
26657
  return result;
@@ -26645,7 +26667,7 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
26645
26667
  }
26646
26668
  });
26647
26669
  }
26648
- return load;
26670
+ return (url, options) => load(url, options);
26649
26671
  }
26650
26672
  function validateCryptoKey(key, type) {
26651
26673
  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.4.0-dev.2155+2ccc5085",
3
+ "version": "2.4.0-dev.2157+b76e5888",
4
4
  "description": "ActivityPub relay support for Fedify",
5
5
  "keywords": [
6
6
  "Fedify",
@@ -47,14 +47,14 @@
47
47
  "dependencies": {
48
48
  "@logtape/logtape": "^2.2.0",
49
49
  "temporal-polyfill": "^1.0.1",
50
- "@fedify/fedify": "^2.4.0-dev.2155+2ccc5085",
51
- "@fedify/vocab": "2.4.0-dev.2155+2ccc5085"
50
+ "@fedify/fedify": "^2.4.0-dev.2157+b76e5888",
51
+ "@fedify/vocab": "2.4.0-dev.2157+b76e5888"
52
52
  },
53
53
  "devDependencies": {
54
54
  "tsdown": "^0.22.0",
55
55
  "typescript": "^6.0.0",
56
56
  "urlpattern-polyfill": "^10.1.0",
57
- "@fedify/vocab-runtime": "^2.4.0-dev.2155+2ccc5085"
57
+ "@fedify/vocab-runtime": "^2.4.0-dev.2157+b76e5888"
58
58
  },
59
59
  "scripts": {
60
60
  "build:self": "tsdown",