@fedify/relay 2.4.6-dev.2837 → 2.4.6

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-MJOSgbbZ.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-C7phGBll.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-MJOSgbbZ.js";
4
+ import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-C7phGBll.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";
@@ -4522,7 +4522,7 @@ const preloadedContexts = {
4522
4522
  } }
4523
4523
  };
4524
4524
  //#endregion
4525
- //#region ../vocab-runtime/dist/url-mWveR5GA.js
4525
+ //#region ../vocab-runtime/dist/url-5tost5FK.js
4526
4526
  var UrlError = class extends Error {
4527
4527
  /**
4528
4528
  * The failure category. Defaults to `"disallowed"`.
@@ -4546,6 +4546,81 @@ function lookupAllAddresses(hostname) {
4546
4546
  return dns.lookup(hostname, { all: true });
4547
4547
  }
4548
4548
  /**
4549
+ * Limits concurrent lookups started by the returned function. A pending
4550
+ * caller can abort before its lookup starts. Once `dns.lookup()` has started,
4551
+ * it cannot be cancelled, so its slot remains occupied until the underlying
4552
+ * lookup settles, even if its caller aborts. This bounds the number of
4553
+ * outstanding getaddrinfo calls made by users of this function.
4554
+ * @internal
4555
+ */
4556
+ function createBoundedLookup(lookup, maxConcurrent = 1) {
4557
+ if (!Number.isInteger(maxConcurrent) || maxConcurrent < 1) throw new RangeError("maxConcurrent must be a positive integer");
4558
+ let active = 0;
4559
+ const waiting = /* @__PURE__ */ new Set();
4560
+ function release() {
4561
+ active--;
4562
+ while (waiting.size > 0) {
4563
+ const next = waiting.values().next().value;
4564
+ waiting.delete(next);
4565
+ next.signal?.removeEventListener("abort", next.onAbort);
4566
+ if (next.signal?.aborted) {
4567
+ next.reject(next.signal.reason);
4568
+ continue;
4569
+ }
4570
+ active++;
4571
+ next.resolve();
4572
+ break;
4573
+ }
4574
+ }
4575
+ function acquire(signal) {
4576
+ signal?.throwIfAborted();
4577
+ if (active < maxConcurrent) {
4578
+ active++;
4579
+ return Promise.resolve();
4580
+ }
4581
+ return new Promise((resolve, reject) => {
4582
+ const entry = {
4583
+ signal,
4584
+ resolve,
4585
+ reject,
4586
+ onAbort() {
4587
+ if (!waiting.delete(entry)) return;
4588
+ signal?.removeEventListener("abort", entry.onAbort);
4589
+ reject(signal?.reason);
4590
+ }
4591
+ };
4592
+ waiting.add(entry);
4593
+ signal?.addEventListener("abort", entry.onAbort, { once: true });
4594
+ if (signal?.aborted) entry.onAbort();
4595
+ });
4596
+ }
4597
+ return async (hostname, signal) => {
4598
+ await acquire(signal);
4599
+ let started = false;
4600
+ try {
4601
+ signal?.throwIfAborted();
4602
+ const pending = lookup(hostname);
4603
+ started = true;
4604
+ pending.then(release, release);
4605
+ if (signal == null) return await pending;
4606
+ let onAbort;
4607
+ const aborted = new Promise((_, reject) => {
4608
+ onAbort = () => reject(signal.reason);
4609
+ signal.addEventListener("abort", onAbort, { once: true });
4610
+ if (signal.aborted) onAbort();
4611
+ });
4612
+ try {
4613
+ return await Promise.race([pending, aborted]);
4614
+ } finally {
4615
+ if (onAbort != null) signal.removeEventListener("abort", onAbort);
4616
+ }
4617
+ } finally {
4618
+ if (!started) release();
4619
+ }
4620
+ };
4621
+ }
4622
+ createBoundedLookup(lookupAllAddresses, 2);
4623
+ /**
4549
4624
  * Checks the parts of a URL that can be validated without resolving it:
4550
4625
  * the protocol, the `localhost` hostname, and IP literal hostnames.
4551
4626
  * @throws {UrlError} If the URL is not allowed.
@@ -4764,7 +4839,7 @@ function matchesIPv6Prefix(address, prefixWords, prefixLength) {
4764
4839
  return true;
4765
4840
  }
4766
4841
  //#endregion
4767
- //#region ../vocab-runtime/dist/public-fetch-ziZ39L5I.js
4842
+ //#region ../vocab-runtime/dist/crypto-key-BGE-FiAL.js
4768
4843
  const grants = /* @__PURE__ */ new WeakMap();
4769
4844
  /**
4770
4845
  * Issues a grant for the given URL's origin and addresses. This does not
@@ -5249,6 +5324,17 @@ function logUnpinned(url) {
5249
5324
  protocol: url.protocol
5250
5325
  });
5251
5326
  }
5327
+ /**
5328
+ * Narrows a {@link CryptoKeyLike} to the ambient `CryptoKey` type, for passing
5329
+ * it to `crypto.subtle` or to APIs that still declare the ambient type.
5330
+ *
5331
+ * This is internal to Fedify and is not exported from the package entry point.
5332
+ * @param key The key to narrow.
5333
+ * @returns The same key, typed as the ambient `CryptoKey`.
5334
+ */
5335
+ function asCryptoKey(key) {
5336
+ return key;
5337
+ }
5252
5338
  //#endregion
5253
5339
  //#region ../../node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/esm/version.js
5254
5340
  const VERSION = "1.9.1";
@@ -26618,7 +26704,7 @@ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
26618
26704
  require_build();
26619
26705
  var import_src = /* @__PURE__ */ __toESM(require_src(), 1);
26620
26706
  var name = "@fedify/vocab-runtime";
26621
- var version = "2.4.6-dev.2837+bb303087";
26707
+ var version = "2.4.6";
26622
26708
  /**
26623
26709
  * Error thrown when fetching a JSON-LD document failed.
26624
26710
  */
@@ -27671,7 +27757,7 @@ constants.reduce((prev, tupple) => {
27671
27757
  */
27672
27758
  async function exportSpki(key) {
27673
27759
  validateCryptoKey(key);
27674
- let pem = a(await crypto.subtle.exportKey("spki", key));
27760
+ let pem = a(await crypto.subtle.exportKey("spki", asCryptoKey(key)));
27675
27761
  pem = (pem.match(/.{1,64}/g) || []).join("\n");
27676
27762
  return `-----BEGIN PUBLIC KEY-----\n${pem}\n-----END PUBLIC KEY-----\n`;
27677
27763
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/relay",
3
- "version": "2.4.6-dev.2837+bb303087",
3
+ "version": "2.4.6",
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.6-dev.2837+bb303087",
51
- "@fedify/vocab": "2.4.6-dev.2837+bb303087"
50
+ "@fedify/fedify": "^2.4.6",
51
+ "@fedify/vocab": "2.4.6"
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.6-dev.2837+bb303087"
57
+ "@fedify/vocab-runtime": "^2.4.6"
58
58
  },
59
59
  "scripts": {
60
60
  "build:self": "tsdown",